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> |
| 28 | #include <linux/i2c-tegra.h> |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 29 | |
Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame^] | 30 | #include <sound/wm8903.h> |
| 31 | |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | #include <asm/mach/time.h> |
| 35 | #include <asm/setup.h> |
| 36 | |
Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 37 | #include <mach/harmony_audio.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, |
| 53 | .flags = UPF_BOOT_AUTOCONF, |
| 54 | .iotype = UPIO_MEM, |
| 55 | .regshift = 2, |
| 56 | .uartclk = 216000000, |
| 57 | }, { |
| 58 | .flags = 0 |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | static struct platform_device debug_uart = { |
| 63 | .name = "serial8250", |
| 64 | .id = PLAT8250_DEV_PLATFORM, |
| 65 | .dev = { |
| 66 | .platform_data = debug_uart_platform_data, |
| 67 | }, |
| 68 | }; |
| 69 | |
Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 70 | static struct harmony_audio_platform_data harmony_audio_pdata = { |
| 71 | .gpio_spkr_en = TEGRA_GPIO_SPKR_EN, |
| 72 | .gpio_hp_det = TEGRA_GPIO_HP_DET, |
| 73 | .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN, |
| 74 | .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN, |
| 75 | }; |
| 76 | |
| 77 | static struct platform_device harmony_audio_device = { |
| 78 | .name = "tegra-snd-harmony", |
| 79 | .id = 0, |
| 80 | .dev = { |
| 81 | .platform_data = &harmony_audio_pdata, |
| 82 | }, |
| 83 | }; |
| 84 | |
Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 85 | static struct tegra_i2c_platform_data harmony_i2c1_platform_data = { |
| 86 | .bus_clk_rate = 400000, |
| 87 | }; |
| 88 | |
| 89 | static struct tegra_i2c_platform_data harmony_i2c2_platform_data = { |
| 90 | .bus_clk_rate = 400000, |
| 91 | }; |
| 92 | |
| 93 | static struct tegra_i2c_platform_data harmony_i2c3_platform_data = { |
| 94 | .bus_clk_rate = 400000, |
| 95 | }; |
| 96 | |
| 97 | static struct tegra_i2c_platform_data harmony_dvc_platform_data = { |
| 98 | .bus_clk_rate = 400000, |
| 99 | }; |
| 100 | |
Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame^] | 101 | static struct wm8903_platform_data harmony_wm8903_pdata = { |
| 102 | .irq_active_low = 0, |
| 103 | .micdet_cfg = 0, |
| 104 | .micdet_delay = 100, |
| 105 | .gpio_cfg = { |
| 106 | WM8903_GPIO_NO_CONFIG, |
| 107 | WM8903_GPIO_NO_CONFIG, |
| 108 | 0, |
| 109 | WM8903_GPIO_NO_CONFIG, |
| 110 | WM8903_GPIO_NO_CONFIG, |
| 111 | }, |
| 112 | }; |
| 113 | |
| 114 | static struct i2c_board_info __initdata wm8903_board_info = { |
| 115 | I2C_BOARD_INFO("wm8903", 0x1a), |
| 116 | .platform_data = &harmony_wm8903_pdata, |
| 117 | .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ), |
| 118 | }; |
| 119 | |
Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 120 | static void __init harmony_i2c_init(void) |
| 121 | { |
| 122 | tegra_i2c_device1.dev.platform_data = &harmony_i2c1_platform_data; |
| 123 | tegra_i2c_device2.dev.platform_data = &harmony_i2c2_platform_data; |
| 124 | tegra_i2c_device3.dev.platform_data = &harmony_i2c3_platform_data; |
| 125 | tegra_i2c_device4.dev.platform_data = &harmony_dvc_platform_data; |
| 126 | |
| 127 | platform_device_register(&tegra_i2c_device1); |
| 128 | platform_device_register(&tegra_i2c_device2); |
| 129 | platform_device_register(&tegra_i2c_device3); |
| 130 | platform_device_register(&tegra_i2c_device4); |
Stephen Warren | fba3b2f | 2011-03-04 22:42:31 -0700 | [diff] [blame^] | 131 | |
| 132 | i2c_register_board_info(0, &wm8903_board_info, 1); |
Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 133 | } |
| 134 | |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 135 | static struct platform_device *harmony_devices[] __initdata = { |
| 136 | &debug_uart, |
Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 137 | &tegra_sdhci_device1, |
| 138 | &tegra_sdhci_device2, |
| 139 | &tegra_sdhci_device4, |
Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 140 | &tegra_i2s_device1, |
| 141 | &tegra_das_device, |
| 142 | &tegra_pcm_device, |
| 143 | &harmony_audio_device, |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | static void __init tegra_harmony_fixup(struct machine_desc *desc, |
| 147 | struct tag *tags, char **cmdline, struct meminfo *mi) |
| 148 | { |
| 149 | mi->nr_banks = 2; |
| 150 | mi->bank[0].start = PHYS_OFFSET; |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 151 | mi->bank[0].size = 448 * SZ_1M; |
| 152 | mi->bank[1].start = SZ_512M; |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 153 | mi->bank[1].size = SZ_512M; |
| 154 | } |
| 155 | |
| 156 | static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = { |
| 157 | /* name parent rate enabled */ |
| 158 | { "uartd", "pll_p", 216000000, true }, |
Stephen Warren | ef2b1a0 | 2011-03-04 22:44:29 -0700 | [diff] [blame] | 159 | { "pll_a", "pll_p_out1", 56448000, true }, |
| 160 | { "pll_a_out0", "pll_a", 11289600, true }, |
| 161 | { "cdev1", NULL, 0, true }, |
| 162 | { "i2s1", "pll_a_out0", 11289600, false}, |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 163 | { NULL, NULL, 0, 0}, |
| 164 | }; |
| 165 | |
Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 166 | |
| 167 | static struct tegra_sdhci_platform_data sdhci_pdata1 = { |
| 168 | .cd_gpio = -1, |
| 169 | .wp_gpio = -1, |
| 170 | .power_gpio = -1, |
| 171 | }; |
| 172 | |
| 173 | static struct tegra_sdhci_platform_data sdhci_pdata2 = { |
Stephen Warren | 986afbe | 2011-03-04 22:44:28 -0700 | [diff] [blame] | 174 | .cd_gpio = TEGRA_GPIO_SD2_CD, |
| 175 | .wp_gpio = TEGRA_GPIO_SD2_WP, |
| 176 | .power_gpio = TEGRA_GPIO_SD2_POWER, |
Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | static struct tegra_sdhci_platform_data sdhci_pdata4 = { |
Stephen Warren | 986afbe | 2011-03-04 22:44:28 -0700 | [diff] [blame] | 180 | .cd_gpio = TEGRA_GPIO_SD4_CD, |
| 181 | .wp_gpio = TEGRA_GPIO_SD4_WP, |
| 182 | .power_gpio = TEGRA_GPIO_SD4_POWER, |
Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 183 | .is_8bit = 1, |
| 184 | }; |
| 185 | |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 186 | static void __init tegra_harmony_init(void) |
| 187 | { |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 188 | tegra_clk_init_from_table(harmony_clk_init_table); |
| 189 | |
| 190 | harmony_pinmux_init(); |
| 191 | |
Olof Johansson | 875d4af | 2011-02-19 16:39:37 -0800 | [diff] [blame] | 192 | tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1; |
| 193 | tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2; |
| 194 | tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4; |
| 195 | |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 196 | platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices)); |
Olof Johansson | de4855d | 2011-03-04 15:26:46 -0800 | [diff] [blame] | 197 | harmony_i2c_init(); |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | MACHINE_START(HARMONY, "harmony") |
| 201 | .boot_params = 0x00000100, |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 202 | .fixup = tegra_harmony_fixup, |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 203 | .map_io = tegra_map_common_io, |
Colin Cross | 0cf6230 | 2011-02-21 17:10:14 -0800 | [diff] [blame] | 204 | .init_early = tegra_init_early, |
| 205 | .init_irq = tegra_init_irq, |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 206 | .timer = &tegra_timer, |
Colin Cross | 0cf6230 | 2011-02-21 17:10:14 -0800 | [diff] [blame] | 207 | .init_machine = tegra_harmony_init, |
Colin Cross | 42a7bf4 | 2010-02-10 17:13:07 -0800 | [diff] [blame] | 208 | MACHINE_END |