usb: dwc_otg: fix problems of commit 058d627
authorlyz <lyz@rock-chips.com>
Fri, 21 Nov 2014 08:18:49 +0000 (16:18 +0800)
committerlyz <lyz@rock-chips.com>
Fri, 21 Nov 2014 11:18:34 +0000 (19:18 +0800)
1.
schedule_delayed_work(&pcd->check_id_work,msecs_to_jiffies(HZ))
should be schedule_delayed_work(&pcd->check_id_work,HZ)

2.fix coding-style to pass checkpatch.pl

3.set otg controler working on foece host/device mode to avoid
mode_missmatch_interrupts

drivers/usb/dwc_otg_310/dwc_otg_cil.c
drivers/usb/dwc_otg_310/dwc_otg_cil.h
drivers/usb/dwc_otg_310/dwc_otg_driver.c
drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c

index 653b2b600f91fe44936fa728cbd8381809dd09e4..89fdaa9e0a8265aff73f8764656d39e99bd52b24 100755 (executable)
@@ -7736,3 +7736,25 @@ int dwc_otg_check_haps_status(dwc_otg_core_if_t *core_if)
        }
 
 }
+
+void dwc_otg_set_force_mode(dwc_otg_core_if_t *core_if, int mode)
+{
+       gusbcfg_data_t usbcfg = {.d32 = 0 };
+
+       usbcfg.d32 = DWC_READ_REG32(&core_if->core_global_regs->gusbcfg);
+       switch (mode) {
+       case USB_MODE_FORCE_HOST:
+               usbcfg.b.force_host_mode = 1;
+               usbcfg.b.force_dev_mode = 0;
+               break;
+       case USB_MODE_FORCE_DEVICE:
+               usbcfg.b.force_host_mode = 0;
+               usbcfg.b.force_dev_mode = 1;
+               break;
+       case USB_MODE_NORMAL:
+               usbcfg.b.force_host_mode = 0;
+               usbcfg.b.force_dev_mode = 0;
+               break;
+       }
+       DWC_WRITE_REG32(&core_if->core_global_regs->gusbcfg, usbcfg.d32);
+}
index 10f8cf07a1202d54845c891587db9188774f1c0d..f0170d2a52308ced60d0711d0c8eda2541e2e99e 100755 (executable)
@@ -1501,4 +1501,6 @@ static inline void cil_pcd_resume(dwc_otg_core_if_t *core_if)
        }
 }
 
+void dwc_otg_set_force_mode(dwc_otg_core_if_t *core_if, int mode);
+
 #endif
index 1279c0d623d89b2f2095a0a9c02dbf728f7cb9c4..16a4464dc51d6bfca7cfdbec05a08d761f8198e1 100755 (executable)
@@ -447,28 +447,6 @@ void dwc_otg_force_device(dwc_otg_core_if_t *core_if)
        local_irq_restore(flags);
 }
 
-static void dwc_otg_set_force_mode(dwc_otg_core_if_t *core_if, int mode)
-{
-       gusbcfg_data_t usbcfg = {.d32 = 0 };
-       printk("!!!dwc_otg_set_force_mode\n");
-       usbcfg.d32 = DWC_READ_REG32(&core_if->core_global_regs->gusbcfg);
-       switch (mode) {
-       case USB_MODE_FORCE_HOST:
-               usbcfg.b.force_host_mode = 1;
-               usbcfg.b.force_dev_mode = 0;
-               break;
-       case USB_MODE_FORCE_DEVICE:
-               usbcfg.b.force_host_mode = 0;
-               usbcfg.b.force_dev_mode = 1;
-               break;
-       case USB_MODE_NORMAL:
-               usbcfg.b.force_host_mode = 0;
-               usbcfg.b.force_dev_mode = 0;
-               break;
-       }
-       DWC_WRITE_REG32(&core_if->core_global_regs->gusbcfg, usbcfg.d32);
-}
-
 static ssize_t force_usb_mode_show(struct device_driver *drv, char *buf)
 {
        dwc_otg_device_t *otg_dev = g_otgdev;
index 5d99badf5d5d7c6557f0beb9677d81db4f006018..b5c73a0ffdf217760d154818252d9c41e7f81015 100755 (executable)
@@ -1502,7 +1502,7 @@ static void dwc_phy_reconnect(struct work_struct *work)
        }
 }
 
-void id_status_change(dwc_otg_core_if_t *p, bool current_id)
+static void id_status_change(dwc_otg_core_if_t *p, bool current_id)
 {
        dwc_otg_core_if_t *core_if = p;
        uint32_t count = 0;
@@ -1513,7 +1513,7 @@ void id_status_change(dwc_otg_core_if_t *p, bool current_id)
        DWC_DEBUGPL(DBG_CIL, "gotgctl=%0x\n", gotgctl.d32);
        DWC_DEBUGPL(DBG_CIL, "gotgctl.b.conidsts=%d\n", gotgctl.b.conidsts);
 
-       if( core_if->usb_mode != USB_MODE_NORMAL )
+       if (core_if->usb_mode != USB_MODE_NORMAL)
                return;
 
        /* B-Device connector (Device Mode) */
@@ -1535,6 +1535,7 @@ void id_status_change(dwc_otg_core_if_t *p, bool current_id)
                        DWC_PRINTF("Connection id status change timed out");
                        return;
                }
+               dwc_otg_set_force_mode(core_if, USB_MODE_FORCE_DEVICE);
                core_if->op_state = B_PERIPHERAL;
                cil_hcd_stop(core_if);
                /* pcd->phy_suspend = 1; */
@@ -1558,6 +1559,7 @@ void id_status_change(dwc_otg_core_if_t *p, bool current_id)
                }
 
                core_if->op_state = A_HOST;
+               dwc_otg_set_force_mode(core_if, USB_MODE_FORCE_HOST);
 
                cancel_delayed_work(&pcd->check_vbus_work);
 
@@ -1580,8 +1582,8 @@ static void check_id(struct work_struct *work)
        static int last_id = -1;
        int id = pldata->get_status(USB_STATUS_ID);
 
-       if((last_id != id)) {
-               printk("[otg id chg] last id %d current id %d \n", last_id, id);
+       if (last_id != id) {
+               pr_info("[otg id chg] last id %d current id %d\n", last_id, id);
                if (!id) { /* Force Host */
                        if (pldata->phy_status == USB_PHY_SUSPEND) {
                                pldata->clock_enable(pldata, 1);
@@ -1594,7 +1596,6 @@ static void check_id(struct work_struct *work)
        }
        last_id = id;
        schedule_delayed_work(&_pcd->check_id_work, (HZ));
-       return;
 }
 
 static void dwc_otg_pcd_check_vbus_work(struct work_struct *work)
@@ -1743,12 +1744,11 @@ static void dwc_otg_pcd_work_init(dwc_otg_pcd_t *pcd,
                        /* usb phy bypass to uart mode */
                        pldata->dwc_otg_uart_mode(pldata, PHY_UART_MODE);
                }
-       }
-       else if (pldata->dwc_otg_uart_mode != NULL) {
+       } else if (pldata->dwc_otg_uart_mode != NULL) {
                /* host mode,enter usb phy mode */
                pldata->dwc_otg_uart_mode(pldata, PHY_USB_MODE);
        }
-       schedule_delayed_work(&pcd->check_id_work, msecs_to_jiffies(HZ));
+       schedule_delayed_work(&pcd->check_id_work, HZ);
 }
 
 #endif /* DWC_HOST_ONLY */