ARM: tegra: harmony: Beginnings of audio support
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-harmony.c
1 /*
2  * arch/arm/mach-tegra/board-harmony.c
3  *
4  * Copyright (C) 2010 Google, Inc.
5  * Copyright (C) 2011 NVIDIA, Inc.
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>
26 #include <linux/gpio.h>
27
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/time.h>
31 #include <asm/setup.h>
32
33 #include <mach/harmony_audio.h>
34 #include <mach/iomap.h>
35 #include <mach/irqs.h>
36 #include <mach/sdhci.h>
37
38 #include "board.h"
39 #include "board-harmony.h"
40 #include "clock.h"
41 #include "devices.h"
42 #include "gpio-names.h"
43
44 static struct plat_serial8250_port debug_uart_platform_data[] = {
45         {
46                 .membase        = IO_ADDRESS(TEGRA_UARTD_BASE),
47                 .mapbase        = TEGRA_UARTD_BASE,
48                 .irq            = INT_UARTD,
49                 .flags          = UPF_BOOT_AUTOCONF,
50                 .iotype         = UPIO_MEM,
51                 .regshift       = 2,
52                 .uartclk        = 216000000,
53         }, {
54                 .flags          = 0
55         }
56 };
57
58 static struct platform_device debug_uart = {
59         .name = "serial8250",
60         .id = PLAT8250_DEV_PLATFORM,
61         .dev = {
62                 .platform_data = debug_uart_platform_data,
63         },
64 };
65
66 static struct harmony_audio_platform_data harmony_audio_pdata = {
67         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
68         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
69         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
70         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
71 };
72
73 static struct platform_device harmony_audio_device = {
74         .name   = "tegra-snd-harmony",
75         .id     = 0,
76         .dev    = {
77                 .platform_data  = &harmony_audio_pdata,
78         },
79 };
80
81 static struct platform_device *harmony_devices[] __initdata = {
82         &debug_uart,
83         &tegra_sdhci_device1,
84         &tegra_sdhci_device2,
85         &tegra_sdhci_device4,
86         &tegra_i2s_device1,
87         &tegra_das_device,
88         &tegra_pcm_device,
89         &harmony_audio_device,
90 };
91
92 static void __init tegra_harmony_fixup(struct machine_desc *desc,
93         struct tag *tags, char **cmdline, struct meminfo *mi)
94 {
95         mi->nr_banks = 2;
96         mi->bank[0].start = PHYS_OFFSET;
97         mi->bank[0].size = 448 * SZ_1M;
98         mi->bank[1].start = SZ_512M;
99         mi->bank[1].size = SZ_512M;
100 }
101
102 static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {
103         /* name         parent          rate            enabled */
104         { "uartd",      "pll_p",        216000000,      true },
105         { "pll_a",      "pll_p_out1",   56448000,       true },
106         { "pll_a_out0", "pll_a",        11289600,       true },
107         { "cdev1",      NULL,           0,              true },
108         { "i2s1",       "pll_a_out0",   11289600,       false},
109         { NULL,         NULL,           0,              0},
110 };
111
112
113 static struct tegra_sdhci_platform_data sdhci_pdata1 = {
114         .cd_gpio        = -1,
115         .wp_gpio        = -1,
116         .power_gpio     = -1,
117 };
118
119 static struct tegra_sdhci_platform_data sdhci_pdata2 = {
120         .cd_gpio        = TEGRA_GPIO_SD2_CD,
121         .wp_gpio        = TEGRA_GPIO_SD2_WP,
122         .power_gpio     = TEGRA_GPIO_SD2_POWER,
123 };
124
125 static struct tegra_sdhci_platform_data sdhci_pdata4 = {
126         .cd_gpio        = TEGRA_GPIO_SD4_CD,
127         .wp_gpio        = TEGRA_GPIO_SD4_WP,
128         .power_gpio     = TEGRA_GPIO_SD4_POWER,
129         .is_8bit        = 1,
130 };
131
132 static void __init tegra_harmony_init(void)
133 {
134         tegra_clk_init_from_table(harmony_clk_init_table);
135
136         harmony_pinmux_init();
137
138         tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
139         tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2;
140         tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
141
142         platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
143 }
144
145 MACHINE_START(HARMONY, "harmony")
146         .boot_params  = 0x00000100,
147         .fixup          = tegra_harmony_fixup,
148         .map_io         = tegra_map_common_io,
149         .init_early     = tegra_init_early,
150         .init_irq       = tegra_init_irq,
151         .timer          = &tegra_timer,
152         .init_machine   = tegra_harmony_init,
153 MACHINE_END