linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] serial: 8250_dw: add support for clk api
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
@ 2013-03-19 10:35 ` Maxime Ripard
  2013-03-19 10:50   ` Maxime Ripard
  2013-03-19 10:52   ` [PATCH] " Maxime Ripard
  2013-03-19 10:35 ` [PATCH 2/7] ARM: sunxi: dt: Use clocks property instead of clock-frequency for the UARTs Maxime Ripard
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Emilio López,
	Greg Kroah-Hartman, Jiri Slaby, linux-kernel

From: Emilio López <emilio@elopez.com.ar>

This commit implements support for using the clk api; this lets us use
the "clocks" property with device tree, instead of having to use
clock-frequency.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
---
 drivers/tty/serial/8250/8250_dw.c |   33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index db0e66f..3dedd24 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -26,6 +26,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 
 #include "8250.h"
 
@@ -55,8 +56,9 @@
 
 
 struct dw8250_data {
-	int	last_lcr;
-	int	line;
+	int		last_lcr;
+	int		line;
+	struct clk	*clk;
 };
 
 static void dw8250_serial_out(struct uart_port *p, int offset, int value)
@@ -136,8 +138,13 @@ static int dw8250_probe_of(struct uart_port *p)
 	if (!of_property_read_u32(np, "reg-shift", &val))
 		p->regshift = val;
 
+	/* clock got configured through clk api, all done */
+	if (IS_ERR(p->uartclk))
+		return 0;
+
+	/* try to find out clock frequency from DT as fallback */
 	if (of_property_read_u32(np, "clock-frequency", &val)) {
-		dev_err(p->dev, "no clock-frequency property set\n");
+		dev_err(p->dev, "clk or clock-frequency not defined\n");
 		return -EINVAL;
 	}
 	p->uartclk = val;
@@ -294,9 +301,20 @@ static int dw8250_probe(struct platform_device *pdev)
 	if (!uart.port.membase)
 		return -ENOMEM;
 
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->clk = devm_clk_get(&pdev->dev, NULL);
+	if (!IS_ERR(data->clk)) {
+		clk_prepare_enable(data->clk);
+		uart.port.uartclk = clk_get_rate(data->clk);
+	}
+
 	uart.port.iotype = UPIO_MEM;
 	uart.port.serial_in = dw8250_serial_in;
 	uart.port.serial_out = dw8250_serial_out;
+	uart.port.private_data = data;
 
 	dw8250_setup_port(&uart);
 
@@ -312,12 +330,6 @@ static int dw8250_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	uart.port.private_data = data;
-
 	data->line = serial8250_register_8250_port(&uart);
 	if (data->line < 0)
 		return data->line;
@@ -333,6 +345,9 @@ static int dw8250_remove(struct platform_device *pdev)
 
 	serial8250_unregister_port(data->line);
 
+	if (!IS_ERR(data->clk))
+		clk_disable_unprepare(data->clk);
+
 	return 0;
 }
 
-- 
1.7.10.4


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

