Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2010, 2011 NVIDIA Corporation. |
| 3 | * Copyright (C) 2010, 2011 Google, Inc. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/serial_8250.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/input.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/gpio_keys.h> |
| 25 | |
| 26 | #include <mach/iomap.h> |
| 27 | #include <mach/irqs.h> |
| 28 | #include <mach/sdhci.h> |
| 29 | |
| 30 | #include <asm/mach-types.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | |
| 33 | #include "board.h" |
| 34 | #include "board-seaboard.h" |
| 35 | #include "clock.h" |
| 36 | #include "devices.h" |
| 37 | #include "gpio-names.h" |
| 38 | |
| 39 | static struct plat_serial8250_port debug_uart_platform_data[] = { |
| 40 | { |
| 41 | /* Memory and IRQ filled in before registration */ |
| 42 | .flags = UPF_BOOT_AUTOCONF, |
| 43 | .iotype = UPIO_MEM, |
| 44 | .regshift = 2, |
| 45 | .uartclk = 216000000, |
| 46 | }, { |
| 47 | .flags = 0, |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | static struct platform_device debug_uart = { |
| 52 | .name = "serial8250", |
| 53 | .id = PLAT8250_DEV_PLATFORM, |
| 54 | .dev = { |
| 55 | .platform_data = debug_uart_platform_data, |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = { |
| 60 | /* name parent rate enabled */ |
| 61 | { "uartb", "pll_p", 216000000, true}, |
| 62 | { "uartd", "pll_p", 216000000, true}, |
| 63 | { NULL, NULL, 0, 0}, |
| 64 | }; |
| 65 | |
| 66 | static struct gpio_keys_button seaboard_gpio_keys_buttons[] = { |
| 67 | { |
| 68 | .code = SW_LID, |
| 69 | .gpio = TEGRA_GPIO_LIDSWITCH, |
| 70 | .active_low = 0, |
| 71 | .desc = "Lid", |
| 72 | .type = EV_SW, |
| 73 | .wakeup = 1, |
| 74 | .debounce_interval = 1, |
| 75 | }, |
| 76 | { |
| 77 | .code = KEY_POWER, |
| 78 | .gpio = TEGRA_GPIO_POWERKEY, |
| 79 | .active_low = 1, |
| 80 | .desc = "Power", |
| 81 | .type = EV_KEY, |
| 82 | .wakeup = 1, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | static struct gpio_keys_platform_data seaboard_gpio_keys = { |
| 87 | .buttons = seaboard_gpio_keys_buttons, |
| 88 | .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons), |
| 89 | }; |
| 90 | |
| 91 | static struct platform_device seaboard_gpio_keys_device = { |
| 92 | .name = "gpio-keys", |
| 93 | .id = -1, |
| 94 | .dev = { |
| 95 | .platform_data = &seaboard_gpio_keys, |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | static struct tegra_sdhci_platform_data sdhci_pdata1 = { |
| 100 | .cd_gpio = -1, |
| 101 | .wp_gpio = -1, |
| 102 | .power_gpio = -1, |
| 103 | }; |
| 104 | |
| 105 | static struct tegra_sdhci_platform_data sdhci_pdata3 = { |
| 106 | .cd_gpio = TEGRA_GPIO_PI5, |
| 107 | .wp_gpio = TEGRA_GPIO_PH1, |
| 108 | .power_gpio = TEGRA_GPIO_PI6, |
| 109 | }; |
| 110 | |
| 111 | static struct tegra_sdhci_platform_data sdhci_pdata4 = { |
| 112 | .cd_gpio = -1, |
| 113 | .wp_gpio = -1, |
| 114 | .power_gpio = -1, |
| 115 | .is_8bit = 1, |
| 116 | }; |
| 117 | |
| 118 | static struct platform_device *seaboard_devices[] __initdata = { |
| 119 | &debug_uart, |
| 120 | &tegra_pmu_device, |
| 121 | &tegra_sdhci_device1, |
| 122 | &tegra_sdhci_device3, |
| 123 | &tegra_sdhci_device4, |
| 124 | &seaboard_gpio_keys_device, |
| 125 | }; |
| 126 | |
| 127 | static void __init __tegra_seaboard_init(void) |
| 128 | { |
| 129 | seaboard_pinmux_init(); |
| 130 | |
| 131 | tegra_clk_init_from_table(seaboard_clk_init_table); |
| 132 | |
| 133 | tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1; |
| 134 | tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3; |
| 135 | tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4; |
| 136 | |
| 137 | platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices)); |
| 138 | } |
| 139 | |
| 140 | static void __init tegra_seaboard_init(void) |
| 141 | { |
| 142 | /* Seaboard uses UARTD for the debug port. */ |
| 143 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE); |
| 144 | debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE; |
| 145 | debug_uart_platform_data[0].irq = INT_UARTD; |
| 146 | |
| 147 | __tegra_seaboard_init(); |
| 148 | } |
| 149 | |
| 150 | static void __init tegra_kaen_init(void) |
| 151 | { |
| 152 | /* Kaen uses UARTB for the debug port. */ |
| 153 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE); |
| 154 | debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE; |
| 155 | debug_uart_platform_data[0].irq = INT_UARTB; |
| 156 | |
| 157 | __tegra_seaboard_init(); |
| 158 | } |
| 159 | |
| 160 | static void __init tegra_wario_init(void) |
| 161 | { |
| 162 | /* Wario uses UARTB for the debug port. */ |
| 163 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE); |
| 164 | debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE; |
| 165 | debug_uart_platform_data[0].irq = INT_UARTB; |
| 166 | |
| 167 | __tegra_seaboard_init(); |
| 168 | } |
| 169 | |
| 170 | |
| 171 | MACHINE_START(SEABOARD, "seaboard") |
| 172 | .boot_params = 0x00000100, |
| 173 | .map_io = tegra_map_common_io, |
| 174 | .init_early = tegra_init_early, |
| 175 | .init_irq = tegra_init_irq, |
| 176 | .timer = &tegra_timer, |
| 177 | .init_machine = tegra_seaboard_init, |
| 178 | MACHINE_END |
| 179 | |
| 180 | MACHINE_START(KAEN, "kaen") |
| 181 | .boot_params = 0x00000100, |
| 182 | .map_io = tegra_map_common_io, |
| 183 | .init_early = tegra_init_early, |
| 184 | .init_irq = tegra_init_irq, |
| 185 | .timer = &tegra_timer, |
| 186 | .init_machine = tegra_kaen_init, |
| 187 | MACHINE_END |
| 188 | |
| 189 | MACHINE_START(WARIO, "wario") |
| 190 | .boot_params = 0x00000100, |
| 191 | .map_io = tegra_map_common_io, |
| 192 | .init_early = tegra_init_early, |
| 193 | .init_irq = tegra_init_irq, |
| 194 | .timer = &tegra_timer, |
| 195 | .init_machine = tegra_wario_init, |
| 196 | MACHINE_END |