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

Commit 05e4b0d6 authored by Jack Pham's avatar Jack Pham Committed by Azhar Shaikh
Browse files

usb: dwc3: msm: Remove psy and regs from struct dwc3_otg



The regs field is unused, so remove it. The psy pointer to
the power_supply is simply the usb_psy in dwc3_msm, so use
that directly instead.

Change-Id: I091c67e49f19e09cc44575080fac42bd495ac651
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
Signed-off-by: default avatarAzhar Shaikh <azhars@codeaurora.org>
parent 93f5a637
Loading
Loading
Loading
Loading
+17 −29
Original line number Diff line number Diff line
@@ -3115,7 +3115,7 @@ static int max_chgr_retry_count = MAX_INVALID_CHRGR_RETRY;
module_param(max_chgr_retry_count, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(max_chgr_retry_count, "Max invalid charger retry count");

static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode);
static void dwc3_otg_notify_host_mode(struct dwc3_msm *mdwc, int host_mode);

/**
 * dwc3_otg_start_host -  helper function for starting/stoping the host controller driver.
@@ -3153,12 +3153,12 @@ static int dwc3_otg_start_host(struct usb_otg *otg, int on)
		pm_runtime_get_sync(otg->phy->dev);
		dbg_event(0xFF, "StrtHost gync",
			atomic_read(&otg->phy->dev->power.usage_count));
		dwc3_otg_notify_host_mode(otg, on);
		dwc3_otg_notify_host_mode(mdwc, on);
		usb_phy_notify_connect(dotg->dwc->usb2_phy, USB_SPEED_HIGH);
		ret = regulator_enable(dotg->vbus_otg);
		if (ret) {
			dev_err(otg->phy->dev, "unable to enable vbus_otg\n");
			dwc3_otg_notify_host_mode(otg, 0);
			dwc3_otg_notify_host_mode(mdwc, 0);
			pm_runtime_put_sync(otg->phy->dev);
			dbg_event(0xFF, "vregerr psync",
				atomic_read(&otg->phy->dev->power.usage_count));
@@ -3181,7 +3181,7 @@ static int dwc3_otg_start_host(struct usb_otg *otg, int on)
				"%s: failed to add XHCI pdev ret=%d\n",
				__func__, ret);
			regulator_disable(dotg->vbus_otg);
			dwc3_otg_notify_host_mode(otg, 0);
			dwc3_otg_notify_host_mode(mdwc, 0);
			pm_runtime_put_sync(otg->phy->dev);
			dbg_event(0xFF, "pdeverr psync",
				atomic_read(&otg->phy->dev->power.usage_count));
@@ -3208,7 +3208,7 @@ static int dwc3_otg_start_host(struct usb_otg *otg, int on)
		dbg_event(0xFF, "StopHost gsync",
			atomic_read(&dwc->dev->power.usage_count));
		usb_phy_notify_disconnect(dotg->dwc->usb2_phy, USB_SPEED_HIGH);
		dwc3_otg_notify_host_mode(otg, on);
		dwc3_otg_notify_host_mode(mdwc, on);
		otg->host = NULL;
		platform_device_del(dwc->xhci);

@@ -3353,28 +3353,24 @@ int dwc3_set_charger(struct usb_otg *otg, struct dwc3_charger *charger)
	return 0;
}

static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode)
static void dwc3_otg_notify_host_mode(struct dwc3_msm *mdwc, int host_mode)
{
	struct dwc3_otg *dotg = container_of(otg, struct dwc3_otg, otg);

	if (!dotg->psy) {
		dev_err(otg->phy->dev, "no usb power supply registered\n");
		return;
	}

	if (host_mode)
		power_supply_set_scope(dotg->psy, POWER_SUPPLY_SCOPE_SYSTEM);
		power_supply_set_scope(&mdwc->usb_psy,
			POWER_SUPPLY_SCOPE_SYSTEM);
	else
		power_supply_set_scope(dotg->psy, POWER_SUPPLY_SCOPE_DEVICE);
		power_supply_set_scope(&mdwc->usb_psy,
			POWER_SUPPLY_SCOPE_DEVICE);
}

static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
{
	enum power_supply_property power_supply_type;
	struct dwc3_otg *dotg = container_of(phy->otg, struct dwc3_otg, otg);
	struct dwc3_msm *mdwc = container_of(dotg, struct dwc3_msm, dotg);


	if (!dotg->psy || !dotg->charger) {
	if (!dotg->charger) {
		dev_err(phy->dev, "no usb power supply/charger registered\n");
		return 0;
	}
@@ -3399,7 +3395,7 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
	else
		power_supply_type = POWER_SUPPLY_TYPE_UNKNOWN;

	power_supply_set_supply_type(dotg->psy, power_supply_type);
	power_supply_set_supply_type(&mdwc->usb_psy, power_supply_type);

skip_psy_type:

@@ -3413,19 +3409,19 @@ skip_psy_type:

	if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) {
		/* Disable charging */
		if (power_supply_set_online(dotg->psy, false))
		if (power_supply_set_online(&mdwc->usb_psy, false))
			goto psy_error;
	} else {
		/* Enable charging */
		if (power_supply_set_online(dotg->psy, true))
		if (power_supply_set_online(&mdwc->usb_psy, true))
			goto psy_error;
	}

	/* Set max current limit in uA */
	if (power_supply_set_current_limit(dotg->psy, 1000*mA))
	if (power_supply_set_current_limit(&mdwc->usb_psy, 1000*mA))
		goto psy_error;

	power_supply_changed(dotg->psy);
	power_supply_changed(&mdwc->usb_psy);
	dotg->charger->max_power = mA;
	return 0;

