diff options
Diffstat (limited to 'arch/mips/tx4938/toshiba_rbtx4938/setup.c')
-rw-r--r-- | arch/mips/tx4938/toshiba_rbtx4938/setup.c | 199 |
1 files changed, 72 insertions, 127 deletions
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/arch/mips/tx4938/toshiba_rbtx4938/setup.c index 61249f049cd6..3a3659e8633a 100644 --- a/arch/mips/tx4938/toshiba_rbtx4938/setup.c +++ b/arch/mips/tx4938/toshiba_rbtx4938/setup.c | |||
@@ -21,8 +21,8 @@ | |||
21 | #include <linux/pm.h> | 21 | #include <linux/pm.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/clk.h> | 23 | #include <linux/clk.h> |
24 | #include <linux/gpio.h> | ||
24 | 25 | ||
25 | #include <asm/wbflush.h> | ||
26 | #include <asm/reboot.h> | 26 | #include <asm/reboot.h> |
27 | #include <asm/time.h> | 27 | #include <asm/time.h> |
28 | #include <asm/txx9tmr.h> | 28 | #include <asm/txx9tmr.h> |
@@ -34,7 +34,7 @@ | |||
34 | #endif | 34 | #endif |
35 | #include <linux/spi/spi.h> | 35 | #include <linux/spi/spi.h> |
36 | #include <asm/tx4938/spi.h> | 36 | #include <asm/tx4938/spi.h> |
37 | #include <asm/gpio.h> | 37 | #include <asm/txx9pio.h> |
38 | 38 | ||
39 | extern char * __init prom_getcmdline(void); | 39 | extern char * __init prom_getcmdline(void); |
40 | static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr); | 40 | static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr); |
@@ -90,12 +90,11 @@ void rbtx4938_machine_restart(char *command) | |||
90 | local_irq_disable(); | 90 | local_irq_disable(); |
91 | 91 | ||
92 | printk("Rebooting..."); | 92 | printk("Rebooting..."); |
93 | *rbtx4938_softresetlock_ptr = 1; | 93 | writeb(1, rbtx4938_softresetlock_addr); |
94 | *rbtx4938_sfvol_ptr = 1; | 94 | writeb(1, rbtx4938_sfvol_addr); |
95 | *rbtx4938_softreset_ptr = 1; | 95 | writeb(1, rbtx4938_softreset_addr); |
96 | wbflush(); | 96 | while(1) |
97 | 97 | ; | |
98 | while(1); | ||
99 | } | 98 | } |
100 | 99 | ||
101 | void __init | 100 | void __init |
@@ -487,7 +486,7 @@ static int __init tx4938_pcibios_init(void) | |||
487 | } | 486 | } |
488 | 487 | ||
489 | /* Reset PCI Bus */ | 488 | /* Reset PCI Bus */ |
490 | *rbtx4938_pcireset_ptr = 0; | 489 | writeb(0, rbtx4938_pcireset_addr); |
491 | /* Reset PCIC */ | 490 | /* Reset PCIC */ |
492 | tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST; | 491 | tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST; |
493 | if (txboard_pci66_mode > 0) | 492 | if (txboard_pci66_mode > 0) |
@@ -495,8 +494,8 @@ static int __init tx4938_pcibios_init(void) | |||
495 | mdelay(10); | 494 | mdelay(10); |
496 | /* clear PCIC reset */ | 495 | /* clear PCIC reset */ |
497 | tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST; | 496 | tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST; |
498 | *rbtx4938_pcireset_ptr = 1; | 497 | writeb(1, rbtx4938_pcireset_addr); |
499 | wbflush(); | 498 | mmiowb(); |
500 | tx4938_report_pcic_status1(tx4938_pcicptr); | 499 | tx4938_report_pcic_status1(tx4938_pcicptr); |
501 | 500 | ||
502 | tx4938_report_pciclk(); | 501 | tx4938_report_pciclk(); |
@@ -504,15 +503,15 @@ static int __init tx4938_pcibios_init(void) | |||
504 | if (txboard_pci66_mode == 0 && | 503 | if (txboard_pci66_mode == 0 && |
505 | txboard_pci66_check(&tx4938_pci_controller[0], 0, 0)) { | 504 | txboard_pci66_check(&tx4938_pci_controller[0], 0, 0)) { |
506 | /* Reset PCI Bus */ | 505 | /* Reset PCI Bus */ |
507 | *rbtx4938_pcireset_ptr = 0; | 506 | writeb(0, rbtx4938_pcireset_addr); |
508 | /* Reset PCIC */ | 507 | /* Reset PCIC */ |
509 | tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST; | 508 | tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST; |
510 | tx4938_pciclk66_setup(); | 509 | tx4938_pciclk66_setup(); |
511 | mdelay(10); | 510 | mdelay(10); |
512 | /* clear PCIC reset */ | 511 | /* clear PCIC reset */ |
513 | tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST; | 512 | tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST; |
514 | *rbtx4938_pcireset_ptr = 1; | 513 | writeb(1, rbtx4938_pcireset_addr); |
515 | wbflush(); | 514 | mmiowb(); |
516 | /* Reinitialize PCIC */ | 515 | /* Reinitialize PCIC */ |
517 | tx4938_report_pciclk(); | 516 | tx4938_report_pciclk(); |
518 | tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb); | 517 | tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb); |
@@ -615,9 +614,6 @@ static void __init rbtx4938_spi_setup(void) | |||
615 | { | 614 | { |
616 | /* set SPI_SEL */ | 615 | /* set SPI_SEL */ |
617 | tx4938_ccfgptr->pcfg |= TX4938_PCFG_SPI_SEL; | 616 | tx4938_ccfgptr->pcfg |= TX4938_PCFG_SPI_SEL; |
618 | /* chip selects for SPI devices */ | ||
619 | tx4938_pioptr->dout |= (1 << SEEPROM1_CS); | ||
620 | tx4938_pioptr->dir |= (1 << SEEPROM1_CS); | ||
621 | } | 617 | } |
622 | 618 | ||
623 | static struct resource rbtx4938_fpga_resource; | 619 | static struct resource rbtx4938_fpga_resource; |
@@ -776,12 +772,13 @@ void __init tx4938_board_setup(void) | |||
776 | txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL); | 772 | txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL); |
777 | 773 | ||
778 | /* enable DMA */ | 774 | /* enable DMA */ |
779 | TX4938_WR64(0xff1fb150, TX4938_DMA_MCR_MSTEN); | 775 | for (i = 0; i < 2; i++) |
780 | TX4938_WR64(0xff1fb950, TX4938_DMA_MCR_MSTEN); | 776 | ____raw_writeq(TX4938_DMA_MCR_MSTEN, |
777 | (void __iomem *)(TX4938_DMA_REG(i) + 0x50)); | ||
781 | 778 | ||
782 | /* PIO */ | 779 | /* PIO */ |
783 | tx4938_pioptr->maskcpu = 0; | 780 | __raw_writel(0, &tx4938_pioptr->maskcpu); |
784 | tx4938_pioptr->maskext = 0; | 781 | __raw_writel(0, &tx4938_pioptr->maskext); |
785 | 782 | ||
786 | /* TX4938 internal registers */ | 783 | /* TX4938 internal registers */ |
787 | if (request_resource(&iomem_resource, &tx4938_reg_resource)) | 784 | if (request_resource(&iomem_resource, &tx4938_reg_resource)) |
@@ -863,10 +860,6 @@ void __init plat_mem_setup(void) | |||
863 | if (txx9_master_clock == 0) | 860 | if (txx9_master_clock == 0) |
864 | txx9_master_clock = 25000000; /* 25MHz */ | 861 | txx9_master_clock = 25000000; /* 25MHz */ |
865 | tx4938_board_setup(); | 862 | tx4938_board_setup(); |
866 | /* setup serial stuff */ | ||
867 | TX4938_WR(0xff1ff314, 0x00000000); /* h/w flow control off */ | ||
868 | TX4938_WR(0xff1ff414, 0x00000000); /* h/w flow control off */ | ||
869 | |||
870 | #ifndef CONFIG_PCI | 863 | #ifndef CONFIG_PCI |
871 | set_io_port_base(RBTX4938_ETHER_BASE); | 864 | set_io_port_base(RBTX4938_ETHER_BASE); |
872 | #endif | 865 | #endif |
@@ -932,16 +925,16 @@ void __init plat_mem_setup(void) | |||
932 | pcfg = tx4938_ccfgptr->pcfg; /* updated */ | 925 | pcfg = tx4938_ccfgptr->pcfg; /* updated */ |
933 | /* fixup piosel */ | 926 | /* fixup piosel */ |
934 | if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == | 927 | if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == |
935 | TX4938_PCFG_ATA_SEL) { | 928 | TX4938_PCFG_ATA_SEL) |
936 | *rbtx4938_piosel_ptr = (*rbtx4938_piosel_ptr & 0x03) | 0x04; | 929 | writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x04, |
937 | } | 930 | rbtx4938_piosel_addr); |
938 | else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == | 931 | else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == |
939 | TX4938_PCFG_NDF_SEL) { | 932 | TX4938_PCFG_NDF_SEL) |
940 | *rbtx4938_piosel_ptr = (*rbtx4938_piosel_ptr & 0x03) | 0x08; | 933 | writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x08, |
941 | } | 934 | rbtx4938_piosel_addr); |
942 | else { | 935 | else |
943 | *rbtx4938_piosel_ptr &= ~(0x08 | 0x04); | 936 | writeb(readb(rbtx4938_piosel_addr) & ~(0x08 | 0x04), |
944 | } | 937 | rbtx4938_piosel_addr); |
945 | 938 | ||
946 | rbtx4938_fpga_resource.name = "FPGA Registers"; | 939 | rbtx4938_fpga_resource.name = "FPGA Registers"; |
947 | rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR); | 940 | rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR); |
@@ -950,17 +943,14 @@ void __init plat_mem_setup(void) | |||
950 | if (request_resource(&iomem_resource, &rbtx4938_fpga_resource)) | 943 | if (request_resource(&iomem_resource, &rbtx4938_fpga_resource)) |
951 | printk("request resource for fpga failed\n"); | 944 | printk("request resource for fpga failed\n"); |
952 | 945 | ||
953 | /* disable all OnBoard I/O interrupts */ | ||
954 | *rbtx4938_imask_ptr = 0; | ||
955 | |||
956 | _machine_restart = rbtx4938_machine_restart; | 946 | _machine_restart = rbtx4938_machine_restart; |
957 | _machine_halt = rbtx4938_machine_halt; | 947 | _machine_halt = rbtx4938_machine_halt; |
958 | pm_power_off = rbtx4938_machine_power_off; | 948 | pm_power_off = rbtx4938_machine_power_off; |
959 | 949 | ||
960 | *rbtx4938_led_ptr = 0xff; | 950 | writeb(0xff, rbtx4938_led_addr); |
961 | printk("RBTX4938 --- FPGA(Rev %02x)", *rbtx4938_fpga_rev_ptr); | 951 | printk(KERN_INFO "RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n", |
962 | printk(" DIPSW:%02x,%02x\n", | 952 | readb(rbtx4938_fpga_rev_addr), |
963 | *rbtx4938_dipsw_ptr, *rbtx4938_bdipsw_ptr); | 953 | readb(rbtx4938_dipsw_addr), readb(rbtx4938_bdipsw_addr)); |
964 | } | 954 | } |
965 | 955 | ||
966 | static int __init rbtx4938_ne_init(void) | 956 | static int __init rbtx4938_ne_init(void) |
@@ -984,106 +974,48 @@ device_initcall(rbtx4938_ne_init); | |||
984 | 974 | ||
985 | /* GPIO support */ | 975 | /* GPIO support */ |
986 | 976 | ||
987 | static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock); | 977 | int gpio_to_irq(unsigned gpio) |
988 | |||
989 | static void rbtx4938_spi_gpio_set(unsigned gpio, int value) | ||
990 | { | 978 | { |
991 | u8 val; | 979 | return -EINVAL; |
992 | unsigned long flags; | ||
993 | gpio -= 16; | ||
994 | spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags); | ||
995 | val = *rbtx4938_spics_ptr; | ||
996 | if (value) | ||
997 | val |= 1 << gpio; | ||
998 | else | ||
999 | val &= ~(1 << gpio); | ||
1000 | *rbtx4938_spics_ptr = val; | ||
1001 | mmiowb(); | ||
1002 | spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags); | ||
1003 | } | 980 | } |
1004 | 981 | ||
1005 | static int rbtx4938_spi_gpio_dir_out(unsigned gpio, int value) | 982 | int irq_to_gpio(unsigned irq) |
1006 | { | 983 | { |
1007 | rbtx4938_spi_gpio_set(gpio, value); | 984 | return -EINVAL; |
1008 | return 0; | ||
1009 | } | 985 | } |
1010 | 986 | ||
1011 | static DEFINE_SPINLOCK(tx4938_gpio_lock); | 987 | static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock); |
1012 | |||
1013 | static int tx4938_gpio_get(unsigned gpio) | ||
1014 | { | ||
1015 | return tx4938_pioptr->din & (1 << gpio); | ||
1016 | } | ||
1017 | 988 | ||
1018 | static void tx4938_gpio_set_raw(unsigned gpio, int value) | 989 | static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset, |
990 | int value) | ||
1019 | { | 991 | { |
1020 | u32 val; | 992 | u8 val; |
1021 | val = tx4938_pioptr->dout; | 993 | unsigned long flags; |
994 | spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags); | ||
995 | val = readb(rbtx4938_spics_addr); | ||
1022 | if (value) | 996 | if (value) |
1023 | val |= 1 << gpio; | 997 | val |= 1 << offset; |
1024 | else | 998 | else |
1025 | val &= ~(1 << gpio); | 999 | val &= ~(1 << offset); |
1026 | tx4938_pioptr->dout = val; | 1000 | writeb(val, rbtx4938_spics_addr); |
1027 | } | ||
1028 | |||
1029 | static void tx4938_gpio_set(unsigned gpio, int value) | ||
1030 | { | ||
1031 | unsigned long flags; | ||
1032 | spin_lock_irqsave(&tx4938_gpio_lock, flags); | ||
1033 | tx4938_gpio_set_raw(gpio, value); | ||
1034 | mmiowb(); | ||
1035 | spin_unlock_irqrestore(&tx4938_gpio_lock, flags); | ||
1036 | } | ||
1037 | |||
1038 | static int tx4938_gpio_dir_in(unsigned gpio) | ||
1039 | { | ||
1040 | spin_lock_irq(&tx4938_gpio_lock); | ||
1041 | tx4938_pioptr->dir &= ~(1 << gpio); | ||
1042 | mmiowb(); | 1001 | mmiowb(); |
1043 | spin_unlock_irq(&tx4938_gpio_lock); | 1002 | spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags); |
1044 | return 0; | ||
1045 | } | ||
1046 | |||
1047 | static int tx4938_gpio_dir_out(unsigned int gpio, int value) | ||
1048 | { | ||
1049 | spin_lock_irq(&tx4938_gpio_lock); | ||
1050 | tx4938_gpio_set_raw(gpio, value); | ||
1051 | tx4938_pioptr->dir |= 1 << gpio; | ||
1052 | mmiowb(); | ||
1053 | spin_unlock_irq(&tx4938_gpio_lock); | ||
1054 | return 0; | ||
1055 | } | ||
1056 | |||
1057 | int gpio_direction_input(unsigned gpio) | ||
1058 | { | ||
1059 | if (gpio < 16) | ||
1060 | return tx4938_gpio_dir_in(gpio); | ||
1061 | return -EINVAL; | ||
1062 | } | ||
1063 | |||
1064 | int gpio_direction_output(unsigned gpio, int value) | ||
1065 | { | ||
1066 | if (gpio < 16) | ||
1067 | return tx4938_gpio_dir_out(gpio, value); | ||
1068 | if (gpio < 16 + 3) | ||
1069 | return rbtx4938_spi_gpio_dir_out(gpio, value); | ||
1070 | return -EINVAL; | ||
1071 | } | 1003 | } |
1072 | 1004 | ||
1073 | int gpio_get_value(unsigned gpio) | 1005 | static int rbtx4938_spi_gpio_dir_out(struct gpio_chip *chip, |
1006 | unsigned int offset, int value) | ||
1074 | { | 1007 | { |
1075 | if (gpio < 16) | 1008 | rbtx4938_spi_gpio_set(chip, offset, value); |
1076 | return tx4938_gpio_get(gpio); | ||
1077 | return 0; | 1009 | return 0; |
1078 | } | 1010 | } |
1079 | 1011 | ||
1080 | void gpio_set_value(unsigned gpio, int value) | 1012 | static struct gpio_chip rbtx4938_spi_gpio_chip = { |
1081 | { | 1013 | .set = rbtx4938_spi_gpio_set, |
1082 | if (gpio < 16) | 1014 | .direction_output = rbtx4938_spi_gpio_dir_out, |
1083 | tx4938_gpio_set(gpio, value); | 1015 | .label = "RBTX4938-SPICS", |
1084 | else | 1016 | .base = 16, |
1085 | rbtx4938_spi_gpio_set(gpio, value); | 1017 | .ngpio = 3, |
1086 | } | 1018 | }; |
1087 | 1019 | ||
1088 | /* SPI support */ | 1020 | /* SPI support */ |
1089 | 1021 | ||
@@ -1094,7 +1026,6 @@ static void __init txx9_spi_init(unsigned long base, int irq) | |||
1094 | .start = base, | 1026 | .start = base, |
1095 | .end = base + 0x20 - 1, | 1027 | .end = base + 0x20 - 1, |
1096 | .flags = IORESOURCE_MEM, | 1028 | .flags = IORESOURCE_MEM, |
1097 | .parent = &tx4938_reg_resource, | ||
1098 | }, { | 1029 | }, { |
1099 | .start = irq, | 1030 | .start = irq, |
1100 | .flags = IORESOURCE_IRQ, | 1031 | .flags = IORESOURCE_IRQ, |
@@ -1118,10 +1049,25 @@ static int __init rbtx4938_spi_init(void) | |||
1118 | spi_eeprom_register(SEEPROM1_CS); | 1049 | spi_eeprom_register(SEEPROM1_CS); |
1119 | spi_eeprom_register(16 + SEEPROM2_CS); | 1050 | spi_eeprom_register(16 + SEEPROM2_CS); |
1120 | spi_eeprom_register(16 + SEEPROM3_CS); | 1051 | spi_eeprom_register(16 + SEEPROM3_CS); |
1052 | gpio_request(16 + SRTC_CS, "rtc-rs5c348"); | ||
1053 | gpio_direction_output(16 + SRTC_CS, 0); | ||
1054 | gpio_request(SEEPROM1_CS, "seeprom1"); | ||
1055 | gpio_direction_output(SEEPROM1_CS, 1); | ||
1056 | gpio_request(16 + SEEPROM2_CS, "seeprom2"); | ||
1057 | gpio_direction_output(16 + SEEPROM2_CS, 1); | ||
1058 | gpio_request(16 + SEEPROM3_CS, "seeprom3"); | ||
1059 | gpio_direction_output(16 + SEEPROM3_CS, 1); | ||
1121 | txx9_spi_init(TX4938_SPI_REG & 0xfffffffffULL, RBTX4938_IRQ_IRC_SPI); | 1060 | txx9_spi_init(TX4938_SPI_REG & 0xfffffffffULL, RBTX4938_IRQ_IRC_SPI); |
1122 | return 0; | 1061 | return 0; |
1123 | } | 1062 | } |
1124 | arch_initcall(rbtx4938_spi_init); | 1063 | |
1064 | static int __init rbtx4938_arch_init(void) | ||
1065 | { | ||
1066 | txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16); | ||
1067 | gpiochip_add(&rbtx4938_spi_gpio_chip); | ||
1068 | return rbtx4938_spi_init(); | ||
1069 | } | ||
1070 | arch_initcall(rbtx4938_arch_init); | ||
1125 | 1071 | ||
1126 | /* Watchdog support */ | 1072 | /* Watchdog support */ |
1127 | 1073 | ||
@@ -1131,7 +1077,6 @@ static int __init txx9_wdt_init(unsigned long base) | |||
1131 | .start = base, | 1077 | .start = base, |
1132 | .end = base + 0x100 - 1, | 1078 | .end = base + 0x100 - 1, |
1133 | .flags = IORESOURCE_MEM, | 1079 | .flags = IORESOURCE_MEM, |
1134 | .parent = &tx4938_reg_resource, | ||
1135 | }; | 1080 | }; |
1136 | struct platform_device *dev = | 1081 | struct platform_device *dev = |
1137 | platform_device_register_simple("txx9wdt", -1, &res, 1); | 1082 | platform_device_register_simple("txx9wdt", -1, &res, 1); |