diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /arch/arm/mach-at91/at91sam9g45_devices.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'arch/arm/mach-at91/at91sam9g45_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9g45_devices.c | 618 |
1 files changed, 115 insertions, 503 deletions
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index 827c9f2a70f..371bb0ecb0d 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c | |||
@@ -13,31 +13,22 @@ | |||
13 | #include <asm/mach/map.h> | 13 | #include <asm/mach/map.h> |
14 | 14 | ||
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/gpio.h> | ||
17 | #include <linux/clk.h> | ||
18 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
19 | #include <linux/i2c-gpio.h> | 17 | #include <linux/i2c-gpio.h> |
20 | #include <linux/atmel-mci.h> | 18 | #include <linux/atmel-mci.h> |
21 | #include <linux/platform_data/atmel-aes.h> | ||
22 | |||
23 | #include <linux/platform_data/at91_adc.h> | ||
24 | 19 | ||
25 | #include <linux/fb.h> | 20 | #include <linux/fb.h> |
26 | #include <video/atmel_lcdc.h> | 21 | #include <video/atmel_lcdc.h> |
27 | 22 | ||
28 | #include <mach/at91_adc.h> | 23 | #include <mach/board.h> |
24 | #include <mach/gpio.h> | ||
29 | #include <mach/at91sam9g45.h> | 25 | #include <mach/at91sam9g45.h> |
30 | #include <mach/at91sam9g45_matrix.h> | 26 | #include <mach/at91sam9g45_matrix.h> |
31 | #include <mach/at91_matrix.h> | ||
32 | #include <mach/at91sam9_smc.h> | 27 | #include <mach/at91sam9_smc.h> |
33 | #include <linux/platform_data/dma-atmel.h> | 28 | #include <mach/at_hdmac.h> |
34 | #include <mach/atmel-mci.h> | 29 | #include <mach/atmel-mci.h> |
35 | 30 | ||
36 | #include <media/atmel-isi.h> | ||
37 | |||
38 | #include "board.h" | ||
39 | #include "generic.h" | 31 | #include "generic.h" |
40 | #include "clock.h" | ||
41 | 32 | ||
42 | 33 | ||
43 | /* -------------------------------------------------------------------- | 34 | /* -------------------------------------------------------------------- |
@@ -47,25 +38,30 @@ | |||
47 | #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE) | 38 | #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE) |
48 | static u64 hdmac_dmamask = DMA_BIT_MASK(32); | 39 | static u64 hdmac_dmamask = DMA_BIT_MASK(32); |
49 | 40 | ||
41 | static struct at_dma_platform_data atdma_pdata = { | ||
42 | .nr_channels = 8, | ||
43 | }; | ||
44 | |||
50 | static struct resource hdmac_resources[] = { | 45 | static struct resource hdmac_resources[] = { |
51 | [0] = { | 46 | [0] = { |
52 | .start = AT91SAM9G45_BASE_DMA, | 47 | .start = AT91_BASE_SYS + AT91_DMA, |
53 | .end = AT91SAM9G45_BASE_DMA + SZ_512 - 1, | 48 | .end = AT91_BASE_SYS + AT91_DMA + SZ_512 - 1, |
54 | .flags = IORESOURCE_MEM, | 49 | .flags = IORESOURCE_MEM, |
55 | }, | 50 | }, |
56 | [1] = { | 51 | [1] = { |
57 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA, | 52 | .start = AT91SAM9G45_ID_DMA, |
58 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA, | 53 | .end = AT91SAM9G45_ID_DMA, |
59 | .flags = IORESOURCE_IRQ, | 54 | .flags = IORESOURCE_IRQ, |
60 | }, | 55 | }, |
61 | }; | 56 | }; |
62 | 57 | ||
63 | static struct platform_device at_hdmac_device = { | 58 | static struct platform_device at_hdmac_device = { |
64 | .name = "at91sam9g45_dma", | 59 | .name = "at_hdmac", |
65 | .id = -1, | 60 | .id = -1, |
66 | .dev = { | 61 | .dev = { |
67 | .dma_mask = &hdmac_dmamask, | 62 | .dma_mask = &hdmac_dmamask, |
68 | .coherent_dma_mask = DMA_BIT_MASK(32), | 63 | .coherent_dma_mask = DMA_BIT_MASK(32), |
64 | .platform_data = &atdma_pdata, | ||
69 | }, | 65 | }, |
70 | .resource = hdmac_resources, | 66 | .resource = hdmac_resources, |
71 | .num_resources = ARRAY_SIZE(hdmac_resources), | 67 | .num_resources = ARRAY_SIZE(hdmac_resources), |
@@ -73,6 +69,8 @@ static struct platform_device at_hdmac_device = { | |||
73 | 69 | ||
74 | void __init at91_add_device_hdmac(void) | 70 | void __init at91_add_device_hdmac(void) |
75 | { | 71 | { |
72 | dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask); | ||
73 | dma_cap_set(DMA_SLAVE, atdma_pdata.cap_mask); | ||
76 | platform_device_register(&at_hdmac_device); | 74 | platform_device_register(&at_hdmac_device); |
77 | } | 75 | } |
78 | #else | 76 | #else |
@@ -95,8 +93,8 @@ static struct resource usbh_ohci_resources[] = { | |||
95 | .flags = IORESOURCE_MEM, | 93 | .flags = IORESOURCE_MEM, |
96 | }, | 94 | }, |
97 | [1] = { | 95 | [1] = { |
98 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, | 96 | .start = AT91SAM9G45_ID_UHPHS, |
99 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, | 97 | .end = AT91SAM9G45_ID_UHPHS, |
100 | .flags = IORESOURCE_IRQ, | 98 | .flags = IORESOURCE_IRQ, |
101 | }, | 99 | }, |
102 | }; | 100 | }; |
@@ -122,15 +120,8 @@ void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) | |||
122 | 120 | ||
123 | /* Enable VBus control for UHP ports */ | 121 | /* Enable VBus control for UHP ports */ |
124 | for (i = 0; i < data->ports; i++) { | 122 | for (i = 0; i < data->ports; i++) { |
125 | if (gpio_is_valid(data->vbus_pin[i])) | 123 | if (data->vbus_pin[i]) |
126 | at91_set_gpio_output(data->vbus_pin[i], | 124 | at91_set_gpio_output(data->vbus_pin[i], 0); |
127 | data->vbus_pin_active_low[i]); | ||
128 | } | ||
129 | |||
130 | /* Enable overcurrent notification */ | ||
131 | for (i = 0; i < data->ports; i++) { | ||
132 | if (gpio_is_valid(data->overcurrent_pin[i])) | ||
133 | at91_set_gpio_input(data->overcurrent_pin[i], 1); | ||
134 | } | 125 | } |
135 | 126 | ||
136 | usbh_ohci_data = *data; | 127 | usbh_ohci_data = *data; |
@@ -157,8 +148,8 @@ static struct resource usbh_ehci_resources[] = { | |||
157 | .flags = IORESOURCE_MEM, | 148 | .flags = IORESOURCE_MEM, |
158 | }, | 149 | }, |
159 | [1] = { | 150 | [1] = { |
160 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, | 151 | .start = AT91SAM9G45_ID_UHPHS, |
161 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, | 152 | .end = AT91SAM9G45_ID_UHPHS, |
162 | .flags = IORESOURCE_IRQ, | 153 | .flags = IORESOURCE_IRQ, |
163 | }, | 154 | }, |
164 | }; | 155 | }; |
@@ -184,9 +175,8 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) | |||
184 | 175 | ||
185 | /* Enable VBus control for UHP ports */ | 176 | /* Enable VBus control for UHP ports */ |
186 | for (i = 0; i < data->ports; i++) { | 177 | for (i = 0; i < data->ports; i++) { |
187 | if (gpio_is_valid(data->vbus_pin[i])) | 178 | if (data->vbus_pin[i]) |
188 | at91_set_gpio_output(data->vbus_pin[i], | 179 | at91_set_gpio_output(data->vbus_pin[i], 0); |
189 | data->vbus_pin_active_low[i]); | ||
190 | } | 180 | } |
191 | 181 | ||
192 | usbh_ehci_data = *data; | 182 | usbh_ehci_data = *data; |
@@ -214,8 +204,8 @@ static struct resource usba_udc_resources[] = { | |||
214 | .flags = IORESOURCE_MEM, | 204 | .flags = IORESOURCE_MEM, |
215 | }, | 205 | }, |
216 | [2] = { | 206 | [2] = { |
217 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS, | 207 | .start = AT91SAM9G45_ID_UDPHS, |
218 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS, | 208 | .end = AT91SAM9G45_ID_UDPHS, |
219 | .flags = IORESOURCE_IRQ, | 209 | .flags = IORESOURCE_IRQ, |
220 | }, | 210 | }, |
221 | }; | 211 | }; |
@@ -267,7 +257,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data) | |||
267 | usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); | 257 | usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); |
268 | memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep)); | 258 | memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep)); |
269 | 259 | ||
270 | if (data && gpio_is_valid(data->vbus_pin)) { | 260 | if (data && data->vbus_pin > 0) { |
271 | at91_set_gpio_input(data->vbus_pin, 0); | 261 | at91_set_gpio_input(data->vbus_pin, 0); |
272 | at91_set_deglitch(data->vbus_pin, 1); | 262 | at91_set_deglitch(data->vbus_pin, 1); |
273 | usba_udc_data.pdata.vbus_pin = data->vbus_pin; | 263 | usba_udc_data.pdata.vbus_pin = data->vbus_pin; |
@@ -288,7 +278,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {} | |||
288 | 278 | ||
289 | #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) | 279 | #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) |
290 | static u64 eth_dmamask = DMA_BIT_MASK(32); | 280 | static u64 eth_dmamask = DMA_BIT_MASK(32); |
291 | static struct macb_platform_data eth_data; | 281 | static struct at91_eth_data eth_data; |
292 | 282 | ||
293 | static struct resource eth_resources[] = { | 283 | static struct resource eth_resources[] = { |
294 | [0] = { | 284 | [0] = { |
@@ -297,8 +287,8 @@ static struct resource eth_resources[] = { | |||
297 | .flags = IORESOURCE_MEM, | 287 | .flags = IORESOURCE_MEM, |
298 | }, | 288 | }, |
299 | [1] = { | 289 | [1] = { |
300 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC, | 290 | .start = AT91SAM9G45_ID_EMAC, |
301 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC, | 291 | .end = AT91SAM9G45_ID_EMAC, |
302 | .flags = IORESOURCE_IRQ, | 292 | .flags = IORESOURCE_IRQ, |
303 | }, | 293 | }, |
304 | }; | 294 | }; |
@@ -315,12 +305,12 @@ static struct platform_device at91sam9g45_eth_device = { | |||
315 | .num_resources = ARRAY_SIZE(eth_resources), | 305 | .num_resources = ARRAY_SIZE(eth_resources), |
316 | }; | 306 | }; |
317 | 307 | ||
318 | void __init at91_add_device_eth(struct macb_platform_data *data) | 308 | void __init at91_add_device_eth(struct at91_eth_data *data) |
319 | { | 309 | { |
320 | if (!data) | 310 | if (!data) |
321 | return; | 311 | return; |
322 | 312 | ||
323 | if (gpio_is_valid(data->phy_irq_pin)) { | 313 | if (data->phy_irq_pin) { |
324 | at91_set_gpio_input(data->phy_irq_pin, 0); | 314 | at91_set_gpio_input(data->phy_irq_pin, 0); |
325 | at91_set_deglitch(data->phy_irq_pin, 1); | 315 | at91_set_deglitch(data->phy_irq_pin, 1); |
326 | } | 316 | } |
@@ -352,7 +342,7 @@ void __init at91_add_device_eth(struct macb_platform_data *data) | |||
352 | platform_device_register(&at91sam9g45_eth_device); | 342 | platform_device_register(&at91sam9g45_eth_device); |
353 | } | 343 | } |
354 | #else | 344 | #else |
355 | void __init at91_add_device_eth(struct macb_platform_data *data) {} | 345 | void __init at91_add_device_eth(struct at91_eth_data *data) {} |
356 | #endif | 346 | #endif |
357 | 347 | ||
358 | 348 | ||
@@ -371,8 +361,8 @@ static struct resource mmc0_resources[] = { | |||
371 | .flags = IORESOURCE_MEM, | 361 | .flags = IORESOURCE_MEM, |
372 | }, | 362 | }, |
373 | [1] = { | 363 | [1] = { |
374 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0, | 364 | .start = AT91SAM9G45_ID_MCI0, |
375 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0, | 365 | .end = AT91SAM9G45_ID_MCI0, |
376 | .flags = IORESOURCE_IRQ, | 366 | .flags = IORESOURCE_IRQ, |
377 | }, | 367 | }, |
378 | }; | 368 | }; |
@@ -396,8 +386,8 @@ static struct resource mmc1_resources[] = { | |||
396 | .flags = IORESOURCE_MEM, | 386 | .flags = IORESOURCE_MEM, |
397 | }, | 387 | }, |
398 | [1] = { | 388 | [1] = { |
399 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1, | 389 | .start = AT91SAM9G45_ID_MCI1, |
400 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1, | 390 | .end = AT91SAM9G45_ID_MCI1, |
401 | .flags = IORESOURCE_IRQ, | 391 | .flags = IORESOURCE_IRQ, |
402 | }, | 392 | }, |
403 | }; | 393 | }; |
@@ -435,8 +425,10 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) | |||
435 | 425 | ||
436 | /* DMA slave channel configuration */ | 426 | /* DMA slave channel configuration */ |
437 | atslave->dma_dev = &at_hdmac_device.dev; | 427 | atslave->dma_dev = &at_hdmac_device.dev; |
428 | atslave->reg_width = AT_DMA_SLAVE_WIDTH_32BIT; | ||
438 | atslave->cfg = ATC_FIFOCFG_HALFFIFO | 429 | atslave->cfg = ATC_FIFOCFG_HALFFIFO |
439 | | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW; | 430 | | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW; |
431 | atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16; | ||
440 | if (mmc_id == 0) /* MCI0 */ | 432 | if (mmc_id == 0) /* MCI0 */ |
441 | atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0) | 433 | atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0) |
442 | | ATC_DST_PER(AT_DMA_ID_MCI0); | 434 | | ATC_DST_PER(AT_DMA_ID_MCI0); |
@@ -451,11 +443,11 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) | |||
451 | 443 | ||
452 | 444 | ||
453 | /* input/irq */ | 445 | /* input/irq */ |
454 | if (gpio_is_valid(data->slot[0].detect_pin)) { | 446 | if (data->slot[0].detect_pin) { |
455 | at91_set_gpio_input(data->slot[0].detect_pin, 1); | 447 | at91_set_gpio_input(data->slot[0].detect_pin, 1); |
456 | at91_set_deglitch(data->slot[0].detect_pin, 1); | 448 | at91_set_deglitch(data->slot[0].detect_pin, 1); |
457 | } | 449 | } |
458 | if (gpio_is_valid(data->slot[0].wp_pin)) | 450 | if (data->slot[0].wp_pin) |
459 | at91_set_gpio_input(data->slot[0].wp_pin, 1); | 451 | at91_set_gpio_input(data->slot[0].wp_pin, 1); |
460 | 452 | ||
461 | if (mmc_id == 0) { /* MCI0 */ | 453 | if (mmc_id == 0) { /* MCI0 */ |
@@ -531,8 +523,8 @@ static struct resource nand_resources[] = { | |||
531 | .flags = IORESOURCE_MEM, | 523 | .flags = IORESOURCE_MEM, |
532 | }, | 524 | }, |
533 | [1] = { | 525 | [1] = { |
534 | .start = AT91SAM9G45_BASE_ECC, | 526 | .start = AT91_BASE_SYS + AT91_ECC, |
535 | .end = AT91SAM9G45_BASE_ECC + SZ_512 - 1, | 527 | .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1, |
536 | .flags = IORESOURCE_MEM, | 528 | .flags = IORESOURCE_MEM, |
537 | } | 529 | } |
538 | }; | 530 | }; |
@@ -554,19 +546,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data) | |||
554 | if (!data) | 546 | if (!data) |
555 | return; | 547 | return; |
556 | 548 | ||
557 | csa = at91_matrix_read(AT91_MATRIX_EBICSA); | 549 | csa = at91_sys_read(AT91_MATRIX_EBICSA); |
558 | at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); | 550 | at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); |
559 | 551 | ||
560 | /* enable pin */ | 552 | /* enable pin */ |
561 | if (gpio_is_valid(data->enable_pin)) | 553 | if (data->enable_pin) |
562 | at91_set_gpio_output(data->enable_pin, 1); | 554 | at91_set_gpio_output(data->enable_pin, 1); |
563 | 555 | ||
564 | /* ready/busy pin */ | 556 | /* ready/busy pin */ |
565 | if (gpio_is_valid(data->rdy_pin)) | 557 | if (data->rdy_pin) |
566 | at91_set_gpio_input(data->rdy_pin, 1); | 558 | at91_set_gpio_input(data->rdy_pin, 1); |
567 | 559 | ||
568 | /* card detect pin */ | 560 | /* card detect pin */ |
569 | if (gpio_is_valid(data->det_pin)) | 561 | if (data->det_pin) |
570 | at91_set_gpio_input(data->det_pin, 1); | 562 | at91_set_gpio_input(data->det_pin, 1); |
571 | 563 | ||
572 | nand_data = *data; | 564 | nand_data = *data; |
@@ -646,14 +638,14 @@ static struct resource twi0_resources[] = { | |||
646 | .flags = IORESOURCE_MEM, | 638 | .flags = IORESOURCE_MEM, |
647 | }, | 639 | }, |
648 | [1] = { | 640 | [1] = { |
649 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0, | 641 | .start = AT91SAM9G45_ID_TWI0, |
650 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0, | 642 | .end = AT91SAM9G45_ID_TWI0, |
651 | .flags = IORESOURCE_IRQ, | 643 | .flags = IORESOURCE_IRQ, |
652 | }, | 644 | }, |
653 | }; | 645 | }; |
654 | 646 | ||
655 | static struct platform_device at91sam9g45_twi0_device = { | 647 | static struct platform_device at91sam9g45_twi0_device = { |
656 | .name = "i2c-at91sam9g10", | 648 | .name = "at91_i2c", |
657 | .id = 0, | 649 | .id = 0, |
658 | .resource = twi0_resources, | 650 | .resource = twi0_resources, |
659 | .num_resources = ARRAY_SIZE(twi0_resources), | 651 | .num_resources = ARRAY_SIZE(twi0_resources), |
@@ -666,14 +658,14 @@ static struct resource twi1_resources[] = { | |||
666 | .flags = IORESOURCE_MEM, | 658 | .flags = IORESOURCE_MEM, |
667 | }, | 659 | }, |
668 | [1] = { | 660 | [1] = { |
669 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1, | 661 | .start = AT91SAM9G45_ID_TWI1, |
670 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1, | 662 | .end = AT91SAM9G45_ID_TWI1, |
671 | .flags = IORESOURCE_IRQ, | 663 | .flags = IORESOURCE_IRQ, |
672 | }, | 664 | }, |
673 | }; | 665 | }; |
674 | 666 | ||
675 | static struct platform_device at91sam9g45_twi1_device = { | 667 | static struct platform_device at91sam9g45_twi1_device = { |
676 | .name = "i2c-at91sam9g10", | 668 | .name = "at91_i2c", |
677 | .id = 1, | 669 | .id = 1, |
678 | .resource = twi1_resources, | 670 | .resource = twi1_resources, |
679 | .num_resources = ARRAY_SIZE(twi1_resources), | 671 | .num_resources = ARRAY_SIZE(twi1_resources), |
@@ -686,12 +678,18 @@ void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, in | |||
686 | /* pins used for TWI interface */ | 678 | /* pins used for TWI interface */ |
687 | if (i2c_id == 0) { | 679 | if (i2c_id == 0) { |
688 | at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */ | 680 | at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */ |
681 | at91_set_multi_drive(AT91_PIN_PA20, 1); | ||
682 | |||
689 | at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */ | 683 | at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */ |
684 | at91_set_multi_drive(AT91_PIN_PA21, 1); | ||
690 | 685 | ||
691 | platform_device_register(&at91sam9g45_twi0_device); | 686 | platform_device_register(&at91sam9g45_twi0_device); |
692 | } else { | 687 | } else { |
693 | at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */ | 688 | at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */ |
689 | at91_set_multi_drive(AT91_PIN_PB10, 1); | ||
690 | |||
694 | at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */ | 691 | at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */ |
692 | at91_set_multi_drive(AT91_PIN_PB11, 1); | ||
695 | 693 | ||
696 | platform_device_register(&at91sam9g45_twi1_device); | 694 | platform_device_register(&at91sam9g45_twi1_device); |
697 | } | 695 | } |
@@ -715,8 +713,8 @@ static struct resource spi0_resources[] = { | |||
715 | .flags = IORESOURCE_MEM, | 713 | .flags = IORESOURCE_MEM, |
716 | }, | 714 | }, |
717 | [1] = { | 715 | [1] = { |
718 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0, | 716 | .start = AT91SAM9G45_ID_SPI0, |
719 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0, | 717 | .end = AT91SAM9G45_ID_SPI0, |
720 | .flags = IORESOURCE_IRQ, | 718 | .flags = IORESOURCE_IRQ, |
721 | }, | 719 | }, |
722 | }; | 720 | }; |
@@ -741,8 +739,8 @@ static struct resource spi1_resources[] = { | |||
741 | .flags = IORESOURCE_MEM, | 739 | .flags = IORESOURCE_MEM, |
742 | }, | 740 | }, |
743 | [1] = { | 741 | [1] = { |
744 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1, | 742 | .start = AT91SAM9G45_ID_SPI1, |
745 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1, | 743 | .end = AT91SAM9G45_ID_SPI1, |
746 | .flags = IORESOURCE_IRQ, | 744 | .flags = IORESOURCE_IRQ, |
747 | }, | 745 | }, |
748 | }; | 746 | }; |
@@ -776,9 +774,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
776 | else | 774 | else |
777 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | 775 | cs_pin = spi1_standard_cs[devices[i].chip_select]; |
778 | 776 | ||
779 | if (!gpio_is_valid(cs_pin)) | ||
780 | continue; | ||
781 | |||
782 | if (devices[i].bus_num == 0) | 777 | if (devices[i].bus_num == 0) |
783 | enable_spi0 = 1; | 778 | enable_spi0 = 1; |
784 | else | 779 | else |
@@ -829,8 +824,8 @@ static struct resource ac97_resources[] = { | |||
829 | .flags = IORESOURCE_MEM, | 824 | .flags = IORESOURCE_MEM, |
830 | }, | 825 | }, |
831 | [1] = { | 826 | [1] = { |
832 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C, | 827 | .start = AT91SAM9G45_ID_AC97C, |
833 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C, | 828 | .end = AT91SAM9G45_ID_AC97C, |
834 | .flags = IORESOURCE_IRQ, | 829 | .flags = IORESOURCE_IRQ, |
835 | }, | 830 | }, |
836 | }; | 831 | }; |
@@ -858,7 +853,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data) | |||
858 | at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */ | 853 | at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */ |
859 | 854 | ||
860 | /* reset */ | 855 | /* reset */ |
861 | if (gpio_is_valid(data->reset_pin)) | 856 | if (data->reset_pin) |
862 | at91_set_gpio_output(data->reset_pin, 0); | 857 | at91_set_gpio_output(data->reset_pin, 0); |
863 | 858 | ||
864 | ac97_data = *data; | 859 | ac97_data = *data; |
@@ -868,96 +863,6 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data) | |||
868 | void __init at91_add_device_ac97(struct ac97c_platform_data *data) {} | 863 | void __init at91_add_device_ac97(struct ac97c_platform_data *data) {} |
869 | #endif | 864 | #endif |
870 | 865 | ||
871 | /* -------------------------------------------------------------------- | ||
872 | * Image Sensor Interface | ||
873 | * -------------------------------------------------------------------- */ | ||
874 | #if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE) | ||
875 | static u64 isi_dmamask = DMA_BIT_MASK(32); | ||
876 | static struct isi_platform_data isi_data; | ||
877 | |||
878 | struct resource isi_resources[] = { | ||
879 | [0] = { | ||
880 | .start = AT91SAM9G45_BASE_ISI, | ||
881 | .end = AT91SAM9G45_BASE_ISI + SZ_16K - 1, | ||
882 | .flags = IORESOURCE_MEM, | ||
883 | }, | ||
884 | [1] = { | ||
885 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI, | ||
886 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI, | ||
887 | .flags = IORESOURCE_IRQ, | ||
888 | }, | ||
889 | }; | ||
890 | |||
891 | static struct platform_device at91sam9g45_isi_device = { | ||
892 | .name = "atmel_isi", | ||
893 | .id = 0, | ||
894 | .dev = { | ||
895 | .dma_mask = &isi_dmamask, | ||
896 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
897 | .platform_data = &isi_data, | ||
898 | }, | ||
899 | .resource = isi_resources, | ||
900 | .num_resources = ARRAY_SIZE(isi_resources), | ||
901 | }; | ||
902 | |||
903 | static struct clk_lookup isi_mck_lookups[] = { | ||
904 | CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL), | ||
905 | }; | ||
906 | |||
907 | void __init at91_add_device_isi(struct isi_platform_data *data, | ||
908 | bool use_pck_as_mck) | ||
909 | { | ||
910 | struct clk *pck; | ||
911 | struct clk *parent; | ||
912 | |||
913 | if (!data) | ||
914 | return; | ||
915 | isi_data = *data; | ||
916 | |||
917 | at91_set_A_periph(AT91_PIN_PB20, 0); /* ISI_D0 */ | ||
918 | at91_set_A_periph(AT91_PIN_PB21, 0); /* ISI_D1 */ | ||
919 | at91_set_A_periph(AT91_PIN_PB22, 0); /* ISI_D2 */ | ||
920 | at91_set_A_periph(AT91_PIN_PB23, 0); /* ISI_D3 */ | ||
921 | at91_set_A_periph(AT91_PIN_PB24, 0); /* ISI_D4 */ | ||
922 | at91_set_A_periph(AT91_PIN_PB25, 0); /* ISI_D5 */ | ||
923 | at91_set_A_periph(AT91_PIN_PB26, 0); /* ISI_D6 */ | ||
924 | at91_set_A_periph(AT91_PIN_PB27, 0); /* ISI_D7 */ | ||
925 | at91_set_A_periph(AT91_PIN_PB28, 0); /* ISI_PCK */ | ||
926 | at91_set_A_periph(AT91_PIN_PB30, 0); /* ISI_HSYNC */ | ||
927 | at91_set_A_periph(AT91_PIN_PB29, 0); /* ISI_VSYNC */ | ||
928 | at91_set_B_periph(AT91_PIN_PB8, 0); /* ISI_PD8 */ | ||
929 | at91_set_B_periph(AT91_PIN_PB9, 0); /* ISI_PD9 */ | ||
930 | at91_set_B_periph(AT91_PIN_PB10, 0); /* ISI_PD10 */ | ||
931 | at91_set_B_periph(AT91_PIN_PB11, 0); /* ISI_PD11 */ | ||
932 | |||
933 | platform_device_register(&at91sam9g45_isi_device); | ||
934 | |||
935 | if (use_pck_as_mck) { | ||
936 | at91_set_B_periph(AT91_PIN_PB31, 0); /* ISI_MCK (PCK1) */ | ||
937 | |||
938 | pck = clk_get(NULL, "pck1"); | ||
939 | parent = clk_get(NULL, "plla"); | ||
940 | |||
941 | BUG_ON(IS_ERR(pck) || IS_ERR(parent)); | ||
942 | |||
943 | if (clk_set_parent(pck, parent)) { | ||
944 | pr_err("Failed to set PCK's parent\n"); | ||
945 | } else { | ||
946 | /* Register PCK as ISI_MCK */ | ||
947 | isi_mck_lookups[0].clk = pck; | ||
948 | clkdev_add_table(isi_mck_lookups, | ||
949 | ARRAY_SIZE(isi_mck_lookups)); | ||
950 | } | ||
951 | |||
952 | clk_put(pck); | ||
953 | clk_put(parent); | ||
954 | } | ||
955 | } | ||
956 | #else | ||
957 | void __init at91_add_device_isi(struct isi_platform_data *data, | ||
958 | bool use_pck_as_mck) {} | ||
959 | #endif | ||
960 | |||
961 | 866 | ||
962 | /* -------------------------------------------------------------------- | 867 | /* -------------------------------------------------------------------- |
963 | * LCD Controller | 868 | * LCD Controller |
@@ -974,8 +879,8 @@ static struct resource lcdc_resources[] = { | |||
974 | .flags = IORESOURCE_MEM, | 879 | .flags = IORESOURCE_MEM, |
975 | }, | 880 | }, |
976 | [1] = { | 881 | [1] = { |
977 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC, | 882 | .start = AT91SAM9G45_ID_LCDC, |
978 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC, | 883 | .end = AT91SAM9G45_ID_LCDC, |
979 | .flags = IORESOURCE_IRQ, | 884 | .flags = IORESOURCE_IRQ, |
980 | }, | 885 | }, |
981 | }; | 886 | }; |
@@ -1045,12 +950,12 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} | |||
1045 | static struct resource tcb0_resources[] = { | 950 | static struct resource tcb0_resources[] = { |
1046 | [0] = { | 951 | [0] = { |
1047 | .start = AT91SAM9G45_BASE_TCB0, | 952 | .start = AT91SAM9G45_BASE_TCB0, |
1048 | .end = AT91SAM9G45_BASE_TCB0 + SZ_256 - 1, | 953 | .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1, |
1049 | .flags = IORESOURCE_MEM, | 954 | .flags = IORESOURCE_MEM, |
1050 | }, | 955 | }, |
1051 | [1] = { | 956 | [1] = { |
1052 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, | 957 | .start = AT91SAM9G45_ID_TCB, |
1053 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, | 958 | .end = AT91SAM9G45_ID_TCB, |
1054 | .flags = IORESOURCE_IRQ, | 959 | .flags = IORESOURCE_IRQ, |
1055 | }, | 960 | }, |
1056 | }; | 961 | }; |
@@ -1066,12 +971,12 @@ static struct platform_device at91sam9g45_tcb0_device = { | |||
1066 | static struct resource tcb1_resources[] = { | 971 | static struct resource tcb1_resources[] = { |
1067 | [0] = { | 972 | [0] = { |
1068 | .start = AT91SAM9G45_BASE_TCB1, | 973 | .start = AT91SAM9G45_BASE_TCB1, |
1069 | .end = AT91SAM9G45_BASE_TCB1 + SZ_256 - 1, | 974 | .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1, |
1070 | .flags = IORESOURCE_MEM, | 975 | .flags = IORESOURCE_MEM, |
1071 | }, | 976 | }, |
1072 | [1] = { | 977 | [1] = { |
1073 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, | 978 | .start = AT91SAM9G45_ID_TCB, |
1074 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, | 979 | .end = AT91SAM9G45_ID_TCB, |
1075 | .flags = IORESOURCE_IRQ, | 980 | .flags = IORESOURCE_IRQ, |
1076 | }, | 981 | }, |
1077 | }; | 982 | }; |
@@ -1098,24 +1003,10 @@ static void __init at91_add_device_tc(void) { } | |||
1098 | * -------------------------------------------------------------------- */ | 1003 | * -------------------------------------------------------------------- */ |
1099 | 1004 | ||
1100 | #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) | 1005 | #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) |
1101 | static struct resource rtc_resources[] = { | ||
1102 | [0] = { | ||
1103 | .start = AT91SAM9G45_BASE_RTC, | ||
1104 | .end = AT91SAM9G45_BASE_RTC + SZ_256 - 1, | ||
1105 | .flags = IORESOURCE_MEM, | ||
1106 | }, | ||
1107 | [1] = { | ||
1108 | .start = NR_IRQS_LEGACY + AT91_ID_SYS, | ||
1109 | .end = NR_IRQS_LEGACY + AT91_ID_SYS, | ||
1110 | .flags = IORESOURCE_IRQ, | ||
1111 | }, | ||
1112 | }; | ||
1113 | |||
1114 | static struct platform_device at91sam9g45_rtc_device = { | 1006 | static struct platform_device at91sam9g45_rtc_device = { |
1115 | .name = "at91_rtc", | 1007 | .name = "at91_rtc", |
1116 | .id = -1, | 1008 | .id = -1, |
1117 | .resource = rtc_resources, | 1009 | .num_resources = 0, |
1118 | .num_resources = ARRAY_SIZE(rtc_resources), | ||
1119 | }; | 1010 | }; |
1120 | 1011 | ||
1121 | static void __init at91_add_device_rtc(void) | 1012 | static void __init at91_add_device_rtc(void) |
@@ -1142,8 +1033,8 @@ static struct resource tsadcc_resources[] = { | |||
1142 | .flags = IORESOURCE_MEM, | 1033 | .flags = IORESOURCE_MEM, |
1143 | }, | 1034 | }, |
1144 | [1] = { | 1035 | [1] = { |
1145 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, | 1036 | .start = AT91SAM9G45_ID_TSC, |
1146 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, | 1037 | .end = AT91SAM9G45_ID_TSC, |
1147 | .flags = IORESOURCE_IRQ, | 1038 | .flags = IORESOURCE_IRQ, |
1148 | } | 1039 | } |
1149 | }; | 1040 | }; |
@@ -1179,116 +1070,14 @@ void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {} | |||
1179 | 1070 | ||
1180 | 1071 | ||
1181 | /* -------------------------------------------------------------------- | 1072 | /* -------------------------------------------------------------------- |
1182 | * ADC | ||
1183 | * -------------------------------------------------------------------- */ | ||
1184 | |||
1185 | #if IS_ENABLED(CONFIG_AT91_ADC) | ||
1186 | static struct at91_adc_data adc_data; | ||
1187 | |||
1188 | static struct resource adc_resources[] = { | ||
1189 | [0] = { | ||
1190 | .start = AT91SAM9G45_BASE_TSC, | ||
1191 | .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1, | ||
1192 | .flags = IORESOURCE_MEM, | ||
1193 | }, | ||
1194 | [1] = { | ||
1195 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, | ||
1196 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, | ||
1197 | .flags = IORESOURCE_IRQ, | ||
1198 | } | ||
1199 | }; | ||
1200 | |||
1201 | static struct platform_device at91_adc_device = { | ||
1202 | .name = "at91_adc", | ||
1203 | .id = -1, | ||
1204 | .dev = { | ||
1205 | .platform_data = &adc_data, | ||
1206 | }, | ||
1207 | .resource = adc_resources, | ||
1208 | .num_resources = ARRAY_SIZE(adc_resources), | ||
1209 | }; | ||
1210 | |||
1211 | static struct at91_adc_trigger at91_adc_triggers[] = { | ||
1212 | [0] = { | ||
1213 | .name = "external-rising", | ||
1214 | .value = 1, | ||
1215 | .is_external = true, | ||
1216 | }, | ||
1217 | [1] = { | ||
1218 | .name = "external-falling", | ||
1219 | .value = 2, | ||
1220 | .is_external = true, | ||
1221 | }, | ||
1222 | [2] = { | ||
1223 | .name = "external-any", | ||
1224 | .value = 3, | ||
1225 | .is_external = true, | ||
1226 | }, | ||
1227 | [3] = { | ||
1228 | .name = "continuous", | ||
1229 | .value = 6, | ||
1230 | .is_external = false, | ||
1231 | }, | ||
1232 | }; | ||
1233 | |||
1234 | static struct at91_adc_reg_desc at91_adc_register_g45 = { | ||
1235 | .channel_base = AT91_ADC_CHR(0), | ||
1236 | .drdy_mask = AT91_ADC_DRDY, | ||
1237 | .status_register = AT91_ADC_SR, | ||
1238 | .trigger_register = 0x08, | ||
1239 | }; | ||
1240 | |||
1241 | void __init at91_add_device_adc(struct at91_adc_data *data) | ||
1242 | { | ||
1243 | if (!data) | ||
1244 | return; | ||
1245 | |||
1246 | if (test_bit(0, &data->channels_used)) | ||
1247 | at91_set_gpio_input(AT91_PIN_PD20, 0); | ||
1248 | if (test_bit(1, &data->channels_used)) | ||
1249 | at91_set_gpio_input(AT91_PIN_PD21, 0); | ||
1250 | if (test_bit(2, &data->channels_used)) | ||
1251 | at91_set_gpio_input(AT91_PIN_PD22, 0); | ||
1252 | if (test_bit(3, &data->channels_used)) | ||
1253 | at91_set_gpio_input(AT91_PIN_PD23, 0); | ||
1254 | if (test_bit(4, &data->channels_used)) | ||
1255 | at91_set_gpio_input(AT91_PIN_PD24, 0); | ||
1256 | if (test_bit(5, &data->channels_used)) | ||
1257 | at91_set_gpio_input(AT91_PIN_PD25, 0); | ||
1258 | if (test_bit(6, &data->channels_used)) | ||
1259 | at91_set_gpio_input(AT91_PIN_PD26, 0); | ||
1260 | if (test_bit(7, &data->channels_used)) | ||
1261 | at91_set_gpio_input(AT91_PIN_PD27, 0); | ||
1262 | |||
1263 | if (data->use_external_triggers) | ||
1264 | at91_set_A_periph(AT91_PIN_PD28, 0); | ||
1265 | |||
1266 | data->num_channels = 8; | ||
1267 | data->startup_time = 40; | ||
1268 | data->registers = &at91_adc_register_g45; | ||
1269 | data->trigger_number = 4; | ||
1270 | data->trigger_list = at91_adc_triggers; | ||
1271 | |||
1272 | adc_data = *data; | ||
1273 | platform_device_register(&at91_adc_device); | ||
1274 | } | ||
1275 | #else | ||
1276 | void __init at91_add_device_adc(struct at91_adc_data *data) {} | ||
1277 | #endif | ||
1278 | |||
1279 | /* -------------------------------------------------------------------- | ||
1280 | * RTT | 1073 | * RTT |
1281 | * -------------------------------------------------------------------- */ | 1074 | * -------------------------------------------------------------------- */ |
1282 | 1075 | ||
1283 | static struct resource rtt_resources[] = { | 1076 | static struct resource rtt_resources[] = { |
1284 | { | 1077 | { |
1285 | .start = AT91SAM9G45_BASE_RTT, | 1078 | .start = AT91_BASE_SYS + AT91_RTT, |
1286 | .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1, | 1079 | .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, |
1287 | .flags = IORESOURCE_MEM, | ||
1288 | }, { | ||
1289 | .flags = IORESOURCE_MEM, | 1080 | .flags = IORESOURCE_MEM, |
1290 | }, { | ||
1291 | .flags = IORESOURCE_IRQ, | ||
1292 | } | 1081 | } |
1293 | }; | 1082 | }; |
1294 | 1083 | ||
@@ -1296,84 +1085,24 @@ static struct platform_device at91sam9g45_rtt_device = { | |||
1296 | .name = "at91_rtt", | 1085 | .name = "at91_rtt", |
1297 | .id = 0, | 1086 | .id = 0, |
1298 | .resource = rtt_resources, | 1087 | .resource = rtt_resources, |
1088 | .num_resources = ARRAY_SIZE(rtt_resources), | ||
1299 | }; | 1089 | }; |
1300 | 1090 | ||
1301 | #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) | ||
1302 | static void __init at91_add_device_rtt_rtc(void) | ||
1303 | { | ||
1304 | at91sam9g45_rtt_device.name = "rtc-at91sam9"; | ||
1305 | /* | ||
1306 | * The second resource is needed: | ||
1307 | * GPBR will serve as the storage for RTC time offset | ||
1308 | */ | ||
1309 | at91sam9g45_rtt_device.num_resources = 3; | ||
1310 | rtt_resources[1].start = AT91SAM9G45_BASE_GPBR + | ||
1311 | 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; | ||
1312 | rtt_resources[1].end = rtt_resources[1].start + 3; | ||
1313 | rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; | ||
1314 | rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; | ||
1315 | } | ||
1316 | #else | ||
1317 | static void __init at91_add_device_rtt_rtc(void) | ||
1318 | { | ||
1319 | /* Only one resource is needed: RTT not used as RTC */ | ||
1320 | at91sam9g45_rtt_device.num_resources = 1; | ||
1321 | } | ||
1322 | #endif | ||
1323 | |||
1324 | static void __init at91_add_device_rtt(void) | 1091 | static void __init at91_add_device_rtt(void) |
1325 | { | 1092 | { |
1326 | at91_add_device_rtt_rtc(); | ||
1327 | platform_device_register(&at91sam9g45_rtt_device); | 1093 | platform_device_register(&at91sam9g45_rtt_device); |
1328 | } | 1094 | } |
1329 | 1095 | ||
1330 | 1096 | ||
1331 | /* -------------------------------------------------------------------- | 1097 | /* -------------------------------------------------------------------- |
1332 | * TRNG | ||
1333 | * -------------------------------------------------------------------- */ | ||
1334 | |||
1335 | #if defined(CONFIG_HW_RANDOM_ATMEL) || defined(CONFIG_HW_RANDOM_ATMEL_MODULE) | ||
1336 | static struct resource trng_resources[] = { | ||
1337 | { | ||
1338 | .start = AT91SAM9G45_BASE_TRNG, | ||
1339 | .end = AT91SAM9G45_BASE_TRNG + SZ_16K - 1, | ||
1340 | .flags = IORESOURCE_MEM, | ||
1341 | }, | ||
1342 | }; | ||
1343 | |||
1344 | static struct platform_device at91sam9g45_trng_device = { | ||
1345 | .name = "atmel-trng", | ||
1346 | .id = -1, | ||
1347 | .resource = trng_resources, | ||
1348 | .num_resources = ARRAY_SIZE(trng_resources), | ||
1349 | }; | ||
1350 | |||
1351 | static void __init at91_add_device_trng(void) | ||
1352 | { | ||
1353 | platform_device_register(&at91sam9g45_trng_device); | ||
1354 | } | ||
1355 | #else | ||
1356 | static void __init at91_add_device_trng(void) {} | ||
1357 | #endif | ||
1358 | |||
1359 | /* -------------------------------------------------------------------- | ||
1360 | * Watchdog | 1098 | * Watchdog |
1361 | * -------------------------------------------------------------------- */ | 1099 | * -------------------------------------------------------------------- */ |
1362 | 1100 | ||
1363 | #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) | 1101 | #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) |
1364 | static struct resource wdt_resources[] = { | ||
1365 | { | ||
1366 | .start = AT91SAM9G45_BASE_WDT, | ||
1367 | .end = AT91SAM9G45_BASE_WDT + SZ_16 - 1, | ||
1368 | .flags = IORESOURCE_MEM, | ||
1369 | } | ||
1370 | }; | ||
1371 | |||
1372 | static struct platform_device at91sam9g45_wdt_device = { | 1102 | static struct platform_device at91sam9g45_wdt_device = { |
1373 | .name = "at91_wdt", | 1103 | .name = "at91_wdt", |
1374 | .id = -1, | 1104 | .id = -1, |
1375 | .resource = wdt_resources, | 1105 | .num_resources = 0, |
1376 | .num_resources = ARRAY_SIZE(wdt_resources), | ||
1377 | }; | 1106 | }; |
1378 | 1107 | ||
1379 | static void __init at91_add_device_watchdog(void) | 1108 | static void __init at91_add_device_watchdog(void) |
@@ -1399,8 +1128,8 @@ static struct resource pwm_resources[] = { | |||
1399 | .flags = IORESOURCE_MEM, | 1128 | .flags = IORESOURCE_MEM, |
1400 | }, | 1129 | }, |
1401 | [1] = { | 1130 | [1] = { |
1402 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC, | 1131 | .start = AT91SAM9G45_ID_PWMC, |
1403 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC, | 1132 | .end = AT91SAM9G45_ID_PWMC, |
1404 | .flags = IORESOURCE_IRQ, | 1133 | .flags = IORESOURCE_IRQ, |
1405 | }, | 1134 | }, |
1406 | }; | 1135 | }; |
@@ -1452,14 +1181,14 @@ static struct resource ssc0_resources[] = { | |||
1452 | .flags = IORESOURCE_MEM, | 1181 | .flags = IORESOURCE_MEM, |
1453 | }, | 1182 | }, |
1454 | [1] = { | 1183 | [1] = { |
1455 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0, | 1184 | .start = AT91SAM9G45_ID_SSC0, |
1456 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0, | 1185 | .end = AT91SAM9G45_ID_SSC0, |
1457 | .flags = IORESOURCE_IRQ, | 1186 | .flags = IORESOURCE_IRQ, |
1458 | }, | 1187 | }, |
1459 | }; | 1188 | }; |
1460 | 1189 | ||
1461 | static struct platform_device at91sam9g45_ssc0_device = { | 1190 | static struct platform_device at91sam9g45_ssc0_device = { |
1462 | .name = "at91sam9g45_ssc", | 1191 | .name = "ssc", |
1463 | .id = 0, | 1192 | .id = 0, |
1464 | .dev = { | 1193 | .dev = { |
1465 | .dma_mask = &ssc0_dmamask, | 1194 | .dma_mask = &ssc0_dmamask, |
@@ -1494,14 +1223,14 @@ static struct resource ssc1_resources[] = { | |||
1494 | .flags = IORESOURCE_MEM, | 1223 | .flags = IORESOURCE_MEM, |
1495 | }, | 1224 | }, |
1496 | [1] = { | 1225 | [1] = { |
1497 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1, | 1226 | .start = AT91SAM9G45_ID_SSC1, |
1498 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1, | 1227 | .end = AT91SAM9G45_ID_SSC1, |
1499 | .flags = IORESOURCE_IRQ, | 1228 | .flags = IORESOURCE_IRQ, |
1500 | }, | 1229 | }, |
1501 | }; | 1230 | }; |
1502 | 1231 | ||
1503 | static struct platform_device at91sam9g45_ssc1_device = { | 1232 | static struct platform_device at91sam9g45_ssc1_device = { |
1504 | .name = "at91sam9g45_ssc", | 1233 | .name = "ssc", |
1505 | .id = 1, | 1234 | .id = 1, |
1506 | .dev = { | 1235 | .dev = { |
1507 | .dma_mask = &ssc1_dmamask, | 1236 | .dma_mask = &ssc1_dmamask, |
@@ -1569,13 +1298,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} | |||
1569 | #if defined(CONFIG_SERIAL_ATMEL) | 1298 | #if defined(CONFIG_SERIAL_ATMEL) |
1570 | static struct resource dbgu_resources[] = { | 1299 | static struct resource dbgu_resources[] = { |
1571 | [0] = { | 1300 | [0] = { |
1572 | .start = AT91SAM9G45_BASE_DBGU, | 1301 | .start = AT91_VA_BASE_SYS + AT91_DBGU, |
1573 | .end = AT91SAM9G45_BASE_DBGU + SZ_512 - 1, | 1302 | .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, |
1574 | .flags = IORESOURCE_MEM, | 1303 | .flags = IORESOURCE_MEM, |
1575 | }, | 1304 | }, |
1576 | [1] = { | 1305 | [1] = { |
1577 | .start = NR_IRQS_LEGACY + AT91_ID_SYS, | 1306 | .start = AT91_ID_SYS, |
1578 | .end = NR_IRQS_LEGACY + AT91_ID_SYS, | 1307 | .end = AT91_ID_SYS, |
1579 | .flags = IORESOURCE_IRQ, | 1308 | .flags = IORESOURCE_IRQ, |
1580 | }, | 1309 | }, |
1581 | }; | 1310 | }; |
@@ -1583,6 +1312,7 @@ static struct resource dbgu_resources[] = { | |||
1583 | static struct atmel_uart_data dbgu_data = { | 1312 | static struct atmel_uart_data dbgu_data = { |
1584 | .use_dma_tx = 0, | 1313 | .use_dma_tx = 0, |
1585 | .use_dma_rx = 0, | 1314 | .use_dma_rx = 0, |
1315 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), | ||
1586 | }; | 1316 | }; |
1587 | 1317 | ||
1588 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 1318 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
@@ -1612,8 +1342,8 @@ static struct resource uart0_resources[] = { | |||
1612 | .flags = IORESOURCE_MEM, | 1342 | .flags = IORESOURCE_MEM, |
1613 | }, | 1343 | }, |
1614 | [1] = { | 1344 | [1] = { |
1615 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US0, | 1345 | .start = AT91SAM9G45_ID_US0, |
1616 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US0, | 1346 | .end = AT91SAM9G45_ID_US0, |
1617 | .flags = IORESOURCE_IRQ, | 1347 | .flags = IORESOURCE_IRQ, |
1618 | }, | 1348 | }, |
1619 | }; | 1349 | }; |
@@ -1655,8 +1385,8 @@ static struct resource uart1_resources[] = { | |||
1655 | .flags = IORESOURCE_MEM, | 1385 | .flags = IORESOURCE_MEM, |
1656 | }, | 1386 | }, |
1657 | [1] = { | 1387 | [1] = { |
1658 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US1, | 1388 | .start = AT91SAM9G45_ID_US1, |
1659 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US1, | 1389 | .end = AT91SAM9G45_ID_US1, |
1660 | .flags = IORESOURCE_IRQ, | 1390 | .flags = IORESOURCE_IRQ, |
1661 | }, | 1391 | }, |
1662 | }; | 1392 | }; |
@@ -1698,8 +1428,8 @@ static struct resource uart2_resources[] = { | |||
1698 | .flags = IORESOURCE_MEM, | 1428 | .flags = IORESOURCE_MEM, |
1699 | }, | 1429 | }, |
1700 | [1] = { | 1430 | [1] = { |
1701 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US2, | 1431 | .start = AT91SAM9G45_ID_US2, |
1702 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US2, | 1432 | .end = AT91SAM9G45_ID_US2, |
1703 | .flags = IORESOURCE_IRQ, | 1433 | .flags = IORESOURCE_IRQ, |
1704 | }, | 1434 | }, |
1705 | }; | 1435 | }; |
@@ -1741,8 +1471,8 @@ static struct resource uart3_resources[] = { | |||
1741 | .flags = IORESOURCE_MEM, | 1471 | .flags = IORESOURCE_MEM, |
1742 | }, | 1472 | }, |
1743 | [1] = { | 1473 | [1] = { |
1744 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US3, | 1474 | .start = AT91SAM9G45_ID_US3, |
1745 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US3, | 1475 | .end = AT91SAM9G45_ID_US3, |
1746 | .flags = IORESOURCE_IRQ, | 1476 | .flags = IORESOURCE_IRQ, |
1747 | }, | 1477 | }, |
1748 | }; | 1478 | }; |
@@ -1778,6 +1508,7 @@ static inline void configure_usart3_pins(unsigned pins) | |||
1778 | } | 1508 | } |
1779 | 1509 | ||
1780 | static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 1510 | static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
1511 | struct platform_device *atmel_default_console_device; /* the serial console device */ | ||
1781 | 1512 | ||
1782 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | 1513 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) |
1783 | { | 1514 | { |
@@ -1815,6 +1546,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1815 | at91_uarts[portnr] = pdev; | 1546 | at91_uarts[portnr] = pdev; |
1816 | } | 1547 | } |
1817 | 1548 | ||
1549 | void __init at91_set_serial_console(unsigned portnr) | ||
1550 | { | ||
1551 | if (portnr < ATMEL_MAX_UART) { | ||
1552 | atmel_default_console_device = at91_uarts[portnr]; | ||
1553 | at91sam9g45_set_console_clock(at91_uarts[portnr]->id); | ||
1554 | } | ||
1555 | } | ||
1556 | |||
1818 | void __init at91_add_device_serial(void) | 1557 | void __init at91_add_device_serial(void) |
1819 | { | 1558 | { |
1820 | int i; | 1559 | int i; |
@@ -1823,136 +1562,16 @@ void __init at91_add_device_serial(void) | |||
1823 | if (at91_uarts[i]) | 1562 | if (at91_uarts[i]) |
1824 | platform_device_register(at91_uarts[i]); | 1563 | platform_device_register(at91_uarts[i]); |
1825 | } | 1564 | } |
1565 | |||
1566 | if (!atmel_default_console_device) | ||
1567 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1826 | } | 1568 | } |
1827 | #else | 1569 | #else |
1828 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | 1570 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} |
1571 | void __init at91_set_serial_console(unsigned portnr) {} | ||
1829 | void __init at91_add_device_serial(void) {} | 1572 | void __init at91_add_device_serial(void) {} |
1830 | #endif | 1573 | #endif |
1831 | 1574 | ||
1832 | /* -------------------------------------------------------------------- | ||
1833 | * SHA1/SHA256 | ||
1834 | * -------------------------------------------------------------------- */ | ||
1835 | |||
1836 | #if defined(CONFIG_CRYPTO_DEV_ATMEL_SHA) || defined(CONFIG_CRYPTO_DEV_ATMEL_SHA_MODULE) | ||
1837 | static struct resource sha_resources[] = { | ||
1838 | { | ||
1839 | .start = AT91SAM9G45_BASE_SHA, | ||
1840 | .end = AT91SAM9G45_BASE_SHA + SZ_16K - 1, | ||
1841 | .flags = IORESOURCE_MEM, | ||
1842 | }, | ||
1843 | [1] = { | ||
1844 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, | ||
1845 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, | ||
1846 | .flags = IORESOURCE_IRQ, | ||
1847 | }, | ||
1848 | }; | ||
1849 | |||
1850 | static struct platform_device at91sam9g45_sha_device = { | ||
1851 | .name = "atmel_sha", | ||
1852 | .id = -1, | ||
1853 | .resource = sha_resources, | ||
1854 | .num_resources = ARRAY_SIZE(sha_resources), | ||
1855 | }; | ||
1856 | |||
1857 | static void __init at91_add_device_sha(void) | ||
1858 | { | ||
1859 | platform_device_register(&at91sam9g45_sha_device); | ||
1860 | } | ||
1861 | #else | ||
1862 | static void __init at91_add_device_sha(void) {} | ||
1863 | #endif | ||
1864 | |||
1865 | /* -------------------------------------------------------------------- | ||
1866 | * DES/TDES | ||
1867 | * -------------------------------------------------------------------- */ | ||
1868 | |||
1869 | #if defined(CONFIG_CRYPTO_DEV_ATMEL_TDES) || defined(CONFIG_CRYPTO_DEV_ATMEL_TDES_MODULE) | ||
1870 | static struct resource tdes_resources[] = { | ||
1871 | [0] = { | ||
1872 | .start = AT91SAM9G45_BASE_TDES, | ||
1873 | .end = AT91SAM9G45_BASE_TDES + SZ_16K - 1, | ||
1874 | .flags = IORESOURCE_MEM, | ||
1875 | }, | ||
1876 | [1] = { | ||
1877 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, | ||
1878 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, | ||
1879 | .flags = IORESOURCE_IRQ, | ||
1880 | }, | ||
1881 | }; | ||
1882 | |||
1883 | static struct platform_device at91sam9g45_tdes_device = { | ||
1884 | .name = "atmel_tdes", | ||
1885 | .id = -1, | ||
1886 | .resource = tdes_resources, | ||
1887 | .num_resources = ARRAY_SIZE(tdes_resources), | ||
1888 | }; | ||
1889 | |||
1890 | static void __init at91_add_device_tdes(void) | ||
1891 | { | ||
1892 | platform_device_register(&at91sam9g45_tdes_device); | ||
1893 | } | ||
1894 | #else | ||
1895 | static void __init at91_add_device_tdes(void) {} | ||
1896 | #endif | ||
1897 | |||
1898 | /* -------------------------------------------------------------------- | ||
1899 | * AES | ||
1900 | * -------------------------------------------------------------------- */ | ||
1901 | |||
1902 | #if defined(CONFIG_CRYPTO_DEV_ATMEL_AES) || defined(CONFIG_CRYPTO_DEV_ATMEL_AES_MODULE) | ||
1903 | static struct aes_platform_data aes_data; | ||
1904 | static u64 aes_dmamask = DMA_BIT_MASK(32); | ||
1905 | |||
1906 | static struct resource aes_resources[] = { | ||
1907 | [0] = { | ||
1908 | .start = AT91SAM9G45_BASE_AES, | ||
1909 | .end = AT91SAM9G45_BASE_AES + SZ_16K - 1, | ||
1910 | .flags = IORESOURCE_MEM, | ||
1911 | }, | ||
1912 | [1] = { | ||
1913 | .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, | ||
1914 | .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, | ||
1915 | .flags = IORESOURCE_IRQ, | ||
1916 | }, | ||
1917 | }; | ||
1918 | |||
1919 | static struct platform_device at91sam9g45_aes_device = { | ||
1920 | .name = "atmel_aes", | ||
1921 | .id = -1, | ||
1922 | .dev = { | ||
1923 | .dma_mask = &aes_dmamask, | ||
1924 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
1925 | .platform_data = &aes_data, | ||
1926 | }, | ||
1927 | .resource = aes_resources, | ||
1928 | .num_resources = ARRAY_SIZE(aes_resources), | ||
1929 | }; | ||
1930 | |||
1931 | static void __init at91_add_device_aes(void) | ||
1932 | { | ||
1933 | struct at_dma_slave *atslave; | ||
1934 | struct aes_dma_data *alt_atslave; | ||
1935 | |||
1936 | alt_atslave = kzalloc(sizeof(struct aes_dma_data), GFP_KERNEL); | ||
1937 | |||
1938 | /* DMA TX slave channel configuration */ | ||
1939 | atslave = &alt_atslave->txdata; | ||
1940 | atslave->dma_dev = &at_hdmac_device.dev; | ||
1941 | atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_SRC_H2SEL_HW | | ||
1942 | ATC_SRC_PER(AT_DMA_ID_AES_RX); | ||
1943 | |||
1944 | /* DMA RX slave channel configuration */ | ||
1945 | atslave = &alt_atslave->rxdata; | ||
1946 | atslave->dma_dev = &at_hdmac_device.dev; | ||
1947 | atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_DST_H2SEL_HW | | ||
1948 | ATC_DST_PER(AT_DMA_ID_AES_TX); | ||
1949 | |||
1950 | aes_data.dma_slave = alt_atslave; | ||
1951 | platform_device_register(&at91sam9g45_aes_device); | ||
1952 | } | ||
1953 | #else | ||
1954 | static void __init at91_add_device_aes(void) {} | ||
1955 | #endif | ||
1956 | 1575 | ||
1957 | /* -------------------------------------------------------------------- */ | 1576 | /* -------------------------------------------------------------------- */ |
1958 | /* | 1577 | /* |
@@ -1961,18 +1580,11 @@ static void __init at91_add_device_aes(void) {} | |||
1961 | */ | 1580 | */ |
1962 | static int __init at91_add_standard_devices(void) | 1581 | static int __init at91_add_standard_devices(void) |
1963 | { | 1582 | { |
1964 | if (of_have_populated_dt()) | ||
1965 | return 0; | ||
1966 | |||
1967 | at91_add_device_hdmac(); | 1583 | at91_add_device_hdmac(); |
1968 | at91_add_device_rtc(); | 1584 | at91_add_device_rtc(); |
1969 | at91_add_device_rtt(); | 1585 | at91_add_device_rtt(); |
1970 | at91_add_device_trng(); | ||
1971 | at91_add_device_watchdog(); | 1586 | at91_add_device_watchdog(); |
1972 | at91_add_device_tc(); | 1587 | at91_add_device_tc(); |
1973 | at91_add_device_sha(); | ||
1974 | at91_add_device_tdes(); | ||
1975 | at91_add_device_aes(); | ||
1976 | return 0; | 1588 | return 0; |
1977 | } | 1589 | } |
1978 | 1590 | ||