]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/arch/arm/mach-lpc21xx/defines/lpcUSB.h
Included ARM LPC21xx related code from uLan project. The snapshot date is 2008-07-05
[lincan.git] / embedded / arch / arm / mach-lpc21xx / defines / lpcUSB.h
1 /******************************************************************************
2  *
3  * $RCSfile: lpcUSB.h,v $
4  * $Revision: 1.3 $
5  *
6  * Header file for Philips LPC214x USB enabled ARM Processors 
7  * Copyright 2006 Pavel Pisa <pisa@cmp.felk.cvut.cz>
8  *
9  * No guarantees, warrantees, or promises, implied or otherwise.
10  * May be used for hobby or commercial purposes provided copyright
11  * notice remains intact or GPL license is applied.
12  *
13  *****************************************************************************/
14
15 /* USBIntSt - USB Interrupt Status (R/W) */
16 #define   USB_INT_REQ_LP        (1<<0) /*Low priority interrupt line status (RO) */
17 #define   USB_INT_REQ_HP        (1<<1) /*High priority interrupt line status. (RO) */
18 #define   USB_INT_REQ_DMA       (1<<2) /*DMA interrupt line status. This bit is read only. (LPC2146/8 only) 0*/
19 #define   USB_need_clock        (1<<8) /*USB need clock indicator*/
20 #define   USB_EN_USB_INTS       (1<<31) /*Enable all USB interrupts*/
21
22 /* Device interrupt registers */
23 #define USBDevIntSt_o   0x0000  /* USB Device Interrupt Status (RO) */
24 #define USBDevIntEn_o   0x0004  /* USB Device Interrupt Enable (R/W) */
25 #define USBDevIntClr_o  0x0008  /* USB Device Interrupt Clear (WO) */
26 #define USBDevIntSet_o  0x000C  /* USB Device Interrupt Set (WO) */
27 #define   USBDevInt_FRAME       (1<<0) /*Frame interrupt @1kHz for ISO transfers*/
28 #define   USBDevInt_EP_FAST     (1<<1) /*Fast interrupt transfer for the endpoint*/
29 #define   USBDevInt_EP_SLOW     (1<<2) /*Slow interrupt transfer for the endpoint*/
30 #define   USBDevInt_DEV_STAT    (1<<3) /*USB Bus reset, USB suspend change or Connect occured*/
31 #define   USBDevInt_CCEMTY      (1<<4) /*Command code register is empty/ready for CMD*/
32 #define   USBDevInt_CDFULL      (1<<5) /*Command data register is full/data available*/
33 #define   USBDevInt_RxENDPKT    (1<<6) /*Current packet in the FIFO is transferred to the CPU*/
34 #define   USBDevInt_TxENDPKT    (1<<7) /*TxPacket bytes written to FIFO*/
35 #define   USBDevInt_EP_RLZED    (1<<8) /*Endpoints realized after Maxpacket size update*/
36 #define   USBDevInt_ERR_INT     (1<<9) /*Error Interrupt - Use Read Error Status Command 0xFB*/
37
38 #define USBDevIntPri_o  0x002C  /* USB Device Interrupt Priority (WO) */
39 #define   USBDevIntPri_FRAME    (1<<0) /*0/1 FRAME int routed to the low/high priority interrupt line*/
40 #define   USBDevIntPri_EP_FAST  (1<<1) /*0/1 EP_FAST int routed to the low/high priority line*/
41
42 /* Endpoint interrupt registers - bits corresponds to  EP0 to EP31 */
43 #define USBEpIntSt_o    0x0030  /* USB Endpoint Interrupt Status (RO) */
44 #define USBEpIntEn_o    0x0034  /* USB Endpoint Interrupt Enable (R/W) */
45 #define USBEpIntClr_o   0x0038  /* USB Endpoint Interrupt Clear (WO) */
46 #define USBEpIntSet_o   0x003C  /* USB Endpoint Interrupt Set (WO) */
47 #define USBEpIntPri_o   0x0040  /* USB Endpoint Priority (WO) */
48 /* Endpoint realization registers */
49 #define USBReEp_o       0x0044  /* USB Realize Endpoint (R/W) */
50 #define USBEpInd_o      0x0048  /* USB Endpoint Index (WO) */
51 #define   USBEpInd_Ind          0x001F  /* Index for subsequent USBMaxPSize (WO) */
52 #define USBMaxPSize_o   0x004C  /* USB MaxPacketSize (R/W) */
53 #define   USBMaxPSize_Size      0x03FF  /* The maximum packet size value */
54 /* USB transfer registers */
55 #define USBRxData_o     0x0018  /* USB Receive Data (RO) */
56 #define USBRxPLen_o     0x0020  /* USB Receive Packet Length (RO) */
57 #define   USBRxPLen_PKT_LNGTH   (0x03FF) /*Remaining amount of bytes to be read from RAM*/
58 #define   USBRxPLen_DV          (1<<10) /*Data valid. 0 only for error ISO packet*/
59 #define   USBRxPLen_PKT_RDY     (1<<11) /*Packet length valid and packet is ready for reading*/
60 #define USBTxData_o     0x001C  /* USB Transmit Data (WO) */
61 #define USBTxPLen_o     0x0024  /* USB Transmit Packet Length (WO) */
62 #define   USBTxPLen_PKT_LNGTH   (0x03FF) /*Remaining amount of bytes to be written to the EP_RAM*/
63 #define USBCtrl_o       0x0028  /* USB Control (R/W) */
64 #define   USBCtrl_RD_EN         (1<<0) /*Read mode control*/
65 #define   USBCtrl_WR_EN         (1<<1) /*Write mode control*/
66 #define   USBCtrl_LOG_ENDPOINT  0x003C /*Logical Endpoint number*/
67 /* Command registers */
68 #define USBCmdCode_o    0x0010  /* USB Command Code (WO) */
69 #define   USBCmdCode_CMD_PHASE  0x0000FF00 /*The command phase*/
70 #define   USBCmdCode_CMD_CODE   0x00FF0000 /*The code for the command*/
71 #define USBCmdData_o    0x0014  /* USB Command Data (RO) */
72 /* DMA registers (LPC2146/8 only) */
73 #define USBDMARSt_o     0x0050  /* USB DMA Request Status (RO) */
74 #define USBDMARClr_o    0x0054  /* USB DMA Request Clear (WO) */
75 #define USBDMARSet_o    0x0058  /* USB DMA Request Set (WO) */
76 #define USBUDCAH_o      0x0080  /* USB UDCA Head (R/W) has to be aligned to 128 bytes */
77 #define USBEpDMASt_o    0x0084  /* USB Endpoint DMA Status (RO) */
78 #define USBEpDMAEn_o    0x0088  /* USB Endpoint DMA Enable (WO) */
79 #define USBEpDMADis_o   0x008C  /* USB Endpoint DMA Disable (WO) */
80 #define USBDMAIntSt_o   0x0090  /* USB DMA Interrupt Status (RO) */
81 #define USBDMAIntEn_o   0x0094  /* USB DMA Interrupt Enable (R/W) */
82 #define   USBDMAInt_EoT         (1<<0) /*End of Transfer Interrupt bit, 1 if USBEoTIntSt != 0*/
83 #define   USBDMAInt_New_DD_Rq   (1<<1) /*  New DD Request Interrupt bit, 1 if USBNDDRIntSt != 0*/
84 #define   USBDMAInt_SysError    (1<<2) /*System Error Interrupt bit, 1 if USBSysErrIntSt != 0*/
85 #define USBEoTIntSt_o   0x00A0  /* USB End of Transfer Interrupt Status (RO) */
86 #define USBEoTIntClr_o  0x00A4  /* USB End of Transfer Interrupt Clear (WO) */
87 #define USBEoTIntSet_o  0x00A8  /* USB End of Transfer Interrupt Set (WO) */
88 #define USBNDDRIntSt_o  0x00AC  /* USB New DD Request Interrupt Status (RO) */
89 #define USBNDDRIntClr_o 0x00B0  /* USB New DD Request Interrupt Clear (WO) */
90 #define USBNDDRIntSet_o 0x00B4  /* USB New DD Request Interrupt Set (WO) */
91 #define USBSysErrIntSt_o        0x00B8  /* USB System Error Interrupt Status (RO) */
92 #define USBSysErrIntClr_o       0x00BC  /* USB System Error Interrupt Clear (WO) */
93 #define USBSysErrIntSet_o       0x00C0  /* USB System Error Interrupt Set (WO) */
94 #define USB_MODULE_ID_o         0x00FC  /* USB Module ID */
95
96 /* Command Codes */
97 #define USB_CMD_SET_ADDR        0x00D00500
98 #define USB_CMD_CFG_DEV         0x00D80500
99 #define USB_CMD_SET_MODE        0x00F30500
100 #define USB_CMD_RD_FRAME        0x00F50500
101 #define USB_DAT_RD_FRAME        0x00F50200
102 #define USB_CMD_RD_TEST         0x00FD0500
103 #define USB_DAT_RD_TEST         0x00FD0200
104 #define USB_CMD_SET_DEV_STAT    0x00FE0500
105 #define USB_CMD_GET_DEV_STAT    0x00FE0500
106 #define USB_DAT_GET_DEV_STAT    0x00FE0200
107 #define USB_CMD_GET_ERR_CODE    0x00FF0500
108 #define USB_DAT_GET_ERR_CODE    0x00FF0200
109 #define USB_CMD_RD_ERR_STAT     0x00FB0500
110 #define USB_DAT_RD_ERR_STAT     0x00FB0200
111 #define USB_DAT_WR_BYTE(x)     (0x00000100 | ((x) << 16))
112 #define USB_CMD_SEL_EP(x)      (0x00000500 | ((x) << 16))
113 #define USB_DAT_SEL_EP(x)      (0x00000200 | ((x) << 16))
114 #define USB_CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
115 #define USB_DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
116 #define USB_CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
117 #define USB_CMD_CLR_BUF         0x00F20500
118 #define USB_DAT_CLR_BUF         0x00F20200
119 #define USB_CMD_VALID_BUF       0x00FA0500
120
121 /* Device Address Register Definitions */
122 #define USBC_DEV_ADDR_MASK       0x7F
123 #define USBC_DEV_EN              0x80
124
125 /* Device Configure Register Definitions */
126 #define USBC_CONF_DEVICE         0x01
127
128 /* Device Mode Register Definitions */
129 #define USBC_AP_CLK              0x01
130 #define USBC_INAK_CI             0x02
131 #define USBC_INAK_CO             0x04
132 #define USBC_INAK_II             0x08
133 #define USBC_INAK_IO             0x10
134 #define USBC_INAK_BI             0x20
135 #define USBC_INAK_BO             0x40
136
137 /* Device Status Register Definitions */
138 #define USBC_DEV_CON             0x01
139 #define USBC_DEV_CON_CH          0x02
140 #define USBC_DEV_SUS             0x04
141 #define USBC_DEV_SUS_CH          0x08
142 #define USBC_DEV_RST             0x10
143
144 /* Error Code Register Definitions */
145 #define USBC_ERR_EC_MASK         0x0F
146 #define USBC_ERR_EA              0x10
147
148 /* Error Status Register Definitions */
149 #define USBC_ERR_PID             0x01
150 #define USBC_ERR_UEPKT           0x02
151 #define USBC_ERR_DCRC            0x04
152 #define USBC_ERR_TIMOUT          0x08
153 #define USBC_ERR_EOP             0x10
154 #define USBC_ERR_B_OVRN          0x20
155 #define USBC_ERR_BTSTF           0x40
156 #define USBC_ERR_TGL             0x80
157
158 /* Endpoint Select Register Definitions */
159 #define USBC_EP_SEL_F            0x01
160 #define USBC_EP_SEL_ST           0x02
161 #define USBC_EP_SEL_STP          0x04
162 #define USBC_EP_SEL_PO           0x08
163 #define USBC_EP_SEL_EPN          0x10
164 #define USBC_EP_SEL_B_1_FULL     0x20
165 #define USBC_EP_SEL_B_2_FULL     0x40
166
167 /* Endpoint Status Register Definitions */
168 #define USBC_EP_STAT_ST          0x01
169 #define USBC_EP_STAT_DA          0x20
170 #define USBC_EP_STAT_RF_MO       0x40
171 #define USBC_EP_STAT_CND_ST      0x80
172
173 /* Clear Buffer Register Definitions */
174 #define USBC_CLR_BUF_PO          0x01
175
176 typedef struct
177 {
178 /* Device interrupt registers */
179   REG32 DevIntSt;       /* USB Device Interrupt Status (RO) 0000 */
180   REG32 DevIntEn;       /* USB Device Interrupt Enable (R/W) 0004 */
181   REG32 DevIntClr;      /* USB Device Interrupt Clear (WO) 0008 */
182   REG32 DevIntSet;      /* USB Device Interrupt Set (WO) 000C */
183 /* Command registers */
184   REG32 CmdCode;        /* USB Command Code (WO) 0010 */
185   REG32 CmdData;        /* USB Command Data (RO) 0014 */
186 /* USB transfer registers */
187   REG32 RxData;         /* USB Receive Data (RO) 0018 */
188   REG32 TxData;         /* USB Transmit Data (WO) 001C */
189   REG32 RxPLen;         /* USB Receive Packet Length (RO) 0020 */
190   REG32 TxPLen;         /* USB Transmit Packet Length (WO) 0024 */
191   REG32 Ctrl;           /* USB Control (R/W) 0028 */
192 /* Device interrupt priority register */
193   REG_8  USBDevIntPri;  /* USB Device Interrupt Priority (WO) 002C */
194   REG_8  _pad0[3];
195 /* Endpoint interrupt registers */
196   REG32 EpIntSt;        /* USB Endpoint Interrupt Status (RO) 0030 */
197   REG32 EpIntEn;        /* USB Endpoint Interrupt Enable (R/W) 0034 */
198   REG32 EpIntClr;       /* USB Endpoint Interrupt Clear (WO) 0038 */
199   REG32 EpIntSet;       /* USB Endpoint Interrupt Set (WO) 003C */
200   REG32 EpIntPri;       /* USB Endpoint Priority (WO) 0040 */
201 /* Endpoint realization registers */
202   REG32 ReEp;           /* USB Realize Endpoint (R/W) 0044 */
203   REG32 EpInd;          /* USB Endpoint Index (WO) 0048 */
204   REG32 MaxPSize;       /* USB MaxPacketSize (R/W) 004C */
205 /* DMA registers (LPC2146/8 only) */
206   REG32 DMARSt;         /* USB DMA Request Status (RO) 0050 */
207   REG32 DMARClr;        /* USB DMA Request Clear (WO) 0054 */
208   REG32 DMARSet;        /* USB DMA Request Set (WO) 0058 */
209   REG32 _pad1[9];
210   REG32 UDCAH;          /* USB UDCA Head (R/W) 0080 */
211   REG32 EpDMASt;        /* USB Endpoint DMA Status (RO) 0084 */
212   REG32 EpDMAEn;        /* USB Endpoint DMA Enable (WO) 0088 */
213   REG32 EpDMADis;       /* USB Endpoint DMA Disable (WO) 008C */
214   REG32 DMAIntSt;       /* USB DMA Interrupt Status (RO) 0090 */
215   REG32 DMAIntEn;       /* USB DMA Interrupt Enable (R/W) 0094 */
216   REG32 _pad2[2];
217   REG32 EoTIntSt;       /* USB End of Transfer Interrupt Status (RO) 00A0 */
218   REG32 EoTIntClr;      /* USB End of Transfer Interrupt Clear (WO) 00A4 */
219   REG32 EoTIntSet;      /* USB End of Transfer Interrupt Set (WO) 00A8 */
220   REG32 NDDRIntSt;      /* USB New DD Request Interrupt Status (RO) 00AC */
221   REG32 NDDRIntClr;     /* USB New DD Request Interrupt Clear (WO) 00B0 */
222   REG32 NDDRIntSet;     /* USB New DD Request Interrupt Set (WO) 00B4 */
223   REG32 SysErrIntSt;    /* USB System Error Interrupt Status (RO) 00B8 */
224   REG32 SysErrIntClr;   /* USB System Error Interrupt Clear (WO) 00BC */
225   REG32 SysErrIntSet;   /* USB System Error Interrupt Set (WO) 00C0 */
226   REG32 _pad3[0xE];
227   REG32 MODULE_ID;      /* Module ID (RO) 00FC */
228 } usbRegs_t;
229