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