aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/mach-at32ap/at32ap7000.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/mach-at32ap/at32ap7000.c')
-rw-r--r--arch/avr32/mach-at32ap/at32ap7000.c182
1 files changed, 106 insertions, 76 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c
index 7ff6ad8bab5f..48f4ef38c70e 100644
--- a/arch/avr32/mach-at32ap/at32ap7000.c
+++ b/arch/avr32/mach-at32ap/at32ap7000.c
@@ -11,6 +11,7 @@
11 11
12#include <asm/io.h> 12#include <asm/io.h>
13 13
14#include <asm/arch/at32ap7000.h>
14#include <asm/arch/board.h> 15#include <asm/arch/board.h>
15#include <asm/arch/portmux.h> 16#include <asm/arch/portmux.h>
16#include <asm/arch/sm.h> 17#include <asm/arch/sm.h>
@@ -57,6 +58,9 @@ static struct platform_device _name##_id##_device = { \
57 .num_resources = ARRAY_SIZE(_name##_id##_resource), \ 58 .num_resources = ARRAY_SIZE(_name##_id##_resource), \
58} 59}
59 60
61#define select_peripheral(pin, periph, flags) \
62 at32_select_periph(GPIO_PIN_##pin, GPIO_##periph, flags)
63
60#define DEV_CLK(_name, devname, bus, _index) \ 64#define DEV_CLK(_name, devname, bus, _index) \
61static struct clk devname##_##_name = { \ 65static struct clk devname##_##_name = { \
62 .name = #_name, \ 66 .name = #_name, \
@@ -67,18 +71,6 @@ static struct clk devname##_##_name = { \
67 .index = _index, \ 71 .index = _index, \
68} 72}
69 73
70enum {
71 PIOA,
72 PIOB,
73 PIOC,
74 PIOD,
75};
76
77enum {
78 FUNC_A,
79 FUNC_B,
80};
81
82unsigned long at32ap7000_osc_rates[3] = { 74unsigned long at32ap7000_osc_rates[3] = {
83 [0] = 32768, 75 [0] = 32768,
84 /* FIXME: these are ATSTK1002-specific */ 76 /* FIXME: these are ATSTK1002-specific */
@@ -569,26 +561,26 @@ DEV_CLK(usart, atmel_usart3, pba, 6);
569 561
570static inline void configure_usart0_pins(void) 562static inline void configure_usart0_pins(void)
571{ 563{
572 portmux_set_func(PIOA, 8, FUNC_B); /* RXD */ 564 select_peripheral(PA(8), PERIPH_B, 0); /* RXD */
573 portmux_set_func(PIOA, 9, FUNC_B); /* TXD */ 565 select_peripheral(PA(9), PERIPH_B, 0); /* TXD */
574} 566}
575 567
576static inline void configure_usart1_pins(void) 568static inline void configure_usart1_pins(void)
577{ 569{
578 portmux_set_func(PIOA, 17, FUNC_A); /* RXD */ 570 select_peripheral(PA(17), PERIPH_A, 0); /* RXD */
579 portmux_set_func(PIOA, 18, FUNC_A); /* TXD */ 571 select_peripheral(PA(18), PERIPH_A, 0); /* TXD */
580} 572}
581 573
582static inline void configure_usart2_pins(void) 574static inline void configure_usart2_pins(void)
583{ 575{
584 portmux_set_func(PIOB, 26, FUNC_B); /* RXD */ 576 select_peripheral(PB(26), PERIPH_B, 0); /* RXD */
585 portmux_set_func(PIOB, 27, FUNC_B); /* TXD */ 577 select_peripheral(PB(27), PERIPH_B, 0); /* TXD */
586} 578}
587 579
588static inline void configure_usart3_pins(void) 580static inline void configure_usart3_pins(void)
589{ 581{
590 portmux_set_func(PIOB, 18, FUNC_B); /* RXD */ 582 select_peripheral(PB(18), PERIPH_B, 0); /* RXD */
591 portmux_set_func(PIOB, 17, FUNC_B); /* TXD */ 583 select_peripheral(PB(17), PERIPH_B, 0); /* TXD */
592} 584}
593 585
594static struct platform_device *at32_usarts[4]; 586static struct platform_device *at32_usarts[4];
@@ -654,6 +646,15 @@ DEFINE_DEV_DATA(macb, 0);
654DEV_CLK(hclk, macb0, hsb, 8); 646DEV_CLK(hclk, macb0, hsb, 8);
655DEV_CLK(pclk, macb0, pbb, 6); 647DEV_CLK(pclk, macb0, pbb, 6);
656 648
649static struct eth_platform_data macb1_data;
650static struct resource macb1_resource[] = {
651 PBMEM(0xfff01c00),
652 IRQ(26),
653};
654DEFINE_DEV_DATA(macb, 1);
655DEV_CLK(hclk, macb1, hsb, 9);
656DEV_CLK(pclk, macb1, pbb, 7);
657
657struct platform_device *__init 658struct platform_device *__init
658at32_add_device_eth(unsigned int id, struct eth_platform_data *data) 659at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
659{ 660{
@@ -663,27 +664,54 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
663 case 0: 664 case 0:
664 pdev = &macb0_device; 665 pdev = &macb0_device;
665 666
666 portmux_set_func(PIOC, 3, FUNC_A); /* TXD0 */ 667 select_peripheral(PC(3), PERIPH_A, 0); /* TXD0 */
667 portmux_set_func(PIOC, 4, FUNC_A); /* TXD1 */ 668 select_peripheral(PC(4), PERIPH_A, 0); /* TXD1 */
668 portmux_set_func(PIOC, 7, FUNC_A); /* TXEN */ 669 select_peripheral(PC(7), PERIPH_A, 0); /* TXEN */
669 portmux_set_func(PIOC, 8, FUNC_A); /* TXCK */ 670 select_peripheral(PC(8), PERIPH_A, 0); /* TXCK */
670 portmux_set_func(PIOC, 9, FUNC_A); /* RXD0 */ 671 select_peripheral(PC(9), PERIPH_A, 0); /* RXD0 */
671 portmux_set_func(PIOC, 10, FUNC_A); /* RXD1 */ 672 select_peripheral(PC(10), PERIPH_A, 0); /* RXD1 */
672 portmux_set_func(PIOC, 13, FUNC_A); /* RXER */ 673 select_peripheral(PC(13), PERIPH_A, 0); /* RXER */
673 portmux_set_func(PIOC, 15, FUNC_A); /* RXDV */ 674 select_peripheral(PC(15), PERIPH_A, 0); /* RXDV */
674 portmux_set_func(PIOC, 16, FUNC_A); /* MDC */ 675 select_peripheral(PC(16), PERIPH_A, 0); /* MDC */
675 portmux_set_func(PIOC, 17, FUNC_A); /* MDIO */ 676 select_peripheral(PC(17), PERIPH_A, 0); /* MDIO */
677
678 if (!data->is_rmii) {
679 select_peripheral(PC(0), PERIPH_A, 0); /* COL */
680 select_peripheral(PC(1), PERIPH_A, 0); /* CRS */
681 select_peripheral(PC(2), PERIPH_A, 0); /* TXER */
682 select_peripheral(PC(5), PERIPH_A, 0); /* TXD2 */
683 select_peripheral(PC(6), PERIPH_A, 0); /* TXD3 */
684 select_peripheral(PC(11), PERIPH_A, 0); /* RXD2 */
685 select_peripheral(PC(12), PERIPH_A, 0); /* RXD3 */
686 select_peripheral(PC(14), PERIPH_A, 0); /* RXCK */
687 select_peripheral(PC(18), PERIPH_A, 0); /* SPD */
688 }
689 break;
690
691 case 1:
692 pdev = &macb1_device;
693
694 select_peripheral(PD(13), PERIPH_B, 0); /* TXD0 */
695 select_peripheral(PD(14), PERIPH_B, 0); /* TXD1 */
696 select_peripheral(PD(11), PERIPH_B, 0); /* TXEN */
697 select_peripheral(PD(12), PERIPH_B, 0); /* TXCK */
698 select_peripheral(PD(10), PERIPH_B, 0); /* RXD0 */
699 select_peripheral(PD(6), PERIPH_B, 0); /* RXD1 */
700 select_peripheral(PD(5), PERIPH_B, 0); /* RXER */
701 select_peripheral(PD(4), PERIPH_B, 0); /* RXDV */
702 select_peripheral(PD(3), PERIPH_B, 0); /* MDC */
703 select_peripheral(PD(2), PERIPH_B, 0); /* MDIO */
676 704
677 if (!data->is_rmii) { 705 if (!data->is_rmii) {
678 portmux_set_func(PIOC, 0, FUNC_A); /* COL */ 706 select_peripheral(PC(19), PERIPH_B, 0); /* COL */
679 portmux_set_func(PIOC, 1, FUNC_A); /* CRS */ 707 select_peripheral(PC(23), PERIPH_B, 0); /* CRS */
680 portmux_set_func(PIOC, 2, FUNC_A); /* TXER */ 708 select_peripheral(PC(26), PERIPH_B, 0); /* TXER */
681 portmux_set_func(PIOC, 5, FUNC_A); /* TXD2 */ 709 select_peripheral(PC(27), PERIPH_B, 0); /* TXD2 */
682 portmux_set_func(PIOC, 6, FUNC_A); /* TXD3 */ 710 select_peripheral(PC(28), PERIPH_B, 0); /* TXD3 */
683 portmux_set_func(PIOC, 11, FUNC_A); /* RXD2 */ 711 select_peripheral(PC(29), PERIPH_B, 0); /* RXD2 */
684 portmux_set_func(PIOC, 12, FUNC_A); /* RXD3 */ 712 select_peripheral(PC(30), PERIPH_B, 0); /* RXD3 */
685 portmux_set_func(PIOC, 14, FUNC_A); /* RXCK */ 713 select_peripheral(PC(24), PERIPH_B, 0); /* RXCK */
686 portmux_set_func(PIOC, 18, FUNC_A); /* SPD */ 714 select_peripheral(PD(15), PERIPH_B, 0); /* SPD */
687 } 715 }
688 break; 716 break;
689 717
@@ -714,12 +742,12 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
714 switch (id) { 742 switch (id) {
715 case 0: 743 case 0:
716 pdev = &spi0_device; 744 pdev = &spi0_device;
717 portmux_set_func(PIOA, 0, FUNC_A); /* MISO */ 745 select_peripheral(PA(0), PERIPH_A, 0); /* MISO */
718 portmux_set_func(PIOA, 1, FUNC_A); /* MOSI */ 746 select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */
719 portmux_set_func(PIOA, 2, FUNC_A); /* SCK */ 747 select_peripheral(PA(2), PERIPH_A, 0); /* SCK */
720 portmux_set_func(PIOA, 3, FUNC_A); /* NPCS0 */ 748 select_peripheral(PA(3), PERIPH_A, 0); /* NPCS0 */
721 portmux_set_func(PIOA, 4, FUNC_A); /* NPCS1 */ 749 select_peripheral(PA(4), PERIPH_A, 0); /* NPCS1 */
722 portmux_set_func(PIOA, 5, FUNC_A); /* NPCS2 */ 750 select_peripheral(PA(5), PERIPH_A, 0); /* NPCS2 */
723 break; 751 break;
724 752
725 default: 753 default:
@@ -762,37 +790,37 @@ at32_add_device_lcdc(unsigned int id, struct lcdc_platform_data *data)
762 switch (id) { 790 switch (id) {
763 case 0: 791 case 0:
764 pdev = &lcdc0_device; 792 pdev = &lcdc0_device;
765 portmux_set_func(PIOC, 19, FUNC_A); /* CC */ 793 select_peripheral(PC(19), PERIPH_A, 0); /* CC */
766 portmux_set_func(PIOC, 20, FUNC_A); /* HSYNC */ 794 select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
767 portmux_set_func(PIOC, 21, FUNC_A); /* PCLK */ 795 select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
768 portmux_set_func(PIOC, 22, FUNC_A); /* VSYNC */ 796 select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
769 portmux_set_func(PIOC, 23, FUNC_A); /* DVAL */ 797 select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
770 portmux_set_func(PIOC, 24, FUNC_A); /* MODE */ 798 select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
771 portmux_set_func(PIOC, 25, FUNC_A); /* PWR */ 799 select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
772 portmux_set_func(PIOC, 26, FUNC_A); /* DATA0 */ 800 select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
773 portmux_set_func(PIOC, 27, FUNC_A); /* DATA1 */ 801 select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
774 portmux_set_func(PIOC, 28, FUNC_A); /* DATA2 */ 802 select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
775 portmux_set_func(PIOC, 29, FUNC_A); /* DATA3 */ 803 select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
776 portmux_set_func(PIOC, 30, FUNC_A); /* DATA4 */ 804 select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
777 portmux_set_func(PIOC, 31, FUNC_A); /* DATA5 */ 805 select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
778 portmux_set_func(PIOD, 0, FUNC_A); /* DATA6 */ 806 select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
779 portmux_set_func(PIOD, 1, FUNC_A); /* DATA7 */ 807 select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
780 portmux_set_func(PIOD, 2, FUNC_A); /* DATA8 */ 808 select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
781 portmux_set_func(PIOD, 3, FUNC_A); /* DATA9 */ 809 select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
782 portmux_set_func(PIOD, 4, FUNC_A); /* DATA10 */ 810 select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
783 portmux_set_func(PIOD, 5, FUNC_A); /* DATA11 */ 811 select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
784 portmux_set_func(PIOD, 6, FUNC_A); /* DATA12 */ 812 select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
785 portmux_set_func(PIOD, 7, FUNC_A); /* DATA13 */ 813 select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
786 portmux_set_func(PIOD, 8, FUNC_A); /* DATA14 */ 814 select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
787 portmux_set_func(PIOD, 9, FUNC_A); /* DATA15 */ 815 select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
788 portmux_set_func(PIOD, 10, FUNC_A); /* DATA16 */ 816 select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
789 portmux_set_func(PIOD, 11, FUNC_A); /* DATA17 */ 817 select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
790 portmux_set_func(PIOD, 12, FUNC_A); /* DATA18 */ 818 select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
791 portmux_set_func(PIOD, 13, FUNC_A); /* DATA19 */ 819 select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
792 portmux_set_func(PIOD, 14, FUNC_A); /* DATA20 */ 820 select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
793 portmux_set_func(PIOD, 15, FUNC_A); /* DATA21 */ 821 select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
794 portmux_set_func(PIOD, 16, FUNC_A); /* DATA22 */ 822 select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
795 portmux_set_func(PIOD, 17, FUNC_A); /* DATA23 */ 823 select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
796 824
797 clk_set_parent(&lcdc0_pixclk, &pll0); 825 clk_set_parent(&lcdc0_pixclk, &pll0);
798 clk_set_rate(&lcdc0_pixclk, clk_get_rate(&pll0)); 826 clk_set_rate(&lcdc0_pixclk, clk_get_rate(&pll0));
@@ -838,6 +866,8 @@ struct clk *at32_clock_list[] = {
838 &atmel_usart3_usart, 866 &atmel_usart3_usart,
839 &macb0_hclk, 867 &macb0_hclk,
840 &macb0_pclk, 868 &macb0_pclk,
869 &macb1_hclk,
870 &macb1_pclk,
841 &spi0_mck, 871 &spi0_mck,
842 &lcdc0_hclk, 872 &lcdc0_hclk,
843 &lcdc0_pixclk, 873 &lcdc0_pixclk,