[RFC 3/6] From: Domenico Andreoli <domenico.andreoli@xxxxxxxxx> ARM: Earlycon support for AMBA PL010 UARTs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Very easy migration of the AMBA PL010 driver. We remove the code twice
and add once but everything works as before. And we are ready for the
runtime prime time.

Signed-off-by: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>

---
 arch/arm/mach-versatile/include/mach/uncompress.h |   22 ++----------
 arch/arm/mach-vexpress/include/mach/uncompress.h  |   26 ++------------
 drivers/tty/serial/amba-pl010.c                   |   40 ++++++++++++++++++++++
 3 files changed, 48 insertions(+), 40 deletions(-)

Index: b/arch/arm/mach-versatile/include/mach/uncompress.h
===================================================================
--- a/arch/arm/mach-versatile/include/mach/uncompress.h
+++ b/arch/arm/mach-versatile/include/mach/uncompress.h
@@ -17,30 +17,16 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#define AMBA_UART_DR	(*(volatile unsigned char *)0x101F1000)
-#define AMBA_UART_LCRH	(*(volatile unsigned char *)0x101F102C)
-#define AMBA_UART_CR	(*(volatile unsigned char *)0x101F1030)
-#define AMBA_UART_FR	(*(volatile unsigned char *)0x101F1018)
 
-/*
- * This does not append a newline
- */
-static inline void putc(int c)
+static inline void arch_decomp_setup(void)
 {
-	while (AMBA_UART_FR & (1 << 5))
-		barrier();
-
-	AMBA_UART_DR = c;
+	// TODO: find the correct driver
+	setup_earlycon("amba-pl010", 0x101f1000);
 }
 
-static inline void flush(void)
-{
-	while (AMBA_UART_FR & (1 << 3))
-		barrier();
-}
+#define EARLYCON_STATIC_SETUP
 
 /*
  * nothing to do
  */
-#define arch_decomp_setup()
 #define arch_decomp_wdog()
Index: b/arch/arm/mach-vexpress/include/mach/uncompress.h
===================================================================
--- a/arch/arm/mach-vexpress/include/mach/uncompress.h
+++ b/arch/arm/mach-vexpress/include/mach/uncompress.h
@@ -17,10 +17,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#define AMBA_UART_DR(base)	(*(volatile unsigned char *)((base) + 0x00))
-#define AMBA_UART_LCRH(base)	(*(volatile unsigned char *)((base) + 0x2c))
-#define AMBA_UART_CR(base)	(*(volatile unsigned char *)((base) + 0x30))
-#define AMBA_UART_FR(base)	(*(volatile unsigned char *)((base) + 0x18))
 
 #define UART_BASE	0x10009000
 #define UART_BASE_RS1	0x1c090000
@@ -44,29 +40,15 @@ static unsigned long get_uart_base(void)
 		return UART_BASE_RS1;
 }
 
-/*
- * This does not append a newline
- */
-static inline void putc(int c)
+static inline void arch_decomp_setup(void)
 {
-	unsigned long base = get_uart_base();
-
-	while (AMBA_UART_FR(base) & (1 << 5))
-		barrier();
-
-	AMBA_UART_DR(base) = c;
+	// TODO: find the correct driver
+	setup_earlycon("amba-pl010", get_uart_base());
 }
 
-static inline void flush(void)
-{
-	unsigned long base = get_uart_base();
-
-	while (AMBA_UART_FR(base) & (1 << 3))
-		barrier();
-}
+#define EARLYCON_STATIC_SETUP
 
 /*
  * nothing to do
  */
-#define arch_decomp_setup()
 #define arch_decomp_wdog()
Index: b/drivers/tty/serial/amba-pl010.c
===================================================================
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -42,6 +42,7 @@
 #include <linux/tty_flip.h>
 #include <linux/serial_core.h>
 #include <linux/serial.h>
+#include <linux/earlycon.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/clk.h>
@@ -832,6 +833,45 @@ static void __exit pl010_exit(void)
 module_init(pl010_init);
 module_exit(pl010_exit);
 
+static int __earlyconinit pl010_earlycon_probe(struct earlycon_drv *drv)
+{
+	volatile uint32_t *cr;
+
+	/* this driver doesn't support probing of the base address */
+	if (!drv->base)
+		return -EINVAL;
+
+	cr = (volatile uint32_t *) (drv->base + UART010_CR);
+	return (*cr & UART01x_CR_UARTEN) ? 0 : -1;
+}
+
+static void __earlyconinit pl010_earlycon_putc(struct earlycon_drv *drv, int ch)
+{
+	volatile uint32_t *fr, *dr;
+
+	fr = (volatile uint32_t *) (drv->base + UART01x_FR);
+	while (*fr & UART01x_FR_TXFF)
+		barrier();
+
+	dr = (volatile uint32_t *) (drv->base + UART01x_DR);
+	*dr = ch;
+}
+
+static void __earlyconinit pl010_earlycon_flush(struct earlycon_drv *drv)
+{
+	volatile uint32_t *fr;
+
+	fr = (volatile uint32_t *) (drv->base + UART01x_FR);
+	while (*fr & UART01x_FR_BUSY)
+		barrier();
+}
+
+EARLYCON_START("amba-pl010")
+	.probe = pl010_earlycon_probe,
+	.putc = pl010_earlycon_putc,
+	.flush = pl010_earlycon_flush,
+EARLYCON_END
+
 MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd");
 MODULE_DESCRIPTION("ARM AMBA serial port driver");
 MODULE_LICENSE("GPL");


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [CentOS ARM]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]

  Powered by Linux