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