]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/serial/serial_s5p.c
serial: push default_serial_console to drivers
[karo-tx-uboot.git] / drivers / serial / serial_s5p.c
index e0d4e8004dd01886b940933ea8551788fdef6f28..6604aa94a7f56e644b0eed58491ef2e2c7d8a94f 100644 (file)
  */
 
 #include <common.h>
+#include <linux/compiler.h>
 #include <asm/io.h>
 #include <asm/arch/uart.h>
 #include <asm/arch/clk.h>
 #include <serial.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
 {
        u32 offset = dev_index * sizeof(struct s5p_uart);
-
-       if (cpu_is_s5pc100())
-               return (struct s5p_uart *)(S5PC100_UART_BASE + offset);
-       else
-               return (struct s5p_uart *)(S5PC110_UART_BASE + offset);
+       return (struct s5p_uart *)(samsung_get_base_uart() + offset);
 }
 
 /*
@@ -65,16 +64,19 @@ static const int udivslot[] = {
 
 void serial_setbrg_dev(const int dev_index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
-       u32 pclk = get_pclk();
+       u32 uclk = get_uart_clk(dev_index);
        u32 baudrate = gd->baudrate;
        u32 val;
 
-       val = pclk / baudrate;
+       val = uclk / baudrate;
 
        writel(val / 16 - 1, &uart->ubrdiv);
-       writew(udivslot[val % 16], &uart->udivslot);
+
+       if (s5p_uart_divslot())
+               writew(udivslot[val % 16], &uart->rest.slot);
+       else
+               writeb(val % 16, &uart->rest.value);
 }
 
 /*
@@ -204,3 +206,18 @@ struct serial_device s5p_serial2_device =
 DECLARE_S5P_SERIAL_FUNCTIONS(3);
 struct serial_device s5p_serial3_device =
        INIT_S5P_SERIAL_STRUCTURE(3, "s5pser3", "S5PUART3");
+
+__weak struct serial_device *default_serial_console(void)
+{
+#if defined(CONFIG_SERIAL0)
+       return &s5p_serial0_device;
+#elif defined(CONFIG_SERIAL1)
+       return &s5p_serial1_device;
+#elif defined(CONFIG_SERIAL2)
+       return &s5p_serial2_device;
+#elif defined(CONFIG_SERIAL3)
+       return &s5p_serial3_device;
+#else
+#error "CONFIG_SERIAL? missing."
+#endif
+}