0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 #include <linux/init.h>
0046 #include <linux/kernel.h>
0047 #include <linux/types.h>
0048 #include <linux/ioport.h>
0049 #include <linux/platform_device.h>
0050 #include <linux/delay.h>
0051 #include <linux/gpio.h>
0052 #include <linux/leds.h>
0053 #include <asm/io.h>
0054 #include <asm/reboot.h>
0055 #include <asm/txx9pio.h>
0056 #include <asm/txx9/generic.h>
0057 #include <asm/txx9/pci.h>
0058 #include <asm/txx9/rbtx4927.h>
0059 #include <asm/txx9/tx4938.h> /* for TX4937 */
0060
0061 #ifdef CONFIG_PCI
0062 static void __init tx4927_pci_setup(void)
0063 {
0064 int extarb = !(__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCIARB);
0065 struct pci_controller *c = &txx9_primary_pcic;
0066
0067 register_pci_controller(c);
0068
0069 if (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66)
0070 txx9_pci_option =
0071 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
0072 TXX9_PCI_OPT_CLK_66;
0073
0074
0075 writeb(1, rbtx4927_pcireset_addr);
0076
0077 txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
0078 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
0079 TXX9_PCI_OPT_CLK_66)
0080 tx4927_pciclk66_setup();
0081 mdelay(10);
0082
0083 txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
0084 writeb(0, rbtx4927_pcireset_addr);
0085 iob();
0086
0087 tx4927_report_pciclk();
0088 tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
0089 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
0090 TXX9_PCI_OPT_CLK_AUTO &&
0091 txx9_pci66_check(c, 0, 0)) {
0092
0093 writeb(1, rbtx4927_pcireset_addr);
0094
0095 txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
0096 tx4927_pciclk66_setup();
0097 mdelay(10);
0098
0099 txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
0100 writeb(0, rbtx4927_pcireset_addr);
0101 iob();
0102
0103 tx4927_report_pciclk();
0104 tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
0105 }
0106 tx4927_setup_pcierr_irq();
0107 }
0108
0109 static void __init tx4937_pci_setup(void)
0110 {
0111 int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB);
0112 struct pci_controller *c = &txx9_primary_pcic;
0113
0114 register_pci_controller(c);
0115
0116 if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66)
0117 txx9_pci_option =
0118 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
0119 TXX9_PCI_OPT_CLK_66;
0120
0121
0122 writeb(1, rbtx4927_pcireset_addr);
0123
0124 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
0125 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
0126 TXX9_PCI_OPT_CLK_66)
0127 tx4938_pciclk66_setup();
0128 mdelay(10);
0129
0130 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
0131 writeb(0, rbtx4927_pcireset_addr);
0132 iob();
0133
0134 tx4938_report_pciclk();
0135 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
0136 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
0137 TXX9_PCI_OPT_CLK_AUTO &&
0138 txx9_pci66_check(c, 0, 0)) {
0139
0140 writeb(1, rbtx4927_pcireset_addr);
0141
0142 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
0143 tx4938_pciclk66_setup();
0144 mdelay(10);
0145
0146 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
0147 writeb(0, rbtx4927_pcireset_addr);
0148 iob();
0149
0150 tx4938_report_pciclk();
0151 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
0152 }
0153 tx4938_setup_pcierr_irq();
0154 }
0155 #else
0156 static inline void tx4927_pci_setup(void) {}
0157 static inline void tx4937_pci_setup(void) {}
0158 #endif
0159
0160 static void __init rbtx4927_gpio_init(void)
0161 {
0162
0163 gpio_request(15, "sio-dtr");
0164 gpio_direction_output(15, 1);
0165
0166 tx4927_sio_init(0, 0);
0167 }
0168
0169 static void __init rbtx4927_arch_init(void)
0170 {
0171 txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
0172
0173 rbtx4927_gpio_init();
0174
0175 tx4927_pci_setup();
0176 }
0177
0178 static void __init rbtx4937_arch_init(void)
0179 {
0180 txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
0181
0182 rbtx4927_gpio_init();
0183
0184 tx4937_pci_setup();
0185 }
0186
0187 static void toshiba_rbtx4927_restart(char *command)
0188 {
0189
0190 writeb(1, rbtx4927_softresetlock_addr);
0191
0192
0193 while (!(readb(rbtx4927_softresetlock_addr) & 1))
0194 ;
0195
0196
0197 writeb(1, rbtx4927_softreset_addr);
0198
0199
0200 (*_machine_halt)();
0201 }
0202
0203 static void __init rbtx4927_clock_init(void);
0204 static void __init rbtx4937_clock_init(void);
0205
0206 static void __init rbtx4927_mem_setup(void)
0207 {
0208 if (TX4927_REV_PCODE() == 0x4927) {
0209 rbtx4927_clock_init();
0210 tx4927_setup();
0211 } else {
0212 rbtx4937_clock_init();
0213 tx4938_setup();
0214 }
0215
0216 _machine_restart = toshiba_rbtx4927_restart;
0217
0218 #ifdef CONFIG_PCI
0219 txx9_alloc_pci_controller(&txx9_primary_pcic,
0220 RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE,
0221 RBTX4927_PCIIO, RBTX4927_PCIIO_SIZE);
0222 txx9_board_pcibios_setup = tx4927_pcibios_setup;
0223 #else
0224 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
0225 #endif
0226 }
0227
0228 static void __init rbtx4927_clock_init(void)
0229 {
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241 switch ((unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg) &
0242 TX4927_CCFG_PCIDIVMODE_MASK) {
0243 case TX4927_CCFG_PCIDIVMODE_2_5:
0244 case TX4927_CCFG_PCIDIVMODE_5:
0245 txx9_cpu_clock = 166666666;
0246 break;
0247 default:
0248 txx9_cpu_clock = 200000000;
0249 }
0250 }
0251
0252 static void __init rbtx4937_clock_init(void)
0253 {
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267 switch ((unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg) &
0268 TX4938_CCFG_PCIDIVMODE_MASK) {
0269 case TX4938_CCFG_PCIDIVMODE_8:
0270 case TX4938_CCFG_PCIDIVMODE_4:
0271 txx9_cpu_clock = 266666666;
0272 break;
0273 case TX4938_CCFG_PCIDIVMODE_9:
0274 case TX4938_CCFG_PCIDIVMODE_4_5:
0275 txx9_cpu_clock = 300000000;
0276 break;
0277 default:
0278 txx9_cpu_clock = 333333333;
0279 }
0280 }
0281
0282 static void __init rbtx4927_time_init(void)
0283 {
0284 tx4927_time_init(0);
0285 }
0286
0287 static void __init toshiba_rbtx4927_rtc_init(void)
0288 {
0289 struct resource res = {
0290 .start = RBTX4927_BRAMRTC_BASE - IO_BASE,
0291 .end = RBTX4927_BRAMRTC_BASE - IO_BASE + 0x800 - 1,
0292 .flags = IORESOURCE_MEM,
0293 };
0294 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
0295 }
0296
0297 static void __init rbtx4927_ne_init(void)
0298 {
0299 struct resource res[] = {
0300 {
0301 .start = RBTX4927_RTL_8019_BASE,
0302 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
0303 .flags = IORESOURCE_IO,
0304 }, {
0305 .start = RBTX4927_RTL_8019_IRQ,
0306 .flags = IORESOURCE_IRQ,
0307 }
0308 };
0309 platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
0310 }
0311
0312 static void __init rbtx4927_mtd_init(void)
0313 {
0314 int i;
0315
0316 for (i = 0; i < 2; i++)
0317 tx4927_mtd_init(i);
0318 }
0319
0320 static void __init rbtx4927_gpioled_init(void)
0321 {
0322 static const struct gpio_led leds[] = {
0323 { .name = "gpioled:green:0", .gpio = 0, .active_low = 1, },
0324 { .name = "gpioled:green:1", .gpio = 1, .active_low = 1, },
0325 };
0326 static struct gpio_led_platform_data pdata = {
0327 .num_leds = ARRAY_SIZE(leds),
0328 .leds = leds,
0329 };
0330 struct platform_device *pdev = platform_device_alloc("leds-gpio", 0);
0331
0332 if (!pdev)
0333 return;
0334 pdev->dev.platform_data = &pdata;
0335 if (platform_device_add(pdev))
0336 platform_device_put(pdev);
0337 }
0338
0339 static void __init rbtx4927_device_init(void)
0340 {
0341 toshiba_rbtx4927_rtc_init();
0342 rbtx4927_ne_init();
0343 tx4927_wdt_init();
0344 rbtx4927_mtd_init();
0345 if (TX4927_REV_PCODE() == 0x4927) {
0346 tx4927_dmac_init(2);
0347 tx4927_aclc_init(0, 1);
0348 } else {
0349 tx4938_dmac_init(0, 2);
0350 tx4938_aclc_init();
0351 }
0352 platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
0353 txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL);
0354 rbtx4927_gpioled_init();
0355 }
0356
0357 struct txx9_board_vec rbtx4927_vec __initdata = {
0358 .system = "Toshiba RBTX4927",
0359 .prom_init = rbtx4927_prom_init,
0360 .mem_setup = rbtx4927_mem_setup,
0361 .irq_setup = rbtx4927_irq_setup,
0362 .time_init = rbtx4927_time_init,
0363 .device_init = rbtx4927_device_init,
0364 .arch_init = rbtx4927_arch_init,
0365 #ifdef CONFIG_PCI
0366 .pci_map_irq = rbtx4927_pci_map_irq,
0367 #endif
0368 };
0369 struct txx9_board_vec rbtx4937_vec __initdata = {
0370 .system = "Toshiba RBTX4937",
0371 .prom_init = rbtx4927_prom_init,
0372 .mem_setup = rbtx4927_mem_setup,
0373 .irq_setup = rbtx4927_irq_setup,
0374 .time_init = rbtx4927_time_init,
0375 .device_init = rbtx4927_device_init,
0376 .arch_init = rbtx4937_arch_init,
0377 #ifdef CONFIG_PCI
0378 .pci_map_irq = rbtx4927_pci_map_irq,
0379 #endif
0380 };