linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hdegoede@redhat.com (Hans de Goede)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] mmc: sunxi: Make sample clocks optional
Date: Sat, 16 Jul 2016 12:46:02 +0200	[thread overview]
Message-ID: <1468665964-27142-3-git-send-email-hdegoede@redhat.com> (raw)
In-Reply-To: <1468665964-27142-1-git-send-email-hdegoede@redhat.com>

It turns out that sun4i (A10) and sun5i (A13 & co) do not have sample
clocks, so make them optional.

Since these do not have sample clocks, they cannot (reliably) do
DDR rates, so only set MMC_CAP_1_8V_DDR when we do have sample clks.

Note this patch only changes the devm_clk_get error checking and sets
the clocks to NULL if they don't exists. All the clk_foo calls accept
a NULL clk and will return success when called with a NULL clk, so this
is all that is necessary.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/mmc/host/sunxi-mmc.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index 71a480b..4552ee0 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1016,14 +1016,20 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,
 
 	host->clk_output = devm_clk_get(&pdev->dev, "output");
 	if (IS_ERR(host->clk_output)) {
-		dev_err(&pdev->dev, "Could not get output clock\n");
-		return PTR_ERR(host->clk_output);
+		if (PTR_ERR(host->clk_output) != -ENOENT) {
+			dev_err(&pdev->dev, "Could not get output clock\n");
+			return PTR_ERR(host->clk_output);
+		}
+		host->clk_output = NULL;
 	}
 
 	host->clk_sample = devm_clk_get(&pdev->dev, "sample");
 	if (IS_ERR(host->clk_sample)) {
-		dev_err(&pdev->dev, "Could not get sample clock\n");
-		return PTR_ERR(host->clk_sample);
+		if (PTR_ERR(host->clk_sample) != -ENOENT) {
+			dev_err(&pdev->dev, "Could not get sample clock\n");
+			return PTR_ERR(host->clk_sample);
+		}
+		host->clk_sample = NULL;
 	}
 
 	host->reset = devm_reset_control_get_optional(&pdev->dev, "ahb");
@@ -1126,9 +1132,11 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 	mmc->f_min		=   400000;
 	mmc->f_max		= 52000000;
 	mmc->caps	       |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
-				  MMC_CAP_1_8V_DDR |
 				  MMC_CAP_ERASE | MMC_CAP_SDIO_IRQ;
 
+	if (host->clk_output && host->clk_sample)
+		mmc->caps      |= MMC_CAP_1_8V_DDR;
+
 	ret = mmc_of_parse(mmc);
 	if (ret)
 		goto error_free_dma;
-- 
2.7.4

  parent reply	other threads:[~2016-07-16 10:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-16 10:46 [PATCH 0/4] mmc: sunxi: Make sample clocks optional Hans de Goede
2016-07-16 10:46 ` [PATCH 1/4] mmc: sunxi: Disable sample clks on remove Hans de Goede
2016-07-16 10:46 ` Hans de Goede [this message]
2016-07-18 11:12   ` [PATCH 2/4] mmc: sunxi: Make sample clocks optional Ulf Hansson
2016-07-25  8:18   ` Maxime Ripard
2016-07-30 14:25     ` Hans de Goede
2016-07-16 10:46 ` [PATCH 3/4] ARM: dts: sun4i: Remove sample clocks from mmc host nodes Hans de Goede
2016-07-16 10:46 ` [PATCH 4/4] ARM: dts: sun5i: " Hans de Goede
2016-07-19  8:59 ` [PATCH 0/4] mmc: sunxi: Make sample clocks optional Icenowy Zheng

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=1468665964-27142-3-git-send-email-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).