~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to drivers/usb/gadget/r8a66597-udc.h

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Copyright (C) 2007-2009 Renesas Solutions Corp.
5
5
 *
6
 
 * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
 
6
 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
10
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
13
#ifndef __R8A66597_H__
53
43
        ((pipenum >= R8A66597_BASE_PIPENUM_ISOC) && \
54
44
         (pipenum < (R8A66597_BASE_PIPENUM_ISOC + R8A66597_MAX_NUM_ISOC)))
55
45
 
 
46
#define r8a66597_is_sudmac(r8a66597)    (r8a66597->pdata->sudmac)
56
47
struct r8a66597_pipe_info {
57
48
        u16     pipe;
58
49
        u16     epnum;
70
61
struct r8a66597_ep {
71
62
        struct usb_ep           ep;
72
63
        struct r8a66597         *r8a66597;
 
64
        struct r8a66597_dma     *dma;
73
65
 
74
66
        struct list_head        queue;
75
67
        unsigned                busy:1;
85
77
        unsigned char           fifoaddr;
86
78
        unsigned char           fifosel;
87
79
        unsigned char           fifoctr;
88
 
        unsigned char           fifotrn;
89
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
90
struct r8a66597 {
93
91
        spinlock_t              lock;
94
92
        void __iomem            *reg;
 
93
        void __iomem            *sudmac_reg;
95
94
 
96
95
#ifdef CONFIG_HAVE_CLK
97
96
        struct clk *clk;
104
103
        struct r8a66597_ep      ep[R8A66597_MAX_NUM_PIPE];
105
104
        struct r8a66597_ep      *pipenum2ep[R8A66597_MAX_NUM_PIPE];
106
105
        struct r8a66597_ep      *epaddr2ep[16];
 
106
        struct r8a66597_dma     dma;
107
107
 
108
108
        struct timer_list       timer;
109
109
        struct usb_request      *ep0_req;       /* for internal request */
124
124
#define gadget_to_r8a66597(_gadget)     \
125
125
                container_of(_gadget, struct r8a66597, gadget)
126
126
#define r8a66597_to_gadget(r8a66597) (&r8a66597->gadget)
 
127
#define r8a66597_to_dev(r8a66597)       (r8a66597->gadget.dev.parent)
127
128
 
128
129
static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset)
129
130
{
182
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
201
static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
186
 
                                       unsigned long offset,
 
202
                                       struct r8a66597_ep *ep,
187
203
                                       unsigned char *buf,
188
204
                                       int len)
189
205
{
190
 
        void __iomem *fifoaddr = r8a66597->reg + offset;
 
206
        void __iomem *fifoaddr = r8a66597->reg + ep->fifoaddr;
191
207
        int adj = 0;
192
208
        int i;
193
209
 
215
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
236
        for (i = 0; i < len; i++)
219
237
                iowrite8(buf[i], fifoaddr + adj - (i & adj));
220
 
}
221
 
 
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);
 
238
        if (r8a66597->pdata->wr0_shorted_to_wr1)
 
239
                r8a66597_bclr(r8a66597, MBW_16, ep->fifosel);
230
240
}
231
241
 
232
242
static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata)
251
261
        return clock;
252
262
}
253
263
 
254
 
#define r8a66597_bclr(r8a66597, val, offset)    \
255
 
                        r8a66597_mdfy(r8a66597, 0, val, offset)
256
 
#define r8a66597_bset(r8a66597, val, offset)    \
257
 
                        r8a66597_mdfy(r8a66597, val, 0, offset)
 
264
static inline u32 r8a66597_sudmac_read(struct r8a66597 *r8a66597,
 
265
                                       unsigned long offset)
 
266
{
 
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
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
280
#define enable_irq_ready(r8a66597, pipenum)     \
262
281
        enable_pipe_irq(r8a66597, pipenum, BRDYENB)