From: Adrian Hunter <adrian.hunter@intel.com>
To: Doug Brown <doug@schmorgal.com>
Cc: Rob Herring <robh+dt@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
linux-mmc@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 5/8] mmc: sdhci-pxav2: add optional core clock
Date: Thu, 22 Dec 2022 19:42:29 +0200 [thread overview]
Message-ID: <6811cd9f-669b-95e7-dff6-c0ec3978ebb6@intel.com> (raw)
In-Reply-To: <c9e5e377-f3ce-87c2-0ff1-aae8da7045a0@intel.com>
On 22/12/22 19:33, Adrian Hunter wrote:
> On 2/12/22 05:13, Doug Brown wrote:
>> Add ability to have an optional core clock just like the pxav3 driver.
>> The PXA168 needs this because its SDHC controllers have separate core
>> and io clocks that both need to be enabled. This also correctly matches
>> the documented devicetree bindings for this driver.
>>
>> Signed-off-by: Doug Brown <doug@schmorgal.com>
>> ---
>> drivers/mmc/host/sdhci-pxav2.c | 40 ++++++++++++++++++++++++++++++----
>> 1 file changed, 36 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c
>> index 509ba5dd4a4a..1f0c3028987a 100644
>> --- a/drivers/mmc/host/sdhci-pxav2.c
>> +++ b/drivers/mmc/host/sdhci-pxav2.c
>> @@ -41,6 +41,10 @@
>> #define MMC_CARD 0x1000
>> #define MMC_WIDTH 0x0100
>>
>> +struct sdhci_pxav2_host {
>> + struct clk *clk_core;
>> +};
>> +
>> static void pxav2_reset(struct sdhci_host *host, u8 mask)
>> {
>> struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
>> @@ -176,6 +180,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
>> {
>> struct sdhci_pltfm_host *pltfm_host;
>> struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
>> + struct sdhci_pxav2_host *pxav2_host;
>> struct device *dev = &pdev->dev;
>> struct sdhci_host *host = NULL;
>> const struct of_device_id *match;
>> @@ -183,11 +188,12 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
>> int ret;
>> struct clk *clk;
>>
>> - host = sdhci_pltfm_init(pdev, NULL, 0);
>> + host = sdhci_pltfm_init(pdev, NULL, sizeof(*pxav2_host));
>> if (IS_ERR(host))
>> return PTR_ERR(host);
>>
>> pltfm_host = sdhci_priv(host);
>> + pxav2_host = sdhci_pltfm_priv(pltfm_host);
>>
>> clk = devm_clk_get(dev, "io");
>> if (IS_ERR(clk))
>> @@ -204,6 +210,15 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
>> goto free;
>> }
>>
>> + pxav2_host->clk_core = devm_clk_get(dev, "core");
>
> This can use devm_clk_get_optional_enabled()
>
>> + if (!IS_ERR(pxav2_host->clk_core)) {
>> + ret = clk_prepare_enable(pxav2_host->clk_core);
>> + if (ret) {
>> + dev_err(&pdev->dev, "failed to enable core clock\n");
>
> if (IS_ERR(pxav2_host->clk_core)) {
> dev_err_probe(&pdev->dev, PTR_ERR(pxav2_host->clk_core), "failed to enable core clock\n");
>
>> + goto disable_io_clk;
>> + }
>> + }
>> +
>> host->quirks = SDHCI_QUIRK_BROKEN_ADMA
>> | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
>> | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN;
>> @@ -240,17 +255,34 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
>>
>> ret = sdhci_add_host(host);
>> if (ret)
>> - goto disable_clk;
>> + goto disable_core_clk;
>>
>> return 0;
>>
>> -disable_clk:
>> +disable_core_clk:
>> + if (!IS_ERR(pxav2_host->clk_core))
>
> With changes above this would need to be: IS_ERR_OR_NULL
Actually with changes above, it is taken care of by devm so
clk_disable_unprepare is not needed.
>
>
>> + clk_disable_unprepare(pxav2_host->clk_core);
>> +disable_io_clk:
>> clk_disable_unprepare(clk);
>> free:
>> sdhci_pltfm_free(pdev);
>> return ret;
>> }
>>
>> +static int sdhci_pxav2_remove(struct platform_device *pdev)
>> +{
>> + struct sdhci_host *host = platform_get_drvdata(pdev);
>> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>> + struct sdhci_pxav2_host *pxav2_host = sdhci_pltfm_priv(pltfm_host);
>> +
>> + int ret = sdhci_pltfm_unregister(pdev);
>> +
>> + if (!IS_ERR(pxav2_host->clk_core))
>
> With changes above this would need to be: IS_ERR_OR_NULL
Ditto
>
>> + clk_disable_unprepare(pxav2_host->clk_core);
>> +
>> + return ret;
>> +}
>> +
>> static struct platform_driver sdhci_pxav2_driver = {
>> .driver = {
>> .name = "sdhci-pxav2",
>> @@ -259,7 +291,7 @@ static struct platform_driver sdhci_pxav2_driver = {
>> .pm = &sdhci_pltfm_pmops,
>> },
>> .probe = sdhci_pxav2_probe,
>> - .remove = sdhci_pltfm_unregister,
>> + .remove = sdhci_pxav2_remove,
>> };
>>
>> module_platform_driver(sdhci_pxav2_driver);
>
next prev parent reply other threads:[~2022-12-22 17:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 3:13 [PATCH v2 0/8] mmc: sdhci-pxav2: Add support for PXA168 Doug Brown
2022-12-02 3:13 ` [PATCH v2 1/8] mmc: sdhci-pxav2: add initial support for PXA168 V1 controller Doug Brown
2022-12-22 16:03 ` Adrian Hunter
2022-12-26 20:35 ` Doug Brown
2022-12-29 11:40 ` Adrian Hunter
2022-12-02 3:13 ` [PATCH v2 2/8] mmc: sdhci-pxav2: enable CONFIG_MMC_SDHCI_IO_ACCESSORS Doug Brown
2022-12-02 3:13 ` [PATCH v2 3/8] mmc: sdhci-pxav2: add register workaround for PXA168 silicon bug Doug Brown
2022-12-02 3:13 ` [PATCH v2 4/8] mmc: sdhci-pxav2: change clock name to match DT bindings Doug Brown
2022-12-22 16:30 ` Adrian Hunter
2022-12-02 3:13 ` [PATCH v2 5/8] mmc: sdhci-pxav2: add optional core clock Doug Brown
2022-12-22 17:33 ` Adrian Hunter
2022-12-22 17:42 ` Adrian Hunter [this message]
2022-12-02 3:13 ` [PATCH v2 6/8] mmc: sdhci-pxav2: add SDIO card IRQ workaround for PXA168 V1 controller Doug Brown
2022-12-22 17:48 ` Adrian Hunter
2022-12-02 3:13 ` [PATCH v2 7/8] mmc: sdhci-pxav2: add optional pinctrl for SDIO IRQ workaround Doug Brown
2022-12-02 3:13 ` [PATCH v2 8/8] dt-bindings: mmc: sdhci-pxa: add pxav1 Doug Brown
2022-12-02 9:13 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6811cd9f-669b-95e7-dff6-c0ec3978ebb6@intel.com \
--to=adrian.hunter@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=doug@schmorgal.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-mmc@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox