arm: tegra: enterprise: Enabling Security Engine
[linux-2.6.git] / arch / arm / mach-tegra / board-enterprise.c
1 /*
2  * arch/arm/mach-tegra/board-enterprise.c
3  *
4  * Copyright (c) 2011, NVIDIA Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <linux/ctype.h>
25 #include <linux/platform_device.h>
26 #include <linux/clk.h>
27 #include <linux/serial_8250.h>
28 #include <linux/i2c.h>
29 #include <linux/dma-mapping.h>
30 #include <linux/delay.h>
31 #include <linux/i2c-tegra.h>
32 #include <linux/gpio.h>
33 #include <linux/input.h>
34 #include <linux/platform_data/tegra_usb.h>
35 #include <linux/spi/spi.h>
36 #include <mach/clk.h>
37 #include <mach/iomap.h>
38 #include <mach/irqs.h>
39 #include <mach/pinmux.h>
40 #include <mach/iomap.h>
41 #include <mach/io.h>
42 #include <asm/mach-types.h>
43 #include <asm/mach/arch.h>
44 #include <mach/usb_phy.h>
45
46 #include "board.h"
47 #include "clock.h"
48 #include "board-enterprise.h"
49 #include "devices.h"
50 #include "gpio-names.h"
51 #include "fuse.h"
52
53
54 static struct plat_serial8250_port debug_uart_platform_data[] = {
55         {
56                 .membase        = IO_ADDRESS(TEGRA_UARTD_BASE),
57                 .mapbase        = TEGRA_UARTD_BASE,
58                 .irq            = INT_UARTD,
59                 .flags          = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
60                 .type           = PORT_TEGRA,
61                 .iotype         = UPIO_MEM,
62                 .regshift       = 2,
63                 .uartclk        = 408000000,
64         }, {
65                 .flags          = 0,
66         }
67 };
68
69 static struct platform_device debug_uart = {
70         .name = "serial8250",
71         .id = PLAT8250_DEV_PLATFORM,
72         .dev = {
73                 .platform_data = debug_uart_platform_data,
74         },
75 };
76
77 /* !!!TODO: Change for enterprise (Taken from Cardhu) */
78 static struct tegra_utmip_config utmi_phy_config[] = {
79         [0] = {
80                         .hssync_start_delay = 0,
81                         .idle_wait_delay = 17,
82                         .elastic_limit = 16,
83                         .term_range_adj = 6,
84                         .xcvr_setup = 15,
85                         .xcvr_lsfslew = 2,
86                         .xcvr_lsrslew = 2,
87         },
88         [1] = {
89                         .hssync_start_delay = 0,
90                         .idle_wait_delay = 17,
91                         .elastic_limit = 16,
92                         .term_range_adj = 6,
93                         .xcvr_setup = 15,
94                         .xcvr_lsfslew = 2,
95                         .xcvr_lsrslew = 2,
96         },
97         [2] = {
98                         .hssync_start_delay = 0,
99                         .idle_wait_delay = 17,
100                         .elastic_limit = 16,
101                         .term_range_adj = 6,
102                         .xcvr_setup = 8,
103                         .xcvr_lsfslew = 2,
104                         .xcvr_lsrslew = 2,
105         },
106 };
107
108 #ifdef CONFIG_BCM4329_RFKILL
109 static struct resource enterprise_bcm4329_rfkill_resources[] = {
110         {
111                 .name   = "bcm4329_nshutdown_gpio",
112                 .start  = TEGRA_GPIO_PE6,
113                 .end    = TEGRA_GPIO_PE6,
114                 .flags  = IORESOURCE_IO,
115         },
116 };
117
118 static struct platform_device enterprise_bcm4329_rfkill_device = {
119         .name = "bcm4329_rfkill",
120         .id             = -1,
121         .num_resources  = ARRAY_SIZE(enterprise_bcm4329_rfkill_resources),
122         .resource       = enterprise_bcm4329_rfkill_resources,
123 };
124
125 static noinline void __init enterprise_bt_rfkill(void)
126 {
127         platform_device_register(&enterprise_bcm4329_rfkill_device);
128
129         return;
130 }
131 #else
132 static inline void enterprise_bt_rfkill(void) { }
133 #endif
134
135 static __initdata struct tegra_clk_init_table enterprise_clk_init_table[] = {
136         /* name         parent          rate            enabled */
137         { "uarta",      "pll_p",        408000000,      true},
138         { "uartb",      "pll_p",        408000000,      false},
139         { "uartc",      "pll_p",        408000000,      false},
140         { "uartd",      "pll_p",        408000000,      true},
141         { "uarte",      "pll_p",        408000000,      false},
142         { "pll_m",      NULL,           0,              true},
143         { "hda",        "pll_p",        108000000,      false},
144         { "hda2codec_2x","pll_p",       48000000,       false},
145         { "pwm",        "clk_32k",      32768,          false},
146         { "blink",      "clk_32k",      32768,          true},
147         { "pll_a",      NULL,           564480000,      false},
148         { "pll_a_out0", NULL,           11289600,       false},
149         { NULL,         NULL,           0,              0},
150 };
151
152 static struct i2c_board_info __initdata enterprise_i2c_bus1_board_info[] = {
153         {
154                 I2C_BOARD_INFO("wm8903", 0x1a),
155         },
156 };
157
158 static struct tegra_i2c_platform_data enterprise_i2c1_platform_data = {
159         .adapter_nr     = 0,
160         .bus_count      = 1,
161         .bus_clk_rate   = { 100000, 0 },
162 };
163
164 static struct tegra_i2c_platform_data enterprise_i2c2_platform_data = {
165         .adapter_nr     = 1,
166         .bus_count      = 1,
167         .bus_clk_rate   = { 100000, 0 },
168         .is_clkon_always = true,
169 };
170
171 static struct tegra_i2c_platform_data enterprise_i2c3_platform_data = {
172         .adapter_nr     = 2,
173         .bus_count      = 1,
174         .bus_clk_rate   = { 100000, 0 },
175 };
176
177 static struct tegra_i2c_platform_data enterprise_i2c4_platform_data = {
178         .adapter_nr     = 3,
179         .bus_count      = 1,
180         .bus_clk_rate   = { 100000, 0 },
181 };
182
183 static struct tegra_i2c_platform_data enterprise_i2c5_platform_data = {
184         .adapter_nr     = 4,
185         .bus_count      = 1,
186         .bus_clk_rate   = { 100000, 0 },
187 };
188
189 static void enterprise_i2c_init(void)
190 {
191         tegra_i2c_device1.dev.platform_data = &enterprise_i2c1_platform_data;
192         tegra_i2c_device2.dev.platform_data = &enterprise_i2c2_platform_data;
193         tegra_i2c_device3.dev.platform_data = &enterprise_i2c3_platform_data;
194         tegra_i2c_device4.dev.platform_data = &enterprise_i2c4_platform_data;
195         tegra_i2c_device5.dev.platform_data = &enterprise_i2c5_platform_data;
196
197         platform_device_register(&tegra_i2c_device5);
198         platform_device_register(&tegra_i2c_device4);
199         platform_device_register(&tegra_i2c_device3);
200         platform_device_register(&tegra_i2c_device2);
201         platform_device_register(&tegra_i2c_device1);
202 }
203
204 static struct resource tegra_rtc_resources[] = {
205         [0] = {
206                 .start = TEGRA_RTC_BASE,
207                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
208                 .flags = IORESOURCE_MEM,
209         },
210         [1] = {
211                 .start = INT_RTC,
212                 .end = INT_RTC,
213                 .flags = IORESOURCE_IRQ,
214         },
215 };
216
217 static struct platform_device tegra_rtc_device = {
218         .name = "tegra_rtc",
219         .id   = -1,
220         .resource = tegra_rtc_resources,
221         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
222 };
223
224 static struct platform_device tegra_camera = {
225         .name = "tegra_camera",
226         .id = -1,
227 };
228
229 static struct platform_device *enterprise_devices[] __initdata = {
230         &debug_uart,
231         &tegra_uarta_device,
232         &tegra_uartb_device,
233         &tegra_uartc_device,
234         &tegra_uarte_device,
235         &tegra_pmu_device,
236         &tegra_rtc_device,
237         &tegra_udc_device,
238 #if defined(CONFIG_SND_HDA_TEGRA)
239         &tegra_hda_device,
240 #endif
241 #if defined(CONFIG_TEGRA_IOVMM_SMMU)
242         &tegra_smmu_device,
243 #endif
244         &tegra_wdt_device,
245         &tegra_avp_device,
246         &tegra_camera,
247         &tegra_spi_device4,
248 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
249         &tegra_se_device,
250 #endif
251 };
252
253 static struct usb_phy_plat_data tegra_usb_phy_pdata[] = {
254         [0] = {
255                         .instance = 0,
256                         .vbus_gpio = -1,
257         },
258         [1] = {
259                         .instance = 1,
260                         .vbus_gpio = -1,
261         },
262         [2] = {
263                         .instance = 2,
264                         .vbus_gpio = -1,
265         },
266 };
267
268
269 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
270         [0] = {
271                         .phy_config = &utmi_phy_config[0],
272                         .operating_mode = TEGRA_USB_HOST,
273                         .power_down_on_bus_suspend = 1,
274         },
275         [1] = {
276                         .phy_config = &utmi_phy_config[1],
277                         .operating_mode = TEGRA_USB_HOST,
278                         .power_down_on_bus_suspend = 1,
279         },
280         [2] = {
281                         .phy_config = &utmi_phy_config[2],
282                         .operating_mode = TEGRA_USB_HOST,
283                         .power_down_on_bus_suspend = 1,
284         },
285 };
286
287 static struct platform_device *tegra_usb_otg_host_register(void)
288 {
289         struct platform_device *pdev;
290         void *platform_data;
291         int val;
292
293         pdev = platform_device_alloc(tegra_ehci1_device.name,
294                 tegra_ehci1_device.id);
295         if (!pdev)
296                 return NULL;
297
298         val = platform_device_add_resources(pdev, tegra_ehci1_device.resource,
299                 tegra_ehci1_device.num_resources);
300         if (val)
301                 goto error;
302
303         pdev->dev.dma_mask =  tegra_ehci1_device.dev.dma_mask;
304         pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask;
305
306         platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data),
307                 GFP_KERNEL);
308         if (!platform_data)
309                 goto error;
310
311         memcpy(platform_data, &tegra_ehci_pdata[0],
312                                 sizeof(struct tegra_ehci_platform_data));
313         pdev->dev.platform_data = platform_data;
314
315         val = platform_device_add(pdev);
316         if (val)
317                 goto error_add;
318
319         return pdev;
320
321 error_add:
322         kfree(platform_data);
323 error:
324         pr_err("%s: failed to add the host contoller device\n", __func__);
325         platform_device_put(pdev);
326         return NULL;
327 }
328
329 static void tegra_usb_otg_host_unregister(struct platform_device *pdev)
330 {
331         platform_device_unregister(pdev);
332 }
333
334 static struct tegra_otg_platform_data tegra_otg_pdata = {
335         .host_register = &tegra_usb_otg_host_register,
336         .host_unregister = &tegra_usb_otg_host_unregister,
337 };
338
339 static void enterprise_usb_init(void)
340 {
341         tegra_usb_phy_init(tegra_usb_phy_pdata, ARRAY_SIZE(tegra_usb_phy_pdata));
342
343         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
344         platform_device_register(&tegra_otg_device);
345
346         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
347         platform_device_register(&tegra_ehci3_device);
348
349 }
350
351 static void enterprise_gps_init(void)
352 {
353         tegra_gpio_enable(TEGRA_GPIO_PE4);
354         tegra_gpio_enable(TEGRA_GPIO_PE5);
355 }
356
357 static void __init tegra_enterprise_init(void)
358 {
359         tegra_clk_init_from_table(enterprise_clk_init_table);
360         enterprise_pinmux_init();
361         enterprise_i2c_init();
362         platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices));
363         enterprise_regulator_init();
364         enterprise_sdhci_init();
365         enterprise_usb_init();
366         /* enterprise_kbc_init(); */
367         enterprise_gps_init();
368         enterprise_baseband_init();
369         enterprise_panel_init();
370         enterprise_bt_rfkill();
371         enterprise_emc_init();
372         enterprise_sensors_init();
373         enterprise_suspend_init();
374 }
375
376 static void __init tegra_enterprise_reserve(void)
377 {
378 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
379         tegra_reserve(0, SZ_4M, SZ_8M);
380 #else
381         tegra_reserve(SZ_128M, SZ_4M, SZ_8M);
382 #endif
383 }
384
385 MACHINE_START(TEGRA_ENTERPRISE, "tegra_enterprise")
386         .boot_params    = 0x80000100,
387         .map_io         = tegra_map_common_io,
388         .reserve        = tegra_enterprise_reserve,
389         .init_early     = tegra_init_early,
390         .init_irq       = tegra_init_irq,
391         .timer          = &tegra_timer,
392         .init_machine   = tegra_enterprise_init,
393 MACHINE_END