diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-09-06 00:07:44 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-09-06 00:07:44 +0000 |
commit | 921bb59a83a3e9112bb83f67ef886a0ce685367d (patch) | |
tree | 2bd11eddb8ea431818d4bdf9abe6c93a6190cffe /c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c | |
parent | 2007-09-05 Daniel Hellstrom <daniel@gaisler.com> (diff) | |
download | rtems-921bb59a83a3e9112bb83f67ef886a0ce685367d.tar.bz2 |
2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
* clock/ckinit.c, console/console.c, leon_greth/leon_greth.c,
leon_smc91111/leon_smc91111.c: LEON3 BSP drivers updated to use new
AMBA PnP scanning functions. Affected drivers:
amba/amba.c,clock/ckinit.c,console/console.c,
leon_greth/leon_greth.c, leon_smc9111.c.
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c | 105 |
1 files changed, 41 insertions, 64 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c index 5929a58b25..f7743ba64e 100644 --- a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c +++ b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c @@ -13,83 +13,60 @@ scmv91111_configuration_t leon_scmv91111_configuration = { SMC91111_BASE_ADDR, /* base address */ - LEON_TRAP_TYPE(SMC91111_BASE_IRQ), /* vector number */ + LEON_TRAP_TYPE (SMC91111_BASE_IRQ), /* vector number */ SMC91111_BASE_PIO, /* PIO */ - 10, /* 10b */ + 100, /* 100b */ 1, /* fulldx */ 1 /* autoneg */ }; -int _rtems_smc91111_driver_attach( - struct rtems_bsdnet_ifconfig *config, - scmv91111_configuration_t *scm_config -); +int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config, + scmv91111_configuration_t * scm_config); /* * Attach an SMC91111 driver to the system */ -int rtems_smc91111_driver_attach_leon3 ( - struct rtems_bsdnet_ifconfig *config, - int attach -) +int +rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config, + int attach) { - unsigned int iobar, conf,i; + unsigned long addr_mctrl = 0; + LEON3_IOPORT_Regs_Map *io; - { - unsigned long irq_pio, irq_mctrl, addr_pio = 0; - unsigned long addr_mctrl = 0, addr_timer = 0; - - i = 0; - while (i < amba_conf.apbslv.devnr) - { - conf = amba_get_confword(amba_conf.apbslv, i, 0); - if ((amba_vendor(conf) == VENDOR_GAISLER) && - (amba_device(conf) == GAISLER_PIOPORT)) - { - irq_pio = amba_irq(conf); - iobar = amba_apb_get_membar(amba_conf.apbslv, i); - addr_pio = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar); - } - else if ((amba_vendor(conf) == VENDOR_ESA) && - (amba_device(conf) == ESA_MCTRL)) - { - irq_mctrl = amba_irq(conf); - iobar = amba_apb_get_membar(amba_conf.apbslv, i); - addr_mctrl = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar); - } - else if ((amba_vendor(conf) == VENDOR_GAISLER) && - (amba_device(conf) == GAISLER_GPTIMER)) - { - iobar = amba_apb_get_membar(amba_conf.apbslv, i); - addr_timer = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar); - } - i++; - } - - if (addr_timer) { - LEON3_Timer_Regs_Map *timer = (LEON3_Timer_Regs_Map *)addr_timer; - if (timer->scaler_reload >= 49) - leon_scmv91111_configuration.ctl_rspeed = 100; - } - - if (addr_pio && addr_mctrl) { - - LEON3_IOPORT_Regs_Map *io = (LEON3_IOPORT_Regs_Map *) addr_pio; - printk( - "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n", - (unsigned int)addr_pio, - (unsigned int)addr_mctrl); - - *((volatile unsigned int *)addr_mctrl) |= 0x10f80000; /*mctrl ctrl 1 */ - io->irqmask |= (1 << leon_scmv91111_configuration.pio); - io->irqpol |= (1 << leon_scmv91111_configuration.pio); - io->irqedge |= (1 << leon_scmv91111_configuration.pio); - io->iodir &= ~(1 << leon_scmv91111_configuration.pio); - } else { + amba_apb_device apbpio, apbmctrl; + + if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){ + printk("SMC9111_leon3: didn't find PIO\n"); + return 0; + } + + /* Find LEON2 memory controller */ + if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){ + /* LEON2 memory controller not found, search for fault tolerant memory controller */ + if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) { + printk("SMC9111_leon3: didn't find any memory controller\n"); return 0; } } - return _rtems_smc91111_driver_attach(config,&leon_scmv91111_configuration); -}; + /* Get controller address */ + addr_mctrl = (unsigned long) apbmctrl.start; + io = (LEON3_IOPORT_Regs_Map *) apbpio.start; + + printk( + "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n", + (unsigned int)io, + (unsigned int)addr_mctrl); + + /* Setup PIO IRQ */ + io->irqmask |= (1 << leon_scmv91111_configuration.pio); + io->irqpol |= (1 << leon_scmv91111_configuration.pio); + io->irqedge |= (1 << leon_scmv91111_configuration.pio); + io->iodir &= ~(1 << leon_scmv91111_configuration.pio); + /* Setup memory controller I/O waitstates */ + *((volatile unsigned int *) addr_mctrl) |= 0x10f80000; /* enable I/O area access */ + + return _rtems_smc91111_driver_attach (config, + &leon_scmv91111_configuration); +}; |