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

Commit c62aa2ae authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

usb: phy: msm: Fix compilation issues



This change fixes the various compilation issues
present in phy-msm-usb driver.

Change-Id: I1df014a7c778e0015a1dcd1ff16561e7f327445f
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent 21f4a744
Loading
Loading
Loading
Loading
+44 −28
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@
#include <linux/usb/hcd.h>
#include <linux/usb/msm_hsusb.h>
#include <linux/usb/msm_hsusb_hw.h>
#include <linux/usb/msm_ext_chg.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
@@ -1451,12 +1450,12 @@ static int msm_otg_suspend(struct msm_otg *motg)
	 * bus suspend scenarios.  Otherwise PHY can not be suspended when
	 * a charger that pulls DP/DM high is connected.
	 */
	config2 = readl_relaxed(USB_GENCONFIG2);
	config2 = readl_relaxed(USB_GENCONFIG_2);
	if (device_bus_suspend)
		config2 |= GENCFG2_LINESTATE_DIFF_WAKEUP_EN;
		config2 |= GENCONFIG_2_LINESTATE_DIFF_WAKEUP_EN;
	else
		config2 &= ~GENCFG2_LINESTATE_DIFF_WAKEUP_EN;
	writel_relaxed(config2, USB_GENCONFIG2);
		config2 &= ~GENCONFIG_2_LINESTATE_DIFF_WAKEUP_EN;
	writel_relaxed(config2, USB_GENCONFIG_2);

	/*
	 * Abort suspend when,
@@ -1638,9 +1637,9 @@ static int msm_otg_suspend(struct msm_otg *motg)
			 * Without this WA, the async_irq will be fired right
			 * after suspending whithout any bus resume.
			 */
			config2 = readl_relaxed(USB_GENCONFIG2);
			config2 &= ~GENCFG2_DPSE_DMSE_HV_INTR_EN;
			writel_relaxed(config2, USB_GENCONFIG2);
			config2 = readl_relaxed(USB_GENCONFIG_2);
			config2 &= ~GENCONFIG_2_DPSE_DMSE_HV_INTR_EN;
			writel_relaxed(config2, USB_GENCONFIG_2);

			msm_otg_enter_phy_retention(motg);
			motg->lpm_flags |= PHY_RETENTIONED;
@@ -1933,6 +1932,7 @@ static void msm_otg_notify_host_mode(struct msm_otg *motg, bool host_mode)
static int msm_otg_notify_chg_type(struct msm_otg *motg)
{
	static int charger_type;
	union power_supply_propval pval = {0};

	/*
	 * TODO
@@ -1960,12 +1960,17 @@ static int msm_otg_notify_chg_type(struct msm_otg *motg)
	pr_debug("setting usb power supply type %d\n", charger_type);
	msm_otg_dbg_log_event(&motg->phy, "SET USB PWR SUPPLY TYPE",
			motg->chg_type, charger_type);
	power_supply_set_supply_type(psy, charger_type);
	pval.intval = charger_type;
	power_supply_set_property(psy, POWER_SUPPLY_PROP_TYPE, &pval);
	return 0;
}

static int msm_otg_notify_power_supply(struct msm_otg *motg, unsigned int mA)
{
	union power_supply_propval pval = {0};
	bool enable;
	int limit;

	if (!psy) {
		dev_dbg(motg->phy.dev, "no usb power supply registered\n");
		goto psy_error;
@@ -1973,25 +1978,28 @@ static int msm_otg_notify_power_supply(struct msm_otg *motg, unsigned int mA)

	if (motg->cur_power == 0 && mA > 2) {
		/* Enable charging */
		if (power_supply_set_online(psy, true))
			goto psy_error;
		if (power_supply_set_current_limit(psy, 1000*mA))
			goto psy_error;
		enable = true;
		limit = 1000 * mA;
	} else if (motg->cur_power >= 0 && (mA == 0 || mA == 2)) {
		/* Disable charging */
		if (power_supply_set_online(psy, false))
			goto psy_error;
		enable = false;
		/* Set max current limit in uA */
		if (power_supply_set_current_limit(psy, 1000*mA))
			goto psy_error;
		limit = 1000 * mA;
	} else {
		if (power_supply_set_online(psy, true))
			goto psy_error;
		enable = true;
		/* Current has changed (100/2 --> 500) */
		if (power_supply_set_current_limit(psy, 1000*mA))
			goto psy_error;
		limit = 1000 * mA;
	}

	pval.intval = enable;
	if (power_supply_set_property(psy, POWER_SUPPLY_PROP_ONLINE, &pval))
		goto psy_error;

	pval.intval = limit;
	if (power_supply_set_property(psy, POWER_SUPPLY_PROP_CURRENT_MAX,
									&pval))
		goto psy_error;

	power_supply_changed(psy);
	return 0;

