Arm: tegra: p1852: Changed sclk to run at max.
[linux-2.6.git] / arch / arm / mach-tegra / board-p1852.c
1 /*
2  * arch/arm/mach-tegra/board-p1852.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 it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope 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
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
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/i2c/panjit_ts.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/platform_data/tegra_nor.h>
36 #include <linux/spi/spi.h>
37 #include <linux/mtd/partitions.h>
38 #include <mach/clk.h>
39 #include <mach/iomap.h>
40 #include <mach/irqs.h>
41 #include <mach/pinmux.h>
42 #include <mach/iomap.h>
43 #include <mach/io.h>
44 #include <mach/pci.h>
45 #include <mach/audio.h>
46 #include <mach/tegra_p1852_pdata.h>
47 #include <asm/mach/flash.h>
48 #include <asm/mach-types.h>
49 #include <asm/mach/arch.h>
50 #include <mach/usb_phy.h>
51 #include <sound/wm8903.h>
52 #include <mach/tsensor.h>
53 #include "board.h"
54 #include "clock.h"
55 #include "board-p1852.h"
56 #include "devices.h"
57 #include "gpio-names.h"
58 #include "fuse.h"
59
60 static struct tegra_utmip_config utmi_phy_config[] = {
61         [0] = {
62                         .hssync_start_delay = 0,
63                         .idle_wait_delay = 17,
64                         .elastic_limit = 16,
65                         .term_range_adj = 6,
66                         .xcvr_setup = 15,
67                         .xcvr_setup_offset = 0,
68                         .xcvr_use_fuses = 1,
69                         .xcvr_lsfslew = 2,
70                         .xcvr_lsrslew = 2,
71         },
72         [1] = {
73                         .hssync_start_delay = 0,
74                         .idle_wait_delay = 17,
75                         .elastic_limit = 16,
76                         .term_range_adj = 6,
77                         .xcvr_setup = 15,
78                         .xcvr_setup_offset = 0,
79                         .xcvr_use_fuses = 1,
80                         .xcvr_lsfslew = 2,
81                         .xcvr_lsrslew = 2,
82         },
83         [2] = {
84                         .hssync_start_delay = 0,
85                         .idle_wait_delay = 17,
86                         .elastic_limit = 16,
87                         .term_range_adj = 6,
88                         .xcvr_setup = 8,
89                         .xcvr_setup_offset = 0,
90                         .xcvr_use_fuses = 1,
91                         .xcvr_lsfslew = 2,
92                         .xcvr_lsrslew = 2,
93         },
94 };
95
96 static __initdata struct tegra_clk_init_table p1852_clk_init_table[] = {
97         /* name         parent          rate            enabled */
98         { "pll_m",              NULL,           0,              true},
99         { "hda",                "pll_p",        108000000,      false},
100         { "hda2codec_2x",       "pll_p",        48000000,       false},
101         { "pwm",                "clk_32k",      32768,          false},
102         { "blink",              "clk_32k",      32768,          true},
103         { "pll_a",              NULL,           552960000,      false},
104         { "pll_a_out0",         NULL,           12288000,       false},
105         { "d_audio",            "pll_a_out0",   12288000,       false},
106         { "nor",                "pll_p",        86500000,       true},
107         { "uarta",              "pll_p",        480000000,      true},
108         { "uartd",              "pll_p",        480000000,      true},
109         { "uarte",              "pll_p",        480000000,      true},
110         { "sdmmc2",             "pll_p",        52000000,       true},
111         { "sbc1",               "pll_m",        100000000,      true},
112         { "sbc2",               "pll_m",        100000000,      true},
113         { "sbc3",               "pll_m",        100000000,      true},
114         { "sbc4",               "pll_m",        100000000,      true},
115         { "sbc5",               "pll_m",        100000000,      true},
116         { "sbc6",               "pll_m",        100000000,      true},
117         { "cpu_g",              "cclk_g",       900000000,      true},
118         { "i2s0",               "pll_a_out0",   12288000,       false},
119         { "i2s1",               "pll_a_out0",   12288000,       false},
120         { "i2s2",               "pll_a_out0",   12288000,       false},
121         { "i2s3",               "pll_a_out0",   12288000,       false},
122         { "i2s4",               "pll_a_out0",   12288000,       false},
123         { "audio0",             "i2s0_sync",    12288000,       false},
124         { "audio1",             "i2s1_sync",    12288000,       false},
125         { "audio2",             "i2s2_sync",    12288000,       false},
126         { "audio3",             "i2s3_sync",    12288000,       false},
127         { "audio4",             "i2s4_sync",    12288000,       false},
128         { "apbif",              "clk_m",        12000000,       false},
129         { "dam0",               "clk_m",        12000000,       true},
130         { "dam1",               "clk_m",        12000000,       true},
131         { "dam2",               "clk_m",        12000000,       true},
132         { "vi",                 "pll_p",        470000000,      false},
133         { "vi_sensor",          "pll_p",        150000000,      false},
134         { "vde",                "pll_c",        484000000,      true},
135         { "host1x",             "pll_c",        242000000,      true},
136         { "mpe",                "pll_c",        484000000,      true},
137         { "se",                 "pll_m",        625000000,      true},
138         { "i2c1",               "pll_p",        3200000,        true},
139         { "i2c2",               "pll_p",        3200000,        true},
140         { "i2c3",               "pll_p",        3200000,        true},
141         { "i2c4",               "pll_p",        3200000,        true},
142         { "i2c5",               "pll_p",        3200000,        true},
143         { "sdmmc2",             "pll_p",        104000000,      false},
144         {"wake.sclk",           NULL,           334000000,      true },
145         { NULL,                 NULL,           0,              0},
146 };
147
148 static struct tegra_i2c_platform_data p1852_i2c1_platform_data = {
149         .adapter_nr     = 0,
150         .bus_count      = 1,
151         .bus_clk_rate   = { 100000, 0 },
152 };
153
154 static struct tegra_i2c_platform_data p1852_i2c2_platform_data = {
155         .adapter_nr     = 1,
156         .bus_count      = 1,
157         .bus_clk_rate   = { 100000, 0 },
158         .is_clkon_always = true,
159 };
160
161 static struct tegra_i2c_platform_data p1852_i2c4_platform_data = {
162         .adapter_nr     = 3,
163         .bus_count      = 1,
164         .bus_clk_rate   = { 100000, 0 },
165 };
166
167 static struct tegra_i2c_platform_data p1852_i2c5_platform_data = {
168         .adapter_nr     = 4,
169         .bus_count      = 1,
170         .bus_clk_rate   = { 100000, 0 },
171 };
172
173 static struct tegra_pci_platform_data p1852_pci_platform_data = {
174         .port_status[0] = 0,
175         .port_status[1] = 1,
176         .port_status[2] = 1,
177         .use_dock_detect = 0,
178         .gpio           = 0,
179 };
180
181 static void p1852_pcie_init(void)
182 {
183         tegra_pci_device.dev.platform_data = &p1852_pci_platform_data;
184         platform_device_register(&tegra_pci_device);
185 }
186
187 static void p1852_i2c_init(void)
188 {
189         tegra_i2c_device1.dev.platform_data = &p1852_i2c1_platform_data;
190         tegra_i2c_device2.dev.platform_data = &p1852_i2c2_platform_data;
191         tegra_i2c_device4.dev.platform_data = &p1852_i2c4_platform_data;
192         tegra_i2c_device5.dev.platform_data = &p1852_i2c5_platform_data;
193
194         platform_device_register(&tegra_i2c_device5);
195         platform_device_register(&tegra_i2c_device4);
196         platform_device_register(&tegra_i2c_device2);
197         platform_device_register(&tegra_i2c_device1);
198 }
199
200 static struct platform_device *p1852_uart_devices[] __initdata = {
201         &tegra_uarta_device,
202         &tegra_uartb_device,
203         &tegra_uartd_device,
204         &tegra_uarte_device,
205 };
206 static struct clk *debug_uart_clk;
207
208 static void __init uart_debug_init(void)
209 {
210         /* Use skuinfo to decide debug uart */
211         /* UARTB is the debug port. */
212         pr_info("Selecting UARTB as the debug console\n");
213         p1852_uart_devices[1] = &debug_uartb_device;
214         debug_uart_clk = clk_get_sys("serial8250.0", "uartb");
215 }
216
217 static void __init p1852_uart_init(void)
218 {
219         /* Register low speed only if it is selected */
220         if (!is_tegra_debug_uartport_hs()) {
221                 uart_debug_init();
222                 /* Clock enable for the debug channel */
223                 if (!IS_ERR_OR_NULL(debug_uart_clk)) {
224                         pr_info("The debug console clock name is %s\n",
225                                                 debug_uart_clk->name);
226                         clk_enable(debug_uart_clk);
227                         clk_set_rate(debug_uart_clk, 408000000);
228                 } else {
229                         pr_err("Not getting the clock %s for debug console\n",
230                                         debug_uart_clk->name);
231                 }
232         }
233
234         platform_add_devices(p1852_uart_devices,
235                                 ARRAY_SIZE(p1852_uart_devices));
236 }
237
238 static struct tegra_p1852_platform_data p1852_audio_pdata = {
239         .codec_info[0] = {
240                 .codec_dai_name = "dit-hifi",
241                 .cpu_dai_name = "tegra30-i2s.0",
242                 .codec_name = "spdif-dit.0",
243                 .name = "tegra-i2s-1",
244                 .i2s_format = format_i2s,
245                 .master = 1,
246         },
247         .codec_info[1] = {
248                 .codec_dai_name = "dit-hifi",
249                 .cpu_dai_name = "tegra30-i2s.1",
250                 .codec_name = "spdif-dit.1",
251                 .name = "tegra-i2s-2",
252                 .i2s_format = format_i2s,
253                 .master = 0,
254         },
255
256 };
257
258 static struct platform_device generic_codec_1 = {
259         .name           = "spdif-dit",
260         .id                     = 0,
261 };
262 static struct platform_device generic_codec_2 = {
263         .name           = "spdif-dit",
264         .id                     = 1,
265 };
266
267 static struct platform_device tegra_snd_p1852 = {
268         .name       = "tegra-snd-p1852",
269         .id = 0,
270         .dev    = {
271             .platform_data = &p1852_audio_pdata,
272         },
273 };
274
275 static void p1852_i2s_audio_init(void)
276 {
277         platform_device_register(&tegra_pcm_device);
278         platform_device_register(&generic_codec_1);
279         platform_device_register(&generic_codec_2);
280         platform_device_register(&tegra_i2s_device0);
281         platform_device_register(&tegra_i2s_device1);
282         platform_device_register(&tegra_ahub_device);
283         platform_device_register(&tegra_snd_p1852);
284 }
285
286
287 #if defined(CONFIG_SPI_TEGRA) && defined(CONFIG_SPI_SPIDEV)
288 static struct spi_board_info tegra_spi_devices[] __initdata = {
289         {
290                 .modalias = "spidev",
291                 .bus_num = 0,
292                 .chip_select = 0,
293                 .mode = SPI_MODE_0,
294                 .max_speed_hz = 18000000,
295                 .platform_data = NULL,
296                 .irq = 0,
297         },
298         {
299                 .modalias = "spidev",
300                 .bus_num = 1,
301                 .chip_select = 1,
302                 .mode = SPI_MODE_0,
303                 .max_speed_hz = 18000000,
304                 .platform_data = NULL,
305                 .irq = 0,
306         },
307         {
308                 .modalias = "spidev",
309                 .bus_num = 3,
310                 .chip_select = 1,
311                 .mode = SPI_MODE_0,
312                 .max_speed_hz = 18000000,
313                 .platform_data = NULL,
314                 .irq = 0,
315         },
316 };
317
318 static void __init p852_register_spidev(void)
319 {
320         spi_register_board_info(tegra_spi_devices,
321                         ARRAY_SIZE(tegra_spi_devices));
322 }
323 #else
324 #define p852_register_spidev() do {} while (0)
325 #endif
326
327
328 static void p1852_spi_init(void)
329 {
330         tegra_spi_device2.name = "spi_slave_tegra";
331         platform_device_register(&tegra_spi_device1);
332         platform_device_register(&tegra_spi_device2);
333         p852_register_spidev();
334 }
335
336 static struct platform_device *p1852_devices[] __initdata = {
337 #if defined(CONFIG_TEGRA_IOVMM_SMMU)
338         &tegra_smmu_device,
339 #endif
340 #if defined(CONFIG_TEGRA_AVP)
341         &tegra_avp_device,
342 #endif
343         &tegra_wdt_device
344 };
345
346 static struct usb_phy_plat_data tegra_usb_phy_pdata[] = {
347         [0] = {
348                         .instance = 0,
349                         .vbus_gpio = -1,
350                         .vbus_reg_supply = NULL,
351         },
352         [1] = {
353                         .instance = 1,
354                         .vbus_gpio = -1,
355         },
356         [2] = {
357                         .instance = 2,
358                         .vbus_gpio = -1,
359                         .vbus_reg_supply = NULL,
360         },
361 };
362
363 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
364         [0] = {
365                         .phy_config = &utmi_phy_config[0],
366                         .operating_mode = TEGRA_USB_HOST,
367                         .power_down_on_bus_suspend = 1,
368         },
369         [1] = {
370                         .phy_config = &utmi_phy_config[1],
371                         .operating_mode = TEGRA_USB_HOST,
372                         .power_down_on_bus_suspend = 1,
373         },
374         [2] = {
375                         .phy_config = &utmi_phy_config[2],
376                         .operating_mode = TEGRA_USB_HOST,
377                         .power_down_on_bus_suspend = 1,
378         },
379 };
380
381 static void p1852_usb_init(void)
382 {
383         /* Need to parse sku info to decide host/device mode */
384         tegra_usb_phy_init(tegra_usb_phy_pdata,
385                                 ARRAY_SIZE(tegra_usb_phy_pdata));
386
387         tegra_ehci1_device.dev.platform_data = &tegra_ehci_pdata[0];
388         platform_device_register(&tegra_ehci1_device);
389
390         tegra_ehci2_device.dev.platform_data = &tegra_ehci_pdata[1];
391         platform_device_register(&tegra_ehci2_device);
392
393         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
394         platform_device_register(&tegra_ehci3_device);
395
396 }
397
398 static struct tegra_nor_platform_data p1852_nor_data = {
399         .flash = {
400                 .map_name = "cfi_probe",
401                 .width = 2,
402         },
403         .chip_parms = {
404                 /* FIXME: Need to use characterized value */
405                 .timing_default = {
406                         .timing0 = 0xA0400273,
407                         .timing1 = 0x00030402,
408                 },
409                 .timing_read = {
410                         .timing0 = 0xA0400273,
411                         .timing1 = 0x00030402,
412                 },
413         },
414 };
415
416 static void p1852_nor_init(void)
417 {
418         tegra_nor_device.resource[2].end = TEGRA_NOR_FLASH_BASE + SZ_64M - 1;
419         tegra_nor_device.dev.platform_data = &p1852_nor_data;
420         platform_device_register(&tegra_nor_device);
421 }
422
423 static void __init tegra_p1852_init(void)
424 {
425         tegra_init_board_info();
426         tegra_clk_init_from_table(p1852_clk_init_table);
427         tegra_enable_pinmux();
428         p1852_pinmux_init();
429         p1852_i2c_init();
430         p1852_i2s_audio_init();
431         p1852_gpio_init();
432         p1852_uart_init();
433         p1852_usb_init();
434         p1852_sdhci_init();
435         p1852_spi_init();
436         platform_add_devices(p1852_devices, ARRAY_SIZE(p1852_devices));
437         p1852_panel_init();
438         p1852_nor_init();
439         p1852_pcie_init();
440 }
441
442 static void __init tegra_p1852_reserve(void)
443 {
444 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
445         tegra_reserve(0, SZ_8M, 0);
446 #else
447         tegra_reserve(SZ_128M, SZ_8M, 0);
448 #endif
449 }
450
451 MACHINE_START(P1852, "p1852")
452         .boot_params    = 0x80000100,
453         .init_irq       = tegra_init_irq,
454         .init_early     = tegra_init_early,
455         .init_machine   = tegra_p1852_init,
456         .map_io         = tegra_map_common_io,
457         .reserve        = tegra_p1852_reserve,
458         .timer          = &tegra_timer,
459 MACHINE_END