From 9956f81dfb0980f7757b26ee4c2d1b0c61f4d0ba Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 12 Jul 2006 19:08:32 +0000 Subject: 2006-07-12 Joel Sherrill * Makefile.am, include/leon.h: Try to merge rest of 4.6 BSP changes. * include/spacewire.h: New file. --- c/src/lib/libbsp/sparc/leon3/ChangeLog | 5 + c/src/lib/libbsp/sparc/leon3/Makefile.am | 1 + c/src/lib/libbsp/sparc/leon3/include/leon.h | 58 ++----- c/src/lib/libbsp/sparc/leon3/include/spacewire.h | 186 +++++++++++++++++++++++ 4 files changed, 204 insertions(+), 46 deletions(-) create mode 100644 c/src/lib/libbsp/sparc/leon3/include/spacewire.h (limited to 'c/src/lib/libbsp') diff --git a/c/src/lib/libbsp/sparc/leon3/ChangeLog b/c/src/lib/libbsp/sparc/leon3/ChangeLog index 71ca067c32..16181f8a9f 100644 --- a/c/src/lib/libbsp/sparc/leon3/ChangeLog +++ b/c/src/lib/libbsp/sparc/leon3/ChangeLog @@ -1,3 +1,8 @@ +2006-07-12 Joel Sherrill + + * Makefile.am, include/leon.h: Try to merge rest of 4.6 BSP changes. + * include/spacewire.h: New file. + 2006-07-12 Joel Sherrill * Makefile.am: Merge SHM support from 4.6 branch. diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am index 021b7e77b0..e9dfc1e605 100644 --- a/c/src/lib/libbsp/sparc/leon3/Makefile.am +++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am @@ -23,6 +23,7 @@ SUBDIRS = . tools include_HEADERS += include/leon.h include_HEADERS += include/coverhd.h +include_HEADERS += include/spacewire.h EXTRA_DIST = ../../sparc/shared/start.S start.$(OBJEXT): ../../sparc/shared/start.S diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h index 3482f161a7..d0efb1ee07 100644 --- a/c/src/lib/libbsp/sparc/leon3/include/leon.h +++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h @@ -118,7 +118,7 @@ typedef struct { volatile unsigned int ipend; volatile unsigned int iforce; volatile unsigned int iclear; - volatile unsigned int notused00; + volatile unsigned int mpstat; volatile unsigned int notused01; volatile unsigned int notused02; volatile unsigned int notused03; @@ -130,65 +130,24 @@ typedef struct { volatile unsigned int notused21; volatile unsigned int notused22; volatile unsigned int notused23; - volatile unsigned int mask_p0; - volatile unsigned int mask_p1; - volatile unsigned int mask_p2; - volatile unsigned int mask_p3; - volatile unsigned int mask_p4; - volatile unsigned int mask_p5; - volatile unsigned int mask_p6; - volatile unsigned int mask_p7; - volatile unsigned int mask_p8; - volatile unsigned int mask_p9; - volatile unsigned int mask_p10; - volatile unsigned int mask_p11; - volatile unsigned int mask_p12; - volatile unsigned int mask_p13; - volatile unsigned int mask_p14; - volatile unsigned int mask_p15; + volatile unsigned int mask[16]; + volatile unsigned int force[16]; } LEON3_IrqCtrl_Regs_Map; -/* typedef struct { volatile unsigned int value; volatile unsigned int reload; volatile unsigned int conf; volatile unsigned int notused; } LEON3_Timer_SubType; -*/ + typedef struct { volatile unsigned int scaler_value; /* common timer registers */ volatile unsigned int scaler_reload; volatile unsigned int status; volatile unsigned int notused; - volatile unsigned int value_t0; /* timer 0 */ - volatile unsigned int reload_t0; - volatile unsigned int conf_t0; - volatile unsigned int notused0; - volatile unsigned int value_t1; /* timer 1 */ - volatile unsigned int reload_t1; - volatile unsigned int conf_t1; - volatile unsigned int notused1; - volatile unsigned int value_t2; /* timer 2 */ - volatile unsigned int reload_t2; - volatile unsigned int conf_t2; - volatile unsigned int notused2; - volatile unsigned int value_t3; /* timer 3 */ - volatile unsigned int reload_t3; - volatile unsigned int conf_t3; - volatile unsigned int notused3; - volatile unsigned int value_t4; /* timer 4 */ - volatile unsigned int reload_t4; - volatile unsigned int conf_t4; - volatile unsigned int notused4; - volatile unsigned int value_t5; /* timer 5 */ - volatile unsigned int reload_t5; - volatile unsigned int conf_t5; - volatile unsigned int notused5; - volatile unsigned int value_t6; /* timer 6 */ - volatile unsigned int reload_t6; - volatile unsigned int conf_t6; + LEON3_Timer_SubType timer[8]; } LEON3_Timer_Regs_Map; typedef struct { @@ -297,6 +256,8 @@ extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */ extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS]; +extern int LEON3_Cpu_Index; + /* Macros used for manipulating bits in LEON3 GP Timer Control Register */ #define LEON3_GPTIMER_EN 1 @@ -304,6 +265,8 @@ extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS]; #define LEON3_GPTIMER_LD 4 #define LEON3_GPTIMER_IRQEN 8 +#define LEON3_MP_IRQ 14 /* Irq used by shared memory driver */ + #ifndef ASM /* @@ -404,6 +367,9 @@ extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS]; #define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003 #define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003 +/* XXX really needed but I can't get it to install -- JRS */ +/* #include */ + #endif /* !ASM */ #ifdef __cplusplus diff --git a/c/src/lib/libbsp/sparc/leon3/include/spacewire.h b/c/src/lib/libbsp/sparc/leon3/include/spacewire.h new file mode 100644 index 0000000000..516cc93772 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon3/include/spacewire.h @@ -0,0 +1,186 @@ +/* + * Macros used for Spacewire bus + * + * COPYRIGHT (c) 2004. + * Gaisler Research + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef __SPACEWIRE_h +#define __SPACEWIRE_h + +typedef struct { + volatile unsigned int ctrl; + volatile unsigned int status; + volatile unsigned int nodeaddr; + volatile unsigned int clockdiv; + volatile unsigned int destkey; + volatile unsigned int pad1,pad2,pad3; + + volatile unsigned int dma0ctrl; /* 0x20 */ + volatile unsigned int dma0rxmax; + volatile unsigned int dma0txdesc; + volatile unsigned int dma0rxdesc; +} LEON3_SPACEWIRE_Regs_Map; + +typedef struct { + volatile unsigned int ctrl; + volatile unsigned int addr; +} SPACEWIRE_RXBD; + +typedef struct { + volatile unsigned int ctrl; + volatile unsigned int addr_header; + volatile unsigned int len; + volatile unsigned int addr_data; +} SPACEWIRE_TXBD; + +#define SPACEWIRE_BDTABLE_SIZE 0x400 +#define SPACEWIRE_TXPCK_SIZE 1024 +#define SPACEWIRE_RXPCK_SIZE 1024 +#define SPACEWIRE_TXBUFS_NR 1 +#define SPACEWIRE_RXBUFS_NR 2 +#define SPW_BUFMALLOC 1 + +#define SPW_ALIGN(p,c) ((((unsigned int)(p))+((c)-1))&~((c)-1)) + +int spacewire_setattibutes(int minor, int nodeaddr, int proto, int dest); + +typedef struct { + unsigned int nodeaddr; + unsigned int destnodeaddr; + unsigned int proto; + unsigned int destkey; + unsigned int maxfreq; + unsigned int clkdiv; + unsigned int rxmaxlen; + + unsigned int is_rmap,is_rxunaligned,is_rmapcrc; + + unsigned int txcur,rxcur,rxbufcur; + unsigned int txbufsize,rxbufsize; + unsigned int txbufcnt,rxbufcnt; + char *ptr_rxbuf0,*ptr_txbuf0; + unsigned int irq; + + SPACEWIRE_RXBD *rx; + SPACEWIRE_TXBD *tx; + + char _rxtable[SPACEWIRE_BDTABLE_SIZE*2]; + char _txtable[SPACEWIRE_BDTABLE_SIZE*2]; + +#ifndef SPW_BUFMALLOC + char _rxbuf0[SPACEWIRE_RXPCK_SIZE*SPACEWIRE_RXBUFS_NR]; + char _txbuf0[SPACEWIRE_TXPCK_SIZE*SPACEWIRE_TXBUFS_NR]; +#endif + + volatile LEON3_SPACEWIRE_Regs_Map *regs; +} SPACEWIRE_PARAM; + +int _SPW_READ(void *addr); +#define SPW_READ(addr) _SPW_READ((void *)(addr)) +#define SPW_WRITE(addr,v) *addr=v + +#define SPACEWIRE_MAX_CORENR 2 +extern SPACEWIRE_PARAM LEON3_Spacewire[SPACEWIRE_MAX_CORENR]; + +#define SPW_PARAM(c) (LEON3_Spacewire[c]) +#define SPW_REG(c,r) (SPW_PARAM(c).regs->r) +#define SPW_REG_CTRL(c) SPW_REG(c,ctrl) +#define SPW_REG_STATUS(c) SPW_REG(c,status) +#define SPW_REG_NODEADDR(c) SPW_REG(c,nodeaddr) + +#define SPW_CTRL_READ(c) SPW_READ(&SPW_REG_CTRL(c)) +#define SPW_CTRL_WRITE(c,v) SPW_WRITE(&SPW_REG_CTRL(c),v) +#define SPW_STATUS_READ(c) SPW_READ(&SPW_REG_STATUS(c)) +#define SPW_STATUS_WRITE(c,v) SPW_WRITE(&SPW_REG_STATUS(c),v) + +#define SPW_LINKSTATE(c) (((c) >> 21) & 0x7) + +#define SPW_NODEADDR_READ(c) SPW_BYPASSCACHE(&SPW_NODEADDR(c)) +#define SPW_NODEADDR_WRITE(c,v) SPW_NODEADDR(c) = v + +#define SPACEWIRE_RXNR(c) ((c&~(SPACEWIRE_BDTABLE_SIZE-1))>>3) +#define SPACEWIRE_TXNR(c) ((c&~(SPACEWIRE_BDTABLE_SIZE-1))>>4) + +#define SPACEWIRE_RXBD_LENGTH 0x1ffffff +#define SPACEWIRE_RXBD_EN (1<<25) +#define SPACEWIRE_RXBD_WR (1<<26) +#define SPACEWIRE_RXBD_IE (1<<27) + +#define SPACEWIRE_RXBD_EEP (1<<28) +#define SPACEWIRE_RXBD_EHC (1<<29) +#define SPACEWIRE_RXBD_EDC (1<<30) +#define SPACEWIRE_RXBD_ETR (1<<31) + +#define SPACEWIRE_RXBD_ERROR (SPACEWIRE_RXBD_EEP | \ + SPACEWIRE_RXBD_EHC | \ + SPACEWIRE_RXBD_EDC | \ + SPACEWIRE_RXBD_ETR) + +#define SPACEWIRE_RXBD_RMAPERROR (SPACEWIRE_RXBD_EHC | SPACEWIRE_RXBD_EDC) + +#define SPACEWIRE_RXBD_LENGTH(c) ((c)&0xffffff) +#define SPACEWIRE_PCKHEAD 2 + +#define SPACEWIRE_TXBD_LENGTH 0xffffff + +#define SPACEWIRE_TXBD_EN (1<<12) +#define SPACEWIRE_TXBD_WR (1<<13) +#define SPACEWIRE_TXBD_IE (1<<14) + +#define SPACEWIRE_TXBD_LE (1<<15) + +#define SPACEWIRE_TXBD_ERROR (SPACEWIRE_TXBD_LE) + +#define SPACEWIRE_CTRL_RA (1<<31) +#define SPACEWIRE_CTRL_RX (1<<30) +#define SPACEWIRE_CTRL_RC (1<<29) + +#define SPACEWIRE_CTRL_RESET (1<<6) +#define SPACEWIRE_CTRL_LINKSTART (1<<1) +#define SPACEWIRE_CTRL_LINKDISABLE (1<<0) + +#define SPACEWIRE_DMACTRL_TXEN (1<<0) +#define SPACEWIRE_DMACTRL_RXEN (1<<1) +#define SPACEWIRE_DMACTRL_TXIE (1<<2) +#define SPACEWIRE_DMACTRL_RXIE (1<<3) + +#define SPACEWIRE_DMACTRL_AI (1<<4) +#define SPACEWIRE_DMACTRL_PS (1<<5) +#define SPACEWIRE_DMACTRL_PR (1<<6) +#define SPACEWIRE_DMACTRL_TA (1<<7) +#define SPACEWIRE_DMACTRL_RA (1<<8) + +#define SPACEWIRE_DMACTRL_RD (1<<11) +#define SPACEWIRE_DMACTRL_NS (1<<12) + +#define SPACEWIRE_PREPAREMASK_TX (SPACEWIRE_DMACTRL_RXEN | SPACEWIRE_DMACTRL_RXIE | SPACEWIRE_DMACTRL_PS | SPACEWIRE_DMACTRL_TA | SPACEWIRE_DMACTRL_RD) +#define SPACEWIRE_PREPAREMASK_RX (SPACEWIRE_DMACTRL_TXEN | SPACEWIRE_DMACTRL_TXIE | SPACEWIRE_DMACTRL_AI | SPACEWIRE_DMACTRL_PR | SPACEWIRE_DMACTRL_RA) + + +#define SPACEWIRE_IOCTRL_SET_NODEADDR 1 +#define SPACEWIRE_IOCTRL_SET_PROTOCOL 2 +#define SPACEWIRE_IOCTRL_SET_DESTNODEADDR 3 +#define SPACEWIRE_IOCTRL_GET_COREBASEADDR 4 +#define SPACEWIRE_IOCTRL_GET_COREIRQ 5 +#define SPACEWIRE_IOCTRL_SET_PACKETSIZE 6 +#define SPACEWIRE_IOCTRL_GETPACKET 7 +#define SPACEWIRE_IOCTRL_PUTPACKET 8 + +typedef struct { + unsigned int txsize, rxsize; +} spw_ioctl_packetsize; + +typedef struct { + char *buf; + int buf_size; + int ret_size; +} spw_ioctl_packet; + +#endif -- cgit v1.2.3