linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Update Kona drivers to use clocks
@ 2013-10-07 18:23 Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 1/6] ARM: dts: Declare clocks as fixed on bcm11351 Tim Kryger
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:23 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

This series declares the clocks present on bcm11351 (aka bcm281xx) SoCs
to be fixed at the rates configured by development bootloaders and then
updates the Kona drivers to make use of clock calls where appropriate.

This patch series depends on the following three commits being present:

https://lkml.org/lkml/2013/9/18/409
https://lkml.org/lkml/2013/9/20/305
http://www.spinics.net/lists/arm-kernel/msg274973.html

Changes in v2:
  - Renamed bsc4_clk to pmu_bsc_clk

Tim Kryger (6):
  ARM: dts: Declare clocks as fixed on bcm11351
  ARM: dts: Specify clocks for UARTs on bcm11351
  ARM: dts: Specify clocks for SDHCIs on bcm11351
  clocksource: kona: Add basic use of external clock
  ARM: dts: Specify clocks for timer on bcm11351
  mmc: sdhci-bcm-kona: Add basic use of clocks

 arch/arm/boot/dts/bcm11351.dtsi      | 111 +++++++++++++++++++++++++++++++++--
 drivers/clocksource/bcm_kona_timer.c |  14 ++++-
 drivers/mmc/host/sdhci-bcm-kona.c    |  30 +++++++++-
 3 files changed, 145 insertions(+), 10 deletions(-)

-- 
1.8.0.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/6] ARM: dts: Declare clocks as fixed on bcm11351
  2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
@ 2013-10-07 18:23 ` Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 2/6] ARM: dts: Specify clocks for UARTs " Tim Kryger
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:23 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

Declare clocks that are enabled and configured by bootloaders as fixed
rate clocks in the DTS such that device drivers may use standard clock
function calls.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 arch/arm/boot/dts/bcm11351.dtsi | 97 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 98e6bc0..c6464fb 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -126,4 +126,101 @@
 		status = "disabled";
 	};
 
+	clocks {
+		bsc1_clk: bsc1 {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		bsc2_clk: bsc2 {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		bsc3_clk: bsc3 {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		pmu_bsc_clk: pmu_bsc {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		hub_timer_clk: hub_timer {
+			compatible = "fixed-clock";
+			clock-frequency = <32768>;
+			#clock-cells = <0>;
+		};
+
+		pwm_clk: pwm {
+			compatible = "fixed-clock";
+			clock-frequency = <26000000>;
+			#clock-cells = <0>;
+		};
+
+		sdio1_clk: sdio1 {
+			compatible = "fixed-clock";
+			clock-frequency = <48000000>;
+			#clock-cells = <0>;
+		};
+
+		sdio2_clk: sdio2 {
+			compatible = "fixed-clock";
+			clock-frequency = <48000000>;
+			#clock-cells = <0>;
+		};
+
+		sdio3_clk: sdio3 {
+			compatible = "fixed-clock";
+			clock-frequency = <48000000>;
+			#clock-cells = <0>;
+		};
+
+		sdio4_clk: sdio4 {
+			compatible = "fixed-clock";
+			clock-frequency = <48000000>;
+			#clock-cells = <0>;
+		};
+
+		tmon_1m_clk: tmon_1m {
+			compatible = "fixed-clock";
+			clock-frequency = <1000000>;
+			#clock-cells = <0>;
+		};
+
+		uartb_clk: uartb {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		uartb2_clk: uartb2 {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		uartb3_clk: uartb3 {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		uartb4_clk: uartb4 {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		usb_otg_ahb_clk: usb_otg_ahb {
+			compatible = "fixed-clock";
+			clock-frequency = <52000000>;
+			#clock-cells = <0>;
+		};
+	};
 };
-- 
1.8.0.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/6] ARM: dts: Specify clocks for UARTs on bcm11351
  2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 1/6] ARM: dts: Declare clocks as fixed on bcm11351 Tim Kryger
@ 2013-10-07 18:23 ` Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 3/6] ARM: dts: Specify clocks for SDHCIs " Tim Kryger
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:23 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

Rather than declaring the frequency of the external clock, specify the
label of the clock such that the driver may determine the frequency on
its own.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 arch/arm/boot/dts/bcm11351.dtsi | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index c6464fb..ce65367 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -43,7 +43,7 @@
 		compatible = "brcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart";
 		status = "disabled";
 		reg = <0x3e000000 0x1000>;
-		clock-frequency = <13000000>;
+		clocks = <&uartb_clk>;
 		interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
 		reg-shift = <2>;
 		reg-io-width = <4>;
@@ -53,7 +53,7 @@
 		compatible = "brcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart";
 		status = "disabled";
 		reg = <0x3e001000 0x1000>;
-		clock-frequency = <13000000>;
+		clocks = <&uartb2_clk>;
 		interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
 		reg-shift = <2>;
 		reg-io-width = <4>;
