From patchwork Wed Apr 27 18:08:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12829306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A3CEC433EF for ; Wed, 27 Apr 2022 18:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LjCVrLndPXOsvuKuWU/S/arpqI6HxcWqKkONKaN7H8U=; b=M3HxXLFXUphk5n Bv0CNwaignMqzzsLXp24MnXUqttiuLUYrgCRsiiPPe4pCjojLOlq6h79OAB1jzB3LX1E1Khj9QULy J80jcrp4/wgSJ7SobL09J+Gigt7q974f+mS6lbdUq5dBH4TTBojzrGGtRDV7BeeFIlmdNLyVRK85u 1F+MkFKLFadPrkkBwBU3Iw351M05f7+MwhRoqiu2jBqoBV6s9kpF8ONHj0XcVrDtnE36IVzvLwnlh K0+2Emm5ul2GAfiEm2O/LpR7a8rMU0h4tjAO+Wq12Gzd0O7ye+pvTPbj25y1GbqS2VTljvLuS3Oxh 1W/YdooyUrTezjngdBrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm6w-002tkh-Mv; Wed, 27 Apr 2022 18:09:58 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm6b-002taW-Ko for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 18:09:41 +0000 Received: by mail-pg1-x535.google.com with SMTP id v10so2038537pgl.11 for ; Wed, 27 Apr 2022 11:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g3ZPy72isW7ZeQco5IszI5xB15RJ/hq79xgf0sAxg2Q=; b=ZNZb9yYVRp907PC/hNoiB8mJwf8khL5iRjNByuh7CnsHcFskVirxwKO76kNBfc1Fx+ fqtI7gTHStyrva6LL8r/Vwy9NSPwjQYIB/aP4XH64DZrJ2gvGKdsiKKAlnmIKeGUtzL7 NJ1PbX/kW/L4ayZ/FZ0GrVoxZiu5qbKuxyW5TZEJdUgHWY7eG3x8zH5ANcUQvKHcqCBP L178BI5nTE0N7lHIF9Zno/7wBu3fzTSNeADyaB9heZSizW8+0MppfWsLDYdL6Q7E/NHf gQHkiHDI5PjBtBuhfasXF/+6SK+ZW+/UmeMfSqRBDJg1abCxCWYTWhMbkE5/HqB1l2PB MLsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g3ZPy72isW7ZeQco5IszI5xB15RJ/hq79xgf0sAxg2Q=; b=2H2+u/F6KjkV+8RjkhBunk+ZhpAIrPczi2jk2wOFxKBMGns67u8HFUFaMix1HBZ+LJ 92xyZqka8aH6rkYia/zYcVd20envCAtMBRokgUjvwT0vd7oLQuvyphx706ynFnTouBb+ un4hLr54XBKzpSEtIH8Kn1W9L66HkLyuJadtF7/XWTZe/5/u2mK88hfB6oicAaEIbPX5 XLd/lBzGaPrZwz4BYVrQtAVSR15hSAQN3ZJQQVqhAfrixPcFuuUmW1gOv/FxLLm1wwgM ecP+Mllar4WK5VBT52l4Xo1nD1F+aYhJ+ZlihCNVdidAfI4IokcmUidbZBy73jwejuT6 taZA== X-Gm-Message-State: AOAM530aKlGxVDHblXnT7fn7/DfZcC+CTC0oPF/ERrD76ed86sULL5GY 121m8AUVLqfwg0JqwPZI9h8= X-Google-Smtp-Source: ABdhPJy2dGvu08NyuZWfqZFsBJjlHr2Q0lInD5fNyMMCV69XyoFCx9L+5NSkmmqjj5NVeDW5u8mKQQ== X-Received: by 2002:a05:6a00:1da0:b0:50d:4d87:566e with SMTP id z32-20020a056a001da000b0050d4d87566emr12449745pfw.13.1651082974661; Wed, 27 Apr 2022 11:09:34 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id u25-20020aa78399000000b00505f75651e7sm19076859pfm.158.2022.04.27.11.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 11:09:34 -0700 (PDT) From: Kamal Dasu To: ulf.hansson@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org, alcooperx@gmail.com Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamal Dasu Subject: [PATCH v2 1/4] mmc: sdhci-brcmstb: Re-organize flags Date: Wed, 27 Apr 2022 14:08:50 -0400 Message-Id: <20220427180853.35970-2-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220427180853.35970-1-kdasu.kdev@gmail.com> References: <20220427180853.35970-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_110937_777869_12642344 X-CRM114-Status: GOOD ( 16.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Al Cooper Re-organize the flags by basing the bit names on the flag that they apply to. Also change the "flags" member in the "brcmstb_match_priv" struct to const. Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-brcmstb.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index f24623aac2db..244780481193 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -18,20 +18,22 @@ #define SDHCI_VENDOR 0x78 #define SDHCI_VENDOR_ENHANCED_STRB 0x1 -#define BRCMSTB_PRIV_FLAGS_NO_64BIT BIT(0) -#define BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT BIT(1) +#define BRCMSTB_MATCH_FLAGS_NO_64BIT BIT(0) +#define BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT BIT(1) + +#define BRCMSTB_PRIV_FLAGS_HAS_CQE BIT(0) #define SDHCI_ARASAN_CQE_BASE_ADDR 0x200 struct sdhci_brcmstb_priv { void __iomem *cfg_regs; - bool has_cqe; + unsigned int flags; }; struct brcmstb_match_priv { void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios); struct sdhci_ops *ops; - unsigned int flags; + const unsigned int flags; }; static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) @@ -134,13 +136,13 @@ static struct sdhci_ops sdhci_brcmstb_ops_7216 = { }; static struct brcmstb_match_priv match_priv_7425 = { - .flags = BRCMSTB_PRIV_FLAGS_NO_64BIT | - BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT, + .flags = BRCMSTB_MATCH_FLAGS_NO_64BIT | + BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, .ops = &sdhci_brcmstb_ops, }; static struct brcmstb_match_priv match_priv_7445 = { - .flags = BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT, + .flags = BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, .ops = &sdhci_brcmstb_ops, }; @@ -176,7 +178,7 @@ static int sdhci_brcmstb_add_host(struct sdhci_host *host, bool dma64; int ret; - if (!priv->has_cqe) + if ((priv->flags & BRCMSTB_PRIV_FLAGS_HAS_CQE) == 0) return sdhci_add_host(host); dev_dbg(mmc_dev(host->mmc), "CQE is enabled\n"); @@ -225,7 +227,6 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) struct sdhci_brcmstb_priv *priv; struct sdhci_host *host; struct resource *iomem; - bool has_cqe = false; struct clk *clk; int res; @@ -244,10 +245,6 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) return res; memset(&brcmstb_pdata, 0, sizeof(brcmstb_pdata)); - if (device_property_read_bool(&pdev->dev, "supports-cqe")) { - has_cqe = true; - match_priv->ops->irq = sdhci_brcmstb_cqhci_irq; - } brcmstb_pdata.ops = match_priv->ops; host = sdhci_pltfm_init(pdev, &brcmstb_pdata, sizeof(struct sdhci_brcmstb_priv)); @@ -258,7 +255,10 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) pltfm_host = sdhci_priv(host); priv = sdhci_pltfm_priv(pltfm_host); - priv->has_cqe = has_cqe; + if (device_property_read_bool(&pdev->dev, "supports-cqe")) { + priv->flags |= BRCMSTB_PRIV_FLAGS_HAS_CQE; + match_priv->ops->irq = sdhci_brcmstb_cqhci_irq; + } /* Map in the non-standard CFG registers */ iomem = platform_get_resource(pdev, IORESOURCE_MEM, 1); @@ -287,14 +287,14 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) * properties through mmc_of_parse(). */ host->caps = sdhci_readl(host, SDHCI_CAPABILITIES); - if (match_priv->flags & BRCMSTB_PRIV_FLAGS_NO_64BIT) + if (match_priv->flags & BRCMSTB_MATCH_FLAGS_NO_64BIT) host->caps &= ~SDHCI_CAN_64BIT; host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_DDR50); host->quirks |= SDHCI_QUIRK_MISSING_CAPS; - if (match_priv->flags & BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT) + if (match_priv->flags & BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT) host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; res = sdhci_brcmstb_add_host(host, priv); From patchwork Wed Apr 27 18:08:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12829307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A093C433EF for ; Wed, 27 Apr 2022 18:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BGX+GyPti62IB8jKGFxrU1MPBhCvUE3M/dxokq73GnU=; b=sCTXacbe1H/p1A dh9UJUnmrl89EafOo+v42OGRfdEqoAum8+i7BL7o+21FhAwMEHyfPvK2YmwQf2uSBbvsl067zMlul HVDnptyEn6V+lLGOtZhe43ctvDQlsOPIqovXn5a6/R8rt002k6Jrjic/meLvE+0ATaCF5LVPXK9Ez ZWcdTScKtqO8hN6y966OZTEFJVeHSpSydXmpIErw7eRREU5OBGZTA+0S5aWfxVzTL88P0j8dQJYfl 1agtDmA276OunxMWKE07nOyAEdqFkYul5u6UUSHqku4FXMUw5ef0Kkkjhjm2J/ldFAgdXrirAAIQ0 rMweffvQUYyscR/VUAWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm7E-002trw-Uh; Wed, 27 Apr 2022 18:10:17 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm6g-002tck-4T for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 18:09:43 +0000 Received: by mail-pg1-x536.google.com with SMTP id q12so2034123pgj.13 for ; Wed, 27 Apr 2022 11:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kh0Z24nrRo8CulmjggTjYpsy8ADRv1RHCAkzggFzOqo=; b=YO+hX3FejKiIUcQuPKn3jM/NlPS0bWPcFDmA0FyymXXFEDz5EBkuVvoiTMZysYoIzx aTu3yjhUia/vlFzbv0uCGKYFDGhrmxay5qwqEc5wv+AbaQL3TwtllZS3bQUZjcxnAoRG mTqBeu2U6nqsTDriKcR0efkJAgXSgXnISpvQIRbgrOH/coQIr13tfBF2LEZqCqwQeXj3 9l54DNeS1HmS5JjbXKxtyrHkLOJoE8vJWKzP5RpHQ3g/sX18sRKJ0dnirmH54255xZQw LSaDP8KjXx3hIigZMm4tD00baD9061wnVRHVrJ2DN3AUBPqsgyfH9zp3/2DV6XySEJ7J /i3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Kh0Z24nrRo8CulmjggTjYpsy8ADRv1RHCAkzggFzOqo=; b=nmWLHaBngTqVtLmHGoNBfYGLSQH3I7lSaPv0oClQBoKRTctwKcjybpJiW0XiRmquiX ONwTuJ6KWzM5Rcy7euaE5NKppBiT+DfJ4FSiREL9hifMc9+jApYHA0HFO6O8OEmhSgIO QNjFPHH2ZvuVcMK+njBthKjqVJI+FysnkVOUlqJRTgOjnJl9ISWJM/HxdX9YLbT0SwmR PPGqrFgiB5yVYuwdhNJ436zFpUQpp7h8V8/mnizYEOfbX5wwH+XV9mU2rfBUBjM0qYMn QETbBSiIUFSXvb4Aske4BtC+Laqp3UUHlf9UujACovv/QvtMECA3UaRyrpCF5uU9Z4il 7Tjw== X-Gm-Message-State: AOAM530/02BXkQskQ+7VqvvLguXcayl0Lv0LtyrLoYWp8lyvdJSIGhZG alQYvxPc5KAHPJNzPywNHKU= X-Google-Smtp-Source: ABdhPJzTXl8P7AReCze57oFAZkussRWXMGswCH8kafFEZ+A1oHWoazDMMoQdqoPoYoo1f2sn7V11Tg== X-Received: by 2002:a05:6a00:e8e:b0:4fa:a52f:59cf with SMTP id bo14-20020a056a000e8e00b004faa52f59cfmr31215863pfb.84.1651082979701; Wed, 27 Apr 2022 11:09:39 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id u25-20020aa78399000000b00505f75651e7sm19076859pfm.158.2022.04.27.11.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 11:09:39 -0700 (PDT) From: Kamal Dasu To: ulf.hansson@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org, alcooperx@gmail.com Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamal Dasu Subject: [PATCH v2 2/4] mmc: sdhci-brcmstb: Enable Clock Gating to save power Date: Wed, 27 Apr 2022 14:08:51 -0400 Message-Id: <20220427180853.35970-3-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220427180853.35970-1-kdasu.kdev@gmail.com> References: <20220427180853.35970-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_110942_238587_8C2C928A X-CRM114-Status: GOOD ( 19.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Al Cooper Enabling this feature will allow the controller to stop the bus clock when the bus is idle. The feature is not part of the standard and is unique to newer Arasan cores and is enabled with a bit in a vendor specific register. This feature will only be enabled for non-removable devices because they don't switch the voltage and clock gating breaks SD Card volatge switching. Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-brcmstb.c | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index 244780481193..683d0c685748 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -17,11 +17,14 @@ #define SDHCI_VENDOR 0x78 #define SDHCI_VENDOR_ENHANCED_STRB 0x1 +#define SDHCI_VENDOR_GATE_SDCLK_EN 0x2 #define BRCMSTB_MATCH_FLAGS_NO_64BIT BIT(0) #define BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT BIT(1) +#define BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE BIT(2) #define BRCMSTB_PRIV_FLAGS_HAS_CQE BIT(0) +#define BRCMSTB_PRIV_FLAGS_GATE_CLOCK BIT(1) #define SDHCI_ARASAN_CQE_BASE_ADDR 0x200 @@ -36,6 +39,27 @@ struct brcmstb_match_priv { const unsigned int flags; }; +static inline void enable_clock_gating(struct sdhci_host *host) +{ + u32 reg; + + reg = sdhci_readl(host, SDHCI_VENDOR); + reg |= SDHCI_VENDOR_GATE_SDCLK_EN; + sdhci_writel(host, reg, SDHCI_VENDOR); +} + +void brcmstb_reset(struct sdhci_host *host, u8 mask) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); + + sdhci_reset(host, mask); + + /* Reset will clear this, so re-enable it */ + if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK) + enable_clock_gating(host); +} + static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) { struct sdhci_host *host = mmc_priv(mmc); @@ -131,7 +155,7 @@ static struct sdhci_ops sdhci_brcmstb_ops = { static struct sdhci_ops sdhci_brcmstb_ops_7216 = { .set_clock = sdhci_brcmstb_set_clock, .set_bus_width = sdhci_set_bus_width, - .reset = sdhci_reset, + .reset = brcmstb_reset, .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, }; @@ -147,6 +171,7 @@ static struct brcmstb_match_priv match_priv_7445 = { }; static const struct brcmstb_match_priv match_priv_7216 = { + .flags = BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE, .hs400es = sdhci_brcmstb_hs400es, .ops = &sdhci_brcmstb_ops_7216, }; @@ -273,6 +298,14 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) if (res) goto err; + /* + * Automatic clock gating does not work for SD cards that may + * voltage switch so only enable it for non-removable devices. + */ + if ((match_priv->flags & BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE) && + (host->mmc->caps & MMC_CAP_NONREMOVABLE)) + priv->flags |= BRCMSTB_PRIV_FLAGS_GATE_CLOCK; + /* * If the chip has enhanced strobe and it's enabled, add * callback From patchwork Wed Apr 27 18:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12829308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9961C433EF for ; Wed, 27 Apr 2022 18:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2LBuVEp6PT5AVngVb4i5uAhO0QHvQKyBvccdaT3rlOQ=; b=RmV/MHjU5Oanss z6XdgXNwf31ZJPOO8h9jP1lLrqgj13SxyFB1UiIr4RP36FqE67rHfFS/CRpQpU40JZ6RvI8taVZIC +0SRwELz4DmLH6zEbyTYAvRjdnzmGQRQeGFQWTHFr9gqsgqFRlZMHtc8dqP61e1hEPA/cREwVABQ/ 8F1wcMytFFDIh0fV8lnvg2vT6823rFA+L2AceW2W7zFZV2VBnF56BgUOJDvb7AwypiE1mhtSMiMr7 ohkffcbvMeIFb0Xv4FxW3ahbq1Sw4N//VzNtWE9zxjRjirlrN9nPVzzBYgPsRHmLx6j2nabVGkAWD QwF0UyROSMbEhlN18X7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm7V-002twZ-VA; Wed, 27 Apr 2022 18:10:34 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm6k-002teS-Sh for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 18:09:48 +0000 Received: by mail-pj1-x1036.google.com with SMTP id fv2so2128829pjb.4 for ; Wed, 27 Apr 2022 11:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DhDEOGzyYb9G9W/Ih5nKdhPS0DtnHgoSg/tqlnDUmxQ=; b=IaDd2rrWQIS7uiZBU4ssser2L4FmpszX7h5IIzB9lYo3FpnQCSUQqXkS9WKOvDNJJd M+X/bAn8Kwq6GOLUjkCOXvRNKWt6BkFyzF/KmzCeln6bDSaWfFM2nxNteh+S+ISqLDaZ gC0iusiE41nDfRT6oX6eq37yUw5mImMTRbrZSd1xLW/+HLUqMeOK+2Ti73nWRUFRWk+l asMg+UoCCObXpKjUKNl9BkUtxZ2FZ03kpC+wSDmoSgx0KGiEKdBJmZY+AjJNjY6DHRSY A4ly/1+TurEixBoM9CQlm6jwnTn2YyowriCzeI+6w7JRzrR9Lg3tClv6XOhjwrSnDo0e UefQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DhDEOGzyYb9G9W/Ih5nKdhPS0DtnHgoSg/tqlnDUmxQ=; b=oqojn6C0HOx80XH1cAyCPz//AsR8ogb6SrATSKNofoo7/qQnG5qXAOlpK3nKWMVOMa yVzKNlwhkSFBohJ1pWbDc6YEZtueEbE2/Vsu66rohL2SOTSrtfuuH4ydFbqZhhN7KcmK hS/B1O0wtowIZN/x474fSENCi/JtRYNUV2RcjfBBgcRgvHATrS0ZY6CXHRBmtSXpzec4 K0CGwSaZHnQDZymvCzo3toxF3UQCsbxVi2vbh6MvteXEOPPpkBQon0Wbo2eorrdgWmaE 00FYlFMevYFF7/j5gXuGvCXiez6qR5kbo0l8i1ry86p3VihXGXFycL1q0m+ez8Ki3BGC Pycw== X-Gm-Message-State: AOAM532Ny+sO/9WHzTd40+bEgiM2QWIUh6HUxKHlgdiVB2vy4St73Gpi adSTNXPNcxsFpgut7wkgUGk= X-Google-Smtp-Source: ABdhPJxobOaSK/Wr/ZaH1v9haLS9wKEynarvNVjK2dORpQmy5KjaZxjBuEOEVwXr4MymO7T1dNlJkw== X-Received: by 2002:a17:902:cec4:b0:15d:50ba:d9bf with SMTP id d4-20020a170902cec400b0015d50bad9bfmr4886679plg.28.1651082983837; Wed, 27 Apr 2022 11:09:43 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id u25-20020aa78399000000b00505f75651e7sm19076859pfm.158.2022.04.27.11.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 11:09:43 -0700 (PDT) From: Kamal Dasu To: ulf.hansson@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org, alcooperx@gmail.com Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamal Dasu Subject: [PATCH v2 3/4] dt-bindings: mmc: Add Broadcom optional sdio_freq clock Date: Wed, 27 Apr 2022 14:08:52 -0400 Message-Id: <20220427180853.35970-4-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220427180853.35970-1-kdasu.kdev@gmail.com> References: <20220427180853.35970-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_110946_979802_D5AA7878 X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The 72116B0 has improved SDIO controllers that allow the max clock rate to be increased from a max of 100MHz to a max of 150MHz. Optional "sdio_freq" clock is used to drive the bus clock if present optional property "max-frequency" specifies a base clock frequency in Hz that overrides the base clock frequency in the CAPS registers. Signed-off-by: Kamal Dasu --- .../bindings/mmc/brcm,sdhci-brcmstb.yaml | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml index dccd5ad96981..bf716c0cf096 100644 --- a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +++ b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml @@ -10,8 +10,6 @@ maintainers: - Al Cooper - Florian Fainelli -allOf: - - $ref: mmc-controller.yaml# properties: compatible: @@ -42,23 +40,39 @@ properties: maxItems: 1 clocks: - maxItems: 1 - description: - handle to core clock for the sdhci controller. + minItems: 1 + items: + - description: handle to core clock for the sdhci controller + - description: improved 150Mhz clock for sdhci controller (Optional clock) clock-names: + minItems: 1 items: - const: sw_sdio + - const: sdio_freq # Optional clock sdhci,auto-cmd12: type: boolean description: Specifies that controller should use auto CMD12 +allOf: + - $ref: mmc-controller.yaml# + - if: + properties: + clock-names: + contains: + const: sdio_freq + + - then: + required: + - max-frequency + required: - compatible - reg - interrupts - clocks + - clock-names unevaluatedProperties: false From patchwork Wed Apr 27 18:08:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12829309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23F79C433EF for ; Wed, 27 Apr 2022 18:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fym7iSggzoGxFYGx32tXoH7bCEinQEfQdL8E3bhe7EU=; b=JEHvKkHX4TIxJf LF1uSksF9bwB4O6uagKnQpCxKO0w3hhh+iZ9bLwkk2t3PZ7FhM/oer5xzBOlZio68LnCnhjbATLhL HbCfKtU9l8I0kkoxOqSttgFBPJu0ABonjp3MtEdEP7MjoTZb3qXupURNu//89a0N84RyLpwSRoeey ndI/gkoXuU8R9/oy3wRM3mYEUEXRSd621ipA6UrmGvc4tIZbMqCf9onfzCT9QVrBtgY/7ba31ZLXC YDpznoUPBoijX7MxDzDKJsRoifel+45ksM6Uotby/yw1QTYPxo1FwwSzx11EwuBKB5UEQY/ez71uy 6ynmoOzoAUHh1KqzoO6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm7s-002u4C-M6; Wed, 27 Apr 2022 18:10:56 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njm6n-002tgj-Jw for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 18:09:51 +0000 Received: by mail-pf1-x433.google.com with SMTP id a11so2245765pff.1 for ; Wed, 27 Apr 2022 11:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SC7RZFmFzY1cOQBSZIdDAHzv/8LeJtBuHEGLtHlFN68=; b=qpzCGKxw/occv4Nuka8IWzq7q96NZjmWekn+OP2qa4Nty8SX7WF1zE1e1B4x4tRgVJ u0JTdGcftj7uwIBthE117rEBdHqeAvgTGr2ttmLNqOA5588saUD4H9aAQu7JlXhm5+eH hs5qn12hvTorb8EKjKqOGUUBAxWx3auU2HTA/uhSSvJlKoYse5hX0GszJc56Eb40zvg2 yy7vMUtAtscMZ4rNVhN5Paq0qM6mJjvasYgTUyC/oxLrxHUmTxxRmum1W1ZFffjqcOw6 40m03OPCHXL0aeMj3ypX0VYluGsePdF8UjTTJHmRVhIy7p55pSV9JllHexou656CxYFn oj2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SC7RZFmFzY1cOQBSZIdDAHzv/8LeJtBuHEGLtHlFN68=; b=n0iqRWl93vuFs5zRNB/LQ05TOjM3TSCVWXZYj28e0Thw/V28/XBc2z1Y0DSrXbkBHc qaaw+hZ9lNGzd2++RbAvRGuXi1KgEOSZCtOrHtweD6fNMd0tB5lWCofSXVLq6XI+3KOK 6i3l3RZ8Akaq4oldX6l3+4zLecdCpn372TQ01hufk6dyaXmSNrmZsfEOGd1wV8zYbdsr KyVvDdyhR7/swekfQAmq+gx/xQzxMjcgY5dh+SVGk6dNNFetgbuQAj15sJJu0RHYwjTb oap7LxYIPV8ZPgBhM4tu7IhosEYpyDEIhPy1o85LFbXBNWvUSmlZo10Fq5ui4D10aJkd QPbw== X-Gm-Message-State: AOAM531klqDWYk6GTsfmKTH9btdG/66ISn7FPBbRZmupgvpzeZSWPfLo gbDsTi7RnIqLKRHmwOfw7RQ= X-Google-Smtp-Source: ABdhPJyBfRvQK5ucNiOqjWVZwaDGd2EDnvC4GpPivMyaWL78F9cq64AYIKfXWqGw7aWexrgMeOqF6g== X-Received: by 2002:a63:4f0b:0:b0:3a9:f4ad:6c30 with SMTP id d11-20020a634f0b000000b003a9f4ad6c30mr24900316pgb.88.1651082989059; Wed, 27 Apr 2022 11:09:49 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id u25-20020aa78399000000b00505f75651e7sm19076859pfm.158.2022.04.27.11.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 11:09:48 -0700 (PDT) From: Kamal Dasu To: ulf.hansson@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org, alcooperx@gmail.com Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamal Dasu Subject: [PATCH v2 4/4] mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0 Date: Wed, 27 Apr 2022 14:08:53 -0400 Message-Id: <20220427180853.35970-5-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220427180853.35970-1-kdasu.kdev@gmail.com> References: <20220427180853.35970-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_110949_691466_68A7FC4E X-CRM114-Status: GOOD ( 17.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Al Cooper The 72116B0 has improved SDIO controllers that allow the max clock rate to be increased from a max of 100MHz to a max of 150MHz. The driver will need to get the clock and increase it's default rate and override the caps register, that still indicates a max of 100MHz. The new clock will be named "sdio_freq" in the DT node's "clock-names" list. The driver will use a DT property, "clock-frequency", to enable this functionality and will get the actual rate in MHz from the property to allow various speeds to be requested. Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu --- drivers/mmc/host/sdhci-brcmstb.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index 683d0c685748..51a23e9f4535 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -250,6 +250,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) struct sdhci_pltfm_host *pltfm_host; const struct of_device_id *match; struct sdhci_brcmstb_priv *priv; + u32 base_clock_hz = 0; struct sdhci_host *host; struct resource *iomem; struct clk *clk; @@ -330,6 +331,30 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) if (match_priv->flags & BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT) host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; + /* Change the base clock frequency if the DT property exists */ + if (device_property_read_u32(&pdev->dev, "max-frequency", + &base_clock_hz) == 0) { + struct clk *master_clk; + u32 actual_clock_mhz; + + master_clk = devm_clk_get(&pdev->dev, "sdio_freq"); + if (IS_ERR(master_clk)) { + dev_warn(&pdev->dev, + "Clock for \"sdio_freq\" was not found\n"); + } else { + clk_set_rate(master_clk, base_clock_hz); + actual_clock_mhz = clk_get_rate(master_clk) / 1000000; + + host->caps &= ~SDHCI_CLOCK_V3_BASE_MASK; + host->caps |= + (actual_clock_mhz << SDHCI_CLOCK_BASE_SHIFT); + /* Disable presets because they are now incorrect */ + host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; + dev_dbg(&pdev->dev, + "Base Clock Frequency changed to %dMHz\n", + actual_clock_mhz); + } + } res = sdhci_brcmstb_add_host(host, priv); if (res) goto err;