All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland-5wv7dgnIgG8@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 <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Subject: [PATCH 4/7] spi: pl022: attempt to get sspclk by name
Date: Tue, 11 Feb 2014 11:37:09 +0000	[thread overview]
Message-ID: <1392118632-11312-5-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1392118632-11312-1-git-send-email-mark.rutland-5wv7dgnIgG8@public.gmane.org>

The primecell device tree binding (from which the pl022 binding is
derived from) states that the apb_pclk clock input should be listed
first for all primecell devices. The spi-pl022 driver requires the
sspclk clock input to enable the SPI bus, 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 pl022 binding does not
mention clocks at all, so the first clock (SSPCLK) is given an arbitrary
name.

This patch attempts to fix the mess my having the spi-pl022 driver first
attempt to get sspclk 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 sspclk 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 <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>
---
 drivers/spi/spi-pl022.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 2789b45..4b3941a 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2176,7 +2176,14 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	dev_info(&adev->dev, "mapped registers from %pa to %p\n",
 		&adev->res.start, pl022->virtbase);
 
-	pl022->clk = devm_clk_get(&adev->dev, NULL);
+	/*
+	 * For compatibility with old DTBs and platform data, fall back to the
+	 * first clock if there's not an explicitly named "sspclk" entry.
+	 */
+	pl022->clk = devm_clk_get(&adev->dev, "sspclk");
+	if (IS_ERR(pl022->clk))
+		pl022->clk = devm_clk_get(&adev->dev, NULL);
+
 	if (IS_ERR(pl022->clk)) {
 		status = PTR_ERR(pl022->clk);
 		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
-- 
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

WARNING: multiple messages have this Message-ID (diff)
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] spi: pl022: attempt to get sspclk by name
Date: Tue, 11 Feb 2014 11:37:09 +0000	[thread overview]
Message-ID: <1392118632-11312-5-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1392118632-11312-1-git-send-email-mark.rutland@arm.com>

The primecell device tree binding (from which the pl022 binding is
derived from) states that the apb_pclk clock input should be listed
first for all primecell devices. The spi-pl022 driver requires the
sspclk clock input to enable the SPI bus, 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 pl022 binding does not
mention clocks at all, so the first clock (SSPCLK) is given an arbitrary
name.

This patch attempts to fix the mess my having the spi-pl022 driver first
attempt to get sspclk 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 sspclk 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 <mark.rutland@arm.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
---
 drivers/spi/spi-pl022.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 2789b45..4b3941a 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2176,7 +2176,14 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	dev_info(&adev->dev, "mapped registers from %pa to %p\n",
 		&adev->res.start, pl022->virtbase);
 
