| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * arch/arm/mach-tegra/board-harmony.c | 
 | 3 |  * | 
 | 4 |  * Copyright (C) 2010 Google, Inc. | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 5 |  * Copyright (C) 2011 NVIDIA, Inc. | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 6 |  * | 
 | 7 |  * This software is licensed under the terms of the GNU General Public | 
 | 8 |  * License version 2, as published by the Free Software Foundation, and | 
 | 9 |  * may be copied, distributed, and modified under those terms. | 
 | 10 |  * | 
 | 11 |  * This program is distributed in the hope that it will be useful, | 
 | 12 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 13 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 14 |  * GNU General Public License for more details. | 
 | 15 |  * | 
 | 16 |  */ | 
 | 17 |  | 
 | 18 | #include <linux/kernel.h> | 
 | 19 | #include <linux/init.h> | 
 | 20 | #include <linux/platform_device.h> | 
 | 21 | #include <linux/serial_8250.h> | 
 | 22 | #include <linux/clk.h> | 
 | 23 | #include <linux/dma-mapping.h> | 
 | 24 | #include <linux/pda_power.h> | 
 | 25 | #include <linux/io.h> | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 26 | #include <linux/gpio.h> | 
| Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 27 | #include <linux/i2c.h> | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 28 |  | 
| Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame] | 29 | #include <sound/wm8903.h> | 
 | 30 |  | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 31 | #include <asm/mach-types.h> | 
 | 32 | #include <asm/mach/arch.h> | 
 | 33 | #include <asm/mach/time.h> | 
| Marc Zyngier | afed2a2 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 34 | #include <asm/hardware/gic.h> | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 35 | #include <asm/setup.h> | 
 | 36 |  | 
| Stephen Warren | 4651d55 | 2011-04-12 11:28:59 -0600 | [diff] [blame] | 37 | #include <mach/tegra_wm8903_pdata.h> | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 38 | #include <mach/iomap.h> | 
 | 39 | #include <mach/irqs.h> | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 40 | #include <mach/sdhci.h> | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 41 |  | 
 | 42 | #include "board.h" | 
 | 43 | #include "board-harmony.h" | 
 | 44 | #include "clock.h" | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 45 | #include "devices.h" | 
 | 46 | #include "gpio-names.h" | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 47 |  | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 48 | static struct plat_serial8250_port debug_uart_platform_data[] = { | 
 | 49 | 	{ | 
 | 50 | 		.membase	= IO_ADDRESS(TEGRA_UARTD_BASE), | 
 | 51 | 		.mapbase	= TEGRA_UARTD_BASE, | 
 | 52 | 		.irq		= INT_UARTD, | 
| Stephen Warren | 11b3adb | 2011-08-08 15:01:05 -0600 | [diff] [blame] | 53 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE, | 
 | 54 | 		.type		= PORT_TEGRA, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 55 | 		.iotype		= UPIO_MEM, | 
 | 56 | 		.regshift	= 2, | 
 | 57 | 		.uartclk	= 216000000, | 
 | 58 | 	}, { | 
 | 59 | 		.flags		= 0 | 
 | 60 | 	} | 
 | 61 | }; | 
 | 62 |  | 
 | 63 | static struct platform_device debug_uart = { | 
 | 64 | 	.name = "serial8250", | 
 | 65 | 	.id = PLAT8250_DEV_PLATFORM, | 
 | 66 | 	.dev = { | 
 | 67 | 		.platform_data = debug_uart_platform_data, | 
 | 68 | 	}, | 
 | 69 | }; | 
 | 70 |  | 
