diff options
Diffstat (limited to 'drivers/usb/gadget/r8a66597-udc.h')
-rw-r--r-- | drivers/usb/gadget/r8a66597-udc.h | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h index 503f766c23a7..8e3de61cd4b8 100644 --- a/drivers/usb/gadget/r8a66597-udc.h +++ b/drivers/usb/gadget/r8a66597-udc.h | |||
@@ -8,16 +8,6 @@ | |||
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; version 2 of the License. | 10 | * the Free Software Foundation; version 2 of the License. |
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | * | ||
21 | */ | 11 | */ |
22 | 12 | ||
23 | #ifndef __R8A66597_H__ | 13 | #ifndef __R8A66597_H__ |
@@ -53,6 +43,7 @@ | |||
53 | ((pipenum >= R8A66597_BASE_PIPENUM_ISOC) && \ | 43 | ((pipenum >= R8A66597_BASE_PIPENUM_ISOC) && \ |
54 | (pipenum < (R8A66597_BASE_PIPENUM_ISOC + R8A66597_MAX_NUM_ISOC))) | 44 | (pipenum < (R8A66597_BASE_PIPENUM_ISOC + R8A66597_MAX_NUM_ISOC))) |
55 | 45 | ||
46 | #define r8a66597_is_sudmac(r8a66597) (r8a66597->pdata->sudmac) | ||
56 | struct r8a66597_pipe_info { | 47 | struct r8a66597_pipe_info { |
57 | u16 pipe; | 48 | u16 pipe; |
58 | u16 epnum; | 49 | u16 epnum; |
@@ -70,6 +61,7 @@ struct r8a66597_request { | |||
70 | struct r8a66597_ep { | 61 | struct r8a66597_ep { |
71 | struct usb_ep ep; | 62 | struct usb_ep ep; |
72 | struct r8a66597 *r8a66597; | 63 | struct r8a66597 *r8a66597; |
64 | struct r8a66597_dma *dma; | ||
73 | 65 | ||
74 | struct list_head queue; | 66 | struct list_head queue; |
75 | unsigned busy:1; | 67 | unsigned busy:1; |
@@ -85,13 +77,20 @@ struct r8a66597_ep { | |||
85 | unsigned char fifoaddr; | 77 | unsigned char fifoaddr; |
86 | unsigned char fifosel; | 78 | unsigned char fifosel; |
87 | unsigned char fifoctr; | 79 | unsigned char fifoctr; |
88 | unsigned char fifotrn; | ||
89 | unsigned char pipectr; | 80 | unsigned char pipectr; |
81 | unsigned char pipetre; | ||
82 | unsigned char pipetrn; | ||
83 | }; | ||
84 | |||
85 | struct r8a66597_dma { | ||
86 | unsigned used:1; | ||
87 | unsigned dir:1; /* 1 = IN(write), 0 = OUT(read) */ | ||
90 | }; | 88 | }; |
91 | 89 | ||
92 | struct r8a66597 { | 90 | struct r8a66597 { |
93 | spinlock_t lock; | 91 | spinlock_t lock; |
94 | void __iomem *reg; | 92 | void __iomem *reg; |
93 | void __iomem *sudmac_reg; | ||
95 | 94 | ||
96 | #ifdef CONFIG_HAVE_CLK | 95 | #ifdef CONFIG_HAVE_CLK |
97 | struct clk *clk; | 96 | struct clk *clk; |
@@ -104,6 +103,7 @@ struct r8a66597 { | |||
104 | struct r8a66597_ep ep[R8A66597_MAX_NUM_PIPE]; | 103 | struct r8a66597_ep ep[R8A66597_MAX_NUM_PIPE]; |
105 | struct r8a66597_ep *pipenum2ep[R8A66597_MAX_NUM_PIPE]; | 104 | struct r8a66597_ep *pipenum2ep[R8A66597_MAX_NUM_PIPE]; |
106 | struct r8a66597_ep *epaddr2ep[16]; | 105 | struct r8a66597_ep *epaddr2ep[16]; |
106 | struct r8a66597_dma dma; | ||
107 | 107 | ||
108 | struct timer_list timer; | 108 | struct timer_list timer; |
109 | struct usb_request *ep0_req; /* for internal request */ | 109 | struct usb_request *ep0_req; /* for internal request */ |
@@ -124,6 +124,7 @@ struct r8a66597 { | |||
124 | #define gadget_to_r8a66597(_gadget) \ | 124 | #define gadget_to_r8a66597(_gadget) \ |
125 | container_of(_gadget, struct r8a66597, gadget) | 125 | container_of(_gadget, struct r8a66597, gadget) |
126 | #define r8a66597_to_gadget(r8a66597) (&r8a66597->gadget) | 126 | #define r8a66597_to_gadget(r8a66597) (&r8a66597->gadget) |
127 | #define r8a66597_to_dev(r8a66597) (r8a66597->gadget.dev.parent) | ||
127 | 128 | ||
128 | static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset) | 129 | static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset) |
129 | { | 130 | { |
@@ -182,12 +183,27 @@ static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, | |||
182 | iowrite16(val, r8a66597->reg + offset); | 183 | iowrite16(val, r8a66597->reg + offset); |
183 | } | 184 | } |
184 | 185 | ||
186 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | ||
187 | u16 val, u16 pat, unsigned long offset) | ||
188 | { | ||
189 | u16 tmp; | ||
190 | tmp = r8a66597_read(r8a66597, offset); | ||
191 | tmp = tmp & (~pat); | ||
192 | tmp = tmp | val; | ||
193 | r8a66597_write(r8a66597, tmp, offset); | ||
194 | } | ||
195 | |||
196 | #define r8a66597_bclr(r8a66597, val, offset) \ | ||
197 | r8a66597_mdfy(r8a66597, 0, val, offset) | ||
198 | #define r8a66597_bset(r8a66597, val, offset) \ | ||
199 | r8a66597_mdfy(r8a66597, val, 0, offset) | ||
200 | |||
185 | static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | 201 | static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, |
186 | unsigned long offset, | 202 | struct r8a66597_ep *ep, |
187 | unsigned char *buf, | 203 | unsigned char *buf, |
188 | int len) | 204 | int len) |
189 | { | 205 | { |
190 | void __iomem *fifoaddr = r8a66597->reg + offset; | 206 | void __iomem *fifoaddr = r8a66597->reg + ep->fifoaddr; |
191 | int adj = 0; | 207 | int adj = 0; |
192 | int i; | 208 | int i; |
193 | 209 | ||
@@ -215,18 +231,12 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | |||
215 | adj = 0x01; /* 16-bit wide */ | 231 | adj = 0x01; /* 16-bit wide */ |
216 | } | 232 | } |
217 | 233 | ||
234 | if (r8a66597->pdata->wr0_shorted_to_wr1) | ||
235 | r8a66597_bclr(r8a66597, MBW_16, ep->fifosel); | ||
218 | for (i = 0; i < len; i++) | 236 | for (i = 0; i < len; i++) |
219 | iowrite8(buf[i], fifoaddr + adj - (i & adj)); | 237 | iowrite8(buf[i], fifoaddr + adj - (i & adj)); |
220 | } | 238 | if (r8a66597->pdata->wr0_shorted_to_wr1) |
221 | 239 | r8a66597_bclr(r8a66597, MBW_16, ep->fifosel); | |
222 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | ||
223 | u16 val, u16 pat, unsigned long offset) | ||
224 | { | ||
225 | u16 tmp; | ||
226 | tmp = r8a66597_read(r8a66597, offset); | ||
227 | tmp = tmp & (~pat); | ||
228 | tmp = tmp | val; | ||
229 | r8a66597_write(r8a66597, tmp, offset); | ||
230 | } | 240 | } |
231 | 241 | ||
232 | static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata) | 242 | static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata) |
@@ -251,12 +261,21 @@ static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata) | |||
251 | return clock; | 261 | return clock; |
252 | } | 262 | } |
253 | 263 | ||
254 | #define r8a66597_bclr(r8a66597, val, offset) \ | 264 | static inline u32 r8a66597_sudmac_read(struct r8a66597 *r8a66597, |
255 | r8a66597_mdfy(r8a66597, 0, val, offset) | 265 | unsigned long offset) |
256 | #define r8a66597_bset(r8a66597, val, offset) \ | 266 | { |
257 | r8a66597_mdfy(r8a66597, val, 0, offset) | 267 | return ioread32(r8a66597->sudmac_reg + offset); |
268 | } | ||
269 | |||
270 | static inline void r8a66597_sudmac_write(struct r8a66597 *r8a66597, u32 val, | ||
271 | unsigned long offset) | ||
272 | { | ||
273 | iowrite32(val, r8a66597->sudmac_reg + offset); | ||
274 | } | ||
258 | 275 | ||
259 | #define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2) | 276 | #define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2) |
277 | #define get_pipetre_addr(pipenum) (PIPE1TRE + (pipenum - 1) * 4) | ||
278 | #define get_pipetrn_addr(pipenum) (PIPE1TRN + (pipenum - 1) * 4) | ||
260 | 279 | ||
261 | #define enable_irq_ready(r8a66597, pipenum) \ | 280 | #define enable_irq_ready(r8a66597, pipenum) \ |
262 | enable_pipe_irq(r8a66597, pipenum, BRDYENB) | 281 | enable_pipe_irq(r8a66597, pipenum, BRDYENB) |