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

Commit a42ccdc1 authored by Anand Gadiyar's avatar Anand Gadiyar
Browse files

usb: ehci-omap: add helpers for checking port mode



Introduce helper functions to test port mode. These checks are
performed in several places in the driver, and these helpers
improve readability.

Signed-off-by: default avatarAnand Gadiyar <gadiyar@ti.com>
parent c5dff554
Loading
Loading
Loading
Loading
+12 −9
Original line number Original line Diff line number Diff line
@@ -127,6 +127,9 @@
#define	EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT		8
#define	EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT		8
#define	EHCI_INSNREG05_ULPI_WRDATA_SHIFT		0
#define	EHCI_INSNREG05_ULPI_WRDATA_SHIFT		0


#define is_ehci_phy_mode(x)	(x == EHCI_HCD_OMAP_MODE_PHY)
#define is_ehci_tll_mode(x)	(x == EHCI_HCD_OMAP_MODE_TLL)

/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/


static inline void ehci_omap_writel(void __iomem *base, u32 reg, u32 val)
static inline void ehci_omap_writel(void __iomem *base, u32 reg, u32 val)
@@ -387,27 +390,27 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
	/* Bypass the TLL module for PHY mode operation */
	/* Bypass the TLL module for PHY mode operation */
	if (cpu_is_omap3430() && (omap_rev() <= OMAP3430_REV_ES2_1)) {
	if (cpu_is_omap3430() && (omap_rev() <= OMAP3430_REV_ES2_1)) {
		dev_dbg(omap->dev, "OMAP3 ES version <= ES2.1\n");
		dev_dbg(omap->dev, "OMAP3 ES version <= ES2.1\n");
		if ((omap->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) ||
		if (is_ehci_phy_mode(omap->port_mode[0]) ||
			(omap->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) ||
			is_ehci_phy_mode(omap->port_mode[1]) ||
				(omap->port_mode[2] == EHCI_HCD_OMAP_MODE_PHY))
				is_ehci_phy_mode(omap->port_mode[2]))
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
		else
		else
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
	} else {
	} else {
		dev_dbg(omap->dev, "OMAP3 ES version > ES2.1\n");
		dev_dbg(omap->dev, "OMAP3 ES version > ES2.1\n");
		if (omap->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY)
		if (is_ehci_phy_mode(omap->port_mode[0]))
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
		else if (omap->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL)
		else if (is_ehci_tll_mode(omap->port_mode[0]))
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;


		if (omap->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY)
		if (is_ehci_phy_mode(omap->port_mode[1]))
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS;
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS;
		else if (omap->port_mode[1] == EHCI_HCD_OMAP_MODE_TLL)
		else if (is_ehci_tll_mode(omap->port_mode[1]))
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS;
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS;


		if (omap->port_mode[2] == EHCI_HCD_OMAP_MODE_PHY)
		if (is_ehci_phy_mode(omap->port_mode[2]))
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS;
			reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS;
		else if (omap->port_mode[2] == EHCI_HCD_OMAP_MODE_TLL)
		else if (is_ehci_tll_mode(omap->port_mode[2]))
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS;
			reg |= OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS;


	}
	}