ARM: tegra3: remove <board>-throttle_list_init functions
[linux-2.6.git] / arch / arm / mach-tegra / board-kai.c
1 /*
2  * arch/arm/mach-tegra/board-kai.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/spi/spi.h>
35 #include <linux/spi/rm31080a_ts.h>
36 #include <linux/tegra_uart.h>
37 #include <linux/memblock.h>
38 #include <linux/spi-tegra.h>
39 #include <linux/nfc/pn544.h>
40 #include <linux/skbuff.h>
41 #include <linux/ti_wilink_st.h>
42 #include <linux/regulator/consumer.h>
43 #include <linux/smb349-charger.h>
44 #include <linux/max17048_battery.h>
45 #include <linux/leds.h>
46 #include <linux/i2c/at24.h>
47 #include <linux/of_platform.h>
48
49 #include <asm/hardware/gic.h>
50
51 #include <mach/clk.h>
52 #include <mach/iomap.h>
53 #include <mach/irqs.h>
54 #include <mach/pinmux.h>
55 #include <mach/pinmux-tegra30.h>
56 #include <mach/iomap.h>
57 #include <mach/io.h>
58 #include <mach/io_dpd.h>
59 #include <mach/i2s.h>
60 #include <mach/tegra_asoc_pdata.h>
61 #include <asm/mach-types.h>
62 #include <asm/mach/arch.h>
63 #include <mach/usb_phy.h>
64 #include <mach/gpio-tegra.h>
65 #include <mach/tegra_fiq_debugger.h>
66
67 #include "board.h"
68 #include "board-common.h"
69 #include "clock.h"
70 #include "board-kai.h"
71 #include "board-touch-raydium.h"
72 #include "devices.h"
73 #include "gpio-names.h"
74 #include "fuse.h"
75 #include "pm.h"
76 #include "wdt-recovery.h"
77 #include "common.h"
78
79 /* wl128x BT, FM, GPS connectivity chip */
80 struct ti_st_plat_data kai_wilink_pdata = {
81         .nshutdown_gpio = TEGRA_GPIO_PU0,
82         .dev_name = BLUETOOTH_UART_DEV_NAME,
83         .flow_cntrl = 1,
84         .baud_rate = 3000000,
85 };
86
87 static struct platform_device wl128x_device = {
88         .name           = "kim",
89         .id             = -1,
90         .dev.platform_data = &kai_wilink_pdata,
91 };
92
93 static struct platform_device btwilink_device = {
94         .name = "btwilink",
95         .id = -1,
96 };
97
98 static noinline void __init kai_bt_st(void)
99 {
100         pr_info("kai_bt_st");
101
102         platform_device_register(&wl128x_device);
103         platform_device_register(&btwilink_device);
104 }
105
106 static struct resource kai_bluesleep_resources[] = {
107         [0] = {
108                 .name = "gpio_host_wake",
109                         .start  = TEGRA_GPIO_PU6,
110                         .end    = TEGRA_GPIO_PU6,
111                         .flags  = IORESOURCE_IO,
112         },
113         [1] = {
114                 .name = "host_wake",
115                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
116         },
117 };
118
119 static struct platform_device kai_bluesleep_device = {
120         .name           = "bluesleep",
121         .id             = 0,
122         .num_resources  = ARRAY_SIZE(kai_bluesleep_resources),
123         .resource       = kai_bluesleep_resources,
124 };
125
126 static noinline void __init kai_tegra_setup_tibluesleep(void)
127 {
128         kai_bluesleep_device.resource[1].start =
129                 kai_bluesleep_device.resource[1].end =
130                         gpio_to_irq(TEGRA_GPIO_PU6);
131         platform_device_register(&kai_bluesleep_device);
132 }
133
134 static __initdata struct tegra_clk_init_table kai_clk_init_table[] = {
135         /* name         parent          rate            enabled */
136         { "pll_m",      NULL,           0,              false},
137         { "hda",        "pll_p",        108000000,      false},
138         { "hda2codec_2x", "pll_p",      48000000,       false},
139         { "pwm",        "pll_p",        3187500,        false},
140         { "blink",      "clk_32k",      32768,          true},
141         { "i2s1",       "pll_a_out0",   0,              false},
142         { "i2s3",       "pll_a_out0",   0,              false},
143         { "i2s4",       "pll_a_out0",   0,              false},
144         { "spdif_out",  "pll_a_out0",   0,              false},
145         { "d_audio",    "clk_m",        12000000,       false},
146         { "dam0",       "clk_m",        12000000,       false},
147         { "dam1",       "clk_m",        12000000,       false},
148         { "dam2",       "clk_m",        12000000,       false},
149         { "audio1",     "i2s1_sync",    0,              false},
150         { "audio3",     "i2s3_sync",    0,              false},
151         { "vi_sensor",  "pll_p",        150000000,      false},
152         { "i2c1",       "pll_p",        3200000,        false},
153         { "i2c2",       "pll_p",        3200000,        false},
154         { "i2c3",       "pll_p",        3200000,        false},
155         { "i2c4",       "pll_p",        3200000,        false},
156         { "i2c5",       "pll_p",        3200000,        false},
157         { NULL,         NULL,           0,              0},
158 };
159
160 static struct pn544_i2c_platform_data nfc_pdata = {
161         .irq_gpio = TEGRA_GPIO_PX0,
162         .ven_gpio = TEGRA_GPIO_PS7,
163         .firm_gpio = TEGRA_GPIO_PR3,
164 };
165
166 static struct i2c_board_info __initdata kai_nfc_board_info[] = {
167         {
168                 I2C_BOARD_INFO("pn544", 0x28),
169                 .platform_data = &nfc_pdata,
170         },
171 };
172
173 static struct tegra_i2c_platform_data kai_i2c1_platform_data = {
174         .adapter_nr     = 0,
175         .bus_count      = 1,
176         .bus_clk_rate   = { 100000, 0 },
177         .scl_gpio               = {TEGRA_GPIO_PC4, 0},
178         .sda_gpio               = {TEGRA_GPIO_PC5, 0},
179         .arb_recovery = arb_lost_recovery,
180 };
181
182 static struct tegra_i2c_platform_data kai_i2c2_platform_data = {
183         .adapter_nr     = 1,
184         .bus_count      = 1,
185         .bus_clk_rate   = { 100000, 0 },
186         .is_clkon_always = true,
187         .scl_gpio               = {TEGRA_GPIO_PT5, 0},
188         .sda_gpio               = {TEGRA_GPIO_PT6, 0},
189         .arb_recovery = arb_lost_recovery,
190 };
191
192 static struct tegra_i2c_platform_data kai_i2c3_platform_data = {
193         .adapter_nr     = 2,
194         .bus_count      = 1,
195         .bus_clk_rate   = { 100000, 0 },
196         .scl_gpio               = {TEGRA_GPIO_PBB1, 0},
197         .sda_gpio               = {TEGRA_GPIO_PBB2, 0},
198         .arb_recovery = arb_lost_recovery,
199 };
200
201 static struct tegra_i2c_platform_data kai_i2c4_platform_data = {
202         .adapter_nr     = 3,
203         .bus_count      = 1,
204         .bus_clk_rate   = { 10000, 0 },
205         .scl_gpio               = {TEGRA_GPIO_PV4, 0},
206         .sda_gpio               = {TEGRA_GPIO_PV5, 0},
207         .arb_recovery = arb_lost_recovery,
208 };
209
210 static struct tegra_i2c_platform_data kai_i2c5_platform_data = {
211         .adapter_nr     = 4,
212         .bus_count      = 1,
213         .bus_clk_rate   = { 400000, 0 },
214         .scl_gpio               = {TEGRA_GPIO_PZ6, 0},
215         .sda_gpio               = {TEGRA_GPIO_PZ7, 0},
216         .arb_recovery = arb_lost_recovery,
217 };
218
219 struct max17048_battery_model max17048_mdata = {
220         .rcomp          = 170,
221         .soccheck_A     = 252,
222         .soccheck_B     = 254,
223         .bits           = 19,
224         .alert_threshold = 0x00,
225         .one_percent_alerts = 0x40,
226         .alert_on_reset = 0x40,
227         .rcomp_seg      = 0x0800,
228         .hibernate      = 0x3080,
229         .vreset         = 0x9696,
230         .valert         = 0xD4AA,
231         .ocvtest        = 55600,
232 };
233
234
235 static struct at24_platform_data eeprom_info = {
236         .byte_len       = (256*1024)/8,
237         .page_size      = 64,
238         .flags          = AT24_FLAG_ADDR16,
239         .setup          = get_mac_addr,
240 };
241
242 static struct i2c_board_info kai_i2c4_max17048_board_info[] = {
243         {
244                 I2C_BOARD_INFO("max17048", 0x36),
245                 .platform_data = &max17048_mdata,
246         },
247 };
248
249 static struct i2c_board_info kai_eeprom_mac_add = {
250         I2C_BOARD_INFO("at24", 0x56),
251         .platform_data = &eeprom_info,
252 };
253
254 static struct regulator_consumer_supply smb349_vbus_supply[] = {
255         REGULATOR_SUPPLY("usb_bat_chg", "tegra-udc.0"),
256 };
257
258 static struct regulator_consumer_supply smb349_otg_vbus_supply[] = {
259         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.0"),
260 };
261
262 static struct smb349_charger_platform_data smb349_charger_pdata = {
263         .max_charge_current_mA = 1000,
264         .charging_term_current_mA = 100,
265         .consumer_supplies = smb349_vbus_supply,
266         .num_consumer_supplies = ARRAY_SIZE(smb349_vbus_supply),
267         .otg_consumer_supplies = smb349_otg_vbus_supply,
268         .num_otg_consumer_supplies = ARRAY_SIZE(smb349_otg_vbus_supply),
269 };
270
271 static struct i2c_board_info kai_i2c4_smb349_board_info[] = {
272         {
273                 I2C_BOARD_INFO("smb349", 0x1B),
274                 .platform_data = &smb349_charger_pdata,
275         },
276 };
277
278 static struct i2c_board_info __initdata rt5640_board_info = {
279         I2C_BOARD_INFO("rt5640", 0x1c),
280 };
281
282 static struct i2c_board_info __initdata rt5639_board_info = {
283         I2C_BOARD_INFO("rt5639", 0x1c),
284 };
285
286 static void kai_i2c_init(void)
287 {
288         struct board_info board_info;
289
290         tegra_get_board_info(&board_info);
291
292         tegra_i2c_device1.dev.platform_data = &kai_i2c1_platform_data;
293         tegra_i2c_device2.dev.platform_data = &kai_i2c2_platform_data;
294         tegra_i2c_device3.dev.platform_data = &kai_i2c3_platform_data;
295         tegra_i2c_device4.dev.platform_data = &kai_i2c4_platform_data;
296         tegra_i2c_device5.dev.platform_data = &kai_i2c5_platform_data;
297
298         platform_device_register(&tegra_i2c_device5);
299         platform_device_register(&tegra_i2c_device4);
300         platform_device_register(&tegra_i2c_device3);
301         platform_device_register(&tegra_i2c_device2);
302         platform_device_register(&tegra_i2c_device1);
303
304         i2c_register_board_info(4, kai_i2c4_smb349_board_info,
305                 ARRAY_SIZE(kai_i2c4_smb349_board_info));
306
307         rt5639_board_info.irq = rt5640_board_info.irq =
308                 gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
309         if (board_info.fab == BOARD_FAB_A00)
310                 i2c_register_board_info(4, &rt5640_board_info, 1);
311         else
312                 i2c_register_board_info(4, &rt5639_board_info, 1);
313
314         i2c_register_board_info(4, &kai_eeprom_mac_add, 1);
315
316         i2c_register_board_info(4, kai_i2c4_max17048_board_info,
317                 ARRAY_SIZE(kai_i2c4_max17048_board_info));
318
319         kai_nfc_board_info[0].irq = gpio_to_irq(TEGRA_GPIO_PX0);
320         i2c_register_board_info(0, kai_nfc_board_info, 1);
321 }
322
323 static struct platform_device *kai_uart_devices[] __initdata = {
324         &tegra_uarta_device,
325         &tegra_uartb_device,
326         &tegra_uartc_device,
327         &tegra_uartd_device,
328         &tegra_uarte_device,
329 };
330 static struct uart_clk_parent uart_parent_clk[] = {
331         [0] = {.name = "clk_m"},
332         [1] = {.name = "pll_p"},
333 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
334         [2] = {.name = "pll_m"},
335 #endif
336 };
337
338 static struct tegra_uart_platform_data kai_uart_pdata;
339 static struct tegra_uart_platform_data kai_loopback_uart_pdata;
340
341 static void __init uart_debug_init(void)
342 {
343         int debug_port_id;
344
345         debug_port_id = uart_console_debug_init(3);
346         if (debug_port_id < 0)
347                 return;
348         kai_uart_devices[debug_port_id] = uart_console_debug_device;
349
350         return;
351 }
352
353 static void __init kai_uart_init(void)
354 {
355         struct clk *c;
356         int i;
357
358         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
359                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
360                 if (IS_ERR_OR_NULL(c)) {
361                         pr_err("Not able to get the clock for %s\n",
362                                                 uart_parent_clk[i].name);
363                         continue;
364                 }
365                 uart_parent_clk[i].parent_clk = c;
366                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
367         }
368         kai_uart_pdata.parent_clk_list = uart_parent_clk;
369         kai_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
370         kai_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
371         kai_loopback_uart_pdata.parent_clk_count =
372                                                 ARRAY_SIZE(uart_parent_clk);
373         kai_loopback_uart_pdata.is_loopback = true;
374         tegra_uarta_device.dev.platform_data = &kai_uart_pdata;
375         tegra_uartb_device.dev.platform_data = &kai_uart_pdata;
376         tegra_uartc_device.dev.platform_data = &kai_uart_pdata;
377         tegra_uartd_device.dev.platform_data = &kai_uart_pdata;
378         /* UARTE is used for loopback test purpose */
379         tegra_uarte_device.dev.platform_data = &kai_loopback_uart_pdata;
380
381         /* Register low speed only if it is selected */
382         if (!is_tegra_debug_uartport_hs())
383                 uart_debug_init();
384
385         platform_add_devices(kai_uart_devices,
386                                 ARRAY_SIZE(kai_uart_devices));
387 }
388
389 static struct platform_device tegra_camera = {
390         .name = "tegra_camera",
391         .id = -1,
392 };
393
394 static struct platform_device *kai_spi_devices[] __initdata = {
395         &tegra_spi_device1,
396 };
397
398 static struct spi_clk_parent spi_parent_clk[] = {
399         [0] = {.name = "pll_p"},
400 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
401         [1] = {.name = "pll_m"},
402         [2] = {.name = "clk_m"},
403 #else
404         [1] = {.name = "clk_m"},
405 #endif
406 };
407
408 static struct tegra_spi_platform_data kai_spi1_pdata = {
409                 .is_dma_based           = true,
410                 .max_dma_buffer         = (128),
411                 .is_clkon_always        = false,
412                 .max_rate               = 100000000,
413 };
414
415 static void __init kai_spi_init(void)
416 {
417         int i;
418         struct clk *c;
419
420         for (i = 0; i < ARRAY_SIZE(spi_parent_clk); ++i) {
421                 c = tegra_get_clock_by_name(spi_parent_clk[i].name);
422                 if (IS_ERR_OR_NULL(c)) {
423                         pr_err("Not able to get the clock for %s\n",
424                                                 spi_parent_clk[i].name);
425                         continue;
426                 }
427                 spi_parent_clk[i].parent_clk = c;
428                 spi_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
429         }
430
431         kai_spi1_pdata.parent_clk_list = spi_parent_clk;
432         kai_spi1_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk);
433         tegra_spi_device1.dev.platform_data = &kai_spi1_pdata;
434         platform_add_devices(kai_spi_devices,
435                                 ARRAY_SIZE(kai_spi_devices));
436
437 }
438
439 static struct resource tegra_rtc_resources[] = {
440         [0] = {
441                 .start = TEGRA_RTC_BASE,
442                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
443                 .flags = IORESOURCE_MEM,
444         },
445         [1] = {
446                 .start = INT_RTC,
447                 .end = INT_RTC,
448                 .flags = IORESOURCE_IRQ,
449         },
450 };
451
452 static struct platform_device tegra_rtc_device = {
453         .name = "tegra_rtc",
454         .id   = -1,
455         .resource = tegra_rtc_resources,
456         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
457 };
458
459 static struct tegra_asoc_platform_data kai_audio_pdata = {
460         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
461         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
462         .gpio_hp_mute           = -1,
463         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
464         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
465         .gpio_ldo1_en           = TEGRA_GPIO_PX2,
466         .i2s_param[HIFI_CODEC]  = {
467                 .audio_port_id  = 0,
468                 .is_i2s_master  = 1,
469                 .i2s_mode       = TEGRA_DAIFMT_I2S,
470         },
471         .i2s_param[BASEBAND]    = {
472                 .audio_port_id  = -1,
473         },
474         .i2s_param[BT_SCO]      = {
475                 .audio_port_id  = 3,
476                 .is_i2s_master  = 1,
477                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
478         },
479 };
480
481 static struct platform_device kai_audio_device = {
482         .name   = "tegra-snd-rt5640",
483         .id     = 0,
484         .dev    = {
485                 .platform_data = &kai_audio_pdata,
486         },
487 };
488
489 static struct gpio_led kai_led_info[] = {
490         {
491                 .name                   = "statled",
492                 .default_trigger        = "default-on",
493                 .gpio                   = TEGRA_GPIO_STAT_LED,
494                 .active_low             = 1,
495                 .retain_state_suspended = 0,
496                 .default_state          = LEDS_GPIO_DEFSTATE_OFF,
497         },
498 };
499
500 static struct gpio_led_platform_data kai_leds_pdata = {
501         .leds           = kai_led_info,
502         .num_leds       = ARRAY_SIZE(kai_led_info),
503 };
504
505 static struct platform_device kai_leds_gpio_device = {
506         .name   = "leds-gpio",
507         .id     = -1,
508         .dev    = {
509                 .platform_data = &kai_leds_pdata,
510         },
511 };
512
513 static struct platform_device *kai_devices[] __initdata = {
514         &tegra_pmu_device,
515         &tegra_rtc_device,
516         &tegra_udc_device,
517         &tegra_wdt0_device,
518         &tegra_wdt1_device,
519         &tegra_wdt2_device,
520 #if defined(CONFIG_TEGRA_AVP)
521         &tegra_avp_device,
522 #endif
523         &tegra_camera,
524 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
525         &tegra_se_device,
526 #endif
527         &tegra_ahub_device,
528         &tegra_dam_device0,
529         &tegra_dam_device1,
530         &tegra_dam_device2,
531         &tegra_i2s_device1,
532         &tegra_i2s_device3,
533         &tegra_i2s_device4,
534         &tegra_spdif_device,
535         &spdif_dit_device,
536         &bluetooth_dit_device,
537         &tegra_pcm_device,
538         &kai_audio_device,
539         &kai_leds_gpio_device,
540         &tegra_hda_device,
541 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
542         &tegra_aes_device,
543 #endif
544 };
545
546 static __initdata struct tegra_clk_init_table spi_clk_init_table[] = {
547         /* name         parent          rate            enabled */
548         { "sbc1",       "pll_p",        52000000,       true},
549         { NULL,         NULL,           0,              0},
550 };
551
552 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
553         /* name         parent          rate            enabled */
554         { "extern3",    "pll_p",        41000000,       true},
555         { "clk_out_3",  "extern3",      40800000,       true},
556         { NULL,         NULL,           0,              0},
557 };
558
559
560 struct rm_spi_ts_platform_data rm31080ts_kai_data = {
561         .gpio_reset = 0,
562         .config = 0,
563 };
564
565 struct spi_board_info rm31080a_kai_spi_board[1] = {
566         {
567          .modalias = "rm_ts_spidev",
568          .bus_num = 0,
569          .chip_select = 0,
570          .max_speed_hz = 13 * 1000 * 1000,
571          .mode = SPI_MODE_0,
572          .platform_data = &rm31080ts_kai_data,
573          },
574 };
575
576 static int __init kai_touch_init(void)
577 {
578         int touch_id;
579
580         touch_id = gpio_request(KAI_TS_ID1, "touch-id1");
581         if (touch_id < 0) {
582                 pr_err("%s: gpio_request failed %d\n",
583                         __func__, touch_id);
584                 return touch_id;
585         }
586         touch_id = gpio_direction_input(KAI_TS_ID1);
587         if (touch_id < 0) {
588                 pr_err("%s: gpio_direction_input failed %d\n",
589                         __func__, touch_id);
590                 gpio_free(KAI_TS_ID1);
591         }
592
593         touch_id = gpio_request(KAI_TS_ID2, "touch-id2");
594         if (touch_id < 0) {
595                 pr_err("%s: gpio_request failed %d\n",
596                         __func__, touch_id);
597                 return touch_id;
598         }
599         touch_id = gpio_direction_input(KAI_TS_ID2);
600         if (touch_id < 0) {
601                 pr_err("%s: gpio_direction_input failed %d\n",
602                         __func__, touch_id);
603                 gpio_free(KAI_TS_ID2);
604         }
605
606         touch_id = gpio_get_value(KAI_TS_ID1) << 1;
607         touch_id |= gpio_get_value(KAI_TS_ID2);
608
609         pr_info("touch-id %d\n", touch_id);
610
611         /* Disable TS_ID GPIO to save power */
612         gpio_direction_output(KAI_TS_ID1, 0);
613         tegra_pinmux_set_pullupdown(KAI_TS_ID1_PG, TEGRA_PUPD_NORMAL);
614         tegra_pinmux_set_tristate(KAI_TS_ID1_PG, TEGRA_TRI_TRISTATE);
615         gpio_direction_output(KAI_TS_ID2, 0);
616         tegra_pinmux_set_pullupdown(KAI_TS_ID2_PG, TEGRA_PUPD_NORMAL);
617         tegra_pinmux_set_tristate(KAI_TS_ID2_PG, TEGRA_TRI_TRISTATE);
618
619         switch (touch_id) {
620         case 0:
621                 pr_info("Raydium PCB based touch init\n");
622                 tegra_clk_init_from_table(spi_clk_init_table);
623                 rm31080ts_kai_data.platform_id = RM_PLATFORM_K007;
624                 rm31080a_kai_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
625                 touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
626                                         TOUCH_GPIO_RST_RAYDIUM_SPI,
627                                         &rm31080ts_kai_data,
628                                         &rm31080a_kai_spi_board[0],
629                                         ARRAY_SIZE(rm31080a_kai_spi_board));
630                 break;
631         case 1:
632                 pr_info("Raydium On-Board touch init\n");
633                 tegra_clk_init_from_table(spi_clk_init_table);
634                 tegra_clk_init_from_table(touch_clk_init_table);
635                 clk_enable(tegra_get_clock_by_name("clk_out_3"));
636                 rm31080ts_kai_data.platform_id = RM_PLATFORM_K107;
637                 rm31080a_kai_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
638                 touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
639                                         TOUCH_GPIO_RST_RAYDIUM_SPI,
640                                         &rm31080ts_kai_data,
641                                         &rm31080a_kai_spi_board[0],
642                                         ARRAY_SIZE(rm31080a_kai_spi_board));
643                 break;
644         case 3:
645                 pr_info("Synaptics PCB based touch init\n");
646                 touch_init_synaptics_kai();
647                 break;
648         default:
649                 pr_err("touch_id error, no touch %d\n", touch_id);
650         }
651         return 0;
652 }
653
654 static struct tegra_usb_platform_data tegra_udc_pdata = {
655         .port_otg = true,
656         .has_hostpc = true,
657         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
658         .op_mode = TEGRA_USB_OPMODE_DEVICE,
659         .u_data.dev = {
660                 .vbus_pmu_irq = 0,
661                 .vbus_gpio = -1,
662                 .charging_supported = false,
663                 .remote_wakeup_supported = false,
664         },
665         .u_cfg.utmi = {
666                 .hssync_start_delay = 0,
667                 .elastic_limit = 16,
668                 .idle_wait_delay = 17,
669                 .term_range_adj = 6,
670                 .xcvr_setup = 8,
671                 .xcvr_lsfslew = 2,
672                 .xcvr_lsrslew = 2,
673                 .xcvr_setup_offset = 0,
674                 .xcvr_use_fuses = 1,
675         },
676 };
677
678 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
679         .port_otg = true,
680         .has_hostpc = true,
681         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
682         .op_mode = TEGRA_USB_OPMODE_HOST,
683         .u_data.host = {
684                 .vbus_gpio = -1,
685                 .hot_plug = true,
686                 .remote_wakeup_supported = true,
687                 .power_off_on_suspend = true,
688         },
689         .u_cfg.utmi = {
690                 .hssync_start_delay = 0,
691                 .elastic_limit = 16,
692                 .idle_wait_delay = 17,
693                 .term_range_adj = 6,
694                 .xcvr_setup = 15,
695                 .xcvr_lsfslew = 2,
696                 .xcvr_lsrslew = 2,
697                 .xcvr_setup_offset = 0,
698                 .xcvr_use_fuses = 1,
699         },
700 };
701
702
703 static struct tegra_usb_platform_data tegra_ehci2_utmi_pdata = {
704         .port_otg = false,
705         .has_hostpc = true,
706         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
707         .op_mode        = TEGRA_USB_OPMODE_HOST,
708         .u_data.host = {
709                 .vbus_gpio = -1,
710                 .hot_plug = false,
711                 .remote_wakeup_supported = true,
712                 .power_off_on_suspend = true,
713
714         },
715         .u_cfg.utmi = {
716                 .hssync_start_delay = 0,
717                 .elastic_limit = 16,
718                 .idle_wait_delay = 17,
719                 .term_range_adj = 6,
720                 .xcvr_setup = 8,
721                 .xcvr_lsfslew = 2,
722                 .xcvr_lsrslew = 2,
723                 .xcvr_setup_offset = 0,
724                 .xcvr_use_fuses = 1,
725         },
726 };
727
728 static struct tegra_usb_otg_data tegra_otg_pdata = {
729         .ehci_device = &tegra_ehci1_device,
730         .ehci_pdata = &tegra_ehci1_utmi_pdata,
731 };
732
733 #if CONFIG_USB_SUPPORT
734 static void kai_usb_init(void)
735 {
736         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
737         platform_device_register(&tegra_otg_device);
738
739         /* Setup the udc platform data */
740         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
741
742         tegra_ehci2_device.dev.platform_data = &tegra_ehci2_utmi_pdata;
743         platform_device_register(&tegra_ehci2_device);
744 }
745
746 static void kai_modem_init(void)
747 {
748         int ret;
749
750         ret = gpio_request(TEGRA_GPIO_W_DISABLE, "w_disable_gpio");
751         if (ret < 0)
752                 pr_err("%s: gpio_request failed for gpio %d\n",
753                         __func__, TEGRA_GPIO_W_DISABLE);
754         else {
755                 ret = gpio_direction_output(TEGRA_GPIO_W_DISABLE, 1);
756                 if (ret < 0) {
757                         pr_err("%s: gpio_direction_output failed %d\n",
758                                 __func__, ret);
759                         gpio_free(TEGRA_GPIO_W_DISABLE);
760                 }
761         }
762
763         ret = gpio_request(TEGRA_GPIO_MODEM_RSVD1, "Port_V_PIN_0");
764         if (ret < 0)
765                 pr_err("%s: gpio_request failed for gpio %d\n",
766                         __func__, TEGRA_GPIO_MODEM_RSVD1);
767         else {
768                 ret = gpio_direction_input(TEGRA_GPIO_MODEM_RSVD1);
769                 if (ret < 0) {
770                         pr_err("%s: gpio_direction_output failed %d\n",
771                                 __func__, ret);
772                         gpio_free(TEGRA_GPIO_MODEM_RSVD1);
773                 }
774         }
775
776
777         ret = gpio_request(TEGRA_GPIO_MODEM_RSVD2, "Port_H_PIN_7");
778         if (ret < 0)
779                 pr_err("%s: gpio_request failed for gpio %d\n",
780                         __func__, TEGRA_GPIO_MODEM_RSVD2);
781         else {
782                 ret = gpio_direction_output(TEGRA_GPIO_MODEM_RSVD2, 1);
783                 if (ret < 0) {
784                         pr_err("%s: gpio_direction_output failed %d\n",
785                                 __func__, ret);
786                         gpio_free(TEGRA_GPIO_MODEM_RSVD2);
787                 }
788         }
789
790 }
791
792 #else
793 static void kai_usb_init(void) { }
794 static void kai_modem_init(void) { }
795 #endif
796
797 static void kai_audio_init(void)
798 {
799         struct board_info board_info;
800
801         tegra_get_board_info(&board_info);
802
803         if (board_info.fab == BOARD_FAB_A01) {
804                 kai_audio_pdata.codec_name = "rt5639.4-001c";
805                 kai_audio_pdata.codec_dai_name = "rt5639-aif1";
806         } else if (board_info.fab == BOARD_FAB_A00) {
807                 kai_audio_pdata.codec_name = "rt5640.4-001c";
808                 kai_audio_pdata.codec_dai_name = "rt5640-aif1";
809         }
810 }
811
812 static void __init tegra_kai_init(void)
813 {
814         tegra_clk_init_from_table(kai_clk_init_table);
815         tegra_enable_pinmux();
816         tegra_smmu_init();
817         tegra_soc_device_init("kai");
818         kai_pinmux_init();
819         kai_i2c_init();
820         kai_spi_init();
821         kai_usb_init();
822 #ifdef CONFIG_TEGRA_EDP_LIMITS
823         kai_edp_init();
824 #endif
825         kai_uart_init();
826         kai_audio_init();
827         platform_add_devices(kai_devices, ARRAY_SIZE(kai_devices));
828         tegra_ram_console_debug_init();
829         tegra_io_dpd_init();
830         kai_sdhci_init();
831         kai_regulator_init();
832         kai_suspend_init();
833         kai_touch_init();
834         kai_keys_init();
835         kai_panel_init();
836         kai_tegra_setup_tibluesleep();
837         kai_bt_st();
838         kai_sensors_init();
839         kai_pins_state_init();
840         kai_emc_init();
841         tegra_release_bootloader_fb();
842         kai_modem_init();
843 #ifdef CONFIG_TEGRA_WDT_RECOVERY
844         tegra_wdt_recovery_init();
845 #endif
846         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
847 }
848
849 static void __init kai_ramconsole_reserve(unsigned long size)
850 {
851         tegra_ram_console_debug_reserve(SZ_1M);
852 }
853
854 static void __init tegra_kai_dt_init(void)
855 {
856         tegra_kai_init();
857
858         of_platform_populate(NULL,
859                 of_default_bus_match_table, NULL, NULL);
860 }
861
862 static void __init tegra_kai_reserve(void)
863 {
864 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
865         /* support 1920X1200 with 24bpp */
866         tegra_reserve(0, SZ_8M + SZ_1M, SZ_8M + SZ_1M);
867 #else
868         tegra_reserve(SZ_128M, SZ_8M, SZ_8M);
869 #endif
870         kai_ramconsole_reserve(SZ_1M);
871 }
872
873 static const char * const kai_dt_board_compat[] = {
874         "nvidia,kai",
875         NULL
876 };
877
878 MACHINE_START(KAI, "kai")
879         .atag_offset    = 0x100,
880         .soc            = &tegra_soc_desc,
881         .map_io         = tegra_map_common_io,
882         .reserve        = tegra_kai_reserve,
883         .init_early     = tegra30_init_early,
884         .init_irq       = tegra_init_irq,
885         .handle_irq     = gic_handle_irq,
886         .timer          = &tegra_timer,
887         .init_machine   = tegra_kai_dt_init,
888         .restart        = tegra_assert_system_reset,
889         .dt_compat      = kai_dt_board_compat,
890 MACHINE_END