usb: gadget: tegra: Add USB NV Charger Support
Rohith Seelaboyina [Tue, 5 Feb 2013 10:30:24 +0000 (15:30 +0530)]
Add Support for NV charger and set correct current limits
for nv charger and non standard charger.

Bug 1225941

Change-Id: I3e9e6749e6df1929f961133e724602ffa0ded63d
Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com>
Reviewed-on: http://git-master/r/197382
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>

drivers/usb/gadget/tegra_udc.c
drivers/usb/gadget/tegra_udc.h

index 6826e0b..aa91065 100644 (file)
@@ -1416,7 +1416,8 @@ static int tegra_vbus_session(struct usb_gadget *gadget, int is_active)
                }
                /* start the controller */
                dr_controller_run(udc);
-               tegra_usb_set_charging_current(udc);
+               if (udc->connect_type != CONNECT_TYPE_SDP)
+                       tegra_usb_set_charging_current(udc);
        }
 
        return 0;
@@ -1436,7 +1437,7 @@ static int tegra_vbus_draw(struct usb_gadget *gadget, unsigned mA)
 
        udc = container_of(gadget, struct tegra_udc, gadget);
        /* Do not set current limits for CDP ports */
-       if (udc->connect_type != CONNECT_TYPE_CDP) {
+       if (udc->connect_type == CONNECT_TYPE_SDP) {
                udc->current_limit = mA;
                schedule_work(&udc->current_work);
        }
@@ -1796,6 +1797,9 @@ static void setup_received_irq(struct tegra_udc *udc,
                return;
 
        case USB_REQ_SET_ADDRESS:
+               udc->connect_type = CONNECT_TYPE_SDP;
+               tegra_vbus_draw(&udc->gadget,
+                               USB_CHARGING_SDP_CURRENT_LIMIT_UA/1000);
                /* Status phase from udc */
                if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD
                                                | USB_RECIP_DEVICE))
index d90d462..a6ff9d4 100644 (file)
@@ -42,7 +42,7 @@
 #define USB_CHARGING_CDP_CURRENT_LIMIT_UA 1500000
 #define USB_CHARGING_SDP_CURRENT_LIMIT_UA 100000
 #define USB_CHARGING_NV_CHARGER_CURRENT_LIMIT_UA 2000000
-#define USB_CHARGING_NON_STANDARD_CHARGER_CURRENT_LIMIT_UA 1800000
+#define USB_CHARGING_NON_STANDARD_CHARGER_CURRENT_LIMIT_UA 500000
 
  /* 4 sec wait time for charger detection after vbus is detected */
 #define USB_CHARGER_DETECTION_WAIT_TIME_MS 4000