-	pl022->clk = devm_clk_get(&adev->dev, NULL);
+	/*
+	 * For compatibility with old DTBs and platform data, fall back to the
+	 * first clock if there's not an explicitly named "sspclk" entry.
+	 */
+	pl022->clk = devm_clk_get(&adev->dev, "sspclk");
+	if (IS_ERR(pl022->clk))
+		pl022->clk = devm_clk_get(&adev->dev, NULL);
+
 	if (IS_ERR(pl022->clk)) {
 		status = PTR_ERR(pl022->clk);
 		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
-- 
1.8.1.1

  parent reply	other threads:[~2014-02-11 11:37 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11 11:37 [PATCH 0/7] primecell: make correct clock parsing possible Mark Rutland
2014-02-11 11:37 ` Mark Rutland
2014-02-11 11:37 ` [PATCH 1/7] Documentation: devicetree: fix up pl011 clocks Mark Rutland
2014-02-11 11:37   ` Mark Rutland
     [not found] ` <1392118632-11312-1-git-send-email-mark.rutland-5wv7dgnIgG8@public.gmane.org>
2014-02-11 11:37   ` [PATCH 2/7] serial: amba-pl011: attempt to get uartclk by name Mark Rutland
2014-02-11 11:37     ` Mark Rutland
2014-02-11 11:37   ` [PATCH 3/7] Documentation: devicetree: fix up pl022 clocks Mark Rutland
2014-02-11 11:37     ` Mark Rutland
     [not found]     ` <1392118632-11312-4-git-send-email-mark.rutland-5wv7dgnIgG8@public.gmane.org>
2014-02-13 12:55       ` Linus Walleij
2014-02-13 12:55         ` Linus Walleij
2014-02-11 11:37   ` Mark Rutland [this message]
2014-02-11 11:37     ` [PATCH 4/7] spi: pl022: attempt to get sspclk by name Mark Rutland
     [not found]     ` <1392118632-11312-5-git-send-email-mark.rutland-5wv7dgnIgG8@public.gmane.org>
2014-02-11 12:06       ` Mark Brown
2014-02-11 12:06         ` Mark Brown
     [not found]         ` <20140211120645.GH13533-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-11 13:39           ` Mark Rutland
2014-02-11 13:39             ` Mark Rutland
2014-02-11 14:08           ` Arnd Bergmann
2014-02-11 14:08             ` Arnd Bergmann
     [not found]             ` <201402111508.06267.arnd-r2nGTMty4D4@public.gmane.org>
2014-02-11 15:04               ` Russell King - ARM Linux
2014-02-11 15:04                 ` Russell King - ARM Linux
     [not found]                 ` <20140211150438.GJ26684-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-02-11 15:48                   ` Arnd Bergmann
2014-02-11 15:48                     ` Arnd Bergmann
2014-02-12 10:33             ` Mark Rutland
2014-02-12 10:33               ` Mark Rutland
     [not found]               ` <20140212103329.GC21992-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2014-02-12 10:55                 ` Mark Brown
2014-02-12 10:55                   ` Mark Brown
2014-02-12 11:21                 ` Arnd Bergmann
2014-02-12 11:21                   ` Arnd Bergmann
     [not found]                   ` <201402121221.51233.arnd-r2nGTMty4D4@public.gmane.org>
2014-02-12 11:47                     ` Mark Rutland
2014-02-12 11:47                       ` Mark Rutland
     [not found]                       ` <20140212114740.GE21992-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2014-02-12 13:03                         ` Arnd Bergmann
2014-02-12 13:03                           ` Arnd Bergmann
2014-02-12 16:12                           ` Mark Rutland
2014-02-12 16:12                             ` Mark Rutland
     [not found]                             ` <20140212161206.GD25957-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2014-02-12 16:22                               ` Mark Brown
2014-02-12 16:22                                 ` Mark Brown
2014-02-12 16:31                               ` Arnd Bergmann
2014-02-12 16:31                                 ` Arnd Bergmann
2014-02-24 12:26                                 ` Linus Walleij
2014-02-24 12:26                                   ` Linus Walleij
2014-02-12 15:13                         ` Mark Brown
2014-02-12 15:13                           ` Mark Brown
2014-02-11 11:37   ` [PATCH 5/7] Documentation: devicetree: fix up pl18x clocks Mark Rutland
2014-02-11 11:37     ` Mark Rutland
2014-02-11 11:37   ` [PATCH 6/7] mmc: arm-mmci: attempt to get mclk by name Mark Rutland
2014-02-11 11:37     ` Mark Rutland
2014-02-11 11:37   ` [PATCH 7/7] Documentation: devicetree: loosen primecell clock requirements Mark Rutland
2014-02-11 11:37     ` Mark Rutland
2014-02-11 12:33   ` [PATCH 0/7] primecell: make correct clock parsing possible Russell King - ARM Linux
2014-02-11 12:33     ` Russell King - ARM Linux
     [not found]     ` <20140211123356.GH26684-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-02-11 13:59       ` Mark Rutland
2014-02-11 13:59         ` Mark Rutland

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=1392118632-11312-5-git-send-email-mark.rutland@arm.com \
    --to=mark.rutland-5wv7dgnigg8@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.