| Stephen Warren | 4651d55 | 2011-04-12 11:28:59 -0600 | [diff] [blame] | 71 | static struct tegra_wm8903_platform_data harmony_audio_pdata = { | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 72 | 	.gpio_spkr_en		= TEGRA_GPIO_SPKR_EN, | 
 | 73 | 	.gpio_hp_det		= TEGRA_GPIO_HP_DET, | 
| Stephen Warren | 61a6d07 | 2011-04-12 11:29:01 -0600 | [diff] [blame] | 74 | 	.gpio_hp_mute		= -1, | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 75 | 	.gpio_int_mic_en	= TEGRA_GPIO_INT_MIC_EN, | 
 | 76 | 	.gpio_ext_mic_en	= TEGRA_GPIO_EXT_MIC_EN, | 
 | 77 | }; | 
 | 78 |  | 
 | 79 | static struct platform_device harmony_audio_device = { | 
| Stephen Warren | 7b33af2 | 2011-04-12 11:29:00 -0600 | [diff] [blame] | 80 | 	.name	= "tegra-snd-wm8903", | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 81 | 	.id	= 0, | 
 | 82 | 	.dev	= { | 
 | 83 | 		.platform_data  = &harmony_audio_pdata, | 
 | 84 | 	}, | 
 | 85 | }; | 
 | 86 |  | 
| Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame] | 87 | static struct wm8903_platform_data harmony_wm8903_pdata = { | 
 | 88 | 	.irq_active_low = 0, | 
 | 89 | 	.micdet_cfg = 0, | 
 | 90 | 	.micdet_delay = 100, | 
| Stephen Warren | 06fc9a3 | 2011-03-04 22:42:32 -0700 | [diff] [blame] | 91 | 	.gpio_base = HARMONY_GPIO_WM8903(0), | 
| Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame] | 92 | 	.gpio_cfg = { | 
| Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame] | 93 | 		0, | 
| Stephen Warren | a0f203d | 2011-12-02 15:08:37 -0700 | [diff] [blame] | 94 | 		0, | 
 | 95 | 		WM8903_GPIO_CONFIG_ZERO, | 
 | 96 | 		0, | 
 | 97 | 		0, | 
| Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame] | 98 | 	}, | 
 | 99 | }; | 
 | 100 |  | 
 | 101 | static struct i2c_board_info __initdata wm8903_board_info = { | 
 | 102 | 	I2C_BOARD_INFO("wm8903", 0x1a), | 
 | 103 | 	.platform_data = &harmony_wm8903_pdata, | 
 | 104 | 	.irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ), | 
 | 105 | }; | 
 | 106 |  | 
| Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 107 | static void __init harmony_i2c_init(void) | 
 | 108 | { | 
| Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 109 | 	platform_device_register(&tegra_i2c_device1); | 
 | 110 | 	platform_device_register(&tegra_i2c_device2); | 
 | 111 | 	platform_device_register(&tegra_i2c_device3); | 
 | 112 | 	platform_device_register(&tegra_i2c_device4); | 
| Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame] | 113 |  | 
 | 114 | 	i2c_register_board_info(0, &wm8903_board_info, 1); | 
| Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 115 | } | 
 | 116 |  | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 117 | static struct platform_device *harmony_devices[] __initdata = { | 
 | 118 | 	&debug_uart, | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 119 | 	&tegra_sdhci_device1, | 
 | 120 | 	&tegra_sdhci_device2, | 
 | 121 | 	&tegra_sdhci_device4, | 
| Stephen Warren | dd58bdb | 2011-08-08 14:35:13 -0600 | [diff] [blame] | 122 | 	&tegra_ehci3_device, | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 123 | 	&tegra_i2s_device1, | 
 | 124 | 	&tegra_das_device, | 
 | 125 | 	&tegra_pcm_device, | 
 | 126 | 	&harmony_audio_device, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 127 | }; | 
 | 128 |  | 
