diff options
author | Daniel Hellstrom <daniel@gaisler.com> | 2011-12-20 15:58:05 +0100 |
---|---|---|
committer | Daniel Hellstrom <daniel@gaisler.com> | 2015-04-17 01:10:17 +0200 |
commit | e67b2b8d0552068d5d2859c02ffb5c2e110056de (patch) | |
tree | 161f7d400a93c7d54569e8b34ceefa45fcaa0aff /c/src/lib/libbsp/sparc/shared/spw | |
parent | LEON2: added support for LEON2-GRLIB systems (diff) | |
download | rtems-e67b2b8d0552068d5d2859c02ffb5c2e110056de.tar.bz2 |
LEON: updated and added PCI peripherals for LEON BSPs
The CCHIP driver is replaced with the GR_701 driver. The
RASTA driver is replaced by the GR-RASTA-IO driver.
All drivers are now compatible with both LEON2 and LEON3,
drivers were initialized directly by the PCI-board drivers
are now initialized by the driver manager and therefore
does not require the double code created by including for
example grcan.c into grcan_rasta.c. The other drivers needs
to be updated to the driver manager framework however.
Added support for:
* GR-701 (only LEON2 before)
* GR-RASTA-IO (only LEON2 before)
* GR-RASTA-ADCDAC
* GR-RASTA-TMTC
* GR-RASTA-SPW-ROUTER
* GR-TMTC-1553
Diffstat (limited to 'c/src/lib/libbsp/sparc/shared/spw')
-rw-r--r-- | c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c | 132 | ||||
-rw-r--r-- | c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c | 158 |
2 files changed, 0 insertions, 290 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c deleted file mode 100644 index fce2fa8b36..0000000000 --- a/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c +++ /dev/null @@ -1,132 +0,0 @@ -#include <ambapp.h> -#include <rtems/libio.h> -#include <grspw_pci.h> - -/* Select PCI driver */ -#define GRSPW_PCI - -#undef GRSPW_MAXDEVS -#undef DEBUG_SPACEWIRE_ONOFF - -/* Only Malloced memory supported - */ -#undef GRSPW_LOCAL_MEM - -/* memory must be aligned to a 128k boundary */ -unsigned int grspwpci_memarea_address; -#define GRSPW_LOCAL_MEM_ADR grspwpci_memarea_address - -/* We have custom address tranlation for HW addresses */ -#define GRSPW_ADR_TO - -/* MEMAREA=>CPU used when reading descriptor buffer pointers, - * they need to be translated from adresses used by GRSPW HW - * into CPU readable addresses. - * - * NOT NEEDED AS GRSPW DRIVER USES INDEXES TO GET DESCRIPTOR - * DATA POINTER ADDRESSES. - */ -#undef GRSPW_ADR_FROM - -/* Set registered device name */ -#define GRSPW_DEVNAME "/dev/grspwpci0" -#define GRSPW_DEVNAME_NO(devstr,no) ((devstr)[13]='0'+(no)) - -/* Any non-static function will begin with */ -#define GRSPW_PREFIX(name) grspwpci##name - -/* do nothing, assume that the interrupt handler is called - * setup externally calling b1553_interrupt_handler. - */ -#define GRSPW_REG_INT(handler,irq,arg) \ - if ( grspw_pci_int_reg ) \ - grspw_pci_int_reg(handler,irq,arg); - -void (*grspw_pci_int_reg)(void *handler, int irq, void *arg) = 0; - - -#ifdef GRSPW_ADR_TO -/* Translate an address within the Memory Region (memarea) into an Hardware - * device address. This address is put into hardware registers or descriptors - * so that the hardware can access the Memory Region. - * Example: - * A local AMBA access at 0xe0000000 will translate into PCI address 0x40000000, - * the PCI address 0x40000000 will translate into LEON-AMBA address 0x40000000. - */ -unsigned int grspwpci_hw_address; -static inline unsigned int memarea_to_hw(unsigned int addr) { - /* don't translate? */ - if ( grspwpci_hw_address == 0xffffffff ) - return addr; - return ((addr & 0x0fffffff) | grspwpci_hw_address); -} -#endif - -/* not used since BRM Core work with offsets */ -#ifdef GRSPW_ADR_FROM -unsigned int grspwpci_cpu_access_address; -static inline unsigned int hw_to_cpu(unsigned int addr) { - /* don't translate? */ - if ( grspwpci_cpu_address == 0xffffffff ) - return addr; - return ((addr & 0x0fffffff) | grspwpci_cpu_address); -} -#endif - -int grspwpci_interrupt_handler(int irq, void *arg); - -#include "grspw.c" - -/* - * - * memarea = preallocated memory somewhere, pointer to start of memory. - * hw_address = how to translate a memarea address into an HW device AMBA address. - */ - -int grspw_pci_register( - struct ambapp_bus *bus, - unsigned int memarea, - unsigned int hw_address - ) -{ - /* Setup configuration */ - - /* if zero the malloc will be used */ - grspwpci_memarea_address = memarea; - - grspwpci_hw_address = hw_address; - -#ifdef GRSPW_ADR_FROM - grspwpci_cpu_address = memarea & 0xf0000000; -#endif - - /* Register the driver */ - return GRSPW_PREFIX(_register)(bus); -} - -/* Call this from PCI interrupt handler - * irq = the irq number of the HW device local to that IRQMP controller - * - */ -int grspwpci_interrupt_handler(int irq, void *arg){ - grspw_interrupt( (GRSPW_DEV *)arg ); - return 0; -} - -#if 0 -int grspw_pci_interrupt_handler(int irqmask){ - int i; - unsigned int mask=0; - /* find minor */ - for(i=0; i<spw_cores; i++){ - if ( (1<<SPW_PARAM(i).irq) & irqmask ){ - mask |= 1<<SPW_PARAM(i).irq; - grspw_interrupt(i); - /* more interrupts to scan for? */ - if ( irqmask & ~mask ) - return mask; /* handled */ - } - } - return mask; -} -#endif diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c deleted file mode 100644 index b76d46a922..0000000000 --- a/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c +++ /dev/null @@ -1,158 +0,0 @@ -#include <rtems.h> -#include <grspw_rasta.h> - -/* Select PCI driver */ -#define GRSPW_PCI - -#undef GRSPW_MAXDEVS -#undef DEBUG_SPACEWIRE_ONOFF -/*#define DEBUG_SPACEWIRE_ONOFF*/ -/* - * If USE_AT697_RAM is defined the RAM on the AT697 board will be used for DMA buffers (but rx message queue is always in AT697 ram). - * USE_AT697_DMA specifies whether the messages will be fetched using DMA or PIO. - * - * RASTA_PCI_BASE is the base address of the GRPCI AHB slave - * - */ - -#define USE_AT697_RAM 1 -#define USE_AT697_DMA 0 -#define RASTA_PCI_BASE 0xe0000000 -#define GRSPW_RASTA_MEM_OFF 0x21000 - -/* Make GRSPW driver use malloced or static memory - */ -#ifdef USE_AT697_RAM -#undef GRSPW_STATIC_MEM -#else -#define GRSPW_STATIC_MEM -#define GRSPW_CALC_MEMOFS(maxcores,corenum,ptr_mem_base,ptr_mem_end,ptr_bdtable_base) \ - grspw_rasta_calc_memoffs((maxcores),(corenum),(ptr_mem_base),(ptr_mem_end),(ptr_bdtable_base)) -#endif - -/* We have custom address tranlation for HW addresses */ -#define GRSPW_ADR_TO - -/* MEMAREA=>CPU used when reading descriptor buffer pointers, - * they need to be translated from adresses used by GRSPW HW - * into CPU readable addresses. - * - * NOT NEEDED AS GRSPW DRIVER USES INDEXES TO GET DESCRIPTOR - * DATA POINTER ADDRESSES. - */ -#undef GRSPW_ADR_FROM - -/* Set registered device name */ -#define GRSPW_DEVNAME "/dev/grspwrasta0" -#define GRSPW_DEVNAME_NO(devstr,no) ((devstr)[15]='0'+(no)) - -/* Any non-static function will begin with */ -#define GRSPW_PREFIX(name) grspwrasta##name - -/* do nothing, assume that the interrupt handler is called - * setup externally calling grspw_interrupt_handler. - */ -#define GRSPW_REG_INT(handler,irq,arg) \ - if ( grspw_rasta_int_reg ) \ - grspw_rasta_int_reg(handler,irq,arg); - -#define GRSPW_DONT_BYPASS_CACHE - -#ifdef GRSPW_ADR_TO -/* Translate a address within the Memory Region (memarea) into an Hardware - * device address. This address is put into hardware registers or descriptors - * so that the hardware can access the Memory Region. - * Example: - * An local AMBA access at 0xe0000000 will translate into PCI address 0x40000000, - * the PCI address 0x40000000 will translate into CPU-AMBA address 0x40000000. - */ -static inline unsigned int memarea_to_hw(unsigned int addr) { - return ((addr & 0x0fffffff) | RASTA_PCI_BASE); -} -#endif - -void (*grspw_rasta_int_reg)(void *handler, int irq, void *arg) = 0; - -#ifdef GRSPW_STATIC_MEM -static int grspw_rasta_calc_memoffs(int maxcores, int corenum, unsigned int *mem_base, unsigned int *mem_end, unsigned int *bdtable_base); -#endif - -void grspw_rasta_interrupt_handler(unsigned int status); - -void grspwrasta_interrupt_handler(int irq, void *pDev); - -#include "grspw.c" - -unsigned int grspw_rasta_memarea_address; - -/* Register RASTA GRSPW driver. - * - * memarea = preallocated memory somewhere, pointer to start of memory. - */ - -int grspw_rasta_register( - struct ambapp_bus *bus, - unsigned int ram_base - ) -{ - /* Setup configuration */ - - /* if zero the malloc will be used */ - grspw_rasta_memarea_address = ram_base + GRSPW_RASTA_MEM_OFF; - - /* Register the driver */ - return GRSPW_PREFIX(_register)(bus); -} - -#if 0 -/* Call this from PCI interrupt handler, simply figures out - * which GRSPW core was responsible for the IRQ (may be multiple). - * v = status of the PCI/AMBA MCPU IRQ CTRL - */ -void grspw_rasta_interrupt_handler(unsigned int status) -{ - int minor; - - for(minor = 0; minor < spw_cores; minor++) { - if (status & (1<<grspw_devs[minor].irq) ) { - grspw_interrupt(&grspw_devs[minor]); - } - } -} -#endif - -void GRSPW_PREFIX(_interrupt_handler)(int irq, void *pDev) -{ - grspw_interrupt(pDev); -} - - -#ifdef GRSPW_STATIC_MEM -/* - * --------------------------------------- <- - * | Core1: BD TABLE 1 and 2 | - * | Core2: BD TABLE 1 and 2 | - * | Core3: BD TABLE 1 and 2 | - * |-------------------------------------| - * | Core1: rx data buf + rx header buf | - * | Core2: rx data buf + rx header buf | - * | Core3: rx data buf + rx header buf | - * --------------------------------------- - */ -static int grspw_rasta_calc_memoffs(int maxcores, int corenum, unsigned int *mem_base, unsigned int *mem_end, unsigned int *bdtable_base) -{ - if ( maxcores > 3 ) - return -1; - - if ( bdtable_base ) - *bdtable_base = grspw_rasta_memarea_address + corenum*2*SPACEWIRE_BDTABLE_SIZE; - - if ( mem_base ) - *mem_base = grspw_rasta_memarea_address + coremax*2*SPACEWIRE_BDTABLE_SIZE + corenum*BUFMEM_PER_LINK; - - if ( mem_end ) - *mem_end = grspw_rasta_memarea_address + coremax*2*SPACEWIRE_BDTABLE_SIZE + (corenum+1)*BUFMEM_PER_LINK; - - return 0; -} -#endif |