Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 1 | /* |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 2 | * Setup pointers to hardware-dependent routines. |
| 3 | * Copyright (C) 2000-2001 Toshiba Corporation |
| 4 | * |
| 5 | * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the |
| 6 | * terms of the GNU General Public License version 2. This program is |
| 7 | * licensed "as is" without any warranty of any kind, whether express |
| 8 | * or implied. |
| 9 | * |
| 10 | * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) |
| 11 | */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/ioport.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 15 | #include <linux/delay.h> |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/console.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 18 | #include <linux/pm.h> |
Atsushi Nemoto | 57e386c | 2007-05-01 00:27:58 +0900 | [diff] [blame] | 19 | #include <linux/platform_device.h> |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 20 | #include <linux/gpio.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 21 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 22 | #include <asm/reboot.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 23 | #include <asm/io.h> |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 24 | #include <asm/txx9/generic.h> |
| 25 | #include <asm/txx9/pci.h> |
Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 26 | #include <asm/txx9/rbtx4938.h> |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 27 | #include <linux/spi/spi.h> |
Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 28 | #include <asm/txx9/spi.h> |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 29 | #include <asm/txx9pio.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 30 | |
Atsushi Nemoto | 7b22609 | 2008-07-14 00:15:04 +0900 | [diff] [blame] | 31 | static void rbtx4938_machine_halt(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 32 | { |
| 33 | printk(KERN_NOTICE "System Halted\n"); |
| 34 | local_irq_disable(); |
| 35 | |
| 36 | while (1) |
| 37 | __asm__(".set\tmips3\n\t" |
| 38 | "wait\n\t" |
| 39 | ".set\tmips0"); |
| 40 | } |
| 41 | |
Atsushi Nemoto | 7b22609 | 2008-07-14 00:15:04 +0900 | [diff] [blame] | 42 | static void rbtx4938_machine_power_off(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 43 | { |
| 44 | rbtx4938_machine_halt(); |
| 45 | /* no return */ |
| 46 | } |
| 47 | |
Atsushi Nemoto | 7b22609 | 2008-07-14 00:15:04 +0900 | [diff] [blame] | 48 | static void rbtx4938_machine_restart(char *command) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 49 | { |
| 50 | local_irq_disable(); |
| 51 | |
| 52 | printk("Rebooting..."); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 53 | writeb(1, rbtx4938_softresetlock_addr); |
| 54 | writeb(1, rbtx4938_sfvol_addr); |
| 55 | writeb(1, rbtx4938_softreset_addr); |
| 56 | while(1) |
| 57 | ; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 60 | static void __init rbtx4938_pci_setup(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 61 | { |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 62 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 63 | int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB); |
| 64 | struct pci_controller *c = &txx9_primary_pcic; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 65 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 66 | register_pci_controller(c); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 67 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 68 | if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66) |
| 69 | txx9_pci_option = |
| 70 | (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) | |
| 71 | TXX9_PCI_OPT_CLK_66; /* already configured */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 72 | |
| 73 | /* Reset PCI Bus */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 74 | writeb(0, rbtx4938_pcireset_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 75 | /* Reset PCIC */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 76 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
| 77 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 78 | TXX9_PCI_OPT_CLK_66) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 79 | tx4938_pciclk66_setup(); |
| 80 | mdelay(10); |
| 81 | /* clear PCIC reset */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 82 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 83 | writeb(1, rbtx4938_pcireset_addr); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 84 | iob(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 85 | |
| 86 | tx4938_report_pciclk(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 87 | tx4927_pcic_setup(tx4938_pcicptr, c, extarb); |
| 88 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 89 | TXX9_PCI_OPT_CLK_AUTO && |
| 90 | txx9_pci66_check(c, 0, 0)) { |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 91 | /* Reset PCI Bus */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 92 | writeb(0, rbtx4938_pcireset_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 93 | /* Reset PCIC */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 94 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 95 | tx4938_pciclk66_setup(); |
| 96 | mdelay(10); |
| 97 | /* clear PCIC reset */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 98 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 99 | writeb(1, rbtx4938_pcireset_addr); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 100 | iob(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 101 | /* Reinitialize PCIC */ |
| 102 | tx4938_report_pciclk(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 103 | tx4927_pcic_setup(tx4938_pcicptr, c, extarb); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 106 | if (__raw_readq(&tx4938_ccfgptr->pcfg) & |
| 107 | (TX4938_PCFG_ETH0_SEL|TX4938_PCFG_ETH1_SEL)) { |
| 108 | /* Reset PCIC1 */ |
| 109 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST); |
| 110 | /* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */ |
| 111 | if (!(__raw_readq(&tx4938_ccfgptr->ccfg) |
| 112 | & TX4938_CCFG_PCI1DMD)) |
| 113 | tx4938_ccfg_set(TX4938_CCFG_PCI1_66); |
| 114 | mdelay(10); |
| 115 | /* clear PCIC1 reset */ |
| 116 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST); |
| 117 | tx4938_report_pci1clk(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 118 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 119 | /* mem:64K(max), io:64K(max) (enough for ETH0,ETH1) */ |
| 120 | c = txx9_alloc_pci_controller(NULL, 0, 0x10000, 0, 0x10000); |
| 121 | register_pci_controller(c); |
| 122 | tx4927_pcic_setup(tx4938_pcic1ptr, c, 0); |
| 123 | } |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 124 | #endif /* CONFIG_PCI */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 125 | } |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 126 | |
| 127 | /* SPI support */ |
| 128 | |
| 129 | /* chip select for SPI devices */ |
| 130 | #define SEEPROM1_CS 7 /* PIO7 */ |
| 131 | #define SEEPROM2_CS 0 /* IOC */ |
| 132 | #define SEEPROM3_CS 1 /* IOC */ |
| 133 | #define SRTC_CS 2 /* IOC */ |
| 134 | |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 135 | static int __init rbtx4938_ethaddr_init(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 136 | { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 137 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 138 | unsigned char dat[17]; |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 139 | unsigned char sum; |
| 140 | int i; |
| 141 | |
| 142 | /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */ |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 143 | if (spi_eeprom_read(SEEPROM1_CS, 0, dat, sizeof(dat))) { |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 144 | printk(KERN_ERR "seeprom: read error.\n"); |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 145 | return -ENODEV; |
| 146 | } else { |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 147 | if (strcmp(dat, "MAC") != 0) |
| 148 | printk(KERN_WARNING "seeprom: bad signature.\n"); |
| 149 | for (i = 0, sum = 0; i < sizeof(dat); i++) |
| 150 | sum += dat[i]; |
| 151 | if (sum) |
| 152 | printk(KERN_WARNING "seeprom: bad checksum.\n"); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 153 | } |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 154 | for (i = 0; i < 2; i++) { |
Atsushi Nemoto | 06675e6 | 2008-01-19 01:15:52 +0900 | [diff] [blame] | 155 | unsigned int id = |
| 156 | TXX9_IRQ_BASE + (i ? TX4938_IR_ETH1 : TX4938_IR_ETH0); |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 157 | struct platform_device *pdev; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 158 | if (!(__raw_readq(&tx4938_ccfgptr->pcfg) & |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 159 | (i ? TX4938_PCFG_ETH1_SEL : TX4938_PCFG_ETH0_SEL))) |
| 160 | continue; |
| 161 | pdev = platform_device_alloc("tc35815-mac", id); |
| 162 | if (!pdev || |
| 163 | platform_device_add_data(pdev, &dat[4 + 6 * i], 6) || |
| 164 | platform_device_add(pdev)) |
| 165 | platform_device_put(pdev); |
| 166 | } |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 167 | #endif /* CONFIG_PCI */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 168 | return 0; |
| 169 | } |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 170 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 171 | static void __init rbtx4938_spi_setup(void) |
| 172 | { |
| 173 | /* set SPI_SEL */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 174 | txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_SPI_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static struct resource rbtx4938_fpga_resource; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 178 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 179 | static void __init rbtx4938_time_init(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 180 | { |
Atsushi Nemoto | 94a4c32 | 2008-07-19 01:51:47 +0900 | [diff] [blame^] | 181 | tx4938_time_init(0); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 184 | static void __init rbtx4938_mem_setup(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 185 | { |
| 186 | unsigned long long pcfg; |
| 187 | char *argptr; |
| 188 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 189 | if (txx9_master_clock == 0) |
| 190 | txx9_master_clock = 25000000; /* 25MHz */ |
Atsushi Nemoto | 94a4c32 | 2008-07-19 01:51:47 +0900 | [diff] [blame^] | 191 | |
| 192 | tx4938_setup(); |
| 193 | |
| 194 | #ifdef CONFIG_PCI |
| 195 | txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0); |
| 196 | #else |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 197 | set_io_port_base(RBTX4938_ETHER_BASE); |
| 198 | #endif |
| 199 | |
Atsushi Nemoto | 94a4c32 | 2008-07-19 01:51:47 +0900 | [diff] [blame^] | 200 | tx4938_setup_serial(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 201 | #ifdef CONFIG_SERIAL_TXX9_CONSOLE |
| 202 | argptr = prom_getcmdline(); |
| 203 | if (strstr(argptr, "console=") == NULL) { |
| 204 | strcat(argptr, " console=ttyS0,38400"); |
| 205 | } |
| 206 | #endif |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 207 | |
| 208 | #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61 |
| 209 | printk("PIOSEL: disabling both ata and nand selection\n"); |
| 210 | local_irq_disable(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 211 | txx9_clear64(&tx4938_ccfgptr->pcfg, |
| 212 | TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 213 | #endif |
| 214 | |
| 215 | #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND |
| 216 | printk("PIOSEL: enabling nand selection\n"); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 217 | txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL); |
| 218 | txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 219 | #endif |
| 220 | |
| 221 | #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA |
| 222 | printk("PIOSEL: enabling ata selection\n"); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 223 | txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL); |
| 224 | txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 225 | #endif |
| 226 | |
| 227 | #ifdef CONFIG_IP_PNP |
| 228 | argptr = prom_getcmdline(); |
| 229 | if (strstr(argptr, "ip=") == NULL) { |
| 230 | strcat(argptr, " ip=any"); |
| 231 | } |
| 232 | #endif |
| 233 | |
| 234 | |
| 235 | #ifdef CONFIG_FB |
| 236 | { |
| 237 | conswitchp = &dummy_con; |
| 238 | } |
| 239 | #endif |
| 240 | |
| 241 | rbtx4938_spi_setup(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 242 | pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg); /* updated */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 243 | /* fixup piosel */ |
| 244 | if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 245 | TX4938_PCFG_ATA_SEL) |
| 246 | writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x04, |
| 247 | rbtx4938_piosel_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 248 | else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 249 | TX4938_PCFG_NDF_SEL) |
| 250 | writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x08, |
| 251 | rbtx4938_piosel_addr); |
| 252 | else |
| 253 | writeb(readb(rbtx4938_piosel_addr) & ~(0x08 | 0x04), |
| 254 | rbtx4938_piosel_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 255 | |
| 256 | rbtx4938_fpga_resource.name = "FPGA Registers"; |
| 257 | rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR); |
| 258 | rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff; |
| 259 | rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY; |
Atsushi Nemoto | 8d795f2 | 2008-07-18 00:43:48 +0900 | [diff] [blame] | 260 | if (request_resource(&txx9_ce_res[2], &rbtx4938_fpga_resource)) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 261 | printk("request resource for fpga failed\n"); |
| 262 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 263 | _machine_restart = rbtx4938_machine_restart; |
| 264 | _machine_halt = rbtx4938_machine_halt; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 265 | pm_power_off = rbtx4938_machine_power_off; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 266 | |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 267 | writeb(0xff, rbtx4938_led_addr); |
| 268 | printk(KERN_INFO "RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n", |
| 269 | readb(rbtx4938_fpga_rev_addr), |
| 270 | readb(rbtx4938_dipsw_addr), readb(rbtx4938_bdipsw_addr)); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Atsushi Nemoto | 57e386c | 2007-05-01 00:27:58 +0900 | [diff] [blame] | 273 | static int __init rbtx4938_ne_init(void) |
| 274 | { |
| 275 | struct resource res[] = { |
| 276 | { |
| 277 | .start = RBTX4938_RTL_8019_BASE, |
| 278 | .end = RBTX4938_RTL_8019_BASE + 0x20 - 1, |
| 279 | .flags = IORESOURCE_IO, |
| 280 | }, { |
| 281 | .start = RBTX4938_RTL_8019_IRQ, |
| 282 | .flags = IORESOURCE_IRQ, |
| 283 | } |
| 284 | }; |
| 285 | struct platform_device *dev = |
| 286 | platform_device_register_simple("ne", -1, |
| 287 | res, ARRAY_SIZE(res)); |
| 288 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 289 | } |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 290 | |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 291 | static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock); |
| 292 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 293 | static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset, |
| 294 | int value) |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 295 | { |
| 296 | u8 val; |
| 297 | unsigned long flags; |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 298 | spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 299 | val = readb(rbtx4938_spics_addr); |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 300 | if (value) |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 301 | val |= 1 << offset; |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 302 | else |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 303 | val &= ~(1 << offset); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 304 | writeb(val, rbtx4938_spics_addr); |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 305 | mmiowb(); |
| 306 | spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags); |
| 307 | } |
| 308 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 309 | static int rbtx4938_spi_gpio_dir_out(struct gpio_chip *chip, |
| 310 | unsigned int offset, int value) |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 311 | { |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 312 | rbtx4938_spi_gpio_set(chip, offset, value); |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 313 | return 0; |
| 314 | } |
| 315 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 316 | static struct gpio_chip rbtx4938_spi_gpio_chip = { |
| 317 | .set = rbtx4938_spi_gpio_set, |
| 318 | .direction_output = rbtx4938_spi_gpio_dir_out, |
| 319 | .label = "RBTX4938-SPICS", |
| 320 | .base = 16, |
| 321 | .ngpio = 3, |
| 322 | }; |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 323 | |
| 324 | /* SPI support */ |
| 325 | |
| 326 | static void __init txx9_spi_init(unsigned long base, int irq) |
| 327 | { |
| 328 | struct resource res[] = { |
| 329 | { |
| 330 | .start = base, |
| 331 | .end = base + 0x20 - 1, |
| 332 | .flags = IORESOURCE_MEM, |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 333 | }, { |
| 334 | .start = irq, |
| 335 | .flags = IORESOURCE_IRQ, |
| 336 | }, |
| 337 | }; |
Atsushi Nemoto | 4ccdb4c | 2007-08-30 23:56:25 -0700 | [diff] [blame] | 338 | platform_device_register_simple("spi_txx9", 0, |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 339 | res, ARRAY_SIZE(res)); |
| 340 | } |
| 341 | |
| 342 | static int __init rbtx4938_spi_init(void) |
| 343 | { |
| 344 | struct spi_board_info srtc_info = { |
Atsushi Nemoto | 9f90a03 | 2007-08-19 22:32:10 +0900 | [diff] [blame] | 345 | .modalias = "rtc-rs5c348", |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 346 | .max_speed_hz = 1000000, /* 1.0Mbps @ Vdd 2.0V */ |
| 347 | .bus_num = 0, |
| 348 | .chip_select = 16 + SRTC_CS, |
| 349 | /* Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS */ |
| 350 | .mode = SPI_MODE_1 | SPI_CS_HIGH, |
| 351 | }; |
| 352 | spi_register_board_info(&srtc_info, 1); |
| 353 | spi_eeprom_register(SEEPROM1_CS); |
| 354 | spi_eeprom_register(16 + SEEPROM2_CS); |
| 355 | spi_eeprom_register(16 + SEEPROM3_CS); |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 356 | gpio_request(16 + SRTC_CS, "rtc-rs5c348"); |
| 357 | gpio_direction_output(16 + SRTC_CS, 0); |
| 358 | gpio_request(SEEPROM1_CS, "seeprom1"); |
| 359 | gpio_direction_output(SEEPROM1_CS, 1); |
| 360 | gpio_request(16 + SEEPROM2_CS, "seeprom2"); |
| 361 | gpio_direction_output(16 + SEEPROM2_CS, 1); |
| 362 | gpio_request(16 + SEEPROM3_CS, "seeprom3"); |
| 363 | gpio_direction_output(16 + SEEPROM3_CS, 1); |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 364 | txx9_spi_init(TX4938_SPI_REG & 0xfffffffffULL, RBTX4938_IRQ_IRC_SPI); |
| 365 | return 0; |
| 366 | } |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 367 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 368 | static void __init rbtx4938_arch_init(void) |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 369 | { |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 370 | gpiochip_add(&rbtx4938_spi_gpio_chip); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 371 | rbtx4938_pci_setup(); |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 372 | rbtx4938_spi_init(); |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 373 | } |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 374 | |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 375 | /* Watchdog support */ |
| 376 | |
| 377 | static int __init txx9_wdt_init(unsigned long base) |
| 378 | { |
| 379 | struct resource res = { |
| 380 | .start = base, |
| 381 | .end = base + 0x100 - 1, |
| 382 | .flags = IORESOURCE_MEM, |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 383 | }; |
| 384 | struct platform_device *dev = |
| 385 | platform_device_register_simple("txx9wdt", -1, &res, 1); |
| 386 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 387 | } |
| 388 | |
| 389 | static int __init rbtx4938_wdt_init(void) |
| 390 | { |
| 391 | return txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL); |
| 392 | } |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 393 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 394 | static void __init rbtx4938_device_init(void) |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 395 | { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 396 | rbtx4938_ethaddr_init(); |
| 397 | rbtx4938_ne_init(); |
| 398 | rbtx4938_wdt_init(); |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 399 | } |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 400 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 401 | struct txx9_board_vec rbtx4938_vec __initdata = { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 402 | .system = "Toshiba RBTX4938", |
| 403 | .prom_init = rbtx4938_prom_init, |
| 404 | .mem_setup = rbtx4938_mem_setup, |
| 405 | .irq_setup = rbtx4938_irq_setup, |
| 406 | .time_init = rbtx4938_time_init, |
| 407 | .device_init = rbtx4938_device_init, |
| 408 | .arch_init = rbtx4938_arch_init, |
| 409 | #ifdef CONFIG_PCI |
| 410 | .pci_map_irq = rbtx4938_pci_map_irq, |
| 411 | #endif |
| 412 | }; |