1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
|
From b014a8a0b66b1f0f55b3384f586f43e67e6dcc5d Mon Sep 17 00:00:00 2001
From: Bruce Schmid <duck@freescale.com>
Date: Tue, 4 Dec 2007 16:03:17 -0700
Subject: [PATCH] USB: cleanup
LTIBName: m5445x-usb-cleanup-2
Signed-off-by: Duck <duck@freescale.com>
---
drivers/usb/gadget/mcf5445x_udc.c | 14 ---
drivers/usb/host/ehci-arc.c | 19 +---
drivers/usb/otg/fsl_otg.c | 225 ++-----------------------------------
drivers/usb/otg/otg_fsm.h | 2 +-
include/linux/usb/fsl_usb2.h | 5 +-
5 files changed, 15 insertions(+), 250 deletions(-)
--- a/drivers/usb/gadget/mcf5445x_udc.c
+++ b/drivers/usb/gadget/mcf5445x_udc.c
@@ -321,11 +321,6 @@ static void pullup_enable(struct fsl_udc
temp = fsl_readl(&dr_regs->usbcmd);
temp |= USB_CMD_RUN_STOP;
fsl_writel(temp, &dr_regs->usbcmd);
-
-#ifdef NEVER /* DDD FIXME: we want this? */
- if (!udc->transceiver)
- *((u16 *)(MCF_FBCS1_CSAR)) &= ~0x1; /* Enable pullup register */
-#endif
}
static void pullup_disable(struct fsl_udc *udc)
@@ -345,12 +340,6 @@ static void pullup_disable(struct fsl_ud
tmp = fsl_readl(&dr_regs->usbcmd);
tmp &= ~USB_CMD_RUN_STOP;
fsl_writel(tmp, &dr_regs->usbcmd);
-
-#ifdef NEVER /* DDD FIXME: we want this? */
- if (!udc->transceiver)
- *((u16 *)(MCF_FBCS1_CSAR)) |= 0x1; /* Disable pullup register */
-#endif
-
}
static void dr_controller_run(struct fsl_udc *udc)
@@ -2598,9 +2587,6 @@ static int __init fsl_udc_probe(struct p
ret = -ENOMEM;
goto err4;
}
-#if 0 // DDD why this? hoarks OTG host
- pullup_disable(udc);
-#endif
create_proc_file();
return 0;
--- a/drivers/usb/host/ehci-arc.c
+++ b/drivers/usb/host/ehci-arc.c
@@ -378,25 +378,14 @@ static int ehci_fsl_drv_resume(struct pl
memcpy(ehci->regs, (void *)&usb_ehci_regs, sizeof(struct ehci_regs));
-#if 0 // DDD test
- ehci_writel(ehci, usb_ehci_portsc, &ehci->regs->port_status[0]);
- printk("set portsc %08x %08x\n", usb_ehci_portsc,
- ehci_readl(ehci, &ehci->regs->port_status[0]));
- printk("set usbmode %08x\n",
- ehci_readl(ehci, &ehci->regs + FSL_SOC_USB_USBMODE));
-
tmp = USBMODE_CM_HOST | (pdata->es ? USBMODE_ES : 0);
ehci_writel(ehci, tmp, hcd->regs + FSL_SOC_USB_USBMODE);
-#else
- tmp = USBMODE_CM_HOST | (pdata->es ? USBMODE_ES : 0);
- ehci_writel(ehci, tmp, hcd->regs + FSL_SOC_USB_USBMODE);
- printk("tmp %08x set usbmode %08x\n", tmp,
- ehci_readl(ehci, hcd->regs + FSL_SOC_USB_USBMODE));
+ pr_debug("tmp %08x set usbmode %08x\n", tmp,
+ ehci_readl(ehci, hcd->regs + FSL_SOC_USB_USBMODE));
ehci_writel(ehci, usb_ehci_portsc, &ehci->regs->port_status[0]);
- printk("set portsc %08x %08x\n", usb_ehci_portsc,
- ehci_readl(ehci, &ehci->regs->port_status[0]));
-#endif
+ pr_debug("set portsc %08x %08x\n", usb_ehci_portsc,
+ ehci_readl(ehci, &ehci->regs->port_status[0]));
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
hcd->state = HC_STATE_RUNNING;
--- a/drivers/usb/otg/fsl_otg.c
+++ b/drivers/usb/otg/fsl_otg.c
@@ -98,6 +98,7 @@ static struct fsl_otg_config fsl_otg_ini
.otg_port = 1,
};
+#if 0
static void dump_state(const char *string, struct otg_fsm *fsm)
{
printk(KERN_DEBUG "%s\n\tOTG state: %s\n", string,
@@ -135,6 +136,7 @@ static void dump_state(const char *strin
printk(KERN_DEBUG "\tb_sess_vld: %d\n", fsm->b_sess_vld);
printk(KERN_DEBUG "\tid: %d\n", fsm->id);
}
+#endif
/* Routines to access transceiver ULPI registers */
@@ -537,6 +539,7 @@ int fsl_otg_start_gadget(struct otg_fsm
return 0;
}
+#if 0
static void fsl_otg_enable(struct otg_transceiver *otg_p)
{
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg);
@@ -549,7 +552,7 @@ static void fsl_otg_enable(struct otg_tr
otg_sc |= OTGSC_INTERRUPT_ENABLE_BITS_MASK;
otg_sc &= ~OTGSC_IE_1ms_TIMER;
otg_sc &= ~OTGSC_CTRL_VBUS_DISCHARGE;
- otg_sc |= OTGSC_IE_USB_ID; /* DDD added this */
+ otg_sc |= OTGSC_IE_USB_ID;
fsl_writel(otg_sc, &usb_dr_regs->otgsc);
fsm->id = (otg_sc & OTGSC_STS_USB_ID) ? 1 : 0;
@@ -570,6 +573,7 @@ static void fsl_otg_enable(struct otg_tr
fsm->a_sess_vld = (otg_sc & OTGSC_STS_A_SESSION_VALID) ? 1 : 0;
fsm->b_sess_end = (otg_sc & OTGSC_STS_B_SESSION_END) ? 1 : 0;
}
+#endif
/*
* Called by initialization code of host driver. Register host controller
@@ -577,34 +581,6 @@ static void fsl_otg_enable(struct otg_tr
*/
static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
{
-#if 0 // DDD beta-final
- struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg);
- struct device *dev = host->controller;
-
- if (!otg_p || otg_dev != fsl_otg_dev)
- return -ENODEV;
-
- otg_p->host = host;
- otg_p->host->is_b_host = otg_dev->fsm.id;
-
- otg_dev->fsm.a_bus_drop = 0;
- otg_dev->fsm.a_bus_req = 1;
-
- otg_p->host->otg_port = fsl_otg_initdata.otg_port;
-
- if (dev && dev->driver) {
- VDBG("suspending host\n");
- dev->driver->suspend(dev, PMSG_SUSPEND);
- otg_dev->host_working = 0;
- VDBG("back\n");
- }
-
-
- /* dump_state("set_host running statemachine", &otg_dev->fsm); DDD */
- otg_statemachine(&otg_dev->fsm);
-
- return 0;
-#else
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg);
if (!otg_p || otg_dev != fsl_otg_dev)
@@ -644,7 +620,6 @@ static int fsl_otg_set_host(struct otg_t
otg_statemachine(&otg_dev->fsm);
return 0;
-#endif
}
/* Called by initialization code of udc. Register udc to OTG.*/
@@ -673,12 +648,6 @@ static int fsl_otg_set_peripheral(struct
otg_dev->fsm.b_bus_req = 1;
-#if 0 /* DDD uClinux */
- if (otg_p->host) {
- fsl_otg_enable(otg_p);
- otg_statemachine(&otg_dev->fsm);
- }
-#endif
/* start the gadget right away if the ID pin says Mini-B */
DBG("ID pin=%d\n", otg_dev->fsm.id);
if (otg_dev->fsm.id == 1) {
@@ -815,162 +784,6 @@ irqreturn_t fsl_otg_isr(int irq, void *d
}
-#if 0 // DDD feta-final
-irqreturn_t foo_fsl_otg_isr(int irq, void *dev_id)
-{
- struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm;
- struct otg_transceiver *otg = &((struct fsl_otg *)dev_id)->otg;
- u32 otg_int_src, usb_int_src, otg_sc;
- int trigger = 0;
- int tmp;
-
- usb_int_src = fsl_readl(&usb_dr_regs->usbsts);
- otg_sc = fsl_readl(&usb_dr_regs->otgsc);
- otg_int_src = otg_sc & OTGSC_INTSTS_MASK & (otg_sc >> 8);
-
- /* Only clear otg interrupts */
- fsl_writel(otg_sc, &usb_dr_regs->otgsc);
-
- /*FIXME: ID change not generate when init to 0 */
- /* process OTG interrupts */
- if (otg_int_src) {
- VDBG("\nOTG irq 0x%08x\n", otg_int_src);
- if (otg_int_src & OTGSC_INTSTS_1MS_TIMER)
- trigger = fsl_otg_tick_timer();
-
- if (otg_int_src & OTGSC_INTSTS_USB_ID) {
- fsm->id = (otg_sc & OTGSC_STS_USB_ID) ? 1 : 0;
- otg->default_a = (fsm->id == 0);
- if (otg->host)
- otg->host->is_b_host = fsm->id;
- if (otg->gadget)
- otg->gadget->is_a_peripheral = !fsm->id;
- VDBG("IRQ=ID now=%d\n", fsm->id);
-
- if (fsm->id) { /* switch to gadget */
- schedule_delayed_work(&((struct fsl_otg *)
- dev_id)->otg_event, 25);
- } else { /* switch to host */
- cancel_delayed_work(&
- ((struct fsl_otg *)dev_id)->
- otg_event);
- fsl_otg_start_gadget(fsm, 0);
- fsl_otg_drv_vbus(1);
- fsl_otg_start_host(fsm, 1);
- }
-
- return IRQ_HANDLED;
- }
- if (otg_int_src & OTGSC_INTSTS_DATA_PULSE) {
- fsm->a_srp_det = 1;
- trigger = 1;
- VDBG("!!!!Data pulse int\n");
- }
- if (otg_int_src & OTGSC_INTSTS_A_SESSION_VALID) {
- fsm->a_sess_vld =
- (otg_sc & OTGSC_STS_A_SESSION_VALID) ? 1 : 0;
- /* detect VBUS pulsing */
- if ((fsm->transceiver->state == OTG_STATE_A_IDLE)
- && fsm->a_sess_vld)
- fsm->a_srp_det = 1;
- trigger = 1;
- VDBG("!!!a_sess_vld int state=%d\n", fsm->a_sess_vld);
- }
- if (otg_int_src & OTGSC_INTSTS_A_VBUS_VALID) {
- fsm->a_vbus_vld = !!(otg_sc & OTGSC_STS_A_VBUS_VALID);
- trigger = 1;
- VDBG("!!!a_vbus_vld int state=%d\n", fsm->a_vbus_vld);
-
-#if 1
- if ((fsm->a_vbus_vld == 0) && (fsm->id == 0)) {
- if (fsm->transceiver->state != OTG_STATE_A_WAIT_VFALL)
- /* Warning insted of transfer to Error state. */
- printk(KERN_WARNING "ulpi: The USB Device is "
- "sinking too much current!!\n");
- fsm->a_vbus_vld = 1;
- }
-#endif
-
-
- }
- if (otg_int_src & OTGSC_INTSTS_B_SESSION_VALID) {
- fsm->b_sess_vld =
- (otg_sc & OTGSC_STS_B_SESSION_VALID) ? 1 : 0;
- trigger = 1;
- /* SRP done */
- if ((fsl_otg_dev->otg.state == OTG_STATE_B_SRP_INIT) &&
- fsm->b_sess_vld && srp_wait_done)
- fsm->b_srp_done = 1;
- VDBG("!!!!b_sess_vld int state=%d\n", fsm->b_sess_vld);
- }
- if (otg_int_src & OTGSC_INTSTS_B_SESSION_END) {
- fsm->b_sess_end =
- (otg_sc & OTGSC_STS_B_SESSION_END) ? 1 : 0;
- trigger = 1;
- VDBG("!!!!b_sess_end int state=%d\n", fsm->b_sess_end);
- }
- }
-
- /* process USB interrupts */
- if ((usb_int_src & USB_STS_PORT_CHANGE)
- && (fsm->protocol == PROTO_HOST)) {
- VDBG("\nUSB irq A 0x%08x\n", usb_int_src);
- /* Device resume do not generate statemachine change */
- if (fsl_readl(&usb_dr_regs->portsc1) &
- PORTSCX_PORT_FORCE_RESUME) {
- if (otg->default_a) {
- fsm->b_bus_resume = 1;
- trigger = 1;
- } else {
- fsm->a_bus_resume = 1;
- trigger = 1;
- }
- }
-
- tmp = (fsl_readl(&usb_dr_regs->portsc1) &
- PORTSCX_CURRENT_CONNECT_STATUS) ? 1 : 0;
- if (otg->default_a && (fsm->b_conn != tmp)) {
- fsm->b_conn = tmp;
- trigger = 1;
- } else if (!otg->default_a && (fsm->a_conn != tmp)) {
- fsm->a_conn = tmp;
- trigger = 1;
- }
- }
- /* Workaround: sometimes CSC bit will lost. We change to
- * polling CCS bit for connect change */
- if (fsm->protocol == PROTO_GADGET) {
- if (usb_int_src & USB_STS_SUSPEND) {
- VDBG("\nUSB irq B 0x%08x\n", usb_int_src);
- VDBG("peripheral detected suspend\n");
- if (otg->default_a)
- /* A-device detects B suspend */
- fsm->b_bus_suspend = 1;
- else
- /* B-device detects A suspend */
- fsm->a_bus_suspend = 1;
- trigger = 1;
- } else if (usb_int_src & USB_STS_PORT_CHANGE) {
- VDBG("\nUSB irq C 0x%08x\n", usb_int_src);
- VDBG("peripheral resumed\n");
- if (otg->default_a)
- fsm->b_bus_suspend = 0;
- else
- fsm->a_bus_suspend = 0;
- trigger = 1;
- }
- }
-
- /* Invoke statemachine until state is stable */
- while (trigger) {
- trigger = otg_statemachine(fsm);
- }
-
- return IRQ_HANDLED;
-}
-#endif
-
-
static struct otg_fsm_ops fsl_otg_ops = {
.chrg_vbus = fsl_otg_chrg_vbus,
.drv_vbus = fsl_otg_drv_vbus,
@@ -1003,7 +816,6 @@ int fsl_otg_cfg(struct platform_device *
if (!fsl_otg_tc)
return -ENODEV;
-#if 1 // DDD
if (pdata->regs) {
fsl_otg_tc->dr_mem_map = pdata->regs;
} else {
@@ -1013,8 +825,10 @@ int fsl_otg_cfg(struct platform_device *
return -ENODEV;
}
+ /*
printk("DDD %s(): rsrc_start=0x%x rsrc_len=0x%x\n",
__FUNCTION__, res->start, res->end - res->start + 1);
+ */
if (!request_mem_region(res->start, res->end - res->start + 1,
"OTG")) {
@@ -1026,7 +840,6 @@ int fsl_otg_cfg(struct platform_device *
}
DBG("set dr_mem_map to 0x%p\n", fsl_otg_tc->dr_mem_map);
-#endif
INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event);
INIT_LIST_HEAD(&active_timers);
@@ -1035,12 +848,11 @@ int fsl_otg_cfg(struct platform_device *
/* Set OTG state machine operations */
fsl_otg_tc->fsm.ops = &fsl_otg_ops;
-#if 1 /* DDD */
/* record initial state of ID pin */
fsl_otg_tc->fsm.id = (fsl_otg_tc->dr_mem_map->otgsc & OTGSC_STS_USB_ID)
? 1 : 0;
DBG("initial ID pin=%d\n", fsl_otg_tc->fsm.id);
-#endif
+
/* initialize the otg structure */
fsl_otg_tc->otg.label = DRIVER_DESC;
fsl_otg_tc->otg.set_host = fsl_otg_set_host;
@@ -1115,13 +927,8 @@ int usb_otg_start(struct platform_device
__FUNCTION__, timeout);
/* configure the VBUSHS as IDLE(both host and device) */
-#if 0
- /* DDD really have to check into setting the following */
- fsl_writel(USB_MODE_STREAM_DISABLE, &usb_dr_regs->usbmode);
-#else
temp = USB_MODE_STREAM_DISABLE | (pdata->es ? USBMODE_ES : 0);
fsl_writel(temp, &usb_dr_regs->usbmode);
-#endif
/* configure PHY interface */
temp = fsl_readl(&usb_dr_regs->portsc1);
@@ -1135,24 +942,11 @@ int usb_otg_start(struct platform_device
/* disable all interrupt and clear all OTGSC status */
temp = fsl_readl(&usb_dr_regs->otgsc);
temp &= ~OTGSC_INTERRUPT_ENABLE_BITS_MASK;
-#if 0 // DDD
- /* DDD only want ID int
- * temp |= OTGSC_INTERRUPT_STATUS_BITS_MASK | OTGSC_CTRL_VBUS_DISCHARGE;
- */
- temp |= OTGSC_IE_USB_ID; /* DDD added this */
- temp &= ~OTGSC_IE_1ms_TIMER; /* DDD added this */
-#else
temp |= OTGSC_INTERRUPT_STATUS_BITS_MASK | OTGSC_CTRL_VBUS_DISCHARGE;
-#endif
fsl_writel(temp, &usb_dr_regs->otgsc);
fsl_otg_drv_vbus(0);
-#if 0 // DDD beta-final
- temp = fsl_readl(&usb_dr_regs->otgsc);
- temp |= OTGSC_IE_A_SESSION_VALID;
- fsl_writel(temp, &usb_dr_regs->otgsc);
-#else
/*
* The identification (id) input is FALSE when a Mini-A plug is inserted
* in the devices Mini-AB receptacle. Otherwise, this input is TRUE.
@@ -1173,7 +967,6 @@ int usb_otg_start(struct platform_device
temp |= OTGSC_IE_USB_ID;
temp &= ~(OTGSC_CTRL_VBUS_DISCHARGE | OTGSC_IE_1ms_TIMER);
fsl_writel(temp, &usb_dr_regs->otgsc);
-#endif
return 0;
}
@@ -1427,10 +1220,8 @@ static int __init fsl_otg_probe(struct p
return -ENOMEM;
pdata = pdev->dev.platform_data;
-#if 1 // DDD do this elsewhere
/* Initialize the clock, multiplexing pin and PHY interface */
board_init(pdev);
-#endif
/* configure the OTG */
status = fsl_otg_cfg(pdev);
--- a/drivers/usb/otg/otg_fsm.h
+++ b/drivers/usb/otg/otg_fsm.h
@@ -18,7 +18,7 @@
#ifndef OTG_FSM_H
#define OTG_FSM_H
-#if 1
+#if 0
#define DEBUG 1
#define VERBOSE 1
#endif
--- a/include/linux/usb/fsl_usb2.h
+++ b/include/linux/usb/fsl_usb2.h
@@ -104,9 +104,8 @@ struct fsl_usb_host_regs {
#if 0
u32 endptctrl[USB_MAX_ENDPOINTS]; /* Endpoint Control Registers */
#else
- // DDD: do these exits in the host register set??
- // DDD see DCCPARAMS:DEN for the real number of device endpoints
- // DDD 16 is the max
+ /* DDD see DCCPARAMS:DEN for the real number of device endpoints */
+ /* DDD 16 is the max */
u32 endptctrl[16]; /* Endpoint Control Registers */
#endif
};
|