* [PATCH 2/7] ARM: sunxi: dt: Use clocks property instead of clock-frequency for the UARTs
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
  2013-03-19 10:35 ` [PATCH 1/7] serial: 8250_dw: add support for clk api Maxime Ripard
@ 2013-03-19 10:35 ` Maxime Ripard
  2013-03-19 10:35 ` [PATCH 3/7] ARM: sunxi: Rename uart nodes to serial Maxime Ripard
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Russell King, linux-kernel

It will be especially useful when we will have the clock definitions in
the device tree.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Emilio López <emilio@elopez.com.ar>
Tested-by: Emilio López <emilio@elopez.com.ar>
---
 arch/arm/boot/dts/sunxi.dtsi |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi
index 8b36abe..791c02a 100644
--- a/arch/arm/boot/dts/sunxi.dtsi
+++ b/arch/arm/boot/dts/sunxi.dtsi
@@ -65,7 +65,7 @@
 			interrupts = <1>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clock-frequency = <24000000>;
+			clocks = <&osc>;
 			status = "disabled";
 		};
 
@@ -75,7 +75,7 @@
 			interrupts = <2>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clock-frequency = <24000000>;
+			clocks = <&osc>;
 			status = "disabled";
 		};
 	};
-- 
1.7.10.4


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

* [PATCH 3/7] ARM: sunxi: Rename uart nodes to serial
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
  2013-03-19 10:35 ` [PATCH 1/7] serial: 8250_dw: add support for clk api Maxime Ripard
  2013-03-19 10:35 ` [PATCH 2/7] ARM: sunxi: dt: Use clocks property instead of clock-frequency for the UARTs Maxime Ripard
@ 2013-03-19 10:35 ` Maxime Ripard
  2013-03-19 10:35 ` [PATCH 4/7] ARM: sunxi: dt: Move uart0 to sun4i-a10.dtsi Maxime Ripard
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Russell King, linux-kernel

The other architecture use serial@address for their uart nodes, so
rename our uart dt nodes to be consistent

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |    4 ++--
 arch/arm/boot/dts/sun4i-a10-hackberry.dts  |    2 +-
 arch/arm/boot/dts/sun5i-a13-olinuxino.dts  |    2 +-
 arch/arm/boot/dts/sunxi.dtsi               |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
index 88e2dc1..cd06a3c 100644
--- a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
+++ b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
@@ -36,11 +36,11 @@
 			};
 		};
 
-		uart0: uart@01c28000 {
+		uart0: serial@01c28000 {
 			status = "okay";
 		};
 
-		uart1: uart@01c28400 {
+		uart1: serial@01c28400 {
 			status = "okay";
 		};
 	};
diff --git a/arch/arm/boot/dts/sun4i-a10-hackberry.dts b/arch/arm/boot/dts/sun4i-a10-hackberry.dts
index f84549a..9ab6875 100644
--- a/arch/arm/boot/dts/sun4i-a10-hackberry.dts
+++ b/arch/arm/boot/dts/sun4i-a10-hackberry.dts
@@ -23,7 +23,7 @@
 	};
 
 	soc {
-		uart0: uart@01c28000 {
+		uart0: serial@01c28000 {
 			status = "okay";
 		};
 	};
diff --git a/arch/arm/boot/dts/sun5i-a13-olinuxino.dts b/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
index 33d1c7e..f1579a8 100644
--- a/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
+++ b/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
@@ -32,7 +32,7 @@
 			};
 		};
 
-		uart1: uart@01c28400 {
+		uart1: serial@01c28400 {
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart1_pins_b>;
 			status = "okay";
diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi
index 791c02a..1e0f4b5 100644
--- a/arch/arm/boot/dts/sunxi.dtsi
+++ b/arch/arm/boot/dts/sunxi.dtsi
@@ -59,7 +59,7 @@
 			#interrupt-cells = <1>;
 		};
 
-		uart0: uart@01c28000 {
+		uart0: serial@01c28000 {
 			compatible = "snps,dw-apb-uart";
 			reg = <0x01c28000 0x400>;
 			interrupts = <1>;
@@ -69,7 +69,7 @@
 			status = "disabled";
 		};
 
-		uart1: uart@01c28400 {
+		uart1: serial@01c28400 {
 			compatible = "snps,dw-apb-uart";
 			reg = <0x01c28400 0x400>;
 			interrupts = <2>;
-- 
1.7.10.4


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

* [PATCH 4/7] ARM: sunxi: dt: Move uart0 to sun4i-a10.dtsi
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
                   ` (2 preceding siblings ...)
  2013-03-19 10:35 ` [PATCH 3/7] ARM: sunxi: Rename uart nodes to serial Maxime Ripard
@ 2013-03-19 10:35 ` Maxime Ripard
  2013-03-19 10:35 ` [PATCH 5/7] ARM: sunxi: dt: Add uart3 dt node Maxime Ripard
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Russell King, linux-kernel

The UART0 is only available on the Allwinner A10 SoCs, and not on the
A13, so move the uart0 node to sun4i-a10.dtsi.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Emilio López <emilio@elopez.com.ar>
Tested-by: Emilio López <emilio@elopez.com.ar>
---
 arch/arm/boot/dts/sun4i-a10.dtsi |   10 ++++++++++
 arch/arm/boot/dts/sunxi.dtsi     |   10 ----------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 03d2b53..b605672 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -47,5 +47,15 @@
 				allwinner,pull = <0>;
 			};
 		};
+
+		uart0: serial@01c28000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28000 0x400>;
+			interrupts = <1>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
 	};
 };
diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi
index 1e0f4b5..cf53c43 100644
--- a/arch/arm/boot/dts/sunxi.dtsi
+++ b/arch/arm/boot/dts/sunxi.dtsi
@@ -59,16 +59,6 @@
 			#interrupt-cells = <1>;
 		};
 
-		uart0: serial@01c28000 {
-			compatible = "snps,dw-apb-uart";
-			reg = <0x01c28000 0x400>;
-			interrupts = <1>;
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			clocks = <&osc>;
-			status = "disabled";
-		};
-
 		uart1: serial@01c28400 {
 			compatible = "snps,dw-apb-uart";
 			reg = <0x01c28400 0x400>;
-- 
1.7.10.4


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

* [PATCH 5/7] ARM: sunxi: dt: Add uart3 dt node
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
                   ` (3 preceding siblings ...)
  2013-03-19 10:35 ` [PATCH 4/7] ARM: sunxi: dt: Move uart0 to sun4i-a10.dtsi Maxime Ripard
@ 2013-03-19 10:35 ` Maxime Ripard
  2013-03-19 10:35 ` [PATCH 6/7] ARM: sunxi: dt: Add A10 UARTs to the dtsi Maxime Ripard
  2013-03-19 10:35 ` [PATCH 7/7] ARM: sunxi: hackberry: Add UART muxing Maxime Ripard
  6 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Russell King, linux-kernel

