00001
00041 #ifndef USBB_REGS_H_INCLUDED
00042 #define USBB_REGS_H_INCLUDED
00043
00044 #include <stdint.h>
00045
00048 #define USBB_DMA_NEXTDESC 0x0000
00049 #define USBB_DMA_ADDR 0x0004
00050 #define USBB_DMA_CONTROL 0x0008
00051 # define USBB_DMA_CH_EN (1 << 0)
00052 # define USBB_DMA_LD_NXT_CH_DESC_EN (1 << 1)
00053 # define USBB_DMA_BUFF_CLOSE_IN_EN (1 << 2)
00054 # define USBB_DMA_DMAEND_EN (1 << 3)
00055 # define USBB_DMA_EOT (1 << 4)
00056 # define USBB_DMA_EOBUFF (1 << 5)
00057 # define USBB_DMA_DESC_LD (1 << 6)
00058 # define USBB_DMA_BURST_LOCK_EN (1 << 7)
00059 # define USBB_DMA_BYTE_LEN(x) ((x) << 16)
00060 # define USBB_DMA_GET_BYTE_LEN(reg) (((reg) >> 16) & 0xffff)
00061
00062 #define USBB_DMA_STATUS 0x000c
00063 # define USBB_DMA_CH_ACTIVE (1 << 1)
00064
00065
00066
00068 #define USBB_UDC_UDCON 0x0000
00069 # define USBB_UDCON_UADD(addr) ((addr) << 0)
00070 # define USBB_UDCON_UADD_MASK (0x7f << 0)
00071 # define USBB_UDCON_ADDEN (1 << 7)
00072 # define USBB_UDCON_DETACH (1 << 8)
00073 # define USBB_UDCON_RMWKUP (1 << 9)
00074 # define USBB_UDCON_SPDCONF_MASK (3 << 10)
00075 # define USBB_UDCON_SPDCONF_NORMAL (0 << 10)
00076 # define USBB_UDCON_SPDCONF_FULL (3 << 10)
00077 # define USBB_UDCON_LS (1 << 12)
00078 # define USBB_UDCON_TSTJ (1 << 13)
00079 # define USBB_UDCON_TSTK (1 << 14)
00080 # define USBB_UDCON_TSTPCKT (1 << 15)
00081 # define USBB_UDCON_OPMODE2 (1 << 16)
00082
00083
00084 #define USBB_UDC_UDINT 0x0004
00085 #define USBB_UDC_UDINTCLR 0x0008
00086 #define USBB_UDC_UDINTSET 0x000c
00087 #define USBB_UDC_UDINTE 0x0010
00088 #define USBB_UDC_UDINTECLR 0x0014
00089 #define USBB_UDC_UDINTESET 0x0018
00090 # define USBB_UDINT_SUSP (1 << 0)
00091 # define USBB_UDINT_MSOF (1 << 1)
00092 # define USBB_UDINT_SOF (1 << 2)
00093 # define USBB_UDINT_EORST (1 << 3)
00094 # define USBB_UDINT_WAKEUP (1 << 4)
00095 # define USBB_UDINT_EORSM (1 << 5)
00096 # define USBB_UDINT_UPRSM (1 << 6)
00097 # define USBB_UDINT_EP(x) (1 << ((x) + 12))
00098 # define USBB_UDINT_DMA(x) (1 << ((x) + 24))
00099
00100 #define USBB_UDC_UERST 0x001c
00101 # define USBB_UERST_EPEN(x) (1 << ((x) + 0))
00102 # define USBB_UERST_EPRST(x) (1 << ((x) + 16))
00103
00104 #define USBB_UDC_UDFNUM 0x0020
00105 # define USBB_UDFNUM_GET_MFNUM(reg) ((reg) & 7)
00106 # define USBB_UDFNUM_GET_FNUM(reg) (((reg) >> 3) & 0x7ff)
00107 # define USBB_UDFNUM_FNCERR (1 << 15)
00108
00109 #define USBB_UDC_UDTST1 0x0024
00110 #define USBB_UDC_UDTST2 0x0028
00111
00112
00114 #define USBB_UDC_UECFG(x) (0x100 + (x) * 4)
00115 # define USBB_UECFG_ALLOC (1 << 1)
00116 # define USBB_UECFG_EPBK(x) ((x) << 2)
00117 # define USBB_UECFG_EPSIZE(x) ((x) << 4)
00118 # define USBB_UECFG_EPDIR_OUT (0 << 8)
00119 # define USBB_UECFG_EPDIR_IN (1 << 8)
00120 # define USBB_UECFG_EPAUTOSW (1 << 9)
00121 # define USBB_UECFG_EPTYPE(x) ((x) << 11)
00122 # define USBB_UECFG_NBTRANS(x) ((x) << 13)
00123
00124 #define USBB_UDC_UESTA(x) (0x130 + (x) * 4)
00125 #define USBB_UDC_UESTACLR(x) (0x160 + (x) * 4)
00126 #define USBB_UDC_UESTASET(x) (0x190 + (x) * 4)
00127 # define USBB_UESTA_GET_DTSEQ(x) (((x) >> 8) & 3)
00128 # define USBB_UESTA_GET_NBUSYBK(x) (((x) >> 12) & 3)
00129 # define USBB_UESTA_GET_CURRBK(x) (((x) >> 14) & 3)
00130 # define USBB_UESTA_RWALL (1 << 16)
00131 # define USBB_UESTA_CTRLDIR_IN (1 << 17)
00132 # define USBB_UESTA_CFGOK (1 << 18)
00133 # define USBB_UESTA_GET_BYCT(x) (((x) >> 20) & 0x7ff)
00134
00135 #define USBB_UDC_UECON(x) (0x1c0 + (x) * 4)
00136 #define USBB_UDC_UECONSET(x) (0x1f0 + (x) * 4)
00137 #define USBB_UDC_UECONCLR(x) (0x220 + (x) * 4)
00138 # define USBB_UECON_MDATAE (1 << 8)
00139 # define USBB_UECON_DATAXE (1 << 9)
00140 # define USBB_UECON_NBUSYBKE (1 << 12)
00141 # define USBB_UECON_KILLBK (1 << 13)
00142 # define USBB_UECON_FIFOCON (1 << 14)
00143 # define USBB_UECON_EPDISHDMA (1 << 16)
00144 # define USBB_UECON_NYETDIS (1 << 17)
00145 # define USBB_UECON_RSTDT (1 << 18)
00146 # define USBB_UECON_STALLRQ (1 << 19)
00147
00149
00150 # define USBB_EP_TXINI (1 << 0)
00151 # define USBB_EP_RXOUTI (1 << 1)
00152 # define USBB_EP_RXSTPI (1 << 2)
00153 # define USBB_EP_UNDERFI (1 << 2)
00154 # define USBB_EP_NAKOUTI (1 << 3)
00155 # define USBB_EP_HBISOINERRI (1 << 3)
00156 # define USBB_EP_NAKINI (1 << 4)
00157 # define USBB_EP_HBISOFLUSHI (1 << 4)
00158 # define USBB_EP_OVERFI (1 << 5)
00159 # define USBB_EP_STALLEDI (1 << 6)
00160 # define USBB_EP_CRCERRI (1 << 6)
00161 # define USBB_EP_SHORTI (1 << 7)
00162 # define USBB_EP_ERRORTRANSI (1 << 10)
00163
00164
00165
00166
00168
00169 #define USBB_HOST_UHCON 0x0400
00170 #define USBB_HOST_UHINT 0x0404
00171 #define USBB_HOST_UHINTCLR 0x0408
00172 #define USBB_HOST_UHINTSET 0x040c
00173 #define USBB_HOST_UHINTE 0x0410
00174 #define USBB_HOST_UHINTECLR 0x0414
00175 #define USBB_HOST_UHINTESET 0x0418
00176 #define USBB_HOST_UPRST 0x041c
00177 #define USBB_HOST_UHFNUM 0x0420
00178 #define USBB_HOST_UHADDR1 0x0424
00179 #define USBB_HOST_UHADDR2 0x0428
00180
00182
00183 #define USBB_HOST_UPCFG(x) (0x500 + 4 * (x))
00184 #define USBB_HOST_UPSTA(x) (0x530 + 4 * (x))
00185 #define USBB_HOST_UPSTACLR(x) (0x560 + 4 * (x))
00186 #define USBB_HOST_UPSTASET(x) (0x590 + 4 * (x))
00187 #define USBB_HOST_UPCON(x) (0x5c0 + 4 * (x))
00188 #define USBB_HOST_UPCONSET(x) (0x5f0 + 4 * (x))
00189 #define USBB_HOST_UPCONCLR(x) (0x620 + 4 * (x))
00190 #define USBB_HOST_UPINRQ(x) (0x650 + 4 * (x))
00191 #define USBB_HOST_UPERR(x) (0x680 + 4 * (x))
00192
00193
00194
00196
00197 #define USBB_CORE_USBCON 0x0800
00198 # define USBB_USBCON_VBUSHWC (1 << 8)
00199 # define USBB_USBCON_SRPSEL (1 << 9)
00200 # define USBB_USBCON_SRPREQ (1 << 10)
00201 # define USBB_USBCON_HNPREQ (1 << 11)
00202 # define USBB_USBCON_OTGPADE (1 << 12)
00203 # define USBB_USBCON_VBUSPO (1 << 13)
00204 # define USBB_USBCON_FRZCLK (1 << 14)
00205 # define USBB_USBCON_USBE (1 << 15)
00206 # define USBB_USBCON_TIMVALUE(x) ((x) << 16)
00207 # define USBB_USBCON_TIMPAGE(x) ((x) << 20)
00208 # define USBB_USBCON_UNLOCK (1 << 22)
00209 # define USBB_USBCON_UIDE (1 << 24)
00210 # define USBB_USBCON_UIMOD_HOST (0 << 25)
00211 # define USBB_USBCON_UIMOD_DEVICE (1 << 25)
00212
00213 #define USBB_CORE_USBSTA 0x0804
00214 #define USBB_CORE_USBSTACLR 0x0808
00215 #define USBB_CORE_USBSTASET 0x080c
00216 # define USBB_USBSTA_VBUSRQ (1 << 9)
00217 # define USBB_USBSTA_ID (1 << 10)
00218 # define USBB_USBSTA_VBUS (1 << 11)
00219 # define USBB_USBSTA_SPEED_MASK (3 << 12)
00220 # define USBB_USBSTA_SPEED_FULL (0 << 12)
00221 # define USBB_USBSTA_SPEED_HIGH (1 << 12)
00222 # define USBB_USBSTA_SPEED_LOW (2 << 12)
00223 # define USBB_USBSTA_CLKUSABLE (1 << 14)
00224
00226
00227 # define USBB_IDTI (1 << 0)
00228 # define USBB_VBUSTI (1 << 1)
00229 # define USBB_SRPI (1 << 2)
00230 # define USBB_VBERRI (1 << 3)
00231 # define USBB_BCERRI (1 << 4)
00232 # define USBB_ROLEEXI (1 << 5)
00233 # define USBB_HNPERRI (1 << 6)
00234 # define USBB_STOI (1 << 7)
00235
00236 #define USBB_CORE_USBFSM 0x082c
00237
00238
00239
00240 struct usbb_dma_desc {
00241 uint32_t next;
00242 uint32_t buf_addr;
00243 uint32_t control;
00244 };
00245
00246
00247 #define usbb_read_reg(reg) \
00248 mmio_read32((void *)(USBB_REGS_BASE + USBB_CORE_##reg))
00249 #define usbb_write_reg(reg, value) \
00250 mmio_write32((void *)(USBB_REGS_BASE + USBB_CORE_##reg), value)
00251
00252 #define usbb_udc_read_reg(reg) \
00253 mmio_read32((void *)(USBB_REGS_BASE + USBB_UDC_##reg))
00254 #define usbb_udc_write_reg(reg, value) \
00255 mmio_write32((void *)(USBB_REGS_BASE + USBB_UDC_##reg), value)
00256
00257 #define usbb_udc_dma_read_reg(ep, reg) \
00258 mmio_read32((void *)(USBB_REGS_BASE + 0x300 + (ep) * 0x10 \
00259 + USBB_DMA_##reg))
00260 #define usbb_udc_dma_write_reg(ep, reg, value) \
00261 mmio_write32((void *)(USBB_REGS_BASE + 0x300 + (ep) * 0x10 \
00262 + USBB_DMA_##reg), value)
00263
00264
00265 #define usbb_ep_fifo(ep) ((void *)(USBB_FIFO_BASE + ep * 0x10000))
00266
00267 #endif