2 * Copyright (C) 2010,2011 Google, Inc.
5 * Colin Cross <ccross@android.com>
6 * Erik Gilling <ccross@android.com>
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
20 #include <linux/resource.h>
21 #include <linux/platform_device.h>
22 #include <linux/dma-mapping.h>
23 #include <linux/fsl_devices.h>
24 #include <linux/serial_8250.h>
25 #include <linux/i2c-tegra.h>
26 #include <linux/platform_data/tegra_usb.h>
28 #include <mach/irqs.h>
29 #include <mach/iomap.h>
31 #include <mach/usb_phy.h>
33 #include "gpio-names.h"
36 static struct resource gpio_resource
[] = {
38 .start
= TEGRA_GPIO_BASE
,
39 .end
= TEGRA_GPIO_BASE
+ TEGRA_GPIO_SIZE
-1,
40 .flags
= IORESOURCE_MEM
,
45 .flags
= IORESOURCE_IRQ
,
50 .flags
= IORESOURCE_IRQ
,
55 .flags
= IORESOURCE_IRQ
,
60 .flags
= IORESOURCE_IRQ
,
65 .flags
= IORESOURCE_IRQ
,
70 .flags
= IORESOURCE_IRQ
,
75 .flags
= IORESOURCE_IRQ
,
79 struct platform_device tegra_gpio_device
= {
82 .resource
= gpio_resource
,
83 .num_resources
= ARRAY_SIZE(gpio_resource
),
86 static struct resource pinmux_resource
[] = {
88 /* Tri-state registers */
89 .start
= TEGRA_APB_MISC_BASE
+ 0x14,
90 .end
= TEGRA_APB_MISC_BASE
+ 0x20 + 3,
91 .flags
= IORESOURCE_MEM
,
95 .start
= TEGRA_APB_MISC_BASE
+ 0x80,
96 .end
= TEGRA_APB_MISC_BASE
+ 0x9c + 3,
97 .flags
= IORESOURCE_MEM
,
100 /* Pull-up/down registers */
101 .start
= TEGRA_APB_MISC_BASE
+ 0xa0,
102 .end
= TEGRA_APB_MISC_BASE
+ 0xb0 + 3,
103 .flags
= IORESOURCE_MEM
,
106 /* Pad control registers */
107 .start
= TEGRA_APB_MISC_BASE
+ 0x868,
108 .end
= TEGRA_APB_MISC_BASE
+ 0x90c + 3,
109 .flags
= IORESOURCE_MEM
,
113 struct platform_device tegra_pinmux_device
= {
114 .name
= "tegra-pinmux",
116 .resource
= pinmux_resource
,
117 .num_resources
= ARRAY_SIZE(pinmux_resource
),
120 static struct resource i2c_resource1
[] = {
124 .flags
= IORESOURCE_IRQ
,
127 .start
= TEGRA_I2C_BASE
,
128 .end
= TEGRA_I2C_BASE
+ TEGRA_I2C_SIZE
-1,
129 .flags
= IORESOURCE_MEM
,
133 static struct resource i2c_resource2
[] = {
137 .flags
= IORESOURCE_IRQ
,
140 .start
= TEGRA_I2C2_BASE
,
141 .end
= TEGRA_I2C2_BASE
+ TEGRA_I2C2_SIZE
-1,
142 .flags
= IORESOURCE_MEM
,
146 static struct resource i2c_resource3
[] = {
150 .flags
= IORESOURCE_IRQ
,
153 .start
= TEGRA_I2C3_BASE
,
154 .end
= TEGRA_I2C3_BASE
+ TEGRA_I2C3_SIZE
-1,
155 .flags
= IORESOURCE_MEM
,
159 static struct resource i2c_resource4
[] = {
163 .flags
= IORESOURCE_IRQ
,
166 .start
= TEGRA_DVC_BASE
,
167 .end
= TEGRA_DVC_BASE
+ TEGRA_DVC_SIZE
-1,
168 .flags
= IORESOURCE_MEM
,
172 static struct tegra_i2c_platform_data tegra_i2c1_platform_data
= {
173 .bus_clk_rate
= 400000,
176 static struct tegra_i2c_platform_data tegra_i2c2_platform_data
= {
177 .bus_clk_rate
= 400000,
180 static struct tegra_i2c_platform_data tegra_i2c3_platform_data
= {
181 .bus_clk_rate
= 400000,
184 static struct tegra_i2c_platform_data tegra_dvc_platform_data
= {
185 .bus_clk_rate
= 400000,
188 struct platform_device tegra_i2c_device1
= {
191 .resource
= i2c_resource1
,
192 .num_resources
= ARRAY_SIZE(i2c_resource1
),
194 .platform_data
= &tegra_i2c1_platform_data
,
198 struct platform_device tegra_i2c_device2
= {
201 .resource
= i2c_resource2
,
202 .num_resources
= ARRAY_SIZE(i2c_resource2
),
204 .platform_data
= &tegra_i2c2_platform_data
,
208 struct platform_device tegra_i2c_device3
= {
211 .resource
= i2c_resource3
,
212 .num_resources
= ARRAY_SIZE(i2c_resource3
),
214 .platform_data
= &tegra_i2c3_platform_data
,
218 struct platform_device tegra_i2c_device4
= {
221 .resource
= i2c_resource4
,
222 .num_resources
= ARRAY_SIZE(i2c_resource4
),
224 .platform_data
= &tegra_dvc_platform_data
,
228 static struct resource spi_resource1
[] = {
230 .start
= INT_S_LINK1
,
232 .flags
= IORESOURCE_IRQ
,
235 .start
= TEGRA_SPI1_BASE
,
236 .end
= TEGRA_SPI1_BASE
+ TEGRA_SPI1_SIZE
-1,
237 .flags
= IORESOURCE_MEM
,
241 static struct resource spi_resource2
[] = {
245 .flags
= IORESOURCE_IRQ
,
248 .start
= TEGRA_SPI2_BASE
,
249 .end
= TEGRA_SPI2_BASE
+ TEGRA_SPI2_SIZE
-1,
250 .flags
= IORESOURCE_MEM
,
254 static struct resource spi_resource3
[] = {
258 .flags
= IORESOURCE_IRQ
,
261 .start
= TEGRA_SPI3_BASE
,
262 .end
= TEGRA_SPI3_BASE
+ TEGRA_SPI3_SIZE
-1,
263 .flags
= IORESOURCE_MEM
,
267 static struct resource spi_resource4
[] = {
271 .flags
= IORESOURCE_IRQ
,
274 .start
= TEGRA_SPI4_BASE
,
275 .end
= TEGRA_SPI4_BASE
+ TEGRA_SPI4_SIZE
-1,
276 .flags
= IORESOURCE_MEM
,
280 struct platform_device tegra_spi_device1
= {
283 .resource
= spi_resource1
,
284 .num_resources
= ARRAY_SIZE(spi_resource1
),
286 .coherent_dma_mask
= 0xffffffff,
290 struct platform_device tegra_spi_device2
= {
293 .resource
= spi_resource2
,
294 .num_resources
= ARRAY_SIZE(spi_resource2
),
296 .coherent_dma_mask
= 0xffffffff,
300 struct platform_device tegra_spi_device3
= {
303 .resource
= spi_resource3
,
304 .num_resources
= ARRAY_SIZE(spi_resource3
),
306 .coherent_dma_mask
= 0xffffffff,
310 struct platform_device tegra_spi_device4
= {
313 .resource
= spi_resource4
,
314 .num_resources
= ARRAY_SIZE(spi_resource4
),
316 .coherent_dma_mask
= 0xffffffff,
321 static struct resource sdhci_resource1
[] = {
325 .flags
= IORESOURCE_IRQ
,
328 .start
= TEGRA_SDMMC1_BASE
,
329 .end
= TEGRA_SDMMC1_BASE
+ TEGRA_SDMMC1_SIZE
-1,
330 .flags
= IORESOURCE_MEM
,
334 static struct resource sdhci_resource2
[] = {
338 .flags
= IORESOURCE_IRQ
,
341 .start
= TEGRA_SDMMC2_BASE
,
342 .end
= TEGRA_SDMMC2_BASE
+ TEGRA_SDMMC2_SIZE
-1,
343 .flags
= IORESOURCE_MEM
,
347 static struct resource sdhci_resource3
[] = {
351 .flags
= IORESOURCE_IRQ
,
354 .start
= TEGRA_SDMMC3_BASE
,
355 .end
= TEGRA_SDMMC3_BASE
+ TEGRA_SDMMC3_SIZE
-1,
356 .flags
= IORESOURCE_MEM
,
360 static struct resource sdhci_resource4
[] = {
364 .flags
= IORESOURCE_IRQ
,
367 .start
= TEGRA_SDMMC4_BASE
,
368 .end
= TEGRA_SDMMC4_BASE
+ TEGRA_SDMMC4_SIZE
-1,
369 .flags
= IORESOURCE_MEM
,
373 /* board files should fill in platform_data register the devices themselvs.
374 * See board-harmony.c for an example
376 struct platform_device tegra_sdhci_device1
= {
377 .name
= "sdhci-tegra",
379 .resource
= sdhci_resource1
,
380 .num_resources
= ARRAY_SIZE(sdhci_resource1
),
383 struct platform_device tegra_sdhci_device2
= {
384 .name
= "sdhci-tegra",
386 .resource
= sdhci_resource2
,
387 .num_resources
= ARRAY_SIZE(sdhci_resource2
),
390 struct platform_device tegra_sdhci_device3
= {
391 .name
= "sdhci-tegra",
393 .resource
= sdhci_resource3
,
394 .num_resources
= ARRAY_SIZE(sdhci_resource3
),
397 struct platform_device tegra_sdhci_device4
= {
398 .name
= "sdhci-tegra",
400 .resource
= sdhci_resource4
,
401 .num_resources
= ARRAY_SIZE(sdhci_resource4
),
404 static struct resource tegra_usb1_resources
[] = {
406 .start
= TEGRA_USB_BASE
,
407 .end
= TEGRA_USB_BASE
+ TEGRA_USB_SIZE
- 1,
408 .flags
= IORESOURCE_MEM
,
413 .flags
= IORESOURCE_IRQ
,
417 static struct resource tegra_usb2_resources
[] = {
419 .start
= TEGRA_USB2_BASE
,
420 .end
= TEGRA_USB2_BASE
+ TEGRA_USB2_SIZE
- 1,
421 .flags
= IORESOURCE_MEM
,
426 .flags
= IORESOURCE_IRQ
,
430 static struct resource tegra_usb3_resources
[] = {
432 .start
= TEGRA_USB3_BASE
,
433 .end
= TEGRA_USB3_BASE
+ TEGRA_USB3_SIZE
- 1,
434 .flags
= IORESOURCE_MEM
,
439 .flags
= IORESOURCE_IRQ
,
443 static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config
= {
444 /* All existing boards use GPIO PV0 for phy reset */
445 .reset_gpio
= TEGRA_GPIO_PV0
,
449 static struct tegra_ehci_platform_data tegra_ehci1_pdata
= {
450 .operating_mode
= TEGRA_USB_OTG
,
451 .power_down_on_bus_suspend
= 1,
454 static struct tegra_ehci_platform_data tegra_ehci2_pdata
= {
455 .phy_config
= &tegra_ehci2_ulpi_phy_config
,
456 .operating_mode
= TEGRA_USB_HOST
,
457 .power_down_on_bus_suspend
= 1,
460 static struct tegra_ehci_platform_data tegra_ehci3_pdata
= {
461 .operating_mode
= TEGRA_USB_HOST
,
462 .power_down_on_bus_suspend
= 1,
465 static u64 tegra_ehci_dmamask
= DMA_BIT_MASK(32);
467 struct platform_device tegra_ehci1_device
= {
468 .name
= "tegra-ehci",
471 .dma_mask
= &tegra_ehci_dmamask
,
472 .coherent_dma_mask
= DMA_BIT_MASK(32),
473 .platform_data
= &tegra_ehci1_pdata
,
475 .resource
= tegra_usb1_resources
,
476 .num_resources
= ARRAY_SIZE(tegra_usb1_resources
),
479 struct platform_device tegra_ehci2_device
= {
480 .name
= "tegra-ehci",
483 .dma_mask
= &tegra_ehci_dmamask
,
484 .coherent_dma_mask
= DMA_BIT_MASK(32),
485 .platform_data
= &tegra_ehci2_pdata
,
487 .resource
= tegra_usb2_resources
,
488 .num_resources
= ARRAY_SIZE(tegra_usb2_resources
),
491 struct platform_device tegra_ehci3_device
= {
492 .name
= "tegra-ehci",
495 .dma_mask
= &tegra_ehci_dmamask
,
496 .coherent_dma_mask
= DMA_BIT_MASK(32),
497 .platform_data
= &tegra_ehci3_pdata
,
499 .resource
= tegra_usb3_resources
,
500 .num_resources
= ARRAY_SIZE(tegra_usb3_resources
),
503 static struct resource tegra_pmu_resources
[] = {
505 .start
= INT_CPU0_PMU_INTR
,
506 .end
= INT_CPU0_PMU_INTR
,
507 .flags
= IORESOURCE_IRQ
,
510 .start
= INT_CPU1_PMU_INTR
,
511 .end
= INT_CPU1_PMU_INTR
,
512 .flags
= IORESOURCE_IRQ
,
516 struct platform_device tegra_pmu_device
= {
518 .id
= ARM_PMU_DEVICE_CPU
,
519 .num_resources
= ARRAY_SIZE(tegra_pmu_resources
),
520 .resource
= tegra_pmu_resources
,
523 static struct resource tegra_uarta_resources
[] = {
525 .start
= TEGRA_UARTA_BASE
,
526 .end
= TEGRA_UARTA_BASE
+ TEGRA_UARTA_SIZE
- 1,
527 .flags
= IORESOURCE_MEM
,
532 .flags
= IORESOURCE_IRQ
,
536 static struct resource tegra_uartb_resources
[] = {
538 .start
= TEGRA_UARTB_BASE
,
539 .end
= TEGRA_UARTB_BASE
+ TEGRA_UARTB_SIZE
- 1,
540 .flags
= IORESOURCE_MEM
,
545 .flags
= IORESOURCE_IRQ
,
549 static struct resource tegra_uartc_resources
[] = {
551 .start
= TEGRA_UARTC_BASE
,
552 .end
= TEGRA_UARTC_BASE
+ TEGRA_UARTC_SIZE
- 1,
553 .flags
= IORESOURCE_MEM
,
558 .flags
= IORESOURCE_IRQ
,
562 static struct resource tegra_uartd_resources
[] = {
564 .start
= TEGRA_UARTD_BASE
,
565 .end
= TEGRA_UARTD_BASE
+ TEGRA_UARTD_SIZE
- 1,
566 .flags
= IORESOURCE_MEM
,
571 .flags
= IORESOURCE_IRQ
,
575 static struct resource tegra_uarte_resources
[] = {
577 .start
= TEGRA_UARTE_BASE
,
578 .end
= TEGRA_UARTE_BASE
+ TEGRA_UARTE_SIZE
- 1,
579 .flags
= IORESOURCE_MEM
,
584 .flags
= IORESOURCE_IRQ
,
588 struct platform_device tegra_uarta_device
= {
589 .name
= "tegra_uart",
591 .num_resources
= ARRAY_SIZE(tegra_uarta_resources
),
592 .resource
= tegra_uarta_resources
,
594 .coherent_dma_mask
= DMA_BIT_MASK(32),
598 struct platform_device tegra_uartb_device
= {
599 .name
= "tegra_uart",
601 .num_resources
= ARRAY_SIZE(tegra_uartb_resources
),
602 .resource
= tegra_uartb_resources
,
604 .coherent_dma_mask
= DMA_BIT_MASK(32),
608 struct platform_device tegra_uartc_device
= {
609 .name
= "tegra_uart",
611 .num_resources
= ARRAY_SIZE(tegra_uartc_resources
),
612 .resource
= tegra_uartc_resources
,
614 .coherent_dma_mask
= DMA_BIT_MASK(32),
618 struct platform_device tegra_uartd_device
= {
619 .name
= "tegra_uart",
621 .num_resources
= ARRAY_SIZE(tegra_uartd_resources
),
622 .resource
= tegra_uartd_resources
,
624 .coherent_dma_mask
= DMA_BIT_MASK(32),
628 struct platform_device tegra_uarte_device
= {
629 .name
= "tegra_uart",
631 .num_resources
= ARRAY_SIZE(tegra_uarte_resources
),
632 .resource
= tegra_uarte_resources
,
634 .coherent_dma_mask
= DMA_BIT_MASK(32),
638 static struct resource i2s_resource1
[] = {
642 .flags
= IORESOURCE_IRQ
645 .start
= TEGRA_DMA_REQ_SEL_I2S_1
,
646 .end
= TEGRA_DMA_REQ_SEL_I2S_1
,
647 .flags
= IORESOURCE_DMA
650 .start
= TEGRA_I2S1_BASE
,
651 .end
= TEGRA_I2S1_BASE
+ TEGRA_I2S1_SIZE
- 1,
652 .flags
= IORESOURCE_MEM
656 static struct resource i2s_resource2
[] = {
660 .flags
= IORESOURCE_IRQ
663 .start
= TEGRA_DMA_REQ_SEL_I2S2_1
,
664 .end
= TEGRA_DMA_REQ_SEL_I2S2_1
,
665 .flags
= IORESOURCE_DMA
668 .start
= TEGRA_I2S2_BASE
,
669 .end
= TEGRA_I2S2_BASE
+ TEGRA_I2S2_SIZE
- 1,
670 .flags
= IORESOURCE_MEM
674 struct platform_device tegra_i2s_device1
= {
677 .resource
= i2s_resource1
,
678 .num_resources
= ARRAY_SIZE(i2s_resource1
),
681 struct platform_device tegra_i2s_device2
= {
684 .resource
= i2s_resource2
,
685 .num_resources
= ARRAY_SIZE(i2s_resource2
),
688 static struct resource tegra_das_resources
[] = {
690 .start
= TEGRA_APB_MISC_DAS_BASE
,
691 .end
= TEGRA_APB_MISC_DAS_BASE
+ TEGRA_APB_MISC_DAS_SIZE
- 1,
692 .flags
= IORESOURCE_MEM
,
696 struct platform_device tegra_das_device
= {
699 .num_resources
= ARRAY_SIZE(tegra_das_resources
),
700 .resource
= tegra_das_resources
,
703 struct platform_device tegra_pcm_device
= {
704 .name
= "tegra-pcm-audio",