blob: f528a5a192a6019fce05ffb4219f0c209bb0d19c [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>
Colin Cross42a7bf42010-02-10 17:13:07 -080028
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070029#include <sound/wm8903.h>
30
Colin Cross42a7bf42010-02-10 17:13:07 -080031#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/time.h>
34#include <asm/setup.h>
35
Stephen Warren4651d552011-04-12 11:28:59 -060036#include <mach/tegra_wm8903_pdata.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080037#include <mach/iomap.h>
38#include <mach/irqs.h>
Olof Johansson875d4af2011-02-19 16:39:37 -080039#include <mach/sdhci.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080040
41#include "board.h"
42#include "board-harmony.h"
43#include "clock.h"
Olof Johansson875d4af2011-02-19 16:39:37 -080044#include "devices.h"
45#include "gpio-names.h"
Colin Cross42a7bf42010-02-10 17:13:07 -080046
Colin Cross42a7bf42010-02-10 17:13:07 -080047static struct plat_serial8250_port debug_uart_platform_data[] = {
48 {
49 .membase = IO_ADDRESS(TEGRA_UARTD_BASE),
50 .mapbase = TEGRA_UARTD_BASE,
51 .irq = INT_UARTD,
52 .flags = UPF_BOOT_AUTOCONF,
53 .iotype = UPIO_MEM,
54 .regshift = 2,
55 .uartclk = 216000000,
56 }, {
57 .flags = 0
58 }
59};
60
61static struct platform_device debug_uart = {
62 .name = "serial8250",
63 .id = PLAT8250_DEV_PLATFORM,
64 .dev = {
65 .platform_data = debug_uart_platform_data,
66 },
67};
68
Stephen Warren4651d552011-04-12 11:28:59 -060069static struct tegra_wm8903_platform_data harmony_audio_pdata = {
Stephen Warrenef2b1a02011-03-04 22:44:29 -070070 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
71 .gpio_hp_det = TEGRA_GPIO_HP_DET,
Stephen Warren61a6d072011-04-12 11:29:01 -060072 .gpio_hp_mute = -1,
Stephen Warrenef2b1a02011-03-04 22:44:29 -070073 .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN,
74 .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN,
75};
76
77static struct platform_device harmony_audio_device = {
Stephen Warren7b33af22011-04-12 11:29:00 -060078 .name = "tegra-snd-wm8903",
Stephen Warrenef2b1a02011-03-04 22:44:29 -070079 .id = 0,
80 .dev = {
81 .platform_data = &harmony_audio_pdata,
82 },
83};
84
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070085static struct wm8903_platform_data harmony_wm8903_pdata = {
86 .irq_active_low = 0,
87 .micdet_cfg = 0,
88 .micdet_delay = 100,
Stephen Warren06fc9a32011-03-04 22:42:32 -070089 .gpio_base = HARMONY_GPIO_WM8903(0),
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070090 .gpio_cfg = {
91 WM8903_GPIO_NO_CONFIG,
92 WM8903_GPIO_NO_CONFIG,
93 0,
94 WM8903_GPIO_NO_CONFIG,
95 WM8903_GPIO_NO_CONFIG,
96 },
97};
98
99static struct i2c_board_info __initdata wm8903_board_info = {
100 I2C_BOARD_INFO("wm8903", 0x1a),
101 .platform_data = &harmony_wm8903_pdata,
102 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
103};
104
Olof Johanssonde4855d2011-03-04 15:26:46 -0800105static void __init harmony_i2c_init(void)
106{
Olof Johanssonde4855d2011-03-04 15:26:46 -0800107 platform_device_register(&tegra_i2c_device1);
108 platform_device_register(&tegra_i2c_device2);
109 platform_device_register(&tegra_i2c_device3);
110 platform_device_register(&tegra_i2c_device4);
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700111
112 i2c_register_board_info(0, &wm8903_board_info, 1);
Olof Johanssonde4855d2011-03-04 15:26:46 -0800113}
114
Colin Cross42a7bf42010-02-10 17:13:07 -0800115static struct platform_device *harmony_devices[] __initdata = {
116 &debug_uart,
Olof Johansson875d4af2011-02-19 16:39:37 -0800117 &tegra_sdhci_device1,
118 &tegra_sdhci_device2,
119 &tegra_sdhci_device4,
Stephen Warrendd58bdb2011-08-08 14:35:13 -0600120 &tegra_ehci3_device,
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700121 &tegra_i2s_device1,
122 &tegra_das_device,
123 &tegra_pcm_device,
124 &harmony_audio_device,
Colin Cross42a7bf42010-02-10 17:13:07 -0800125};
126
127static void __init tegra_harmony_fixup(struct machine_desc *desc,
128 struct tag *tags, char **cmdline, struct meminfo *mi)
129{
130 mi->nr_banks = 2;
131 mi->bank[0].start = PHYS_OFFSET;
Colin Cross42a7bf42010-02-10 17:13:07 -0800132 mi->bank[0].size = 448 * SZ_1M;
133 mi->bank[1].start = SZ_512M;
Colin Cross42a7bf42010-02-10 17:13:07 -0800134 mi->bank[1].size = SZ_512M;
135}
136
137static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {
138 /* name parent rate enabled */
139 { "uartd", "pll_p", 216000000, true },
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700140 { "pll_a", "pll_p_out1", 56448000, true },
141 { "pll_a_out0", "pll_a", 11289600, true },
142 { "cdev1", NULL, 0, true },
143 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrendd58bdb2011-08-08 14:35:13 -0600144 { "usb3", "clk_m", 12000000, true },
Colin Cross42a7bf42010-02-10 17:13:07 -0800145 { NULL, NULL, 0, 0},
146};
147
Olof Johansson875d4af2011-02-19 16:39:37 -0800148
149static struct tegra_sdhci_platform_data sdhci_pdata1 = {
150 .cd_gpio = -1,
151 .wp_gpio = -1,
152 .power_gpio = -1,
153};
154
155static struct tegra_sdhci_platform_data sdhci_pdata2 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700156 .cd_gpio = TEGRA_GPIO_SD2_CD,
157 .wp_gpio = TEGRA_GPIO_SD2_WP,
158 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johansson875d4af2011-02-19 16:39:37 -0800159};
160
161static struct tegra_sdhci_platform_data sdhci_pdata4 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700162 .cd_gpio = TEGRA_GPIO_SD4_CD,
163 .wp_gpio = TEGRA_GPIO_SD4_WP,
164 .power_gpio = TEGRA_GPIO_SD4_POWER,
Olof Johansson875d4af2011-02-19 16:39:37 -0800165 .is_8bit = 1,
166};
167
Colin Cross42a7bf42010-02-10 17:13:07 -0800168static void __init tegra_harmony_init(void)
169{
Colin Cross42a7bf42010-02-10 17:13:07 -0800170 tegra_clk_init_from_table(harmony_clk_init_table);
171
172 harmony_pinmux_init();
173
Olof Johansson875d4af2011-02-19 16:39:37 -0800174 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
175 tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2;
176 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
177
Colin Cross42a7bf42010-02-10 17:13:07 -0800178 platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
Olof Johanssonde4855d2011-03-04 15:26:46 -0800179 harmony_i2c_init();
Mike Rapoport6f168f22011-03-09 16:31:18 +0200180 harmony_regulator_init();
Colin Cross42a7bf42010-02-10 17:13:07 -0800181}
182
183MACHINE_START(HARMONY, "harmony")
184 .boot_params = 0x00000100,
Colin Cross42a7bf42010-02-10 17:13:07 -0800185 .fixup = tegra_harmony_fixup,
Colin Cross42a7bf42010-02-10 17:13:07 -0800186 .map_io = tegra_map_common_io,
Colin Cross0cf62302011-02-21 17:10:14 -0800187 .init_early = tegra_init_early,
188 .init_irq = tegra_init_irq,
Colin Cross42a7bf42010-02-10 17:13:07 -0800189 .timer = &tegra_timer,
Colin Cross0cf62302011-02-21 17:10:14 -0800190 .init_machine = tegra_harmony_init,
Colin Cross42a7bf42010-02-10 17:13:07 -0800191MACHINE_END