From dc83973f99b5567af802f70f40bcf602952f43ca Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Sun, 26 Jun 2011 21:52:15 +0530 Subject: arm: tegra: enterprise/ventana: debug console through device Using the debug port device structure to enabling/configuring the uart debug console port. Removing the duplicate local definition of the uart console. Original-Change-Id: Icbf954e0d02dcc4891169b3c701c72f35f8f29e3 Reviewed-on: http://git-master/r/35711 Reviewed-by: Varun Colbert Tested-by: Varun Colbert Rebase-Id: R74bd3a179a7ef7327397805f21389f08ac3bceb1 --- arch/arm/mach-tegra/board-enterprise.c | 117 +++++++++++++++++++++++---------- arch/arm/mach-tegra/board-ventana.c | 104 ++++++++++++++++++++--------- 2 files changed, 157 insertions(+), 64 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-tegra/board-enterprise.c b/arch/arm/mach-tegra/board-enterprise.c index 01ef3df1d52b..6a6ab5d8da2b 100644 --- a/arch/arm/mach-tegra/board-enterprise.c +++ b/arch/arm/mach-tegra/board-enterprise.c @@ -33,6 +33,8 @@ #include #include #include +#include + #include #include #include @@ -51,29 +53,6 @@ #include "fuse.h" -static struct plat_serial8250_port debug_uart_platform_data[] = { - { - .membase = IO_ADDRESS(TEGRA_UARTD_BASE), - .mapbase = TEGRA_UARTD_BASE, - .irq = INT_UARTD, - .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE, - .type = PORT_TEGRA, - .iotype = UPIO_MEM, - .regshift = 2, - .uartclk = 408000000, - }, { - .flags = 0, - } -}; - -static struct platform_device debug_uart = { - .name = "serial8250", - .id = PLAT8250_DEV_PLATFORM, - .dev = { - .platform_data = debug_uart_platform_data, - }, -}; - /* !!!TODO: Change for enterprise (Taken from Cardhu) */ static struct tegra_utmip_config utmi_phy_config[] = { [0] = { @@ -117,7 +96,7 @@ static struct resource enterprise_bcm4329_rfkill_resources[] = { static struct platform_device enterprise_bcm4329_rfkill_device = { .name = "bcm4329_rfkill", - .id = -1, + .id = -1, .num_resources = ARRAY_SIZE(enterprise_bcm4329_rfkill_resources), .resource = enterprise_bcm4329_rfkill_resources, }; @@ -134,11 +113,6 @@ static inline void enterprise_bt_rfkill(void) { } static __initdata struct tegra_clk_init_table enterprise_clk_init_table[] = { /* name parent rate enabled */ - { "uarta", "pll_p", 408000000, true}, - { "uartb", "pll_p", 408000000, false}, - { "uartc", "pll_p", 408000000, false}, - { "uartd", "pll_p", 408000000, true}, - { "uarte", "pll_p", 408000000, false}, { "pll_m", NULL, 0, true}, { "hda", "pll_p", 108000000, false}, { "hda2codec_2x","pll_p", 48000000, false}, @@ -201,6 +175,85 @@ static void enterprise_i2c_init(void) platform_device_register(&tegra_i2c_device1); } +static struct platform_device *enterprise_uart_devices[] __initdata = { + &tegra_uarta_device, + &tegra_uartb_device, + &tegra_uartc_device, + &tegra_uartd_device, + &tegra_uarte_device, +}; + +static struct uart_clk_parent uart_parent_clk[] = { + [0] = {.name = "pll_p"}, + [1] = {.name = "pll_m"}, + [2] = {.name = "clk_m"}, +}; +static struct clk *debug_uart_clk; +static struct tegra_uart_platform_data enterprise_uart_pdata; + +static void __init uart_debug_init(void) +{ + unsigned long rate; + struct clk *c; + + /* UARTD is the debug port. */ + pr_info("Selecting UARTD as the debug console\n"); + enterprise_uart_devices[3] = &debug_uartd_device; + debug_uart_clk = clk_get_sys("serial8250.0", "uartd"); + + /* Clock enable for the debug channel */ + if (!IS_ERR_OR_NULL(debug_uart_clk)) { + rate = ((struct plat_serial8250_port *)( + debug_uartd_device.dev.platform_data))->uartclk; + pr_info("The debug console clock name is %s\n", + debug_uart_clk->name); + c = tegra_get_clock_by_name("pll_p"); + if (IS_ERR_OR_NULL(c)) + pr_err("Not getting the parent clock pll_p\n"); + else + clk_set_parent(debug_uart_clk, c); + + clk_enable(debug_uart_clk); + clk_set_rate(debug_uart_clk, rate); + } else { + pr_err("Not getting the clock %s for debug console\n", + debug_uart_clk->name); + } +} + +static void __init enterprise_uart_init(void) +{ + int i; + struct clk *c; + + for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) { + c = tegra_get_clock_by_name(uart_parent_clk[i].name); + if (IS_ERR_OR_NULL(c)) { + pr_err("Not able to get the clock for %s\n", + uart_parent_clk[i].name); + continue; + } + uart_parent_clk[i].parent_clk = c; + uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c); + } + enterprise_uart_pdata.parent_clk_list = uart_parent_clk; + enterprise_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk); + tegra_uarta_device.dev.platform_data = &enterprise_uart_pdata; + tegra_uartb_device.dev.platform_data = &enterprise_uart_pdata; + tegra_uartc_device.dev.platform_data = &enterprise_uart_pdata; + tegra_uartd_device.dev.platform_data = &enterprise_uart_pdata; + tegra_uarte_device.dev.platform_data = &enterprise_uart_pdata; + + /* Register low speed only if it is selected */ + if (!is_tegra_debug_uartport_hs()) + uart_debug_init(); + + platform_add_devices(enterprise_uart_devices, + ARRAY_SIZE(enterprise_uart_devices)); +} + + + static struct resource tegra_rtc_resources[] = { [0] = { .start = TEGRA_RTC_BASE, @@ -227,11 +280,6 @@ static struct platform_device tegra_camera = { }; static struct platform_device *enterprise_devices[] __initdata = { - &debug_uart, - &tegra_uarta_device, - &tegra_uartb_device, - &tegra_uartc_device, - &tegra_uarte_device, &tegra_pmu_device, &tegra_rtc_device, &tegra_udc_device, @@ -360,6 +408,7 @@ static void __init tegra_enterprise_init(void) tegra_clk_init_from_table(enterprise_clk_init_table); enterprise_pinmux_init(); enterprise_i2c_init(); + enterprise_uart_init(); platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices)); enterprise_regulator_init(); enterprise_sdhci_init(); diff --git a/arch/arm/mach-tegra/board-ventana.c b/arch/arm/mach-tegra/board-ventana.c index 1ed2a5637b80..31a848af7177 100644 --- a/arch/arm/mach-tegra/board-ventana.c +++ b/arch/arm/mach-tegra/board-ventana.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -56,28 +57,6 @@ #include "gpio-names.h" #include "wakeups-t2.h" -static struct plat_serial8250_port debug_uart_platform_data[] = { - { - .membase = IO_ADDRESS(TEGRA_UARTD_BASE), - .mapbase = TEGRA_UARTD_BASE, - .irq = INT_UARTD, - .flags = UPF_BOOT_AUTOCONF, - .iotype = UPIO_MEM, - .regshift = 2, - .uartclk = 216000000, - }, { - .flags = 0, - } -}; - -static struct platform_device debug_uart = { - .name = "serial8250", - .id = PLAT8250_DEV_PLATFORM, - .dev = { - .platform_data = debug_uart_platform_data, - }, -}; - static struct tegra_utmip_config utmi_phy_config[] = { [0] = { .hssync_start_delay = 9, @@ -138,8 +117,6 @@ static inline void ventana_bt_rfkill(void) { } static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = { /* name parent rate enabled */ - { "uartd", "pll_p", 216000000, true}, - { "uartc", "pll_m", 600000000, false}, { "blink", "clk_32k", 32768, false}, { "pll_p_out4", "pll_p", 24000000, true }, { "pwm", "clk_32k", 32768, false}, @@ -211,7 +188,79 @@ static void ventana_i2c_init(void) platform_device_register(&tegra_i2c_device3); platform_device_register(&tegra_i2c_device4); } +static struct platform_device *ventana_uart_devices[] __initdata = { + &tegra_uartb_device, + &tegra_uartc_device, + &tegra_uartd_device, +}; + +static struct uart_clk_parent uart_parent_clk[] = { + [0] = {.name = "pll_p"}, + [1] = {.name = "pll_m"}, + [2] = {.name = "clk_m"}, +}; + +static struct clk *debug_uart_clk; +static struct tegra_uart_platform_data ventana_uart_pdata; + +static void __init uart_debug_init(void) +{ + unsigned long rate; + struct clk *c; + + /* UARTD is the debug port. */ + pr_info("Selecting UARTD as the debug console\n"); + ventana_uart_devices[2] = &debug_uartd_device; + debug_uart_clk = clk_get_sys("serial8250.0", "uartd"); + + /* Clock enable for the debug channel */ + if (!IS_ERR_OR_NULL(debug_uart_clk)) { + rate = ((struct plat_serial8250_port *)( + debug_uartd_device.dev.platform_data))->uartclk; + pr_info("The debug console clock name is %s\n", + debug_uart_clk->name); + c = tegra_get_clock_by_name("pll_p"); + if (IS_ERR_OR_NULL(c)) + pr_err("Not getting the parent clock pll_p\n"); + else + clk_set_parent(debug_uart_clk, c); + + clk_enable(debug_uart_clk); + clk_set_rate(debug_uart_clk, rate); + } else { + pr_err("Not getting the clock %s for debug console\n", + debug_uart_clk->name); + } +} +static void __init ventana_uart_init(void) +{ + int i; + struct clk *c; + + for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) { + c = tegra_get_clock_by_name(uart_parent_clk[i].name); + if (IS_ERR_OR_NULL(c)) { + pr_err("Not able to get the clock for %s\n", + uart_parent_clk[i].name); + continue; + } + uart_parent_clk[i].parent_clk = c; + uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c); + } + ventana_uart_pdata.parent_clk_list = uart_parent_clk; + ventana_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk); + tegra_uartb_device.dev.platform_data = &ventana_uart_pdata; + tegra_uartc_device.dev.platform_data = &ventana_uart_pdata; + tegra_uartd_device.dev.platform_data = &ventana_uart_pdata; + + /* Register low speed only if it is selected */ + if (!is_tegra_debug_uartport_hs()) + uart_debug_init(); + + platform_add_devices(ventana_uart_devices, + ARRAY_SIZE(ventana_uart_devices)); +} #ifdef CONFIG_KEYBOARD_GPIO #define GPIO_KEY(_id, _gpio, _iswake) \ @@ -274,8 +323,6 @@ static struct platform_device tegra_camera = { }; static struct platform_device *ventana_devices[] __initdata = { - &tegra_uartb_device, - &tegra_uartc_device, &tegra_pmu_device, &tegra_udc_device, &tegra_ehci2_device, @@ -461,10 +508,7 @@ static void __init tegra_ventana_init(void) tegra_clk_init_from_table(ventana_clk_init_table); ventana_pinmux_init(); ventana_i2c_init(); - if (is_tegra_debug_uartport_hs() == true) - platform_device_register(&tegra_uartd_device); - else - platform_device_register(&debug_uart); + ventana_uart_init(); tegra_ehci2_device.dev.platform_data = &ventana_ehci2_ulpi_platform_data; platform_add_devices(ventana_devices, ARRAY_SIZE(ventana_devices)); -- cgit v1.2.3