@@ -3488,13 +3484,6 @@ static void dwc3_otg_sm_work(struct work_struct *w)
	switch (phy->state) {
	case OTG_STATE_UNDEFINED:
		dwc3_otg_init_sm(dotg);
		if (!dotg->psy) {
			dotg->psy = power_supply_get_by_name("usb");

			if (!dotg->psy)
				dev_err(phy->dev,
					 "couldn't get usb power supply\n");
		}

		/* Switch to A or B-Device according to ID / BSV */
		if (!test_bit(ID, &dotg->inputs)) {
@@ -3766,7 +3755,6 @@ int dwc3_otg_init(struct dwc3 *dwc)
	dotg->otg.phy->set_power = dwc3_otg_set_power;
	dotg->otg.set_peripheral = dwc3_otg_set_peripheral;
	dotg->otg.phy->state = OTG_STATE_UNDEFINED;
	dotg->regs = dwc->regs;

	/* This reference is used by dwc3 modules for checking otg existence */
	dwc->dotg = dotg;
+0 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#define __LINUX_USB_DWC3_OTG_H

#include <linux/workqueue.h>
#include <linux/power_supply.h>

#include <linux/usb/otg.h>

@@ -35,7 +34,6 @@ struct dwc3_charger;
/**
 * struct dwc3_otg: OTG driver data. Shared by HCD and DCD.
 * @otg: USB OTG Transceiver structure.
 * @regs: ioremapped register base address.
 * @sm_work: OTG state machine work.
 * @charger: DWC3 external charger detector
 * @inputs: OTG state machine inputs
@@ -43,7 +41,6 @@ struct dwc3_charger;
struct dwc3_otg {
	struct usb_otg		otg;
	struct dwc3		*dwc;
	void __iomem		*regs;
	struct regulator	*vbus_otg;
	struct delayed_work	sm_work;
	struct dwc3_charger	*charger;
@@ -51,7 +48,6 @@ struct dwc3_otg {
#define B_SESS_VLD	 1
#define B_SUSPEND	2
	unsigned long inputs;
	struct power_supply	*psy;
	struct completion	dwc3_xcvr_vbus_init;
	int			charger_retry_count;
	int			vbus_retry_count;