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