1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-25 19:16:16 +02:00
openwrt-xburst/target/linux/coldfire/patches/026-m5445x_usb_cleanup_2.patch
kaloz 343c185b7d use broken-out patches for the coldfire to make it easier to follow differences against the bsp
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@16547 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-06-23 21:04:37 +00:00

471 lines
14 KiB
Diff

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
};