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> |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 21 | #include <linux/i2c.h> |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 22 | #include <linux/delay.h> |
| 23 | #include <linux/input.h> |
| 24 | #include <linux/io.h> |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 25 | #include <linux/gpio.h> |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 26 | #include <linux/gpio_keys.h> |
| 27 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 28 | #include <sound/wm8903.h> |
| 29 | |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 30 | #include <mach/iomap.h> |
| 31 | #include <mach/irqs.h> |
| 32 | #include <mach/sdhci.h> |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 33 | #include <mach/tegra_wm8903_pdata.h> |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 34 | |
| 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
| 37 | |
| 38 | #include "board.h" |
| 39 | #include "board-seaboard.h" |
| 40 | #include "clock.h" |
| 41 | #include "devices.h" |
| 42 | #include "gpio-names.h" |
| 43 | |
| 44 | static struct plat_serial8250_port debug_uart_platform_data[] = { |
| 45 | { |
| 46 | /* Memory and IRQ filled in before registration */ |
| 47 | .flags = UPF_BOOT_AUTOCONF, |
| 48 | .iotype = UPIO_MEM, |
| 49 | .regshift = 2, |
| 50 | .uartclk = 216000000, |
| 51 | }, { |
| 52 | .flags = 0, |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | static struct platform_device debug_uart = { |
| 57 | .name = "serial8250", |
| 58 | .id = PLAT8250_DEV_PLATFORM, |
| 59 | .dev = { |
| 60 | .platform_data = debug_uart_platform_data, |
| 61 | }, |
| 62 | }; |
| 63 | |
| 64 | static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = { |
| 65 | /* name parent rate enabled */ |
| 66 | { "uartb", "pll_p", 216000000, true}, |
| 67 | { "uartd", "pll_p", 216000000, true}, |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 68 | { "pll_a", "pll_p_out1", 56448000, true }, |
| 69 | { "pll_a_out0", "pll_a", 11289600, true }, |
| 70 | { "cdev1", NULL, 0, true }, |
| 71 | { "i2s1", "pll_a_out0", 11289600, false}, |
Stephen Warren | bc24ed4 | 2011-08-08 14:35:15 -0600 | [diff] [blame^] | 72 | { "usbd", "clk_m", 12000000, true}, |
| 73 | { "usb3", "clk_m", 12000000, true}, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 74 | { NULL, NULL, 0, 0}, |
| 75 | }; |
| 76 | |
| 77 | static struct gpio_keys_button seaboard_gpio_keys_buttons[] = { |
| 78 | { |
| 79 | .code = SW_LID, |
| 80 | .gpio = TEGRA_GPIO_LIDSWITCH, |
| 81 | .active_low = 0, |
| 82 | .desc = "Lid", |
| 83 | .type = EV_SW, |
| 84 | .wakeup = 1, |
| 85 | .debounce_interval = 1, |
| 86 | }, |
| 87 | { |
| 88 | .code = KEY_POWER, |
| 89 | .gpio = TEGRA_GPIO_POWERKEY, |
| 90 | .active_low = 1, |
| 91 | .desc = "Power", |
| 92 | .type = EV_KEY, |
| 93 | .wakeup = 1, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct gpio_keys_platform_data seaboard_gpio_keys = { |
| 98 | .buttons = seaboard_gpio_keys_buttons, |
| 99 | .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons), |
| 100 | }; |
| 101 | |
| 102 | static struct platform_device seaboard_gpio_keys_device = { |
| 103 | .name = "gpio-keys", |
| 104 | .id = -1, |
| 105 | .dev = { |
| 106 | .platform_data = &seaboard_gpio_keys, |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | static struct tegra_sdhci_platform_data sdhci_pdata1 = { |
| 111 | .cd_gpio = -1, |
| 112 | .wp_gpio = -1, |
| 113 | .power_gpio = -1, |
| 114 | }; |
| 115 | |
| 116 | static struct tegra_sdhci_platform_data sdhci_pdata3 = { |
Stephen Warren | 986afbe | 2011-03-04 22:44:28 -0700 | [diff] [blame] | 117 | .cd_gpio = TEGRA_GPIO_SD2_CD, |
| 118 | .wp_gpio = TEGRA_GPIO_SD2_WP, |
| 119 | .power_gpio = TEGRA_GPIO_SD2_POWER, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | static struct tegra_sdhci_platform_data sdhci_pdata4 = { |
| 123 | .cd_gpio = -1, |
| 124 | .wp_gpio = -1, |
| 125 | .power_gpio = -1, |
| 126 | .is_8bit = 1, |
| 127 | }; |
| 128 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 129 | static struct tegra_wm8903_platform_data seaboard_audio_pdata = { |
| 130 | .gpio_spkr_en = TEGRA_GPIO_SPKR_EN, |
| 131 | .gpio_hp_det = TEGRA_GPIO_HP_DET, |
| 132 | .gpio_hp_mute = -1, |
| 133 | .gpio_int_mic_en = -1, |
| 134 | .gpio_ext_mic_en = -1, |
| 135 | }; |
| 136 | |
| 137 | static struct platform_device seaboard_audio_device = { |
| 138 | .name = "tegra-snd-wm8903", |
| 139 | .id = 0, |
| 140 | .dev = { |
| 141 | .platform_data = &seaboard_audio_pdata, |
| 142 | }, |
| 143 | }; |
| 144 | |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 145 | static struct platform_device *seaboard_devices[] __initdata = { |
| 146 | &debug_uart, |
| 147 | &tegra_pmu_device, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 148 | &tegra_sdhci_device4, |
Stephen Warren | cfeb34e | 2011-05-31 15:14:08 -0600 | [diff] [blame] | 149 | &tegra_sdhci_device3, |
| 150 | &tegra_sdhci_device1, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 151 | &seaboard_gpio_keys_device, |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 152 | &tegra_i2s_device1, |
| 153 | &tegra_das_device, |
| 154 | &tegra_pcm_device, |
| 155 | &seaboard_audio_device, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 156 | }; |
| 157 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 158 | static struct i2c_board_info __initdata isl29018_device = { |
| 159 | I2C_BOARD_INFO("isl29018", 0x44), |
| 160 | .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ), |
| 161 | }; |
| 162 | |
| 163 | static struct i2c_board_info __initdata adt7461_device = { |
| 164 | I2C_BOARD_INFO("adt7461", 0x4c), |
| 165 | }; |
| 166 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 167 | static struct wm8903_platform_data wm8903_pdata = { |
| 168 | .irq_active_low = 0, |
| 169 | .micdet_cfg = 0, |
| 170 | .micdet_delay = 100, |
| 171 | .gpio_base = SEABOARD_GPIO_WM8903(0), |
| 172 | .gpio_cfg = { |
| 173 | WM8903_GPIO_NO_CONFIG, |
| 174 | WM8903_GPIO_NO_CONFIG, |
| 175 | 0, |
| 176 | WM8903_GPIO_NO_CONFIG, |
| 177 | WM8903_GPIO_NO_CONFIG, |
| 178 | }, |
| 179 | }; |
| 180 | |
| 181 | static struct i2c_board_info __initdata wm8903_device = { |
| 182 | I2C_BOARD_INFO("wm8903", 0x1a), |
| 183 | .platform_data = &wm8903_pdata, |
| 184 | .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ), |
| 185 | }; |
| 186 | |
Stephen Warren | bc24ed4 | 2011-08-08 14:35:15 -0600 | [diff] [blame^] | 187 | static int seaboard_ehci_init(void) |
| 188 | { |
| 189 | int gpio_status; |
| 190 | |
| 191 | gpio_status = gpio_request(TEGRA_GPIO_USB1, "VBUS_USB1"); |
| 192 | if (gpio_status < 0) { |
| 193 | pr_err("VBUS_USB1 request GPIO FAILED\n"); |
| 194 | WARN_ON(1); |
| 195 | } |
| 196 | |
| 197 | gpio_status = gpio_direction_output(TEGRA_GPIO_USB1, 1); |
| 198 | if (gpio_status < 0) { |
| 199 | pr_err("VBUS_USB1 request GPIO DIRECTION FAILED\n"); |
| 200 | WARN_ON(1); |
| 201 | } |
| 202 | gpio_set_value(TEGRA_GPIO_USB1, 1); |
| 203 | |
| 204 | platform_device_register(&tegra_ehci1_device); |
| 205 | platform_device_register(&tegra_ehci3_device); |
| 206 | |
| 207 | return 0; |
| 208 | } |
| 209 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 210 | static void __init seaboard_i2c_init(void) |
| 211 | { |
| 212 | gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018"); |
| 213 | gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ); |
| 214 | |
| 215 | i2c_register_board_info(0, &isl29018_device, 1); |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 216 | i2c_register_board_info(0, &wm8903_device, 1); |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 217 | |
Stephen Warren | 29e9c68 | 2011-07-13 12:53:53 -0600 | [diff] [blame] | 218 | i2c_register_board_info(3, &adt7461_device, 1); |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 219 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 220 | platform_device_register(&tegra_i2c_device1); |
| 221 | platform_device_register(&tegra_i2c_device2); |
| 222 | platform_device_register(&tegra_i2c_device3); |
| 223 | platform_device_register(&tegra_i2c_device4); |
| 224 | } |
| 225 | |
| 226 | static void __init seaboard_common_init(void) |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 227 | { |
| 228 | seaboard_pinmux_init(); |
| 229 | |
| 230 | tegra_clk_init_from_table(seaboard_clk_init_table); |
| 231 | |
| 232 | tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1; |
| 233 | tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3; |
| 234 | tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4; |
| 235 | |
| 236 | platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices)); |
Stephen Warren | bc24ed4 | 2011-08-08 14:35:15 -0600 | [diff] [blame^] | 237 | |
| 238 | seaboard_ehci_init(); |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static void __init tegra_seaboard_init(void) |
| 242 | { |
| 243 | /* Seaboard uses UARTD for the debug port. */ |
| 244 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE); |
| 245 | debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE; |
| 246 | debug_uart_platform_data[0].irq = INT_UARTD; |
| 247 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 248 | seaboard_common_init(); |
| 249 | |
| 250 | seaboard_i2c_init(); |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | static void __init tegra_kaen_init(void) |
| 254 | { |
| 255 | /* Kaen uses UARTB for the debug port. */ |
| 256 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE); |
| 257 | debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE; |
| 258 | debug_uart_platform_data[0].irq = INT_UARTB; |
| 259 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame] | 260 | seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE; |
| 261 | tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE); |
| 262 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 263 | seaboard_common_init(); |
| 264 | |
| 265 | seaboard_i2c_init(); |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static void __init tegra_wario_init(void) |
| 269 | { |
| 270 | /* Wario uses UARTB for the debug port. */ |
| 271 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE); |
| 272 | debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE; |
| 273 | debug_uart_platform_data[0].irq = INT_UARTB; |
| 274 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 275 | seaboard_common_init(); |
| 276 | |
| 277 | seaboard_i2c_init(); |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | |
| 281 | MACHINE_START(SEABOARD, "seaboard") |
| 282 | .boot_params = 0x00000100, |
| 283 | .map_io = tegra_map_common_io, |
| 284 | .init_early = tegra_init_early, |
| 285 | .init_irq = tegra_init_irq, |
| 286 | .timer = &tegra_timer, |
| 287 | .init_machine = tegra_seaboard_init, |
| 288 | MACHINE_END |
| 289 | |
| 290 | MACHINE_START(KAEN, "kaen") |
| 291 | .boot_params = 0x00000100, |
| 292 | .map_io = tegra_map_common_io, |
| 293 | .init_early = tegra_init_early, |
| 294 | .init_irq = tegra_init_irq, |
| 295 | .timer = &tegra_timer, |
| 296 | .init_machine = tegra_kaen_init, |
| 297 | MACHINE_END |
| 298 | |
| 299 | MACHINE_START(WARIO, "wario") |
| 300 | .boot_params = 0x00000100, |
| 301 | .map_io = tegra_map_common_io, |
| 302 | .init_early = tegra_init_early, |
| 303 | .init_irq = tegra_init_irq, |
| 304 | .timer = &tegra_timer, |
| 305 | .init_machine = tegra_wario_init, |
| 306 | MACHINE_END |