ARM: tegra: roth: remove spi and touch driver
[linux-2.6.git] / arch / arm / mach-tegra / board-roth.c
1 /*
2  * arch/arm/mach-tegra/board-roth.c
3  *
4  * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
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 version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/ctype.h>
24 #include <linux/platform_device.h>
25 #include <linux/clk.h>
26 #include <linux/serial_8250.h>
27 #include <linux/i2c.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/delay.h>
30 #include <linux/i2c-tegra.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/platform_data/tegra_usb.h>
34 #include <linux/tegra_uart.h>
35 #include <linux/memblock.h>
36 #include <linux/rfkill-gpio.h>
37 #include <linux/skbuff.h>
38 #include <linux/ti_wilink_st.h>
39 #include <linux/regulator/consumer.h>
40 #include <linux/max17048_battery.h>
41 #include <linux/leds.h>
42 #include <linux/i2c/at24.h>
43 #include <linux/of_platform.h>
44
45 #include <asm/hardware/gic.h>
46
47 #include <mach/clk.h>
48 #include <mach/iomap.h>
49 #include <mach/irqs.h>
50 #include <mach/pinmux.h>
51 #include <mach/pinmux-tegra30.h>
52 #include <mach/iomap.h>
53 #include <mach/io.h>
54 #include <mach/io_dpd.h>
55 #include <mach/i2s.h>
56 #include <mach/tegra_asoc_pdata.h>
57 #include <asm/mach-types.h>
58 #include <asm/mach/arch.h>
59 #include <mach/usb_phy.h>
60 #include <mach/gpio-tegra.h>
61 #include <mach/tegra_fiq_debugger.h>
62 #include <mach/edp.h>
63
64 #include "board.h"
65 #include "board-common.h"
66 #include "clock.h"
67 #include "board-roth.h"
68 #include "devices.h"
69 #include "gpio-names.h"
70 #include "fuse.h"
71 #include "pm.h"
72 #include "common.h"
73 #include "tegra-board-id.h"
74
75 static struct rfkill_gpio_platform_data roth_bt_rfkill_pdata = {
76                 .name           = "bt_rfkill",
77                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
78                 .type           = RFKILL_TYPE_BLUETOOTH,
79 };
80
81 static struct platform_device roth_bt_rfkill_device = {
82         .name = "rfkill_gpio",
83         .id             = -1,
84         .dev = {
85                 .platform_data = &roth_bt_rfkill_pdata,
86         },
87 };
88
89 static struct resource roth_bluesleep_resources[] = {
90         [0] = {
91                 .name = "gpio_host_wake",
92                         .start  = TEGRA_GPIO_PU6,
93                         .end    = TEGRA_GPIO_PU6,
94                         .flags  = IORESOURCE_IO,
95         },
96         [1] = {
97                 .name = "gpio_ext_wake",
98                         .start  = TEGRA_GPIO_PEE1,
99                         .end    = TEGRA_GPIO_PEE1,
100                         .flags  = IORESOURCE_IO,
101         },
102         [2] = {
103                 .name = "host_wake",
104                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
105         },
106 };
107
108 static struct platform_device roth_bluesleep_device = {
109         .name           = "bluesleep",
110         .id             = -1,
111         .num_resources  = ARRAY_SIZE(roth_bluesleep_resources),
112         .resource       = roth_bluesleep_resources,
113 };
114
115 static noinline void __init roth_setup_bt_rfkill(void)
116 {
117         if ((tegra_get_commchip_id() == COMMCHIP_BROADCOM_BCM43241) ||
118                 (tegra_get_commchip_id() == COMMCHIP_DEFAULT))
119                 roth_bt_rfkill_pdata.reset_gpio = TEGRA_GPIO_INVALID;
120         else
121                 roth_bt_rfkill_pdata.reset_gpio = TEGRA_GPIO_PQ6;
122         platform_device_register(&roth_bt_rfkill_device);
123 }
124
125 static noinline void __init roth_setup_bluesleep(void)
126 {
127         roth_bluesleep_resources[2].start =
128                 roth_bluesleep_resources[2].end =
129                         gpio_to_irq(TEGRA_GPIO_PU6);
130         platform_device_register(&roth_bluesleep_device);
131         return;
132 }
133 static __initdata struct tegra_clk_init_table roth_clk_init_table[] = {
134         /* name         parent          rate            enabled */
135         { "pll_m",      NULL,           0,              false},
136         { "hda",        "pll_p",        108000000,      false},
137         { "hda2codec_2x", "pll_p",      48000000,       false},
138         { "pwm",        "pll_p",        3187500,        false},
139         { "blink",      "clk_32k",      32768,          true},
140         { "i2s1",       "pll_a_out0",   0,              false},
141         { "i2s3",       "pll_a_out0",   0,              false},
142         { "i2s4",       "pll_a_out0",   0,              false},
143         { "spdif_out",  "pll_a_out0",   0,              false},
144         { "d_audio",    "clk_m",        12000000,       false},
145         { "dam0",       "clk_m",        12000000,       false},
146         { "dam1",       "clk_m",        12000000,       false},
147         { "dam2",       "clk_m",        12000000,       false},
148         { "audio1",     "i2s1_sync",    0,              false},
149         { "audio3",     "i2s3_sync",    0,              false},
150         /* Setting vi_sensor-clk to true for validation purpose, will imapact
151          * power, later set to be false.*/
152         { "vi_sensor",  "pll_p",        150000000,      false},
153         { "cilab",      "pll_p",        150000000,      false},
154         { "cilcd",      "pll_p",        150000000,      false},
155         { "cile",       "pll_p",        150000000,      false},
156         { "i2c1",       "pll_p",        3200000,        false},
157         { "i2c2",       "pll_p",        3200000,        false},
158         { "i2c3",       "pll_p",        3200000,        false},
159         { "i2c4",       "pll_p",        3200000,        false},
160         { "i2c5",       "pll_p",        3200000,        false},
161         { NULL,         NULL,           0,              0},
162 };
163
164 static struct tegra_i2c_platform_data roth_i2c1_platform_data = {
165         .adapter_nr     = 0,
166         .bus_count      = 1,
167         .bus_clk_rate   = { 100000, 0 },
168         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
169         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
170         .arb_recovery = arb_lost_recovery,
171 };
172
173 static struct tegra_i2c_platform_data roth_i2c2_platform_data = {
174         .adapter_nr     = 1,
175         .bus_count      = 1,
176         .bus_clk_rate   = { 100000, 0 },
177         .is_clkon_always = true,
178         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
179         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
180         .arb_recovery = arb_lost_recovery,
181 };
182
183 static struct tegra_i2c_platform_data roth_i2c3_platform_data = {
184         .adapter_nr     = 2,
185         .bus_count      = 1,
186         .bus_clk_rate   = { 100000, 0 },
187         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
188         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
189         .arb_recovery = arb_lost_recovery,
190 };
191
192 static struct tegra_i2c_platform_data roth_i2c4_platform_data = {
193         .adapter_nr     = 3,
194         .bus_count      = 1,
195         .bus_clk_rate   = { 10000, 0 },
196         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
197         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
198         .arb_recovery = arb_lost_recovery,
199 };
200
201 static struct tegra_i2c_platform_data roth_i2c5_platform_data = {
202         .adapter_nr     = 4,
203         .bus_count      = 1,
204         .bus_clk_rate   = { 400000, 0 },
205         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
206         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
207         .arb_recovery = arb_lost_recovery,
208 };
209
210 #if defined(CONFIG_ARCH_TEGRA_11x_SOC)
211 static struct i2c_board_info __initdata rt5640_board_info = {
212         I2C_BOARD_INFO("rt5640", 0x1c),
213 };
214 #endif
215
216 static void roth_i2c_init(void)
217 {
218         tegra11_i2c_device1.dev.platform_data = &roth_i2c1_platform_data;
219         tegra11_i2c_device2.dev.platform_data = &roth_i2c2_platform_data;
220         tegra11_i2c_device3.dev.platform_data = &roth_i2c3_platform_data;
221         tegra11_i2c_device4.dev.platform_data = &roth_i2c4_platform_data;
222         tegra11_i2c_device5.dev.platform_data = &roth_i2c5_platform_data;
223
224         platform_device_register(&tegra11_i2c_device5);
225         platform_device_register(&tegra11_i2c_device4);
226         platform_device_register(&tegra11_i2c_device3);
227         platform_device_register(&tegra11_i2c_device2);
228         platform_device_register(&tegra11_i2c_device1);
229
230         i2c_register_board_info(0, &rt5640_board_info, 1);
231 }
232
233 static struct platform_device *roth_uart_devices[] __initdata = {
234         &tegra_uarta_device,
235         &tegra_uartb_device,
236         &tegra_uartc_device,
237         &tegra_uartd_device,
238 };
239 static struct uart_clk_parent uart_parent_clk[] = {
240         [0] = {.name = "clk_m"},
241         [1] = {.name = "pll_p"},
242 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
243         [2] = {.name = "pll_m"},
244 #endif
245 };
246
247 static struct tegra_uart_platform_data roth_uart_pdata;
248 static struct tegra_uart_platform_data roth_loopback_uart_pdata;
249
250 static void __init uart_debug_init(void)
251 {
252         int debug_port_id;
253
254         debug_port_id = uart_console_debug_init(3);
255         if (debug_port_id < 0)
256                 return;
257
258         roth_uart_devices[debug_port_id] = uart_console_debug_device;
259 }
260
261 static void __init roth_uart_init(void)
262 {
263         struct clk *c;
264         int i;
265
266         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
267                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
268                 if (IS_ERR_OR_NULL(c)) {
269                         pr_err("Not able to get the clock for %s\n",
270                                                 uart_parent_clk[i].name);
271                         continue;
272                 }
273                 uart_parent_clk[i].parent_clk = c;
274                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
275         }
276         roth_uart_pdata.parent_clk_list = uart_parent_clk;
277         roth_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
278         roth_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
279         roth_loopback_uart_pdata.parent_clk_count =
280                                                 ARRAY_SIZE(uart_parent_clk);
281         roth_loopback_uart_pdata.is_loopback = true;
282         tegra_uarta_device.dev.platform_data = &roth_uart_pdata;
283         tegra_uartb_device.dev.platform_data = &roth_uart_pdata;
284         tegra_uartc_device.dev.platform_data = &roth_uart_pdata;
285         tegra_uartd_device.dev.platform_data = &roth_uart_pdata;
286
287         /* Register low speed only if it is selected */
288         if (!is_tegra_debug_uartport_hs())
289                 uart_debug_init();
290
291         platform_add_devices(roth_uart_devices,
292                                 ARRAY_SIZE(roth_uart_devices));
293 }
294
295 static struct resource tegra_rtc_resources[] = {
296         [0] = {
297                 .start = TEGRA_RTC_BASE,
298                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
299                 .flags = IORESOURCE_MEM,
300         },
301         [1] = {
302                 .start = INT_RTC,
303                 .end = INT_RTC,
304                 .flags = IORESOURCE_IRQ,
305         },
306 };
307
308 static struct platform_device tegra_rtc_device = {
309         .name = "tegra_rtc",
310         .id   = -1,
311         .resource = tegra_rtc_resources,
312         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
313 };
314
315 static struct tegra_asoc_platform_data roth_audio_pdata = {
316         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
317         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
318         .gpio_hp_mute           = -1,
319         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
320         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
321         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
322         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
323         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
324         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
325         .i2s_param[HIFI_CODEC]  = {
326                 .audio_port_id  = 1,
327                 .is_i2s_master  = 1,
328                 .i2s_mode       = TEGRA_DAIFMT_I2S,
329         },
330         .i2s_param[BT_SCO]      = {
331                 .audio_port_id  = 3,
332                 .is_i2s_master  = 1,
333                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
334         },
335 };
336
337 static struct platform_device roth_audio_device = {
338         .name   = "tegra-snd-rt5640",
339         .id     = 0,
340         .dev    = {
341                 .platform_data = &roth_audio_pdata,
342         },
343 };
344
345 static struct platform_device tegra_camera = {
346         .name = "tegra_camera",
347         .id = -1,
348 };
349
350 static struct platform_device *roth_devices[] __initdata = {
351         &tegra_pmu_device,
352         &tegra_rtc_device,
353         &tegra_udc_device,
354 #if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
355         &tegra_smmu_device,
356 #endif
357 #if defined(CONFIG_TEGRA_AVP)
358         &tegra_avp_device,
359 #endif
360         &tegra_camera,
361 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
362         &tegra11_se_device,
363 #endif
364         &tegra_ahub_device,
365         &tegra_dam_device0,
366         &tegra_dam_device1,
367         &tegra_dam_device2,
368         &tegra_i2s_device1,
369         &tegra_i2s_device3,
370         &tegra_i2s_device4,
371         &tegra_spdif_device,
372         &spdif_dit_device,
373         &bluetooth_dit_device,
374         &tegra_pcm_device,
375         &roth_audio_device,
376         &tegra_hda_device,
377 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
378         &tegra_aes_device,
379 #endif
380 };
381
382 #ifdef CONFIG_USB_SUPPORT
383 static struct tegra_usb_platform_data tegra_udc_pdata = {
384         .port_otg = true,
385         .has_hostpc = true,
386         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
387         .op_mode = TEGRA_USB_OPMODE_DEVICE,
388         .u_data.dev = {
389                 .vbus_pmu_irq = 0,
390                 .vbus_gpio = -1,
391                 .charging_supported = false,
392                 .remote_wakeup_supported = false,
393         },
394         .u_cfg.utmi = {
395                 .hssync_start_delay = 0,
396                 .elastic_limit = 16,
397                 .idle_wait_delay = 17,
398                 .term_range_adj = 6,
399                 .xcvr_setup = 8,
400                 .xcvr_lsfslew = 2,
401                 .xcvr_lsrslew = 2,
402                 .xcvr_setup_offset = 0,
403                 .xcvr_use_fuses = 1,
404         },
405 };
406
407 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
408         .port_otg = true,
409         .has_hostpc = true,
410         .unaligned_dma_buf_supported = false,
411         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
412         .op_mode = TEGRA_USB_OPMODE_HOST,
413         .u_data.host = {
414                 .vbus_gpio = -1,
415                 .hot_plug = true,
416                 .remote_wakeup_supported = true,
417                 .power_off_on_suspend = true,
418         },
419         .u_cfg.utmi = {
420                 .hssync_start_delay = 0,
421                 .elastic_limit = 16,
422                 .idle_wait_delay = 17,
423                 .term_range_adj = 6,
424                 .xcvr_setup = 15,
425                 .xcvr_lsfslew = 2,
426                 .xcvr_lsrslew = 2,
427                 .xcvr_setup_offset = 0,
428                 .xcvr_use_fuses = 1,
429         },
430 };
431
432 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
433         .port_otg = false,
434         .has_hostpc = true,
435         .unaligned_dma_buf_supported = false,
436         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
437         .op_mode = TEGRA_USB_OPMODE_HOST,
438         .u_data.host = {
439                 .vbus_gpio = -1,
440                 .hot_plug = true,
441                 .remote_wakeup_supported = true,
442                 .power_off_on_suspend = true,
443         },
444         .u_cfg.utmi = {
445         .hssync_start_delay = 0,
446                 .elastic_limit = 16,
447                 .idle_wait_delay = 17,
448                 .term_range_adj = 6,
449                 .xcvr_setup = 8,
450                 .xcvr_lsfslew = 2,
451                 .xcvr_lsrslew = 2,
452                 .xcvr_setup_offset = 0,
453                 .xcvr_use_fuses = 1,
454         },
455 };
456
457 static struct tegra_usb_otg_data tegra_otg_pdata = {
458         .ehci_device = &tegra_ehci1_device,
459         .ehci_pdata = &tegra_ehci1_utmi_pdata,
460 };
461
462 static void roth_usb_init(void)
463 {
464         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
465         platform_device_register(&tegra_otg_device);
466
467         /* Setup the udc platform data */
468         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
469
470         tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
471         platform_device_register(&tegra_ehci3_device);
472 }
473
474 #else
475 static void roth_usb_init(void) { }
476 #endif
477
478 static void roth_audio_init(void)
479 {
480         struct board_info board_info;
481
482         tegra_get_board_info(&board_info);
483
484         roth_audio_pdata.codec_name = "rt5640.0-001c";
485         roth_audio_pdata.codec_dai_name = "rt5640-aif1";
486 }
487
488
489 static void __init tegra_roth_init(void)
490 {
491
492         tegra_battery_edp_init(2500);
493         tegra_clk_init_from_table(roth_clk_init_table);
494         tegra_soc_device_init("roth");
495         tegra_enable_pinmux();
496         roth_pinmux_init();
497         roth_i2c_init();
498         roth_usb_init();
499         roth_uart_init();
500         roth_audio_init();
501         platform_add_devices(roth_devices, ARRAY_SIZE(roth_devices));
502         tegra_ram_console_debug_init();
503         tegra_io_dpd_init();
504         roth_regulator_init();
505         roth_sdhci_init();
506         roth_suspend_init();
507         roth_emc_init();
508         roth_edp_init();
509         roth_touch_init();
510         roth_panel_init();
511         roth_kbc_init();
512         roth_pmon_init();
513         roth_setup_bluesleep();
514         roth_setup_bt_rfkill();
515         tegra_release_bootloader_fb();
516 #ifdef CONFIG_TEGRA_WDT_RECOVERY
517         tegra_wdt_recovery_init();
518 #endif
519         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
520         roth_sensors_init();
521         roth_soctherm_init();
522 }
523
524 static void __init roth_ramconsole_reserve(unsigned long size)
525 {
526         tegra_ram_console_debug_reserve(SZ_1M);
527 }
528
529 static void __init tegra_roth_dt_init(void)
530 {
531         tegra_roth_init();
532
533         of_platform_populate(NULL,
534                 of_default_bus_match_table, NULL, NULL);
535 }
536
537 static void __init tegra_roth_reserve(void)
538 {
539 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
540         /* 1920*1200*4*2 = 18432000 bytes */
541         tegra_reserve(0, SZ_16M + SZ_2M, SZ_4M);
542 #else
543         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
544 #endif
545         roth_ramconsole_reserve(SZ_1M);
546 }
547
548 static const char * const roth_dt_board_compat[] = {
549         "nvidia,roth",
550         NULL
551 };
552
553 MACHINE_START(ROTH, "roth")
554         .atag_offset    = 0x100,
555         .soc            = &tegra_soc_desc,
556         .map_io         = tegra_map_common_io,
557         .reserve        = tegra_roth_reserve,
558         .init_early     = tegra11x_init_early,
559         .init_irq       = tegra_init_irq,
560         .handle_irq     = gic_handle_irq,
561         .timer          = &tegra_timer,
562         .init_machine   = tegra_roth_dt_init,
563         .restart        = tegra_assert_system_reset,
564         .dt_compat      = roth_dt_board_compat,
565 MACHINE_END