@@ -2002,13 +2010,16 @@ static int msm_otg_notify_power_supply(struct msm_otg *motg, unsigned int mA)

static void msm_otg_set_online_status(struct msm_otg *motg)
{
	union power_supply_propval pval = {0};

	if (!psy) {
		dev_dbg(motg->phy.dev, "no usb power supply registered\n");
		return;
	}

	/* Set power supply online status to false */
	if (power_supply_set_online(psy, false))
	pval.intval = false;
	if (power_supply_set_property(psy, POWER_SUPPLY_PROP_ONLINE, &pval))
		dev_dbg(motg->phy.dev, "error setting power supply property\n");
}

@@ -2442,13 +2453,15 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
static bool msm_otg_read_pmic_id_state(struct msm_otg *motg)
{
	unsigned long flags;
	int id;
	bool id;
	int ret;

	if (!motg->pdata->pmic_id_irq)
		return -ENODEV;

	local_irq_save(flags);
	id = irq_read_line(motg->pdata->pmic_id_irq);
	ret = irq_get_irqchip_state(motg->pdata->pmic_id_irq,
					IRQCHIP_STATE_LINE_LEVEL, &id);
	local_irq_restore(flags);

	/*
@@ -2456,6 +2469,9 @@ static bool msm_otg_read_pmic_id_state(struct msm_otg *motg)
	 * it as float. This would prevent MHL discovery and kicking
	 * host mode unnecessarily.
	 */
	if (ret < 0)
		return true;

	return !!id;
}

