Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21ae58ee authored by jianzhou's avatar jianzhou
Browse files

Revert "usb: composite: Draw 900mA on USB resume if speed is super-speed"



This reverts commit 4be36028.
The same funcion was implemented by upstream android-4.9.216(4ad9bb85)
"usb: gadget: composite: Support more than 500mA MaxPower".

Change-Id: I906a86ed71be24f7e0fafc3ad4a8b1ceb7538f80
Signed-off-by: default avatarjianzhou <jianzhou@codeaurora.org>
parent 5687ffb6
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -28,14 +28,6 @@
#define SSUSB_GADGET_VBUS_DRAW_UNITS 8
#define HSUSB_GADGET_VBUS_DRAW_UNITS 2

/*
 * Based on enumerated USB speed, draw power with set_config and resume
 * HSUSB: 500mA, SSUSB: 900mA
 */
#define USB_VBUS_DRAW(speed)\
	(speed == USB_SPEED_SUPER ?\
	 SSUSB_GADGET_VBUS_DRAW : CONFIG_USB_GADGET_VBUS_DRAW)

/* disable LPM by default */
static bool disable_l1_for_hs;
module_param(disable_l1_for_hs, bool, 0644);
@@ -896,6 +888,7 @@ static int set_config(struct usb_composite_dev *cdev,
	struct usb_gadget	*gadget = cdev->gadget;
	struct usb_configuration *c = NULL;
	int			result = -EINVAL;
	unsigned		power = gadget_is_otg(gadget) ? 8 : 100;
	int			tmp;

	if (number) {
@@ -984,8 +977,14 @@ static int set_config(struct usb_composite_dev *cdev,
		}
	}

	/* Allow 900mA to draw with Super-Speed */
	if (gadget->speed == USB_SPEED_SUPER)
		power = SSUSB_GADGET_VBUS_DRAW;
	else
		power = CONFIG_USB_GADGET_VBUS_DRAW;

done:
	usb_gadget_vbus_draw(gadget, USB_VBUS_DRAW(gadget->speed));
	usb_gadget_vbus_draw(gadget, power);
	if (result >= 0 && cdev->delayed_status)
		result = USB_GADGET_DELAYED_STATUS;
	return result;
@@ -2485,6 +2484,7 @@ void composite_resume(struct usb_gadget *gadget)
{
	struct usb_composite_dev	*cdev = get_gadget_data(gadget);
	struct usb_function		*f;
	u16				maxpower;
	int				ret;
	unsigned long			flags;

@@ -2525,7 +2525,10 @@ void composite_resume(struct usb_gadget *gadget)
				f->resume(f);
		}

		usb_gadget_vbus_draw(gadget, USB_VBUS_DRAW(gadget->speed));
		maxpower = cdev->config->MaxPower;

		usb_gadget_vbus_draw(gadget, maxpower ?
			maxpower : CONFIG_USB_GADGET_VBUS_DRAW);
	}

	spin_unlock_irqrestore(&cdev->lock, flags);