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