summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2011-09-30 07:07:21 -0400
committerFelipe Balbi <balbi@ti.com>2011-10-13 13:38:37 -0400
commit5c481a639068ac34bd1dcd183f37b7a65d0e3841 (patch)
tree3b94182bcaa581375fc26920ef4ba0c118ff5d20
parent0a85577627fc81936d3dbdfb349964024adcb01d (diff)
usb: gadget: r8a66597-udc: add function for external controller
R8A66597 has the pin of WR0 and WR1. So, if one write-pin of CPU connects to the pins, we have to change the setting of FIFOSEL register in the controller. If we don't change the setting, the controller cannot send the data of odd length. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/r8a66597-udc.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h
index 31047f899c37..f9ac2d713c57 100644
--- a/drivers/usb/gadget/r8a66597-udc.h
+++ b/drivers/usb/gadget/r8a66597-udc.h
@@ -172,6 +172,21 @@ static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
172 iowrite16(val, r8a66597->reg + offset); 172 iowrite16(val, r8a66597->reg + offset);
173} 173}
174 174
175static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
176 u16 val, u16 pat, unsigned long offset)
177{
178 u16 tmp;
179 tmp = r8a66597_read(r8a66597, offset);
180 tmp = tmp & (~pat);
181 tmp = tmp | val;
182 r8a66597_write(r8a66597, tmp, offset);
183}
184
185#define r8a66597_bclr(r8a66597, val, offset) \
186 r8a66597_mdfy(r8a66597, 0, val, offset)
187#define r8a66597_bset(r8a66597, val, offset) \
188 r8a66597_mdfy(r8a66597, val, 0, offset)
189
175static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, 190static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
176 struct r8a66597_ep *ep, 191 struct r8a66597_ep *ep,
177 unsigned char *buf, 192 unsigned char *buf,
@@ -205,18 +220,12 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
205 adj = 0x01; /* 16-bit wide */ 220 adj = 0x01; /* 16-bit wide */
206 } 221 }
207 222
223 if (r8a66597->pdata->wr0_shorted_to_wr1)
224 r8a66597_bclr(r8a66597, MBW_16, ep->fifosel);
208 for (i = 0; i < len; i++) 225 for (i = 0; i < len; i++)
209 iowrite8(buf[i], fifoaddr + adj - (i & adj)); 226 iowrite8(buf[i], fifoaddr + adj - (i & adj));
210} 227 if (r8a66597->pdata->wr0_shorted_to_wr1)
211 228 r8a66597_bclr(r8a66597, MBW_16, ep->fifosel);
212static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
213 u16 val, u16 pat, unsigned long offset)
214{
215 u16 tmp;
216 tmp = r8a66597_read(r8a66597, offset);
217 tmp = tmp & (~pat);
218 tmp = tmp | val;
219 r8a66597_write(r8a66597, tmp, offset);
220} 229}
221 230
222static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata) 231static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata)
@@ -241,11 +250,6 @@ static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata)
241 return clock; 250 return clock;
242} 251}
243 252
244#define r8a66597_bclr(r8a66597, val, offset) \
245 r8a66597_mdfy(r8a66597, 0, val, offset)
246#define r8a66597_bset(r8a66597, val, offset) \
247 r8a66597_mdfy(r8a66597, val, 0, offset)
248
249#define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2) 253#define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2)
250 254
251#define enable_irq_ready(r8a66597, pipenum) \ 255#define enable_irq_ready(r8a66597, pipenum) \