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/time.h> |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 24 | #include <asm/txx9tmr.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 25 | #include <asm/io.h> |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 26 | #include <asm/txx9/generic.h> |
| 27 | #include <asm/txx9/pci.h> |
Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 28 | #include <asm/txx9/rbtx4938.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 29 | #ifdef CONFIG_SERIAL_TXX9 |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 30 | #include <linux/serial_core.h> |
| 31 | #endif |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 32 | #include <linux/spi/spi.h> |
Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 33 | #include <asm/txx9/spi.h> |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 34 | #include <asm/txx9pio.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 35 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 36 | static int tx4938_ccfg_toeon = 1; |
| 37 | |
Atsushi Nemoto | 7b22609 | 2008-07-14 00:15:04 +0900 | [diff] [blame^] | 38 | static void rbtx4938_machine_halt(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 39 | { |
| 40 | printk(KERN_NOTICE "System Halted\n"); |
| 41 | local_irq_disable(); |
| 42 | |
| 43 | while (1) |
| 44 | __asm__(".set\tmips3\n\t" |
| 45 | "wait\n\t" |
| 46 | ".set\tmips0"); |
| 47 | } |
| 48 | |
Atsushi Nemoto | 7b22609 | 2008-07-14 00:15:04 +0900 | [diff] [blame^] | 49 | static void rbtx4938_machine_power_off(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 50 | { |
| 51 | rbtx4938_machine_halt(); |
| 52 | /* no return */ |
| 53 | } |
| 54 | |
Atsushi Nemoto | 7b22609 | 2008-07-14 00:15:04 +0900 | [diff] [blame^] | 55 | static void rbtx4938_machine_restart(char *command) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 56 | { |
| 57 | local_irq_disable(); |
| 58 | |
| 59 | printk("Rebooting..."); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 60 | writeb(1, rbtx4938_softresetlock_addr); |
| 61 | writeb(1, rbtx4938_sfvol_addr); |
| 62 | writeb(1, rbtx4938_softreset_addr); |
| 63 | while(1) |
| 64 | ; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 67 | static void __init rbtx4938_pci_setup(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 68 | { |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 69 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 70 | int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB); |
| 71 | struct pci_controller *c = &txx9_primary_pcic; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 72 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 73 | register_pci_controller(c); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 74 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 75 | if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66) |
| 76 | txx9_pci_option = |
| 77 | (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) | |
| 78 | TXX9_PCI_OPT_CLK_66; /* already configured */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 79 | |
| 80 | /* Reset PCI Bus */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 81 | writeb(0, rbtx4938_pcireset_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 82 | /* Reset PCIC */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 83 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
| 84 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 85 | TXX9_PCI_OPT_CLK_66) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 86 | tx4938_pciclk66_setup(); |
| 87 | mdelay(10); |
| 88 | /* clear PCIC reset */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 89 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 90 | writeb(1, rbtx4938_pcireset_addr); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 91 | iob(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 92 | |
| 93 | tx4938_report_pciclk(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 94 | tx4927_pcic_setup(tx4938_pcicptr, c, extarb); |
| 95 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 96 | TXX9_PCI_OPT_CLK_AUTO && |
| 97 | txx9_pci66_check(c, 0, 0)) { |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 98 | /* Reset PCI Bus */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 99 | writeb(0, rbtx4938_pcireset_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 100 | /* Reset PCIC */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 101 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 102 | tx4938_pciclk66_setup(); |
| 103 | mdelay(10); |
| 104 | /* clear PCIC reset */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 105 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 106 | writeb(1, rbtx4938_pcireset_addr); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 107 | iob(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 108 | /* Reinitialize PCIC */ |
| 109 | tx4938_report_pciclk(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 110 | tx4927_pcic_setup(tx4938_pcicptr, c, extarb); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 113 | if (__raw_readq(&tx4938_ccfgptr->pcfg) & |
| 114 | (TX4938_PCFG_ETH0_SEL|TX4938_PCFG_ETH1_SEL)) { |
| 115 | /* Reset PCIC1 */ |
| 116 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST); |
| 117 | /* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */ |
| 118 | if (!(__raw_readq(&tx4938_ccfgptr->ccfg) |
| 119 | & TX4938_CCFG_PCI1DMD)) |
| 120 | tx4938_ccfg_set(TX4938_CCFG_PCI1_66); |
| 121 | mdelay(10); |
| 122 | /* clear PCIC1 reset */ |
| 123 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST); |
| 124 | tx4938_report_pci1clk(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 125 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 126 | /* mem:64K(max), io:64K(max) (enough for ETH0,ETH1) */ |
| 127 | c = txx9_alloc_pci_controller(NULL, 0, 0x10000, 0, 0x10000); |
| 128 | register_pci_controller(c); |
| 129 | tx4927_pcic_setup(tx4938_pcic1ptr, c, 0); |
| 130 | } |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 131 | #endif /* CONFIG_PCI */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 132 | } |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 133 | |
| 134 | /* SPI support */ |
| 135 | |
| 136 | /* chip select for SPI devices */ |
| 137 | #define SEEPROM1_CS 7 /* PIO7 */ |
| 138 | #define SEEPROM2_CS 0 /* IOC */ |
| 139 | #define SEEPROM3_CS 1 /* IOC */ |
| 140 | #define SRTC_CS 2 /* IOC */ |
| 141 | |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 142 | static int __init rbtx4938_ethaddr_init(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 143 | { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 144 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 145 | unsigned char dat[17]; |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 146 | unsigned char sum; |
| 147 | int i; |
| 148 | |
| 149 | /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */ |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 150 | if (spi_eeprom_read(SEEPROM1_CS, 0, dat, sizeof(dat))) { |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 151 | printk(KERN_ERR "seeprom: read error.\n"); |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 152 | return -ENODEV; |
| 153 | } else { |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 154 | if (strcmp(dat, "MAC") != 0) |
| 155 | printk(KERN_WARNING "seeprom: bad signature.\n"); |
| 156 | for (i = 0, sum = 0; i < sizeof(dat); i++) |
| 157 | sum += dat[i]; |
| 158 | if (sum) |
| 159 | printk(KERN_WARNING "seeprom: bad checksum.\n"); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 160 | } |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 161 | for (i = 0; i < 2; i++) { |
Atsushi Nemoto | 06675e6 | 2008-01-19 01:15:52 +0900 | [diff] [blame] | 162 | unsigned int id = |
| 163 | TXX9_IRQ_BASE + (i ? TX4938_IR_ETH1 : TX4938_IR_ETH0); |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 164 | struct platform_device *pdev; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 165 | if (!(__raw_readq(&tx4938_ccfgptr->pcfg) & |
Atsushi Nemoto | 2db3015 | 2007-07-02 22:43:06 +0900 | [diff] [blame] | 166 | (i ? TX4938_PCFG_ETH1_SEL : TX4938_PCFG_ETH0_SEL))) |
| 167 | continue; |
| 168 | pdev = platform_device_alloc("tc35815-mac", id); |
| 169 | if (!pdev || |
| 170 | platform_device_add_data(pdev, &dat[4 + 6 * i], 6) || |
| 171 | platform_device_add(pdev)) |
| 172 | platform_device_put(pdev); |
| 173 | } |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 174 | #endif /* CONFIG_PCI */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 175 | return 0; |
| 176 | } |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 177 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 178 | static void __init rbtx4938_spi_setup(void) |
| 179 | { |
| 180 | /* set SPI_SEL */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 181 | txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_SPI_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static struct resource rbtx4938_fpga_resource; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 185 | static struct resource tx4938_sdram_resource[4]; |
| 186 | static struct resource tx4938_sram_resource; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 187 | |
| 188 | void __init tx4938_board_setup(void) |
| 189 | { |
| 190 | int i; |
| 191 | unsigned long divmode; |
| 192 | int cpuclk = 0; |
| 193 | unsigned long pcode = TX4938_REV_PCODE(); |
| 194 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 195 | ioport_resource.start = 0; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 196 | ioport_resource.end = 0xffffffff; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 197 | iomem_resource.start = 0; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 198 | iomem_resource.end = 0xffffffff; /* expand to 4GB */ |
| 199 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 200 | txx9_reg_res_init(pcode, TX4938_REG_BASE, |
| 201 | TX4938_REG_SIZE); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 202 | /* SDRAMC,EBUSC are configured by PROM */ |
| 203 | for (i = 0; i < 8; i++) { |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 204 | if (!(TX4938_EBUSC_CR(i) & 0x8)) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 205 | continue; /* disabled */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 206 | txx9_ce_res[i].start = (unsigned long)TX4938_EBUSC_BA(i); |
| 207 | txx9_ce_res[i].end = |
| 208 | txx9_ce_res[i].start + TX4938_EBUSC_SIZE(i) - 1; |
| 209 | request_resource(&iomem_resource, &txx9_ce_res[i]); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | /* clocks */ |
| 213 | if (txx9_master_clock) { |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 214 | u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg); |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 215 | /* calculate gbus_clock and cpu_clock_freq from master_clock */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 216 | divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 217 | switch (divmode) { |
| 218 | case TX4938_CCFG_DIVMODE_8: |
| 219 | case TX4938_CCFG_DIVMODE_10: |
| 220 | case TX4938_CCFG_DIVMODE_12: |
| 221 | case TX4938_CCFG_DIVMODE_16: |
| 222 | case TX4938_CCFG_DIVMODE_18: |
| 223 | txx9_gbus_clock = txx9_master_clock * 4; break; |
| 224 | default: |
| 225 | txx9_gbus_clock = txx9_master_clock; |
| 226 | } |
| 227 | switch (divmode) { |
| 228 | case TX4938_CCFG_DIVMODE_2: |
| 229 | case TX4938_CCFG_DIVMODE_8: |
| 230 | cpuclk = txx9_gbus_clock * 2; break; |
| 231 | case TX4938_CCFG_DIVMODE_2_5: |
| 232 | case TX4938_CCFG_DIVMODE_10: |
| 233 | cpuclk = txx9_gbus_clock * 5 / 2; break; |
| 234 | case TX4938_CCFG_DIVMODE_3: |
| 235 | case TX4938_CCFG_DIVMODE_12: |
| 236 | cpuclk = txx9_gbus_clock * 3; break; |
| 237 | case TX4938_CCFG_DIVMODE_4: |
| 238 | case TX4938_CCFG_DIVMODE_16: |
| 239 | cpuclk = txx9_gbus_clock * 4; break; |
| 240 | case TX4938_CCFG_DIVMODE_4_5: |
| 241 | case TX4938_CCFG_DIVMODE_18: |
| 242 | cpuclk = txx9_gbus_clock * 9 / 2; break; |
| 243 | } |
| 244 | txx9_cpu_clock = cpuclk; |
| 245 | } else { |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 246 | u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 247 | if (txx9_cpu_clock == 0) { |
| 248 | txx9_cpu_clock = 300000000; /* 300MHz */ |
| 249 | } |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 250 | /* calculate gbus_clock and master_clock from cpu_clock_freq */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 251 | cpuclk = txx9_cpu_clock; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 252 | divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 253 | switch (divmode) { |
| 254 | case TX4938_CCFG_DIVMODE_2: |
| 255 | case TX4938_CCFG_DIVMODE_8: |
| 256 | txx9_gbus_clock = cpuclk / 2; break; |
| 257 | case TX4938_CCFG_DIVMODE_2_5: |
| 258 | case TX4938_CCFG_DIVMODE_10: |
| 259 | txx9_gbus_clock = cpuclk * 2 / 5; break; |
| 260 | case TX4938_CCFG_DIVMODE_3: |
| 261 | case TX4938_CCFG_DIVMODE_12: |
| 262 | txx9_gbus_clock = cpuclk / 3; break; |
| 263 | case TX4938_CCFG_DIVMODE_4: |
| 264 | case TX4938_CCFG_DIVMODE_16: |
| 265 | txx9_gbus_clock = cpuclk / 4; break; |
| 266 | case TX4938_CCFG_DIVMODE_4_5: |
| 267 | case TX4938_CCFG_DIVMODE_18: |
| 268 | txx9_gbus_clock = cpuclk * 2 / 9; break; |
| 269 | } |
| 270 | switch (divmode) { |
| 271 | case TX4938_CCFG_DIVMODE_8: |
| 272 | case TX4938_CCFG_DIVMODE_10: |
| 273 | case TX4938_CCFG_DIVMODE_12: |
| 274 | case TX4938_CCFG_DIVMODE_16: |
| 275 | case TX4938_CCFG_DIVMODE_18: |
| 276 | txx9_master_clock = txx9_gbus_clock / 4; break; |
| 277 | default: |
| 278 | txx9_master_clock = txx9_gbus_clock; |
| 279 | } |
| 280 | } |
| 281 | /* change default value to udelay/mdelay take reasonable time */ |
| 282 | loops_per_jiffy = txx9_cpu_clock / HZ / 2; |
| 283 | |
| 284 | /* CCFG */ |
| 285 | /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 286 | tx4938_ccfg_set(TX4938_CCFG_WDRST | TX4938_CCFG_BEOW); |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 287 | /* do reset on watchdog */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 288 | tx4938_ccfg_set(TX4938_CCFG_WR); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 289 | /* clear PCIC1 reset */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 290 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 291 | |
| 292 | /* enable Timeout BusError */ |
| 293 | if (tx4938_ccfg_toeon) |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 294 | tx4938_ccfg_set(TX4938_CCFG_TOE); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 295 | |
| 296 | /* DMA selection */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 297 | txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_DMASEL_ALL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 298 | |
| 299 | /* Use external clock for external arbiter */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 300 | if (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB)) |
| 301 | txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_PCICLKEN_ALL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 302 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 303 | printk(KERN_INFO "%s -- %dMHz(M%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n", |
| 304 | txx9_pcode_str, |
| 305 | (cpuclk + 500000) / 1000000, |
| 306 | (txx9_master_clock + 500000) / 1000000, |
| 307 | (__u32)____raw_readq(&tx4938_ccfgptr->crir), |
| 308 | (unsigned long long)____raw_readq(&tx4938_ccfgptr->ccfg), |
| 309 | (unsigned long long)____raw_readq(&tx4938_ccfgptr->pcfg)); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 310 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 311 | printk(KERN_INFO "%s SDRAMC --", txx9_pcode_str); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 312 | for (i = 0; i < 4; i++) { |
| 313 | unsigned long long cr = tx4938_sdramcptr->cr[i]; |
| 314 | unsigned long ram_base, ram_size; |
| 315 | if (!((unsigned long)cr & 0x00000400)) |
| 316 | continue; /* disabled */ |
| 317 | ram_base = (unsigned long)(cr >> 49) << 21; |
| 318 | ram_size = ((unsigned long)(cr >> 33) + 1) << 21; |
| 319 | if (ram_base >= 0x20000000) |
| 320 | continue; /* high memory (ignore) */ |
| 321 | printk(" CR%d:%016Lx", i, cr); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 322 | tx4938_sdram_resource[i].name = "SDRAM"; |
| 323 | tx4938_sdram_resource[i].start = ram_base; |
| 324 | tx4938_sdram_resource[i].end = ram_base + ram_size - 1; |
| 325 | tx4938_sdram_resource[i].flags = IORESOURCE_MEM; |
| 326 | request_resource(&iomem_resource, &tx4938_sdram_resource[i]); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 327 | } |
| 328 | printk(" TR:%09Lx\n", tx4938_sdramcptr->tr); |
| 329 | |
| 330 | /* SRAM */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 331 | if (tx4938_sramcptr->cr & 1) { |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 332 | unsigned int size = 0x800; |
| 333 | unsigned long base = |
| 334 | (tx4938_sramcptr->cr >> (39-11)) & ~(size - 1); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 335 | tx4938_sram_resource.name = "SRAM"; |
| 336 | tx4938_sram_resource.start = base; |
| 337 | tx4938_sram_resource.end = base + size - 1; |
| 338 | tx4938_sram_resource.flags = IORESOURCE_MEM; |
| 339 | request_resource(&iomem_resource, &tx4938_sram_resource); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 340 | } |
| 341 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 342 | /* TMR */ |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 343 | for (i = 0; i < TX4938_NR_TMR; i++) |
| 344 | txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 345 | |
| 346 | /* enable DMA */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 347 | for (i = 0; i < 2; i++) |
| 348 | ____raw_writeq(TX4938_DMA_MCR_MSTEN, |
| 349 | (void __iomem *)(TX4938_DMA_REG(i) + 0x50)); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 350 | |
| 351 | /* PIO */ |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 352 | __raw_writel(0, &tx4938_pioptr->maskcpu); |
| 353 | __raw_writel(0, &tx4938_pioptr->maskext); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 354 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 355 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 356 | txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0); |
| 357 | #endif |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 358 | } |
| 359 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 360 | static void __init rbtx4938_time_init(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 361 | { |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 362 | mips_hpt_frequency = txx9_cpu_clock / 2; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 363 | if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS) |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 364 | txx9_clockevent_init(TX4938_TMR_REG(0) & 0xfffffffffULL, |
| 365 | TXX9_IRQ_BASE + TX4938_IR_TMR(0), |
| 366 | txx9_gbus_clock / 2); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 367 | } |
| 368 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 369 | static void __init rbtx4938_mem_setup(void) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 370 | { |
| 371 | unsigned long long pcfg; |
| 372 | char *argptr; |
| 373 | |
| 374 | iomem_resource.end = 0xffffffff; /* 4GB */ |
| 375 | |
| 376 | if (txx9_master_clock == 0) |
| 377 | txx9_master_clock = 25000000; /* 25MHz */ |
| 378 | tx4938_board_setup(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 379 | #ifndef CONFIG_PCI |
| 380 | set_io_port_base(RBTX4938_ETHER_BASE); |
| 381 | #endif |
| 382 | |
| 383 | #ifdef CONFIG_SERIAL_TXX9 |
| 384 | { |
| 385 | extern int early_serial_txx9_setup(struct uart_port *port); |
| 386 | int i; |
| 387 | struct uart_port req; |
| 388 | for(i = 0; i < 2; i++) { |
| 389 | memset(&req, 0, sizeof(req)); |
| 390 | req.line = i; |
| 391 | req.iotype = UPIO_MEM; |
| 392 | req.membase = (char *)(0xff1ff300 + i * 0x100); |
| 393 | req.mapbase = 0xff1ff300 + i * 0x100; |
Atsushi Nemoto | c87abd7 | 2007-08-02 23:36:02 +0900 | [diff] [blame] | 394 | req.irq = RBTX4938_IRQ_IRC_SIO(i); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 395 | req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/; |
| 396 | req.uartclk = 50000000; |
| 397 | early_serial_txx9_setup(&req); |
| 398 | } |
| 399 | } |
| 400 | #ifdef CONFIG_SERIAL_TXX9_CONSOLE |
| 401 | argptr = prom_getcmdline(); |
| 402 | if (strstr(argptr, "console=") == NULL) { |
| 403 | strcat(argptr, " console=ttyS0,38400"); |
| 404 | } |
| 405 | #endif |
| 406 | #endif |
| 407 | |
| 408 | #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61 |
| 409 | printk("PIOSEL: disabling both ata and nand selection\n"); |
| 410 | local_irq_disable(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 411 | txx9_clear64(&tx4938_ccfgptr->pcfg, |
| 412 | TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 413 | #endif |
| 414 | |
| 415 | #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND |
| 416 | printk("PIOSEL: enabling nand selection\n"); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 417 | txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL); |
| 418 | txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 419 | #endif |
| 420 | |
| 421 | #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA |
| 422 | printk("PIOSEL: enabling ata selection\n"); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 423 | txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL); |
| 424 | txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 425 | #endif |
| 426 | |
| 427 | #ifdef CONFIG_IP_PNP |
| 428 | argptr = prom_getcmdline(); |
| 429 | if (strstr(argptr, "ip=") == NULL) { |
| 430 | strcat(argptr, " ip=any"); |
| 431 | } |
| 432 | #endif |
| 433 | |
| 434 | |
| 435 | #ifdef CONFIG_FB |
| 436 | { |
| 437 | conswitchp = &dummy_con; |
| 438 | } |
| 439 | #endif |
| 440 | |
| 441 | rbtx4938_spi_setup(); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 442 | pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg); /* updated */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 443 | /* fixup piosel */ |
| 444 | if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 445 | TX4938_PCFG_ATA_SEL) |
| 446 | writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x04, |
| 447 | rbtx4938_piosel_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 448 | else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) == |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 449 | TX4938_PCFG_NDF_SEL) |
| 450 | writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x08, |
| 451 | rbtx4938_piosel_addr); |
| 452 | else |
| 453 | writeb(readb(rbtx4938_piosel_addr) & ~(0x08 | 0x04), |
| 454 | rbtx4938_piosel_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 455 | |
| 456 | rbtx4938_fpga_resource.name = "FPGA Registers"; |
| 457 | rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR); |
| 458 | rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff; |
| 459 | rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY; |
| 460 | if (request_resource(&iomem_resource, &rbtx4938_fpga_resource)) |
| 461 | printk("request resource for fpga failed\n"); |
| 462 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 463 | _machine_restart = rbtx4938_machine_restart; |
| 464 | _machine_halt = rbtx4938_machine_halt; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 465 | pm_power_off = rbtx4938_machine_power_off; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 466 | |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 467 | writeb(0xff, rbtx4938_led_addr); |
| 468 | printk(KERN_INFO "RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n", |
| 469 | readb(rbtx4938_fpga_rev_addr), |
| 470 | readb(rbtx4938_dipsw_addr), readb(rbtx4938_bdipsw_addr)); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 471 | } |
| 472 | |
Atsushi Nemoto | 57e386c | 2007-05-01 00:27:58 +0900 | [diff] [blame] | 473 | static int __init rbtx4938_ne_init(void) |
| 474 | { |
| 475 | struct resource res[] = { |
| 476 | { |
| 477 | .start = RBTX4938_RTL_8019_BASE, |
| 478 | .end = RBTX4938_RTL_8019_BASE + 0x20 - 1, |
| 479 | .flags = IORESOURCE_IO, |
| 480 | }, { |
| 481 | .start = RBTX4938_RTL_8019_IRQ, |
| 482 | .flags = IORESOURCE_IRQ, |
| 483 | } |
| 484 | }; |
| 485 | struct platform_device *dev = |
| 486 | platform_device_register_simple("ne", -1, |
| 487 | res, ARRAY_SIZE(res)); |
| 488 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 489 | } |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 490 | |
| 491 | /* GPIO support */ |
| 492 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 493 | int gpio_to_irq(unsigned gpio) |
| 494 | { |
| 495 | return -EINVAL; |
| 496 | } |
| 497 | |
| 498 | int irq_to_gpio(unsigned irq) |
| 499 | { |
| 500 | return -EINVAL; |
| 501 | } |
| 502 | |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 503 | static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock); |
| 504 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 505 | static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset, |
| 506 | int value) |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 507 | { |
| 508 | u8 val; |
| 509 | unsigned long flags; |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 510 | spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 511 | val = readb(rbtx4938_spics_addr); |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 512 | if (value) |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 513 | val |= 1 << offset; |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 514 | else |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 515 | val &= ~(1 << offset); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 516 | writeb(val, rbtx4938_spics_addr); |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 517 | mmiowb(); |
| 518 | spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags); |
| 519 | } |
| 520 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 521 | static int rbtx4938_spi_gpio_dir_out(struct gpio_chip *chip, |
| 522 | unsigned int offset, int value) |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 523 | { |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 524 | rbtx4938_spi_gpio_set(chip, offset, value); |
Atsushi Nemoto | 3896b05 | 2007-06-22 23:21:55 +0900 | [diff] [blame] | 525 | return 0; |
| 526 | } |
| 527 | |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 528 | static struct gpio_chip rbtx4938_spi_gpio_chip = { |
| 529 | .set = rbtx4938_spi_gpio_set, |
| 530 | .direction_output = rbtx4938_spi_gpio_dir_out, |
| 531 | .label = "RBTX4938-SPICS", |
| 532 | .base = 16, |
| 533 | .ngpio = 3, |
| 534 | }; |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 535 | |
| 536 | /* SPI support */ |
| 537 | |
| 538 | static void __init txx9_spi_init(unsigned long base, int irq) |
| 539 | { |
| 540 | struct resource res[] = { |
| 541 | { |
| 542 | .start = base, |
| 543 | .end = base + 0x20 - 1, |
| 544 | .flags = IORESOURCE_MEM, |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 545 | }, { |
| 546 | .start = irq, |
| 547 | .flags = IORESOURCE_IRQ, |
| 548 | }, |
| 549 | }; |
Atsushi Nemoto | 4ccdb4c | 2007-08-30 23:56:25 -0700 | [diff] [blame] | 550 | platform_device_register_simple("spi_txx9", 0, |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 551 | res, ARRAY_SIZE(res)); |
| 552 | } |
| 553 | |
| 554 | static int __init rbtx4938_spi_init(void) |
| 555 | { |
| 556 | struct spi_board_info srtc_info = { |
Atsushi Nemoto | 9f90a03 | 2007-08-19 22:32:10 +0900 | [diff] [blame] | 557 | .modalias = "rtc-rs5c348", |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 558 | .max_speed_hz = 1000000, /* 1.0Mbps @ Vdd 2.0V */ |
| 559 | .bus_num = 0, |
| 560 | .chip_select = 16 + SRTC_CS, |
| 561 | /* Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS */ |
| 562 | .mode = SPI_MODE_1 | SPI_CS_HIGH, |
| 563 | }; |
| 564 | spi_register_board_info(&srtc_info, 1); |
| 565 | spi_eeprom_register(SEEPROM1_CS); |
| 566 | spi_eeprom_register(16 + SEEPROM2_CS); |
| 567 | spi_eeprom_register(16 + SEEPROM3_CS); |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 568 | gpio_request(16 + SRTC_CS, "rtc-rs5c348"); |
| 569 | gpio_direction_output(16 + SRTC_CS, 0); |
| 570 | gpio_request(SEEPROM1_CS, "seeprom1"); |
| 571 | gpio_direction_output(SEEPROM1_CS, 1); |
| 572 | gpio_request(16 + SEEPROM2_CS, "seeprom2"); |
| 573 | gpio_direction_output(16 + SEEPROM2_CS, 1); |
| 574 | gpio_request(16 + SEEPROM3_CS, "seeprom3"); |
| 575 | gpio_direction_output(16 + SEEPROM3_CS, 1); |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 576 | txx9_spi_init(TX4938_SPI_REG & 0xfffffffffULL, RBTX4938_IRQ_IRC_SPI); |
| 577 | return 0; |
| 578 | } |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 579 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 580 | static void __init rbtx4938_arch_init(void) |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 581 | { |
| 582 | txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16); |
| 583 | gpiochip_add(&rbtx4938_spi_gpio_chip); |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 584 | rbtx4938_pci_setup(); |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 585 | rbtx4938_spi_init(); |
Atsushi Nemoto | 4cad154 | 2008-04-05 00:56:09 +0900 | [diff] [blame] | 586 | } |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 587 | |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 588 | /* Watchdog support */ |
| 589 | |
| 590 | static int __init txx9_wdt_init(unsigned long base) |
| 591 | { |
| 592 | struct resource res = { |
| 593 | .start = base, |
| 594 | .end = base + 0x100 - 1, |
| 595 | .flags = IORESOURCE_MEM, |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 596 | }; |
| 597 | struct platform_device *dev = |
| 598 | platform_device_register_simple("txx9wdt", -1, &res, 1); |
| 599 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 600 | } |
| 601 | |
| 602 | static int __init rbtx4938_wdt_init(void) |
| 603 | { |
| 604 | return txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL); |
| 605 | } |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 606 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 607 | static void __init rbtx4938_device_init(void) |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 608 | { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 609 | rbtx4938_ethaddr_init(); |
| 610 | rbtx4938_ne_init(); |
| 611 | rbtx4938_wdt_init(); |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 612 | } |
Atsushi Nemoto | f74cf6f | 2007-06-22 23:22:06 +0900 | [diff] [blame] | 613 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 614 | struct txx9_board_vec rbtx4938_vec __initdata = { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 615 | .system = "Toshiba RBTX4938", |
| 616 | .prom_init = rbtx4938_prom_init, |
| 617 | .mem_setup = rbtx4938_mem_setup, |
| 618 | .irq_setup = rbtx4938_irq_setup, |
| 619 | .time_init = rbtx4938_time_init, |
| 620 | .device_init = rbtx4938_device_init, |
| 621 | .arch_init = rbtx4938_arch_init, |
| 622 | #ifdef CONFIG_PCI |
| 623 | .pci_map_irq = rbtx4938_pci_map_irq, |
| 624 | #endif |
| 625 | }; |