arm: tegra: enterprise: Enabling vbus regulator
[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                         .vbus_reg_supply = "usb_vbus",
258         },
259         [1] = {
260                         .instance = 1,
261                         .vbus_gpio = -1,
262         },
263         [2] = {
264                         .instance = 2,
265                         .vbus_gpio = -1,
266         },
267 };
268
269
270 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
271         [0] = {
272                         .phy_config = &utmi_phy_config[0],
273                         .operating_mode = TEGRA_USB_HOST,
274                         .power_down_on_bus_suspend = 1,
275         },
276         [1] = {
277                         .phy_config = &utmi_phy_config[1],
278                         .operating_mode = TEGRA_USB_HOST,
279                         .power_down_on_bus_suspend = 1,
280         },
281         [2] = {
282                         .phy_config = &utmi_phy_config[2],
283                         .operating_mode = TEGRA_USB_HOST,
284                         .power_down_on_bus_suspend = 1,
285         },
286 };
287
288 static struct platform_device *tegra_usb_otg_host_register(void)
289 {
290         struct platform_device *pdev;
291         void *platform_data;
292         int val;
293
294         pdev = platform_device_alloc(tegra_ehci1_device.name,
295                 tegra_ehci1_device.id);
296         if (!pdev)
297                 return NULL;
298
299         val = platform_device_add_resources(pdev, tegra_ehci1_device.resource,
300                 tegra_ehci1_device.num_resources);
301         if (val)
302                 goto error;
303
304         pdev->dev.dma_mask =  tegra_ehci1_device.dev.dma_mask;
305         pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask;
306
307         platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data),
308                 GFP_KERNEL);
309         if (!platform_data)
310                 goto error;
311
312         memcpy(platform_data, &tegra_ehci_pdata[0],
313                                 sizeof(struct tegra_ehci_platform_data));
314         pdev->dev.platform_data = platform_data;
315
316         val = platform_device_add(pdev);
317         if (val)
318                 goto error_add;
319
320         return pdev;
321
322 error_add:
323         kfree(platform_data);
324 error:
325         pr_err("%s: failed to add the host contoller device\n", __func__);
326         platform_device_put(pdev);
327         return NULL;
328 }
329
330 static void tegra_usb_otg_host_unregister(struct platform_device *pdev)
331 {
332         platform_device_unregister(pdev);
333 }
334
335 static struct tegra_otg_platform_data tegra_otg_pdata = {
336         .host_register = &tegra_usb_otg_host_register,
337         .host_unregister = &tegra_usb_otg_host_unregister,
338 };
339
340 static void enterprise_usb_init(void)
341 {
342         tegra_usb_phy_init(tegra_usb_phy_pdata, ARRAY_SIZE(tegra_usb_phy_pdata));
343
344         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
345         platform_device_register(&tegra_otg_device);
346
347         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
348         platform_device_register(&tegra_ehci3_device);
349
350 }
351
352 static void enterprise_gps_init(void)
353 {
354         tegra_gpio_enable(TEGRA_GPIO_PE4);
355         tegra_gpio_enable(TEGRA_GPIO_PE5);
356 }
357
358 static void __init tegra_enterprise_init(void)
359 {
360         tegra_clk_init_from_table(enterprise_clk_init_table);
361         enterprise_pinmux_init();
362         enterprise_i2c_init();
363         platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices));
364         enterprise_regulator_init();
365         enterprise_sdhci_init();
366         enterprise_usb_init();
367         /* enterprise_kbc_init(); */
368         enterprise_gps_init();
369         enterprise_baseband_init();
370         enterprise_panel_init();
371         enterprise_bt_rfkill();
372         enterprise_emc_init();
373         enterprise_sensors_init();
374         enterprise_suspend_init();
375 }
376
377 static void __init tegra_enterprise_reserve(void)
378 {
379 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
380         tegra_reserve(0, SZ_4M, SZ_8M);
381 #else
382         tegra_reserve(SZ_128M, SZ_4M, SZ_8M);
383 #endif
384 }
385
386 MACHINE_START(TEGRA_ENTERPRISE, "tegra_enterprise")
387         .boot_params    = 0x80000100,
388         .map_io         = tegra_map_common_io,
389         .reserve        = tegra_enterprise_reserve,
390         .init_early     = tegra_init_early,
391         .init_irq       = tegra_init_irq,
392         .timer          = &tegra_timer,
393         .init_machine   = tegra_enterprise_init,
394 MACHINE_END