blob: 30e18bc60647b35e78bc914703de41af0ecc8e44 [file] [log] [blame]
Colin Cross42a7bf42010-02-10 17:13:07 -08001/*
2 * arch/arm/mach-tegra/board-harmony.c
3 *
4 * Copyright (C) 2010 Google, Inc.
Stephen Warrenef2b1a02011-03-04 22:44:29 -07005 * Copyright (C) 2011 NVIDIA, Inc.
Colin Cross42a7bf42010-02-10 17:13:07 -08006 *
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 Warrenef2b1a02011-03-04 22:44:29 -070026#include <linux/gpio.h>
Olof Johanssonde4855d2011-03-04 15:26:46 -080027#include <linux/i2c.h>
28#include <linux/i2c-tegra.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080029
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070030#include <sound/wm8903.h>
31
Colin Cross42a7bf42010-02-10 17:13:07 -080032#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/time.h>
35#include <asm/setup.h>
36
Stephen Warren4651d552011-04-12 11:28:59 -060037#include <mach/tegra_wm8903_pdata.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080038#include <mach/iomap.h>
39#include <mach/irqs.h>
Olof Johansson875d4af2011-02-19 16:39:37 -080040#include <mach/sdhci.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080041
42#include "board.h"
43#include "board-harmony.h"
44#include "clock.h"
Olof Johansson875d4af2011-02-19 16:39:37 -080045#include "devices.h"
46#include "gpio-names.h"
Colin Cross42a7bf42010-02-10 17:13:07 -080047
Colin Cross42a7bf42010-02-10 17:13:07 -080048static 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
62static 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 Warren4651d552011-04-12 11:28:59 -060070static struct tegra_wm8903_platform_data harmony_audio_pdata = {
Stephen Warrenef2b1a02011-03-04 22:44:29 -070071 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
72 .gpio_hp_det = TEGRA_GPIO_HP_DET,
Stephen Warren61a6d072011-04-12 11:29:01 -060073 .gpio_hp_mute = -1,
Stephen Warrenef2b1a02011-03-04 22:44:29 -070074 .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN,
75 .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN,
76};
77
78static struct platform_device harmony_audio_device = {
Stephen Warren7b33af22011-04-12 11:29:00 -060079 .name = "tegra-snd-wm8903",
Stephen Warrenef2b1a02011-03-04 22:44:29 -070080 .id = 0,
81 .dev = {
82 .platform_data = &harmony_audio_pdata,
83 },
84};
85
Olof Johanssonde4855d2011-03-04 15:26:46 -080086static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
87 .bus_clk_rate = 400000,
88};
89
90static struct tegra_i2c_platform_data harmony_i2c2_platform_data = {
91 .bus_clk_rate = 400000,
92};
93
94static struct tegra_i2c_platform_data harmony_i2c3_platform_data = {
95 .bus_clk_rate = 400000,
96};
97
98static struct tegra_i2c_platform_data harmony_dvc_platform_data = {
99 .bus_clk_rate = 400000,
100};
101
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700102static struct wm8903_platform_data harmony_wm8903_pdata = {
103 .irq_active_low = 0,
104 .micdet_cfg = 0,
105 .micdet_delay = 100,
Stephen Warren06fc9a32011-03-04 22:42:32 -0700106 .gpio_base = HARMONY_GPIO_WM8903(0),
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700107 .gpio_cfg = {
108 WM8903_GPIO_NO_CONFIG,
109 WM8903_GPIO_NO_CONFIG,
110 0,
111 WM8903_GPIO_NO_CONFIG,
112 WM8903_GPIO_NO_CONFIG,
113 },
114};
115
116static struct i2c_board_info __initdata wm8903_board_info = {
117 I2C_BOARD_INFO("wm8903", 0x1a),
118 .platform_data = &harmony_wm8903_pdata,
119 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
120};
121
Olof Johanssonde4855d2011-03-04 15:26:46 -0800122static void __init harmony_i2c_init(void)
123{
124 tegra_i2c_device1.dev.platform_data = &harmony_i2c1_platform_data;
125 tegra_i2c_device2.dev.platform_data = &harmony_i2c2_platform_data;
126 tegra_i2c_device3.dev.platform_data = &harmony_i2c3_platform_data;
127 tegra_i2c_device4.dev.platform_data = &harmony_dvc_platform_data;
128
129 platform_device_register(&tegra_i2c_device1);
130 platform_device_register(&tegra_i2c_device2);
131 platform_device_register(&tegra_i2c_device3);
132 platform_device_register(&tegra_i2c_device4);
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700133
134 i2c_register_board_info(0, &wm8903_board_info, 1);
Olof Johanssonde4855d2011-03-04 15:26:46 -0800135}
136
Colin Cross42a7bf42010-02-10 17:13:07 -0800137static struct platform_device *harmony_devices[] __initdata = {
138 &debug_uart,
Olof Johansson875d4af2011-02-19 16:39:37 -0800139 &tegra_sdhci_device1,
140 &tegra_sdhci_device2,
141 &tegra_sdhci_device4,
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700142 &tegra_i2s_device1,
143 &tegra_das_device,
144 &tegra_pcm_device,
145 &harmony_audio_device,
Colin Cross42a7bf42010-02-10 17:13:07 -0800146};
147
148static void __init tegra_harmony_fixup(struct machine_desc *desc,
149 struct tag *tags, char **cmdline, struct meminfo *mi)
150{
151 mi->nr_banks = 2;
152 mi->bank[0].start = PHYS_OFFSET;
Colin Cross42a7bf42010-02-10 17:13:07 -0800153 mi->bank[0].size = 448 * SZ_1M;
154 mi->bank[1].start = SZ_512M;
Colin Cross42a7bf42010-02-10 17:13:07 -0800155 mi->bank[1].size = SZ_512M;
156}
157
158static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {
159 /* name parent rate enabled */
160 { "uartd", "pll_p", 216000000, true },
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700161 { "pll_a", "pll_p_out1", 56448000, true },
162 { "pll_a_out0", "pll_a", 11289600, true },
163 { "cdev1", NULL, 0, true },
164 { "i2s1", "pll_a_out0", 11289600, false},
Colin Cross42a7bf42010-02-10 17:13:07 -0800165 { NULL, NULL, 0, 0},
166};
167
Olof Johansson875d4af2011-02-19 16:39:37 -0800168
169static struct tegra_sdhci_platform_data sdhci_pdata1 = {
170 .cd_gpio = -1,
171 .wp_gpio = -1,
172 .power_gpio = -1,
173};
174
175static struct tegra_sdhci_platform_data sdhci_pdata2 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700176 .cd_gpio = TEGRA_GPIO_SD2_CD,
177 .wp_gpio = TEGRA_GPIO_SD2_WP,
178 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johansson875d4af2011-02-19 16:39:37 -0800179};
180
181static struct tegra_sdhci_platform_data sdhci_pdata4 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700182 .cd_gpio = TEGRA_GPIO_SD4_CD,
183 .wp_gpio = TEGRA_GPIO_SD4_WP,
184 .power_gpio = TEGRA_GPIO_SD4_POWER,
Olof Johansson875d4af2011-02-19 16:39:37 -0800185 .is_8bit = 1,
186};
187
Colin Cross42a7bf42010-02-10 17:13:07 -0800188static void __init tegra_harmony_init(void)
189{
Colin Cross42a7bf42010-02-10 17:13:07 -0800190 tegra_clk_init_from_table(harmony_clk_init_table);
191
192 harmony_pinmux_init();
193
Olof Johansson875d4af2011-02-19 16:39:37 -0800194 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
195 tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2;
196 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
197
Colin Cross42a7bf42010-02-10 17:13:07 -0800198 platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
Olof Johanssonde4855d2011-03-04 15:26:46 -0800199 harmony_i2c_init();
Mike Rapoport6f168f22011-03-09 16:31:18 +0200200 harmony_regulator_init();
Colin Cross42a7bf42010-02-10 17:13:07 -0800201}
202
203MACHINE_START(HARMONY, "harmony")
204 .boot_params = 0x00000100,
Colin Cross42a7bf42010-02-10 17:13:07 -0800205 .fixup = tegra_harmony_fixup,
Colin Cross42a7bf42010-02-10 17:13:07 -0800206 .map_io = tegra_map_common_io,
Colin Cross0cf62302011-02-21 17:10:14 -0800207 .init_early = tegra_init_early,
208 .init_irq = tegra_init_irq,
Colin Cross42a7bf42010-02-10 17:13:07 -0800209 .timer = &tegra_timer,
Colin Cross0cf62302011-02-21 17:10:14 -0800210 .init_machine = tegra_harmony_init,
Colin Cross42a7bf42010-02-10 17:13:07 -0800211MACHINE_END