diff options
Diffstat (limited to 'arch/arm/mach-at91/at91sam9261_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9261_devices.c | 366 |
1 files changed, 321 insertions, 45 deletions
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 64979a9023c2..245641263fce 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <asm/mach/arch.h> | 13 | #include <asm/mach/arch.h> |
14 | #include <asm/mach/map.h> | 14 | #include <asm/mach/map.h> |
15 | 15 | ||
16 | #include <linux/dma-mapping.h> | ||
16 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
17 | #include <linux/i2c-gpio.h> | 18 | #include <linux/i2c-gpio.h> |
18 | 19 | ||
@@ -33,7 +34,7 @@ | |||
33 | * -------------------------------------------------------------------- */ | 34 | * -------------------------------------------------------------------- */ |
34 | 35 | ||
35 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | 36 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
36 | static u64 ohci_dmamask = 0xffffffffUL; | 37 | static u64 ohci_dmamask = DMA_BIT_MASK(32); |
37 | static struct at91_usbh_data usbh_data; | 38 | static struct at91_usbh_data usbh_data; |
38 | 39 | ||
39 | static struct resource usbh_resources[] = { | 40 | static struct resource usbh_resources[] = { |
@@ -54,7 +55,7 @@ static struct platform_device at91sam9261_usbh_device = { | |||
54 | .id = -1, | 55 | .id = -1, |
55 | .dev = { | 56 | .dev = { |
56 | .dma_mask = &ohci_dmamask, | 57 | .dma_mask = &ohci_dmamask, |
57 | .coherent_dma_mask = 0xffffffff, | 58 | .coherent_dma_mask = DMA_BIT_MASK(32), |
58 | .platform_data = &usbh_data, | 59 | .platform_data = &usbh_data, |
59 | }, | 60 | }, |
60 | .resource = usbh_resources, | 61 | .resource = usbh_resources, |
@@ -106,8 +107,6 @@ static struct platform_device at91sam9261_udc_device = { | |||
106 | 107 | ||
107 | void __init at91_add_device_udc(struct at91_udc_data *data) | 108 | void __init at91_add_device_udc(struct at91_udc_data *data) |
108 | { | 109 | { |
109 | unsigned long x; | ||
110 | |||
111 | if (!data) | 110 | if (!data) |
112 | return; | 111 | return; |
113 | 112 | ||
@@ -116,9 +115,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) | |||
116 | at91_set_deglitch(data->vbus_pin, 1); | 115 | at91_set_deglitch(data->vbus_pin, 1); |
117 | } | 116 | } |
118 | 117 | ||
119 | /* Pullup pin is handled internally */ | 118 | /* Pullup pin is handled internally by USB device peripheral */ |
120 | x = at91_sys_read(AT91_MATRIX_USBPUCR); | ||
121 | at91_sys_write(AT91_MATRIX_USBPUCR, x | AT91_MATRIX_USBPUCR_PUON); | ||
122 | 119 | ||
123 | udc_data = *data; | 120 | udc_data = *data; |
124 | platform_device_register(&at91sam9261_udc_device); | 121 | platform_device_register(&at91sam9261_udc_device); |
@@ -132,7 +129,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {} | |||
132 | * -------------------------------------------------------------------- */ | 129 | * -------------------------------------------------------------------- */ |
133 | 130 | ||
134 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) | 131 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) |
135 | static u64 mmc_dmamask = 0xffffffffUL; | 132 | static u64 mmc_dmamask = DMA_BIT_MASK(32); |
136 | static struct at91_mmc_data mmc_data; | 133 | static struct at91_mmc_data mmc_data; |
137 | 134 | ||
138 | static struct resource mmc_resources[] = { | 135 | static struct resource mmc_resources[] = { |
@@ -153,7 +150,7 @@ static struct platform_device at91sam9261_mmc_device = { | |||
153 | .id = -1, | 150 | .id = -1, |
154 | .dev = { | 151 | .dev = { |
155 | .dma_mask = &mmc_dmamask, | 152 | .dma_mask = &mmc_dmamask, |
156 | .coherent_dma_mask = 0xffffffff, | 153 | .coherent_dma_mask = DMA_BIT_MASK(32), |
157 | .platform_data = &mmc_data, | 154 | .platform_data = &mmc_data, |
158 | }, | 155 | }, |
159 | .resource = mmc_resources, | 156 | .resource = mmc_resources, |
@@ -232,7 +229,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data) | |||
232 | return; | 229 | return; |
233 | 230 | ||
234 | csa = at91_sys_read(AT91_MATRIX_EBICSA); | 231 | csa = at91_sys_read(AT91_MATRIX_EBICSA); |
235 | at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC); | 232 | at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); |
236 | 233 | ||
237 | /* set the bus interface characteristics */ | 234 | /* set the bus interface characteristics */ |
238 | at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) | 235 | at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) |
@@ -354,7 +351,7 @@ void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) | |||
354 | * -------------------------------------------------------------------- */ | 351 | * -------------------------------------------------------------------- */ |
355 | 352 | ||
356 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) | 353 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) |
357 | static u64 spi_dmamask = 0xffffffffUL; | 354 | static u64 spi_dmamask = DMA_BIT_MASK(32); |
358 | 355 | ||
359 | static struct resource spi0_resources[] = { | 356 | static struct resource spi0_resources[] = { |
360 | [0] = { | 357 | [0] = { |
@@ -374,7 +371,7 @@ static struct platform_device at91sam9261_spi0_device = { | |||
374 | .id = 0, | 371 | .id = 0, |
375 | .dev = { | 372 | .dev = { |
376 | .dma_mask = &spi_dmamask, | 373 | .dma_mask = &spi_dmamask, |
377 | .coherent_dma_mask = 0xffffffff, | 374 | .coherent_dma_mask = DMA_BIT_MASK(32), |
378 | }, | 375 | }, |
379 | .resource = spi0_resources, | 376 | .resource = spi0_resources, |
380 | .num_resources = ARRAY_SIZE(spi0_resources), | 377 | .num_resources = ARRAY_SIZE(spi0_resources), |
@@ -400,7 +397,7 @@ static struct platform_device at91sam9261_spi1_device = { | |||
400 | .id = 1, | 397 | .id = 1, |
401 | .dev = { | 398 | .dev = { |
402 | .dma_mask = &spi_dmamask, | 399 | .dma_mask = &spi_dmamask, |
403 | .coherent_dma_mask = 0xffffffff, | 400 | .coherent_dma_mask = DMA_BIT_MASK(32), |
404 | }, | 401 | }, |
405 | .resource = spi1_resources, | 402 | .resource = spi1_resources, |
406 | .num_resources = ARRAY_SIZE(spi1_resources), | 403 | .num_resources = ARRAY_SIZE(spi1_resources), |
@@ -466,7 +463,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
466 | * -------------------------------------------------------------------- */ | 463 | * -------------------------------------------------------------------- */ |
467 | 464 | ||
468 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) | 465 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) |
469 | static u64 lcdc_dmamask = 0xffffffffUL; | 466 | static u64 lcdc_dmamask = DMA_BIT_MASK(32); |
470 | static struct atmel_lcdfb_info lcdc_data; | 467 | static struct atmel_lcdfb_info lcdc_data; |
471 | 468 | ||
472 | static struct resource lcdc_resources[] = { | 469 | static struct resource lcdc_resources[] = { |
@@ -494,7 +491,7 @@ static struct platform_device at91_lcdc_device = { | |||
494 | .id = 0, | 491 | .id = 0, |
495 | .dev = { | 492 | .dev = { |
496 | .dma_mask = &lcdc_dmamask, | 493 | .dma_mask = &lcdc_dmamask, |
497 | .coherent_dma_mask = 0xffffffff, | 494 | .coherent_dma_mask = DMA_BIT_MASK(32), |
498 | .platform_data = &lcdc_data, | 495 | .platform_data = &lcdc_data, |
499 | }, | 496 | }, |
500 | .resource = lcdc_resources, | 497 | .resource = lcdc_resources, |
@@ -507,6 +504,17 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) | |||
507 | return; | 504 | return; |
508 | } | 505 | } |
509 | 506 | ||
507 | #if defined(CONFIG_FB_ATMEL_STN) | ||
508 | at91_set_A_periph(AT91_PIN_PB0, 0); /* LCDVSYNC */ | ||
509 | at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */ | ||
510 | at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */ | ||
511 | at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */ | ||
512 | at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */ | ||
513 | at91_set_A_periph(AT91_PIN_PB5, 0); /* LCDD0 */ | ||
514 | at91_set_A_periph(AT91_PIN_PB6, 0); /* LCDD1 */ | ||
515 | at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */ | ||
516 | at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */ | ||
517 | #else | ||
510 | at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */ | 518 | at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */ |
511 | at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */ | 519 | at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */ |
512 | at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */ | 520 | at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */ |
@@ -529,6 +537,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) | |||
529 | at91_set_B_periph(AT91_PIN_PB26, 0); /* LCDD21 */ | 537 | at91_set_B_periph(AT91_PIN_PB26, 0); /* LCDD21 */ |
530 | at91_set_B_periph(AT91_PIN_PB27, 0); /* LCDD22 */ | 538 | at91_set_B_periph(AT91_PIN_PB27, 0); /* LCDD22 */ |
531 | at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */ | 539 | at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */ |
540 | #endif | ||
532 | 541 | ||
533 | lcdc_data = *data; | 542 | lcdc_data = *data; |
534 | platform_device_register(&at91_lcdc_device); | 543 | platform_device_register(&at91_lcdc_device); |
@@ -539,24 +548,220 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} | |||
539 | 548 | ||
540 | 549 | ||
541 | /* -------------------------------------------------------------------- | 550 | /* -------------------------------------------------------------------- |
542 | * LEDs | 551 | * RTT |
552 | * -------------------------------------------------------------------- */ | ||
553 | |||
554 | static struct resource rtt_resources[] = { | ||
555 | { | ||
556 | .start = AT91_BASE_SYS + AT91_RTT, | ||
557 | .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, | ||
558 | .flags = IORESOURCE_MEM, | ||
559 | } | ||
560 | }; | ||
561 | |||
562 | static struct platform_device at91sam9261_rtt_device = { | ||
563 | .name = "at91_rtt", | ||
564 | .id = -1, | ||
565 | .resource = rtt_resources, | ||
566 | .num_resources = ARRAY_SIZE(rtt_resources), | ||
567 | }; | ||
568 | |||
569 | static void __init at91_add_device_rtt(void) | ||
570 | { | ||
571 | platform_device_register(&at91sam9261_rtt_device); | ||
572 | } | ||
573 | |||
574 | |||
575 | /* -------------------------------------------------------------------- | ||
576 | * Watchdog | ||
577 | * -------------------------------------------------------------------- */ | ||
578 | |||
579 | #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) | ||
580 | static struct platform_device at91sam9261_wdt_device = { | ||
581 | .name = "at91_wdt", | ||
582 | .id = -1, | ||
583 | .num_resources = 0, | ||
584 | }; | ||
585 | |||
586 | static void __init at91_add_device_watchdog(void) | ||
587 | { | ||
588 | platform_device_register(&at91sam9261_wdt_device); | ||
589 | } | ||
590 | #else | ||
591 | static void __init at91_add_device_watchdog(void) {} | ||
592 | #endif | ||
593 | |||
594 | |||
595 | /* -------------------------------------------------------------------- | ||
596 | * SSC -- Synchronous Serial Controller | ||
543 | * -------------------------------------------------------------------- */ | 597 | * -------------------------------------------------------------------- */ |
544 | 598 | ||
545 | #if defined(CONFIG_LEDS) | 599 | #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE) |
546 | u8 at91_leds_cpu; | 600 | static u64 ssc0_dmamask = DMA_BIT_MASK(32); |
547 | u8 at91_leds_timer; | 601 | |
602 | static struct resource ssc0_resources[] = { | ||
603 | [0] = { | ||
604 | .start = AT91SAM9261_BASE_SSC0, | ||
605 | .end = AT91SAM9261_BASE_SSC0 + SZ_16K - 1, | ||
606 | .flags = IORESOURCE_MEM, | ||
607 | }, | ||
608 | [1] = { | ||
609 | .start = AT91SAM9261_ID_SSC0, | ||
610 | .end = AT91SAM9261_ID_SSC0, | ||
611 | .flags = IORESOURCE_IRQ, | ||
612 | }, | ||
613 | }; | ||
614 | |||
615 | static struct platform_device at91sam9261_ssc0_device = { | ||
616 | .name = "ssc", | ||
617 | .id = 0, | ||
618 | .dev = { | ||
619 | .dma_mask = &ssc0_dmamask, | ||
620 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
621 | }, | ||
622 | .resource = ssc0_resources, | ||
623 | .num_resources = ARRAY_SIZE(ssc0_resources), | ||
624 | }; | ||
625 | |||
626 | static inline void configure_ssc0_pins(unsigned pins) | ||
627 | { | ||
628 | if (pins & ATMEL_SSC_TF) | ||
629 | at91_set_A_periph(AT91_PIN_PB21, 1); | ||
630 | if (pins & ATMEL_SSC_TK) | ||
631 | at91_set_A_periph(AT91_PIN_PB22, 1); | ||
632 | if (pins & ATMEL_SSC_TD) | ||
633 | at91_set_A_periph(AT91_PIN_PB23, 1); | ||
634 | if (pins & ATMEL_SSC_RD) | ||
635 | at91_set_A_periph(AT91_PIN_PB24, 1); | ||
636 | if (pins & ATMEL_SSC_RK) | ||
637 | at91_set_A_periph(AT91_PIN_PB25, 1); | ||
638 | if (pins & ATMEL_SSC_RF) | ||
639 | at91_set_A_periph(AT91_PIN_PB26, 1); | ||
640 | } | ||
641 | |||
642 | static u64 ssc1_dmamask = DMA_BIT_MASK(32); | ||
643 | |||
644 | static struct resource ssc1_resources[] = { | ||
645 | [0] = { | ||
646 | .start = AT91SAM9261_BASE_SSC1, | ||
647 | .end = AT91SAM9261_BASE_SSC1 + SZ_16K - 1, | ||
648 | .flags = IORESOURCE_MEM, | ||
649 | }, | ||
650 | [1] = { | ||
651 | .start = AT91SAM9261_ID_SSC1, | ||
652 | .end = AT91SAM9261_ID_SSC1, | ||
653 | .flags = IORESOURCE_IRQ, | ||
654 | }, | ||
655 | }; | ||
656 | |||
657 | static struct platform_device at91sam9261_ssc1_device = { | ||
658 | .name = "ssc", | ||
659 | .id = 1, | ||
660 | .dev = { | ||
661 | .dma_mask = &ssc1_dmamask, | ||
662 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
663 | }, | ||
664 | .resource = ssc1_resources, | ||
665 | .num_resources = ARRAY_SIZE(ssc1_resources), | ||
666 | }; | ||
667 | |||
668 | static inline void configure_ssc1_pins(unsigned pins) | ||
669 | { | ||
670 | if (pins & ATMEL_SSC_TF) | ||
671 | at91_set_B_periph(AT91_PIN_PA17, 1); | ||
672 | if (pins & ATMEL_SSC_TK) | ||
673 | at91_set_B_periph(AT91_PIN_PA18, 1); | ||
674 | if (pins & ATMEL_SSC_TD) | ||
675 | at91_set_B_periph(AT91_PIN_PA19, 1); | ||
676 | if (pins & ATMEL_SSC_RD) | ||
677 | at91_set_B_periph(AT91_PIN_PA20, 1); | ||
678 | if (pins & ATMEL_SSC_RK) | ||
679 | at91_set_B_periph(AT91_PIN_PA21, 1); | ||
680 | if (pins & ATMEL_SSC_RF) | ||
681 | at91_set_B_periph(AT91_PIN_PA22, 1); | ||
682 | } | ||
683 | |||
684 | static u64 ssc2_dmamask = DMA_BIT_MASK(32); | ||
685 | |||
686 | static struct resource ssc2_resources[] = { | ||
687 | [0] = { | ||
688 | .start = AT91SAM9261_BASE_SSC2, | ||
689 | .end = AT91SAM9261_BASE_SSC2 + SZ_16K - 1, | ||
690 | .flags = IORESOURCE_MEM, | ||
691 | }, | ||
692 | [1] = { | ||
693 | .start = AT91SAM9261_ID_SSC2, | ||
694 | .end = AT91SAM9261_ID_SSC2, | ||
695 | .flags = IORESOURCE_IRQ, | ||
696 | }, | ||
697 | }; | ||
698 | |||
699 | static struct platform_device at91sam9261_ssc2_device = { | ||
700 | .name = "ssc", | ||
701 | .id = 2, | ||
702 | .dev = { | ||
703 | .dma_mask = &ssc2_dmamask, | ||
704 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
705 | }, | ||
706 | .resource = ssc2_resources, | ||
707 | .num_resources = ARRAY_SIZE(ssc2_resources), | ||
708 | }; | ||
709 | |||
710 | static inline void configure_ssc2_pins(unsigned pins) | ||
711 | { | ||
712 | if (pins & ATMEL_SSC_TF) | ||
713 | at91_set_B_periph(AT91_PIN_PC25, 1); | ||
714 | if (pins & ATMEL_SSC_TK) | ||
715 | at91_set_B_periph(AT91_PIN_PC26, 1); | ||
716 | if (pins & ATMEL_SSC_TD) | ||
717 | at91_set_B_periph(AT91_PIN_PC27, 1); | ||
718 | if (pins & ATMEL_SSC_RD) | ||
719 | at91_set_B_periph(AT91_PIN_PC28, 1); | ||
720 | if (pins & ATMEL_SSC_RK) | ||
721 | at91_set_B_periph(AT91_PIN_PC29, 1); | ||
722 | if (pins & ATMEL_SSC_RF) | ||
723 | at91_set_B_periph(AT91_PIN_PC30, 1); | ||
724 | } | ||
548 | 725 | ||
549 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) | 726 | /* |
727 | * SSC controllers are accessed through library code, instead of any | ||
728 | * kind of all-singing/all-dancing driver. For example one could be | ||
729 | * used by a particular I2S audio codec's driver, while another one | ||
730 | * on the same system might be used by a custom data capture driver. | ||
731 | */ | ||
732 | void __init at91_add_device_ssc(unsigned id, unsigned pins) | ||
550 | { | 733 | { |
551 | /* Enable GPIO to access the LEDs */ | 734 | struct platform_device *pdev; |
552 | at91_set_gpio_output(cpu_led, 1); | 735 | |
553 | at91_set_gpio_output(timer_led, 1); | 736 | /* |
737 | * NOTE: caller is responsible for passing information matching | ||
738 | * "pins" to whatever will be using each particular controller. | ||
739 | */ | ||
740 | switch (id) { | ||
741 | case AT91SAM9261_ID_SSC0: | ||
742 | pdev = &at91sam9261_ssc0_device; | ||
743 | configure_ssc0_pins(pins); | ||
744 | at91_clock_associate("ssc0_clk", &pdev->dev, "pclk"); | ||
745 | break; | ||
746 | case AT91SAM9261_ID_SSC1: | ||
747 | pdev = &at91sam9261_ssc1_device; | ||
748 | configure_ssc1_pins(pins); | ||
749 | at91_clock_associate("ssc1_clk", &pdev->dev, "pclk"); | ||
750 | break; | ||
751 | case AT91SAM9261_ID_SSC2: | ||
752 | pdev = &at91sam9261_ssc2_device; | ||
753 | configure_ssc2_pins(pins); | ||
754 | at91_clock_associate("ssc2_clk", &pdev->dev, "pclk"); | ||
755 | break; | ||
756 | default: | ||
757 | return; | ||
758 | } | ||
554 | 759 | ||
555 | at91_leds_cpu = cpu_led; | 760 | platform_device_register(pdev); |
556 | at91_leds_timer = timer_led; | ||
557 | } | 761 | } |
762 | |||
558 | #else | 763 | #else |
559 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} | 764 | void __init at91_add_device_ssc(unsigned id, unsigned pins) {} |
560 | #endif | 765 | #endif |
561 | 766 | ||
562 | 767 | ||
@@ -584,12 +789,15 @@ static struct atmel_uart_data dbgu_data = { | |||
584 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), | 789 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), |
585 | }; | 790 | }; |
586 | 791 | ||
792 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | ||
793 | |||
587 | static struct platform_device at91sam9261_dbgu_device = { | 794 | static struct platform_device at91sam9261_dbgu_device = { |
588 | .name = "atmel_usart", | 795 | .name = "atmel_usart", |
589 | .id = 0, | 796 | .id = 0, |
590 | .dev = { | 797 | .dev = { |
591 | .platform_data = &dbgu_data, | 798 | .dma_mask = &dbgu_dmamask, |
592 | .coherent_dma_mask = 0xffffffff, | 799 | .coherent_dma_mask = DMA_BIT_MASK(32), |
800 | .platform_data = &dbgu_data, | ||
593 | }, | 801 | }, |
594 | .resource = dbgu_resources, | 802 | .resource = dbgu_resources, |
595 | .num_resources = ARRAY_SIZE(dbgu_resources), | 803 | .num_resources = ARRAY_SIZE(dbgu_resources), |
@@ -619,23 +827,29 @@ static struct atmel_uart_data uart0_data = { | |||
619 | .use_dma_rx = 1, | 827 | .use_dma_rx = 1, |
620 | }; | 828 | }; |
621 | 829 | ||
830 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | ||
831 | |||
622 | static struct platform_device at91sam9261_uart0_device = { | 832 | static struct platform_device at91sam9261_uart0_device = { |
623 | .name = "atmel_usart", | 833 | .name = "atmel_usart", |
624 | .id = 1, | 834 | .id = 1, |
625 | .dev = { | 835 | .dev = { |
626 | .platform_data = &uart0_data, | 836 | .dma_mask = &uart0_dmamask, |
627 | .coherent_dma_mask = 0xffffffff, | 837 | .coherent_dma_mask = DMA_BIT_MASK(32), |
838 | .platform_data = &uart0_data, | ||
628 | }, | 839 | }, |
629 | .resource = uart0_resources, | 840 | .resource = uart0_resources, |
630 | .num_resources = ARRAY_SIZE(uart0_resources), | 841 | .num_resources = ARRAY_SIZE(uart0_resources), |
631 | }; | 842 | }; |
632 | 843 | ||
633 | static inline void configure_usart0_pins(void) | 844 | static inline void configure_usart0_pins(unsigned pins) |
634 | { | 845 | { |
635 | at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ | 846 | at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ |
636 | at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ | 847 | at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ |
637 | at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ | 848 | |
638 | at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ | 849 | if (pins & ATMEL_UART_RTS) |
850 | at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ | ||
851 | if (pins & ATMEL_UART_CTS) | ||
852 | at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ | ||
639 | } | 853 | } |
640 | 854 | ||
641 | static struct resource uart1_resources[] = { | 855 | static struct resource uart1_resources[] = { |
@@ -656,21 +870,29 @@ static struct atmel_uart_data uart1_data = { | |||
656 | .use_dma_rx = 1, | 870 | .use_dma_rx = 1, |
657 | }; | 871 | }; |
658 | 872 | ||
873 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | ||
874 | |||
659 | static struct platform_device at91sam9261_uart1_device = { | 875 | static struct platform_device at91sam9261_uart1_device = { |
660 | .name = "atmel_usart", | 876 | .name = "atmel_usart", |
661 | .id = 2, | 877 | .id = 2, |
662 | .dev = { | 878 | .dev = { |
663 | .platform_data = &uart1_data, | 879 | .dma_mask = &uart1_dmamask, |
664 | .coherent_dma_mask = 0xffffffff, | 880 | .coherent_dma_mask = DMA_BIT_MASK(32), |
881 | .platform_data = &uart1_data, | ||
665 | }, | 882 | }, |
666 | .resource = uart1_resources, | 883 | .resource = uart1_resources, |
667 | .num_resources = ARRAY_SIZE(uart1_resources), | 884 | .num_resources = ARRAY_SIZE(uart1_resources), |
668 | }; | 885 | }; |
669 | 886 | ||
670 | static inline void configure_usart1_pins(void) | 887 | static inline void configure_usart1_pins(unsigned pins) |
671 | { | 888 | { |
672 | at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ | 889 | at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ |
673 | at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ | 890 | at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ |
891 | |||
892 | if (pins & ATMEL_UART_RTS) | ||
893 | at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */ | ||
894 | if (pins & ATMEL_UART_CTS) | ||
895 | at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */ | ||
674 | } | 896 | } |
675 | 897 | ||
676 | static struct resource uart2_resources[] = { | 898 | static struct resource uart2_resources[] = { |
@@ -691,27 +913,35 @@ static struct atmel_uart_data uart2_data = { | |||
691 | .use_dma_rx = 1, | 913 | .use_dma_rx = 1, |
692 | }; | 914 | }; |
693 | 915 | ||
916 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | ||
917 | |||
694 | static struct platform_device at91sam9261_uart2_device = { | 918 | static struct platform_device at91sam9261_uart2_device = { |
695 | .name = "atmel_usart", | 919 | .name = "atmel_usart", |
696 | .id = 3, | 920 | .id = 3, |
697 | .dev = { | 921 | .dev = { |
698 | .platform_data = &uart2_data, | 922 | .dma_mask = &uart2_dmamask, |
699 | .coherent_dma_mask = 0xffffffff, | 923 | .coherent_dma_mask = DMA_BIT_MASK(32), |
924 | .platform_data = &uart2_data, | ||
700 | }, | 925 | }, |
701 | .resource = uart2_resources, | 926 | .resource = uart2_resources, |
702 | .num_resources = ARRAY_SIZE(uart2_resources), | 927 | .num_resources = ARRAY_SIZE(uart2_resources), |
703 | }; | 928 | }; |
704 | 929 | ||
705 | static inline void configure_usart2_pins(void) | 930 | static inline void configure_usart2_pins(unsigned pins) |
706 | { | 931 | { |
707 | at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ | 932 | at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ |
708 | at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ | 933 | at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ |
934 | |||
935 | if (pins & ATMEL_UART_RTS) | ||
936 | at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/ | ||
937 | if (pins & ATMEL_UART_CTS) | ||
938 | at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ | ||
709 | } | 939 | } |
710 | 940 | ||
711 | struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 941 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
712 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 942 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
713 | 943 | ||
714 | void __init at91_init_serial(struct at91_uart_config *config) | 944 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) |
715 | { | 945 | { |
716 | int i; | 946 | int i; |
717 | 947 | ||
@@ -719,17 +949,17 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
719 | for (i = 0; i < config->nr_tty; i++) { | 949 | for (i = 0; i < config->nr_tty; i++) { |
720 | switch (config->tty_map[i]) { | 950 | switch (config->tty_map[i]) { |
721 | case 0: | 951 | case 0: |
722 | configure_usart0_pins(); | 952 | configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
723 | at91_uarts[i] = &at91sam9261_uart0_device; | 953 | at91_uarts[i] = &at91sam9261_uart0_device; |
724 | at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart"); | 954 | at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart"); |
725 | break; | 955 | break; |
726 | case 1: | 956 | case 1: |
727 | configure_usart1_pins(); | 957 | configure_usart1_pins(0); |
728 | at91_uarts[i] = &at91sam9261_uart1_device; | 958 | at91_uarts[i] = &at91sam9261_uart1_device; |
729 | at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart"); | 959 | at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart"); |
730 | break; | 960 | break; |
731 | case 2: | 961 | case 2: |
732 | configure_usart2_pins(); | 962 | configure_usart2_pins(0); |
733 | at91_uarts[i] = &at91sam9261_uart2_device; | 963 | at91_uarts[i] = &at91sam9261_uart2_device; |
734 | at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart"); | 964 | at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart"); |
735 | break; | 965 | break; |
@@ -751,6 +981,48 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
751 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 981 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
752 | } | 982 | } |
753 | 983 | ||
984 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | ||
985 | { | ||
986 | struct platform_device *pdev; | ||
987 | |||
988 | switch (id) { | ||
989 | case 0: /* DBGU */ | ||
990 | pdev = &at91sam9261_dbgu_device; | ||
991 | configure_dbgu_pins(); | ||
992 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
993 | break; | ||
994 | case AT91SAM9261_ID_US0: | ||
995 | pdev = &at91sam9261_uart0_device; | ||
996 | configure_usart0_pins(pins); | ||
997 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
998 | break; | ||
999 | case AT91SAM9261_ID_US1: | ||
1000 | pdev = &at91sam9261_uart1_device; | ||
1001 | configure_usart1_pins(pins); | ||
1002 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1003 | break; | ||
1004 | case AT91SAM9261_ID_US2: | ||
1005 | pdev = &at91sam9261_uart2_device; | ||
1006 | configure_usart2_pins(pins); | ||
1007 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1008 | break; | ||
1009 | default: | ||
1010 | return; | ||
1011 | } | ||
1012 | pdev->id = portnr; /* update to mapped ID */ | ||
1013 | |||
1014 | if (portnr < ATMEL_MAX_UART) | ||
1015 | at91_uarts[portnr] = pdev; | ||
1016 | } | ||
1017 | |||
1018 | void __init at91_set_serial_console(unsigned portnr) | ||
1019 | { | ||
1020 | if (portnr < ATMEL_MAX_UART) | ||
1021 | atmel_default_console_device = at91_uarts[portnr]; | ||
1022 | if (!atmel_default_console_device) | ||
1023 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1024 | } | ||
1025 | |||
754 | void __init at91_add_device_serial(void) | 1026 | void __init at91_add_device_serial(void) |
755 | { | 1027 | { |
756 | int i; | 1028 | int i; |
@@ -761,7 +1033,9 @@ void __init at91_add_device_serial(void) | |||
761 | } | 1033 | } |
762 | } | 1034 | } |
763 | #else | 1035 | #else |
764 | void __init at91_init_serial(struct at91_uart_config *config) {} | 1036 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} |
1037 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
1038 | void __init at91_set_serial_console(unsigned portnr) {} | ||
765 | void __init at91_add_device_serial(void) {} | 1039 | void __init at91_add_device_serial(void) {} |
766 | #endif | 1040 | #endif |
767 | 1041 | ||
@@ -774,6 +1048,8 @@ void __init at91_add_device_serial(void) {} | |||
774 | */ | 1048 | */ |
775 | static int __init at91_add_standard_devices(void) | 1049 | static int __init at91_add_standard_devices(void) |
776 | { | 1050 | { |
1051 | at91_add_device_rtt(); | ||
1052 | at91_add_device_watchdog(); | ||
777 | return 0; | 1053 | return 0; |
778 | } | 1054 | } |
779 | 1055 | ||