From patchwork Fri May 20 18:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12857282 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 855BEC433EF for ; Fri, 20 May 2022 18:40:21 +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=yIb+zgzZDorpu2MphG1Pnh7z4J8U6OWO30KWjWhSEHg=; b=ee6h6fKc6lh3Ax E22P7iZ1q/cJ2rbMQXpw67wfEezNWNZCC+xeHpHOPgzWGX35/+/YormxhA2mSACz4/MTCcsusuWaq hbNSGpqk4NeLVOALDf5eI7EZJioqlDwNr/AHbKIek9bX2qJ5ghQrnU0LhZiytGK0HWv7FgD/LlRad qA6sYWhu55wFq7WkhbtjAZLmDZ1Y8lVhS9svOGpMldI6QlPtZfRxSsMTRtHRU0t7Jyyef5qo54fB3 02N+smDLNd8QqZ3+B6CeJgD4bnt5Adb3Tm102P+ZtBgua4dZ4FJ9ANZF7O/Mf/DjD27bO+gG8rhj2 AR1LE9pf8a+cxKsOnf8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ns7Wf-00EEaP-NJ; Fri, 20 May 2022 18:39:02 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ns7PJ-00E9Sr-Eu for linux-arm-kernel@lists.infradead.org; Fri, 20 May 2022 18:31:27 +0000 Received: by mail-pg1-x529.google.com with SMTP id a38so5548089pgl.9 for ; Fri, 20 May 2022 11:31:23 -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=iO2fsPEYlQDVIZ7lQbZaJ20cTBcTRTZy5qAAh7ygKlw=; b=ElaW/bNy9MYn5dDTQY1NdS7ysepHanfeFKkEUsNW0pkWDxH6vU6ie6Ar15TG24IAw8 KvKIl/HtBdRS2/KehJEFHWQqHh5MeEFA+vfBiED0USOmBE5yXfWS9Wvffw/0AbrpVtbU mPfQt00ethvn27cHUNGEjR5bmUrc5nmnuvqQ2pJdjHK3X2u8A5w4fwQihySTH0vC6IbN jp94SMNXHyWziVGB79Od1bBqWhCwI2oT+OgRkok8dxtV5bBQn1SfyXtAXLMfMWQQqD8R vCgTi6nDZ2ZcAHX+S57c3wOZ0GxMgNTR1M4DJRyFDMc/E2Q5i3T+w4NT+rvIICfW+k0A uZ9g== 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=iO2fsPEYlQDVIZ7lQbZaJ20cTBcTRTZy5qAAh7ygKlw=; b=qxF9b/JdYvpnmoszWp/a9U2gaDzQgx1qeAWH4jdkua9F0/k4dg1XR0Am7VW4vq76N/ K4g2XkQL10TiB/j299NmvC6inb7CMdLQjxtve0rGLhK0SVljS1SWG0Kj3HgXKS+RENmz AqI+MWGx5uH4rTob4FmAiPNQuJSB6vtHRaulKpcCjpzxwt7PAR1KMNUmPbbrfS8HOabf RNhZ9ZRhhOAi4vy+PEaBW7qDfsD8/Sq38xQVOx0LpIgRyaGs1rhEpJLeUylM4/QBeZ+r i9DEGxupFxUt3mpHulIX9ZP4h2eESdCk5/pGVaiomHD6FLwox2m5HWFq7z6pKMBi5g7U 1rNA== X-Gm-Message-State: AOAM530BwL3jX5SXeei/3AjzE6erJQMVActyM0fOxb8w4Fo0Uq/Zm8nc gB88LypUdhZ3knF1ffHpqPs= X-Google-Smtp-Source: ABdhPJzlYBXhoGS1RkVSAv1iowtzHG6oaqlqF4zDokBBmUHNjpObKmyWvTYKGPZEXZ6CDfy1Ud4GoQ== X-Received: by 2002:a05:6a00:14c8:b0:518:7789:d33b with SMTP id w8-20020a056a0014c800b005187789d33bmr2131553pfu.36.1653071482505; Fri, 20 May 2022 11:31:22 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id i3-20020a170902c94300b0016168e90f3fsm87476pla.5.2022.05.20.11.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 11:31:22 -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 v3 1/2] dt-bindings: mmc: Add Broadcom optional sdio_freq clock Date: Fri, 20 May 2022 14:31:07 -0400 Message-Id: <20220520183108.47358-2-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220520183108.47358-1-kdasu.kdev@gmail.com> References: <20220520183108.47358-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220520_113125_596103_42AD0194 X-CRM114-Status: GOOD ( 12.56 ) 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 "clock-frequency" specifies a base clock frequency in Hz that overrides the base clock frequency in the CAPS registers. Signed-off-by: Kamal Dasu Reviewed-by: Krzysztof Kozlowski Acked-by: Florian Fainelli --- .../bindings/mmc/brcm,sdhci-brcmstb.yaml | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml index b672202fff4e..c92bfd4eb83a 100644 --- a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +++ b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml @@ -10,9 +10,6 @@ maintainers: - Al Cooper - Florian Fainelli -allOf: - - $ref: mmc-controller.yaml# - properties: compatible: oneOf: @@ -42,23 +39,46 @@ 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: handle to improved 150Mhz clock for sdhci controller (Optional clock) clock-names: + minItems: 1 items: - const: sw_sdio + - const: sdio_freq # Optional clock + + clock-frequency: + description: + Maximum operating frequency of sdio_freq sdhci controller clock + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 100000000 + maximum: 150000000 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: + - clock-frequency + required: - compatible - reg - interrupts - clocks + - clock-names unevaluatedProperties: false From patchwork Fri May 20 18:31:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12857283 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 A9B7FC433EF for ; Fri, 20 May 2022 18:40:49 +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=Jmn1FWdsCXmWzERKuhmHRzjuOAfwTRTCWtOiryMr204=; b=zukOp8iq9t1TX/ cR7fMt9tdQ8FhzQHUmvLMFlNnCNdjk4NyEsZxzD5f0H9MVBFQhvm7MOYh3Cwsqe1Nx/HRhsLDfzlK tZCuHWnDNi5B2t2UaN2itWvkzuPRZE7n3ZsnhAcM1zr3gEvdiETKRKPRdPXQg/ovVbba6ZQWXgDcZ GN0n/4qALZ4A6IrMhe89ecaTpeMzTZoVV6yZ4GbI+xEAZTZ6WNKTLgb0zLWHVDMKEyLHSF4DGaYLr qcXPwQnRhsBj2cLRnVjB/7htAkarUfQv1p00tQRaobL8wZL8oNwj/YxsItJ0I8hNha1mMV8W0719y iT2IUr2IOpvrlhU1bpVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ns7X7-00EF19-BF; Fri, 20 May 2022 18:39:30 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ns7PN-00E9Uo-Ah for linux-arm-kernel@lists.infradead.org; Fri, 20 May 2022 18:31:31 +0000 Received: by mail-pf1-x432.google.com with SMTP id u15so8388632pfi.3 for ; Fri, 20 May 2022 11:31:26 -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=TrVBwi9ChEStDb414/EQSVLSr7SDyZse6yMzYWxEvEo=; b=UBL+P3X7ctSbd7Skb4jmW1zTGbI0arseg8tprz5invYnTFI6mLJBPkwWhZHwuOrBRo Y7KynSP2iDw8VCXkrcbOp18wQR1aHj11ADhnppvJgiGg6POma4kKwUctl5IzIheyezy9 JjaPLnHnR3vZZMH7WtZA0+/cVHWMbp9lRVyq1S3E7reScBmpcb5Z11qh7i6VTpJCDv3f +T5DaJStwAjIdtYdVw48QjyaHq3TIQi0yJgzdTz9lWL2DTeQdjzi5NmA3aOqUXvWV8hG HtsZKqmzAdXv3lFl6bPFQ5LQ7zwdybdB3mBS2Z4lOCvgcdJKjoAA17GGFJzJwK6tmHF4 tisA== 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=TrVBwi9ChEStDb414/EQSVLSr7SDyZse6yMzYWxEvEo=; b=0siY2hUSnWlcgqArkhsDnveUl9XjoeHN7jd5jphE6jeAqOTe6OYpR9Cwz+eH2lsr/0 iX/SuybUOzo2OyHT3OOUKeW7wir/XgDjNEjQikYfwM4VbxeRi1vbdD9aAXoXSQRLxWxy tYnGgH240y+bjiOlOqMCD9KFsPKvJMuwMX4Mcwh5Q6kMZCcUUdD24thMAGT6z/E+J3jb CEz4Xi7iCLehUkV0HsGVsbG/MtVq271YGCdH3SiSiPv1PNNBZv2GVFFECfvnuzI/D7Ki BxIcT9DrNezqzWV9kXriixH9hQphdhPxs1wHcM0FKTzXCF58Kcm9nftzAM27pSJTFgKy y4sA== X-Gm-Message-State: AOAM532oOvMuPFWcg6Y9O0OA93lstIx7JO90A2fEEYrSNRvH4ILSxZoB 3RelfsX8I+pMNT0zsHM0qUA= X-Google-Smtp-Source: ABdhPJwBo7UF6JOo07RO6EF+qP1fWBEV2SUIBn+kEMRUBayh3o4ygeHqrkqMQBkdxaNQ0BCsm9GY1w== X-Received: by 2002:a65:6888:0:b0:3f5:f0e3:c443 with SMTP id e8-20020a656888000000b003f5f0e3c443mr9571332pgt.396.1653071485934; Fri, 20 May 2022 11:31:25 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id i3-20020a170902c94300b0016168e90f3fsm87476pla.5.2022.05.20.11.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 11:31:25 -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 v3 2/2] mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0 Date: Fri, 20 May 2022 14:31:08 -0400 Message-Id: <20220520183108.47358-3-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220520183108.47358-1-kdasu.kdev@gmail.com> References: <20220520183108.47358-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220520_113129_490027_A4D19049 X-CRM114-Status: GOOD ( 21.58 ) 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. 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 Acked-by: Florian Fainelli --- drivers/mmc/host/sdhci-brcmstb.c | 69 +++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index 8eb57de48e0c..f8dff8537920 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -31,6 +31,8 @@ struct sdhci_brcmstb_priv { void __iomem *cfg_regs; unsigned int flags; + struct clk *base_clk; + u32 base_freq_hz; }; struct brcmstb_match_priv { @@ -250,9 +252,11 @@ 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 actual_clock_mhz; struct sdhci_host *host; struct resource *iomem; struct clk *clk; + struct clk *base_clk; int res; match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node); @@ -330,6 +334,35 @@ 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, "clock-frequency", + &priv->base_freq_hz) != 0) + goto add_host; + + base_clk = devm_clk_get_optional(&pdev->dev, "sdio_freq"); + if (IS_ERR(base_clk)) { + dev_warn(&pdev->dev, "Clock for \"sdio_freq\" not found\n"); + goto add_host; + } + + res = clk_prepare_enable(base_clk); + if (res) + goto err; + + /* set improved clock rate */ + clk_set_rate(base_clk, priv->base_freq_hz); + actual_clock_mhz = clk_get_rate(base_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); + priv->base_clk = base_clk; + +add_host: res = sdhci_brcmstb_add_host(host, priv); if (res) goto err; @@ -340,6 +373,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) err: sdhci_pltfm_free(pdev); err_clk: + clk_disable_unprepare(base_clk); clk_disable_unprepare(clk); return res; } @@ -351,11 +385,44 @@ static void sdhci_brcmstb_shutdown(struct platform_device *pdev) MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match); +#ifdef CONFIG_PM_SLEEP +static int sdhci_brcmstb_suspend(struct device *dev) +{ + struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); + + clk_disable_unprepare(priv->base_clk); + return sdhci_pltfm_suspend(dev); +} + +static int sdhci_brcmstb_resume(struct device *dev) +{ + struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); + int ret; + + ret = sdhci_pltfm_resume(dev); + if (!ret && priv->base_freq_hz) { + ret = clk_prepare_enable(priv->base_clk); + if (!ret) + ret = clk_set_rate(priv->base_clk, priv->base_freq_hz); + } + + return ret; +} +#endif + +static const struct dev_pm_ops sdhci_brcmstb_pmops = { + SET_SYSTEM_SLEEP_PM_OPS(sdhci_brcmstb_suspend, sdhci_brcmstb_resume) +}; + static struct platform_driver sdhci_brcmstb_driver = { .driver = { .name = "sdhci-brcmstb", .probe_type = PROBE_PREFER_ASYNCHRONOUS, - .pm = &sdhci_pltfm_pmops, + .pm = &sdhci_brcmstb_pmops, .of_match_table = of_match_ptr(sdhci_brcm_of_match), }, .probe = sdhci_brcmstb_probe,