Both A10 and A13 Allwinner SoCs have a Synopsys APB uart3 device
available, so add it to the sunxi.dtsi file

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Emilio López <emilio@elopez.com.ar>
---
 arch/arm/boot/dts/sunxi.dtsi |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi
index cf53c43..a85030b 100644
--- a/arch/arm/boot/dts/sunxi.dtsi
+++ b/arch/arm/boot/dts/sunxi.dtsi
@@ -68,5 +68,15 @@
 			clocks = <&osc>;
 			status = "disabled";
 		};
+
+		uart3: serial@01c28c00 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28c00 0x400>;
+			interrupts = <4>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
 	};
 };
-- 
1.7.10.4


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

* [PATCH 6/7] ARM: sunxi: dt: Add A10 UARTs to the dtsi.
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
                   ` (4 preceding siblings ...)
  2013-03-19 10:35 ` [PATCH 5/7] ARM: sunxi: dt: Add uart3 dt node Maxime Ripard
@ 2013-03-19 10:35 ` Maxime Ripard
  2013-03-19 10:35 ` [PATCH 7/7] ARM: sunxi: hackberry: Add UART muxing Maxime Ripard
  6 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Russell King, linux-kernel

The Allwinner A10 SoC has 8 available UARTs, which is 6 more than on the
A13, so add the missing UARTs to the sun4i-a10 dtsi.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Emilio López <emilio@elopez.com.ar>
---
 arch/arm/boot/dts/sun4i-a10.dtsi |   50 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index b605672..68a27fc 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -57,5 +57,55 @@
 			clocks = <&osc>;
 			status = "disabled";
 		};
+
+		uart2: serial@01c28800 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28800 0x400>;
+			interrupts = <3>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
+
+		uart4: serial@01c29000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c29000 0x400>;
+			interrupts = <17>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
+
+		uart5: serial@01c29400 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c29400 0x400>;
+			interrupts = <18>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
+
+		uart6: serial@01c29800 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c29800 0x400>;
+			interrupts = <19>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
+
+		uart7: serial@01c29c00 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c29c00 0x400>;
+			interrupts = <20>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc>;
+			status = "disabled";
+		};
 	};
 };
-- 
1.7.10.4


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

