From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Rutland Subject: [PATCH 6/7] mmc: arm-mmci: attempt to get mclk by name Date: Tue, 11 Feb 2014 11:37:11 +0000 Message-ID: <1392118632-11312-7-git-send-email-mark.rutland@arm.com> References: <1392118632-11312-1-git-send-email-mark.rutland@arm.com> Return-path: In-Reply-To: <1392118632-11312-1-git-send-email-mark.rutland-5wv7dgnIgG8@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, pawel.moll-5wv7dgnIgG8@public.gmane.org, Mark Rutland , Russell King , Arnd Bergmann , Chris Ball List-Id: devicetree@vger.kernel.org The primecell device tree binding (from which the pl18x binding is derived from) states that the apb_pclk clock input should be listed first for all primecell devices. The arm-mmci driver requires the mclk clock input, but the way it currently grabs the clock means that it always gets the first clock (which should be apb_pclk). As the AMBA bus code grabs apb_pclk by name, some existing dts provide apb_pclk as the second clock in the clocks list to work around this, in violation of both the primecell binding. The pl18x binding does not mention clocks at all, so the first clock (MCLK) is given an arbitrary name. This patch attempts to fix the mess my having the arm-mmci driver first attempt to get mclk by name. If this fails, it falls back to the old behaviour of simply acquiring the first clock. This is compatible with any old dtb, whether it lists mclk by name or not, and allows the driver to support dtbs which do not violate the bindings. Hopefully this will lead to future uniformity across dtbs. Signed-off-by: Mark Rutland Cc: Russell King Cc: Arnd Bergmann Cc: Chris Ball Cc: Rob Herring Cc: Pawel Moll --- drivers/mmc/host/mmci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index b931226..4af962c 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1470,7 +1470,14 @@ static int mmci_probe(struct amba_device *dev, dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer); dev_dbg(mmc_dev(mmc), "revision = 0x%01x\n", host->hw_revision); - host->clk = devm_clk_get(&dev->dev, NULL); + /* + * For compatibility with old DTBs and platform data, fall back to the + * first clock if there's not an explicitly named "mclk" entry. + */ + host->clk = devm_clk_get(&dev->dev, "mclk"); + if (IS_ERR(host->clk)) + host->clk = devm_clk_get(&dev->dev, NULL); + if (IS_ERR(host->clk)) { ret = PTR_ERR(host->clk); goto host_free; -- 1.8.1.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: mark.rutland@arm.com (Mark Rutland) Date: Tue, 11 Feb 2014 11:37:11 +0000 Subject: [PATCH 6/7] mmc: arm-mmci: attempt to get mclk by name In-Reply-To: <1392118632-11312-1-git-send-email-mark.rutland@arm.com> References: <1392118632-11312-1-git-send-email-mark.rutland@arm.com> Message-ID: <1392118632-11312-7-git-send-email-mark.rutland@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org The primecell device tree binding (from which the pl18x binding is derived from) states that the apb_pclk clock input should be listed first for all primecell devices. The arm-mmci driver requires the mclk clock input, but the way it currently grabs the clock means that it always gets the first clock (which should be apb_pclk). As the AMBA bus code grabs apb_pclk by name, some existing dts provide apb_pclk as the second clock in the clocks list to work around this, in violation of both the primecell binding. The pl18x binding does not mention clocks at all, so the first clock (MCLK) is given an arbitrary name. This patch attempts to fix the mess my having the arm-mmci driver first attempt to get mclk by name. If this fails, it falls back to the old behaviour of simply acquiring the first clock. This is compatible with any old dtb, whether it lists mclk by name or not, and allows the driver to support dtbs which do not violate the bindings. Hopefully this will lead to future uniformity across dtbs. Signed-off-by: Mark Rutland Cc: Russell King Cc: Arnd Bergmann Cc: Chris Ball Cc: Rob Herring Cc: Pawel Moll --- drivers/mmc/host/mmci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index b931226..4af962c 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1470,7 +1470,14 @@ static int mmci_probe(struct amba_device *dev, dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer); dev_dbg(mmc_dev(mmc), "revision = 0x%01x\n", host->hw_revision); - host->clk = devm_clk_get(&dev->dev, NULL); + /* + * For compatibility with old DTBs and platform data, fall back to the + * first clock if there's not an explicitly named "mclk" entry. + */ + host->clk = devm_clk_get(&dev->dev, "mclk"); + if (IS_ERR(host->clk)) + host->clk = devm_clk_get(&dev->dev, NULL); + if (IS_ERR(host->clk)) { ret = PTR_ERR(host->clk); goto host_free; -- 1.8.1.1