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
6 LTIBName: m5445x-usb-cleanup-2
7 Signed-off-by: Duck <duck@freescale.com>
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(-)
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);
23 -#ifdef NEVER /* DDD FIXME: we want this? */
24 - if (!udc->transceiver)
25 - *((u16 *)(MCF_FBCS1_CSAR)) &= ~0x1; /* Enable pullup register */
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);
35 -#ifdef NEVER /* DDD FIXME: we want this? */
36 - if (!udc->transceiver)
37 - *((u16 *)(MCF_FBCS1_CSAR)) |= 0x1; /* Disable pullup register */
42 static void dr_controller_run(struct fsl_udc *udc)
43 @@ -2598,9 +2587,6 @@ static int __init fsl_udc_probe(struct p
47 -#if 0 // DDD why this? hoarks OTG host
48 - pullup_disable(udc);
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
57 memcpy(ehci->regs, (void *)&usb_ehci_regs, sizeof(struct ehci_regs));
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));
66 tmp = USBMODE_CM_HOST | (pdata->es ? USBMODE_ES : 0);
67 ehci_writel(ehci, tmp, hcd->regs + FSL_SOC_USB_USBMODE);
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));
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]));
80 + pr_debug("set portsc %08x %08x\n", usb_ehci_portsc,
81 + ehci_readl(ehci, &ehci->regs->port_status[0]));
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
92 static void dump_state(const char *string, struct otg_fsm *fsm)
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);
102 /* Routines to access transceiver ULPI registers */
103 @@ -537,6 +539,7 @@ int fsl_otg_start_gadget(struct otg_fsm
108 static void fsl_otg_enable(struct otg_transceiver *otg_p)
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);
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;
127 * Called by initialization code of host driver. Register host controller
128 @@ -577,34 +581,6 @@ static void fsl_otg_enable(struct otg_tr
130 static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
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;
136 - if (!otg_p || otg_dev != fsl_otg_dev)
139 - otg_p->host = host;
140 - otg_p->host->is_b_host = otg_dev->fsm.id;
142 - otg_dev->fsm.a_bus_drop = 0;
143 - otg_dev->fsm.a_bus_req = 1;
145 - otg_p->host->otg_port = fsl_otg_initdata.otg_port;
147 - if (dev && dev->driver) {
148 - VDBG("suspending host\n");
149 - dev->driver->suspend(dev, PMSG_SUSPEND);
150 - otg_dev->host_working = 0;
155 - /* dump_state("set_host running statemachine", &otg_dev->fsm); DDD */
156 - otg_statemachine(&otg_dev->fsm);
160 struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg);
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);
170 /* Called by initialization code of udc. Register udc to OTG.*/
171 @@ -673,12 +648,6 @@ static int fsl_otg_set_peripheral(struct
173 otg_dev->fsm.b_bus_req = 1;
175 -#if 0 /* DDD uClinux */
177 - fsl_otg_enable(otg_p);
178 - otg_statemachine(&otg_dev->fsm);
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
188 -#if 0 // DDD feta-final
189 -irqreturn_t foo_fsl_otg_isr(int irq, void *dev_id)
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;
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);
201 - /* Only clear otg interrupts */
202 - fsl_writel(otg_sc, &usb_dr_regs->otgsc);
204 - /*FIXME: ID change not generate when init to 0 */
205 - /* process OTG interrupts */
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();
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);
215 - otg->host->is_b_host = fsm->id;
217 - otg->gadget->is_a_peripheral = !fsm->id;
218 - VDBG("IRQ=ID now=%d\n", fsm->id);
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)->
227 - fsl_otg_start_gadget(fsm, 0);
228 - fsl_otg_drv_vbus(1);
229 - fsl_otg_start_host(fsm, 1);
232 - return IRQ_HANDLED;
234 - if (otg_int_src & OTGSC_INTSTS_DATA_PULSE) {
235 - fsm->a_srp_det = 1;
237 - VDBG("!!!!Data pulse int\n");
239 - if (otg_int_src & OTGSC_INTSTS_A_SESSION_VALID) {
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;
247 - VDBG("!!!a_sess_vld int state=%d\n", fsm->a_sess_vld);
249 - if (otg_int_src & OTGSC_INTSTS_A_VBUS_VALID) {
250 - fsm->a_vbus_vld = !!(otg_sc & OTGSC_STS_A_VBUS_VALID);
252 - VDBG("!!!a_vbus_vld int state=%d\n", fsm->a_vbus_vld);
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;
266 - if (otg_int_src & OTGSC_INTSTS_B_SESSION_VALID) {
268 - (otg_sc & OTGSC_STS_B_SESSION_VALID) ? 1 : 0;
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);
276 - if (otg_int_src & OTGSC_INTSTS_B_SESSION_END) {
278 - (otg_sc & OTGSC_STS_B_SESSION_END) ? 1 : 0;
280 - VDBG("!!!!b_sess_end int state=%d\n", fsm->b_sess_end);
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;
295 - fsm->a_bus_resume = 1;
300 - tmp = (fsl_readl(&usb_dr_regs->portsc1) &
301 - PORTSCX_CURRENT_CONNECT_STATUS) ? 1 : 0;
302 - if (otg->default_a && (fsm->b_conn != tmp)) {
305 - } else if (!otg->default_a && (fsm->a_conn != tmp)) {
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;
320 - /* B-device detects A suspend */
321 - fsm->a_bus_suspend = 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;
329 - fsm->a_bus_suspend = 0;
334 - /* Invoke statemachine until state is stable */
336 - trigger = otg_statemachine(fsm);
339 - return IRQ_HANDLED;
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 *
353 fsl_otg_tc->dr_mem_map = pdata->regs;
355 @@ -1013,8 +825,10 @@ int fsl_otg_cfg(struct platform_device *
360 printk("DDD %s(): rsrc_start=0x%x rsrc_len=0x%x\n",
361 __FUNCTION__, res->start, res->end - res->start + 1);
364 if (!request_mem_region(res->start, res->end - res->start + 1,
366 @@ -1026,7 +840,6 @@ int fsl_otg_cfg(struct platform_device *
368 DBG("set dr_mem_map to 0x%p\n", fsl_otg_tc->dr_mem_map);
371 INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event);
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;
379 /* record initial state of ID pin */
380 fsl_otg_tc->fsm.id = (fsl_otg_tc->dr_mem_map->otgsc & OTGSC_STS_USB_ID)
382 DBG("initial ID pin=%d\n", fsl_otg_tc->fsm.id);
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);
391 /* configure the VBUSHS as IDLE(both host and device) */
393 - /* DDD really have to check into setting the following */
394 - fsl_writel(USB_MODE_STREAM_DISABLE, &usb_dr_regs->usbmode);
396 temp = USB_MODE_STREAM_DISABLE | (pdata->es ? USBMODE_ES : 0);
397 fsl_writel(temp, &usb_dr_regs->usbmode);
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;
407 - /* DDD only want ID int
408 - * temp |= OTGSC_INTERRUPT_STATUS_BITS_MASK | OTGSC_CTRL_VBUS_DISCHARGE;
410 - temp |= OTGSC_IE_USB_ID; /* DDD added this */
411 - temp &= ~OTGSC_IE_1ms_TIMER; /* DDD added this */
413 temp |= OTGSC_INTERRUPT_STATUS_BITS_MASK | OTGSC_CTRL_VBUS_DISCHARGE;
415 fsl_writel(temp, &usb_dr_regs->otgsc);
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);
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);
435 @@ -1427,10 +1220,8 @@ static int __init fsl_otg_probe(struct p
438 pdata = pdev->dev.platform_data;
439 -#if 1 // DDD do this elsewhere
440 /* Initialize the clock, multiplexing pin and PHY interface */
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
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 {
461 u32 endptctrl[USB_MAX_ENDPOINTS]; /* Endpoint Control Registers */
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 */