aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2014-09-15 20:22:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-28 21:49:48 -0400
commit0efe72963409739778e93d8e2046305bc8310e83 (patch)
tree24db739e3d0646205618eeca9c77004cfb55b134 /drivers/tty
parenta86713b1536c818972675e6dd8c6e738f0379f1d (diff)
tty: serial: msm: Add earlycon support
Add support for DT based and command line based early console on platforms with the msm serial hardware. Cc: Rob Herring <robh@kernel.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/Kconfig1
-rw-r--r--drivers/tty/serial/msm_serial.c74
2 files changed, 63 insertions, 12 deletions
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 02a896f4dbcd..649b784081c7 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1070,6 +1070,7 @@ config SERIAL_MSM_CONSOLE
1070 bool "MSM serial console support" 1070 bool "MSM serial console support"
1071 depends on SERIAL_MSM=y 1071 depends on SERIAL_MSM=y
1072 select SERIAL_CORE_CONSOLE 1072 select SERIAL_CORE_CONSOLE
1073 select SERIAL_EARLYCON
1073 1074
1074config SERIAL_MSM_HS 1075config SERIAL_MSM_HS
1075 tristate "MSM UART High Speed: Serial Driver" 1076 tristate "MSM UART High Speed: Serial Driver"
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 4f9640d0b1bb..4b6c78331a64 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -845,22 +845,15 @@ static inline struct uart_port *get_port_from_line(unsigned int line)
845} 845}
846 846
847#ifdef CONFIG_SERIAL_MSM_CONSOLE 847#ifdef CONFIG_SERIAL_MSM_CONSOLE
848static void msm_console_write(struct console *co, const char *s, 848static void __msm_console_write(struct uart_port *port, const char *s,
849 unsigned int count) 849 unsigned int count, bool is_uartdm)
850{ 850{
851 int i; 851 int i;
852 struct uart_port *port;
853 struct msm_port *msm_port;
854 int num_newlines = 0; 852 int num_newlines = 0;
855 bool replaced = false; 853 bool replaced = false;
856 void __iomem *tf; 854 void __iomem *tf;
857 855
858 BUG_ON(co->index < 0 || co->index >= UART_NR); 856 if (is_uartdm)
859
860 port = get_port_from_line(co->index);
861 msm_port = UART_TO_MSM(port);
862
863 if (msm_port->is_uartdm)
864 tf = port->membase + UARTDM_TF; 857 tf = port->membase + UARTDM_TF;
865 else 858 else
866 tf = port->membase + UART_TF; 859 tf = port->membase + UART_TF;
@@ -872,7 +865,7 @@ static void msm_console_write(struct console *co, const char *s,
872 count += num_newlines; 865 count += num_newlines;
873 866
874 spin_lock(&port->lock); 867 spin_lock(&port->lock);
875 if (msm_port->is_uartdm) 868 if (is_uartdm)
876 reset_dm_count(port, count); 869 reset_dm_count(port, count);
877 870
878 i = 0; 871 i = 0;
@@ -881,7 +874,7 @@ static void msm_console_write(struct console *co, const char *s,
881 unsigned int num_chars; 874 unsigned int num_chars;
882 char buf[4] = { 0 }; 875 char buf[4] = { 0 };
883 876
884 if (msm_port->is_uartdm) 877 if (is_uartdm)
885 num_chars = min(count - i, (unsigned int)sizeof(buf)); 878 num_chars = min(count - i, (unsigned int)sizeof(buf));
886 else 879 else
887 num_chars = 1; 880 num_chars = 1;
@@ -910,6 +903,20 @@ static void msm_console_write(struct console *co, const char *s,
910 spin_unlock(&port->lock); 903 spin_unlock(&port->lock);
911} 904}
912 905
906static void msm_console_write(struct console *co, const char *s,
907 unsigned int count)
908{
909 struct uart_port *port;
910 struct msm_port *msm_port;
911
912 BUG_ON(co->index < 0 || co->index >= UART_NR);
913
914 port = get_port_from_line(co->index);
915 msm_port = UART_TO_MSM(port);
916
917 __msm_console_write(port, s, count, msm_port->is_uartdm);
918}
919
913static int __init msm_console_setup(struct console *co, char *options) 920static int __init msm_console_setup(struct console *co, char *options)
914{ 921{
915 struct uart_port *port; 922 struct uart_port *port;
@@ -952,6 +959,49 @@ static int __init msm_console_setup(struct console *co, char *options)
952 return uart_set_options(port, co, baud, parity, bits, flow); 959 return uart_set_options(port, co, baud, parity, bits, flow);
953} 960}
954 961
962static void
963msm_serial_early_write(struct console *con, const char *s, unsigned n)
964{
965 struct earlycon_device *dev = con->data;
966
967 __msm_console_write(&dev->port, s, n, false);
968}
969
970static int __init
971msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
972{
973 if (!device->port.membase)
974 return -ENODEV;
975
976 device->con->write = msm_serial_early_write;
977 return 0;
978}
979EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
980OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
981 msm_serial_early_console_setup);
982
983static void
984msm_serial_early_write_dm(struct console *con, const char *s, unsigned n)
985{
986 struct earlycon_device *dev = con->data;
987
988 __msm_console_write(&dev->port, s, n, true);
989}
990
991static int __init
992msm_serial_early_console_setup_dm(struct earlycon_device *device,
993 const char *opt)
994{
995 if (!device->port.membase)
996 return -ENODEV;
997
998 device->con->write = msm_serial_early_write_dm;
999 return 0;
1000}
1001EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
1002OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
1003 msm_serial_early_console_setup_dm);
1004
955static struct uart_driver msm_uart_driver; 1005static struct uart_driver msm_uart_driver;
956 1006
957static struct console msm_console = { 1007static struct console msm_console = {