summaryrefslogtreecommitdiffstats
path: root/drivers/serial/amba-pl011.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/amba-pl011.c')
-rw-r--r--drivers/serial/amba-pl011.c67
1 files changed, 29 insertions, 38 deletions
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 9b567e3cd2..b53ff6877b 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* (C) Copyright 2000
* Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
@@ -5,20 +6,6 @@
* (C) Copyright 2004
* ARM Ltd.
* Philippe Robin, <philippe.robin@arm.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
*/
/* Simple U-Boot driver for the PrimeCell PL010/PL011 UARTs */
@@ -67,6 +54,23 @@ to_amba_uart_port(struct console_device *uart)
return container_of(uart, struct amba_uart_port, uart);
}
+static void pl011_rlcr(struct amba_uart_port *uart, u32 lcr)
+{
+ struct vendor_data *vendor = uart->vendor;
+
+ writew(lcr, uart->base + vendor->lcrh_rx);
+ if (vendor->lcrh_tx != vendor->lcrh_rx) {
+ int i;
+ /*
+ * Wait 10 PCLKs before writing LCRH_TX register,
+ * to get this delay write read only register 10 times
+ */
+ for (i = 0; i < 10; ++i)
+ writew(0xff, uart->base + UART011_MIS);
+ writew(lcr, uart->base + vendor->lcrh_tx);
+ }
+}
+
static int pl011_setbaudrate(struct console_device *cdev, int baudrate)
{
struct amba_uart_port *uart = to_amba_uart_port(cdev);
@@ -74,6 +78,7 @@ static int pl011_setbaudrate(struct console_device *cdev, int baudrate)
unsigned int divider;
unsigned int remainder;
unsigned int fraction;
+ uint32_t cr;
/*
** Set baud rate
@@ -87,9 +92,15 @@ static int pl011_setbaudrate(struct console_device *cdev, int baudrate)
temp = (8 * remainder) / baudrate;
fraction = (temp >> 1) + (temp & 1);
+ cr = readl(uart->base + UART011_CR);
+ writel(0x0, uart->base + UART011_CR);
+
writel(divider, uart->base + UART011_IBRD);
writel(fraction, uart->base + UART011_FBRD);
+ pl011_rlcr(uart, UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN);
+ writel(cr, uart->base + UART011_CR);
+
return 0;
}
@@ -131,23 +142,6 @@ static int pl011_tstc(struct console_device *cdev)
return !(readl(uart->base + UART01x_FR) & UART01x_FR_RXFE);
}
-static void pl011_rlcr(struct amba_uart_port *uart, u32 lcr)
-{
- struct vendor_data *vendor = uart->vendor;
-
- writew(lcr, uart->base + vendor->lcrh_rx);
- if (vendor->lcrh_tx != vendor->lcrh_rx) {
- int i;
- /*
- * Wait 10 PCLKs before writing LCRH_TX register,
- * to get this delay write read only register 10 times
- */
- for (i = 0; i < 10; ++i)
- writew(0xff, uart->base + UART011_MIS);
- writew(lcr, uart->base + vendor->lcrh_tx);
- }
-}
-
static int pl011_init_port(struct console_device *cdev)
{
struct amba_uart_port *uart = to_amba_uart_port(cdev);
@@ -207,6 +201,9 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
cdev->putc = pl011_putc;
cdev->getc = pl011_getc;
cdev->setbrg = pl011_setbaudrate;
+ cdev->linux_console_name = "ttyAMA";
+ cdev->linux_earlycon_name = "pl011";
+ cdev->phys_base = uart->base;
pl011_init_port(cdev);
@@ -239,10 +236,4 @@ struct amba_driver pl011_driver = {
.id_table = pl011_ids,
};
-static int pl011_init(void)
-{
- amba_driver_register(&pl011_driver);
- return 0;
-}
-
-console_initcall(pl011_init);
+console_amba_driver(pl011_driver);