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}, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 72 | { NULL, NULL, 0, 0}, |
| 73 | }; |
| 74 | |
| 75 | static struct gpio_keys_button seaboard_gpio_keys_buttons[] = { |
| 76 | { |
| 77 | .code = SW_LID, |
| 78 | .gpio = TEGRA_GPIO_LIDSWITCH, |
| 79 | .active_low = 0, |
| 80 | .desc = "Lid", |
| 81 | .type = EV_SW, |
| 82 | .wakeup = 1, |
| 83 | .debounce_interval = 1, |
| 84 | }, |
| 85 | { |
| 86 | .code = KEY_POWER, |
| 87 | .gpio = TEGRA_GPIO_POWERKEY, |
| 88 | .active_low = 1, |
| 89 | .desc = "Power", |
| 90 | .type = EV_KEY, |
| 91 | .wakeup = 1, |
| 92 | }, |
| 93 | }; |
| 94 | |
| 95 | static struct gpio_keys_platform_data seaboard_gpio_keys = { |
| 96 | .buttons = seaboard_gpio_keys_buttons, |
| 97 | .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons), |
| 98 | }; |
| 99 | |
| 100 | static struct platform_device seaboard_gpio_keys_device = { |
| 101 | .name = "gpio-keys", |
| 102 | .id = -1, |
| 103 | .dev = { |
| 104 | .platform_data = &seaboard_gpio_keys, |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | static struct tegra_sdhci_platform_data sdhci_pdata1 = { |
| 109 | .cd_gpio = -1, |
| 110 | .wp_gpio = -1, |
| 111 | .power_gpio = -1, |
| 112 | }; |
| 113 | |
| 114 | static struct tegra_sdhci_platform_data sdhci_pdata3 = { |
Stephen Warren | 986afbe | 2011-03-04 22:44:28 -0700 | [diff] [blame] | 115 | .cd_gpio = TEGRA_GPIO_SD2_CD, |
| 116 | .wp_gpio = TEGRA_GPIO_SD2_WP, |
| 117 | .power_gpio = TEGRA_GPIO_SD2_POWER, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | static struct tegra_sdhci_platform_data sdhci_pdata4 = { |
| 121 | .cd_gpio = -1, |
| 122 | .wp_gpio = -1, |
| 123 | .power_gpio = -1, |
| 124 | .is_8bit = 1, |
| 125 | }; |
| 126 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame^] | 127 | static struct tegra_wm8903_platform_data seaboard_audio_pdata = { |
| 128 | .gpio_spkr_en = TEGRA_GPIO_SPKR_EN, |
| 129 | .gpio_hp_det = TEGRA_GPIO_HP_DET, |
| 130 | .gpio_hp_mute = -1, |
| 131 | .gpio_int_mic_en = -1, |
| 132 | .gpio_ext_mic_en = -1, |
| 133 | }; |
| 134 | |
| 135 | static struct platform_device seaboard_audio_device = { |
| 136 | .name = "tegra-snd-wm8903", |
| 137 | .id = 0, |
| 138 | .dev = { |
| 139 | .platform_data = &seaboard_audio_pdata, |
| 140 | }, |
| 141 | }; |
| 142 | |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 143 | static struct platform_device *seaboard_devices[] __initdata = { |
| 144 | &debug_uart, |
| 145 | &tegra_pmu_device, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 146 | &tegra_sdhci_device4, |
Stephen Warren | cfeb34e | 2011-05-31 15:14:08 -0600 | [diff] [blame] | 147 | &tegra_sdhci_device3, |
| 148 | &tegra_sdhci_device1, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 149 | &seaboard_gpio_keys_device, |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame^] | 150 | &tegra_i2s_device1, |
| 151 | &tegra_das_device, |
| 152 | &tegra_pcm_device, |
| 153 | &seaboard_audio_device, |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 154 | }; |
| 155 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 156 | static struct i2c_board_info __initdata isl29018_device = { |
| 157 | I2C_BOARD_INFO("isl29018", 0x44), |
| 158 | .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ), |
| 159 | }; |
| 160 | |
| 161 | static struct i2c_board_info __initdata adt7461_device = { |
| 162 | I2C_BOARD_INFO("adt7461", 0x4c), |
| 163 | }; |
| 164 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame^] | 165 | static struct wm8903_platform_data wm8903_pdata = { |
| 166 | .irq_active_low = 0, |
| 167 | .micdet_cfg = 0, |
| 168 | .micdet_delay = 100, |
| 169 | .gpio_base = SEABOARD_GPIO_WM8903(0), |
| 170 | .gpio_cfg = { |
| 171 | WM8903_GPIO_NO_CONFIG, |
| 172 | WM8903_GPIO_NO_CONFIG, |
| 173 | 0, |
| 174 | WM8903_GPIO_NO_CONFIG, |
| 175 | WM8903_GPIO_NO_CONFIG, |
| 176 | }, |
| 177 | }; |
| 178 | |
| 179 | static struct i2c_board_info __initdata wm8903_device = { |
| 180 | I2C_BOARD_INFO("wm8903", 0x1a), |
| 181 | .platform_data = &wm8903_pdata, |
| 182 | .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ), |
| 183 | }; |
| 184 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 185 | static void __init seaboard_i2c_init(void) |
| 186 | { |
| 187 | gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018"); |
| 188 | gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ); |
| 189 | |
| 190 | i2c_register_board_info(0, &isl29018_device, 1); |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame^] | 191 | i2c_register_board_info(0, &wm8903_device, 1); |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 192 | |
Stephen Warren | 29e9c68 | 2011-07-13 12:53:53 -0600 | [diff] [blame] | 193 | i2c_register_board_info(3, &adt7461_device, 1); |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 194 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 195 | platform_device_register(&tegra_i2c_device1); |
| 196 | platform_device_register(&tegra_i2c_device2); |
| 197 | platform_device_register(&tegra_i2c_device3); |
| 198 | platform_device_register(&tegra_i2c_device4); |
| 199 | } |
| 200 | |
| 201 | static void __init seaboard_common_init(void) |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 202 | { |
| 203 | seaboard_pinmux_init(); |
| 204 | |
| 205 | tegra_clk_init_from_table(seaboard_clk_init_table); |
| 206 | |
| 207 | tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1; |
| 208 | tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3; |
| 209 | tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4; |
| 210 | |
| 211 | platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices)); |
| 212 | } |
| 213 | |
| 214 | static void __init tegra_seaboard_init(void) |
| 215 | { |
| 216 | /* Seaboard uses UARTD for the debug port. */ |
| 217 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE); |
| 218 | debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE; |
| 219 | debug_uart_platform_data[0].irq = INT_UARTD; |
| 220 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 221 | seaboard_common_init(); |
| 222 | |
| 223 | seaboard_i2c_init(); |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static void __init tegra_kaen_init(void) |
| 227 | { |
| 228 | /* Kaen uses UARTB for the debug port. */ |
| 229 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE); |
| 230 | debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE; |
| 231 | debug_uart_platform_data[0].irq = INT_UARTB; |
| 232 | |
Stephen Warren | a697e69 | 2011-08-08 14:35:14 -0600 | [diff] [blame^] | 233 | seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE; |
| 234 | tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE); |
| 235 | |
Olof Johansson | f9a795a | 2011-03-04 15:21:53 -0800 | [diff] [blame] | 236 | seaboard_common_init(); |
| 237 | |
| 238 | seaboard_i2c_init(); |
Olof Johansson | d9a51fe | 2011-02-19 17:25:32 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static void __init tegra_wario_init(void) |
| 242 | { |
| 243 | /* Wario uses UARTB for the debug port. */ |
| 244 | debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE); |
| 245 | debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE; |
| 246 | debug_uart_platform_data[0].irq = INT_UARTB; |
| 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 | |
| 254 | MACHINE_START(SEABOARD, "seaboard") |
| 255 | .boot_params = 0x00000100, |
| 256 | .map_io = tegra_map_common_io, |
| 257 | .init_early = tegra_init_early, |
| 258 | .init_irq = tegra_init_irq, |
| 259 | .timer = &tegra_timer, |
| 260 | .init_machine = tegra_seaboard_init, |
| 261 | MACHINE_END |
| 262 | |
| 263 | MACHINE_START(KAEN, "kaen") |
| 264 | .boot_params = 0x00000100, |
| 265 | .map_io = tegra_map_common_io, |
| 266 | .init_early = tegra_init_early, |
| 267 | .init_irq = tegra_init_irq, |
| 268 | .timer = &tegra_timer, |
| 269 | .init_machine = tegra_kaen_init, |
| 270 | MACHINE_END |
| 271 | |
| 272 | MACHINE_START(WARIO, "wario") |
| 273 | .boot_params = 0x00000100, |
| 274 | .map_io = tegra_map_common_io, |
| 275 | .init_early = tegra_init_early, |
| 276 | .init_irq = tegra_init_irq, |
| 277 | .timer = &tegra_timer, |
| 278 | .init_machine = tegra_wario_init, |
| 279 | MACHINE_END |