ARM: tegra: t114/t148: increase camera i2c speed
[linux-3.10.git] / arch / arm / mach-tegra / board-macallan.c
1 /*
2  * arch/arm/mach-tegra/board-macallan.c
3  *
4  * Copyright (c) 2013, 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/usb/tegra_usb_phy.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/rm31080a_ts.h>
37 #include <linux/tegra_uart.h>
38 #include <linux/memblock.h>
39 #include <linux/spi-tegra.h>
40 #include <linux/nfc/pn544.h>
41 #include <linux/rfkill-gpio.h>
42 #include <linux/skbuff.h>
43 #include <linux/ti_wilink_st.h>
44 #include <linux/regulator/consumer.h>
45 #include <linux/smb349-charger.h>
46 #include <linux/max17048_battery.h>
47 #include <linux/leds.h>
48 #include <linux/i2c/at24.h>
49 #include <linux/of_platform.h>
50 #include <linux/edp.h>
51
52 #include <asm/hardware/gic.h>
53
54 #include <mach/clk.h>
55 #include <mach/irqs.h>
56 #include <mach/pinmux.h>
57 #include <mach/pinmux-tegra30.h>
58 #include <mach/io_dpd.h>
59 #include <mach/i2s.h>
60 #include <mach/isomgr.h>
61 #include <mach/tegra_asoc_pdata.h>
62 #include <asm/mach-types.h>
63 #include <asm/mach/arch.h>
64 #include <mach/gpio-tegra.h>
65 #include <mach/tegra_fiq_debugger.h>
66 #include <linux/platform_data/tegra_usb_modem_power.h>
67
68 #include "board-touch-raydium.h"
69 #include "board.h"
70 #include "board-common.h"
71 #include "clock.h"
72 #include "board-macallan.h"
73 #include "devices.h"
74 #include "gpio-names.h"
75 #include "fuse.h"
76 #include "iomap.h"
77 #include "pm.h"
78 #include "pm-irq.h"
79 #include "common.h"
80 #include "tegra-board-id.h"
81
82 static struct board_info board_info, display_board_info;
83
84 #ifdef CONFIG_BT_BLUESLEEP
85 static struct rfkill_gpio_platform_data macallan_bt_rfkill_pdata = {
86                 .name           = "bt_rfkill",
87                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
88                 .reset_gpio     = TEGRA_GPIO_PQ6,
89                 .type           = RFKILL_TYPE_BLUETOOTH,
90 };
91
92 static struct platform_device macallan_bt_rfkill_device = {
93         .name = "rfkill_gpio",
94         .id             = -1,
95         .dev = {
96                 .platform_data = &macallan_bt_rfkill_pdata,
97         },
98 };
99
100 static struct resource macallan_bluesleep_resources[] = {
101         [0] = {
102                 .name = "gpio_host_wake",
103                         .start  = TEGRA_GPIO_PU6,
104                         .end    = TEGRA_GPIO_PU6,
105                         .flags  = IORESOURCE_IO,
106         },
107         [1] = {
108                 .name = "gpio_ext_wake",
109                         .start  = TEGRA_GPIO_PEE1,
110                         .end    = TEGRA_GPIO_PEE1,
111                         .flags  = IORESOURCE_IO,
112         },
113         [2] = {
114                 .name = "host_wake",
115                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
116         },
117 };
118
119 static struct platform_device macallan_bluesleep_device = {
120         .name           = "bluesleep",
121         .id             = -1,
122         .num_resources  = ARRAY_SIZE(macallan_bluesleep_resources),
123         .resource       = macallan_bluesleep_resources,
124 };
125
126 static noinline void __init macallan_setup_bt_rfkill(void)
127 {
128         platform_device_register(&macallan_bt_rfkill_device);
129 }
130
131 static noinline void __init macallan_setup_bluesleep(void)
132 {
133         macallan_bluesleep_resources[2].start =
134                 macallan_bluesleep_resources[2].end =
135                         gpio_to_irq(TEGRA_GPIO_PU6);
136         platform_device_register(&macallan_bluesleep_device);
137         return;
138 }
139 #elif defined CONFIG_BLUEDROID_PM
140 static struct resource macallan_bluedroid_pm_resources[] = {
141         [0] = {
142                 .name   = "shutdown_gpio",
143                 .start  = TEGRA_GPIO_PQ7,
144                 .end    = TEGRA_GPIO_PQ7,
145                 .flags  = IORESOURCE_IO,
146         },
147         [1] = {
148                 .name = "host_wake",
149                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
150         },
151         [2] = {
152                 .name = "gpio_ext_wake",
153                 .start  = TEGRA_GPIO_PEE1,
154                 .end    = TEGRA_GPIO_PEE1,
155                 .flags  = IORESOURCE_IO,
156         },
157         [3] = {
158                 .name = "gpio_host_wake",
159                 .start  = TEGRA_GPIO_PU6,
160                 .end    = TEGRA_GPIO_PU6,
161                 .flags  = IORESOURCE_IO,
162         },
163         [4] = {
164                 .name = "reset_gpio",
165                 .start  = TEGRA_GPIO_PQ6,
166                 .end    = TEGRA_GPIO_PQ6,
167                 .flags  = IORESOURCE_IO,
168         },
169 };
170
171 static struct platform_device macallan_bluedroid_pm_device = {
172         .name = "bluedroid_pm",
173         .id             = 0,
174         .num_resources  = ARRAY_SIZE(macallan_bluedroid_pm_resources),
175         .resource       = macallan_bluedroid_pm_resources,
176 };
177
178 static noinline void __init macallan_setup_bluedroid_pm(void)
179 {
180         macallan_bluedroid_pm_resources[1].start =
181                 macallan_bluedroid_pm_resources[1].end =
182                                 gpio_to_irq(TEGRA_GPIO_PU6);
183         platform_device_register(&macallan_bluedroid_pm_device);
184 }
185 #endif
186
187 static __initdata struct tegra_clk_init_table macallan_clk_init_table[] = {
188         /* name         parent          rate            enabled */
189         { "pll_m",      NULL,           0,              false},
190         { "hda",        "pll_p",        108000000,      false},
191         { "hda2codec_2x", "pll_p",      48000000,       false},
192         { "pwm",        "pll_p",        3187500,        false},
193         { "blink",      "clk_32k",      32768,          true},
194         { "i2s1",       "pll_a_out0",   0,              false},
195         { "i2s3",       "pll_a_out0",   0,              false},
196         { "i2s4",       "pll_a_out0",   0,              false},
197         { "spdif_out",  "pll_a_out0",   0,              false},
198         { "d_audio",    "clk_m",        12000000,       false},
199         { "dam0",       "clk_m",        12000000,       false},
200         { "dam1",       "clk_m",        12000000,       false},
201         { "dam2",       "clk_m",        12000000,       false},
202         { "audio1",     "i2s1_sync",    0,              false},
203         { "audio3",     "i2s3_sync",    0,              false},
204         /* Setting vi_sensor-clk to true for validation purpose, will imapact
205          * power, later set to be false.*/
206         { "vi_sensor",  "pll_p",        150000000,      false},
207         { "cilab",      "pll_p",        150000000,      false},
208         { "cilcd",      "pll_p",        150000000,      false},
209         { "cile",       "pll_p",        150000000,      false},
210         { "i2c1",       "pll_p",        3200000,        false},
211         { "i2c2",       "pll_p",        3200000,        false},
212         { "i2c3",       "pll_p",        3200000,        false},
213         { "i2c4",       "pll_p",        3200000,        false},
214         { "i2c5",       "pll_p",        3200000,        false},
215         { NULL,         NULL,           0,              0},
216 };
217
218 #ifndef CONFIG_USE_OF
219 static struct tegra_i2c_platform_data macallan_i2c1_platform_data = {
220         .bus_clk_rate   = 100000,
221         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
222         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
223 };
224
225 static struct tegra_i2c_platform_data macallan_i2c2_platform_data = {
226         .bus_clk_rate   = 100000,
227         .is_clkon_always = true,
228         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
229         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
230 };
231
232 static struct tegra_i2c_platform_data macallan_i2c3_platform_data = {
233         .bus_clk_rate   = 400000,
234         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
235         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
236 };
237
238 static struct tegra_i2c_platform_data macallan_i2c4_platform_data = {
239         .bus_clk_rate   = 10000,
240         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
241         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
242 };
243
244 static struct tegra_i2c_platform_data macallan_i2c5_platform_data = {
245         .bus_clk_rate   = 400000,
246         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
247         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
248 };
249 #endif
250
251 static struct i2c_board_info __initdata rt5640_board_info = {
252         I2C_BOARD_INFO("rt5640", 0x1c),
253 };
254
255 static struct pn544_i2c_platform_data nfc_pdata = {
256         .irq_gpio = TEGRA_GPIO_PW2,
257         .ven_gpio = TEGRA_GPIO_PQ3,
258         .firm_gpio = TEGRA_GPIO_PH0,
259 };
260
261 static struct i2c_board_info __initdata nfc_board_info = {
262         I2C_BOARD_INFO("pn544", 0x28),
263         .platform_data = &nfc_pdata,
264 };
265
266 static void macallan_i2c_init(void)
267 {
268 #ifndef CONFIG_USE_OF
269         tegra11_i2c_device1.dev.platform_data = &macallan_i2c1_platform_data;
270         tegra11_i2c_device2.dev.platform_data = &macallan_i2c2_platform_data;
271         tegra11_i2c_device3.dev.platform_data = &macallan_i2c3_platform_data;
272         tegra11_i2c_device4.dev.platform_data = &macallan_i2c4_platform_data;
273         tegra11_i2c_device5.dev.platform_data = &macallan_i2c5_platform_data;
274
275         platform_device_register(&tegra11_i2c_device5);
276         platform_device_register(&tegra11_i2c_device4);
277         platform_device_register(&tegra11_i2c_device3);
278         platform_device_register(&tegra11_i2c_device2);
279         platform_device_register(&tegra11_i2c_device1);
280 #endif
281
282         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
283         i2c_register_board_info(0, &nfc_board_info, 1);
284         i2c_register_board_info(0, &rt5640_board_info, 1);
285 }
286
287 static struct platform_device *macallan_uart_devices[] __initdata = {
288         &tegra_uarta_device,
289         &tegra_uartb_device,
290         &tegra_uartc_device,
291         &tegra_uartd_device,
292 };
293 static struct uart_clk_parent uart_parent_clk[] = {
294         [0] = {.name = "clk_m"},
295         [1] = {.name = "pll_p"},
296 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
297         [2] = {.name = "pll_m"},
298 #endif
299 };
300
301 static struct tegra_uart_platform_data macallan_uart_pdata;
302 static struct tegra_uart_platform_data macallan_loopback_uart_pdata;
303
304 static void __init uart_debug_init(void)
305 {
306         int debug_port_id;
307
308         debug_port_id = uart_console_debug_init(3);
309         if (debug_port_id < 0)
310                 return;
311
312         macallan_uart_devices[debug_port_id] = uart_console_debug_device;
313 }
314
315 static void __init macallan_uart_init(void)
316 {
317         struct clk *c;
318         int i;
319
320         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
321                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
322                 if (IS_ERR_OR_NULL(c)) {
323                         pr_err("Not able to get the clock for %s\n",
324                                                 uart_parent_clk[i].name);
325                         continue;
326                 }
327                 uart_parent_clk[i].parent_clk = c;
328                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
329         }
330         macallan_uart_pdata.parent_clk_list = uart_parent_clk;
331         macallan_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
332         macallan_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
333         macallan_loopback_uart_pdata.parent_clk_count =
334                                                 ARRAY_SIZE(uart_parent_clk);
335         macallan_loopback_uart_pdata.is_loopback = true;
336         tegra_uarta_device.dev.platform_data = &macallan_uart_pdata;
337         tegra_uartb_device.dev.platform_data = &macallan_uart_pdata;
338         tegra_uartc_device.dev.platform_data = &macallan_uart_pdata;
339         tegra_uartd_device.dev.platform_data = &macallan_uart_pdata;
340
341         /* Register low speed only if it is selected */
342         if (!is_tegra_debug_uartport_hs())
343                 uart_debug_init();
344
345         platform_add_devices(macallan_uart_devices,
346                                 ARRAY_SIZE(macallan_uart_devices));
347 }
348
349 static struct resource tegra_rtc_resources[] = {
350         [0] = {
351                 .start = TEGRA_RTC_BASE,
352                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
353                 .flags = IORESOURCE_MEM,
354         },
355         [1] = {
356                 .start = INT_RTC,
357                 .end = INT_RTC,
358                 .flags = IORESOURCE_IRQ,
359         },
360 };
361
362 static struct platform_device tegra_rtc_device = {
363         .name = "tegra_rtc",
364         .id   = -1,
365         .resource = tegra_rtc_resources,
366         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
367 };
368
369 static struct tegra_asoc_platform_data macallan_audio_pdata = {
370         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
371         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
372         .gpio_hp_mute           = -1,
373         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
374         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
375         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
376         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
377         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
378         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
379         .i2s_param[HIFI_CODEC]  = {
380                 .audio_port_id  = 1,
381                 .is_i2s_master  = 1,
382                 .i2s_mode       = TEGRA_DAIFMT_I2S,
383         },
384         .i2s_param[BT_SCO]      = {
385                 .audio_port_id  = 3,
386                 .is_i2s_master  = 1,
387                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
388         },
389 };
390
391 static struct platform_device macallan_audio_device = {
392         .name   = "tegra-snd-rt5640",
393         .id     = 0,
394         .dev    = {
395                 .platform_data = &macallan_audio_pdata,
396         },
397 };
398
399 static struct platform_device *macallan_devices[] __initdata = {
400         &tegra_pmu_device,
401         &tegra_rtc_device,
402         &tegra_udc_device,
403 #if defined(CONFIG_TEGRA_AVP)
404         &tegra_avp_device,
405 #endif
406 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
407         &tegra11_se_device,
408 #endif
409         &tegra_ahub_device,
410         &tegra_dam_device0,
411         &tegra_dam_device1,
412         &tegra_dam_device2,
413         &tegra_i2s_device1,
414         &tegra_i2s_device3,
415         &tegra_i2s_device4,
416         &tegra_spdif_device,
417         &spdif_dit_device,
418         &bluetooth_dit_device,
419         &macallan_audio_device,
420         &tegra_hda_device,
421 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
422         &tegra_aes_device,
423 #endif
424 };
425
426 #ifdef CONFIG_USB_SUPPORT
427 static struct tegra_usb_platform_data tegra_udc_pdata = {
428         .port_otg = true,
429         .has_hostpc = true,
430         .support_pmu_vbus = true,
431         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
432         .op_mode = TEGRA_USB_OPMODE_DEVICE,
433         .u_data.dev = {
434                 .vbus_pmu_irq = 0,
435                 .vbus_gpio = -1,
436                 .charging_supported = false,
437                 .remote_wakeup_supported = false,
438         },
439         .u_cfg.utmi = {
440                 .hssync_start_delay = 0,
441                 .elastic_limit = 16,
442                 .idle_wait_delay = 17,
443                 .term_range_adj = 6,
444                 .xcvr_setup = 8,
445                 .xcvr_lsfslew = 2,
446                 .xcvr_lsrslew = 2,
447                 .xcvr_setup_offset = 0,
448                 .xcvr_use_fuses = 1,
449         },
450 };
451
452 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
453         .port_otg = true,
454         .has_hostpc = true,
455         .support_pmu_vbus = true,
456         .unaligned_dma_buf_supported = false,
457         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
458         .op_mode = TEGRA_USB_OPMODE_HOST,
459         .u_data.host = {
460                 .vbus_gpio = -1,
461                 .hot_plug = false,
462                 .remote_wakeup_supported = true,
463                 .power_off_on_suspend = true,
464         },
465         .u_cfg.utmi = {
466                 .hssync_start_delay = 0,
467                 .elastic_limit = 16,
468                 .idle_wait_delay = 17,
469                 .term_range_adj = 6,
470                 .xcvr_setup = 15,
471                 .xcvr_lsfslew = 2,
472                 .xcvr_lsrslew = 2,
473                 .xcvr_setup_offset = 0,
474                 .xcvr_use_fuses = 1,
475                 .vbus_oc_map = 0x4,
476         },
477 };
478
479 static struct tegra_usb_otg_data tegra_otg_pdata = {
480         .ehci_device = &tegra_ehci1_device,
481         .ehci_pdata = &tegra_ehci1_utmi_pdata,
482         .extcon_dev_name = "palmas-extcon.10",
483 };
484
485 static void macallan_usb_init(void)
486 {
487         int usb_port_owner_info = tegra_get_usb_port_owner_info();
488
489         /* Set USB wake sources for macallan */
490         tegra_set_usb_wake_source();
491
492         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
493                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
494                 platform_device_register(&tegra_otg_device);
495                 /* Setup the udc platform data */
496                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
497         }
498 }
499
500 static struct gpio modem_gpios[] = { /* Nemo modem */
501         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
502         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
503 };
504
505 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
506         .port_otg = false,
507         .has_hostpc = true,
508         .unaligned_dma_buf_supported = false,
509         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
510         .op_mode = TEGRA_USB_OPMODE_HOST,
511         .u_data.host = {
512                 .vbus_gpio = -1,
513                 .hot_plug = false,
514                 .remote_wakeup_supported = true,
515                 .power_off_on_suspend = true,
516         },
517 };
518
519 static int baseband_init(void)
520 {
521         int ret;
522
523         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
524         if (ret) {
525                 pr_warn("%s:gpio request failed\n", __func__);
526                 return ret;
527         }
528
529         /* enable pull-down for MDM_COLD_BOOT */
530         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
531                                     TEGRA_PUPD_PULL_DOWN);
532
533         /* export GPIO for user space access through sysfs */
534         gpio_export(MDM_RST, false);
535
536         return 0;
537 }
538
539 static const struct tegra_modem_operations baseband_operations = {
540         .init = baseband_init,
541 };
542
543 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
544         .ops = &baseband_operations,
545         .wake_gpio = -1,
546         .boot_gpio = MDM_COLDBOOT,
547         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
548         .autosuspend_delay = 2000,
549         .short_autosuspend_delay = 50,
550         .tegra_ehci_device = &tegra_ehci2_device,
551         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
552 };
553
554 static struct platform_device icera_nemo_device = {
555         .name = "tegra_usb_modem_power",
556         .id = -1,
557         .dev = {
558                 .platform_data = &baseband_pdata,
559         },
560 };
561
562 static void macallan_modem_init(void)
563 {
564         int modem_id = tegra_get_modem_id();
565         int usb_port_owner_info = tegra_get_usb_port_owner_info();
566         switch (modem_id) {
567         case TEGRA_BB_NEMO: /* on board i500 HSIC */
568                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
569                         platform_device_register(&icera_nemo_device);
570                 break;
571         }
572 }
573
574 #else
575 static void macallan_usb_init(void) { }
576 static void macallan_modem_init(void) { }
577 #endif
578
579 static void macallan_audio_init(void)
580 {
581         macallan_audio_pdata.codec_name = "rt5640.0-001c";
582         macallan_audio_pdata.codec_dai_name = "rt5640-aif1";
583 }
584
585
586 static struct platform_device *macallan_spi_devices[] __initdata = {
587         &tegra11_spi_device1,
588 };
589
590 struct spi_clk_parent spi_parent_clk_macallan[] = {
591         [0] = {.name = "pll_p"},
592 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
593         [1] = {.name = "pll_m"},
594         [2] = {.name = "clk_m"},
595 #else
596         [1] = {.name = "clk_m"},
597 #endif
598 };
599
600 static struct tegra_spi_platform_data macallan_spi_pdata = {
601         .is_dma_based           = false,
602         .max_dma_buffer         = 16 * 1024,
603         .is_clkon_always        = false,
604         .max_rate               = 25000000,
605 };
606
607 static void __init macallan_spi_init(void)
608 {
609         int i;
610         struct clk *c;
611
612         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_macallan); ++i) {
613                 c = tegra_get_clock_by_name(spi_parent_clk_macallan[i].name);
614                 if (IS_ERR_OR_NULL(c)) {
615                         pr_err("Not able to get the clock for %s\n",
616                                         spi_parent_clk_macallan[i].name);
617                         continue;
618                 }
619                 spi_parent_clk_macallan[i].parent_clk = c;
620                 spi_parent_clk_macallan[i].fixed_clk_rate = clk_get_rate(c);
621         }
622         macallan_spi_pdata.parent_clk_list = spi_parent_clk_macallan;
623         macallan_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_macallan);
624         tegra11_spi_device1.dev.platform_data = &macallan_spi_pdata;
625         platform_add_devices(macallan_spi_devices,
626                                 ARRAY_SIZE(macallan_spi_devices));
627 }
628
629 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
630         /* name         parent          rate            enabled */
631         { "extern2",    "pll_p",        41000000,       false},
632         { "clk_out_2",  "extern2",      40800000,       false},
633         { NULL,         NULL,           0,              0},
634 };
635
636 struct rm_spi_ts_platform_data rm31080ts_macallan_data = {
637         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
638         .config = 0,
639         .platform_id = RM_PLATFORM_D010,
640         .name_of_clock = "clk_out_2",
641         .name_of_clock_con = "extern2",
642 };
643
644 static struct tegra_spi_device_controller_data dev_cdata = {
645         .rx_clk_tap_delay = 0,
646         .tx_clk_tap_delay = 16,
647 };
648
649 struct spi_board_info rm31080a_macallan_spi_board[1] = {
650         {
651          .modalias = "rm_ts_spidev",
652          .bus_num = 0,
653          .chip_select = 0,
654          .max_speed_hz = 12 * 1000 * 1000,
655          .mode = SPI_MODE_0,
656          .controller_data = &dev_cdata,
657          .platform_data = &rm31080ts_macallan_data,
658          },
659 };
660
661 static int __init macallan_touch_init(void)
662 {
663         tegra_clk_init_from_table(touch_clk_init_table);
664         if (display_board_info.board_id == BOARD_E1582)
665                 rm31080ts_macallan_data.platform_id = RM_PLATFORM_P005;
666         else
667                 rm31080ts_macallan_data.platform_id = RM_PLATFORM_D010;
668         mdelay(20);
669         rm31080a_macallan_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
670         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
671                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
672                                 &rm31080ts_macallan_data,
673                                 &rm31080a_macallan_spi_board[0],
674                                 ARRAY_SIZE(rm31080a_macallan_spi_board));
675         return 0;
676 }
677
678 #ifdef CONFIG_USE_OF
679 struct of_dev_auxdata macallan_auxdata_lookup[] __initdata = {
680         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
681                                 NULL),
682         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
683                                 NULL),
684         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
685                                 &macallan_tegra_sdhci_platform_data0),
686         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
687                                 NULL),
688         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
689                                 NULL),
690         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
691                                 NULL),
692         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
693                                 NULL),
694         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
695                                 NULL),
696         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
697                                 NULL),
698         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
699                                 NULL),
700         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
701                                 NULL),
702
703         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
704                                 NULL),
705         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
706                                 NULL),
707         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
708                                 NULL),
709         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
710                                 NULL),
711         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
712                                 NULL),
713         {}
714 };
715 #endif
716
717 static void __init tegra_macallan_early_init(void)
718 {
719         tegra_clk_init_from_table(macallan_clk_init_table);
720         tegra_clk_vefify_parents();
721         tegra_smmu_init();
722         tegra_soc_device_init("macallan");
723 }
724
725
726 static void __init tegra_macallan_late_init(void)
727 {
728         platform_device_register(&tegra_pinmux_device);
729         macallan_pinmux_init();
730         macallan_i2c_init();
731         macallan_spi_init();
732         macallan_usb_init();
733         macallan_uart_init();
734         macallan_audio_init();
735         platform_add_devices(macallan_devices, ARRAY_SIZE(macallan_devices));
736         //tegra_ram_console_debug_init();
737         tegra_io_dpd_init();
738         macallan_regulator_init();
739         macallan_sdhci_init();
740         macallan_suspend_init();
741         macallan_emc_init();
742         macallan_edp_init();
743         isomgr_init();
744         macallan_touch_init();
745         macallan_panel_init();
746         macallan_kbc_init();
747         macallan_pmon_init();
748 #ifdef CONFIG_BT_BLUESLEEP
749         macallan_setup_bluesleep();
750         macallan_setup_bt_rfkill();
751 #elif defined CONFIG_BLUEDROID_PM
752         macallan_setup_bluedroid_pm();
753 #endif
754         tegra_release_bootloader_fb();
755         macallan_modem_init();
756 #ifdef CONFIG_TEGRA_WDT_RECOVERY
757         tegra_wdt_recovery_init();
758 #endif
759         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
760         /* macallan_sensors_init(); */
761         macallan_soctherm_init();
762         tegra_register_fuse();
763 }
764
765 static void __init macallan_ramconsole_reserve(unsigned long size)
766 {
767         tegra_ram_console_debug_reserve(SZ_1M);
768 }
769
770 static void __init tegra_macallan_dt_init(void)
771 {
772         tegra_get_board_info(&board_info);
773         tegra_get_display_board_info(&display_board_info);
774
775         tegra_macallan_early_init();
776
777 #ifdef CONFIG_USE_OF
778         of_platform_populate(NULL,
779                 of_default_bus_match_table, macallan_auxdata_lookup,
780                 &platform_bus);
781 #else
782         platform_device_register(&tegra_gpio_device);
783 #endif
784
785         tegra_macallan_late_init();
786 }
787
788 static void __init tegra_macallan_reserve(void)
789 {
790 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
791         /* 1920*1200*4*2 = 18432000 bytes */
792         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
793 #else
794         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
795 #endif
796         macallan_ramconsole_reserve(SZ_1M);
797 }
798
799 static const char * const macallan_dt_board_compat[] = {
800         "nvidia,macallan",
801         NULL
802 };
803
804 MACHINE_START(MACALLAN, "macallan")
805         .atag_offset    = 0x100,
806         .smp            = smp_ops(tegra_smp_ops),
807         .map_io         = tegra_map_common_io,
808         .reserve        = tegra_macallan_reserve,
809         .init_early     = tegra11x_init_early,
810         .init_irq       = tegra_dt_init_irq,
811         .handle_irq     = gic_handle_irq,
812         .timer          = &tegra_sys_timer,
813         .init_machine   = tegra_macallan_dt_init,
814         .restart        = tegra_assert_system_reset,
815         .dt_compat      = macallan_dt_board_compat,
816 MACHINE_END