blob: e65e837f40136bba659b5ce2ae3b640fc70e9a0b [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>
Dan Williamsbf03f652012-04-10 14:10:53 -070022#include <linux/of_serial.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080023#include <linux/clk.h>
24#include <linux/dma-mapping.h>
25#include <linux/pda_power.h>
26#include <linux/io.h>
Stephen Warrenef2b1a02011-03-04 22:44:29 -070027#include <linux/gpio.h>
Olof Johanssonde4855d2011-03-04 15:26:46 -080028#include <linux/i2c.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>
Marc Zyngierafed2a22011-09-06 10:23:45 +010035#include <asm/hardware/gic.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080036#include <asm/setup.h>
37
Stephen Warren4651d552011-04-12 11:28:59 -060038#include <mach/tegra_wm8903_pdata.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080039#include <mach/iomap.h>
40#include <mach/irqs.h>
Olof Johansson875d4af2011-02-19 16:39:37 -080041#include <mach/sdhci.h>
Colin Cross42a7bf42010-02-10 17:13:07 -080042
43#include "board.h"
44#include "board-harmony.h"
45#include "clock.h"
Olof Johansson875d4af2011-02-19 16:39:37 -080046#include "devices.h"
47#include "gpio-names.h"
Colin Cross42a7bf42010-02-10 17:13:07 -080048
Colin Cross42a7bf42010-02-10 17:13:07 -080049static struct plat_serial8250_port debug_uart_platform_data[] = {
50 {
51 .membase = IO_ADDRESS(TEGRA_UARTD_BASE),
52 .mapbase = TEGRA_UARTD_BASE,
53 .irq = INT_UARTD,
Stephen Warren11b3adb2011-08-08 15:01:05 -060054 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
55 .type = PORT_TEGRA,
Dan Williamsbf03f652012-04-10 14:10:53 -070056 .handle_break = tegra_serial_handle_break,
Colin Cross42a7bf42010-02-10 17:13:07 -080057 .iotype = UPIO_MEM,
58 .regshift = 2,
59 .uartclk = 216000000,
60 }, {
61 .flags = 0
62 }
63};
64
65static struct platform_device debug_uart = {
66 .name = "serial8250",
67 .id = PLAT8250_DEV_PLATFORM,
68 .dev = {
69 .platform_data = debug_uart_platform_data,
70 },
71};
72
Stephen Warren4651d552011-04-12 11:28:59 -060073static struct tegra_wm8903_platform_data harmony_audio_pdata = {
Stephen Warrenef2b1a02011-03-04 22:44:29 -070074 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
75 .gpio_hp_det = TEGRA_GPIO_HP_DET,
Stephen Warren61a6d072011-04-12 11:29:01 -060076 .gpio_hp_mute = -1,
Stephen Warrenef2b1a02011-03-04 22:44:29 -070077 .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN,
78 .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN,
79};
80
81static struct platform_device harmony_audio_device = {
Stephen Warren7b33af22011-04-12 11:29:00 -060082 .name = "tegra-snd-wm8903",
Stephen Warrenef2b1a02011-03-04 22:44:29 -070083 .id = 0,
84 .dev = {
85 .platform_data = &harmony_audio_pdata,
86 },
87};
88
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070089static struct wm8903_platform_data harmony_wm8903_pdata = {
90 .irq_active_low = 0,
91 .micdet_cfg = 0,
92 .micdet_delay = 100,
Stephen Warren06fc9a32011-03-04 22:42:32 -070093 .gpio_base = HARMONY_GPIO_WM8903(0),
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070094 .gpio_cfg = {
Stephen Warrenfba3b2f2011-03-04 22:42:31 -070095 0,
Stephen Warrena0f203d2011-12-02 15:08:37 -070096 0,
97 WM8903_GPIO_CONFIG_ZERO,
98 0,
99 0,
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700100 },
101};
102
103static struct i2c_board_info __initdata wm8903_board_info = {
104 I2C_BOARD_INFO("wm8903", 0x1a),
105 .platform_data = &harmony_wm8903_pdata,
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700106};
107
Olof Johanssonde4855d2011-03-04 15:26:46 -0800108static void __init harmony_i2c_init(void)
109{
Olof Johanssonde4855d2011-03-04 15:26:46 -0800110 platform_device_register(&tegra_i2c_device1);
111 platform_device_register(&tegra_i2c_device2);
112 platform_device_register(&tegra_i2c_device3);
113 platform_device_register(&tegra_i2c_device4);
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700114
Stephen Warren21235522012-01-04 08:39:33 +0000115 wm8903_board_info.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
Stephen Warrenfba3b2f2011-03-04 22:42:31 -0700116 i2c_register_board_info(0, &wm8903_board_info, 1);
Olof Johanssonde4855d2011-03-04 15:26:46 -0800117}
118
Colin Cross42a7bf42010-02-10 17:13:07 -0800119static struct platform_device *harmony_devices[] __initdata = {
120 &debug_uart,
Olof Johansson875d4af2011-02-19 16:39:37 -0800121 &tegra_sdhci_device1,
122 &tegra_sdhci_device2,
123 &tegra_sdhci_device4,
Stephen Warrendd58bdb2011-08-08 14:35:13 -0600124 &tegra_ehci3_device,
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700125 &tegra_i2s_device1,
126 &tegra_das_device,
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700127 &harmony_audio_device,
Colin Cross42a7bf42010-02-10 17:13:07 -0800128};
129
Russell King0744a3e2010-12-20 10:37:50 +0000130static void __init tegra_harmony_fixup(struct tag *tags, char **cmdline,
131 struct meminfo *mi)
Colin Cross42a7bf42010-02-10 17:13:07 -0800132{
133 mi->nr_banks = 2;
134 mi->bank[0].start = PHYS_OFFSET;
Colin Cross42a7bf42010-02-10 17:13:07 -0800135 mi->bank[0].size = 448 * SZ_1M;
136 mi->bank[1].start = SZ_512M;
Colin Cross42a7bf42010-02-10 17:13:07 -0800137 mi->bank[1].size = SZ_512M;
138}
139
140static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {
141 /* name parent rate enabled */
142 { "uartd", "pll_p", 216000000, true },
Stephen Warrenef2b1a02011-03-04 22:44:29 -0700143 { "pll_a", "pll_p_out1", 56448000, true },
144 { "pll_a_out0", "pll_a", 11289600, true },
145 { "cdev1", NULL, 0, true },
146 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrendd58bdb2011-08-08 14:35:13 -0600147 { "usb3", "clk_m", 12000000, true },
Colin Cross42a7bf42010-02-10 17:13:07 -0800148 { NULL, NULL, 0, 0},
149};
150
Olof Johansson875d4af2011-02-19 16:39:37 -0800151
152static struct tegra_sdhci_platform_data sdhci_pdata1 = {
153 .cd_gpio = -1,
154 .wp_gpio = -1,
155 .power_gpio = -1,
156};
157
158static struct tegra_sdhci_platform_data sdhci_pdata2 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700159 .cd_gpio = TEGRA_GPIO_SD2_CD,
160 .wp_gpio = TEGRA_GPIO_SD2_WP,
161 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johansson875d4af2011-02-19 16:39:37 -0800162};
163
164static struct tegra_sdhci_platform_data sdhci_pdata4 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700165 .cd_gpio = TEGRA_GPIO_SD4_CD,
166 .wp_gpio = TEGRA_GPIO_SD4_WP,
167 .power_gpio = TEGRA_GPIO_SD4_POWER,
Olof Johansson875d4af2011-02-19 16:39:37 -0800168 .is_8bit = 1,
169};
170
Colin Cross42a7bf42010-02-10 17:13:07 -0800171static void __init tegra_harmony_init(void)
172{
Colin Cross42a7bf42010-02-10 17:13:07 -0800173 tegra_clk_init_from_table(harmony_clk_init_table);
174
175 harmony_pinmux_init();
176
Olof Johansson875d4af2011-02-19 16:39:37 -0800177 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
178 tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2;
179 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
180
Colin Cross42a7bf42010-02-10 17:13:07 -0800181 platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
Olof Johanssonde4855d2011-03-04 15:26:46 -0800182 harmony_i2c_init();
Mike Rapoport6f168f22011-03-09 16:31:18 +0200183 harmony_regulator_init();
Colin Cross42a7bf42010-02-10 17:13:07 -0800184}
185
186MACHINE_START(HARMONY, "harmony")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400187 .atag_offset = 0x100,
Colin Cross42a7bf42010-02-10 17:13:07 -0800188 .fixup = tegra_harmony_fixup,
Colin Cross42a7bf42010-02-10 17:13:07 -0800189 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200190 .init_early = tegra20_init_early,
Colin Cross0cf62302011-02-21 17:10:14 -0800191 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100192 .handle_irq = gic_handle_irq,
Colin Cross42a7bf42010-02-10 17:13:07 -0800193 .timer = &tegra_timer,
Colin Cross0cf62302011-02-21 17:10:14 -0800194 .init_machine = tegra_harmony_init,
Shawn Guo390e0cf2012-05-02 17:08:06 +0800195 .init_late = tegra_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000196 .restart = tegra_assert_system_reset,
Colin Cross42a7bf42010-02-10 17:13:07 -0800197MACHINE_END