26 #ifndef __R8A66597_H__
27 #define __R8A66597_H__
32 #define R8A66597_MAX_NUM_PIPE 10
33 #define R8A66597_BUF_BSIZE 8
34 #define R8A66597_MAX_DEVICE 10
35 #define R8A66597_MAX_ROOT_HUB 2
36 #define R8A66597_MAX_SAMPLING 5
37 #define R8A66597_RH_POLL_TIME 10
38 #define R8A66597_MAX_DMA_CHANNEL 2
39 #define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL
40 #define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5))
41 #define check_interrupt(pipenum) ((pipenum >= 6 && pipenum <= 9))
42 #define make_devsel(addr) (addr << 12)
137 static inline struct r8a66597 *hcd_to_r8a66597(
struct usb_hcd *hcd)
139 return (
struct r8a66597 *)(hcd->hcd_priv);
144 return container_of((
void *)r8a66597,
struct usb_hcd, hcd_priv);
147 static inline struct r8a66597_td *r8a66597_get_td(
struct r8a66597 *r8a66597,
157 static inline struct urb *r8a66597_get_urb(
struct r8a66597 *r8a66597,
162 td = r8a66597_get_td(r8a66597, pipenum);
166 static inline u16 r8a66597_read(
struct r8a66597 *r8a66597,
unsigned long offset)
171 static inline void r8a66597_read_fifo(
struct r8a66597 *r8a66597,
178 if (r8a66597->
pdata->on_chip) {
182 if (len & 0x00000003) {
184 memcpy((
unsigned char *)buf + count * 4, &tmp,
193 static inline void r8a66597_write(
struct r8a66597 *r8a66597,
u16 val,
194 unsigned long offset)
199 static inline void r8a66597_mdfy(
struct r8a66597 *r8a66597,
203 tmp = r8a66597_read(r8a66597, offset);
206 r8a66597_write(r8a66597, tmp, offset);
209 #define r8a66597_bclr(r8a66597, val, offset) \
210 r8a66597_mdfy(r8a66597, 0, val, offset)
211 #define r8a66597_bset(r8a66597, val, offset) \
212 r8a66597_mdfy(r8a66597, val, 0, offset)
214 static inline void r8a66597_write_fifo(
struct r8a66597 *r8a66597,
223 if (r8a66597->
pdata->on_chip) {
227 if (len & 0x00000003) {
228 pb = (
unsigned char *)buf + count * 4;
229 for (i = 0; i < (len & 0x00000003); i++) {
237 int odd = len & 0x0001;
243 if (r8a66597->
pdata->wr0_shorted_to_wr1)
245 iowrite8((
unsigned char)*buf, fifoaddr);
246 if (r8a66597->
pdata->wr0_shorted_to_wr1)
252 static inline unsigned long get_syscfg_reg(
int port)
257 static inline unsigned long get_syssts_reg(
int port)
262 static inline unsigned long get_dvstctr_reg(
int port)
267 static inline unsigned long get_dmacfg_reg(
int port)
272 static inline unsigned long get_intenb_reg(
int port)
277 static inline unsigned long get_intsts_reg(
int port)
282 static inline u16 get_rh_usb_speed(
struct r8a66597 *r8a66597,
int port)
284 unsigned long dvstctr_reg = get_dvstctr_reg(port);
286 return r8a66597_read(r8a66597, dvstctr_reg) &
RHST;
289 static inline void r8a66597_port_power(
struct r8a66597 *r8a66597,
int port,
292 unsigned long dvstctr_reg = get_dvstctr_reg(port);
294 if (r8a66597->
pdata->port_power) {
295 r8a66597->
pdata->port_power(port, power);
308 switch (pdata->
xtal) {
326 #define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2)
327 #define get_pipetre_addr(pipenum) (PIPE1TRE + (pipenum - 1) * 4)
328 #define get_pipetrn_addr(pipenum) (PIPE1TRN + (pipenum - 1) * 4)
329 #define get_devadd_addr(address) (DEVADD0 + address * 2)
331 #define enable_irq_ready(r8a66597, pipenum) \
332 enable_pipe_irq(r8a66597, pipenum, BRDYENB)
333 #define disable_irq_ready(r8a66597, pipenum) \
334 disable_pipe_irq(r8a66597, pipenum, BRDYENB)
335 #define enable_irq_empty(r8a66597, pipenum) \
336 enable_pipe_irq(r8a66597, pipenum, BEMPENB)
337 #define disable_irq_empty(r8a66597, pipenum) \
338 disable_pipe_irq(r8a66597, pipenum, BEMPENB)
339 #define enable_irq_nrdy(r8a66597, pipenum) \
340 enable_pipe_irq(r8a66597, pipenum, NRDYENB)
341 #define disable_irq_nrdy(r8a66597, pipenum) \
342 disable_pipe_irq(r8a66597, pipenum, NRDYENB)