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