@@ -63,7 +63,7 @@
 		compatible = "brcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart";
 		status = "disabled";
 		reg = <0x3e002000 0x1000>;
-		clock-frequency = <13000000>;
+		clocks = <&uartb3_clk>;
 		interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
 		reg-shift = <2>;
 		reg-io-width = <4>;
@@ -73,7 +73,7 @@
 		compatible = "brcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart";
 		status = "disabled";
 		reg = <0x3e003000 0x1000>;
-		clock-frequency = <13000000>;
+		clocks = <&uartb4_clk>;
 		interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
 		reg-shift = <2>;
 		reg-io-width = <4>;
-- 
1.8.0.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/6] ARM: dts: Specify clocks for SDHCIs on bcm11351
  2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 1/6] ARM: dts: Declare clocks as fixed on bcm11351 Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 2/6] ARM: dts: Specify clocks for UARTs " Tim Kryger
@ 2013-10-07 18:23 ` Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 4/6] clocksource: kona: Add basic use of external clock Tim Kryger
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:23 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

Specify the external clock label in each SDHCI node.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 arch/arm/boot/dts/bcm11351.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index ce65367..193659c 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -101,6 +101,7 @@
 	sdio1: sdio@3f180000 {
 		compatible = "brcm,kona-sdhci";
 		reg = <0x3f180000 0x10000>;
+		clocks = <&sdio1_clk>;
 		interrupts = <0x0 77 0x4>;
 		status = "disabled";
 	};
@@ -108,6 +109,7 @@
 	sdio2: sdio@3f190000 {
 		compatible = "brcm,kona-sdhci";
 		reg = <0x3f190000 0x10000>;
+		clocks = <&sdio2_clk>;
 		interrupts = <0x0 76 0x4>;
 		status = "disabled";
 	};
@@ -115,6 +117,7 @@
 	sdio3: sdio@3f1a0000 {
 		compatible = "brcm,kona-sdhci";
 		reg = <0x3f1a0000 0x10000>;
+		clocks = <&sdio3_clk>;
 		interrupts = <0x0 74 0x4>;
 		status = "disabled";
 	};
@@ -122,6 +125,7 @@
 	sdio4: sdio@3f1b0000 {
 		compatible = "brcm,kona-sdhci";
 		reg = <0x3f1b0000 0x10000>;
+		clocks = <&sdio4_clk>;
 		interrupts = <0x0 73 0x4>;
 		status = "disabled";
 	};
-- 
1.8.0.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/6] clocksource: kona: Add basic use of external clock
  2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
                   ` (2 preceding siblings ...)
  2013-10-07 18:23 ` [PATCH v2 3/6] ARM: dts: Specify clocks for SDHCIs " Tim Kryger
@ 2013-10-07 18:23 ` Tim Kryger
  2013-10-07 18:23 ` [PATCH v2 5/6] ARM: dts: Specify clocks for timer on bcm11351 Tim Kryger
  2013-10-07 18:24 ` [PATCH v2 6/6] mmc: sdhci-bcm-kona: Add basic use of clocks Tim Kryger
  5 siblings, 0 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:23 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

When an clock handle is specified in the device tree, enable it and use
it to determine the external clock frequency.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/clocksource/bcm_kona_timer.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c
index 0d7d8c3..fd11f96 100644
--- a/drivers/clocksource/bcm_kona_timer.c
+++ b/drivers/clocksource/bcm_kona_timer.c
@@ -17,6 +17,7 @@
 #include <linux/jiffies.h>
 #include <linux/clockchips.h>
 #include <linux/types.h>
+#include <linux/clk.h>
 
 #include <linux/io.h>
 #include <asm/mach/time.h>
@@ -107,11 +108,18 @@ static const struct of_device_id bcm_timer_ids[] __initconst = {
 static void __init kona_timers_init(struct device_node *node)
 {
 	u32 freq;
+	struct clk *external_clk;
 
-	if (!of_property_read_u32(node, "clock-frequency", &freq))
+	external_clk = of_clk_get_by_name(node, NULL);
+
+	if (!IS_ERR(external_clk)) {
+		arch_timer_rate = clk_get_rate(external_clk);
+		clk_prepare_enable(external_clk);
+	} else if (!of_property_read_u32(node, "clock-frequency", &freq)) {
 		arch_timer_rate = freq;
-	else
-		panic("clock-frequency not set in the .dts file");
+	} else {
+		panic("neither clock-frequency or clocks handle in .dts file");
+	}
 
 	/* Setup IRQ numbers */
 	timers.tmr_irq = irq_of_parse_and_map(node, 0);
-- 
1.8.0.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 5/6] ARM: dts: Specify clocks for timer on bcm11351
  2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
                   ` (3 preceding siblings ...)
  2013-10-07 18:23 ` [PATCH v2 4/6] clocksource: kona: Add basic use of external clock Tim Kryger
@ 2013-10-07 18:23 ` Tim Kryger
  2013-10-07 18:24 ` [PATCH v2 6/6] mmc: sdhci-bcm-kona: Add basic use of clocks Tim Kryger
  5 siblings, 0 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:23 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

Specify the external clock label in the timer node.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 arch/arm/boot/dts/bcm11351.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 193659c..39c1395 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -95,7 +95,7 @@
 		compatible = "brcm,kona-timer";
 		reg = <0x35006000 0x1000>;
 		interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
-		clock-frequency = <32768>;
+		clocks = <&hub_timer_clk>;
 	};
 
 	sdio1: sdio@3f180000 {
-- 
1.8.0.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 6/6] mmc: sdhci-bcm-kona: Add basic use of clocks
  2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
                   ` (4 preceding siblings ...)
  2013-10-07 18:23 ` [PATCH v2 5/6] ARM: dts: Specify clocks for timer on bcm11351 Tim Kryger
