arm: tegra: cardhu: Select debug console from kernel command line
Laxman Dewangan [Sun, 11 Sep 2011 04:52:05 +0000 (09:52 +0530)]
Selecting debug console from linux command line.

bug 795847

Reviewed-on: http://git-master/r/51723
(cherry picked from commit ce5675f5a7607f9e549f84c42bea3df6f14c9008)

Change-Id: Ia242b6b0fed0b9d2fad6c66a14895e5574f6f5b9
Reviewed-on: http://git-master/r/61422
Reviewed-by: Lokesh Pathak <lpathak@nvidia.com>
Tested-by: Lokesh Pathak <lpathak@nvidia.com>

Rebase-Id: R3fd2b06fefa1b153d2c739c5d7c55b2265659225

arch/arm/mach-tegra/board-cardhu.c

index 4e03c05..b570dac 100644 (file)
@@ -316,32 +316,80 @@ static struct tegra_uart_platform_data cardhu_uart_pdata;
 static void __init uart_debug_init(void)
 {
        struct board_info board_info;
+       int debug_port_id;
 
        tegra_get_board_info(&board_info);
-       /* UARTB is debug port
-        *       for SLT - E1186/E1187/PM269
-        *       for E1256/E1257
-        */
-       if (((board_info.sku & SKU_SLT_ULPI_SUPPORT) &&
-               ((board_info.board_id == BOARD_E1186) ||
-               (board_info.board_id == BOARD_E1187) ||
-               (board_info.board_id == BOARD_PM269))) ||
-               (board_info.board_id == BOARD_E1256) ||
-               (board_info.board_id == BOARD_E1257)) {
-                       /* UARTB is the debug port. */
-                       pr_info("Selecting UARTB as the debug console\n");
-                       cardhu_uart_devices[1] = &debug_uartb_device;
-                       debug_uart_clk =  clk_get_sys("serial8250.0", "uartb");
-                       debug_uart_port_base = ((struct plat_serial8250_port *)(
-                               debug_uartb_device.dev.platform_data))->mapbase;
-                       return;
+
+       debug_port_id = get_tegra_uart_debug_port_id();
+       if (debug_port_id < 0) {
+               debug_port_id = 0;
+                       /* UARTB is debug port
+                        *       for SLT - E1186/E1187/PM269
+                        *       for E1256/E1257
+                        */
+               if (((board_info.sku & SKU_SLT_ULPI_SUPPORT) &&
+                       ((board_info.board_id == BOARD_E1186) ||
+                       (board_info.board_id == BOARD_E1187) ||
+                       (board_info.board_id == BOARD_PM269))) ||
+                       (board_info.board_id == BOARD_E1256) ||
+                       (board_info.board_id == BOARD_E1257))
+                               debug_port_id = 1;
        }
-       /* UARTA is the debug port. */
-       pr_info("Selecting UARTA as the debug console\n");
-       cardhu_uart_devices[0] = &debug_uarta_device;
-       debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
-       debug_uart_port_base = ((struct plat_serial8250_port *)(
+       switch (debug_port_id) {
+       case 0:
+               /* UARTA is the debug port. */
+               pr_info("Selecting UARTA as the debug console\n");
+               cardhu_uart_devices[0] = &debug_uarta_device;
+               debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
+               debug_uart_port_base = ((struct plat_serial8250_port *)(
+                       debug_uarta_device.dev.platform_data))->mapbase;
+               break;
+
+       case 1:
+               /* UARTB is the debug port. */
+               pr_info("Selecting UARTB as the debug console\n");
+               cardhu_uart_devices[1] = &debug_uartb_device;
+               debug_uart_clk =  clk_get_sys("serial8250.0", "uartb");
+               debug_uart_port_base = ((struct plat_serial8250_port *)(
+                       debug_uartb_device.dev.platform_data))->mapbase;
+               break;
+
+       case 2:
+               /* UARTC is the debug port. */
+               pr_info("Selecting UARTC as the debug console\n");
+               cardhu_uart_devices[2] = &debug_uartc_device;
+               debug_uart_clk =  clk_get_sys("serial8250.0", "uartc");
+               debug_uart_port_base = ((struct plat_serial8250_port *)(
+                       debug_uartc_device.dev.platform_data))->mapbase;
+               break;
+
+       case 3:
+               /* UARTD is the debug port. */
+               pr_info("Selecting UARTD as the debug console\n");
+               cardhu_uart_devices[3] = &debug_uartd_device;
+               debug_uart_clk =  clk_get_sys("serial8250.0", "uartd");
+               debug_uart_port_base = ((struct plat_serial8250_port *)(
+                       debug_uartd_device.dev.platform_data))->mapbase;
+               break;
+
+       case 4:
+               /* UARTE is the debug port. */
+               pr_info("Selecting UARTE as the debug console\n");
+               cardhu_uart_devices[4] = &debug_uarte_device;
+               debug_uart_clk =  clk_get_sys("serial8250.0", "uarte");
+               debug_uart_port_base = ((struct plat_serial8250_port *)(
+                       debug_uarte_device.dev.platform_data))->mapbase;
+               break;
+
+       default:
+               pr_info("The debug console id %d is invalid, Assuming UARTA", debug_port_id);
+               cardhu_uart_devices[0] = &debug_uarta_device;
+               debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
+               debug_uart_port_base = ((struct plat_serial8250_port *)(
                        debug_uarta_device.dev.platform_data))->mapbase;
+               break;
+       }
+       return;
 }
 
 static void __init cardhu_uart_init(void)