提交 8062d94a 编写于 作者: G Greg Kroah-Hartman

Merge tag 'xceiv-for-v3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next

USB: transceiver changes for 3.4

Here we have a big rework done by Heikki Krogerus (thanks) which
splits OTG functionality away from transceivers.

We have known for quite a long time that struct otg_transceiver was
a bad name for the structure, considering transceiver is far from
being OTG-specific (see 4e67185a).
...@@ -158,7 +158,7 @@ static int devboard_usbh1_hw_init(struct platform_device *pdev) ...@@ -158,7 +158,7 @@ static int devboard_usbh1_hw_init(struct platform_device *pdev)
#define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B) #define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B)
#define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE) #define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE)
static int devboard_isp1105_init(struct otg_transceiver *otg) static int devboard_isp1105_init(struct usb_phy *otg)
{ {
int ret = gpio_request(USBH1_MODE, "usbh1-mode"); int ret = gpio_request(USBH1_MODE, "usbh1-mode");
if (ret) if (ret)
...@@ -177,7 +177,7 @@ static int devboard_isp1105_init(struct otg_transceiver *otg) ...@@ -177,7 +177,7 @@ static int devboard_isp1105_init(struct otg_transceiver *otg)
} }
static int devboard_isp1105_set_vbus(struct otg_transceiver *otg, bool on) static int devboard_isp1105_set_vbus(struct usb_otg *otg, bool on)
{ {
if (on) if (on)
gpio_set_value(USBH1_VBUSEN_B, 0); gpio_set_value(USBH1_VBUSEN_B, 0);
...@@ -194,18 +194,24 @@ static struct mxc_usbh_platform_data usbh1_pdata __initdata = { ...@@ -194,18 +194,24 @@ static struct mxc_usbh_platform_data usbh1_pdata __initdata = {
static int __init devboard_usbh1_init(void) static int __init devboard_usbh1_init(void)
{ {
struct otg_transceiver *otg; struct usb_phy *phy;
struct platform_device *pdev; struct platform_device *pdev;
otg = kzalloc(sizeof(*otg), GFP_KERNEL); phy = kzalloc(sizeof(*phy), GFP_KERNEL);
if (!otg) if (!phy)
return -ENOMEM; return -ENOMEM;
otg->label = "ISP1105"; phy->otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
otg->init = devboard_isp1105_init; if (!phy->otg) {
otg->set_vbus = devboard_isp1105_set_vbus; kfree(phy);
return -ENOMEM;
}
phy->label = "ISP1105";
phy->init = devboard_isp1105_init;
phy->otg->set_vbus = devboard_isp1105_set_vbus;
usbh1_pdata.otg = otg; usbh1_pdata.otg = phy;
pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata); pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata);
if (IS_ERR(pdev)) if (IS_ERR(pdev))
......
...@@ -272,7 +272,7 @@ static int marxbot_usbh1_hw_init(struct platform_device *pdev) ...@@ -272,7 +272,7 @@ static int marxbot_usbh1_hw_init(struct platform_device *pdev)
#define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B) #define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B)
#define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE) #define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE)
static int marxbot_isp1105_init(struct otg_transceiver *otg) static int marxbot_isp1105_init(struct usb_phy *otg)
{ {
int ret = gpio_request(USBH1_MODE, "usbh1-mode"); int ret = gpio_request(USBH1_MODE, "usbh1-mode");
if (ret) if (ret)
...@@ -291,7 +291,7 @@ static int marxbot_isp1105_init(struct otg_transceiver *otg) ...@@ -291,7 +291,7 @@ static int marxbot_isp1105_init(struct otg_transceiver *otg)
} }
static int marxbot_isp1105_set_vbus(struct otg_transceiver *otg, bool on) static int marxbot_isp1105_set_vbus(struct usb_otg *otg, bool on)
{ {
if (on) if (on)
gpio_set_value(USBH1_VBUSEN_B, 0); gpio_set_value(USBH1_VBUSEN_B, 0);
...@@ -308,18 +308,24 @@ static struct mxc_usbh_platform_data usbh1_pdata __initdata = { ...@@ -308,18 +308,24 @@ static struct mxc_usbh_platform_data usbh1_pdata __initdata = {
static int __init marxbot_usbh1_init(void) static int __init marxbot_usbh1_init(void)
{ {
struct otg_transceiver *otg; struct usb_phy *phy;
struct platform_device *pdev; struct platform_device *pdev;
otg = kzalloc(sizeof(*otg), GFP_KERNEL); phy = kzalloc(sizeof(*phy), GFP_KERNEL);
if (!otg) if (!phy)
return -ENOMEM; return -ENOMEM;
otg->label = "ISP1105"; phy->otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
otg->init = marxbot_isp1105_init; if (!phy->otg) {
otg->set_vbus = marxbot_isp1105_set_vbus; kfree(phy);
return -ENOMEM;
}
phy->label = "ISP1105";
phy->init = marxbot_isp1105_init;
phy->otg->set_vbus = marxbot_isp1105_set_vbus;
usbh1_pdata.otg = otg; usbh1_pdata.otg = phy;
pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata); pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata);
if (IS_ERR(pdev)) if (IS_ERR(pdev))
......
...@@ -33,7 +33,7 @@ struct pxa3xx_u2d_ulpi { ...@@ -33,7 +33,7 @@ struct pxa3xx_u2d_ulpi {
struct clk *clk; struct clk *clk;
void __iomem *mmio_base; void __iomem *mmio_base;
struct otg_transceiver *otg; struct usb_phy *otg;
unsigned int ulpi_mode; unsigned int ulpi_mode;
}; };
...@@ -79,7 +79,7 @@ static int pxa310_ulpi_poll(void) ...@@ -79,7 +79,7 @@ static int pxa310_ulpi_poll(void)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
static int pxa310_ulpi_read(struct otg_transceiver *otg, u32 reg) static int pxa310_ulpi_read(struct usb_phy *otg, u32 reg)
{ {
int err; int err;
...@@ -98,7 +98,7 @@ static int pxa310_ulpi_read(struct otg_transceiver *otg, u32 reg) ...@@ -98,7 +98,7 @@ static int pxa310_ulpi_read(struct otg_transceiver *otg, u32 reg)
return u2d_readl(U2DOTGUCR) & U2DOTGUCR_RDATA; return u2d_readl(U2DOTGUCR) & U2DOTGUCR_RDATA;
} }
static int pxa310_ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) static int pxa310_ulpi_write(struct usb_phy *otg, u32 val, u32 reg)
{ {
if (pxa310_ulpi_get_phymode() != SYNCH) { if (pxa310_ulpi_get_phymode() != SYNCH) {
pr_warning("%s: PHY is not in SYNCH mode!\n", __func__); pr_warning("%s: PHY is not in SYNCH mode!\n", __func__);
...@@ -111,7 +111,7 @@ static int pxa310_ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) ...@@ -111,7 +111,7 @@ static int pxa310_ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg)
return pxa310_ulpi_poll(); return pxa310_ulpi_poll();
} }
struct otg_io_access_ops pxa310_ulpi_access_ops = { struct usb_phy_io_ops pxa310_ulpi_access_ops = {
.read = pxa310_ulpi_read, .read = pxa310_ulpi_read,
.write = pxa310_ulpi_write, .write = pxa310_ulpi_write,
}; };
...@@ -139,19 +139,19 @@ static int pxa310_start_otg_host_transcvr(struct usb_bus *host) ...@@ -139,19 +139,19 @@ static int pxa310_start_otg_host_transcvr(struct usb_bus *host)
pxa310_otg_transceiver_rtsm(); pxa310_otg_transceiver_rtsm();
err = otg_init(u2d->otg); err = usb_phy_init(u2d->otg);
if (err) { if (err) {
pr_err("OTG transceiver init failed"); pr_err("OTG transceiver init failed");
return err; return err;
} }
err = otg_set_vbus(u2d->otg, 1); err = otg_set_vbus(u2d->otg->otg, 1);
if (err) { if (err) {
pr_err("OTG transceiver VBUS set failed"); pr_err("OTG transceiver VBUS set failed");
return err; return err;
} }
err = otg_set_host(u2d->otg, host); err = otg_set_host(u2d->otg->otg, host);
if (err) if (err)
pr_err("OTG transceiver Host mode set failed"); pr_err("OTG transceiver Host mode set failed");
...@@ -189,9 +189,9 @@ static void pxa310_stop_otg_hc(void) ...@@ -189,9 +189,9 @@ static void pxa310_stop_otg_hc(void)
{ {
pxa310_otg_transceiver_rtsm(); pxa310_otg_transceiver_rtsm();
otg_set_host(u2d->otg, NULL); otg_set_host(u2d->otg->otg, NULL);
otg_set_vbus(u2d->otg, 0); otg_set_vbus(u2d->otg->otg, 0);
otg_shutdown(u2d->otg); usb_phy_shutdown(u2d->otg);
} }
static void pxa310_u2d_setup_otg_hc(void) static void pxa310_u2d_setup_otg_hc(void)
......
...@@ -58,7 +58,7 @@ struct tegra_usb_phy { ...@@ -58,7 +58,7 @@ struct tegra_usb_phy {
struct clk *pad_clk; struct clk *pad_clk;
enum tegra_usb_phy_mode mode; enum tegra_usb_phy_mode mode;
void *config; void *config;
struct otg_transceiver *ulpi; struct usb_phy *ulpi;
}; };
struct tegra_usb_phy *tegra_usb_phy_open(int instance, void __iomem *regs, struct tegra_usb_phy *tegra_usb_phy_open(int instance, void __iomem *regs,
......
...@@ -608,13 +608,13 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) ...@@ -608,13 +608,13 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
writel(val, base + ULPI_TIMING_CTRL_1); writel(val, base + ULPI_TIMING_CTRL_1);
/* Fix VbusInvalid due to floating VBUS */ /* Fix VbusInvalid due to floating VBUS */
ret = otg_io_write(phy->ulpi, 0x40, 0x08); ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08);
if (ret) { if (ret) {
pr_err("%s: ulpi write failed\n", __func__); pr_err("%s: ulpi write failed\n", __func__);
return ret; return ret;
} }
ret = otg_io_write(phy->ulpi, 0x80, 0x0B); ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B);
if (ret) { if (ret) {
pr_err("%s: ulpi write failed\n", __func__); pr_err("%s: ulpi write failed\n", __func__);
return ret; return ret;
......
...@@ -44,7 +44,7 @@ struct mxc_usbh_platform_data { ...@@ -44,7 +44,7 @@ struct mxc_usbh_platform_data {
int (*exit)(struct platform_device *pdev); int (*exit)(struct platform_device *pdev);
unsigned int portsc; unsigned int portsc;
struct otg_transceiver *otg; struct usb_phy *otg;
}; };
int mx51_initialize_usb_hw(int port, unsigned int flags); int mx51_initialize_usb_hw(int port, unsigned int flags);
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
#define __MACH_ULPI_H #define __MACH_ULPI_H
#ifdef CONFIG_USB_ULPI #ifdef CONFIG_USB_ULPI
struct otg_transceiver *imx_otg_ulpi_create(unsigned int flags); struct usb_phy *imx_otg_ulpi_create(unsigned int flags);
#else #else
static inline struct otg_transceiver *imx_otg_ulpi_create(unsigned int flags) static inline struct usb_phy *imx_otg_ulpi_create(unsigned int flags)
{ {
return NULL; return NULL;
} }
#endif #endif
extern struct otg_io_access_ops mxc_ulpi_access_ops; extern struct usb_phy_io_ops mxc_ulpi_access_ops;
#endif /* __MACH_ULPI_H */ #endif /* __MACH_ULPI_H */
...@@ -58,7 +58,7 @@ static int ulpi_poll(void __iomem *view, u32 bit) ...@@ -58,7 +58,7 @@ static int ulpi_poll(void __iomem *view, u32 bit)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
static int ulpi_read(struct otg_transceiver *otg, u32 reg) static int ulpi_read(struct usb_phy *otg, u32 reg)
{ {
int ret; int ret;
void __iomem *view = otg->io_priv; void __iomem *view = otg->io_priv;
...@@ -84,7 +84,7 @@ static int ulpi_read(struct otg_transceiver *otg, u32 reg) ...@@ -84,7 +84,7 @@ static int ulpi_read(struct otg_transceiver *otg, u32 reg)
return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK; return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK;
} }
static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) static int ulpi_write(struct usb_phy *otg, u32 val, u32 reg)
{ {
int ret; int ret;
void __iomem *view = otg->io_priv; void __iomem *view = otg->io_priv;
...@@ -106,13 +106,13 @@ static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) ...@@ -106,13 +106,13 @@ static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg)
return ulpi_poll(view, ULPIVW_RUN); return ulpi_poll(view, ULPIVW_RUN);
} }
struct otg_io_access_ops mxc_ulpi_access_ops = { struct usb_phy_io_ops mxc_ulpi_access_ops = {
.read = ulpi_read, .read = ulpi_read,
.write = ulpi_write, .write = ulpi_write,
}; };
EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops); EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops);
struct otg_transceiver *imx_otg_ulpi_create(unsigned int flags) struct usb_phy *imx_otg_ulpi_create(unsigned int flags)
{ {
return otg_ulpi_create(&mxc_ulpi_access_ops, flags); return otg_ulpi_create(&mxc_ulpi_access_ops, flags);
} }
...@@ -56,7 +56,7 @@ static u16 isp170x_id[] = { ...@@ -56,7 +56,7 @@ static u16 isp170x_id[] = {
struct isp1704_charger { struct isp1704_charger {
struct device *dev; struct device *dev;
struct power_supply psy; struct power_supply psy;
struct otg_transceiver *otg; struct usb_phy *phy;
struct notifier_block nb; struct notifier_block nb;
struct work_struct work; struct work_struct work;
...@@ -71,6 +71,16 @@ struct isp1704_charger { ...@@ -71,6 +71,16 @@ struct isp1704_charger {
unsigned max_power; unsigned max_power;
}; };
static inline int isp1704_read(struct isp1704_charger *isp, u32 reg)
{
return usb_phy_io_read(isp->phy, reg);
}
static inline int isp1704_write(struct isp1704_charger *isp, u32 val, u32 reg)
{
return usb_phy_io_write(isp->phy, val, reg);
}
/* /*
* Disable/enable the power from the isp1704 if a function for it * Disable/enable the power from the isp1704 if a function for it
* has been provided with platform data. * has been provided with platform data.
...@@ -97,31 +107,31 @@ static inline int isp1704_charger_type(struct isp1704_charger *isp) ...@@ -97,31 +107,31 @@ static inline int isp1704_charger_type(struct isp1704_charger *isp)
u8 otg_ctrl; u8 otg_ctrl;
int type = POWER_SUPPLY_TYPE_USB_DCP; int type = POWER_SUPPLY_TYPE_USB_DCP;
func_ctrl = otg_io_read(isp->otg, ULPI_FUNC_CTRL); func_ctrl = isp1704_read(isp, ULPI_FUNC_CTRL);
otg_ctrl = otg_io_read(isp->otg, ULPI_OTG_CTRL); otg_ctrl = isp1704_read(isp, ULPI_OTG_CTRL);
/* disable pulldowns */ /* disable pulldowns */
reg = ULPI_OTG_CTRL_DM_PULLDOWN | ULPI_OTG_CTRL_DP_PULLDOWN; reg = ULPI_OTG_CTRL_DM_PULLDOWN | ULPI_OTG_CTRL_DP_PULLDOWN;
otg_io_write(isp->otg, ULPI_CLR(ULPI_OTG_CTRL), reg); isp1704_write(isp, ULPI_CLR(ULPI_OTG_CTRL), reg);
/* full speed */ /* full speed */
otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL),
ULPI_FUNC_CTRL_XCVRSEL_MASK); ULPI_FUNC_CTRL_XCVRSEL_MASK);
otg_io_write(isp->otg, ULPI_SET(ULPI_FUNC_CTRL), isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL),
ULPI_FUNC_CTRL_FULL_SPEED); ULPI_FUNC_CTRL_FULL_SPEED);
/* Enable strong pull-up on DP (1.5K) and reset */ /* Enable strong pull-up on DP (1.5K) and reset */
reg = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET; reg = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET;
otg_io_write(isp->otg, ULPI_SET(ULPI_FUNC_CTRL), reg); isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL), reg);
usleep_range(1000, 2000); usleep_range(1000, 2000);
reg = otg_io_read(isp->otg, ULPI_DEBUG); reg = isp1704_read(isp, ULPI_DEBUG);
if ((reg & 3) != 3) if ((reg & 3) != 3)
type = POWER_SUPPLY_TYPE_USB_CDP; type = POWER_SUPPLY_TYPE_USB_CDP;
/* recover original state */ /* recover original state */
otg_io_write(isp->otg, ULPI_FUNC_CTRL, func_ctrl); isp1704_write(isp, ULPI_FUNC_CTRL, func_ctrl);
otg_io_write(isp->otg, ULPI_OTG_CTRL, otg_ctrl); isp1704_write(isp, ULPI_OTG_CTRL, otg_ctrl);
return type; return type;
} }
...@@ -136,28 +146,28 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp) ...@@ -136,28 +146,28 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp)
u8 r; u8 r;
/* Reset the transceiver */ /* Reset the transceiver */
r = otg_io_read(isp->otg, ULPI_FUNC_CTRL); r = isp1704_read(isp, ULPI_FUNC_CTRL);
r |= ULPI_FUNC_CTRL_RESET; r |= ULPI_FUNC_CTRL_RESET;
otg_io_write(isp->otg, ULPI_FUNC_CTRL, r); isp1704_write(isp, ULPI_FUNC_CTRL, r);
usleep_range(1000, 2000); usleep_range(1000, 2000);
/* Set normal mode */ /* Set normal mode */
r &= ~(ULPI_FUNC_CTRL_RESET | ULPI_FUNC_CTRL_OPMODE_MASK); r &= ~(ULPI_FUNC_CTRL_RESET | ULPI_FUNC_CTRL_OPMODE_MASK);
otg_io_write(isp->otg, ULPI_FUNC_CTRL, r); isp1704_write(isp, ULPI_FUNC_CTRL, r);
/* Clear the DP and DM pull-down bits */ /* Clear the DP and DM pull-down bits */
r = ULPI_OTG_CTRL_DP_PULLDOWN | ULPI_OTG_CTRL_DM_PULLDOWN; r = ULPI_OTG_CTRL_DP_PULLDOWN | ULPI_OTG_CTRL_DM_PULLDOWN;
otg_io_write(isp->otg, ULPI_CLR(ULPI_OTG_CTRL), r); isp1704_write(isp, ULPI_CLR(ULPI_OTG_CTRL), r);
/* Enable strong pull-up on DP (1.5K) and reset */ /* Enable strong pull-up on DP (1.5K) and reset */
r = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET; r = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET;
otg_io_write(isp->otg, ULPI_SET(ULPI_FUNC_CTRL), r); isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL), r);
usleep_range(1000, 2000); usleep_range(1000, 2000);
/* Read the line state */ /* Read the line state */
if (!otg_io_read(isp->otg, ULPI_DEBUG)) { if (!isp1704_read(isp, ULPI_DEBUG)) {
/* Disable strong pull-up on DP (1.5K) */ /* Disable strong pull-up on DP (1.5K) */
otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL),
ULPI_FUNC_CTRL_TERMSELECT); ULPI_FUNC_CTRL_TERMSELECT);
return 1; return 1;
} }
...@@ -165,23 +175,23 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp) ...@@ -165,23 +175,23 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp)
/* Is it a charger or PS/2 connection */ /* Is it a charger or PS/2 connection */
/* Enable weak pull-up resistor on DP */ /* Enable weak pull-up resistor on DP */
otg_io_write(isp->otg, ULPI_SET(ISP1704_PWR_CTRL), isp1704_write(isp, ULPI_SET(ISP1704_PWR_CTRL),
ISP1704_PWR_CTRL_DP_WKPU_EN); ISP1704_PWR_CTRL_DP_WKPU_EN);
/* Disable strong pull-up on DP (1.5K) */ /* Disable strong pull-up on DP (1.5K) */
otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL),
ULPI_FUNC_CTRL_TERMSELECT); ULPI_FUNC_CTRL_TERMSELECT);
/* Enable weak pull-down resistor on DM */ /* Enable weak pull-down resistor on DM */
otg_io_write(isp->otg, ULPI_SET(ULPI_OTG_CTRL), isp1704_write(isp, ULPI_SET(ULPI_OTG_CTRL),
ULPI_OTG_CTRL_DM_PULLDOWN); ULPI_OTG_CTRL_DM_PULLDOWN);
/* It's a charger if the line states are clear */ /* It's a charger if the line states are clear */
if (!(otg_io_read(isp->otg, ULPI_DEBUG))) if (!(isp1704_read(isp, ULPI_DEBUG)))
ret = 1; ret = 1;
/* Disable weak pull-up resistor on DP */ /* Disable weak pull-up resistor on DP */
otg_io_write(isp->otg, ULPI_CLR(ISP1704_PWR_CTRL), isp1704_write(isp, ULPI_CLR(ISP1704_PWR_CTRL),
ISP1704_PWR_CTRL_DP_WKPU_EN); ISP1704_PWR_CTRL_DP_WKPU_EN);
return ret; return ret;
...@@ -193,14 +203,14 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) ...@@ -193,14 +203,14 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp)
u8 pwr_ctrl; u8 pwr_ctrl;
int ret = 0; int ret = 0;
pwr_ctrl = otg_io_read(isp->otg, ISP1704_PWR_CTRL); pwr_ctrl = isp1704_read(isp, ISP1704_PWR_CTRL);
/* set SW control bit in PWR_CTRL register */ /* set SW control bit in PWR_CTRL register */
otg_io_write(isp->otg, ISP1704_PWR_CTRL, isp1704_write(isp, ISP1704_PWR_CTRL,
ISP1704_PWR_CTRL_SWCTRL); ISP1704_PWR_CTRL_SWCTRL);
/* enable manual charger detection */ /* enable manual charger detection */
otg_io_write(isp->otg, ULPI_SET(ISP1704_PWR_CTRL), isp1704_write(isp, ULPI_SET(ISP1704_PWR_CTRL),
ISP1704_PWR_CTRL_SWCTRL ISP1704_PWR_CTRL_SWCTRL
| ISP1704_PWR_CTRL_DPVSRC_EN); | ISP1704_PWR_CTRL_DPVSRC_EN);
usleep_range(1000, 2000); usleep_range(1000, 2000);
...@@ -208,7 +218,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) ...@@ -208,7 +218,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp)
timeout = jiffies + msecs_to_jiffies(300); timeout = jiffies + msecs_to_jiffies(300);
do { do {
/* Check if there is a charger */ /* Check if there is a charger */
if (otg_io_read(isp->otg, ISP1704_PWR_CTRL) if (isp1704_read(isp, ISP1704_PWR_CTRL)
& ISP1704_PWR_CTRL_VDAT_DET) { & ISP1704_PWR_CTRL_VDAT_DET) {
ret = isp1704_charger_verify(isp); ret = isp1704_charger_verify(isp);
break; break;
...@@ -216,7 +226,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) ...@@ -216,7 +226,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp)
} while (!time_after(jiffies, timeout) && isp->online); } while (!time_after(jiffies, timeout) && isp->online);
/* recover original state */ /* recover original state */
otg_io_write(isp->otg, ISP1704_PWR_CTRL, pwr_ctrl); isp1704_write(isp, ISP1704_PWR_CTRL, pwr_ctrl);
return ret; return ret;
} }
...@@ -264,8 +274,8 @@ static void isp1704_charger_work(struct work_struct *data) ...@@ -264,8 +274,8 @@ static void isp1704_charger_work(struct work_struct *data)
case POWER_SUPPLY_TYPE_USB: case POWER_SUPPLY_TYPE_USB:
default: default:
/* enable data pullups */ /* enable data pullups */
if (isp->otg->gadget) if (isp->phy->otg->gadget)
usb_gadget_connect(isp->otg->gadget); usb_gadget_connect(isp->phy->otg->gadget);
} }
break; break;
case USB_EVENT_NONE: case USB_EVENT_NONE:
...@@ -283,8 +293,8 @@ static void isp1704_charger_work(struct work_struct *data) ...@@ -283,8 +293,8 @@ static void isp1704_charger_work(struct work_struct *data)
* chargers. The pullups may be enabled elsewhere, so this can * chargers. The pullups may be enabled elsewhere, so this can
* not be the final solution. * not be the final solution.
*/ */
if (isp->otg->gadget) if (isp->phy->otg->gadget)
usb_gadget_disconnect(isp->otg->gadget); usb_gadget_disconnect(isp->phy->otg->gadget);
isp1704_charger_set_power(isp, 0); isp1704_charger_set_power(isp, 0);
break; break;
...@@ -364,11 +374,11 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) ...@@ -364,11 +374,11 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp)
int ret = -ENODEV; int ret = -ENODEV;
/* Test ULPI interface */ /* Test ULPI interface */
ret = otg_io_write(isp->otg, ULPI_SCRATCH, 0xaa); ret = isp1704_write(isp, ULPI_SCRATCH, 0xaa);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = otg_io_read(isp->otg, ULPI_SCRATCH); ret = isp1704_read(isp, ULPI_SCRATCH);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -376,13 +386,13 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) ...@@ -376,13 +386,13 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp)
return -ENODEV; return -ENODEV;
/* Verify the product and vendor id matches */ /* Verify the product and vendor id matches */
vendor = otg_io_read(isp->otg, ULPI_VENDOR_ID_LOW); vendor = isp1704_read(isp, ULPI_VENDOR_ID_LOW);
vendor |= otg_io_read(isp->otg, ULPI_VENDOR_ID_HIGH) << 8; vendor |= isp1704_read(isp, ULPI_VENDOR_ID_HIGH) << 8;
if (vendor != NXP_VENDOR_ID) if (vendor != NXP_VENDOR_ID)
return -ENODEV; return -ENODEV;
product = otg_io_read(isp->otg, ULPI_PRODUCT_ID_LOW); product = isp1704_read(isp, ULPI_PRODUCT_ID_LOW);
product |= otg_io_read(isp->otg, ULPI_PRODUCT_ID_HIGH) << 8; product |= isp1704_read(isp, ULPI_PRODUCT_ID_HIGH) << 8;
for (i = 0; i < ARRAY_SIZE(isp170x_id); i++) { for (i = 0; i < ARRAY_SIZE(isp170x_id); i++) {
if (product == isp170x_id[i]) { if (product == isp170x_id[i]) {
...@@ -405,8 +415,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) ...@@ -405,8 +415,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
if (!isp) if (!isp)
return -ENOMEM; return -ENOMEM;
isp->otg = otg_get_transceiver(); isp->phy = usb_get_transceiver();
if (!isp->otg) if (!isp->phy)
goto fail0; goto fail0;
isp->dev = &pdev->dev; isp->dev = &pdev->dev;
...@@ -429,14 +439,14 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) ...@@ -429,14 +439,14 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
goto fail1; goto fail1;
/* /*
* REVISIT: using work in order to allow the otg notifications to be * REVISIT: using work in order to allow the usb notifications to be
* made atomically in the future. * made atomically in the future.
*/ */
INIT_WORK(&isp->work, isp1704_charger_work); INIT_WORK(&isp->work, isp1704_charger_work);
isp->nb.notifier_call = isp1704_notifier_call; isp->nb.notifier_call = isp1704_notifier_call;
ret = otg_register_notifier(isp->otg, &isp->nb); ret = usb_register_notifier(isp->phy, &isp->nb);
if (ret) if (ret)
goto fail2; goto fail2;
...@@ -449,13 +459,13 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) ...@@ -449,13 +459,13 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
* enumerated. The charger driver should be always loaded before any * enumerated. The charger driver should be always loaded before any
* gadget is loaded. * gadget is loaded.
*/ */
if (isp->otg->gadget) if (isp->phy->otg->gadget)
usb_gadget_disconnect(isp->otg->gadget); usb_gadget_disconnect(isp->phy->otg->gadget);
/* Detect charger if VBUS is valid (the cable was already plugged). */ /* Detect charger if VBUS is valid (the cable was already plugged). */
ret = otg_io_read(isp->otg, ULPI_USB_INT_STS); ret = isp1704_read(isp, ULPI_USB_INT_STS);
isp1704_charger_set_power(isp, 0); isp1704_charger_set_power(isp, 0);
if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) { if ((ret & ULPI_INT_VBUS_VALID) && !isp->phy->otg->default_a) {
isp->event = USB_EVENT_VBUS; isp->event = USB_EVENT_VBUS;
schedule_work(&isp->work); schedule_work(&isp->work);
} }
...@@ -464,7 +474,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) ...@@ -464,7 +474,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
fail2: fail2:
power_supply_unregister(&isp->psy); power_supply_unregister(&isp->psy);
fail1: fail1:
otg_put_transceiver(isp->otg); usb_put_transceiver(isp->phy);
fail0: fail0:
kfree(isp); kfree(isp);
...@@ -477,9 +487,9 @@ static int __devexit isp1704_charger_remove(struct platform_device *pdev) ...@@ -477,9 +487,9 @@ static int __devexit isp1704_charger_remove(struct platform_device *pdev)
{ {
struct isp1704_charger *isp = platform_get_drvdata(pdev); struct isp1704_charger *isp = platform_get_drvdata(pdev);
otg_unregister_notifier(isp->otg, &isp->nb); usb_unregister_notifier(isp->phy, &isp->nb);
power_supply_unregister(&isp->psy); power_supply_unregister(&isp->psy);
otg_put_transceiver(isp->otg); usb_put_transceiver(isp->phy);
isp1704_charger_set_power(isp, 0); isp1704_charger_set_power(isp, 0);
kfree(isp); kfree(isp);
......
...@@ -40,7 +40,7 @@ static struct timer_list polling_timer; ...@@ -40,7 +40,7 @@ static struct timer_list polling_timer;
static int polling; static int polling;
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
static struct otg_transceiver *transceiver; static struct usb_phy *transceiver;
static struct notifier_block otg_nb; static struct notifier_block otg_nb;
#endif #endif
...@@ -321,7 +321,7 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -321,7 +321,7 @@ static int pda_power_probe(struct platform_device *pdev)
} }
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
transceiver = otg_get_transceiver(); transceiver = usb_get_transceiver();
if (transceiver && !pdata->is_usb_online) { if (transceiver && !pdata->is_usb_online) {
pdata->is_usb_online = otg_is_usb_online; pdata->is_usb_online = otg_is_usb_online;
} }
...@@ -375,7 +375,7 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -375,7 +375,7 @@ static int pda_power_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (transceiver && pdata->use_otg_notifier) { if (transceiver && pdata->use_otg_notifier) {
otg_nb.notifier_call = otg_handle_notification; otg_nb.notifier_call = otg_handle_notification;
ret = otg_register_notifier(transceiver, &otg_nb); ret = usb_register_notifier(transceiver, &otg_nb);
if (ret) { if (ret) {
dev_err(dev, "failure to register otg notifier\n"); dev_err(dev, "failure to register otg notifier\n");
goto otg_reg_notifier_failed; goto otg_reg_notifier_failed;
...@@ -409,7 +409,7 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -409,7 +409,7 @@ static int pda_power_probe(struct platform_device *pdev)
free_irq(ac_irq->start, &pda_psy_ac); free_irq(ac_irq->start, &pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (transceiver) if (transceiver)
otg_put_transceiver(transceiver); usb_put_transceiver(transceiver);
#endif #endif
ac_irq_failed: ac_irq_failed:
if (pdata->is_ac_online) if (pdata->is_ac_online)
...@@ -444,7 +444,7 @@ static int pda_power_remove(struct platform_device *pdev) ...@@ -444,7 +444,7 @@ static int pda_power_remove(struct platform_device *pdev)
power_supply_unregister(&pda_psy_ac); power_supply_unregister(&pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (transceiver) if (transceiver)
otg_put_transceiver(transceiver); usb_put_transceiver(transceiver);
#endif #endif
if (ac_draw) { if (ac_draw) {
regulator_put(ac_draw); regulator_put(ac_draw);
......
...@@ -69,8 +69,8 @@ struct twl4030_bci { ...@@ -69,8 +69,8 @@ struct twl4030_bci {
struct device *dev; struct device *dev;
struct power_supply ac; struct power_supply ac;
struct power_supply usb; struct power_supply usb;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
struct notifier_block otg_nb; struct notifier_block usb_nb;
struct work_struct work; struct work_struct work;
int irq_chg; int irq_chg;
int irq_bci; int irq_bci;
...@@ -279,7 +279,7 @@ static void twl4030_bci_usb_work(struct work_struct *data) ...@@ -279,7 +279,7 @@ static void twl4030_bci_usb_work(struct work_struct *data)
static int twl4030_bci_usb_ncb(struct notifier_block *nb, unsigned long val, static int twl4030_bci_usb_ncb(struct notifier_block *nb, unsigned long val,
void *priv) void *priv)
{ {
struct twl4030_bci *bci = container_of(nb, struct twl4030_bci, otg_nb); struct twl4030_bci *bci = container_of(nb, struct twl4030_bci, usb_nb);
dev_dbg(bci->dev, "OTG notify %lu\n", val); dev_dbg(bci->dev, "OTG notify %lu\n", val);
...@@ -479,10 +479,10 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) ...@@ -479,10 +479,10 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
INIT_WORK(&bci->work, twl4030_bci_usb_work); INIT_WORK(&bci->work, twl4030_bci_usb_work);
bci->transceiver = otg_get_transceiver(); bci->transceiver = usb_get_transceiver();
if (bci->transceiver != NULL) { if (bci->transceiver != NULL) {
bci->otg_nb.notifier_call = twl4030_bci_usb_ncb; bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
otg_register_notifier(bci->transceiver, &bci->otg_nb); usb_register_notifier(bci->transceiver, &bci->usb_nb);
} }
/* Enable interrupts now. */ /* Enable interrupts now. */
...@@ -508,8 +508,8 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) ...@@ -508,8 +508,8 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
fail_unmask_interrupts: fail_unmask_interrupts:
if (bci->transceiver != NULL) { if (bci->transceiver != NULL) {
otg_unregister_notifier(bci->transceiver, &bci->otg_nb); usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
otg_put_transceiver(bci->transceiver); usb_put_transceiver(bci->transceiver);
} }
free_irq(bci->irq_bci, bci); free_irq(bci->irq_bci, bci);
fail_bci_irq: fail_bci_irq:
...@@ -539,8 +539,8 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev) ...@@ -539,8 +539,8 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
TWL4030_INTERRUPTS_BCIIMR2A); TWL4030_INTERRUPTS_BCIIMR2A);
if (bci->transceiver != NULL) { if (bci->transceiver != NULL) {
otg_unregister_notifier(bci->transceiver, &bci->otg_nb); usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
otg_put_transceiver(bci->transceiver); usb_put_transceiver(bci->transceiver);
} }
free_irq(bci->irq_bci, bci); free_irq(bci->irq_bci, bci);
free_irq(bci->irq_chg, bci); free_irq(bci->irq_chg, bci);
......
...@@ -37,10 +37,10 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event) ...@@ -37,10 +37,10 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
* Put the transceiver in non-driving mode. Otherwise host * Put the transceiver in non-driving mode. Otherwise host
* may not detect soft-disconnection. * may not detect soft-disconnection.
*/ */
val = otg_io_read(udc->transceiver, ULPI_FUNC_CTRL); val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL);
val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
otg_io_write(udc->transceiver, val, ULPI_FUNC_CTRL); usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL);
break; break;
default: default:
dev_dbg(dev, "unknown ci13xxx_udc event\n"); dev_dbg(dev, "unknown ci13xxx_udc event\n");
......
...@@ -2537,7 +2537,7 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -2537,7 +2537,7 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
struct ci13xxx *udc = container_of(_gadget, struct ci13xxx, gadget); struct ci13xxx *udc = container_of(_gadget, struct ci13xxx, gadget);
if (udc->transceiver) if (udc->transceiver)
return otg_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -2900,7 +2900,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2900,7 +2900,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
if (retval < 0) if (retval < 0)
goto free_udc; goto free_udc;
udc->transceiver = otg_get_transceiver(); udc->transceiver = usb_get_transceiver();
if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) { if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (udc->transceiver == NULL) { if (udc->transceiver == NULL) {
...@@ -2928,7 +2928,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2928,7 +2928,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
goto unreg_device; goto unreg_device;
if (udc->transceiver) { if (udc->transceiver) {
retval = otg_set_peripheral(udc->transceiver, &udc->gadget); retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget);
if (retval) if (retval)
goto remove_dbg; goto remove_dbg;
} }
...@@ -2945,8 +2946,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2945,8 +2946,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
remove_trans: remove_trans:
if (udc->transceiver) { if (udc->transceiver) {
otg_set_peripheral(udc->transceiver, &udc->gadget); otg_set_peripheral(udc->transceiver->otg, &udc->gadget);
otg_put_transceiver(udc->transceiver); usb_put_transceiver(udc->transceiver);
} }
err("error = %i", retval); err("error = %i", retval);
...@@ -2958,7 +2959,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2958,7 +2959,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
device_unregister(&udc->gadget.dev); device_unregister(&udc->gadget.dev);
put_transceiver: put_transceiver:
if (udc->transceiver) if (udc->transceiver)
otg_put_transceiver(udc->transceiver); usb_put_transceiver(udc->transceiver);
free_udc: free_udc:
kfree(udc); kfree(udc);
_udc = NULL; _udc = NULL;
...@@ -2981,8 +2982,8 @@ static void udc_remove(void) ...@@ -2981,8 +2982,8 @@ static void udc_remove(void)
usb_del_gadget_udc(&udc->gadget); usb_del_gadget_udc(&udc->gadget);
if (udc->transceiver) { if (udc->transceiver) {
otg_set_peripheral(udc->transceiver, &udc->gadget); otg_set_peripheral(udc->transceiver->otg, &udc->gadget);
otg_put_transceiver(udc->transceiver); usb_put_transceiver(udc->transceiver);
} }
#ifdef CONFIG_USB_GADGET_DEBUG_FILES #ifdef CONFIG_USB_GADGET_DEBUG_FILES
dbg_remove_files(&udc->gadget.dev); dbg_remove_files(&udc->gadget.dev);
......
...@@ -136,7 +136,7 @@ struct ci13xxx { ...@@ -136,7 +136,7 @@ struct ci13xxx {
struct usb_gadget_driver *driver; /* 3rd party gadget driver */ struct usb_gadget_driver *driver; /* 3rd party gadget driver */
struct ci13xxx_udc_driver *udc_driver; /* device controller driver */ struct ci13xxx_udc_driver *udc_driver; /* device controller driver */
int vbus_active; /* is VBUS active */ int vbus_active; /* is VBUS active */
struct otg_transceiver *transceiver; /* Transceiver struct */ struct usb_phy *transceiver; /* Transceiver struct */
}; };
/****************************************************************************** /******************************************************************************
......
...@@ -1217,7 +1217,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1217,7 +1217,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
udc = container_of(gadget, struct fsl_udc, gadget); udc = container_of(gadget, struct fsl_udc, gadget);
if (udc->transceiver) if (udc->transceiver)
return otg_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -1966,7 +1966,8 @@ static int fsl_start(struct usb_gadget_driver *driver, ...@@ -1966,7 +1966,8 @@ static int fsl_start(struct usb_gadget_driver *driver,
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (udc_controller->transceiver) { if (udc_controller->transceiver) {
retval = otg_set_peripheral(udc_controller->transceiver, retval = otg_set_peripheral(
udc_controller->transceiver->otg,
&udc_controller->gadget); &udc_controller->gadget);
if (retval < 0) { if (retval < 0) {
ERR("can't bind to transceiver\n"); ERR("can't bind to transceiver\n");
...@@ -2006,7 +2007,7 @@ static int fsl_stop(struct usb_gadget_driver *driver) ...@@ -2006,7 +2007,7 @@ static int fsl_stop(struct usb_gadget_driver *driver)
return -EINVAL; return -EINVAL;
if (udc_controller->transceiver) if (udc_controller->transceiver)
otg_set_peripheral(udc_controller->transceiver, NULL); otg_set_peripheral(udc_controller->transceiver->otg, NULL);
/* stop DR, disable intr */ /* stop DR, disable intr */
dr_controller_stop(udc_controller); dr_controller_stop(udc_controller);
...@@ -2430,7 +2431,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) ...@@ -2430,7 +2431,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
if (pdata->operating_mode == FSL_USB2_DR_OTG) { if (pdata->operating_mode == FSL_USB2_DR_OTG) {
udc_controller->transceiver = otg_get_transceiver(); udc_controller->transceiver = usb_get_transceiver();
if (!udc_controller->transceiver) { if (!udc_controller->transceiver) {
ERR("Can't find OTG driver!\n"); ERR("Can't find OTG driver!\n");
ret = -ENODEV; ret = -ENODEV;
......
...@@ -471,7 +471,7 @@ struct fsl_udc { ...@@ -471,7 +471,7 @@ struct fsl_udc {
struct usb_ctrlrequest local_setup_buff; struct usb_ctrlrequest local_setup_buff;
spinlock_t lock; spinlock_t lock;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
unsigned softconnect:1; unsigned softconnect:1;
unsigned vbus_active:1; unsigned vbus_active:1;
unsigned stopped:1; unsigned stopped:1;
......
...@@ -1261,9 +1261,9 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -1261,9 +1261,9 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->transceiver) { if (dev->transceiver) {
dev_vdbg(&dev->pdev->dev, "otg_set_power\n"); dev_vdbg(&dev->pdev->dev, "usb_phy_set_power\n");
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return otg_set_power(dev->transceiver, mA); return usb_phy_set_power(dev->transceiver, mA);
} }
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
...@@ -1906,7 +1906,7 @@ static int langwell_stop(struct usb_gadget *g, ...@@ -1906,7 +1906,7 @@ static int langwell_stop(struct usb_gadget *g,
/* unbind OTG transceiver */ /* unbind OTG transceiver */
if (dev->transceiver) if (dev->transceiver)
(void)otg_set_peripheral(dev->transceiver, 0); (void)otg_set_peripheral(dev->transceiver->otg, 0);
/* disable interrupt and set controller to stop state */ /* disable interrupt and set controller to stop state */
langwell_udc_stop(dev); langwell_udc_stop(dev);
......
...@@ -162,7 +162,7 @@ struct langwell_udc { ...@@ -162,7 +162,7 @@ struct langwell_udc {
spinlock_t lock; /* device lock */ spinlock_t lock; /* device lock */
struct langwell_ep *ep; struct langwell_ep *ep;
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
u8 dev_addr; u8 dev_addr;
u32 usb_state; u32 usb_state;
u32 resume_state; u32 resume_state;
......
...@@ -217,7 +217,7 @@ struct mv_udc { ...@@ -217,7 +217,7 @@ struct mv_udc {
struct work_struct vbus_work; struct work_struct vbus_work;
struct workqueue_struct *qwork; struct workqueue_struct *qwork;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
struct mv_usb_platform_data *pdata; struct mv_usb_platform_data *pdata;
......
...@@ -1384,7 +1384,8 @@ static int mv_udc_start(struct usb_gadget_driver *driver, ...@@ -1384,7 +1384,8 @@ static int mv_udc_start(struct usb_gadget_driver *driver,
} }
if (udc->transceiver) { if (udc->transceiver) {
retval = otg_set_peripheral(udc->transceiver, &udc->gadget); retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget);
if (retval) { if (retval) {
dev_err(&udc->dev->dev, dev_err(&udc->dev->dev,
"unable to register peripheral to otg\n"); "unable to register peripheral to otg\n");
...@@ -2181,7 +2182,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev) ...@@ -2181,7 +2182,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (pdata->mode == MV_USB_MODE_OTG) if (pdata->mode == MV_USB_MODE_OTG)
udc->transceiver = otg_get_transceiver(); udc->transceiver = usb_get_transceiver();
#endif #endif
udc->clknum = pdata->clknum; udc->clknum = pdata->clknum;
......
...@@ -1213,7 +1213,7 @@ static int omap_wakeup(struct usb_gadget *gadget) ...@@ -1213,7 +1213,7 @@ static int omap_wakeup(struct usb_gadget *gadget)
/* NOTE: non-OTG systems may use SRP TOO... */ /* NOTE: non-OTG systems may use SRP TOO... */
} else if (!(udc->devstat & UDC_ATT)) { } else if (!(udc->devstat & UDC_ATT)) {
if (udc->transceiver) if (udc->transceiver)
retval = otg_start_srp(udc->transceiver); retval = otg_start_srp(udc->transceiver->otg);
} }
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
...@@ -1345,7 +1345,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1345,7 +1345,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA)
udc = container_of(gadget, struct omap_udc, gadget); udc = container_of(gadget, struct omap_udc, gadget);
if (udc->transceiver) if (udc->transceiver)
return otg_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1839,11 +1839,13 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) ...@@ -1839,11 +1839,13 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
spin_lock(&udc->lock); spin_lock(&udc->lock);
} }
if (udc->transceiver) if (udc->transceiver)
otg_set_suspend(udc->transceiver, 1); usb_phy_set_suspend(
udc->transceiver, 1);
} else { } else {
VDBG("resume\n"); VDBG("resume\n");
if (udc->transceiver) if (udc->transceiver)
otg_set_suspend(udc->transceiver, 0); usb_phy_set_suspend(
udc->transceiver, 0);
if (udc->gadget.speed == USB_SPEED_FULL if (udc->gadget.speed == USB_SPEED_FULL
&& udc->driver->resume) { && udc->driver->resume) {
spin_unlock(&udc->lock); spin_unlock(&udc->lock);
...@@ -2154,7 +2156,8 @@ static int omap_udc_start(struct usb_gadget_driver *driver, ...@@ -2154,7 +2156,8 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (udc->transceiver) { if (udc->transceiver) {
status = otg_set_peripheral(udc->transceiver, &udc->gadget); status = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget);
if (status < 0) { if (status < 0) {
ERR("can't bind to transceiver\n"); ERR("can't bind to transceiver\n");
if (driver->unbind) { if (driver->unbind) {
...@@ -2200,7 +2203,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) ...@@ -2200,7 +2203,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver)
omap_vbus_session(&udc->gadget, 0); omap_vbus_session(&udc->gadget, 0);
if (udc->transceiver) if (udc->transceiver)
(void) otg_set_peripheral(udc->transceiver, NULL); (void) otg_set_peripheral(udc->transceiver->otg, NULL);
else else
pullup_disable(udc); pullup_disable(udc);
...@@ -2650,7 +2653,7 @@ static void omap_udc_release(struct device *dev) ...@@ -2650,7 +2653,7 @@ static void omap_udc_release(struct device *dev)
} }
static int __init static int __init
omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv) omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
{ {
unsigned tmp, buf; unsigned tmp, buf;
...@@ -2790,7 +2793,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) ...@@ -2790,7 +2793,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
{ {
int status = -ENODEV; int status = -ENODEV;
int hmc; int hmc;
struct otg_transceiver *xceiv = NULL; struct usb_phy *xceiv = NULL;
const char *type = NULL; const char *type = NULL;
struct omap_usb_config *config = pdev->dev.platform_data; struct omap_usb_config *config = pdev->dev.platform_data;
struct clk *dc_clk; struct clk *dc_clk;
...@@ -2863,7 +2866,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) ...@@ -2863,7 +2866,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
* use it. Except for OTG, we don't _need_ to talk to one; * use it. Except for OTG, we don't _need_ to talk to one;
* but not having one probably means no VBUS detection. * but not having one probably means no VBUS detection.
*/ */
xceiv = otg_get_transceiver(); xceiv = usb_get_transceiver();
if (xceiv) if (xceiv)
type = xceiv->label; type = xceiv->label;
else if (config->otg) { else if (config->otg) {
...@@ -3009,7 +3012,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) ...@@ -3009,7 +3012,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
cleanup0: cleanup0:
if (xceiv) if (xceiv)
otg_put_transceiver(xceiv); usb_put_transceiver(xceiv);
if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) { if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) {
clk_disable(hhc_clk); clk_disable(hhc_clk);
...@@ -3039,7 +3042,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev) ...@@ -3039,7 +3042,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev)
pullup_disable(udc); pullup_disable(udc);
if (udc->transceiver) { if (udc->transceiver) {
otg_put_transceiver(udc->transceiver); usb_put_transceiver(udc->transceiver);
udc->transceiver = NULL; udc->transceiver = NULL;
} }
omap_writew(0, UDC_SYSCON1); omap_writew(0, UDC_SYSCON1);
......
...@@ -164,7 +164,7 @@ struct omap_udc { ...@@ -164,7 +164,7 @@ struct omap_udc {
struct omap_ep ep[32]; struct omap_ep ep[32];
u16 devstat; u16 devstat;
u16 clr_halt; u16 clr_halt;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
struct list_head iso; struct list_head iso;
unsigned softconnect:1; unsigned softconnect:1;
unsigned vbus_active:1; unsigned vbus_active:1;
......
...@@ -995,7 +995,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -995,7 +995,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
udc = container_of(_gadget, struct pxa25x_udc, gadget); udc = container_of(_gadget, struct pxa25x_udc, gadget);
if (udc->transceiver) if (udc->transceiver)
return otg_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1301,7 +1301,8 @@ static int pxa25x_start(struct usb_gadget_driver *driver, ...@@ -1301,7 +1301,8 @@ static int pxa25x_start(struct usb_gadget_driver *driver,
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (dev->transceiver) { if (dev->transceiver) {
retval = otg_set_peripheral(dev->transceiver, &dev->gadget); retval = otg_set_peripheral(dev->transceiver->otg,
&dev->gadget);
if (retval) { if (retval) {
DMSG("can't bind to transceiver\n"); DMSG("can't bind to transceiver\n");
if (driver->unbind) if (driver->unbind)
...@@ -1360,7 +1361,7 @@ static int pxa25x_stop(struct usb_gadget_driver *driver) ...@@ -1360,7 +1361,7 @@ static int pxa25x_stop(struct usb_gadget_driver *driver)
local_irq_enable(); local_irq_enable();
if (dev->transceiver) if (dev->transceiver)
(void) otg_set_peripheral(dev->transceiver, NULL); (void) otg_set_peripheral(dev->transceiver->otg, NULL);
driver->unbind(&dev->gadget); driver->unbind(&dev->gadget);
dev->gadget.dev.driver = NULL; dev->gadget.dev.driver = NULL;
...@@ -2159,7 +2160,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) ...@@ -2159,7 +2160,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->mach = pdev->dev.platform_data; dev->mach = pdev->dev.platform_data;
dev->transceiver = otg_get_transceiver(); dev->transceiver = usb_get_transceiver();
if (gpio_is_valid(dev->mach->gpio_pullup)) { if (gpio_is_valid(dev->mach->gpio_pullup)) {
if ((retval = gpio_request(dev->mach->gpio_pullup, if ((retval = gpio_request(dev->mach->gpio_pullup,
...@@ -2238,7 +2239,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) ...@@ -2238,7 +2239,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
gpio_free(dev->mach->gpio_pullup); gpio_free(dev->mach->gpio_pullup);
err_gpio_pullup: err_gpio_pullup:
if (dev->transceiver) { if (dev->transceiver) {
otg_put_transceiver(dev->transceiver); usb_put_transceiver(dev->transceiver);
dev->transceiver = NULL; dev->transceiver = NULL;
} }
clk_put(dev->clk); clk_put(dev->clk);
...@@ -2280,7 +2281,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev) ...@@ -2280,7 +2281,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev)
clk_put(dev->clk); clk_put(dev->clk);
if (dev->transceiver) { if (dev->transceiver) {
otg_put_transceiver(dev->transceiver); usb_put_transceiver(dev->transceiver);
dev->transceiver = NULL; dev->transceiver = NULL;
} }
......
...@@ -119,7 +119,7 @@ struct pxa25x_udc { ...@@ -119,7 +119,7 @@ struct pxa25x_udc {
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
struct pxa2xx_udc_mach_info *mach; struct pxa2xx_udc_mach_info *mach;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
u64 dma_mask; u64 dma_mask;
struct pxa25x_ep ep [PXA_UDC_NUM_ENDPOINTS]; struct pxa25x_ep ep [PXA_UDC_NUM_ENDPOINTS];
......
...@@ -1666,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -1666,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
udc = to_gadget_udc(_gadget); udc = to_gadget_udc(_gadget);
if (udc->transceiver) if (udc->transceiver)
return otg_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1835,7 +1835,8 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, ...@@ -1835,7 +1835,8 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
driver->driver.name); driver->driver.name);
if (udc->transceiver) { if (udc->transceiver) {
retval = otg_set_peripheral(udc->transceiver, &udc->gadget); retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget);
if (retval) { if (retval) {
dev_err(udc->dev, "can't bind to transceiver\n"); dev_err(udc->dev, "can't bind to transceiver\n");
goto transceiver_fail; goto transceiver_fail;
...@@ -1908,7 +1909,7 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver) ...@@ -1908,7 +1909,7 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver)
driver->driver.name); driver->driver.name);
if (udc->transceiver) if (udc->transceiver)
return otg_set_peripheral(udc->transceiver, NULL); return otg_set_peripheral(udc->transceiver->otg, NULL);
return 0; return 0;
} }
...@@ -2463,7 +2464,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) ...@@ -2463,7 +2464,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
udc->dev = &pdev->dev; udc->dev = &pdev->dev;
udc->mach = pdev->dev.platform_data; udc->mach = pdev->dev.platform_data;
udc->transceiver = otg_get_transceiver(); udc->transceiver = usb_get_transceiver();
gpio = udc->mach->gpio_pullup; gpio = udc->mach->gpio_pullup;
if (gpio_is_valid(gpio)) { if (gpio_is_valid(gpio)) {
...@@ -2542,7 +2543,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev) ...@@ -2542,7 +2543,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev)
if (gpio_is_valid(gpio)) if (gpio_is_valid(gpio))
gpio_free(gpio); gpio_free(gpio);
otg_put_transceiver(udc->transceiver); usb_put_transceiver(udc->transceiver);
udc->transceiver = NULL; udc->transceiver = NULL;
platform_set_drvdata(_dev, NULL); platform_set_drvdata(_dev, NULL);
......
...@@ -447,7 +447,7 @@ struct pxa_udc { ...@@ -447,7 +447,7 @@ struct pxa_udc {
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
struct device *dev; struct device *dev;
struct pxa2xx_udc_mach_info *mach; struct pxa2xx_udc_mach_info *mach;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
enum ep0_state ep0state; enum ep0_state ep0state;
struct udc_stats stats; struct udc_stats stats;
......
...@@ -145,7 +145,7 @@ struct s3c_hsudc { ...@@ -145,7 +145,7 @@ struct s3c_hsudc {
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
struct device *dev; struct device *dev;
struct s3c24xx_hsudc_platdata *pd; struct s3c24xx_hsudc_platdata *pd;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)];
spinlock_t lock; spinlock_t lock;
void __iomem *regs; void __iomem *regs;
...@@ -1166,7 +1166,8 @@ static int s3c_hsudc_start(struct usb_gadget *gadget, ...@@ -1166,7 +1166,8 @@ static int s3c_hsudc_start(struct usb_gadget *gadget,
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (hsudc->transceiver) { if (hsudc->transceiver) {
ret = otg_set_peripheral(hsudc->transceiver, &hsudc->gadget); ret = otg_set_peripheral(hsudc->transceiver->otg,
&hsudc->gadget);
if (ret) { if (ret) {
dev_err(hsudc->dev, "%s: can't bind to transceiver\n", dev_err(hsudc->dev, "%s: can't bind to transceiver\n",
hsudc->gadget.name); hsudc->gadget.name);
...@@ -1214,7 +1215,7 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget, ...@@ -1214,7 +1215,7 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget,
spin_unlock_irqrestore(&hsudc->lock, flags); spin_unlock_irqrestore(&hsudc->lock, flags);
if (hsudc->transceiver) if (hsudc->transceiver)
(void) otg_set_peripheral(hsudc->transceiver, NULL); (void) otg_set_peripheral(hsudc->transceiver->otg, NULL);
disable_irq(hsudc->irq); disable_irq(hsudc->irq);
...@@ -1243,7 +1244,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1243,7 +1244,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA)
return -ENODEV; return -ENODEV;
if (hsudc->transceiver) if (hsudc->transceiver)
return otg_set_power(hsudc->transceiver, mA); return usb_phy_set_power(hsudc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1275,7 +1276,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1275,7 +1276,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
hsudc->dev = dev; hsudc->dev = dev;
hsudc->pd = pdev->dev.platform_data; hsudc->pd = pdev->dev.platform_data;
hsudc->transceiver = otg_get_transceiver(); hsudc->transceiver = usb_get_transceiver();
for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++) for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++)
hsudc->supplies[i].supply = s3c_hsudc_supply_names[i]; hsudc->supplies[i].supply = s3c_hsudc_supply_names[i];
...@@ -1377,7 +1378,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1377,7 +1378,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
err_res: err_res:
if (hsudc->transceiver) if (hsudc->transceiver)
otg_put_transceiver(hsudc->transceiver); usb_put_transceiver(hsudc->transceiver);
regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies);
err_supplies: err_supplies:
......
...@@ -142,12 +142,12 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver, ...@@ -142,12 +142,12 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
if (pdata->operating_mode == FSL_USB2_DR_OTG) { if (pdata->operating_mode == FSL_USB2_DR_OTG) {
struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct ehci_hcd *ehci = hcd_to_ehci(hcd);
ehci->transceiver = otg_get_transceiver(); ehci->transceiver = usb_get_transceiver();
dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n",
hcd, ehci, ehci->transceiver); hcd, ehci, ehci->transceiver);
if (ehci->transceiver) { if (ehci->transceiver) {
retval = otg_set_host(ehci->transceiver, retval = otg_set_host(ehci->transceiver->otg,
&ehci_to_hcd(ehci)->self); &ehci_to_hcd(ehci)->self);
if (retval) { if (retval) {
if (ehci->transceiver) if (ehci->transceiver)
...@@ -194,7 +194,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd, ...@@ -194,7 +194,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct ehci_hcd *ehci = hcd_to_ehci(hcd);
if (ehci->transceiver) { if (ehci->transceiver) {
otg_set_host(ehci->transceiver, NULL); otg_set_host(ehci->transceiver->otg, NULL);
put_device(ehci->transceiver->dev); put_device(ehci->transceiver->dev);
} }
......
...@@ -727,7 +727,7 @@ static int ehci_hub_control ( ...@@ -727,7 +727,7 @@ static int ehci_hub_control (
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
if ((hcd->self.otg_port == (wIndex + 1)) if ((hcd->self.otg_port == (wIndex + 1))
&& hcd->self.b_hnp_enable) { && hcd->self.b_hnp_enable) {
otg_start_hnp(ehci->transceiver); otg_start_hnp(ehci->transceiver->otg);
break; break;
} }
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define MSM_USB_BASE (hcd->regs) #define MSM_USB_BASE (hcd->regs)
static struct otg_transceiver *otg; static struct usb_phy *phy;
static int ehci_msm_reset(struct usb_hcd *hcd) static int ehci_msm_reset(struct usb_hcd *hcd)
{ {
...@@ -145,14 +145,14 @@ static int ehci_msm_probe(struct platform_device *pdev) ...@@ -145,14 +145,14 @@ static int ehci_msm_probe(struct platform_device *pdev)
* powering up VBUS, mapping of registers address space and power * powering up VBUS, mapping of registers address space and power
* management. * management.
*/ */
otg = otg_get_transceiver(); phy = usb_get_transceiver();
if (!otg) { if (!phy) {
dev_err(&pdev->dev, "unable to find transceiver\n"); dev_err(&pdev->dev, "unable to find transceiver\n");
ret = -ENODEV; ret = -ENODEV;
goto unmap; goto unmap;
} }
ret = otg_set_host(otg, &hcd->self); ret = otg_set_host(phy->otg, &hcd->self);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "unable to register with transceiver\n"); dev_err(&pdev->dev, "unable to register with transceiver\n");
goto put_transceiver; goto put_transceiver;
...@@ -169,7 +169,7 @@ static int ehci_msm_probe(struct platform_device *pdev) ...@@ -169,7 +169,7 @@ static int ehci_msm_probe(struct platform_device *pdev)
return 0; return 0;
put_transceiver: put_transceiver:
otg_put_transceiver(otg); usb_put_transceiver(phy);
unmap: unmap:
iounmap(hcd->regs); iounmap(hcd->regs);
put_hcd: put_hcd:
...@@ -186,8 +186,8 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev) ...@@ -186,8 +186,8 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
otg_set_host(otg, NULL); otg_set_host(phy->otg, NULL);
otg_put_transceiver(otg); usb_put_transceiver(phy);
usb_put_hcd(hcd); usb_put_hcd(hcd);
......
...@@ -28,7 +28,7 @@ struct ehci_hcd_mv { ...@@ -28,7 +28,7 @@ struct ehci_hcd_mv {
void __iomem *cap_regs; void __iomem *cap_regs;
void __iomem *op_regs; void __iomem *op_regs;
struct otg_transceiver *otg; struct usb_phy *otg;
struct mv_usb_platform_data *pdata; struct mv_usb_platform_data *pdata;
...@@ -253,7 +253,7 @@ static int mv_ehci_probe(struct platform_device *pdev) ...@@ -253,7 +253,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
ehci_mv->mode = pdata->mode; ehci_mv->mode = pdata->mode;
if (ehci_mv->mode == MV_USB_MODE_OTG) { if (ehci_mv->mode == MV_USB_MODE_OTG) {
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
ehci_mv->otg = otg_get_transceiver(); ehci_mv->otg = usb_get_transceiver();
if (!ehci_mv->otg) { if (!ehci_mv->otg) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"unable to find transceiver\n"); "unable to find transceiver\n");
...@@ -261,7 +261,7 @@ static int mv_ehci_probe(struct platform_device *pdev) ...@@ -261,7 +261,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
goto err_disable_clk; goto err_disable_clk;
} }
retval = otg_set_host(ehci_mv->otg, &hcd->self); retval = otg_set_host(ehci_mv->otg->otg, &hcd->self);
if (retval < 0) { if (retval < 0) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"unable to register with transceiver\n"); "unable to register with transceiver\n");
...@@ -303,7 +303,7 @@ static int mv_ehci_probe(struct platform_device *pdev) ...@@ -303,7 +303,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
err_put_transceiver: err_put_transceiver:
if (ehci_mv->otg) if (ehci_mv->otg)
otg_put_transceiver(ehci_mv->otg); usb_put_transceiver(ehci_mv->otg);
#endif #endif
err_disable_clk: err_disable_clk:
mv_ehci_disable(ehci_mv); mv_ehci_disable(ehci_mv);
...@@ -332,8 +332,8 @@ static int mv_ehci_remove(struct platform_device *pdev) ...@@ -332,8 +332,8 @@ static int mv_ehci_remove(struct platform_device *pdev)
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
if (ehci_mv->otg) { if (ehci_mv->otg) {
otg_set_host(ehci_mv->otg, NULL); otg_set_host(ehci_mv->otg->otg, NULL);
otg_put_transceiver(ehci_mv->otg); usb_put_transceiver(ehci_mv->otg);
} }
if (ehci_mv->mode == MV_USB_MODE_HOST) { if (ehci_mv->mode == MV_USB_MODE_HOST) {
......
...@@ -220,13 +220,13 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) ...@@ -220,13 +220,13 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
/* Initialize the transceiver */ /* Initialize the transceiver */
if (pdata->otg) { if (pdata->otg) {
pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET;
ret = otg_init(pdata->otg); ret = usb_phy_init(pdata->otg);
if (ret) { if (ret) {
dev_err(dev, "unable to init transceiver, probably missing\n"); dev_err(dev, "unable to init transceiver, probably missing\n");
ret = -ENODEV; ret = -ENODEV;
goto err_add; goto err_add;
} }
ret = otg_set_vbus(pdata->otg, 1); ret = otg_set_vbus(pdata->otg->otg, 1);
if (ret) { if (ret) {
dev_err(dev, "unable to enable vbus on transceiver\n"); dev_err(dev, "unable to enable vbus on transceiver\n");
goto err_add; goto err_add;
...@@ -247,9 +247,11 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) ...@@ -247,9 +247,11 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
* It's in violation of USB specs * It's in violation of USB specs
*/ */
if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) { if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL); flags = usb_phy_io_read(pdata->otg,
ULPI_OTG_CTRL);
flags |= ULPI_OTG_CTRL_CHRGVBUS; flags |= ULPI_OTG_CTRL_CHRGVBUS;
ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL); ret = usb_phy_io_write(pdata->otg, flags,
ULPI_OTG_CTRL);
if (ret) { if (ret) {
dev_err(dev, "unable to set CHRVBUS\n"); dev_err(dev, "unable to set CHRVBUS\n");
goto err_add; goto err_add;
...@@ -297,7 +299,7 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev) ...@@ -297,7 +299,7 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
pdata->exit(pdev); pdata->exit(pdev);
if (pdata->otg) if (pdata->otg)
otg_shutdown(pdata->otg); usb_phy_shutdown(pdata->otg);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap(hcd->regs); iounmap(hcd->regs);
......
...@@ -35,7 +35,7 @@ struct tegra_ehci_hcd { ...@@ -35,7 +35,7 @@ struct tegra_ehci_hcd {
struct tegra_usb_phy *phy; struct tegra_usb_phy *phy;
struct clk *clk; struct clk *clk;
struct clk *emc_clk; struct clk *emc_clk;
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
int host_resumed; int host_resumed;
int bus_suspended; int bus_suspended;
int port_resuming; int port_resuming;
...@@ -733,9 +733,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -733,9 +733,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (pdata->operating_mode == TEGRA_USB_OTG) { if (pdata->operating_mode == TEGRA_USB_OTG) {
tegra->transceiver = otg_get_transceiver(); tegra->transceiver = usb_get_transceiver();
if (tegra->transceiver) if (tegra->transceiver)
otg_set_host(tegra->transceiver, &hcd->self); otg_set_host(tegra->transceiver->otg, &hcd->self);
} }
#endif #endif
...@@ -750,8 +750,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -750,8 +750,8 @@ static int tegra_ehci_probe(struct platform_device *pdev)
fail: fail:
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (tegra->transceiver) { if (tegra->transceiver) {
otg_set_host(tegra->transceiver, NULL); otg_set_host(tegra->transceiver->otg, NULL);
otg_put_transceiver(tegra->transceiver); usb_put_transceiver(tegra->transceiver);
} }
#endif #endif
tegra_usb_phy_close(tegra->phy); tegra_usb_phy_close(tegra->phy);
...@@ -808,8 +808,8 @@ static int tegra_ehci_remove(struct platform_device *pdev) ...@@ -808,8 +808,8 @@ static int tegra_ehci_remove(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (tegra->transceiver) { if (tegra->transceiver) {
otg_set_host(tegra->transceiver, NULL); otg_set_host(tegra->transceiver->otg, NULL);
otg_put_transceiver(tegra->transceiver); usb_put_transceiver(tegra->transceiver);
} }
#endif #endif
......
...@@ -176,7 +176,7 @@ struct ehci_hcd { /* one per controller */ ...@@ -176,7 +176,7 @@ struct ehci_hcd { /* one per controller */
/* /*
* OTG controllers and transceivers need software interaction * OTG controllers and transceivers need software interaction
*/ */
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
}; };
/* convert between an HCD pointer and the corresponding EHCI_HCD */ /* convert between an HCD pointer and the corresponding EHCI_HCD */
......
...@@ -171,7 +171,7 @@ static void start_hnp(struct ohci_hcd *ohci) ...@@ -171,7 +171,7 @@ static void start_hnp(struct ohci_hcd *ohci)
unsigned long flags; unsigned long flags;
u32 l; u32 l;
otg_start_hnp(ohci->transceiver); otg_start_hnp(ohci->transceiver->otg);
local_irq_save(flags); local_irq_save(flags);
ohci->transceiver->state = OTG_STATE_A_SUSPEND; ohci->transceiver->state = OTG_STATE_A_SUSPEND;
...@@ -210,9 +210,9 @@ static int ohci_omap_init(struct usb_hcd *hcd) ...@@ -210,9 +210,9 @@ static int ohci_omap_init(struct usb_hcd *hcd)
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
if (need_transceiver) { if (need_transceiver) {
ohci->transceiver = otg_get_transceiver(); ohci->transceiver = usb_get_transceiver();
if (ohci->transceiver) { if (ohci->transceiver) {
int status = otg_set_host(ohci->transceiver, int status = otg_set_host(ohci->transceiver->otg,
&ohci_to_hcd(ohci)->self); &ohci_to_hcd(ohci)->self);
dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n",
ohci->transceiver->label, status); ohci->transceiver->label, status);
...@@ -404,7 +404,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) ...@@ -404,7 +404,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
if (ohci->transceiver) { if (ohci->transceiver) {
(void) otg_set_host(ohci->transceiver, 0); (void) otg_set_host(ohci->transceiver->otg, 0);
put_device(ohci->transceiver->dev); put_device(ohci->transceiver->dev);
} }
if (machine_is_omap_osk()) if (machine_is_omap_osk())
......
...@@ -376,7 +376,7 @@ struct ohci_hcd { ...@@ -376,7 +376,7 @@ struct ohci_hcd {
* OTG controllers and transceivers need software interaction; * OTG controllers and transceivers need software interaction;
* other external transceivers should be software-transparent * other external transceivers should be software-transparent
*/ */
struct otg_transceiver *transceiver; struct usb_phy *transceiver;
void (*start_hnp)(struct ohci_hcd *ohci); void (*start_hnp)(struct ohci_hcd *ohci);
/* /*
......
...@@ -226,6 +226,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) ...@@ -226,6 +226,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
struct device *dev = musb->controller; struct device *dev = musb->controller;
struct musb_hdrc_platform_data *plat = dev->platform_data; struct musb_hdrc_platform_data *plat = dev->platform_data;
struct omap_musb_board_data *data = plat->board_data; struct omap_musb_board_data *data = plat->board_data;
struct usb_otg *otg = musb->xceiv->otg;
unsigned long flags; unsigned long flags;
irqreturn_t ret = IRQ_NONE; irqreturn_t ret = IRQ_NONE;
u32 epintr, usbintr; u32 epintr, usbintr;
...@@ -289,14 +290,14 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) ...@@ -289,14 +290,14 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) { } else if (is_host_enabled(musb) && drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER); portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround); del_timer(&otg_workaround);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
musb->xceiv->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
} }
...@@ -363,7 +364,7 @@ static int am35x_musb_init(struct musb *musb) ...@@ -363,7 +364,7 @@ static int am35x_musb_init(struct musb *musb)
return -ENODEV; return -ENODEV;
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) if (!musb->xceiv)
return -ENODEV; return -ENODEV;
...@@ -405,7 +406,7 @@ static int am35x_musb_exit(struct musb *musb) ...@@ -405,7 +406,7 @@ static int am35x_musb_exit(struct musb *musb)
if (data->set_phy_power) if (data->set_phy_power)
data->set_phy_power(0); data->set_phy_power(0);
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
......
...@@ -317,7 +317,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on) ...@@ -317,7 +317,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)
musb_readb(musb->mregs, MUSB_DEVCTL)); musb_readb(musb->mregs, MUSB_DEVCTL));
} }
static int bfin_musb_set_power(struct otg_transceiver *x, unsigned mA) static int bfin_musb_set_power(struct usb_phy *x, unsigned mA)
{ {
return 0; return 0;
} }
...@@ -415,7 +415,7 @@ static int bfin_musb_init(struct musb *musb) ...@@ -415,7 +415,7 @@ static int bfin_musb_init(struct musb *musb)
gpio_direction_output(musb->config->gpio_vrsel, 0); gpio_direction_output(musb->config->gpio_vrsel, 0);
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) { if (!musb->xceiv) {
gpio_free(musb->config->gpio_vrsel); gpio_free(musb->config->gpio_vrsel);
return -ENODEV; return -ENODEV;
...@@ -440,7 +440,7 @@ static int bfin_musb_exit(struct musb *musb) ...@@ -440,7 +440,7 @@ static int bfin_musb_exit(struct musb *musb)
{ {
gpio_free(musb->config->gpio_vrsel); gpio_free(musb->config->gpio_vrsel);
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
} }
......
...@@ -294,6 +294,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) ...@@ -294,6 +294,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
{ {
struct musb *musb = hci; struct musb *musb = hci;
void __iomem *reg_base = musb->ctrl_base; void __iomem *reg_base = musb->ctrl_base;
struct usb_otg *otg = musb->xceiv->otg;
unsigned long flags; unsigned long flags;
irqreturn_t ret = IRQ_NONE; irqreturn_t ret = IRQ_NONE;
u32 status; u32 status;
...@@ -351,14 +352,14 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) ...@@ -351,14 +352,14 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) { } else if (is_host_enabled(musb) && drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER); portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround); del_timer(&otg_workaround);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
musb->xceiv->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
} }
...@@ -424,7 +425,7 @@ static int da8xx_musb_init(struct musb *musb) ...@@ -424,7 +425,7 @@ static int da8xx_musb_init(struct musb *musb)
goto fail; goto fail;
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) if (!musb->xceiv)
goto fail; goto fail;
...@@ -457,7 +458,7 @@ static int da8xx_musb_exit(struct musb *musb) ...@@ -457,7 +458,7 @@ static int da8xx_musb_exit(struct musb *musb)
phy_off(); phy_off();
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
......
...@@ -265,6 +265,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) ...@@ -265,6 +265,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
unsigned long flags; unsigned long flags;
irqreturn_t retval = IRQ_NONE; irqreturn_t retval = IRQ_NONE;
struct musb *musb = __hci; struct musb *musb = __hci;
struct usb_otg *otg = musb->xceiv->otg;
void __iomem *tibase = musb->ctrl_base; void __iomem *tibase = musb->ctrl_base;
struct cppi *cppi; struct cppi *cppi;
u32 tmp; u32 tmp;
...@@ -331,14 +332,14 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) ...@@ -331,14 +332,14 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) { } else if (is_host_enabled(musb) && drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER); portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround); del_timer(&otg_workaround);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
musb->xceiv->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
} }
...@@ -383,7 +384,7 @@ static int davinci_musb_init(struct musb *musb) ...@@ -383,7 +384,7 @@ static int davinci_musb_init(struct musb *musb)
u32 revision; u32 revision;
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) if (!musb->xceiv)
return -ENODEV; return -ENODEV;
...@@ -442,7 +443,7 @@ static int davinci_musb_init(struct musb *musb) ...@@ -442,7 +443,7 @@ static int davinci_musb_init(struct musb *musb)
return 0; return 0;
fail: fail:
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return -ENODEV; return -ENODEV;
} }
...@@ -464,7 +465,7 @@ static int davinci_musb_exit(struct musb *musb) ...@@ -464,7 +465,7 @@ static int davinci_musb_exit(struct musb *musb)
davinci_musb_source_power(musb, 0 /*off*/, 1); davinci_musb_source_power(musb, 0 /*off*/, 1);
/* delay, to avoid problems with module reload */ /* delay, to avoid problems with module reload */
if (is_host_enabled(musb) && musb->xceiv->default_a) { if (is_host_enabled(musb) && musb->xceiv->otg->default_a) {
int maxdelay = 30; int maxdelay = 30;
u8 devctl, warn = 0; u8 devctl, warn = 0;
...@@ -491,7 +492,7 @@ static int davinci_musb_exit(struct musb *musb) ...@@ -491,7 +492,7 @@ static int davinci_musb_exit(struct musb *musb)
phy_off(); phy_off();
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
......
...@@ -131,9 +131,9 @@ static inline struct musb *dev_to_musb(struct device *dev) ...@@ -131,9 +131,9 @@ static inline struct musb *dev_to_musb(struct device *dev)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
#ifndef CONFIG_BLACKFIN #ifndef CONFIG_BLACKFIN
static int musb_ulpi_read(struct otg_transceiver *otg, u32 offset) static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
{ {
void __iomem *addr = otg->io_priv; void __iomem *addr = phy->io_priv;
int i = 0; int i = 0;
u8 r; u8 r;
u8 power; u8 power;
...@@ -165,10 +165,9 @@ static int musb_ulpi_read(struct otg_transceiver *otg, u32 offset) ...@@ -165,10 +165,9 @@ static int musb_ulpi_read(struct otg_transceiver *otg, u32 offset)
return musb_readb(addr, MUSB_ULPI_REG_DATA); return musb_readb(addr, MUSB_ULPI_REG_DATA);
} }
static int musb_ulpi_write(struct otg_transceiver *otg, static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
u32 offset, u32 data)
{ {
void __iomem *addr = otg->io_priv; void __iomem *addr = phy->io_priv;
int i = 0; int i = 0;
u8 r = 0; u8 r = 0;
u8 power; u8 power;
...@@ -200,7 +199,7 @@ static int musb_ulpi_write(struct otg_transceiver *otg, ...@@ -200,7 +199,7 @@ static int musb_ulpi_write(struct otg_transceiver *otg,
#define musb_ulpi_write NULL #define musb_ulpi_write NULL
#endif #endif
static struct otg_io_access_ops musb_ulpi_access = { static struct usb_phy_io_ops musb_ulpi_access = {
.read = musb_ulpi_read, .read = musb_ulpi_read,
.write = musb_ulpi_write, .write = musb_ulpi_write,
}; };
...@@ -414,6 +413,7 @@ void musb_hnp_stop(struct musb *musb) ...@@ -414,6 +413,7 @@ void musb_hnp_stop(struct musb *musb)
static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
u8 devctl, u8 power) u8 devctl, u8 power)
{ {
struct usb_otg *otg = musb->xceiv->otg;
irqreturn_t handled = IRQ_NONE; irqreturn_t handled = IRQ_NONE;
dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl, dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
...@@ -626,7 +626,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -626,7 +626,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
musb_g_suspend(musb); musb_g_suspend(musb);
musb->is_active = is_otg_enabled(musb) musb->is_active = is_otg_enabled(musb)
&& musb->xceiv->gadget->b_hnp_enable; && otg->gadget->b_hnp_enable;
if (musb->is_active) { if (musb->is_active) {
musb->xceiv->state = OTG_STATE_B_WAIT_ACON; musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
...@@ -643,7 +643,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -643,7 +643,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
musb->xceiv->state = OTG_STATE_A_SUSPEND; musb->xceiv->state = OTG_STATE_A_SUSPEND;
musb->is_active = is_otg_enabled(musb) musb->is_active = is_otg_enabled(musb)
&& musb->xceiv->host->b_hnp_enable; && otg->host->b_hnp_enable;
break; break;
case OTG_STATE_B_HOST: case OTG_STATE_B_HOST:
/* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */
...@@ -1961,11 +1961,11 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -1961,11 +1961,11 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
if (is_host_enabled(musb)) { if (is_host_enabled(musb)) {
struct usb_hcd *hcd = musb_to_hcd(musb); struct usb_hcd *hcd = musb_to_hcd(musb);
otg_set_host(musb->xceiv, &hcd->self); otg_set_host(musb->xceiv->otg, &hcd->self);
if (is_otg_enabled(musb)) if (is_otg_enabled(musb))
hcd->self.otg_port = 1; hcd->self.otg_port = 1;
musb->xceiv->host = &hcd->self; musb->xceiv->otg->host = &hcd->self;
hcd->power_budget = 2 * (plat->power ? : 250); hcd->power_budget = 2 * (plat->power ? : 250);
/* program PHY to use external vBus if required */ /* program PHY to use external vBus if required */
...@@ -1984,7 +1984,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -1984,7 +1984,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
struct usb_hcd *hcd = musb_to_hcd(musb); struct usb_hcd *hcd = musb_to_hcd(musb);
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->default_a = 1; musb->xceiv->otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->state = OTG_STATE_A_IDLE;
status = usb_add_hcd(musb_to_hcd(musb), -1, 0); status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
...@@ -1999,7 +1999,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -1999,7 +1999,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
} else /* peripheral is enabled */ { } else /* peripheral is enabled */ {
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
musb->xceiv->default_a = 0; musb->xceiv->otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
status = musb_gadget_setup(musb); status = musb_gadget_setup(musb);
......
...@@ -372,7 +372,7 @@ struct musb { ...@@ -372,7 +372,7 @@ struct musb {
u16 int_rx; u16 int_rx;
u16 int_tx; u16 int_tx;
struct otg_transceiver *xceiv; struct usb_phy *xceiv;
u8 xceiv_event; u8 xceiv_event;
int nIrq; int nIrq;
......
...@@ -1642,7 +1642,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) ...@@ -1642,7 +1642,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
} }
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
otg_start_srp(musb->xceiv); otg_start_srp(musb->xceiv->otg);
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
/* Block idling for at least 1s */ /* Block idling for at least 1s */
...@@ -1721,7 +1721,7 @@ static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1721,7 +1721,7 @@ static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
if (!musb->xceiv->set_power) if (!musb->xceiv->set_power)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return otg_set_power(musb->xceiv, mA); return usb_phy_set_power(musb->xceiv, mA);
} }
static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on)
...@@ -1916,6 +1916,7 @@ static int musb_gadget_start(struct usb_gadget *g, ...@@ -1916,6 +1916,7 @@ static int musb_gadget_start(struct usb_gadget *g,
struct usb_gadget_driver *driver) struct usb_gadget_driver *driver)
{ {
struct musb *musb = gadget_to_musb(g); struct musb *musb = gadget_to_musb(g);
struct usb_otg *otg = musb->xceiv->otg;
unsigned long flags; unsigned long flags;
int retval = -EINVAL; int retval = -EINVAL;
...@@ -1932,7 +1933,7 @@ static int musb_gadget_start(struct usb_gadget *g, ...@@ -1932,7 +1933,7 @@ static int musb_gadget_start(struct usb_gadget *g,
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
musb->is_active = 1; musb->is_active = 1;
otg_set_peripheral(musb->xceiv, &musb->g); otg_set_peripheral(otg, &musb->g);
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
/* /*
...@@ -1963,8 +1964,8 @@ static int musb_gadget_start(struct usb_gadget *g, ...@@ -1963,8 +1964,8 @@ static int musb_gadget_start(struct usb_gadget *g,
} }
if ((musb->xceiv->last_event == USB_EVENT_ID) if ((musb->xceiv->last_event == USB_EVENT_ID)
&& musb->xceiv->set_vbus) && otg->set_vbus)
otg_set_vbus(musb->xceiv, 1); otg_set_vbus(otg, 1);
hcd->self.uses_pio_for_control = 1; hcd->self.uses_pio_for_control = 1;
} }
...@@ -2046,7 +2047,7 @@ static int musb_gadget_stop(struct usb_gadget *g, ...@@ -2046,7 +2047,7 @@ static int musb_gadget_stop(struct usb_gadget *g,
musb->xceiv->state = OTG_STATE_UNDEFINED; musb->xceiv->state = OTG_STATE_UNDEFINED;
stop_activity(musb, driver); stop_activity(musb, driver);
otg_set_peripheral(musb->xceiv, NULL); otg_set_peripheral(musb->xceiv->otg, NULL);
dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); dev_dbg(musb->controller, "unregistering driver %s\n", driver->function);
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
static void musb_port_suspend(struct musb *musb, bool do_suspend) static void musb_port_suspend(struct musb *musb, bool do_suspend)
{ {
struct usb_otg *otg = musb->xceiv->otg;
u8 power; u8 power;
void __iomem *mbase = musb->mregs; void __iomem *mbase = musb->mregs;
...@@ -81,7 +82,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) ...@@ -81,7 +82,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend)
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
musb->xceiv->state = OTG_STATE_A_SUSPEND; musb->xceiv->state = OTG_STATE_A_SUSPEND;
musb->is_active = is_otg_enabled(musb) musb->is_active = is_otg_enabled(musb)
&& musb->xceiv->host->b_hnp_enable; && otg->host->b_hnp_enable;
if (musb->is_active) if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies( + msecs_to_jiffies(
...@@ -91,7 +92,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) ...@@ -91,7 +92,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend)
case OTG_STATE_B_HOST: case OTG_STATE_B_HOST:
musb->xceiv->state = OTG_STATE_B_WAIT_ACON; musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = is_otg_enabled(musb) musb->is_active = is_otg_enabled(musb)
&& musb->xceiv->host->b_hnp_enable; && otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0); musb_platform_try_idle(musb, 0);
break; break;
default: default:
...@@ -179,6 +180,8 @@ static void musb_port_reset(struct musb *musb, bool do_reset) ...@@ -179,6 +180,8 @@ static void musb_port_reset(struct musb *musb, bool do_reset)
void musb_root_disconnect(struct musb *musb) void musb_root_disconnect(struct musb *musb)
{ {
struct usb_otg *otg = musb->xceiv->otg;
musb->port1_status = USB_PORT_STAT_POWER musb->port1_status = USB_PORT_STAT_POWER
| (USB_PORT_STAT_C_CONNECTION << 16); | (USB_PORT_STAT_C_CONNECTION << 16);
...@@ -188,7 +191,7 @@ void musb_root_disconnect(struct musb *musb) ...@@ -188,7 +191,7 @@ void musb_root_disconnect(struct musb *musb)
switch (musb->xceiv->state) { switch (musb->xceiv->state) {
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
if (is_otg_enabled(musb) if (is_otg_enabled(musb)
&& musb->xceiv->host->b_hnp_enable) { && otg->host->b_hnp_enable) {
musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1; musb->g.is_a_peripheral = 1;
break; break;
......
...@@ -132,6 +132,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -132,6 +132,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
static void omap2430_musb_set_vbus(struct musb *musb, int is_on) static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
{ {
struct usb_otg *otg = musb->xceiv->otg;
u8 devctl; u8 devctl;
unsigned long timeout = jiffies + msecs_to_jiffies(1000); unsigned long timeout = jiffies + msecs_to_jiffies(1000);
int ret = 1; int ret = 1;
...@@ -163,11 +164,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -163,11 +164,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
} }
} }
if (ret && musb->xceiv->set_vbus) if (ret && otg->set_vbus)
otg_set_vbus(musb->xceiv, 1); otg_set_vbus(otg, 1);
} else { } else {
musb->is_active = 1; musb->is_active = 1;
musb->xceiv->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
...@@ -179,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -179,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
* jumping right to B_IDLE... * jumping right to B_IDLE...
*/ */
musb->xceiv->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION; devctl &= ~MUSB_DEVCTL_SESSION;
...@@ -246,7 +247,7 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work) ...@@ -246,7 +247,7 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
if (!is_otg_enabled(musb) || musb->gadget_driver) { if (!is_otg_enabled(musb) || musb->gadget_driver) {
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
otg_init(musb->xceiv); usb_phy_init(musb->xceiv);
omap2430_musb_set_vbus(musb, 1); omap2430_musb_set_vbus(musb, 1);
} }
break; break;
...@@ -256,7 +257,7 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work) ...@@ -256,7 +257,7 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
if (musb->gadget_driver) if (musb->gadget_driver)
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
otg_init(musb->xceiv); usb_phy_init(musb->xceiv);
break; break;
case USB_EVENT_NONE: case USB_EVENT_NONE:
...@@ -269,10 +270,10 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work) ...@@ -269,10 +270,10 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
} }
if (data->interface_type == MUSB_INTERFACE_UTMI) { if (data->interface_type == MUSB_INTERFACE_UTMI) {
if (musb->xceiv->set_vbus) if (musb->xceiv->otg->set_vbus)
otg_set_vbus(musb->xceiv, 0); otg_set_vbus(musb->xceiv->otg, 0);
} }
otg_shutdown(musb->xceiv); usb_phy_shutdown(musb->xceiv);
break; break;
default: default:
dev_dbg(musb->controller, "ID float\n"); dev_dbg(musb->controller, "ID float\n");
...@@ -290,7 +291,7 @@ static int omap2430_musb_init(struct musb *musb) ...@@ -290,7 +291,7 @@ static int omap2430_musb_init(struct musb *musb)
* up through ULPI. TWL4030-family PMICs include one, * up through ULPI. TWL4030-family PMICs include one,
* which needs a driver, drivers aren't always needed. * which needs a driver, drivers aren't always needed.
*/ */
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) { if (!musb->xceiv) {
pr_err("HS USB OTG: no transceiver configured\n"); pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV; return -ENODEV;
...@@ -325,7 +326,7 @@ static int omap2430_musb_init(struct musb *musb) ...@@ -325,7 +326,7 @@ static int omap2430_musb_init(struct musb *musb)
musb_readl(musb->mregs, OTG_SIMENABLE)); musb_readl(musb->mregs, OTG_SIMENABLE));
musb->nb.notifier_call = musb_otg_notifications; musb->nb.notifier_call = musb_otg_notifications;
status = otg_register_notifier(musb->xceiv, &musb->nb); status = usb_register_notifier(musb->xceiv, &musb->nb);
if (status) if (status)
dev_dbg(musb->controller, "notification register failed\n"); dev_dbg(musb->controller, "notification register failed\n");
...@@ -349,7 +350,7 @@ static void omap2430_musb_enable(struct musb *musb) ...@@ -349,7 +350,7 @@ static void omap2430_musb_enable(struct musb *musb)
switch (musb->xceiv->last_event) { switch (musb->xceiv->last_event) {
case USB_EVENT_ID: case USB_EVENT_ID:
otg_init(musb->xceiv); usb_phy_init(musb->xceiv);
if (data->interface_type != MUSB_INTERFACE_UTMI) if (data->interface_type != MUSB_INTERFACE_UTMI)
break; break;
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
...@@ -368,7 +369,7 @@ static void omap2430_musb_enable(struct musb *musb) ...@@ -368,7 +369,7 @@ static void omap2430_musb_enable(struct musb *musb)
break; break;
case USB_EVENT_VBUS: case USB_EVENT_VBUS:
otg_init(musb->xceiv); usb_phy_init(musb->xceiv);
break; break;
default: default:
...@@ -379,7 +380,7 @@ static void omap2430_musb_enable(struct musb *musb) ...@@ -379,7 +380,7 @@ static void omap2430_musb_enable(struct musb *musb)
static void omap2430_musb_disable(struct musb *musb) static void omap2430_musb_disable(struct musb *musb)
{ {
if (musb->xceiv->last_event) if (musb->xceiv->last_event)
otg_shutdown(musb->xceiv); usb_phy_shutdown(musb->xceiv);
} }
static int omap2430_musb_exit(struct musb *musb) static int omap2430_musb_exit(struct musb *musb)
...@@ -388,7 +389,7 @@ static int omap2430_musb_exit(struct musb *musb) ...@@ -388,7 +389,7 @@ static int omap2430_musb_exit(struct musb *musb)
cancel_work_sync(&musb->otg_notifier_work); cancel_work_sync(&musb->otg_notifier_work);
omap2430_low_level_exit(musb); omap2430_low_level_exit(musb);
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
return 0; return 0;
} }
...@@ -494,7 +495,7 @@ static int omap2430_runtime_suspend(struct device *dev) ...@@ -494,7 +495,7 @@ static int omap2430_runtime_suspend(struct device *dev)
OTG_INTERFSEL); OTG_INTERFSEL);
omap2430_low_level_exit(musb); omap2430_low_level_exit(musb);
otg_set_suspend(musb->xceiv, 1); usb_phy_set_suspend(musb->xceiv, 1);
return 0; return 0;
} }
...@@ -508,7 +509,7 @@ static int omap2430_runtime_resume(struct device *dev) ...@@ -508,7 +509,7 @@ static int omap2430_runtime_resume(struct device *dev)
musb_writel(musb->mregs, OTG_INTERFSEL, musb_writel(musb->mregs, OTG_INTERFSEL,
musb->context.otg_interfsel); musb->context.otg_interfsel);
otg_set_suspend(musb->xceiv, 0); usb_phy_set_suspend(musb->xceiv, 0);
return 0; return 0;
} }
......
...@@ -277,7 +277,7 @@ static struct musb *the_musb; ...@@ -277,7 +277,7 @@ static struct musb *the_musb;
* mode), or low power Default-B sessions, something else supplies power. * mode), or low power Default-B sessions, something else supplies power.
* Caller must take care of locking. * Caller must take care of locking.
*/ */
static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) static int tusb_draw_power(struct usb_phy *x, unsigned mA)
{ {
struct musb *musb = the_musb; struct musb *musb = the_musb;
void __iomem *tbase = musb->ctrl_base; void __iomem *tbase = musb->ctrl_base;
...@@ -293,7 +293,7 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) ...@@ -293,7 +293,7 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA)
* The actual current usage would be very board-specific. For now, * The actual current usage would be very board-specific. For now,
* it's simpler to just use an aggregate (also board-specific). * it's simpler to just use an aggregate (also board-specific).
*/ */
if (x->default_a || mA < (musb->min_power << 1)) if (x->otg->default_a || mA < (musb->min_power << 1))
mA = 0; mA = 0;
reg = musb_readl(tbase, TUSB_PRCM_MNGMT); reg = musb_readl(tbase, TUSB_PRCM_MNGMT);
...@@ -510,6 +510,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -510,6 +510,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
void __iomem *tbase = musb->ctrl_base; void __iomem *tbase = musb->ctrl_base;
u32 conf, prcm, timer; u32 conf, prcm, timer;
u8 devctl; u8 devctl;
struct usb_otg *otg = musb->xceiv->otg;
/* HDRC controls CPEN, but beware current surges during device /* HDRC controls CPEN, but beware current surges during device
* connect. They can trigger transient overcurrent conditions * connect. They can trigger transient overcurrent conditions
...@@ -522,7 +523,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -522,7 +523,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) { if (is_on) {
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
musb->xceiv->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
...@@ -548,11 +549,11 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -548,11 +549,11 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->state = OTG_STATE_A_IDLE;
} }
musb->is_active = 0; musb->is_active = 0;
musb->xceiv->default_a = 1; otg->default_a = 1;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
musb->xceiv->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
} }
...@@ -644,6 +645,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -644,6 +645,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
{ {
u32 otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); u32 otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
unsigned long idle_timeout = 0; unsigned long idle_timeout = 0;
struct usb_otg *otg = musb->xceiv->otg;
/* ID pin */ /* ID pin */
if ((int_src & TUSB_INT_SRC_ID_STATUS_CHNG)) { if ((int_src & TUSB_INT_SRC_ID_STATUS_CHNG)) {
...@@ -654,7 +656,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -654,7 +656,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
else else
default_a = is_host_enabled(musb); default_a = is_host_enabled(musb);
dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B'); dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B');
musb->xceiv->default_a = default_a; otg->default_a = default_a;
tusb_musb_set_vbus(musb, default_a); tusb_musb_set_vbus(musb, default_a);
/* Don't allow idling immediately */ /* Don't allow idling immediately */
...@@ -666,7 +668,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -666,7 +668,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) { if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) {
/* B-dev state machine: no vbus ~= disconnect */ /* B-dev state machine: no vbus ~= disconnect */
if ((is_otg_enabled(musb) && !musb->xceiv->default_a) if ((is_otg_enabled(musb) && !otg->default_a)
|| !is_host_enabled(musb)) { || !is_host_enabled(musb)) {
/* ? musb_root_disconnect(musb); */ /* ? musb_root_disconnect(musb); */
musb->port1_status &= musb->port1_status &=
...@@ -1076,7 +1078,7 @@ static int tusb_musb_init(struct musb *musb) ...@@ -1076,7 +1078,7 @@ static int tusb_musb_init(struct musb *musb)
int ret; int ret;
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) if (!musb->xceiv)
return -ENODEV; return -ENODEV;
...@@ -1128,7 +1130,7 @@ static int tusb_musb_init(struct musb *musb) ...@@ -1128,7 +1130,7 @@ static int tusb_musb_init(struct musb *musb)
if (sync) if (sync)
iounmap(sync); iounmap(sync);
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
} }
return ret; return ret;
...@@ -1144,7 +1146,7 @@ static int tusb_musb_exit(struct musb *musb) ...@@ -1144,7 +1146,7 @@ static int tusb_musb_exit(struct musb *musb)
iounmap(musb->sync_va); iounmap(musb->sync_va);
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; return 0;
} }
......
...@@ -37,7 +37,7 @@ struct ux500_glue { ...@@ -37,7 +37,7 @@ struct ux500_glue {
static int ux500_musb_init(struct musb *musb) static int ux500_musb_init(struct musb *musb)
{ {
musb->xceiv = otg_get_transceiver(); musb->xceiv = usb_get_transceiver();
if (!musb->xceiv) { if (!musb->xceiv) {
pr_err("HS USB OTG: no transceiver configured\n"); pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV; return -ENODEV;
...@@ -48,7 +48,7 @@ static int ux500_musb_init(struct musb *musb) ...@@ -48,7 +48,7 @@ static int ux500_musb_init(struct musb *musb)
static int ux500_musb_exit(struct musb *musb) static int ux500_musb_exit(struct musb *musb)
{ {
otg_put_transceiver(musb->xceiv); usb_put_transceiver(musb->xceiv);
return 0; return 0;
} }
...@@ -160,7 +160,7 @@ static int ux500_suspend(struct device *dev) ...@@ -160,7 +160,7 @@ static int ux500_suspend(struct device *dev)
struct ux500_glue *glue = dev_get_drvdata(dev); struct ux500_glue *glue = dev_get_drvdata(dev);
struct musb *musb = glue_to_musb(glue); struct musb *musb = glue_to_musb(glue);
otg_set_suspend(musb->xceiv, 1); usb_phy_set_suspend(musb->xceiv, 1);
clk_disable(glue->clk); clk_disable(glue->clk);
return 0; return 0;
...@@ -178,7 +178,7 @@ static int ux500_resume(struct device *dev) ...@@ -178,7 +178,7 @@ static int ux500_resume(struct device *dev)
return ret; return ret;
} }
otg_set_suspend(musb->xceiv, 0); usb_phy_set_suspend(musb->xceiv, 0);
return 0; return 0;
} }
......
...@@ -23,7 +23,7 @@ config USB_GPIO_VBUS ...@@ -23,7 +23,7 @@ config USB_GPIO_VBUS
select USB_OTG_UTILS select USB_OTG_UTILS
help help
Provides simple GPIO VBUS sensing for controllers with an Provides simple GPIO VBUS sensing for controllers with an
internal transceiver via the otg_transceiver interface, and internal transceiver via the usb_phy interface, and
optionally control of a D+ pullup GPIO as well as a VBUS optionally control of a D+ pullup GPIO as well as a VBUS
current limit regulator. current limit regulator.
......
...@@ -68,7 +68,7 @@ enum ab8500_usb_link_status { ...@@ -68,7 +68,7 @@ enum ab8500_usb_link_status {
}; };
struct ab8500_usb { struct ab8500_usb {
struct otg_transceiver otg; struct usb_phy phy;
struct device *dev; struct device *dev;
int irq_num_id_rise; int irq_num_id_rise;
int irq_num_id_fall; int irq_num_id_fall;
...@@ -82,9 +82,9 @@ struct ab8500_usb { ...@@ -82,9 +82,9 @@ struct ab8500_usb {
int rev; int rev;
}; };
static inline struct ab8500_usb *xceiv_to_ab(struct otg_transceiver *x) static inline struct ab8500_usb *phy_to_ab(struct usb_phy *x)
{ {
return container_of(x, struct ab8500_usb, otg); return container_of(x, struct ab8500_usb, phy);
} }
static void ab8500_usb_wd_workaround(struct ab8500_usb *ab) static void ab8500_usb_wd_workaround(struct ab8500_usb *ab)
...@@ -153,7 +153,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) ...@@ -153,7 +153,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
u8 reg; u8 reg;
enum ab8500_usb_link_status lsts; enum ab8500_usb_link_status lsts;
void *v = NULL; void *v = NULL;
enum usb_xceiv_events event; enum usb_phy_events event;
abx500_get_register_interruptible(ab->dev, abx500_get_register_interruptible(ab->dev,
AB8500_USB, AB8500_USB,
...@@ -169,8 +169,8 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) ...@@ -169,8 +169,8 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
/* TODO: Disable regulators. */ /* TODO: Disable regulators. */
ab8500_usb_host_phy_dis(ab); ab8500_usb_host_phy_dis(ab);
ab8500_usb_peri_phy_dis(ab); ab8500_usb_peri_phy_dis(ab);
ab->otg.state = OTG_STATE_B_IDLE; ab->phy.state = OTG_STATE_B_IDLE;
ab->otg.default_a = false; ab->phy.otg->default_a = false;
ab->vbus_draw = 0; ab->vbus_draw = 0;
event = USB_EVENT_NONE; event = USB_EVENT_NONE;
break; break;
...@@ -181,22 +181,22 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) ...@@ -181,22 +181,22 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
case USB_LINK_HOST_CHG_NM: case USB_LINK_HOST_CHG_NM:
case USB_LINK_HOST_CHG_HS: case USB_LINK_HOST_CHG_HS:
case USB_LINK_HOST_CHG_HS_CHIRP: case USB_LINK_HOST_CHG_HS_CHIRP:
if (ab->otg.gadget) { if (ab->phy.otg->gadget) {
/* TODO: Enable regulators. */ /* TODO: Enable regulators. */
ab8500_usb_peri_phy_en(ab); ab8500_usb_peri_phy_en(ab);
v = ab->otg.gadget; v = ab->phy.otg->gadget;
} }
event = USB_EVENT_VBUS; event = USB_EVENT_VBUS;
break; break;
case USB_LINK_HM_IDGND: case USB_LINK_HM_IDGND:
if (ab->otg.host) { if (ab->phy.otg->host) {
/* TODO: Enable regulators. */ /* TODO: Enable regulators. */
ab8500_usb_host_phy_en(ab); ab8500_usb_host_phy_en(ab);
v = ab->otg.host; v = ab->phy.otg->host;
} }
ab->otg.state = OTG_STATE_A_IDLE; ab->phy.state = OTG_STATE_A_IDLE;
ab->otg.default_a = true; ab->phy.otg->default_a = true;
event = USB_EVENT_ID; event = USB_EVENT_ID;
break; break;
...@@ -212,7 +212,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) ...@@ -212,7 +212,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
break; break;
} }
atomic_notifier_call_chain(&ab->otg.notifier, event, v); atomic_notifier_call_chain(&ab->phy.notifier, event, v);
return 0; return 0;
} }
...@@ -262,27 +262,27 @@ static void ab8500_usb_phy_disable_work(struct work_struct *work) ...@@ -262,27 +262,27 @@ static void ab8500_usb_phy_disable_work(struct work_struct *work)
struct ab8500_usb *ab = container_of(work, struct ab8500_usb, struct ab8500_usb *ab = container_of(work, struct ab8500_usb,
phy_dis_work); phy_dis_work);
if (!ab->otg.host) if (!ab->phy.otg->host)
ab8500_usb_host_phy_dis(ab); ab8500_usb_host_phy_dis(ab);
if (!ab->otg.gadget) if (!ab->phy.otg->gadget)
ab8500_usb_peri_phy_dis(ab); ab8500_usb_peri_phy_dis(ab);
} }
static int ab8500_usb_set_power(struct otg_transceiver *otg, unsigned mA) static int ab8500_usb_set_power(struct usb_phy *phy, unsigned mA)
{ {
struct ab8500_usb *ab; struct ab8500_usb *ab;
if (!otg) if (!phy)
return -ENODEV; return -ENODEV;
ab = xceiv_to_ab(otg); ab = phy_to_ab(phy);
ab->vbus_draw = mA; ab->vbus_draw = mA;
if (mA) if (mA)
atomic_notifier_call_chain(&ab->otg.notifier, atomic_notifier_call_chain(&ab->phy.notifier,
USB_EVENT_ENUMERATED, ab->otg.gadget); USB_EVENT_ENUMERATED, ab->phy.otg->gadget);
return 0; return 0;
} }
...@@ -290,13 +290,13 @@ static int ab8500_usb_set_power(struct otg_transceiver *otg, unsigned mA) ...@@ -290,13 +290,13 @@ static int ab8500_usb_set_power(struct otg_transceiver *otg, unsigned mA)
* ab->vbus_draw. * ab->vbus_draw.
*/ */
static int ab8500_usb_set_suspend(struct otg_transceiver *x, int suspend) static int ab8500_usb_set_suspend(struct usb_phy *x, int suspend)
{ {
/* TODO */ /* TODO */
return 0; return 0;
} }
static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, static int ab8500_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget) struct usb_gadget *gadget)
{ {
struct ab8500_usb *ab; struct ab8500_usb *ab;
...@@ -304,7 +304,7 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, ...@@ -304,7 +304,7 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg,
if (!otg) if (!otg)
return -ENODEV; return -ENODEV;
ab = xceiv_to_ab(otg); ab = phy_to_ab(otg->phy);
/* Some drivers call this function in atomic context. /* Some drivers call this function in atomic context.
* Do not update ab8500 registers directly till this * Do not update ab8500 registers directly till this
...@@ -313,11 +313,11 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, ...@@ -313,11 +313,11 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg,
if (!gadget) { if (!gadget) {
/* TODO: Disable regulators. */ /* TODO: Disable regulators. */
ab->otg.gadget = NULL; otg->gadget = NULL;
schedule_work(&ab->phy_dis_work); schedule_work(&ab->phy_dis_work);
} else { } else {
ab->otg.gadget = gadget; otg->gadget = gadget;
ab->otg.state = OTG_STATE_B_IDLE; otg->phy->state = OTG_STATE_B_IDLE;
/* Phy will not be enabled if cable is already /* Phy will not be enabled if cable is already
* plugged-in. Schedule to enable phy. * plugged-in. Schedule to enable phy.
...@@ -329,15 +329,14 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, ...@@ -329,15 +329,14 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg,
return 0; return 0;
} }
static int ab8500_usb_set_host(struct otg_transceiver *otg, static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
struct usb_bus *host)
{ {
struct ab8500_usb *ab; struct ab8500_usb *ab;
if (!otg) if (!otg)
return -ENODEV; return -ENODEV;
ab = xceiv_to_ab(otg); ab = phy_to_ab(otg->phy);
/* Some drivers call this function in atomic context. /* Some drivers call this function in atomic context.
* Do not update ab8500 registers directly till this * Do not update ab8500 registers directly till this
...@@ -346,10 +345,10 @@ static int ab8500_usb_set_host(struct otg_transceiver *otg, ...@@ -346,10 +345,10 @@ static int ab8500_usb_set_host(struct otg_transceiver *otg,
if (!host) { if (!host) {
/* TODO: Disable regulators. */ /* TODO: Disable regulators. */
ab->otg.host = NULL; otg->host = NULL;
schedule_work(&ab->phy_dis_work); schedule_work(&ab->phy_dis_work);
} else { } else {
ab->otg.host = host; otg->host = host;
/* Phy will not be enabled if cable is already /* Phy will not be enabled if cable is already
* plugged-in. Schedule to enable phy. * plugged-in. Schedule to enable phy.
* Use same delay to avoid any race condition. * Use same delay to avoid any race condition.
...@@ -472,6 +471,7 @@ static int ab8500_usb_v2_res_setup(struct platform_device *pdev, ...@@ -472,6 +471,7 @@ static int ab8500_usb_v2_res_setup(struct platform_device *pdev,
static int __devinit ab8500_usb_probe(struct platform_device *pdev) static int __devinit ab8500_usb_probe(struct platform_device *pdev)
{ {
struct ab8500_usb *ab; struct ab8500_usb *ab;
struct usb_otg *otg;
int err; int err;
int rev; int rev;
...@@ -488,19 +488,28 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev) ...@@ -488,19 +488,28 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
if (!ab) if (!ab)
return -ENOMEM; return -ENOMEM;
otg = kzalloc(sizeof *otg, GFP_KERNEL);
if (!ab->phy.otg) {
kfree(ab);
return -ENOMEM;
}
ab->dev = &pdev->dev; ab->dev = &pdev->dev;
ab->rev = rev; ab->rev = rev;
ab->otg.dev = ab->dev; ab->phy.dev = ab->dev;
ab->otg.label = "ab8500"; ab->phy.otg = otg;
ab->otg.state = OTG_STATE_UNDEFINED; ab->phy.label = "ab8500";
ab->otg.set_host = ab8500_usb_set_host; ab->phy.set_suspend = ab8500_usb_set_suspend;
ab->otg.set_peripheral = ab8500_usb_set_peripheral; ab->phy.set_power = ab8500_usb_set_power;
ab->otg.set_suspend = ab8500_usb_set_suspend; ab->phy.state = OTG_STATE_UNDEFINED;
ab->otg.set_power = ab8500_usb_set_power;
otg->phy = &ab->phy;
otg->set_host = ab8500_usb_set_host;
otg->set_peripheral = ab8500_usb_set_peripheral;
platform_set_drvdata(pdev, ab); platform_set_drvdata(pdev, ab);
ATOMIC_INIT_NOTIFIER_HEAD(&ab->otg.notifier); ATOMIC_INIT_NOTIFIER_HEAD(&ab->phy.notifier);
/* v1: Wait for link status to become stable. /* v1: Wait for link status to become stable.
* all: Updates form set_host and set_peripheral as they are atomic. * all: Updates form set_host and set_peripheral as they are atomic.
...@@ -520,7 +529,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev) ...@@ -520,7 +529,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
if (err < 0) if (err < 0)
goto fail0; goto fail0;
err = otg_set_transceiver(&ab->otg); err = usb_set_transceiver(&ab->phy);
if (err) { if (err) {
dev_err(&pdev->dev, "Can't register transceiver\n"); dev_err(&pdev->dev, "Can't register transceiver\n");
goto fail1; goto fail1;
...@@ -532,6 +541,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev) ...@@ -532,6 +541,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
fail1: fail1:
ab8500_usb_irq_free(ab); ab8500_usb_irq_free(ab);
fail0: fail0:
kfree(otg);
kfree(ab); kfree(ab);
return err; return err;
} }
...@@ -546,13 +556,14 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev) ...@@ -546,13 +556,14 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev)
cancel_work_sync(&ab->phy_dis_work); cancel_work_sync(&ab->phy_dis_work);
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
ab8500_usb_host_phy_dis(ab); ab8500_usb_host_phy_dis(ab);
ab8500_usb_peri_phy_dis(ab); ab8500_usb_peri_phy_dis(ab);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(ab->phy.otg);
kfree(ab); kfree(ab);
return 0; return 0;
......
...@@ -275,7 +275,7 @@ void b_srp_end(unsigned long foo) ...@@ -275,7 +275,7 @@ void b_srp_end(unsigned long foo)
fsl_otg_dischrg_vbus(0); fsl_otg_dischrg_vbus(0);
srp_wait_done = 1; srp_wait_done = 1;
if ((fsl_otg_dev->otg.state == OTG_STATE_B_SRP_INIT) && if ((fsl_otg_dev->phy.state == OTG_STATE_B_SRP_INIT) &&
fsl_otg_dev->fsm.b_sess_vld) fsl_otg_dev->fsm.b_sess_vld)
fsl_otg_dev->fsm.b_srp_done = 1; fsl_otg_dev->fsm.b_srp_done = 1;
} }
...@@ -288,7 +288,7 @@ void b_srp_end(unsigned long foo) ...@@ -288,7 +288,7 @@ void b_srp_end(unsigned long foo)
void a_wait_enum(unsigned long foo) void a_wait_enum(unsigned long foo)
{ {
VDBG("a_wait_enum timeout\n"); VDBG("a_wait_enum timeout\n");
if (!fsl_otg_dev->otg.host->b_hnp_enable) if (!fsl_otg_dev->phy.otg->host->b_hnp_enable)
fsl_otg_add_timer(a_wait_enum_tmr); fsl_otg_add_timer(a_wait_enum_tmr);
else else
otg_statemachine(&fsl_otg_dev->fsm); otg_statemachine(&fsl_otg_dev->fsm);
...@@ -452,14 +452,14 @@ void otg_reset_controller(void) ...@@ -452,14 +452,14 @@ void otg_reset_controller(void)
/* Call suspend/resume routines in host driver */ /* Call suspend/resume routines in host driver */
int fsl_otg_start_host(struct otg_fsm *fsm, int on) int fsl_otg_start_host(struct otg_fsm *fsm, int on)
{ {
struct otg_transceiver *xceiv = fsm->transceiver; struct usb_otg *otg = fsm->otg;
struct device *dev; struct device *dev;
struct fsl_otg *otg_dev = container_of(xceiv, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
u32 retval = 0; u32 retval = 0;
if (!xceiv->host) if (!otg->host)
return -ENODEV; return -ENODEV;
dev = xceiv->host->controller; dev = otg->host->controller;
/* /*
* Update a_vbus_vld state as a_vbus_vld int is disabled * Update a_vbus_vld state as a_vbus_vld int is disabled
...@@ -518,14 +518,14 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on) ...@@ -518,14 +518,14 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
*/ */
int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
{ {
struct otg_transceiver *xceiv = fsm->transceiver; struct usb_otg *otg = fsm->otg;
struct device *dev; struct device *dev;
if (!xceiv->gadget || !xceiv->gadget->dev.parent) if (!otg->gadget || !otg->gadget->dev.parent)
return -ENODEV; return -ENODEV;
VDBG("gadget %s\n", on ? "on" : "off"); VDBG("gadget %s\n", on ? "on" : "off");
dev = xceiv->gadget->dev.parent; dev = otg->gadget->dev.parent;
if (on) { if (on) {
if (dev->driver->resume) if (dev->driver->resume)
...@@ -542,14 +542,14 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) ...@@ -542,14 +542,14 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
* Called by initialization code of host driver. Register host controller * Called by initialization code of host driver. Register host controller
* to the OTG. Suspend host for OTG role detection. * to the OTG. Suspend host for OTG role detection.
*/ */
static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
if (!otg_p || otg_dev != fsl_otg_dev) if (!otg || otg_dev != fsl_otg_dev)
return -ENODEV; return -ENODEV;
otg_p->host = host; otg->host = host;
otg_dev->fsm.a_bus_drop = 0; otg_dev->fsm.a_bus_drop = 0;
otg_dev->fsm.a_bus_req = 1; otg_dev->fsm.a_bus_req = 1;
...@@ -557,8 +557,8 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) ...@@ -557,8 +557,8 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
if (host) { if (host) {
VDBG("host off......\n"); VDBG("host off......\n");
otg_p->host->otg_port = fsl_otg_initdata.otg_port; otg->host->otg_port = fsl_otg_initdata.otg_port;
otg_p->host->is_b_host = otg_dev->fsm.id; otg->host->is_b_host = otg_dev->fsm.id;
/* /*
* must leave time for khubd to finish its thing * must leave time for khubd to finish its thing
* before yanking the host driver out from under it, * before yanking the host driver out from under it,
...@@ -574,7 +574,7 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) ...@@ -574,7 +574,7 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
/* Mini-A cable connected */ /* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm; struct otg_fsm *fsm = &otg_dev->fsm;
otg_p->state = OTG_STATE_UNDEFINED; otg->phy->state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF; fsm->protocol = PROTO_UNDEF;
} }
} }
...@@ -587,29 +587,29 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) ...@@ -587,29 +587,29 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
} }
/* Called by initialization code of udc. Register udc to OTG. */ /* Called by initialization code of udc. Register udc to OTG. */
static int fsl_otg_set_peripheral(struct otg_transceiver *otg_p, static int fsl_otg_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget) struct usb_gadget *gadget)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
VDBG("otg_dev 0x%x\n", (int)otg_dev); VDBG("otg_dev 0x%x\n", (int)otg_dev);
VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev);
if (!otg_p || otg_dev != fsl_otg_dev) if (!otg || otg_dev != fsl_otg_dev)
return -ENODEV; return -ENODEV;
if (!gadget) { if (!gadget) {
if (!otg_dev->otg.default_a) if (!otg->default_a)
otg_p->gadget->ops->vbus_draw(otg_p->gadget, 0); otg->gadget->ops->vbus_draw(otg->gadget, 0);
usb_gadget_vbus_disconnect(otg_dev->otg.gadget); usb_gadget_vbus_disconnect(otg->gadget);
otg_dev->otg.gadget = 0; otg->gadget = 0;
otg_dev->fsm.b_bus_req = 0; otg_dev->fsm.b_bus_req = 0;
otg_statemachine(&otg_dev->fsm); otg_statemachine(&otg_dev->fsm);
return 0; return 0;
} }
otg_p->gadget = gadget; otg->gadget = gadget;
otg_p->gadget->is_a_peripheral = !otg_dev->fsm.id; otg->gadget->is_a_peripheral = !otg_dev->fsm.id;
otg_dev->fsm.b_bus_req = 1; otg_dev->fsm.b_bus_req = 1;
...@@ -625,11 +625,11 @@ static int fsl_otg_set_peripheral(struct otg_transceiver *otg_p, ...@@ -625,11 +625,11 @@ static int fsl_otg_set_peripheral(struct otg_transceiver *otg_p,
} }
/* Set OTG port power, only for B-device */ /* Set OTG port power, only for B-device */
static int fsl_otg_set_power(struct otg_transceiver *otg_p, unsigned mA) static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{ {
if (!fsl_otg_dev) if (!fsl_otg_dev)
return -ENODEV; return -ENODEV;
if (otg_p->state == OTG_STATE_B_PERIPHERAL) if (phy->state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA); pr_info("FSL OTG: Draw %d mA\n", mA);
return 0; return 0;
...@@ -658,12 +658,12 @@ static void fsl_otg_event(struct work_struct *work) ...@@ -658,12 +658,12 @@ static void fsl_otg_event(struct work_struct *work)
} }
/* B-device start SRP */ /* B-device start SRP */
static int fsl_otg_start_srp(struct otg_transceiver *otg_p) static int fsl_otg_start_srp(struct usb_otg *otg)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
if (!otg_p || otg_dev != fsl_otg_dev if (!otg || otg_dev != fsl_otg_dev
|| otg_p->state != OTG_STATE_B_IDLE) || otg->phy->state != OTG_STATE_B_IDLE)
return -ENODEV; return -ENODEV;
otg_dev->fsm.b_bus_req = 1; otg_dev->fsm.b_bus_req = 1;
...@@ -673,11 +673,11 @@ static int fsl_otg_start_srp(struct otg_transceiver *otg_p) ...@@ -673,11 +673,11 @@ static int fsl_otg_start_srp(struct otg_transceiver *otg_p)
} }
/* A_host suspend will call this function to start hnp */ /* A_host suspend will call this function to start hnp */
static int fsl_otg_start_hnp(struct otg_transceiver *otg_p) static int fsl_otg_start_hnp(struct usb_otg *otg)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
if (!otg_p || otg_dev != fsl_otg_dev) if (!otg || otg_dev != fsl_otg_dev)
return -ENODEV; return -ENODEV;
DBG("start_hnp...n"); DBG("start_hnp...n");
...@@ -698,7 +698,7 @@ static int fsl_otg_start_hnp(struct otg_transceiver *otg_p) ...@@ -698,7 +698,7 @@ static int fsl_otg_start_hnp(struct otg_transceiver *otg_p)
irqreturn_t fsl_otg_isr(int irq, void *dev_id) irqreturn_t fsl_otg_isr(int irq, void *dev_id)
{ {
struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm; struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm;
struct otg_transceiver *otg = &((struct fsl_otg *)dev_id)->otg; struct usb_otg *otg = ((struct fsl_otg *)dev_id)->phy.otg;
u32 otg_int_src, otg_sc; u32 otg_int_src, otg_sc;
otg_sc = fsl_readl(&usb_dr_regs->otgsc); otg_sc = fsl_readl(&usb_dr_regs->otgsc);
...@@ -774,6 +774,12 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -774,6 +774,12 @@ static int fsl_otg_conf(struct platform_device *pdev)
if (!fsl_otg_tc) if (!fsl_otg_tc)
return -ENOMEM; return -ENOMEM;
fsl_otg_tc->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
if (!fsl_otg_tc->phy.otg) {
kfree(fsl_otg_tc);
return -ENOMEM;
}
INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event); INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event);
INIT_LIST_HEAD(&active_timers); INIT_LIST_HEAD(&active_timers);
...@@ -788,17 +794,19 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -788,17 +794,19 @@ static int fsl_otg_conf(struct platform_device *pdev)
fsl_otg_tc->fsm.ops = &fsl_otg_ops; fsl_otg_tc->fsm.ops = &fsl_otg_ops;
/* initialize the otg structure */ /* initialize the otg structure */
fsl_otg_tc->otg.label = DRIVER_DESC; fsl_otg_tc->phy.label = DRIVER_DESC;
fsl_otg_tc->otg.set_host = fsl_otg_set_host; fsl_otg_tc->phy.set_power = fsl_otg_set_power;
fsl_otg_tc->otg.set_peripheral = fsl_otg_set_peripheral;
fsl_otg_tc->otg.set_power = fsl_otg_set_power; fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy;
fsl_otg_tc->otg.start_hnp = fsl_otg_start_hnp; fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host;
fsl_otg_tc->otg.start_srp = fsl_otg_start_srp; fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral;
fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp;
fsl_otg_tc->phy.otg->start_srp = fsl_otg_start_srp;
fsl_otg_dev = fsl_otg_tc; fsl_otg_dev = fsl_otg_tc;
/* Store the otg transceiver */ /* Store the otg transceiver */
status = otg_set_transceiver(&fsl_otg_tc->otg); status = usb_set_transceiver(&fsl_otg_tc->phy);
if (status) { if (status) {
pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n"); pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n");
goto err; goto err;
...@@ -807,6 +815,7 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -807,6 +815,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
return 0; return 0;
err: err:
fsl_otg_uninit_timers(); fsl_otg_uninit_timers();
kfree(fsl_otg_tc->phy.otg);
kfree(fsl_otg_tc); kfree(fsl_otg_tc);
return status; return status;
} }
...@@ -815,19 +824,19 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -815,19 +824,19 @@ static int fsl_otg_conf(struct platform_device *pdev)
int usb_otg_start(struct platform_device *pdev) int usb_otg_start(struct platform_device *pdev)
{ {
struct fsl_otg *p_otg; struct fsl_otg *p_otg;
struct otg_transceiver *otg_trans = otg_get_transceiver(); struct usb_phy *otg_trans = usb_get_transceiver();
struct otg_fsm *fsm; struct otg_fsm *fsm;
int status; int status;
struct resource *res; struct resource *res;
u32 temp; u32 temp;
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
p_otg = container_of(otg_trans, struct fsl_otg, otg); p_otg = container_of(otg_trans, struct fsl_otg, phy);
fsm = &p_otg->fsm; fsm = &p_otg->fsm;
/* Initialize the state machine structure with default values */ /* Initialize the state machine structure with default values */
SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED); SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED);
fsm->transceiver = &p_otg->otg; fsm->otg = p_otg->phy.otg;
/* We don't require predefined MEM/IRQ resource index */ /* We don't require predefined MEM/IRQ resource index */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -857,9 +866,10 @@ int usb_otg_start(struct platform_device *pdev) ...@@ -857,9 +866,10 @@ int usb_otg_start(struct platform_device *pdev)
status = request_irq(p_otg->irq, fsl_otg_isr, status = request_irq(p_otg->irq, fsl_otg_isr,
IRQF_SHARED, driver_name, p_otg); IRQF_SHARED, driver_name, p_otg);
if (status) { if (status) {
dev_dbg(p_otg->otg.dev, "can't get IRQ %d, error %d\n", dev_dbg(p_otg->phy.dev, "can't get IRQ %d, error %d\n",
p_otg->irq, status); p_otg->irq, status);
iounmap(p_otg->dr_mem_map); iounmap(p_otg->dr_mem_map);
kfree(p_otg->phy.otg);
kfree(p_otg); kfree(p_otg);
return status; return status;
} }
...@@ -919,10 +929,10 @@ int usb_otg_start(struct platform_device *pdev) ...@@ -919,10 +929,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin * Also: record initial state of ID pin
*/ */
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
p_otg->otg.state = OTG_STATE_UNDEFINED; p_otg->phy.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1; p_otg->fsm.id = 1;
} else { } else {
p_otg->otg.state = OTG_STATE_A_IDLE; p_otg->phy.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0; p_otg->fsm.id = 0;
} }
...@@ -978,7 +988,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, ...@@ -978,7 +988,7 @@ static int show_fsl_usb2_otg_state(struct device *dev,
/* State */ /* State */
t = scnprintf(next, size, t = scnprintf(next, size,
"OTG state: %s\n\n", "OTG state: %s\n\n",
otg_state_string(fsl_otg_dev->otg.state)); otg_state_string(fsl_otg_dev->phy.state));
size -= t; size -= t;
next += t; next += t;
...@@ -1124,12 +1134,13 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev) ...@@ -1124,12 +1134,13 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev)
{ {
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
free_irq(fsl_otg_dev->irq, fsl_otg_dev); free_irq(fsl_otg_dev->irq, fsl_otg_dev);
iounmap((void *)usb_dr_regs); iounmap((void *)usb_dr_regs);
fsl_otg_uninit_timers(); fsl_otg_uninit_timers();
kfree(fsl_otg_dev->phy.otg);
kfree(fsl_otg_dev); kfree(fsl_otg_dev);
device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state);
......
...@@ -369,7 +369,7 @@ inline struct fsl_otg_timer *otg_timer_initializer ...@@ -369,7 +369,7 @@ inline struct fsl_otg_timer *otg_timer_initializer
} }
struct fsl_otg { struct fsl_otg {
struct otg_transceiver otg; struct usb_phy phy;
struct otg_fsm fsm; struct otg_fsm fsm;
struct usb_dr_mmap *dr_mem_map; struct usb_dr_mmap *dr_mem_map;
struct delayed_work otg_event; struct delayed_work otg_event;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* Needs to be loaded before the UDC driver that will use it. * Needs to be loaded before the UDC driver that will use it.
*/ */
struct gpio_vbus_data { struct gpio_vbus_data {
struct otg_transceiver otg; struct usb_phy phy;
struct device *dev; struct device *dev;
struct regulator *vbus_draw; struct regulator *vbus_draw;
int vbus_draw_enabled; int vbus_draw_enabled;
...@@ -98,7 +98,7 @@ static void gpio_vbus_work(struct work_struct *work) ...@@ -98,7 +98,7 @@ static void gpio_vbus_work(struct work_struct *work)
struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data;
int gpio; int gpio;
if (!gpio_vbus->otg.gadget) if (!gpio_vbus->phy.otg->gadget)
return; return;
/* Peripheral controllers which manage the pullup themselves won't have /* Peripheral controllers which manage the pullup themselves won't have
...@@ -108,8 +108,8 @@ static void gpio_vbus_work(struct work_struct *work) ...@@ -108,8 +108,8 @@ static void gpio_vbus_work(struct work_struct *work)
*/ */
gpio = pdata->gpio_pullup; gpio = pdata->gpio_pullup;
if (is_vbus_powered(pdata)) { if (is_vbus_powered(pdata)) {
gpio_vbus->otg.state = OTG_STATE_B_PERIPHERAL; gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
usb_gadget_vbus_connect(gpio_vbus->otg.gadget); usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
/* drawing a "unit load" is *always* OK, except for OTG */ /* drawing a "unit load" is *always* OK, except for OTG */
set_vbus_draw(gpio_vbus, 100); set_vbus_draw(gpio_vbus, 100);
...@@ -124,8 +124,8 @@ static void gpio_vbus_work(struct work_struct *work) ...@@ -124,8 +124,8 @@ static void gpio_vbus_work(struct work_struct *work)
set_vbus_draw(gpio_vbus, 0); set_vbus_draw(gpio_vbus, 0);
usb_gadget_vbus_disconnect(gpio_vbus->otg.gadget); usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
gpio_vbus->otg.state = OTG_STATE_B_IDLE; gpio_vbus->phy.state = OTG_STATE_B_IDLE;
} }
} }
...@@ -135,12 +135,13 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data) ...@@ -135,12 +135,13 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data)
struct platform_device *pdev = data; struct platform_device *pdev = data;
struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data;
struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
struct usb_otg *otg = gpio_vbus->phy.otg;
dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n", dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
is_vbus_powered(pdata) ? "supplied" : "inactive", is_vbus_powered(pdata) ? "supplied" : "inactive",
gpio_vbus->otg.gadget ? gpio_vbus->otg.gadget->name : "none"); otg->gadget ? otg->gadget->name : "none");
if (gpio_vbus->otg.gadget) if (otg->gadget)
schedule_work(&gpio_vbus->work); schedule_work(&gpio_vbus->work);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -149,7 +150,7 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data) ...@@ -149,7 +150,7 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data)
/* OTG transceiver interface */ /* OTG transceiver interface */
/* bind/unbind the peripheral controller */ /* bind/unbind the peripheral controller */
static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, static int gpio_vbus_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget) struct usb_gadget *gadget)
{ {
struct gpio_vbus_data *gpio_vbus; struct gpio_vbus_data *gpio_vbus;
...@@ -157,7 +158,7 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, ...@@ -157,7 +158,7 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg,
struct platform_device *pdev; struct platform_device *pdev;
int gpio, irq; int gpio, irq;
gpio_vbus = container_of(otg, struct gpio_vbus_data, otg); gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy);
pdev = to_platform_device(gpio_vbus->dev); pdev = to_platform_device(gpio_vbus->dev);
pdata = gpio_vbus->dev->platform_data; pdata = gpio_vbus->dev->platform_data;
irq = gpio_to_irq(pdata->gpio_vbus); irq = gpio_to_irq(pdata->gpio_vbus);
...@@ -174,7 +175,7 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, ...@@ -174,7 +175,7 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg,
set_vbus_draw(gpio_vbus, 0); set_vbus_draw(gpio_vbus, 0);
usb_gadget_vbus_disconnect(otg->gadget); usb_gadget_vbus_disconnect(otg->gadget);
otg->state = OTG_STATE_UNDEFINED; otg->phy->state = OTG_STATE_UNDEFINED;
otg->gadget = NULL; otg->gadget = NULL;
return 0; return 0;
...@@ -189,23 +190,23 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, ...@@ -189,23 +190,23 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg,
} }
/* effective for B devices, ignored for A-peripheral */ /* effective for B devices, ignored for A-peripheral */
static int gpio_vbus_set_power(struct otg_transceiver *otg, unsigned mA) static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)
{ {
struct gpio_vbus_data *gpio_vbus; struct gpio_vbus_data *gpio_vbus;
gpio_vbus = container_of(otg, struct gpio_vbus_data, otg); gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);
if (otg->state == OTG_STATE_B_PERIPHERAL) if (phy->state == OTG_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA); set_vbus_draw(gpio_vbus, mA);
return 0; return 0;
} }
/* for non-OTG B devices: set/clear transceiver suspend mode */ /* for non-OTG B devices: set/clear transceiver suspend mode */
static int gpio_vbus_set_suspend(struct otg_transceiver *otg, int suspend) static int gpio_vbus_set_suspend(struct usb_phy *phy, int suspend)
{ {
struct gpio_vbus_data *gpio_vbus; struct gpio_vbus_data *gpio_vbus;
gpio_vbus = container_of(otg, struct gpio_vbus_data, otg); gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);
/* draw max 0 mA from vbus in suspend mode; or the previously /* draw max 0 mA from vbus in suspend mode; or the previously
* recorded amount of current if not suspended * recorded amount of current if not suspended
...@@ -213,7 +214,7 @@ static int gpio_vbus_set_suspend(struct otg_transceiver *otg, int suspend) ...@@ -213,7 +214,7 @@ static int gpio_vbus_set_suspend(struct otg_transceiver *otg, int suspend)
* NOTE: high powered configs (mA > 100) may draw up to 2.5 mA * NOTE: high powered configs (mA > 100) may draw up to 2.5 mA
* if they're wake-enabled ... we don't handle that yet. * if they're wake-enabled ... we don't handle that yet.
*/ */
return gpio_vbus_set_power(otg, suspend ? 0 : gpio_vbus->mA); return gpio_vbus_set_power(phy, suspend ? 0 : gpio_vbus->mA);
} }
/* platform driver interface */ /* platform driver interface */
...@@ -233,13 +234,21 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) ...@@ -233,13 +234,21 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
if (!gpio_vbus) if (!gpio_vbus)
return -ENOMEM; return -ENOMEM;
gpio_vbus->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
if (!gpio_vbus->phy.otg) {
kfree(gpio_vbus);
return -ENOMEM;
}
platform_set_drvdata(pdev, gpio_vbus); platform_set_drvdata(pdev, gpio_vbus);
gpio_vbus->dev = &pdev->dev; gpio_vbus->dev = &pdev->dev;
gpio_vbus->otg.label = "gpio-vbus"; gpio_vbus->phy.label = "gpio-vbus";
gpio_vbus->otg.state = OTG_STATE_UNDEFINED; gpio_vbus->phy.set_power = gpio_vbus_set_power;
gpio_vbus->otg.set_peripheral = gpio_vbus_set_peripheral; gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
gpio_vbus->otg.set_power = gpio_vbus_set_power; gpio_vbus->phy.state = OTG_STATE_UNDEFINED;
gpio_vbus->otg.set_suspend = gpio_vbus_set_suspend;
gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
err = gpio_request(gpio, "vbus_detect"); err = gpio_request(gpio, "vbus_detect");
if (err) { if (err) {
...@@ -288,7 +297,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) ...@@ -288,7 +297,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
} }
/* only active when a gadget is registered */ /* only active when a gadget is registered */
err = otg_set_transceiver(&gpio_vbus->otg); err = usb_set_transceiver(&gpio_vbus->phy);
if (err) { if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n", dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err); err);
...@@ -304,6 +313,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) ...@@ -304,6 +313,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
gpio_free(pdata->gpio_vbus); gpio_free(pdata->gpio_vbus);
err_gpio: err_gpio:
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(gpio_vbus->phy.otg);
kfree(gpio_vbus); kfree(gpio_vbus);
return err; return err;
} }
...@@ -316,13 +326,14 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev) ...@@ -316,13 +326,14 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev)
regulator_put(gpio_vbus->vbus_draw); regulator_put(gpio_vbus->vbus_draw);
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
free_irq(gpio_to_irq(gpio), &pdev->dev); free_irq(gpio_to_irq(gpio), &pdev->dev);
if (gpio_is_valid(pdata->gpio_pullup)) if (gpio_is_valid(pdata->gpio_pullup))
gpio_free(pdata->gpio_pullup); gpio_free(pdata->gpio_pullup);
gpio_free(gpio); gpio_free(gpio);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(gpio_vbus->phy.otg);
kfree(gpio_vbus); kfree(gpio_vbus);
return 0; return 0;
......
此差异已折叠。
此差异已折叠。
...@@ -55,16 +55,16 @@ static char *state_string[] = { ...@@ -55,16 +55,16 @@ static char *state_string[] = {
"a_vbus_err" "a_vbus_err"
}; };
static int mv_otg_set_vbus(struct otg_transceiver *otg, bool on) static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
{ {
struct mv_otg *mvotg = container_of(otg, struct mv_otg, otg); struct mv_otg *mvotg = container_of(otg->phy, struct mv_otg, phy);
if (mvotg->pdata->set_vbus == NULL) if (mvotg->pdata->set_vbus == NULL)
return -ENODEV; return -ENODEV;
return mvotg->pdata->set_vbus(on); return mvotg->pdata->set_vbus(on);
} }
static int mv_otg_set_host(struct otg_transceiver *otg, static int mv_otg_set_host(struct usb_otg *otg,
struct usb_bus *host) struct usb_bus *host)
{ {
otg->host = host; otg->host = host;
...@@ -72,7 +72,7 @@ static int mv_otg_set_host(struct otg_transceiver *otg, ...@@ -72,7 +72,7 @@ static int mv_otg_set_host(struct otg_transceiver *otg,
return 0; return 0;
} }
static int mv_otg_set_peripheral(struct otg_transceiver *otg, static int mv_otg_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget) struct usb_gadget *gadget)
{ {
otg->gadget = gadget; otg->gadget = gadget;
...@@ -203,7 +203,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg) ...@@ -203,7 +203,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
static void mv_otg_start_host(struct mv_otg *mvotg, int on) static void mv_otg_start_host(struct mv_otg *mvotg, int on)
{ {
#ifdef CONFIG_USB #ifdef CONFIG_USB
struct otg_transceiver *otg = &mvotg->otg; struct usb_otg *otg = mvotg->phy.otg;
struct usb_hcd *hcd; struct usb_hcd *hcd;
if (!otg->host) if (!otg->host)
...@@ -222,12 +222,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on) ...@@ -222,12 +222,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
{ {
struct otg_transceiver *otg = &mvotg->otg; struct usb_otg *otg = mvotg->phy.otg;
if (!otg->gadget) if (!otg->gadget)
return; return;
dev_info(otg->dev, "gadget %s\n", on ? "on" : "off"); dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off");
if (on) if (on)
usb_gadget_vbus_connect(otg->gadget); usb_gadget_vbus_connect(otg->gadget);
...@@ -343,69 +343,69 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg) ...@@ -343,69 +343,69 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
static void mv_otg_update_state(struct mv_otg *mvotg) static void mv_otg_update_state(struct mv_otg *mvotg)
{ {
struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
struct otg_transceiver *otg = &mvotg->otg; struct usb_phy *phy = &mvotg->phy;
int old_state = otg->state; int old_state = phy->state;
switch (old_state) { switch (old_state) {
case OTG_STATE_UNDEFINED: case OTG_STATE_UNDEFINED:
otg->state = OTG_STATE_B_IDLE; phy->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */ /* FALL THROUGH */
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
if (otg_ctrl->id == 0) if (otg_ctrl->id == 0)
otg->state = OTG_STATE_A_IDLE; phy->state = OTG_STATE_A_IDLE;
else if (otg_ctrl->b_sess_vld) else if (otg_ctrl->b_sess_vld)
otg->state = OTG_STATE_B_PERIPHERAL; phy->state = OTG_STATE_B_PERIPHERAL;
break; break;
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
otg->state = OTG_STATE_B_IDLE; phy->state = OTG_STATE_B_IDLE;
break; break;
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
if (otg_ctrl->id) if (otg_ctrl->id)
otg->state = OTG_STATE_B_IDLE; phy->state = OTG_STATE_B_IDLE;
else if (!(otg_ctrl->a_bus_drop) && else if (!(otg_ctrl->a_bus_drop) &&
(otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
otg->state = OTG_STATE_A_WAIT_VRISE; phy->state = OTG_STATE_A_WAIT_VRISE;
break; break;
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
if (otg_ctrl->a_vbus_vld) if (otg_ctrl->a_vbus_vld)
otg->state = OTG_STATE_A_WAIT_BCON; phy->state = OTG_STATE_A_WAIT_BCON;
break; break;
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
if (otg_ctrl->id || otg_ctrl->a_bus_drop if (otg_ctrl->id || otg_ctrl->a_bus_drop
|| otg_ctrl->a_wait_bcon_timeout) { || otg_ctrl->a_wait_bcon_timeout) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0; mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
otg->state = OTG_STATE_A_WAIT_VFALL; phy->state = OTG_STATE_A_WAIT_VFALL;
otg_ctrl->a_bus_req = 0; otg_ctrl->a_bus_req = 0;
} else if (!otg_ctrl->a_vbus_vld) { } else if (!otg_ctrl->a_vbus_vld) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0; mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
otg->state = OTG_STATE_A_VBUS_ERR; phy->state = OTG_STATE_A_VBUS_ERR;
} else if (otg_ctrl->b_conn) { } else if (otg_ctrl->b_conn) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0; mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
otg->state = OTG_STATE_A_HOST; phy->state = OTG_STATE_A_HOST;
} }
break; break;
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
if (otg_ctrl->id || !otg_ctrl->b_conn if (otg_ctrl->id || !otg_ctrl->b_conn
|| otg_ctrl->a_bus_drop) || otg_ctrl->a_bus_drop)
otg->state = OTG_STATE_A_WAIT_BCON; phy->state = OTG_STATE_A_WAIT_BCON;
else if (!otg_ctrl->a_vbus_vld) else if (!otg_ctrl->a_vbus_vld)
otg->state = OTG_STATE_A_VBUS_ERR; phy->state = OTG_STATE_A_VBUS_ERR;
break; break;
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
if (otg_ctrl->id if (otg_ctrl->id
|| (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
|| otg_ctrl->a_bus_req) || otg_ctrl->a_bus_req)
otg->state = OTG_STATE_A_IDLE; phy->state = OTG_STATE_A_IDLE;
break; break;
case OTG_STATE_A_VBUS_ERR: case OTG_STATE_A_VBUS_ERR:
if (otg_ctrl->id || otg_ctrl->a_clr_err if (otg_ctrl->id || otg_ctrl->a_clr_err
|| otg_ctrl->a_bus_drop) { || otg_ctrl->a_bus_drop) {
otg_ctrl->a_clr_err = 0; otg_ctrl->a_clr_err = 0;
otg->state = OTG_STATE_A_WAIT_VFALL; phy->state = OTG_STATE_A_WAIT_VFALL;
} }
break; break;
default: default:
...@@ -416,15 +416,17 @@ static void mv_otg_update_state(struct mv_otg *mvotg) ...@@ -416,15 +416,17 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
static void mv_otg_work(struct work_struct *work) static void mv_otg_work(struct work_struct *work)
{ {
struct mv_otg *mvotg; struct mv_otg *mvotg;
struct otg_transceiver *otg; struct usb_phy *phy;
struct usb_otg *otg;
int old_state; int old_state;
mvotg = container_of((struct delayed_work *)work, struct mv_otg, work); mvotg = container_of((struct delayed_work *)work, struct mv_otg, work);
run: run:
/* work queue is single thread, or we need spin_lock to protect */ /* work queue is single thread, or we need spin_lock to protect */
otg = &mvotg->otg; phy = &mvotg->phy;
old_state = otg->state; otg = phy->otg;
old_state = phy->state;
if (!mvotg->active) if (!mvotg->active)
return; return;
...@@ -432,14 +434,14 @@ static void mv_otg_work(struct work_struct *work) ...@@ -432,14 +434,14 @@ static void mv_otg_work(struct work_struct *work)
mv_otg_update_inputs(mvotg); mv_otg_update_inputs(mvotg);
mv_otg_update_state(mvotg); mv_otg_update_state(mvotg);
if (old_state != otg->state) { if (old_state != phy->state) {
dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
state_string[old_state], state_string[old_state],
state_string[otg->state]); state_string[phy->state]);
switch (otg->state) { switch (phy->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
mvotg->otg.default_a = 0; otg->default_a = 0;
if (old_state == OTG_STATE_B_PERIPHERAL) if (old_state == OTG_STATE_B_PERIPHERAL)
mv_otg_start_periphrals(mvotg, 0); mv_otg_start_periphrals(mvotg, 0);
mv_otg_reset(mvotg); mv_otg_reset(mvotg);
...@@ -450,14 +452,14 @@ static void mv_otg_work(struct work_struct *work) ...@@ -450,14 +452,14 @@ static void mv_otg_work(struct work_struct *work)
mv_otg_start_periphrals(mvotg, 1); mv_otg_start_periphrals(mvotg, 1);
break; break;
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
mvotg->otg.default_a = 1; otg->default_a = 1;
mv_otg_enable(mvotg); mv_otg_enable(mvotg);
if (old_state == OTG_STATE_A_WAIT_VFALL) if (old_state == OTG_STATE_A_WAIT_VFALL)
mv_otg_start_host(mvotg, 0); mv_otg_start_host(mvotg, 0);
mv_otg_reset(mvotg); mv_otg_reset(mvotg);
break; break;
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
mv_otg_set_vbus(&mvotg->otg, 1); mv_otg_set_vbus(otg, 1);
break; break;
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
if (old_state != OTG_STATE_A_HOST) if (old_state != OTG_STATE_A_HOST)
...@@ -479,7 +481,7 @@ static void mv_otg_work(struct work_struct *work) ...@@ -479,7 +481,7 @@ static void mv_otg_work(struct work_struct *work)
* here. In fact, it need host driver to notify us. * here. In fact, it need host driver to notify us.
*/ */
mvotg->otg_ctrl.b_conn = 0; mvotg->otg_ctrl.b_conn = 0;
mv_otg_set_vbus(&mvotg->otg, 0); mv_otg_set_vbus(otg, 0);
break; break;
case OTG_STATE_A_VBUS_ERR: case OTG_STATE_A_VBUS_ERR:
break; break;
...@@ -548,8 +550,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr, ...@@ -548,8 +550,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return -1; return -1;
/* We will use this interface to change to A device */ /* We will use this interface to change to A device */
if (mvotg->otg.state != OTG_STATE_B_IDLE if (mvotg->phy.state != OTG_STATE_B_IDLE
&& mvotg->otg.state != OTG_STATE_A_IDLE) && mvotg->phy.state != OTG_STATE_A_IDLE)
return -1; return -1;
/* The clock may disabled and we need to set irq for ID detected */ /* The clock may disabled and we need to set irq for ID detected */
...@@ -579,7 +581,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr, ...@@ -579,7 +581,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct mv_otg *mvotg = dev_get_drvdata(dev); struct mv_otg *mvotg = dev_get_drvdata(dev);
if (!mvotg->otg.default_a) if (!mvotg->phy.otg->default_a)
return -1; return -1;
if (count > 2) if (count > 2)
...@@ -615,7 +617,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr, ...@@ -615,7 +617,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct mv_otg *mvotg = dev_get_drvdata(dev); struct mv_otg *mvotg = dev_get_drvdata(dev);
if (!mvotg->otg.default_a) if (!mvotg->phy.otg->default_a)
return -1; return -1;
if (count > 2) if (count > 2)
...@@ -688,9 +690,10 @@ int mv_otg_remove(struct platform_device *pdev) ...@@ -688,9 +690,10 @@ int mv_otg_remove(struct platform_device *pdev)
for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++) for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++)
clk_put(mvotg->clk[clk_i]); clk_put(mvotg->clk[clk_i]);
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(mvotg->phy.otg);
kfree(mvotg); kfree(mvotg);
return 0; return 0;
...@@ -700,6 +703,7 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -700,6 +703,7 @@ static int mv_otg_probe(struct platform_device *pdev)
{ {
struct mv_usb_platform_data *pdata = pdev->dev.platform_data; struct mv_usb_platform_data *pdata = pdev->dev.platform_data;
struct mv_otg *mvotg; struct mv_otg *mvotg;
struct usb_otg *otg;
struct resource *r; struct resource *r;
int retval = 0, clk_i, i; int retval = 0, clk_i, i;
size_t size; size_t size;
...@@ -716,6 +720,12 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -716,6 +720,12 @@ static int mv_otg_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
otg = kzalloc(sizeof *otg, GFP_KERNEL);
if (!otg) {
kfree(mvotg);
return -ENOMEM;
}
platform_set_drvdata(pdev, mvotg); platform_set_drvdata(pdev, mvotg);
mvotg->pdev = pdev; mvotg->pdev = pdev;
...@@ -741,12 +751,15 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -741,12 +751,15 @@ static int mv_otg_probe(struct platform_device *pdev)
/* OTG common part */ /* OTG common part */
mvotg->pdev = pdev; mvotg->pdev = pdev;
mvotg->otg.dev = &pdev->dev; mvotg->phy.dev = &pdev->dev;
mvotg->otg.label = driver_name; mvotg->phy.otg = otg;
mvotg->otg.set_host = mv_otg_set_host; mvotg->phy.label = driver_name;
mvotg->otg.set_peripheral = mv_otg_set_peripheral; mvotg->phy.state = OTG_STATE_UNDEFINED;
mvotg->otg.set_vbus = mv_otg_set_vbus;
mvotg->otg.state = OTG_STATE_UNDEFINED; otg->phy = &mvotg->phy;
otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus;
for (i = 0; i < OTG_TIMER_NUM; i++) for (i = 0; i < OTG_TIMER_NUM; i++)
init_timer(&mvotg->otg_ctrl.timer[i]); init_timer(&mvotg->otg_ctrl.timer[i]);
...@@ -840,7 +853,7 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -840,7 +853,7 @@ static int mv_otg_probe(struct platform_device *pdev)
goto err_disable_clk; goto err_disable_clk;
} }
retval = otg_set_transceiver(&mvotg->otg); retval = usb_set_transceiver(&mvotg->phy);
if (retval < 0) { if (retval < 0) {
dev_err(&pdev->dev, "can't register transceiver, %d\n", dev_err(&pdev->dev, "can't register transceiver, %d\n",
retval); retval);
...@@ -867,7 +880,7 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -867,7 +880,7 @@ static int mv_otg_probe(struct platform_device *pdev)
return 0; return 0;
err_set_transceiver: err_set_transceiver:
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
err_free_irq: err_free_irq:
free_irq(mvotg->irq, mvotg); free_irq(mvotg->irq, mvotg);
err_disable_clk: err_disable_clk:
...@@ -888,6 +901,7 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -888,6 +901,7 @@ static int mv_otg_probe(struct platform_device *pdev)
clk_put(mvotg->clk[clk_i]); clk_put(mvotg->clk[clk_i]);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(otg);
kfree(mvotg); kfree(mvotg);
return retval; return retval;
...@@ -898,10 +912,10 @@ static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -898,10 +912,10 @@ static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state)
{ {
struct mv_otg *mvotg = platform_get_drvdata(pdev); struct mv_otg *mvotg = platform_get_drvdata(pdev);
if (mvotg->otg.state != OTG_STATE_B_IDLE) { if (mvotg->phy.state != OTG_STATE_B_IDLE) {
dev_info(&pdev->dev, dev_info(&pdev->dev,
"OTG state is not B_IDLE, it is %d!\n", "OTG state is not B_IDLE, it is %d!\n",
mvotg->otg.state); mvotg->phy.state);
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -136,7 +136,7 @@ struct mv_otg_regs { ...@@ -136,7 +136,7 @@ struct mv_otg_regs {
}; };
struct mv_otg { struct mv_otg {
struct otg_transceiver otg; struct usb_phy phy;
struct mv_otg_ctrl otg_ctrl; struct mv_otg_ctrl otg_ctrl;
/* base address */ /* base address */
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <linux/slab.h> #include <linux/slab.h>
struct nop_usb_xceiv { struct nop_usb_xceiv {
struct otg_transceiver otg; struct usb_phy phy;
struct device *dev; struct device *dev;
}; };
...@@ -58,51 +58,37 @@ void usb_nop_xceiv_unregister(void) ...@@ -58,51 +58,37 @@ void usb_nop_xceiv_unregister(void)
} }
EXPORT_SYMBOL(usb_nop_xceiv_unregister); EXPORT_SYMBOL(usb_nop_xceiv_unregister);
static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x) static int nop_set_suspend(struct usb_phy *x, int suspend)
{
return container_of(x, struct nop_usb_xceiv, otg);
}
static int nop_set_suspend(struct otg_transceiver *x, int suspend)
{ {
return 0; return 0;
} }
static int nop_set_peripheral(struct otg_transceiver *x, static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
struct usb_gadget *gadget)
{ {
struct nop_usb_xceiv *nop; if (!otg)
if (!x)
return -ENODEV; return -ENODEV;
nop = xceiv_to_nop(x);
if (!gadget) { if (!gadget) {
nop->otg.gadget = NULL; otg->gadget = NULL;
return -ENODEV; return -ENODEV;
} }
nop->otg.gadget = gadget; otg->gadget = gadget;
nop->otg.state = OTG_STATE_B_IDLE; otg->phy->state = OTG_STATE_B_IDLE;
return 0; return 0;
} }
static int nop_set_host(struct otg_transceiver *x, struct usb_bus *host) static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
{ {
struct nop_usb_xceiv *nop; if (!otg)
if (!x)
return -ENODEV; return -ENODEV;
nop = xceiv_to_nop(x);
if (!host) { if (!host) {
nop->otg.host = NULL; otg->host = NULL;
return -ENODEV; return -ENODEV;
} }
nop->otg.host = host; otg->host = host;
return 0; return 0;
} }
...@@ -115,15 +101,23 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) ...@@ -115,15 +101,23 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
if (!nop) if (!nop)
return -ENOMEM; return -ENOMEM;
nop->phy.otg = kzalloc(sizeof *nop->phy.otg, GFP_KERNEL);
if (!nop->phy.otg) {
kfree(nop);
return -ENOMEM;
}
nop->dev = &pdev->dev; nop->dev = &pdev->dev;
nop->otg.dev = nop->dev; nop->phy.dev = nop->dev;
nop->otg.label = "nop-xceiv"; nop->phy.label = "nop-xceiv";
nop->otg.state = OTG_STATE_UNDEFINED; nop->phy.set_suspend = nop_set_suspend;
nop->otg.set_host = nop_set_host; nop->phy.state = OTG_STATE_UNDEFINED;
nop->otg.set_peripheral = nop_set_peripheral;
nop->otg.set_suspend = nop_set_suspend; nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
err = otg_set_transceiver(&nop->otg); nop->phy.otg->set_peripheral = nop_set_peripheral;
err = usb_set_transceiver(&nop->phy);
if (err) { if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n", dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err); err);
...@@ -132,10 +126,11 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) ...@@ -132,10 +126,11 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, nop); platform_set_drvdata(pdev, nop);
ATOMIC_INIT_NOTIFIER_HEAD(&nop->otg.notifier); ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier);
return 0; return 0;
exit: exit:
kfree(nop->phy.otg);
kfree(nop); kfree(nop);
return err; return err;
} }
...@@ -144,9 +139,10 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) ...@@ -144,9 +139,10 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
{ {
struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(nop->phy.otg);
kfree(nop); kfree(nop);
return 0; return 0;
......
...@@ -15,56 +15,56 @@ ...@@ -15,56 +15,56 @@
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
static struct otg_transceiver *xceiv; static struct usb_phy *phy;
/** /**
* otg_get_transceiver - find the (single) OTG transceiver * usb_get_transceiver - find the (single) USB transceiver
* *
* Returns the transceiver driver, after getting a refcount to it; or * Returns the transceiver driver, after getting a refcount to it; or
* null if there is no such transceiver. The caller is responsible for * null if there is no such transceiver. The caller is responsible for
* calling otg_put_transceiver() to release that count. * calling usb_put_transceiver() to release that count.
* *
* For use by USB host and peripheral drivers. * For use by USB host and peripheral drivers.
*/ */
struct otg_transceiver *otg_get_transceiver(void) struct usb_phy *usb_get_transceiver(void)
{ {
if (xceiv) if (phy)
get_device(xceiv->dev); get_device(phy->dev);
return xceiv; return phy;
} }
EXPORT_SYMBOL(otg_get_transceiver); EXPORT_SYMBOL(usb_get_transceiver);
/** /**
* otg_put_transceiver - release the (single) OTG transceiver * usb_put_transceiver - release the (single) USB transceiver
* @x: the transceiver returned by otg_get_transceiver() * @x: the transceiver returned by usb_get_transceiver()
* *
* Releases a refcount the caller received from otg_get_transceiver(). * Releases a refcount the caller received from usb_get_transceiver().
* *
* For use by USB host and peripheral drivers. * For use by USB host and peripheral drivers.
*/ */
void otg_put_transceiver(struct otg_transceiver *x) void usb_put_transceiver(struct usb_phy *x)
{ {
if (x) if (x)
put_device(x->dev); put_device(x->dev);
} }
EXPORT_SYMBOL(otg_put_transceiver); EXPORT_SYMBOL(usb_put_transceiver);
/** /**
* otg_set_transceiver - declare the (single) OTG transceiver * usb_set_transceiver - declare the (single) USB transceiver
* @x: the USB OTG transceiver to be used; or NULL * @x: the USB transceiver to be used; or NULL
* *
* This call is exclusively for use by transceiver drivers, which * This call is exclusively for use by transceiver drivers, which
* coordinate the activities of drivers for host and peripheral * coordinate the activities of drivers for host and peripheral
* controllers, and in some cases for VBUS current regulation. * controllers, and in some cases for VBUS current regulation.
*/ */
int otg_set_transceiver(struct otg_transceiver *x) int usb_set_transceiver(struct usb_phy *x)
{ {
if (xceiv && x) if (phy && x)
return -EBUSY; return -EBUSY;
xceiv = x; phy = x;
return 0; return 0;
} }
EXPORT_SYMBOL(otg_set_transceiver); EXPORT_SYMBOL(usb_set_transceiver);
const char *otg_state_string(enum usb_otg_state state) const char *otg_state_string(enum usb_otg_state state)
{ {
......
...@@ -117,10 +117,10 @@ void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) ...@@ -117,10 +117,10 @@ void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{ {
state_changed = 1; state_changed = 1;
if (fsm->transceiver->state == new_state) if (fsm->otg->phy->state == new_state)
return 0; return 0;
VDBG("Set state: %s\n", otg_state_string(new_state)); VDBG("Set state: %s\n", otg_state_string(new_state));
otg_leave_state(fsm, fsm->transceiver->state); otg_leave_state(fsm, fsm->otg->phy->state);
switch (new_state) { switch (new_state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0); otg_drv_vbus(fsm, 0);
...@@ -155,8 +155,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) ...@@ -155,8 +155,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
otg_loc_conn(fsm, 0); otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1); otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST); otg_set_protocol(fsm, PROTO_HOST);
usb_bus_start_enum(fsm->transceiver->host, usb_bus_start_enum(fsm->otg->host,
fsm->transceiver->host->otg_port); fsm->otg->host->otg_port);
break; break;
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
otg_drv_vbus(fsm, 0); otg_drv_vbus(fsm, 0);
...@@ -221,7 +221,7 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) ...@@ -221,7 +221,7 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break; break;
} }
fsm->transceiver->state = new_state; fsm->otg->phy->state = new_state;
return 0; return 0;
} }
...@@ -233,7 +233,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -233,7 +233,7 @@ int otg_statemachine(struct otg_fsm *fsm)
spin_lock_irqsave(&fsm->lock, flags); spin_lock_irqsave(&fsm->lock, flags);
state = fsm->transceiver->state; state = fsm->otg->phy->state;
state_changed = 0; state_changed = 0;
/* State machine state change judgement */ /* State machine state change judgement */
...@@ -248,7 +248,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -248,7 +248,7 @@ int otg_statemachine(struct otg_fsm *fsm)
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
if (!fsm->id) if (!fsm->id)
otg_set_state(fsm, OTG_STATE_A_IDLE); otg_set_state(fsm, OTG_STATE_A_IDLE);
else if (fsm->b_sess_vld && fsm->transceiver->gadget) else if (fsm->b_sess_vld && fsm->otg->gadget)
otg_set_state(fsm, OTG_STATE_B_PERIPHERAL); otg_set_state(fsm, OTG_STATE_B_PERIPHERAL);
else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp) else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp)
otg_set_state(fsm, OTG_STATE_B_SRP_INIT); otg_set_state(fsm, OTG_STATE_B_SRP_INIT);
...@@ -260,7 +260,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -260,7 +260,7 @@ int otg_statemachine(struct otg_fsm *fsm)
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
if (!fsm->id || !fsm->b_sess_vld) if (!fsm->id || !fsm->b_sess_vld)
otg_set_state(fsm, OTG_STATE_B_IDLE); otg_set_state(fsm, OTG_STATE_B_IDLE);
else if (fsm->b_bus_req && fsm->transceiver-> else if (fsm->b_bus_req && fsm->otg->
gadget->b_hnp_enable && fsm->a_bus_suspend) gadget->b_hnp_enable && fsm->a_bus_suspend)
otg_set_state(fsm, OTG_STATE_B_WAIT_ACON); otg_set_state(fsm, OTG_STATE_B_WAIT_ACON);
break; break;
...@@ -302,7 +302,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -302,7 +302,7 @@ int otg_statemachine(struct otg_fsm *fsm)
break; break;
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
if ((!fsm->a_bus_req || fsm->a_suspend_req) && if ((!fsm->a_bus_req || fsm->a_suspend_req) &&
fsm->transceiver->host->b_hnp_enable) fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_SUSPEND); otg_set_state(fsm, OTG_STATE_A_SUSPEND);
else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop) else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
...@@ -310,9 +310,9 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -310,9 +310,9 @@ int otg_statemachine(struct otg_fsm *fsm)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
break; break;
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
if (!fsm->b_conn && fsm->transceiver->host->b_hnp_enable) if (!fsm->b_conn && fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_PERIPHERAL); otg_set_state(fsm, OTG_STATE_A_PERIPHERAL);
else if (!fsm->b_conn && !fsm->transceiver->host->b_hnp_enable) else if (!fsm->b_conn && !fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
else if (fsm->a_bus_req || fsm->b_bus_resume) else if (fsm->a_bus_req || fsm->b_bus_resume)
otg_set_state(fsm, OTG_STATE_A_HOST); otg_set_state(fsm, OTG_STATE_A_HOST);
......
...@@ -82,7 +82,7 @@ struct otg_fsm { ...@@ -82,7 +82,7 @@ struct otg_fsm {
int loc_sof; int loc_sof;
struct otg_fsm_ops *ops; struct otg_fsm_ops *ops;
struct otg_transceiver *transceiver; struct usb_otg *otg;
/* Current usb protocol used: 0:undefine; 1:host; 2:client */ /* Current usb protocol used: 0:undefine; 1:host; 2:client */
int protocol; int protocol;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -40,7 +40,7 @@ static int ulpi_viewport_wait(void __iomem *view, u32 mask) ...@@ -40,7 +40,7 @@ static int ulpi_viewport_wait(void __iomem *view, u32 mask)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
static int ulpi_viewport_read(struct otg_transceiver *otg, u32 reg) static int ulpi_viewport_read(struct usb_phy *otg, u32 reg)
{ {
int ret; int ret;
void __iomem *view = otg->io_priv; void __iomem *view = otg->io_priv;
...@@ -58,7 +58,7 @@ static int ulpi_viewport_read(struct otg_transceiver *otg, u32 reg) ...@@ -58,7 +58,7 @@ static int ulpi_viewport_read(struct otg_transceiver *otg, u32 reg)
return ULPI_VIEW_DATA_READ(readl(view)); return ULPI_VIEW_DATA_READ(readl(view));
} }
static int ulpi_viewport_write(struct otg_transceiver *otg, u32 val, u32 reg) static int ulpi_viewport_write(struct usb_phy *otg, u32 val, u32 reg)
{ {
int ret; int ret;
void __iomem *view = otg->io_priv; void __iomem *view = otg->io_priv;
...@@ -74,7 +74,7 @@ static int ulpi_viewport_write(struct otg_transceiver *otg, u32 val, u32 reg) ...@@ -74,7 +74,7 @@ static int ulpi_viewport_write(struct otg_transceiver *otg, u32 val, u32 reg)
return ulpi_viewport_wait(view, ULPI_VIEW_RUN); return ulpi_viewport_wait(view, ULPI_VIEW_RUN);
} }
struct otg_io_access_ops ulpi_viewport_access_ops = { struct usb_phy_io_ops ulpi_viewport_access_ops = {
.read = ulpi_viewport_read, .read = ulpi_viewport_read,
.write = ulpi_viewport_write, .write = ulpi_viewport_write,
}; };
...@@ -104,11 +104,11 @@ struct iotg_ulpi_access_ops { ...@@ -104,11 +104,11 @@ struct iotg_ulpi_access_ops {
/* /*
* the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact
* with device and host drivers to implement the USB OTG related feature. More * with device and host drivers to implement the USB OTG related feature. More
* function members are added based on otg_transceiver data structure for this * function members are added based on usb_phy data structure for this
* purpose. * purpose.
*/ */
struct intel_mid_otg_xceiv { struct intel_mid_otg_xceiv {
struct otg_transceiver otg; struct usb_phy otg;
struct otg_hsm hsm; struct otg_hsm hsm;
/* base address */ /* base address */
...@@ -147,7 +147,7 @@ struct intel_mid_otg_xceiv { ...@@ -147,7 +147,7 @@ struct intel_mid_otg_xceiv {
}; };
static inline static inline
struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct otg_transceiver *otg) struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct usb_phy *otg)
{ {
return container_of(otg, struct intel_mid_otg_xceiv, otg); return container_of(otg, struct intel_mid_otg_xceiv, otg);
} }
......
...@@ -160,7 +160,7 @@ struct msm_otg_platform_data { ...@@ -160,7 +160,7 @@ struct msm_otg_platform_data {
* detection process. * detection process.
*/ */
struct msm_otg { struct msm_otg {
struct otg_transceiver otg; struct usb_phy phy;
struct msm_otg_platform_data *pdata; struct msm_otg_platform_data *pdata;
int irq; int irq;
struct clk *clk; struct clk *clk;
......
此差异已折叠。
...@@ -181,12 +181,12 @@ ...@@ -181,12 +181,12 @@
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops, struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops,
unsigned int flags); unsigned int flags);
#ifdef CONFIG_USB_ULPI_VIEWPORT #ifdef CONFIG_USB_ULPI_VIEWPORT
/* access ops for controllers with a viewport register */ /* access ops for controllers with a viewport register */
extern struct otg_io_access_ops ulpi_viewport_access_ops; extern struct usb_phy_io_ops ulpi_viewport_access_ops;
#endif #endif
#endif /* __LINUX_USB_ULPI_H */ #endif /* __LINUX_USB_ULPI_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册