@ 2013-10-07 18:24 ` Tim Kryger
  5 siblings, 0 replies; 7+ messages in thread
From: Tim Kryger @ 2013-10-07 18:24 UTC (permalink / raw)
  To: Christian Daudt, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Daniel Lezcano, Thomas Gleixner,
	Chris Ball
  Cc: Tim Kryger, devicetree, linux-arm-kernel, linux-kernel,
	linux-mmc, patches

Enable the external clock needed by the host controller during the
probe and disable it during the remove.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/mmc/host/sdhci-bcm-kona.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 85472d3..91db099 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -54,6 +54,7 @@
 
 struct sdhci_bcm_kona_dev {
 	struct mutex	write_lock; /* protect back to back writes */
+	struct clk	*external_clk;
 };
 
 
@@ -252,11 +253,29 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
 	mmc_of_parse(host->mmc);
 
 	if (!host->mmc->f_max) {
-		dev_err(&pdev->dev, "Missing max-freq for SDHCI cfg\n");
+		dev_err(dev, "Missing max-freq for SDHCI cfg\n");
 		ret = -ENXIO;
 		goto err_pltfm_free;
 	}
 
+	/* Get and enable the external clock */
+	kona_dev->external_clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(kona_dev->external_clk)) {
+		dev_err(dev, "Failed to get external clock\n");
+		ret = PTR_ERR(kona_dev->external_clk);
+		goto err_pltfm_free;
+	}
+
+	if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) {
+		dev_err(dev, "Failed to set rate external clock\n");
+		goto err_pltfm_free;
+	}
+
+	if (clk_prepare_enable(kona_dev->external_clk) != 0) {
+		dev_err(dev, "Failed to enable external clock\n");
+		goto err_pltfm_free;
+	}
+
 	dev_dbg(dev, "non-removable=%c\n",
 		(host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N');
 	dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n",
@@ -271,7 +290,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
 
 	ret = sdhci_bcm_kona_sd_reset(host);
 	if (ret)
-		goto err_pltfm_free;
+		goto err_clk_disable;
 
 	sdhci_bcm_kona_sd_init(host);
 
@@ -307,6 +326,9 @@ err_remove_host:
 err_reset:
 	sdhci_bcm_kona_sd_reset(host);
 
+err_clk_disable:
+	clk_disable_unprepare(kona_dev->external_clk);
+
 err_pltfm_free:
 	sdhci_pltfm_free(pdev);
 
@@ -317,6 +339,8 @@ err_pltfm_free:
 static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
 {
 	struct sdhci_host *host = platform_get_drvdata(pdev);
+	struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host);
+	struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv);
 	int dead;
 	u32 scratch;
 
@@ -326,6 +350,8 @@ static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
 		dead = 1;
 	sdhci_remove_host(host, dead);
 
+	clk_disable_unprepare(kona_dev->external_clk);
+
 	sdhci_free_host(host);
 
 	return 0;
-- 
1.8.0.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-07 18:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-07 18:23 [PATCH v2 0/6] Update Kona drivers to use clocks Tim Kryger
2013-10-07 18:23 ` [PATCH v2 1/6] ARM: dts: Declare clocks as fixed on bcm11351 Tim Kryger
2013-10-07 18:23 ` [PATCH v2 2/6] ARM: dts: Specify clocks for UARTs " Tim Kryger
2013-10-07 18:23 ` [PATCH v2 3/6] ARM: dts: Specify clocks for SDHCIs " Tim Kryger
2013-10-07 18:23 ` [PATCH v2 4/6] clocksource: kona: Add basic use of external clock Tim Kryger
2013-10-07 18:23 ` [PATCH v2 5/6] ARM: dts: Specify clocks for timer on bcm11351 Tim Kryger
2013-10-07 18:24 ` [PATCH v2 6/6] mmc: sdhci-bcm-kona: Add basic use of clocks Tim Kryger

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).