On Mon, Dec 01, 2008 at 11:20:58AM +0000, Andy Green wrote:
> When we are informed by UDC stuff that we have been enumerated as
> a gadget, we recorded the new current limit but then did nothing.
> 
> It meant that on boot, the enumeration happened but we remained
> stuck at 100mA current limit.  This patch provokes a call to the
> work queue to change the current limit and means that coldplugged
> USB to a PC now recognizes it can pull 500mA when enumerated.
> 

Yes, you are right. In the normal case, this causes the worker to be
scheduled twice, right ? And probably we could schedule the worker
immediately in vbus_draw,.

Here's the patch against balaji-tracking with the fixes, It'll mostly
apply to andy-tracking ok.

Signed-off-by: Balaji Rao <[EMAIL PROTECTED]>
Signed-off-by: Andy Green <[EMAIL PROTECTED]>

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c 
b/arch/arm/mach-s3c2440/mach-gta02.c
index b1ec259..068c3f8 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -557,8 +557,9 @@ static void gta02_charger_worker(struct work_struct *work)
 static void gta02_pmu_event_callback(struct pcf50633 *pcf, int irq)
 {
        if (irq == PCF50633_IRQ_USBINS) {
-               schedule_delayed_work(&gta02_charger_work,
-                               GTA02_CHARGER_CONFIGURE_TIMEOUT);
+               if (!gta02_usb_vbus_draw)
+                       schedule_delayed_work(&gta02_charger_work,
+                                       GTA02_CHARGER_CONFIGURE_TIMEOUT);
                return;
        } else if (irq == PCF50633_IRQ_USBREM) {
                cancel_delayed_work_sync(&gta02_charger_work);
@@ -972,16 +973,17 @@ static struct s3c24xx_mci_pdata gta02_s3c_mmc_cfg = {
 
 static void gta02_udc_command(enum s3c2410_udc_cmd_e cmd)
 {
-       printk(KERN_DEBUG "%s(%d)\n", __func__, cmd);
-
        switch (cmd) {
        case S3C2410_UDC_P_ENABLE:
+               printk(KERN_DEBUG "%s S3C2410_UDC_P_ENABLE\n", __func__);
                neo1973_gpb_setpin(GTA02_GPIO_USB_PULLUP, 1);
                break;
        case S3C2410_UDC_P_DISABLE:
+               printk(KERN_DEBUG "%s S3C2410_UDC_P_DISABLE\n", __func__);
                neo1973_gpb_setpin(GTA02_GPIO_USB_PULLUP, 0);
                break;
        case S3C2410_UDC_P_RESET:
+               printk(KERN_DEBUG "%s S3C2410_UDC_P_RESET\n", __func__);
                /* FIXME! */
                break;
        default:
@@ -993,10 +995,14 @@ static void gta02_udc_command(enum s3c2410_udc_cmd_e cmd)
 
 static void gta02_udc_vbus_draw(unsigned int ma)
 {
-        if (!gta02_pcf_pdata.pcf)
+        if (!gta02_pcf_pdata.pcf) {
+               printk(KERN_ERR "********** NULL gta02_pcf_pdata.pcf *****\n");
                return;
+       }
 
        gta02_usb_vbus_draw = ma;
+
+       schedule_delayed_work(&gta02_charger_work, 0);
 }
 
 static struct s3c2410_udc_mach_info gta02_udc_cfg = {
@@ -1663,6 +1669,7 @@ static void __init gta02_machine_init(void)
        }
 
        spin_lock_init(&motion_irq_lock);
+       INIT_DELAYED_WORK(&gta02_charger_work, gta02_charger_worker);
 
        /* Glamo chip select optimization */
 /*      *((u32 *)(S3C2410_MEMREG(((1 + 1) << 2)))) = 0x1280; */
@@ -1711,8 +1718,6 @@ static void __init gta02_machine_init(void)
        if (rc < 0)
                printk(KERN_ERR "GTA02: can't request ar6k wakeup IRQ\n");
        enable_irq_wake(GTA02_IRQ_WLAN_GPIO1);
-
-       INIT_DELAYED_WORK(&gta02_charger_work, gta02_charger_worker);
 }
 
 void DEBUG_LED(int n)

Reply via email to