Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCHv4 0/7] ARM: sunxi: Extend UART support for Allwinner SoCs
@ 2013-03-19 10:35 Maxime Ripard
  2013-03-19 10:35 ` [PATCH 1/7] serial: 8250_dw: add support for clk api Maxime Ripard
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Maxime Ripard @ 2013-03-19 10:35 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: kevin, sunny, shuge, linux-serial

Hi,

This patchset reworks a bit the UART support that is found in the DT
for Allwinner SoCs, which was quite limited until now.

It first switches to using the clocks property, then rework a bit the
DTSI to have only the UART available in the A10 and the A13 (the A10
has 8 UARTs, while A13 has only the uart1 and uart3).

Thanks,
Maxime

Changes from v3:
  - Renamed uart nodes to serial
  - Reworked the patch for 8250_dw to use the IS_ERR macro for clocks error
    checking

Changes from v2:
  - Reworked Emilio's patch according to Heikki Krogerus' review to enable the
    use of the clock framework even when not using the dt

Emilio López (1):
  serial: 8250_dw: add support for clk api

Maxime Ripard (6):
  ARM: sunxi: dt: Use clocks property instead of clock-frequency for
    the UARTs
  ARM: sunxi: Rename uart nodes to serial
  ARM: sunxi: dt: Move uart0 to sun4i-a10.dtsi
  ARM: sunxi: dt: Add uart3 dt node
  ARM: sunxi: dt: Add A10 UARTs to the dtsi.
  ARM: sunxi: hackberry: Add UART muxing

 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |    4 +-
 arch/arm/boot/dts/sun4i-a10-hackberry.dts  |    4 +-
 arch/arm/boot/dts/sun4i-a10.dtsi           |   60 ++++++++++++++++++++++++++++
 arch/arm/boot/dts/sun5i-a13-olinuxino.dts  |    2 +-
 arch/arm/boot/dts/sunxi.dtsi               |   16 ++++----
 drivers/tty/serial/8250/8250_dw.c          |   33 ++++++++++-----
 6 files changed, 98 insertions(+), 21 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread
* [PATCH] serial: 8250_dw: add support for clk api
@ 2013-03-27 12:35 Maxime Ripard
  2013-03-28 23:03 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 17+ messages in thread
From: Maxime Ripard @ 2013-03-27 12:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Emilio López, Jiri Slaby, linux-serial, 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

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

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

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 10:35 [PATCHv4 0/7] ARM: sunxi: Extend UART support for Allwinner SoCs Maxime Ripard
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
  -- strict thread matches above, loose matches on Subject: below --
2013-03-27 12:35 [PATCH] serial: 8250_dw: add support for clk api Maxime Ripard
2013-03-28 23:03 ` Greg Kroah-Hartman
2013-03-28 23:06   ` Maxime Ripard
2013-03-28 23:09     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox