[PATCH 7/8] serial: amba-pl011: add start and shutdown support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Fri Sep 27 03:14:17 EDT 2013
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/serial/amba-pl011.c | 45 +++++++++++++++++++++++++++++++++------------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index fc7723e..5a8e633 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -147,14 +147,41 @@ 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);
+
+ 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);
+
+ /*
+ ** Finally, enable the UART
+ */
+ writel((UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_RXE | UART011_CR_RTS),
+ uart->base + UART011_CR);
+
+ return 0;
+}
+
+static void pl011_port_init(struct console_device *cdev)
{
struct amba_uart_port *uart = to_amba_uart_port(cdev);
/*
** First, disable everything.
*/
- writel(0x0, uart->base + UART011_CR);
+ pl011_shutdown(cdev);
/*
* Try to enable the clock producer.
@@ -168,13 +195,7 @@ int pl011_init_port (struct console_device *cdev)
*/
pl011_rlcr(uart, UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN);
- /*
- ** Finally, enable the UART
- */
- writel((UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_RXE | UART011_CR_RTS),
- uart->base + UART011_CR);
-
- return 0;
+ clk_disable(uart->clk);
}
static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
@@ -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