source: rtems/c/src/lib/libbsp/sparc/leon3/include/spacewire.h @ 9956f81d

4.104.114.84.95
Last change on this file since 9956f81d was 9956f81d, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 12, 2006 at 7:08:32 PM

2006-07-12 Joel Sherrill <joel@…>

  • Makefile.am, include/leon.h: Try to merge rest of 4.6 BSP changes.
  • include/spacewire.h: New file.
  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 *  Macros used for Spacewire bus
3 *
4 *  COPYRIGHT (c) 2004.
5 *  Gaisler Research
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifndef __SPACEWIRE_h
15#define __SPACEWIRE_h
16
17typedef struct {
18  volatile unsigned int ctrl;
19  volatile unsigned int status;
20  volatile unsigned int nodeaddr;
21  volatile unsigned int clockdiv;
22  volatile unsigned int destkey;
23  volatile unsigned int pad1,pad2,pad3;
24 
25  volatile unsigned int dma0ctrl; /* 0x20 */
26  volatile unsigned int dma0rxmax;
27  volatile unsigned int dma0txdesc;
28  volatile unsigned int dma0rxdesc;
29} LEON3_SPACEWIRE_Regs_Map;
30
31typedef struct {
32  volatile unsigned int ctrl;
33  volatile unsigned int addr;
34} SPACEWIRE_RXBD;
35
36typedef struct {
37  volatile unsigned int ctrl;
38  volatile unsigned int addr_header;
39  volatile unsigned int len;
40  volatile unsigned int addr_data;
41} SPACEWIRE_TXBD;
42
43#define SPACEWIRE_BDTABLE_SIZE 0x400
44#define SPACEWIRE_TXPCK_SIZE 1024
45#define SPACEWIRE_RXPCK_SIZE 1024
46#define SPACEWIRE_TXBUFS_NR 1
47#define SPACEWIRE_RXBUFS_NR 2
48#define SPW_BUFMALLOC 1
49
50#define SPW_ALIGN(p,c) ((((unsigned int)(p))+((c)-1))&~((c)-1))
51
52int spacewire_setattibutes(int minor, int nodeaddr, int proto, int dest);
53
54typedef struct {
55  unsigned int nodeaddr;
56  unsigned int destnodeaddr;
57  unsigned int proto;
58  unsigned int destkey;
59  unsigned int maxfreq;
60  unsigned int clkdiv;
61  unsigned int rxmaxlen;
62 
63  unsigned int is_rmap,is_rxunaligned,is_rmapcrc;
64
65  unsigned int txcur,rxcur,rxbufcur;
66  unsigned int txbufsize,rxbufsize;
67  unsigned int txbufcnt,rxbufcnt;
68  char *ptr_rxbuf0,*ptr_txbuf0;
69  unsigned int irq;
70 
71  SPACEWIRE_RXBD *rx;
72  SPACEWIRE_TXBD *tx;
73 
74  char _rxtable[SPACEWIRE_BDTABLE_SIZE*2];
75  char _txtable[SPACEWIRE_BDTABLE_SIZE*2];
76
77#ifndef SPW_BUFMALLOC 
78  char _rxbuf0[SPACEWIRE_RXPCK_SIZE*SPACEWIRE_RXBUFS_NR];
79  char _txbuf0[SPACEWIRE_TXPCK_SIZE*SPACEWIRE_TXBUFS_NR];
80#endif 
81 
82  volatile LEON3_SPACEWIRE_Regs_Map *regs;
83} SPACEWIRE_PARAM;
84
85int _SPW_READ(void *addr);
86#define SPW_READ(addr) _SPW_READ((void *)(addr))
87#define SPW_WRITE(addr,v) *addr=v
88
89#define SPACEWIRE_MAX_CORENR 2
90extern SPACEWIRE_PARAM LEON3_Spacewire[SPACEWIRE_MAX_CORENR]; 
91
92#define SPW_PARAM(c) (LEON3_Spacewire[c])
93#define SPW_REG(c,r) (SPW_PARAM(c).regs->r)
94#define SPW_REG_CTRL(c) SPW_REG(c,ctrl)
95#define SPW_REG_STATUS(c) SPW_REG(c,status)
96#define SPW_REG_NODEADDR(c) SPW_REG(c,nodeaddr)
97
98#define SPW_CTRL_READ(c)      SPW_READ(&SPW_REG_CTRL(c))
99#define SPW_CTRL_WRITE(c,v)   SPW_WRITE(&SPW_REG_CTRL(c),v)
100#define SPW_STATUS_READ(c)    SPW_READ(&SPW_REG_STATUS(c))
101#define SPW_STATUS_WRITE(c,v) SPW_WRITE(&SPW_REG_STATUS(c),v)
102
103#define SPW_LINKSTATE(c) (((c) >> 21) & 0x7)
104
105#define SPW_NODEADDR_READ(c)    SPW_BYPASSCACHE(&SPW_NODEADDR(c))
106#define SPW_NODEADDR_WRITE(c,v) SPW_NODEADDR(c) = v
107
108#define SPACEWIRE_RXNR(c) ((c&~(SPACEWIRE_BDTABLE_SIZE-1))>>3)
109#define SPACEWIRE_TXNR(c) ((c&~(SPACEWIRE_BDTABLE_SIZE-1))>>4)
110
111#define SPACEWIRE_RXBD_LENGTH 0x1ffffff
112#define SPACEWIRE_RXBD_EN (1<<25)
113#define SPACEWIRE_RXBD_WR (1<<26)
114#define SPACEWIRE_RXBD_IE (1<<27)
115
116#define SPACEWIRE_RXBD_EEP (1<<28)
117#define SPACEWIRE_RXBD_EHC (1<<29)
118#define SPACEWIRE_RXBD_EDC (1<<30)
119#define SPACEWIRE_RXBD_ETR (1<<31)
120
121#define SPACEWIRE_RXBD_ERROR (SPACEWIRE_RXBD_EEP | \
122                              SPACEWIRE_RXBD_EHC | \
123                              SPACEWIRE_RXBD_EDC | \
124                              SPACEWIRE_RXBD_ETR)
125
126#define SPACEWIRE_RXBD_RMAPERROR (SPACEWIRE_RXBD_EHC | SPACEWIRE_RXBD_EDC)
127
128#define SPACEWIRE_RXBD_LENGTH(c) ((c)&0xffffff)
129#define SPACEWIRE_PCKHEAD 2
130
131#define SPACEWIRE_TXBD_LENGTH 0xffffff
132
133#define SPACEWIRE_TXBD_EN (1<<12)
134#define SPACEWIRE_TXBD_WR (1<<13)
135#define SPACEWIRE_TXBD_IE (1<<14)
136
137#define SPACEWIRE_TXBD_LE (1<<15)
138
139#define SPACEWIRE_TXBD_ERROR (SPACEWIRE_TXBD_LE)
140
141#define SPACEWIRE_CTRL_RA   (1<<31)
142#define SPACEWIRE_CTRL_RX   (1<<30)
143#define SPACEWIRE_CTRL_RC   (1<<29)
144
145#define SPACEWIRE_CTRL_RESET         (1<<6)
146#define SPACEWIRE_CTRL_LINKSTART     (1<<1)
147#define SPACEWIRE_CTRL_LINKDISABLE   (1<<0)
148
149#define SPACEWIRE_DMACTRL_TXEN (1<<0)
150#define SPACEWIRE_DMACTRL_RXEN (1<<1)
151#define SPACEWIRE_DMACTRL_TXIE (1<<2)
152#define SPACEWIRE_DMACTRL_RXIE (1<<3)
153
154#define SPACEWIRE_DMACTRL_AI (1<<4)
155#define SPACEWIRE_DMACTRL_PS (1<<5)
156#define SPACEWIRE_DMACTRL_PR (1<<6)
157#define SPACEWIRE_DMACTRL_TA (1<<7)
158#define SPACEWIRE_DMACTRL_RA (1<<8)
159
160#define SPACEWIRE_DMACTRL_RD (1<<11)
161#define SPACEWIRE_DMACTRL_NS (1<<12)
162
163#define SPACEWIRE_PREPAREMASK_TX (SPACEWIRE_DMACTRL_RXEN | SPACEWIRE_DMACTRL_RXIE | SPACEWIRE_DMACTRL_PS | SPACEWIRE_DMACTRL_TA | SPACEWIRE_DMACTRL_RD)
164#define SPACEWIRE_PREPAREMASK_RX (SPACEWIRE_DMACTRL_TXEN | SPACEWIRE_DMACTRL_TXIE | SPACEWIRE_DMACTRL_AI | SPACEWIRE_DMACTRL_PR | SPACEWIRE_DMACTRL_RA)
165
166
167#define SPACEWIRE_IOCTRL_SET_NODEADDR     1
168#define SPACEWIRE_IOCTRL_SET_PROTOCOL     2
169#define SPACEWIRE_IOCTRL_SET_DESTNODEADDR 3
170#define SPACEWIRE_IOCTRL_GET_COREBASEADDR 4
171#define SPACEWIRE_IOCTRL_GET_COREIRQ      5
172#define SPACEWIRE_IOCTRL_SET_PACKETSIZE   6
173#define SPACEWIRE_IOCTRL_GETPACKET        7
174#define SPACEWIRE_IOCTRL_PUTPACKET        8
175
176typedef struct {
177  unsigned int txsize, rxsize;
178} spw_ioctl_packetsize;
179
180typedef struct {
181  char *buf;
182  int buf_size;
183  int ret_size;
184} spw_ioctl_packet;
185
186#endif
Note: See TracBrowser for help on using the repository browser.