* [PATCH 7/7] ARM: sunxi: hackberry: Add UART muxing
       [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
                   ` (5 preceding siblings ...)
  2013-03-19 10:35 ` [PATCH 6/7] ARM: sunxi: dt: Add A10 UARTs to the dtsi Maxime Ripard
@ 2013-03-19 10:35 ` Maxime Ripard
  6 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Russell King, linux-kernel

We previously relied on the bootloader to do the muxing of the UART for
the Hackberry. Don't rely on it anymore and use pinctrl.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Emilio López <emilio@elopez.com.ar>
---
 arch/arm/boot/dts/sun4i-a10-hackberry.dts |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-hackberry.dts b/arch/arm/boot/dts/sun4i-a10-hackberry.dts
index 9ab6875..2046000 100644
--- a/arch/arm/boot/dts/sun4i-a10-hackberry.dts
+++ b/arch/arm/boot/dts/sun4i-a10-hackberry.dts
@@ -24,6 +24,8 @@
 
 	soc {
 		uart0: serial@01c28000 {
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart0_pins_a>;
 			status = "okay";
 		};
 	};
-- 
1.7.10.4


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

* Re: [PATCH 1/7] serial: 8250_dw: add support for clk api
  2013-03-19 10:35 ` [PATCH 1/7] serial: 8250_dw: add support for clk api Maxime Ripard
@ 2013-03-19 10:50   ` Maxime Ripard
  2013-03-19 10:52   ` [PATCH] " Maxime Ripard
  1 sibling, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:50 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Emilio López, Greg Kroah-Hartman, linux-kernel,
	linux-serial, sunny, shuge, Jiri Slaby, kevin

Hi,

Le 19/03/2013 11:35, Maxime Ripard a écrit :
> From: Emilio López <emilio@elopez.com.ar>
> 
> This commit implements support for using the clk api; this lets us use
> the "clocks" property with device tree, instead of having to use
> clock-frequency.
> 
> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> ---
>  drivers/tty/serial/8250/8250_dw.c |   33 ++++++++++++++++++++++++---------
>  1 file changed, 24 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index db0e66f..3dedd24 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -26,6 +26,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/acpi.h>
> +#include <linux/clk.h>
>  
>  #include "8250.h"
>  
> @@ -55,8 +56,9 @@
>  
>  
>  struct dw8250_data {
> -	int	last_lcr;
> -	int	line;
> +	int		last_lcr;
> +	int		line;
> +	struct clk	*clk;
>  };
>  
>  static void dw8250_serial_out(struct uart_port *p, int offset, int value)
> @@ -136,8 +138,13 @@ static int dw8250_probe_of(struct uart_port *p)
>  	if (!of_property_read_u32(np, "reg-shift", &val))
>  		p->regshift = val;
>  
> +	/* clock got configured through clk api, all done */
> +	if (IS_ERR(p->uartclk))

Hmm, I messed up here.

I'll resend a new version of this mail without this IS_ERR call

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH] serial: 8250_dw: add support for clk api
  2013-03-19 10:35 ` [PATCH 1/7] serial: 8250_dw: add support for clk api Maxime Ripard
  2013-03-19 10:50   ` Maxime Ripard
@ 2013-03-19 10:52   ` Maxime Ripard
  2013-03-21  8:47     ` Heikki Krogerus
  1 sibling, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:52 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kevin, sunny, shuge, linux-serial, Emilio López,
	Greg Kroah-Hartman, Jiri Slaby, linux-kernel

From: Emilio López <emilio@elopez.com.ar>

This commit implements support for using the clk api; this lets us use
the "clocks" property with device tree, instead of having to use
clock-frequency.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
---
 drivers/tty/serial/8250/8250_dw.c |   33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index db0e66f..3dedd24 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -26,6 +26,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 
 #include "8250.h"
 
@@ -55,8 +56,9 @@
 
 
 struct dw8250_data {
-	int	last_lcr;
-	int	line;
+	int		last_lcr;
+	int		line;
+	struct clk	*clk;
 };
 
 static void dw8250_serial_out(struct uart_port *p, int offset, int value)
@@ -136,8 +138,13 @@ static int dw8250_probe_of(struct uart_port *p)
 	if (!of_property_read_u32(np, "reg-shift", &val))
 		p->regshift = val;
 
+	/* clock got configured through clk api, all done */
+	if (p->uartclk)
+		return 0;
+
+	/* try to find out clock frequency from DT as fallback */
 	if (of_property_read_u32(np, "clock-frequency", &val)) {
-		dev_err(p->dev, "no clock-frequency property set\n");
+		dev_err(p->dev, "clk or clock-frequency not defined\n");
 		return -EINVAL;
 	}
 	p->uartclk = val;
@@ -294,9 +301,20 @@ static int dw8250_probe(struct platform_device *pdev)
 	if (!uart.port.membase)
 		return -ENOMEM;
 
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->clk = devm_clk_get(&pdev->dev, NULL);
+	if (!IS_ERR(data->clk)) {
+		clk_prepare_enable(data->clk);
+		uart.port.uartclk = clk_get_rate(data->clk);
+	}
+
 	uart.port.iotype = UPIO_MEM;
 	uart.port.serial_in = dw8250_serial_in;
 	uart.port.serial_out = dw8250_serial_out;
+	uart.port.private_data = data;
 
 	dw8250_setup_port(&uart);
 
@@ -312,12 +330,6 @@ static int dw8250_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	uart.port.private_data = data;
-
 	data->line = serial8250_register_8250_port(&uart);
 	if (data->line < 0)
 		return data->line;
@@ -333,6 +345,9 @@ static int dw8250_remove(struct platform_device *pdev)
 
 	serial8250_unregister_port(data->line);
 
+	if (!IS_ERR(data->clk))
+		clk_disable_unprepare(data->clk);
+
 	return 0;
 }
 
-- 
1.7.10.4


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