| Russell King | 0744a3e | 2010-12-20 10:37:50 +0000 | [diff] [blame] | 129 | static void __init tegra_harmony_fixup(struct tag *tags, char **cmdline, | 
 | 130 | 	struct meminfo *mi) | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 131 | { | 
 | 132 | 	mi->nr_banks = 2; | 
 | 133 | 	mi->bank[0].start = PHYS_OFFSET; | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 134 | 	mi->bank[0].size = 448 * SZ_1M; | 
 | 135 | 	mi->bank[1].start = SZ_512M; | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 136 | 	mi->bank[1].size = SZ_512M; | 
 | 137 | } | 
 | 138 |  | 
 | 139 | static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = { | 
 | 140 | 	/* name		parent		rate		enabled */ | 
 | 141 | 	{ "uartd",	"pll_p",	216000000,	true }, | 
| Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 142 | 	{ "pll_a",	"pll_p_out1",	56448000,	true }, | 
 | 143 | 	{ "pll_a_out0",	"pll_a",	11289600,	true }, | 
 | 144 | 	{ "cdev1",	NULL,		0,		true }, | 
 | 145 | 	{ "i2s1",	"pll_a_out0",	11289600,	false}, | 
| Stephen Warren | dd58bdb | 2011-08-08 14:35:13 -0600 | [diff] [blame] | 146 | 	{ "usb3",	"clk_m",	12000000,	true }, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 147 | 	{ NULL,		NULL,		0,		0}, | 
 | 148 | }; | 
 | 149 |  | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 150 |  | 
 | 151 | static struct tegra_sdhci_platform_data sdhci_pdata1 = { | 
 | 152 | 	.cd_gpio	= -1, | 
 | 153 | 	.wp_gpio	= -1, | 
 | 154 | 	.power_gpio	= -1, | 
 | 155 | }; | 
 | 156 |  | 
 | 157 | static struct tegra_sdhci_platform_data sdhci_pdata2 = { | 
| Stephen Warren | 986afbe | 2011-03-04 22:44:28 -0700 | [diff] [blame] | 158 | 	.cd_gpio	= TEGRA_GPIO_SD2_CD, | 
 | 159 | 	.wp_gpio	= TEGRA_GPIO_SD2_WP, | 
 | 160 | 	.power_gpio	= TEGRA_GPIO_SD2_POWER, | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 161 | }; | 
 | 162 |  | 
 | 163 | static struct tegra_sdhci_platform_data sdhci_pdata4 = { | 
| Stephen Warren | 986afbe | 2011-03-04 22:44:28 -0700 | [diff] [blame] | 164 | 	.cd_gpio	= TEGRA_GPIO_SD4_CD, | 
 | 165 | 	.wp_gpio	= TEGRA_GPIO_SD4_WP, | 
 | 166 | 	.power_gpio	= TEGRA_GPIO_SD4_POWER, | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 167 | 	.is_8bit	= 1, | 
 | 168 | }; | 
 | 169 |  | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 170 | static void __init tegra_harmony_init(void) | 
 | 171 | { | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 172 | 	tegra_clk_init_from_table(harmony_clk_init_table); | 
 | 173 |  | 
 | 174 | 	harmony_pinmux_init(); | 
 | 175 |  | 
| Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 176 | 	tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1; | 
 | 177 | 	tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2; | 
 | 178 | 	tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4; | 
 | 179 |  | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 180 | 	platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices)); | 
| Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 181 | 	harmony_i2c_init(); | 
| Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 182 | 	harmony_regulator_init(); | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 183 | } | 
 | 184 |  | 
 | 185 | MACHINE_START(HARMONY, "harmony") | 
| Nicolas Pitre | b61cafe | 2011-07-05 22:38:18 -0400 | [diff] [blame] | 186 | 	.atag_offset	= 0x100, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 187 | 	.fixup		= tegra_harmony_fixup, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 188 | 	.map_io         = tegra_map_common_io, | 
| Peter De Schrijver | c37c07d | 2011-12-14 17:03:17 +0200 | [diff] [blame] | 189 | 	.init_early	= tegra20_init_early, | 
| Colin Cross | 0cf6230 | 2011-02-21 17:10:14 -0800 | [diff] [blame] | 190 | 	.init_irq       = tegra_init_irq, | 
| Marc Zyngier | afed2a2 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 191 | 	.handle_irq	= gic_handle_irq, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 192 | 	.timer          = &tegra_timer, | 
| Colin Cross | 0cf6230 | 2011-02-21 17:10:14 -0800 | [diff] [blame] | 193 | 	.init_machine   = tegra_harmony_init, | 
| Russell King | abea3f2 | 2011-11-05 08:48:33 +0000 | [diff] [blame] | 194 | 	.restart	= tegra_assert_system_reset, | 
| Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 195 | MACHINE_END |