@@ -3813,9 +3829,9 @@ set_msm_otg_perf_mode(struct device *dev, struct device_attribute *attr,
	int ret;
	long clk_rate;

	pr_debug("%s: enable:%d\n", __func__, !strnicmp(buf, "enable", 6));
	pr_debug("%s: enable:%d\n", __func__, !strncasecmp(buf, "enable", 6));

	if (!strnicmp(buf, "enable", 6)) {
	if (!strncasecmp(buf, "enable", 6)) {
		clk_rate = motg->core_clk_nominal_rate;
		msm_otg_bus_freq_set(motg, USB_NOC_NOM_VOTE);
	} else {
@@ -4207,10 +4223,10 @@ static ssize_t dpdm_pulldown_enable_store(struct device *dev,
	struct msm_otg *motg = the_msm_otg;
	struct msm_otg_platform_data *pdata = motg->pdata;

	if (!strnicmp(buf, "enable", 6)) {
	if (!strncasecmp(buf, "enable", 6)) {
		pdata->dpdm_pulldown_added = true;
		return size;
	} else if (!strnicmp(buf, "disable", 7)) {
	} else if (!strncasecmp(buf, "disable", 7)) {
		pdata->dpdm_pulldown_added = false;
		return size;
	}
+0 −8
Original line number Diff line number Diff line
@@ -348,18 +348,10 @@ int msm_do_bam_disable_enable(enum usb_ctrl ctrl) { return true; }
#endif
#ifdef CONFIG_USB_CI13XXX_MSM
void msm_hw_soft_reset(void);
void msm_hw_bam_disable(bool bam_disable);
void msm_usb_irq_disable(bool disable);
#else
static inline void msm_hw_soft_reset(void)
{
}
static inline void msm_hw_bam_disable(bool bam_disable)
{
}
static inline void msm_usb_irq_disable(bool disable)
{
}
#endif

#endif
+42 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
#define ULPI_TX_PKT_EN_CLR_FIX	BIT(19)

#define USB_CAPLENGTH        (MSM_USB_BASE + 0x0100) /* 8 bit */
#define USB_HS_APF_CTRL      (MSM_USB_BASE + 0x0380)

#define APF_CTRL_EN		BIT(0)

#define USB_USBCMD           (MSM_USB_BASE + 0x0140)
#define USB_PORTSC           (MSM_USB_BASE + 0x0184)
@@ -35,6 +38,8 @@
#define USB_PHY_CTRL2        (MSM_USB_BASE + 0x0278)

#define GENCONFIG_2_SESS_VLD_CTRL_EN	BIT(7)
#define GENCONFIG_2_LINESTATE_DIFF_WAKEUP_EN	BIT(12)
#define GENCONFIG_2_DPSE_DMSE_HV_INTR_EN	BIT(15)
#define USBCMD_SESS_VLD_CTRL		BIT(25)

#define USBCMD_RESET   2
@@ -48,11 +53,17 @@
#define L1_CONFIG_GATE_SYS_CLK	BIT(7)
#define L1_CONFIG_PHY_LPM	BIT(10)
#define L1_CONFIG_PLL		BIT(11)
#define AHB2AHB_BYPASS          BIT(31)
#define AHB2AHB_BYPASS_BIT_MASK        BIT(31)
#define AHB2AHB_BYPASS_CLEAR   (0 << 31)

#define PORTSC_PHCD            (1 << 23) /* phy suspend mode */
#define PORTSC_PTS_MASK        (3 << 30)
#define PORTSC_PTS_ULPI        (2 << 30)
#define PORTSC_PTS_SERIAL      (3 << 30)
#define PORTSC_LS	       (3 << 10)
#define PORTSC_LS_DM	       (1 << 10)
#define PORTSC_CCS	       (1 << 0)

#define USB_ULPI_VIEWPORT    (MSM_USB_BASE + 0x0170)
#define ULPI_RUN              (1 << 30)
@@ -77,10 +88,16 @@
#define ASYNC_INTR_CTRL         (1 << 29) /* Enable async interrupt */
#define ULPI_STP_CTRL           (1 << 30) /* Block communication with PHY */
#define PHY_RETEN               (1 << 1) /* PHY retention enable/disable */
#define PHY_IDHV_INTEN          (1 << 8) /* PHY ID HV interrupt */
#define PHY_OTGSESSVLDHV_INTEN  (1 << 9) /* PHY Session Valid HV int. */
#define PHY_CLAMP_DPDMSE_EN	(1 << 21) /* PHY mpm DP DM clamp enable */
#define PHY_POR_BIT_MASK        BIT(0)
#define PHY_POR_ASSERT		(1 << 0) /* USB2 28nm PHY POR ASSERT */
#define PHY_POR_DEASSERT        (0 << 0) /* USB2 28nm PHY POR DEASSERT */

/* OTG definitions */
#define OTGSC_INTSTS_MASK	(0x7f << 16)
#define OTGSC_IDPU		(1 << 5)
#define OTGSC_ID		(1 << 8)
#define OTGSC_BSV		(1 << 11)
#define OTGSC_IDIS		(1 << 16)
@@ -88,4 +105,29 @@
#define OTGSC_IDIE		(1 << 24)
#define OTGSC_BSVIE		(1 << 27)

/* USB PHY CSR registers and bit definitions */

#define USB_PHY_CSR_PHY_CTRL_COMMON0 (MSM_USB_PHY_CSR_BASE + 0x078)
#define SIDDQ BIT(2)

#define USB_PHY_CSR_PHY_CTRL1 (MSM_USB_PHY_CSR_BASE + 0x08C)
#define ID_HV_CLAMP_EN_N BIT(1)

#define USB_PHY_CSR_PHY_CTRL3 (MSM_USB_PHY_CSR_BASE + 0x094)
#define CLAMP_MPM_DPSE_DMSE_EN_N BIT(2)

#define USB2_PHY_USB_PHY_IRQ_CMD (MSM_USB_PHY_CSR_BASE + 0x0D0)
#define USB2_PHY_USB_PHY_INTERRUPT_SRC_STATUS (MSM_USB_PHY_CSR_BASE + 0x05C)

#define USB2_PHY_USB_PHY_INTERRUPT_CLEAR0 (MSM_USB_PHY_CSR_BASE + 0x0DC)
#define USB2_PHY_USB_PHY_INTERRUPT_CLEAR1 (MSM_USB_PHY_CSR_BASE + 0x0E0)

#define USB2_PHY_USB_PHY_INTERRUPT_MASK1 (MSM_USB_PHY_CSR_BASE + 0x0D8)

#define USB_PHY_IDDIG_1_0 BIT(7)

#define USB_PHY_IDDIG_RISE_MASK BIT(0)
#define USB_PHY_IDDIG_FALL_MASK BIT(1)
#define USB_PHY_ID_MASK (USB_PHY_IDDIG_RISE_MASK | USB_PHY_IDDIG_FALL_MASK)

#endif /* __LINUX_USB_GADGET_MSM72K_UDC_H__ */
+5 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ enum usb_otg_state {
	OTG_STATE_B_SRP_INIT,
	OTG_STATE_B_PERIPHERAL,
	OTG_STATE_B_SUSPEND,
	OTG_STATE_B_CHARGER,

	/* extra dual-role default-b states */
	OTG_STATE_B_WAIT_ACON,
@@ -141,6 +142,10 @@ struct usb_phy {

	/* reset the PHY clocks */
	int     (*reset)(struct usb_phy *x);

	/* for notification of usb_phy_dbg_events */
	void    (*dbg_event)(struct usb_phy *x,
			char *event, int msg1, int msg2);
	int	(*disable_chirp)(struct usb_phy *x, bool disable);
};