* Re: [PATCH] serial: 8250_dw: add support for clk api
  2013-03-19 10:52   ` [PATCH] " Maxime Ripard
@ 2013-03-21  8:47     ` Heikki Krogerus
  2013-03-26 10:35       ` Maxime Ripard
  0 siblings, 1 reply; 12+ messages in thread
From: Heikki Krogerus @ 2013-03-21  8:47 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-arm-kernel, kevin, sunny, shuge, linux-serial,
	Emilio López, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

On Tue, Mar 19, 2013 at 11:52:49AM +0100, Maxime Ripard wrote:
> From: Emilio López <emilio@elopez.com.ar>
> 
> This commit implements support for using the clk api; this lets us use
> the "clocks" property with device tree, instead of having to use
> clock-frequency.
> 
> Signed-off-by: Emilio López <emilio@elopez.com.ar>

FWIW,

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

-- 
heikki

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

* Re: [PATCH] serial: 8250_dw: add support for clk api
  2013-03-21  8:47     ` Heikki Krogerus
@ 2013-03-26 10:35       ` Maxime Ripard
  2013-03-26 23:34         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2013-03-26 10:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Heikki Krogerus, linux-arm-kernel, kevin, sunny, shuge,
	linux-serial, Emilio López, Jiri Slaby, linux-kernel

Hi Greg,

Le 21/03/2013 09:47, Heikki Krogerus a écrit :
> On Tue, Mar 19, 2013 at 11:52:49AM +0100, Maxime Ripard wrote:
>> From: Emilio López <emilio@elopez.com.ar>
>>
>> This commit implements support for using the clk api; this lets us use
>> the "clocks" property with device tree, instead of having to use
>> clock-frequency.
>>
>> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> 
> FWIW,
> 
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Would you consider merging this patch, or do you have additional comments?

We have several patch series that depends on this one that I'd like to
see included in 3.10, and we begin to see the end of the 3.9 release cycle.

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH] serial: 8250_dw: add support for clk api
  2013-03-26 10:35       ` Maxime Ripard
@ 2013-03-26 23:34         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2013-03-26 23:34 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Heikki Krogerus, linux-arm-kernel, kevin, sunny, shuge,
	linux-serial, Emilio López, Jiri Slaby, linux-kernel

On Tue, Mar 26, 2013 at 11:35:18AM +0100, Maxime Ripard wrote:
> Hi Greg,
> 
> Le 21/03/2013 09:47, Heikki Krogerus a écrit :
> > On Tue, Mar 19, 2013 at 11:52:49AM +0100, Maxime Ripard wrote:
> >> From: Emilio López <emilio@elopez.com.ar>
> >>
> >> This commit implements support for using the clk api; this lets us use
> >> the "clocks" property with device tree, instead of having to use
> >> clock-frequency.
> >>
> >> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> > 
> > FWIW,
> > 
> > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 
> Would you consider merging this patch, or do you have additional comments?
> 
> We have several patch series that depends on this one that I'd like to
> see included in 3.10, and we begin to see the end of the 3.9 release cycle.

You resent one patch, in the middle of a 7 patch series, with me on the
 cc: and somehow expected me to know that I was supposed to apply it?

Please be specific and realistic with your requests.

Resend it if you feel I should apply it.

greg k-h

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

end of thread, other threads:[~2013-03-26 23:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1363689316-7847-1-git-send-email-maxime.ripard@free-electrons.com>
2013-03-19 10:35 ` [PATCH 1/7] serial: 8250_dw: add support for clk api Maxime Ripard
2013-03-19 10:50   ` Maxime Ripard
2013-03-19 10:52   ` [PATCH] " Maxime Ripard
2013-03-21  8:47     ` Heikki Krogerus
2013-03-26 10:35       ` Maxime Ripard
2013-03-26 23:34         ` Greg Kroah-Hartman
2013-03-19 10:35 ` [PATCH 2/7] ARM: sunxi: dt: Use clocks property instead of clock-frequency for the UARTs Maxime Ripard
2013-03-19 10:35 ` [PATCH 3/7] ARM: sunxi: Rename uart nodes to serial Maxime Ripard
2013-03-19 10:35 ` [PATCH 4/7] ARM: sunxi: dt: Move uart0 to sun4i-a10.dtsi Maxime Ripard
2013-03-19 10:35 ` [PATCH 5/7] ARM: sunxi: dt: Add uart3 dt node Maxime Ripard
2013-03-19 10:35 ` [PATCH 6/7] ARM: sunxi: dt: Add A10 UARTs to the dtsi Maxime Ripard
2013-03-19 10:35 ` [PATCH 7/7] ARM: sunxi: hackberry: Add UART muxing Maxime Ripard

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