From patchwork Tue Apr 23 09:02:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 162666 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3540942jan; Tue, 23 Apr 2019 02:02:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUrICTrig30Nyo5G7reTyHUsWhjOruYnKzPbSBrawB8Ze2M5cydeG56Z1vACYQEZ6yJCfD X-Received: by 2002:a65:51c8:: with SMTP id i8mr23321329pgq.175.1556010173985; Tue, 23 Apr 2019 02:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556010173; cv=none; d=google.com; s=arc-20160816; b=NXl/v4mP+/CmCHaVqF56gBtn7hAewFp+N2qUiWI+9+Om43hbwDcdx5W20ScchDHnp3 YHI5gjGtGBvSl+pAveOQw7BO8sAZ2yxvBQV2dDVnssACjRJbGopLnO0oFnPUHqWjleF/ 9o6NlOI0voxls0Mf8azk+wd4RO1PuFul/d8hmGdjGL00EbEp1AGbjmOPwIl805wsV151 LQOU7HWKBJ5HJyonE2gkGoiLQih9xwfKKYIcMtmmpDgf3X3+LFer5iodFBzN9JYtjNqz jujfdNeDl26HNiu2yu2X8PDMeX8Z+ujXtC/g5QyItz6Hr60j8KEcp/dT90XSMd3v5xX8 QcHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VS6sWtIBcpW++wv0mYIjcVLqIR7LghrNYUg8/Ta7WWE=; b=PsUcGz1nMYwRD2SzKsqrMCU0gAv+zU6gVG8kkzVS+ZhEpkwOhAZi5/Gw/S7iRXLAvg tgR1mQHQPeOmlotkMXoY14JYRxn197RXfpc+IdExUSe1WJE+3xbiN03E5EkPbV8omuvA aGh46wcZssDYUA4AJSe35uR30XALVm+sb3jjUpOBm0Jxf9CQCOt8tYga7xL4Oim7VYYY FAvFTDfSjIst7pDAaFYvAzZlORtxwGWkTxp4uyilERqjYZRL1cpO9WTwMaGrE2UxraDP JkvHwXJo+IMMLYcRAQqsURTIlm5Zbc3HaRAA7CHEdGRlOlYgWgc3PIJxo+5FmrB34OfI bPMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xbMqCO6z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si16627421pfo.49.2019.04.23.02.02.53; Tue, 23 Apr 2019 02:02:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xbMqCO6z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727161AbfDWJCw (ORCPT + 30 others); Tue, 23 Apr 2019 05:02:52 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39192 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbfDWJCr (ORCPT ); Tue, 23 Apr 2019 05:02:47 -0400 Received: by mail-wr1-f68.google.com with SMTP id a9so1578396wrp.6 for ; Tue, 23 Apr 2019 02:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VS6sWtIBcpW++wv0mYIjcVLqIR7LghrNYUg8/Ta7WWE=; b=xbMqCO6zj/632iEPHiWSPhZGMBKBsDiZrQeirlU04yPkWiApOm24k7zLVyG5N1k4ZS fRf30jGYSKoSdVluBAAxFRnrxdV1uMkUIBU9ZIlhwO2NPoKtjJOBE3/L2tp34JpdjWTu uCQaT5k/IM10+QaOAd/NEVTX+lTW9dI8CMNXUPv6AecORRQres0ZqV6wz7G4tdiU8N8X M+FxI87l3FQXlJdI8UvEkd3dSwBOCoPsKBLbbqZmobuUT8Qqn2SHZEjYsV9HXy49HzGq 1i4rmkfEokMShkmMUvIf4jkscOg9xyIImE3i+kurOVotZf3Qwu5sPLb907IzKSLd5JDt RBMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VS6sWtIBcpW++wv0mYIjcVLqIR7LghrNYUg8/Ta7WWE=; b=NNsTUIjsPwphr0CzQN0KkZbjklzuqMofYNR2omovvaaOWDvty8PXdVCVK6R/5lmw2n 1TfRWXjWshKWYqFq1IiRbEpZkq4rydnrUI/fOE3uCeft5PuK7u5oT7xGUJ5oUxS/Lv9n P7aSl9lE24rB4m17fejIghPf7nikdy5TWDqxyKnZPjVuXW+FlDYBKaK2p3WLkvESdoyX Og+y1WN374O0nZskUWwPP/1s+Zi4AxINekqCvsH0QMomIei3FEJRAYum8EN44jW0D2CO SdoZCVn9lcTiMkvLvWK7/Mjaq4/aMwAqwT7oh6NmaAGUXsnirOLfgldyjODVbf/vG2vp 0qVA== X-Gm-Message-State: APjAAAVnZmuddhycYIGQyHr13hhKWJfGRtaX9T+NAAhv6YqD7EWaKBqQ fJHkUWKJyZfsv3qpCutAc1mFuQ== X-Received: by 2002:a5d:6604:: with SMTP id n4mr13301965wru.42.1556010165874; Tue, 23 Apr 2019 02:02:45 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z23sm12361894wma.0.2019.04.23.02.02.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 02:02:45 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH v2 1/7] mmc: meson-gx: remove open coded read with timeout Date: Tue, 23 Apr 2019 11:02:29 +0200 Message-Id: <20190423090235.17244-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423090235.17244-1-jbrunet@baylibre.com> References: <20190423090235.17244-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is already a function available to poll a register until a condition is met. Let's use it instead of open coding it. Reviewed-by: Martin Blumenstingl Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 2eba507790e4..2deeacc051b1 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1100,7 +1101,6 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) static int meson_mmc_wait_desc_stop(struct meson_host *host) { - int loop; u32 status; /* @@ -1110,20 +1110,10 @@ static int meson_mmc_wait_desc_stop(struct meson_host *host) * If we don't confirm the descriptor is stopped, it might raise new * IRQs after we have called mmc_request_done() which is bad. */ - for (loop = 50; loop; loop--) { - status = readl(host->regs + SD_EMMC_STATUS); - if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) - udelay(100); - else - break; - } - if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) { - dev_err(host->dev, "Timed out waiting for host to stop\n"); - return -ETIMEDOUT; - } - - return 0; + return readl_poll_timeout(host->regs + SD_EMMC_STATUS, status, + !(status & (STATUS_BUSY | STATUS_DESC_BUSY)), + 100, 5000); } static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) From patchwork Tue Apr 23 09:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 162671 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3541327jan; Tue, 23 Apr 2019 02:03:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSKynzCWcSoMbBIpdD+sKZyM0lNtDNQLi7a0xN00TgbpxmYo3EMw+MbD0oMoQYzGoNC4ao X-Received: by 2002:a63:180a:: with SMTP id y10mr23340362pgl.450.1556010198406; Tue, 23 Apr 2019 02:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556010198; cv=none; d=google.com; s=arc-20160816; b=nl05ANbGQioG3YKBy5nk3AchjBtKkGkgVdHFUBcuRvs1rhLspcG9hAbvNFNTv3QhhO OVErZ2OVNjBHy46Zg0OD5i0qOWMpyG9z8cZpLO4EaL1r2iyiLpXZYp1Ouo393rz/De9s 8LVzSaz0iJjRJIWfBj+XjWUZUeqspaLxo2SuVWCK9K675alUx8uuXVKrXd17If2WsQB2 pFMmFzLxBh26UaUc5w2eImxqoteiRaGobzjIDMLrKH46UV2a+dOe0GbhpZ7ReqNVQ4sD M2VGjvftAAYqN6RdCKpRIejiSv1IHTaQCzy8xHwAmwjHvlHca4+gYisANZ2D4aIf7GJm wjBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w1pW48pbPFvZbhJkwoKxPVapl0Fl2yGEGKo5zLNjkdw=; b=SfGDZgPkeKoQyqB6heqse5WILsQTYYJFoNB51hZHPmBqMelth+61tRwII+gVojv/+I Qmy3lb3W5lb2XEI6B53k/raheSSvRH1SwWUuNx3vsIaQr4qtfUUXiKdXWODCuBnJXhVk 33jhGkSwJX0dzEwk73tC5DWXYfW/nAT4fRV3Uz4XBuQAwmhh9y/K1YSO/MpiaGTsoB7B sIL/CBBxPciw5WXUc3/Wypo6nLDh0pDtGoP93LWaVVshinXCWxlERPi82R4nzo2HNAbR aTZ7FyNflCpE4FwpCd56Z+V1vktVbrz+QrSyRevMx7/FYPTwggVZbPcX8ROcUEw10nCs +Eag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0CRtXmBu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si2022200pgl.571.2019.04.23.02.03.18; Tue, 23 Apr 2019 02:03:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0CRtXmBu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727114AbfDWJCv (ORCPT + 30 others); Tue, 23 Apr 2019 05:02:51 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35028 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfDWJCs (ORCPT ); Tue, 23 Apr 2019 05:02:48 -0400 Received: by mail-wm1-f67.google.com with SMTP id y197so17794582wmd.0 for ; Tue, 23 Apr 2019 02:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w1pW48pbPFvZbhJkwoKxPVapl0Fl2yGEGKo5zLNjkdw=; b=0CRtXmBu8o8LrKmAYE/sKRtheqjZAWj3UgypeINdpuSrpGNjH3EQKerJ+HyxR/+FTG Zp5uBMcs29yn/DaNQUqyYDg/IkVtX4U/o7gddZfA9w/7rS6uCFRnJ2s2ubM8u30AGIi2 clgE2Gwb8zHddinILtYdLIce/IiGEU68JPc2mZVYXnsPx1kwuNJDWDfDmWdh9Qqy/hdV F3617T0lI1T+MlUHawgS2qHBdqSYcIX8t9GSHuQNXtmDqF1dp328G+t/YcxMGZ1pDlvG Ac4kyDTTAugznAgDZXTKGRnVqxV1RPTHDaxU4CK5ZCNg6LPpLcxISp8yVsyv//Dz+hYE RRfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w1pW48pbPFvZbhJkwoKxPVapl0Fl2yGEGKo5zLNjkdw=; b=bBqZ7a6nMUjAupLCRceIRHqWWvg/VR2Cdut8jq4ZN8M3G7b8E6EQqJrFkATDECikAG L3BLJlNwgiEzTTTPxRo2Iap2WV039AAewYm2nrJnGjR0eFxsCn/Nwsaw78NcZg3BZIaN n0titE5HIlTF4xMda6hIZW7DN8W3ZhQiMaSAvvubLN2cLIvX7er0m1H7WDSbbopamIBp yhBVLC/KSx+X4a7NXBqVxCJs/i83JMG+HRyx5lIMbDeYutqRBTkOfeO2hm03vZd3D703 XqN6NgC9gIWGpsehrkDVxStto8u6KTN9c1NHHk4retl7n0zfvUsGU22ibDDnczcOT4Zj wnCw== X-Gm-Message-State: APjAAAXYp5Ij9E96aLsFjbIpIqvvvQpL8gj2LjP3fpwZhGISVAOF3ub4 9kXPvFOgxzXEurQzgQ+6P2O9p+9jWEg= X-Received: by 2002:a7b:c1cf:: with SMTP id a15mr1556030wmj.44.1556010166990; Tue, 23 Apr 2019 02:02:46 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z23sm12361894wma.0.2019.04.23.02.02.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 02:02:46 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] mmc: meson-gx: ack only raised irq Date: Tue, 23 Apr 2019 11:02:30 +0200 Message-Id: <20190423090235.17244-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423090235.17244-1-jbrunet@baylibre.com> References: <20190423090235.17244-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is merely a clean up. It makes sense to only ack raised irqs instead of acking everything all the time. Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 2deeacc051b1..8b690ecde4c5 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -1082,9 +1082,6 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) } out: - /* ack all enabled interrupts */ - writel(irq_en, host->regs + SD_EMMC_STATUS); - if (cmd->error) { /* Stop desc in case of errors */ u32 start = readl(host->regs + SD_EMMC_START); @@ -1096,6 +1093,9 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) if (ret == IRQ_HANDLED) meson_mmc_request_done(host->mmc, cmd->mrq); + /* ack all raised interrupts */ + writel(status, host->regs + SD_EMMC_STATUS); + return ret; } From patchwork Tue Apr 23 09:02:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 162672 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3541388jan; Tue, 23 Apr 2019 02:03:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6/b6z65sw+5pxfTJsmv+U9GO3p6T8jzZW4mygPhm9DlZVtwa9qE5kJQ/tq8VE5QDsfvrC X-Received: by 2002:a63:84c7:: with SMTP id k190mr23485012pgd.255.1556010202067; Tue, 23 Apr 2019 02:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556010202; cv=none; d=google.com; s=arc-20160816; b=kEhqZgdi4bXTVvCbOVwtFWP8U6r86A3nqCYMNlrOa0cGZPxrF8h32I5xuQWtij899M ymwY/xhTkylULm16dJHZtvEWafZuPVbV1OJQcyxtIuTaCCo/8BE3+oMDNfh2qHWr8Y2p 42fEPWmiAavjBlgDajLss2CvJmgqC6Pl33SvSNyisuYxVeudDtMociU1xLBmjBl/Oj7T IPxMT+bSlG8XUCueykcKmXuuWDxC6q2njaHcvLHtt/CX3mBrCY2RaNsNEGfsMefEVQIn Tw2jCzA+HW285DQ53S6fVLTr/znTJRxF347NWkRXbRXktlyx/9eTMXPr8u5pIjSw0f/4 r9Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A9mkQOCOyKUJCXFL3UmoX1uExjUUiwIU7JlFlpoGkgA=; b=hGtKxnGIq4Vowv+qTVNKj5I3OXTgrFJj/QtPfeTwkXpnVeADG0r4K2lPzgzfeNpgde lQVlzstVDZ9N0e9FZNVgvQ2ix6YXQ8LZ4JpA/orKegXQuyaVVxafZdNR2uLRz2+JsM+N ObiZXzAqgVRpqkdmLR0ywt/tST8x6CoikC7gR7ggGO+g04EvQbYoZQGtcbvQv4QSC30x EBZj7gYSqxpIeO21tXcBXhsnSW5UhQXfXCgcpyKk+A6yiNRgS6M6JxVGrID58fdn555U uPjV/k1/G8aPG9Z2QXEtnnANMiHdSBBnL183HUicD8N4SYstknaLKpuuXbCyVPHgJjnC cJog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=qypmTfDB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si2022200pgl.571.2019.04.23.02.03.21; Tue, 23 Apr 2019 02:03:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=qypmTfDB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbfDWJCv (ORCPT + 30 others); Tue, 23 Apr 2019 05:02:51 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39453 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbfDWJCt (ORCPT ); Tue, 23 Apr 2019 05:02:49 -0400 Received: by mail-wm1-f66.google.com with SMTP id n25so17767391wmk.4 for ; Tue, 23 Apr 2019 02:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A9mkQOCOyKUJCXFL3UmoX1uExjUUiwIU7JlFlpoGkgA=; b=qypmTfDBnIggohr4oTcl1DKf+xQhzrv43qq64kdnrsD5FiChu544D2Z/Q6kDPHyMyE YFr/zzUgt/cRfM02ECYDfFz8ANOaKMQZfoVXdk9Szf/L6Cx0N9zY2TEjP59uvaeYm7Xe A2CteyW3kkGwfrZsA4lxmp7pNmDnZa0Dxc6ynlfMeN+WQnIU9RTYJf2jmZwkBvh4Q5On KFGW76zK0Hd1RFqBtWmy3Cnbt4+pcMfuveWDl9PPOIPhjtMTOb47nFGhA9qIhfKCfhuM B65nCNoiNI2pZpuw+HMJzBH/Wf66saIli5qI8RnEFtEJ6/oYDs9hQEJom43JcDBIWrV3 EKig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A9mkQOCOyKUJCXFL3UmoX1uExjUUiwIU7JlFlpoGkgA=; b=nU6HlsYbxPfTjnJkg3ueG3UBV4tvTRQyguP6uOsjRyNpUaQlPMh7Ukry9UEP06Ins5 r3y6vmPF86+6ih1RM6NoSrqSqQ6VF+y4qa1ujQTQMhQXtCPckfDo/z1UUUw97mWSRo/N GNBaI6xRf8E/ewYsZe+TyoTwYDZ5gWHKqOKsksjqeFeJdqiTWvCqdo+Pi+yHbBSRaSr1 2ZcTUnq2v6qcbKmI6U/BWyATQeYwBI4wR66q61QYByfyzM48+wZ3WSJ6LqiqJ3fHUQAj 9zfV7pR5WvPgcijhBOCghU5ty2abi5RmkpCk1BSALAEIHTuTZpCVsy6o6hrymmp3wcfJ oahg== X-Gm-Message-State: APjAAAXQ7Jp5Yft5wddyNfR1KbHVubzHYgodvn8R1fjDgY6nIt0+G5YF wDvV3Kw568XdL3DJq+xxOpkyTA== X-Received: by 2002:a1c:ed12:: with SMTP id l18mr1517688wmh.13.1556010168140; Tue, 23 Apr 2019 02:02:48 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z23sm12361894wma.0.2019.04.23.02.02.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 02:02:47 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] mmc: meson-gx: correct irq flag Date: Tue, 23 Apr 2019 11:02:31 +0200 Message-Id: <20190423090235.17244-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423090235.17244-1-jbrunet@baylibre.com> References: <20190423090235.17244-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no reason for another device to request the MMC irq. It should only be used the MMC device, so remove IRQ_SHARED and replace by IRQ_ONESHOT as we don't the irq to fire again until the irq thread is done Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 8b690ecde4c5..3df50b53f834 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -1328,7 +1328,7 @@ static int meson_mmc_probe(struct platform_device *pdev) host->regs + SD_EMMC_IRQ_EN); ret = request_threaded_irq(host->irq, meson_mmc_irq, - meson_mmc_irq_thread, IRQF_SHARED, + meson_mmc_irq_thread, IRQF_ONESHOT, dev_name(&pdev->dev), host); if (ret) goto err_init_clk; From patchwork Tue Apr 23 09:02:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 162670 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3541081jan; Tue, 23 Apr 2019 02:03:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDeYgpmvYGGM4Bv4uMtcrdqYnAcl/gsSXlKw25wFb/8bZsaWtSjn/RV7V7G7uPcnOVHiez X-Received: by 2002:a63:7d0a:: with SMTP id y10mr23271634pgc.292.1556010183656; Tue, 23 Apr 2019 02:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556010183; cv=none; d=google.com; s=arc-20160816; b=ihXNVNKavv/Nf3jcCbeMqOGTqfyJ3n7utObHUAd0tsD5DNLtNfwtG6gvPUlChuAitb HQljBKK/ezzkUEhdhs4kALO3T8ti6HN2NE6gFmQ90qhHSgpUEjrOZltCEEoniReKcp8b S01H1Kpi+kx2ssglHldSBDKZT23EU6EnwftuY1rsukuDG+YIyKgTFl6cNZR0Qpm3zu9z bF6LQJlfpD4nXevTC1YWmu5cy7B4ls6fUX2XOZoDkbDnT1BAEr3OvkAhuin6A7zeMFXJ +cPvCUVpoV9RbLwy8TXVHiXW9f/Mcz6+kYGC8s9GUt9McWdEDL0bVa0O4B1zPR+yKFPP xEHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7O3wIgqarfFHawq5yu8xhv0dh+R+qxDhpOLDHXRq0pw=; b=W8mkS8Pe/6xDD07Z49Y2fPe6QE97SYB401zVfLtqhPYOUs8MfFeeNY4KHkM3kc9U0c 6jgOKiv6KO5ka8ivt+nrTTDaGgL9hslFWmS+g1bty3YV0VWC2Jd6NBMeutq48P5X9SEJ EHMW2ivn43f0CvGlXxofma4MfjlyxFJO81OlHRZad4hQWuFQhwr29bIk5J40DL/L3Jns R6WnvB2x19kullONhAL//N0J40MjXpHAEboD1mlKoCaccksJeTLMIeVsXZOdoSMkRspO ZVdG67n5Hzoy0bE+a2EwU9RFpHDzNCs3yWzG1HRI8Ml1IZATS3UiGUZdYLRmg/wUHqF+ kgHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=EYXX0DSB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si14920910plk.297.2019.04.23.02.03.03; Tue, 23 Apr 2019 02:03:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=EYXX0DSB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727224AbfDWJC4 (ORCPT + 30 others); Tue, 23 Apr 2019 05:02:56 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35537 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727162AbfDWJCx (ORCPT ); Tue, 23 Apr 2019 05:02:53 -0400 Received: by mail-wr1-f66.google.com with SMTP id o12so15839172wrn.2 for ; Tue, 23 Apr 2019 02:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7O3wIgqarfFHawq5yu8xhv0dh+R+qxDhpOLDHXRq0pw=; b=EYXX0DSB5uuxcp29aYUMyf76vuVTa5lzw+kKasn1gcmLgWBtCrDk0cSDcZxW/55KU2 XHKRJ8jLLxXRxyxmpi53+rkruleKq+q3ETmvvTrLgeSFPu3naAY+qm7PgJzXGsD5FBb4 1Rx5XqaTuLY9vZKEcUNn7l8q1Sfxx7T9c487vN702ySJKtfkvWV+DOuOmB0fAz1mzUSY 9dNGhVdXFsuFkCqn5U473kwRsiSOXTHcrzzb005cZ6yM5S0D9swNfiHl/6LPjui+SxBx ltunbGnn7TvgMx6z8bvBicacKIwgZRdDZIq0WjSjr7YssZQZ6I/ayD1gikaEB+itIIJK h//Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7O3wIgqarfFHawq5yu8xhv0dh+R+qxDhpOLDHXRq0pw=; b=VgjPFtdYDFBlm4YhPNOZ37Wj/l42cN28rgNp6YqlJpePZYuTL0/n1wJTUvtv+P+Clj f9Dc0aqxkzMCH7IOmv9fQKw7whmD3q0OU09gnwrR7WWGZDeUY7wE33Izpslt1prPdmTY NVTzZ+/fZWlxw8Zw/OaTiAePRd9/cINelcPyQq1EgZzT5f0Y0pFKrP8+LNCg+bIwKAb5 kc98qeowq7c7vjcahGPmUiywUcsZfqwH79AyH/TxJ03QLJNAJnCAKkMU8gJQUPWscPUS S2PUbZUknOAZxvbdcmtWfqWNc9onsLTVd2+mzLGpSfdI81yMw03jZ74X6SHkzyPzLtvN 1mmg== X-Gm-Message-State: APjAAAXWvo9quHo8f9tBE9frJFyKJG3jkus85dA6H+hzwJSV+L8k+xxp OZL3sKJkuM1XVVsPZPzLswuW4A== X-Received: by 2002:adf:eb87:: with SMTP id t7mr17162388wrn.39.1556010171982; Tue, 23 Apr 2019 02:02:51 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z23sm12361894wma.0.2019.04.23.02.02.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 02:02:50 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] mmc: meson-gx: avoid clock glitch when switching to DDR modes Date: Tue, 23 Apr 2019 11:02:33 +0200 Message-Id: <20190423090235.17244-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423090235.17244-1-jbrunet@baylibre.com> References: <20190423090235.17244-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Activating DDR in the Amlogic mmc controller, among other things, will divide the output clock by 2. So by activating it with clock on, we are creating a glitch on the output. Instead, let's deal with DDR when the clock output is off, when setting the clock. Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 73 +++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 30 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 118f09da8dfb..0454021c9ff5 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -169,6 +169,7 @@ struct meson_host { struct clk *rx_clk; struct clk *tx_clk; unsigned long req_rate; + bool ddr; struct pinctrl *pinctrl; struct pinctrl_state *pins_default; @@ -384,16 +385,6 @@ static void meson_mmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, mmc_get_dma_dir(data)); } -static bool meson_mmc_timing_is_ddr(struct mmc_ios *ios) -{ - if (ios->timing == MMC_TIMING_MMC_DDR52 || - ios->timing == MMC_TIMING_UHS_DDR50 || - ios->timing == MMC_TIMING_MMC_HS400) - return true; - - return false; -} - /* * Gating the clock on this controller is tricky. It seems the mmc clock * is also used by the controller. It may crash during some operation if the @@ -430,36 +421,41 @@ static void meson_mmc_clk_ungate(struct meson_host *host) writel(cfg, host->regs + SD_EMMC_CFG); } -static int meson_mmc_clk_set(struct meson_host *host, struct mmc_ios *ios) +static int meson_mmc_clk_set(struct meson_host *host, unsigned long rate, + bool ddr) { struct mmc_host *mmc = host->mmc; - unsigned long rate = ios->clock; int ret; u32 cfg; - /* DDR modes require higher module clock */ - if (meson_mmc_timing_is_ddr(ios)) - rate <<= 1; - /* Same request - bail-out */ - if (host->req_rate == rate) + if (host->ddr == ddr && host->req_rate == rate) return 0; /* stop clock */ meson_mmc_clk_gate(host); host->req_rate = 0; + mmc->actual_clock = 0; - if (!rate) { - mmc->actual_clock = 0; - /* return with clock being stopped */ + /* return with clock being stopped */ + if (!rate) return 0; - } /* Stop the clock during rate change to avoid glitches */ cfg = readl(host->regs + SD_EMMC_CFG); cfg |= CFG_STOP_CLOCK; writel(cfg, host->regs + SD_EMMC_CFG); + if (ddr) { + /* DDR modes require higher module clock */ + rate <<= 1; + cfg |= CFG_DDR; + } else { + cfg &= ~CFG_DDR; + } + writel(cfg, host->regs + SD_EMMC_CFG); + host->ddr = ddr; + ret = clk_set_rate(host->mmc_clk, rate); if (ret) { dev_err(host->dev, "Unable to set cfg_div_clk to %lu. ret=%d\n", @@ -471,12 +467,14 @@ static int meson_mmc_clk_set(struct meson_host *host, struct mmc_ios *ios) mmc->actual_clock = clk_get_rate(host->mmc_clk); /* We should report the real output frequency of the controller */ - if (meson_mmc_timing_is_ddr(ios)) + if (ddr) { + host->req_rate >>= 1; mmc->actual_clock >>= 1; + } dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock); - if (ios->clock != mmc->actual_clock) - dev_dbg(host->dev, "requested rate was %u\n", ios->clock); + if (rate != mmc->actual_clock) + dev_dbg(host->dev, "requested rate was %lu\n", rate); /* (re)start clock */ meson_mmc_clk_ungate(host); @@ -750,6 +748,25 @@ static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); } +static int meson_mmc_prepare_ios_clock(struct meson_host *host, + struct mmc_ios *ios) +{ + bool ddr; + + switch (ios->timing) { + case MMC_TIMING_MMC_DDR52: + case MMC_TIMING_UHS_DDR50: + ddr = true; + break; + + default: + ddr = false; + break; + } + + return meson_mmc_clk_set(host, ios->clock, ddr); +} + static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct meson_host *host = mmc_priv(mmc); @@ -818,16 +835,12 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) val = readl(host->regs + SD_EMMC_CFG); val &= ~CFG_BUS_WIDTH_MASK; val |= FIELD_PREP(CFG_BUS_WIDTH_MASK, bus_width); + writel(val, host->regs + SD_EMMC_CFG); - val &= ~CFG_DDR; - if (meson_mmc_timing_is_ddr(ios)) - val |= CFG_DDR; - - err = meson_mmc_clk_set(host, ios); + err = meson_mmc_prepare_ios_clock(host, ios); if (err) dev_err(host->dev, "Failed to set clock: %d\n,", err); - writel(val, host->regs + SD_EMMC_CFG); dev_dbg(host->dev, "SD_EMMC_CFG: 0x%08x\n", val); } From patchwork Tue Apr 23 09:02:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 162668 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3541035jan; Tue, 23 Apr 2019 02:02:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwm8faPxZC1F6R1KqV37LNfMDH+HXGVxPWZyz6M0DAPpnazQkRSX8inVM96J7QhtcR7J6LL X-Received: by 2002:a17:902:2c01:: with SMTP id m1mr25741898plb.22.1556010179295; Tue, 23 Apr 2019 02:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556010179; cv=none; d=google.com; s=arc-20160816; b=aq61wR9qekhHxRtx9OYRqnvP8tN4109HCya69g4gcENmucpPEes5J1Tk/+VY4b0dd7 kLe2IAAA7eOQk2fKXv7UyXBKmbWc/0cGyScTVypvNjrGenE8ycTpA6f2fuXbMfE9rTBw SbOXRnJ6BSvzP5DWwtWYjr/q9KCB5doOkHBTwrneCsR3OIDR+I/suhhOfqu5DjDpWyAD 2VP9Pp/4gq5rVzfY5OYRjiXwV00pfF6PUdVg4eAi1Pl8o5zvTorj9xuONaNhhbg5u1NS 6HJL8LufFe9uHrW38sgE+hIV0IsR859Zz6HS1JxCNJoCc4mt5zyjCb9R3Beg0N7FJRhB n2UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gQX+K9p9SQAOy7UwhmluaKADnDQs943ULXYGiNIkGa4=; b=SOofmY2qytCS/87T0GuPJk0ODWZqRDWlLw4XypiAqVWaYjGHguGc7kIHz/2pO7qtpB b7Y1OHGLKny0XiJUGSqcCw84K1R68kpX7dS4Bar7CuFQWd8MtVTXpBaVskQS05lZobLP Y6r9pHCCwkzHwv5DN951wKrAC+/iZ6Qib3W3vMNsRk/2aj+cZmFrb+pfHafF+Eyun8gX hmVRU1xbSk61k2LhORq+ds9UCOTE9ui5Wfy1tqtH1GvSJlp4c92MZR/wy/EC3PwGmK8a n84uyj+YI1bk1RFmyZuh8bxV3A0XcCDw2CeLbota8mniLiJK8Vk6bdlAyxPc/bQACbAx Biwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="1Hot/GKK"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w34si7598952pla.250.2019.04.23.02.02.59; Tue, 23 Apr 2019 02:02:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="1Hot/GKK"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727236AbfDWJC5 (ORCPT + 30 others); Tue, 23 Apr 2019 05:02:57 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42016 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbfDWJC4 (ORCPT ); Tue, 23 Apr 2019 05:02:56 -0400 Received: by mail-wr1-f67.google.com with SMTP id g3so19134502wrx.9 for ; Tue, 23 Apr 2019 02:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gQX+K9p9SQAOy7UwhmluaKADnDQs943ULXYGiNIkGa4=; b=1Hot/GKKAF181enkj5J517RScAaqI3GuFMOfFMA3hgp6FLJe97zWqYT9GJYhBD1Cyt WFagKCP3BrH6knGrHYsDoDtJl9vVOn0meKChi8ut6kfzVqe4rRXzJJvtqgnmAzv1gvBH Vy2Z+pshyeyz42eHzLBsiXFYwxuXHhhzRwZu+dyKMX7tk9ACbnwnXtcJqTkwMIElBjKM Iq07EQUE1+YmR4bfhcU7ulDso/Cs3iy8iMXhc5mXMTT+Wr1NJulXuej0LnEXT2ziI3yw nx7RwRDqd61xhPJQdtx+nimnScisczCeaVJR5mtoWNtb7SPmNG3wK4tLIR3i6+XPzuY3 hHzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gQX+K9p9SQAOy7UwhmluaKADnDQs943ULXYGiNIkGa4=; b=SFASn4+Ka31APBnCA7/Qm6nTYtzQ5mgt+xkK9wOAUM+sCbUeWlqzz4oUiJDYrqXWfx DKxCx6qDYKOIYZflYLqde0iR87HVtmrG4Lcw6lwDiqIPFmWuAsqDajUtqeXG8jsnzN5S GXDbBqbVABTORJ8d+MQJpuMjBkoSEhiq1tIcfjvqT6fGN2cWzO1w34Xyj/sfcqGKrQ17 JG12HSlfXYAG/mZyZA/c5DDDl+YirdLBaHoUQqS88fZNa4qtHGss6nmo9C/GDcvKgP3Z aMf6o8A8n6jHGCwyECTQr0a8YUxv8txaJQWpnSaUdM1D/snzW+D9rQXQOBb4HbT4gh30 8VAA== X-Gm-Message-State: APjAAAUbbA/z5s/Pxouj86FsI71MCOXFXsUIkTSFBOauqo+GhnDEj6+K KC8WyoZOygCf1Dif/I5VzTWpOA== X-Received: by 2002:a5d:4d49:: with SMTP id a9mr17804701wru.227.1556010173339; Tue, 23 Apr 2019 02:02:53 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z23sm12361894wma.0.2019.04.23.02.02.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 02:02:52 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] mmc: meson-gx: remove Rx phase tuning Date: Tue, 23 Apr 2019 11:02:34 +0200 Message-Id: <20190423090235.17244-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423090235.17244-1-jbrunet@baylibre.com> References: <20190423090235.17244-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This remove all the code related to phase settings. Using the Rx phase for tuning has not been reliable. We had several issues over the past months, on both v2 and v3 mmc chips After discussing the issue matter with Amlogic, They suggested to set a phase shift of 180 between Core and Tx and use signal resampling for the tuning. Since we won't be playing with the phase anymore, let's remove all the clock code related to it and set the appropriate value on init. Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 290 ++------------------------------ 1 file changed, 13 insertions(+), 277 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 0454021c9ff5..acdc5520d02c 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -49,6 +49,8 @@ #define CLK_CORE_PHASE_MASK GENMASK(9, 8) #define CLK_TX_PHASE_MASK GENMASK(11, 10) #define CLK_RX_PHASE_MASK GENMASK(13, 12) +#define CLK_PHASE_0 0 +#define CLK_PHASE_180 2 #define CLK_V2_TX_DELAY_MASK GENMASK(19, 16) #define CLK_V2_RX_DELAY_MASK GENMASK(23, 20) #define CLK_V2_ALWAYS_ON BIT(24) @@ -57,10 +59,6 @@ #define CLK_V3_RX_DELAY_MASK GENMASK(27, 22) #define CLK_V3_ALWAYS_ON BIT(28) -#define CLK_DELAY_STEP_PS 200 -#define CLK_PHASE_STEP 30 -#define CLK_PHASE_POINT_NUM (360 / CLK_PHASE_STEP) - #define CLK_TX_DELAY_MASK(h) (h->data->tx_delay_mask) #define CLK_RX_DELAY_MASK(h) (h->data->rx_delay_mask) #define CLK_ALWAYS_ON(h) (h->data->always_on) @@ -165,9 +163,8 @@ struct meson_host { void __iomem *regs; struct clk *core_clk; + struct clk *mux_clk; struct clk *mmc_clk; - struct clk *rx_clk; - struct clk *tx_clk; unsigned long req_rate; bool ddr; @@ -209,90 +206,6 @@ struct meson_host { #define CMD_RESP_MASK GENMASK(31, 1) #define CMD_RESP_SRAM BIT(0) -struct meson_mmc_phase { - struct clk_hw hw; - void __iomem *reg; - unsigned long phase_mask; - unsigned long delay_mask; - unsigned int delay_step_ps; -}; - -#define to_meson_mmc_phase(_hw) container_of(_hw, struct meson_mmc_phase, hw) - -static int meson_mmc_clk_get_phase(struct clk_hw *hw) -{ - struct meson_mmc_phase *mmc = to_meson_mmc_phase(hw); - unsigned int phase_num = 1 << hweight_long(mmc->phase_mask); - unsigned long period_ps, p, d; - int degrees; - u32 val; - - val = readl(mmc->reg); - p = (val & mmc->phase_mask) >> __ffs(mmc->phase_mask); - degrees = p * 360 / phase_num; - - if (mmc->delay_mask) { - period_ps = DIV_ROUND_UP((unsigned long)NSEC_PER_SEC * 1000, - clk_get_rate(hw->clk)); - d = (val & mmc->delay_mask) >> __ffs(mmc->delay_mask); - degrees += d * mmc->delay_step_ps * 360 / period_ps; - degrees %= 360; - } - - return degrees; -} - -static void meson_mmc_apply_phase_delay(struct meson_mmc_phase *mmc, - unsigned int phase, - unsigned int delay) -{ - u32 val; - - val = readl(mmc->reg); - val &= ~mmc->phase_mask; - val |= phase << __ffs(mmc->phase_mask); - - if (mmc->delay_mask) { - val &= ~mmc->delay_mask; - val |= delay << __ffs(mmc->delay_mask); - } - - writel(val, mmc->reg); -} - -static int meson_mmc_clk_set_phase(struct clk_hw *hw, int degrees) -{ - struct meson_mmc_phase *mmc = to_meson_mmc_phase(hw); - unsigned int phase_num = 1 << hweight_long(mmc->phase_mask); - unsigned long period_ps, d = 0, r; - uint64_t p; - - p = degrees % 360; - - if (!mmc->delay_mask) { - p = DIV_ROUND_CLOSEST_ULL(p, 360 / phase_num); - } else { - period_ps = DIV_ROUND_UP((unsigned long)NSEC_PER_SEC * 1000, - clk_get_rate(hw->clk)); - - /* First compute the phase index (p), the remainder (r) is the - * part we'll try to acheive using the delays (d). - */ - r = do_div(p, 360 / phase_num); - d = DIV_ROUND_CLOSEST(r * period_ps, - 360 * mmc->delay_step_ps); - d = min(d, mmc->delay_mask >> __ffs(mmc->delay_mask)); - } - - meson_mmc_apply_phase_delay(mmc, p, d); - return 0; -} - -static const struct clk_ops meson_mmc_clk_phase_ops = { - .get_phase = meson_mmc_clk_get_phase, - .set_phase = meson_mmc_clk_set_phase, -}; - static unsigned int meson_mmc_get_timeout_msecs(struct mmc_data *data) { unsigned int timeout = data->timeout_ns / NSEC_PER_MSEC; @@ -492,8 +405,6 @@ static int meson_mmc_clk_init(struct meson_host *host) struct clk_init_data init; struct clk_mux *mux; struct clk_divider *div; - struct meson_mmc_phase *core, *tx, *rx; - struct clk *clk; char clk_name[32]; int i, ret = 0; const char *mux_parent_names[MUX_CLK_NUM_PARENTS]; @@ -501,9 +412,11 @@ static int meson_mmc_clk_init(struct meson_host *host) u32 clk_reg; /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */ - clk_reg = 0; - clk_reg |= CLK_ALWAYS_ON(host); + clk_reg = CLK_ALWAYS_ON(host); clk_reg |= CLK_DIV_MASK; + clk_reg |= FIELD_PREP(CLK_CORE_PHASE_MASK, CLK_PHASE_180); + clk_reg |= FIELD_PREP(CLK_TX_PHASE_MASK, CLK_PHASE_0); + clk_reg |= FIELD_PREP(CLK_RX_PHASE_MASK, CLK_PHASE_0); writel(clk_reg, host->regs + SD_EMMC_CLOCK); /* get the mux parents */ @@ -539,9 +452,9 @@ static int meson_mmc_clk_init(struct meson_host *host) mux->mask = CLK_SRC_MASK >> mux->shift; mux->hw.init = &init; - clk = devm_clk_register(host->dev, &mux->hw); - if (WARN_ON(IS_ERR(clk))) - return PTR_ERR(clk); + host->mux_clk = devm_clk_register(host->dev, &mux->hw); + if (WARN_ON(IS_ERR(host->mux_clk))) + return PTR_ERR(host->mux_clk); /* create the divider */ div = devm_kzalloc(host->dev, sizeof(*div), GFP_KERNEL); @@ -552,7 +465,7 @@ static int meson_mmc_clk_init(struct meson_host *host) init.name = clk_name; init.ops = &clk_divider_ops; init.flags = CLK_SET_RATE_PARENT; - clk_parent[0] = __clk_get_name(clk); + clk_parent[0] = __clk_get_name(host->mux_clk); init.parent_names = clk_parent; init.num_parents = 1; @@ -562,192 +475,19 @@ static int meson_mmc_clk_init(struct meson_host *host) div->hw.init = &init; div->flags = CLK_DIVIDER_ONE_BASED; - clk = devm_clk_register(host->dev, &div->hw); - if (WARN_ON(IS_ERR(clk))) - return PTR_ERR(clk); - - /* create the mmc core clock */ - core = devm_kzalloc(host->dev, sizeof(*core), GFP_KERNEL); - if (!core) - return -ENOMEM; - - snprintf(clk_name, sizeof(clk_name), "%s#core", dev_name(host->dev)); - init.name = clk_name; - init.ops = &meson_mmc_clk_phase_ops; - init.flags = CLK_SET_RATE_PARENT; - clk_parent[0] = __clk_get_name(clk); - init.parent_names = clk_parent; - init.num_parents = 1; - - core->reg = host->regs + SD_EMMC_CLOCK; - core->phase_mask = CLK_CORE_PHASE_MASK; - core->hw.init = &init; - - host->mmc_clk = devm_clk_register(host->dev, &core->hw); - if (WARN_ON(PTR_ERR_OR_ZERO(host->mmc_clk))) + host->mmc_clk = devm_clk_register(host->dev, &div->hw); + if (WARN_ON(IS_ERR(host->mmc_clk))) return PTR_ERR(host->mmc_clk); - /* create the mmc tx clock */ - tx = devm_kzalloc(host->dev, sizeof(*tx), GFP_KERNEL); - if (!tx) - return -ENOMEM; - - snprintf(clk_name, sizeof(clk_name), "%s#tx", dev_name(host->dev)); - init.name = clk_name; - init.ops = &meson_mmc_clk_phase_ops; - init.flags = 0; - clk_parent[0] = __clk_get_name(host->mmc_clk); - init.parent_names = clk_parent; - init.num_parents = 1; - - tx->reg = host->regs + SD_EMMC_CLOCK; - tx->phase_mask = CLK_TX_PHASE_MASK; - tx->delay_mask = CLK_TX_DELAY_MASK(host); - tx->delay_step_ps = CLK_DELAY_STEP_PS; - tx->hw.init = &init; - - host->tx_clk = devm_clk_register(host->dev, &tx->hw); - if (WARN_ON(PTR_ERR_OR_ZERO(host->tx_clk))) - return PTR_ERR(host->tx_clk); - - /* create the mmc rx clock */ - rx = devm_kzalloc(host->dev, sizeof(*rx), GFP_KERNEL); - if (!rx) - return -ENOMEM; - - snprintf(clk_name, sizeof(clk_name), "%s#rx", dev_name(host->dev)); - init.name = clk_name; - init.ops = &meson_mmc_clk_phase_ops; - init.flags = 0; - clk_parent[0] = __clk_get_name(host->mmc_clk); - init.parent_names = clk_parent; - init.num_parents = 1; - - rx->reg = host->regs + SD_EMMC_CLOCK; - rx->phase_mask = CLK_RX_PHASE_MASK; - rx->delay_mask = CLK_RX_DELAY_MASK(host); - rx->delay_step_ps = CLK_DELAY_STEP_PS; - rx->hw.init = &init; - - host->rx_clk = devm_clk_register(host->dev, &rx->hw); - if (WARN_ON(PTR_ERR_OR_ZERO(host->rx_clk))) - return PTR_ERR(host->rx_clk); - /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */ host->mmc->f_min = clk_round_rate(host->mmc_clk, 400000); ret = clk_set_rate(host->mmc_clk, host->mmc->f_min); if (ret) return ret; - clk_set_phase(host->mmc_clk, 180); - clk_set_phase(host->tx_clk, 0); - clk_set_phase(host->rx_clk, 0); - return clk_prepare_enable(host->mmc_clk); } -static void meson_mmc_shift_map(unsigned long *map, unsigned long shift) -{ - DECLARE_BITMAP(left, CLK_PHASE_POINT_NUM); - DECLARE_BITMAP(right, CLK_PHASE_POINT_NUM); - - /* - * shift the bitmap right and reintroduce the dropped bits on the left - * of the bitmap - */ - bitmap_shift_right(right, map, shift, CLK_PHASE_POINT_NUM); - bitmap_shift_left(left, map, CLK_PHASE_POINT_NUM - shift, - CLK_PHASE_POINT_NUM); - bitmap_or(map, left, right, CLK_PHASE_POINT_NUM); -} - -static void meson_mmc_find_next_region(unsigned long *map, - unsigned long *start, - unsigned long *stop) -{ - *start = find_next_bit(map, CLK_PHASE_POINT_NUM, *start); - *stop = find_next_zero_bit(map, CLK_PHASE_POINT_NUM, *start); -} - -static int meson_mmc_find_tuning_point(unsigned long *test) -{ - unsigned long shift, stop, offset = 0, start = 0, size = 0; - - /* Get the all good/all bad situation out the way */ - if (bitmap_full(test, CLK_PHASE_POINT_NUM)) - return 0; /* All points are good so point 0 will do */ - else if (bitmap_empty(test, CLK_PHASE_POINT_NUM)) - return -EIO; /* No successful tuning point */ - - /* - * Now we know there is a least one region find. Make sure it does - * not wrap by the shifting the bitmap if necessary - */ - shift = find_first_zero_bit(test, CLK_PHASE_POINT_NUM); - if (shift != 0) - meson_mmc_shift_map(test, shift); - - while (start < CLK_PHASE_POINT_NUM) { - meson_mmc_find_next_region(test, &start, &stop); - - if ((stop - start) > size) { - offset = start; - size = stop - start; - } - - start = stop; - } - - /* Get the center point of the region */ - offset += (size / 2); - - /* Shift the result back */ - offset = (offset + shift) % CLK_PHASE_POINT_NUM; - - return offset; -} - -static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode, - struct clk *clk) -{ - int point, ret; - DECLARE_BITMAP(test, CLK_PHASE_POINT_NUM); - - dev_dbg(mmc_dev(mmc), "%s phase/delay tunning...\n", - __clk_get_name(clk)); - bitmap_zero(test, CLK_PHASE_POINT_NUM); - - /* Explore tuning points */ - for (point = 0; point < CLK_PHASE_POINT_NUM; point++) { - clk_set_phase(clk, point * CLK_PHASE_STEP); - ret = mmc_send_tuning(mmc, opcode, NULL); - if (!ret) - set_bit(point, test); - } - - /* Find the optimal tuning point and apply it */ - point = meson_mmc_find_tuning_point(test); - if (point < 0) - return point; /* tuning failed */ - - clk_set_phase(clk, point * CLK_PHASE_STEP); - dev_dbg(mmc_dev(mmc), "success with phase: %d\n", - clk_get_phase(clk)); - return 0; -} - -static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) -{ - struct meson_host *host = mmc_priv(mmc); - int adj = 0; - - /* enable signal resampling w/o delay */ - adj = ADJUST_ADJ_EN; - writel(adj, host->regs + host->data->adjust); - - return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); -} - static int meson_mmc_prepare_ios_clock(struct meson_host *host, struct mmc_ios *ios) { @@ -796,9 +536,6 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) /* disable signal resampling */ writel(0, host->regs + host->data->adjust); - /* Reset rx phase */ - clk_set_phase(host->rx_clk, 0); - break; case MMC_POWER_ON: @@ -1226,7 +963,6 @@ static const struct mmc_host_ops meson_mmc_ops = { .get_cd = meson_mmc_get_cd, .pre_req = meson_mmc_pre_req, .post_req = meson_mmc_post_req, - .execute_tuning = meson_mmc_execute_tuning, .card_busy = meson_mmc_card_busy, .start_signal_voltage_switch = meson_mmc_voltage_switch, };