[PATCH 7/8] serial: amba-pl011: add start and shutdown support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Thu Oct 3 03:21:59 EDT 2013


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/serial/amba-pl011.c | 39 ++++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index fc7723e..b7e01dd 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -147,22 +147,24 @@ static void pl011_rlcr(struct amba_uart_port *uart, u32 lcr)
 	}
 }
 
-int pl011_init_port (struct console_device *cdev)
+static void pl011_shutdown(struct console_device *cdev)
 {
 	struct amba_uart_port *uart = to_amba_uart_port(cdev);
 
-	/*
-	 ** First, disable everything.
-	 */
 	writel(0x0, uart->base + UART011_CR);
 
+	clk_disable(uart->clk);
+}
+
+static int pl011_startup(struct console_device *cdev)
+{
+	struct amba_uart_port *uart = to_amba_uart_port(cdev);
+
 	/*
 	 * Try to enable the clock producer.
 	 */
 	clk_enable(uart->clk);
 
-	uart->uartclk = clk_get_rate(uart->clk);
-
 	/*
 	 ** Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled.
 	 */
@@ -177,6 +179,25 @@ int pl011_init_port (struct console_device *cdev)
 	return 0;
 }
 
+static void pl011_port_init(struct console_device *cdev)
+{
+	struct amba_uart_port *uart = to_amba_uart_port(cdev);
+
+	/*
+	 ** First, disable everything.
+	 */
+	pl011_shutdown(cdev);
+
+	/*
+	 * Try to enable the clock producer.
+	 */
+	clk_enable(uart->clk);
+
+	uart->uartclk = clk_get_rate(uart->clk);
+
+	clk_disable(uart->clk);
+}
+
 static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 {
 	struct amba_uart_port *uart;
@@ -192,14 +213,14 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 
 	cdev = &uart->uart;
 	cdev->dev = &dev->dev;
+	cdev->startup = pl011_startup;
+	cdev->shutdown = pl011_shutdown;
 	cdev->tstc = pl011_tstc;
 	cdev->putc = pl011_putc;
 	cdev->getc = pl011_getc;
 	cdev->setbrg = pl011_setbaudrate;
 
-	pl011_init_port(cdev);
-
-	/* Enable UART */
+	pl011_port_init(cdev);
 
 	console_register(cdev);
 
-- 
1.8.4.rc3




More information about the barebox mailing list