diff options
Diffstat (limited to 'arch/mips/txx9/rbtx4939/setup.c')
-rw-r--r-- | arch/mips/txx9/rbtx4939/setup.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c index 9855d7bccc20..6daee9b1cd5e 100644 --- a/arch/mips/txx9/rbtx4939/setup.c +++ b/arch/mips/txx9/rbtx4939/setup.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/leds.h> | 16 | #include <linux/leds.h> |
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/smc91x.h> | ||
17 | #include <asm/reboot.h> | 19 | #include <asm/reboot.h> |
18 | #include <asm/txx9/generic.h> | 20 | #include <asm/txx9/generic.h> |
19 | #include <asm/txx9/pci.h> | 21 | #include <asm/txx9/pci.h> |
@@ -33,6 +35,21 @@ static void __init rbtx4939_time_init(void) | |||
33 | tx4939_time_init(0); | 35 | tx4939_time_init(0); |
34 | } | 36 | } |
35 | 37 | ||
38 | #if defined(__BIG_ENDIAN) && \ | ||
39 | (defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)) | ||
40 | #define HAVE_RBTX4939_IOSWAB | ||
41 | #define IS_CE1_ADDR(addr) \ | ||
42 | ((((unsigned long)(addr) - IO_BASE) & 0xfff00000) == TXX9_CE(1)) | ||
43 | static u16 rbtx4939_ioswabw(volatile u16 *a, u16 x) | ||
44 | { | ||
45 | return IS_CE1_ADDR(a) ? x : le16_to_cpu(x); | ||
46 | } | ||
47 | static u16 rbtx4939_mem_ioswabw(volatile u16 *a, u16 x) | ||
48 | { | ||
49 | return !IS_CE1_ADDR(a) ? x : le16_to_cpu(x); | ||
50 | } | ||
51 | #endif /* __BIG_ENDIAN && CONFIG_SMC91X */ | ||
52 | |||
36 | static void __init rbtx4939_pci_setup(void) | 53 | static void __init rbtx4939_pci_setup(void) |
37 | { | 54 | { |
38 | #ifdef CONFIG_PCI | 55 | #ifdef CONFIG_PCI |
@@ -239,6 +256,32 @@ static inline void rbtx4939_led_setup(void) | |||
239 | } | 256 | } |
240 | #endif | 257 | #endif |
241 | 258 | ||
259 | static void __rbtx4939_7segled_putc(unsigned int pos, unsigned char val) | ||
260 | { | ||
261 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) | ||
262 | unsigned long flags; | ||
263 | local_irq_save(flags); | ||
264 | /* bit7: reserved for LED class */ | ||
265 | led_val[pos] = (led_val[pos] & 0x80) | (val & 0x7f); | ||
266 | val = led_val[pos]; | ||
267 | local_irq_restore(flags); | ||
268 | #endif | ||
269 | writeb(val, rbtx4939_7seg_addr(pos / 4, pos % 4)); | ||
270 | } | ||
271 | |||
272 | static void rbtx4939_7segled_putc(unsigned int pos, unsigned char val) | ||
273 | { | ||
274 | /* convert from map_to_seg7() notation */ | ||
275 | val = (val & 0x88) | | ||
276 | ((val & 0x40) >> 6) | | ||
277 | ((val & 0x20) >> 4) | | ||
278 | ((val & 0x10) >> 2) | | ||
279 | ((val & 0x04) << 2) | | ||
280 | ((val & 0x02) << 4) | | ||
281 | ((val & 0x01) << 6); | ||
282 | __rbtx4939_7segled_putc(pos, val); | ||
283 | } | ||
284 | |||
242 | static void __init rbtx4939_arch_init(void) | 285 | static void __init rbtx4939_arch_init(void) |
243 | { | 286 | { |
244 | rbtx4939_pci_setup(); | 287 | rbtx4939_pci_setup(); |
@@ -246,6 +289,22 @@ static void __init rbtx4939_arch_init(void) | |||
246 | 289 | ||
247 | static void __init rbtx4939_device_init(void) | 290 | static void __init rbtx4939_device_init(void) |
248 | { | 291 | { |
292 | unsigned long smc_addr = RBTX4939_ETHER_ADDR - IO_BASE; | ||
293 | struct resource smc_res[] = { | ||
294 | { | ||
295 | .start = smc_addr, | ||
296 | .end = smc_addr + 0x10 - 1, | ||
297 | .flags = IORESOURCE_MEM, | ||
298 | }, { | ||
299 | .start = RBTX4939_IRQ_ETHER, | ||
300 | /* override default irq flag defined in smc91x.h */ | ||
301 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, | ||
302 | }, | ||
303 | }; | ||
304 | struct smc91x_platdata smc_pdata = { | ||
305 | .flags = SMC91X_USE_16BIT, | ||
306 | }; | ||
307 | struct platform_device *pdev; | ||
249 | #if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) | 308 | #if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) |
250 | int i, j; | 309 | int i, j; |
251 | unsigned char ethaddr[2][6]; | 310 | unsigned char ethaddr[2][6]; |
@@ -262,6 +321,12 @@ static void __init rbtx4939_device_init(void) | |||
262 | } | 321 | } |
263 | tx4939_ethaddr_init(ethaddr[0], ethaddr[1]); | 322 | tx4939_ethaddr_init(ethaddr[0], ethaddr[1]); |
264 | #endif | 323 | #endif |
324 | pdev = platform_device_alloc("smc91x", -1); | ||
325 | if (!pdev || | ||
326 | platform_device_add_resources(pdev, smc_res, ARRAY_SIZE(smc_res)) || | ||
327 | platform_device_add_data(pdev, &smc_pdata, sizeof(smc_pdata)) || | ||
328 | platform_device_add(pdev)) | ||
329 | platform_device_put(pdev); | ||
265 | rbtx4939_led_setup(); | 330 | rbtx4939_led_setup(); |
266 | tx4939_wdt_init(); | 331 | tx4939_wdt_init(); |
267 | tx4939_ata_init(); | 332 | tx4939_ata_init(); |
@@ -269,6 +334,8 @@ static void __init rbtx4939_device_init(void) | |||
269 | 334 | ||
270 | static void __init rbtx4939_setup(void) | 335 | static void __init rbtx4939_setup(void) |
271 | { | 336 | { |
337 | int i; | ||
338 | |||
272 | rbtx4939_ebusc_setup(); | 339 | rbtx4939_ebusc_setup(); |
273 | /* always enable ATA0 */ | 340 | /* always enable ATA0 */ |
274 | txx9_set64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_ATA0MODE); | 341 | txx9_set64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_ATA0MODE); |
@@ -276,9 +343,16 @@ static void __init rbtx4939_setup(void) | |||
276 | if (txx9_master_clock == 0) | 343 | if (txx9_master_clock == 0) |
277 | txx9_master_clock = 20000000; | 344 | txx9_master_clock = 20000000; |
278 | tx4939_setup(); | 345 | tx4939_setup(); |
346 | #ifdef HAVE_RBTX4939_IOSWAB | ||
347 | ioswabw = rbtx4939_ioswabw; | ||
348 | __mem_ioswabw = rbtx4939_mem_ioswabw; | ||
349 | #endif | ||
279 | 350 | ||
280 | _machine_restart = rbtx4939_machine_restart; | 351 | _machine_restart = rbtx4939_machine_restart; |
281 | 352 | ||
353 | txx9_7segled_init(RBTX4939_MAX_7SEGLEDS, rbtx4939_7segled_putc); | ||
354 | for (i = 0; i < RBTX4939_MAX_7SEGLEDS; i++) | ||
355 | txx9_7segled_putc(i, '-'); | ||
282 | pr_info("RBTX4939 (Rev %02x) --- FPGA(Rev %02x) DIPSW:%02x,%02x\n", | 356 | pr_info("RBTX4939 (Rev %02x) --- FPGA(Rev %02x) DIPSW:%02x,%02x\n", |
283 | readb(rbtx4939_board_rev_addr), readb(rbtx4939_ioc_rev_addr), | 357 | readb(rbtx4939_board_rev_addr), readb(rbtx4939_ioc_rev_addr), |
284 | readb(rbtx4939_udipsw_addr), readb(rbtx4939_bdipsw_addr)); | 358 | readb(rbtx4939_udipsw_addr), readb(rbtx4939_bdipsw_addr)); |