From 8675381109b0eb1c948a423c2b35e3f4509cb25e Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 13 Feb 2012 13:24:02 +0200 Subject: usb: otg: Rename otg_transceiver to usb_phy This is the first step in separating USB transceivers from USB OTG utilities. Includes fixes to IMX code from Sascha Hauer. Signed-off-by: Heikki Krogerus Acked-by: Sascha Hauer Acked-by: Pavankumar Kondeti Acked-by: Li Yang Acked-by: Alan Stern Acked-by: Igor Grinberg Reviewed-by: Marek Vasut Signed-off-by: Felipe Balbi --- drivers/power/isp1704_charger.c | 2 +- drivers/power/pda_power.c | 2 +- drivers/power/twl4030_charger.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/power') diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c index b806667b59a..51cdea4fc03 100644 --- a/drivers/power/isp1704_charger.c +++ b/drivers/power/isp1704_charger.c @@ -56,7 +56,7 @@ static u16 isp170x_id[] = { struct isp1704_charger { struct device *dev; struct power_supply psy; - struct otg_transceiver *otg; + struct usb_phy *otg; struct notifier_block nb; struct work_struct work; diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index fd49689738a..dcf07f55eb0 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c @@ -40,7 +40,7 @@ static struct timer_list polling_timer; static int polling; #ifdef CONFIG_USB_OTG_UTILS -static struct otg_transceiver *transceiver; +static struct usb_phy *transceiver; static struct notifier_block otg_nb; #endif diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index 54b9198fa57..b3ead2305b4 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -69,7 +69,7 @@ struct twl4030_bci { struct device *dev; struct power_supply ac; struct power_supply usb; - struct otg_transceiver *transceiver; + struct usb_phy *transceiver; struct notifier_block otg_nb; struct work_struct work; int irq_chg; -- cgit v1.2.3-70-g09d2 From fcc8ebc99034bae4020a3cec030553d469e265db Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 13 Feb 2012 13:24:16 +0200 Subject: power_supply: Convert all users to new usb_phy Use the new usb_phy_* functions instead of the old otg_* ones. Signed-off-by: Heikki Krogerus Acked-by: Anton Vorontsov Reviewed-by: Marek Vasut Signed-off-by: Felipe Balbi --- drivers/power/isp1704_charger.c | 106 ++++++++++++++++++++++------------------ drivers/power/pda_power.c | 8 +-- drivers/power/twl4030_charger.c | 18 +++---- 3 files changed, 71 insertions(+), 61 deletions(-) (limited to 'drivers/power') diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c index 51cdea4fc03..58ad6e998ca 100644 --- a/drivers/power/isp1704_charger.c +++ b/drivers/power/isp1704_charger.c @@ -56,7 +56,7 @@ static u16 isp170x_id[] = { struct isp1704_charger { struct device *dev; struct power_supply psy; - struct usb_phy *otg; + struct usb_phy *phy; struct notifier_block nb; struct work_struct work; @@ -71,6 +71,16 @@ struct isp1704_charger { 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 * has been provided with platform data. @@ -97,31 +107,31 @@ static inline int isp1704_charger_type(struct isp1704_charger *isp) u8 otg_ctrl; int type = POWER_SUPPLY_TYPE_USB_DCP; - func_ctrl = otg_io_read(isp->otg, ULPI_FUNC_CTRL); - otg_ctrl = otg_io_read(isp->otg, ULPI_OTG_CTRL); + func_ctrl = isp1704_read(isp, ULPI_FUNC_CTRL); + otg_ctrl = isp1704_read(isp, ULPI_OTG_CTRL); /* disable pulldowns */ 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 */ - otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), + isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL), 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); /* Enable strong pull-up on DP (1.5K) and 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); - reg = otg_io_read(isp->otg, ULPI_DEBUG); + reg = isp1704_read(isp, ULPI_DEBUG); if ((reg & 3) != 3) type = POWER_SUPPLY_TYPE_USB_CDP; /* recover original state */ - otg_io_write(isp->otg, ULPI_FUNC_CTRL, func_ctrl); - otg_io_write(isp->otg, ULPI_OTG_CTRL, otg_ctrl); + isp1704_write(isp, ULPI_FUNC_CTRL, func_ctrl); + isp1704_write(isp, ULPI_OTG_CTRL, otg_ctrl); return type; } @@ -136,28 +146,28 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp) u8 r; /* Reset the transceiver */ - r = otg_io_read(isp->otg, ULPI_FUNC_CTRL); + r = isp1704_read(isp, ULPI_FUNC_CTRL); 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); /* Set normal mode */ 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 */ 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 */ 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); /* 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) */ - otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), + isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL), ULPI_FUNC_CTRL_TERMSELECT); return 1; } @@ -165,23 +175,23 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp) /* Is it a charger or PS/2 connection */ /* 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); /* 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); /* 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); /* 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; /* 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); return ret; @@ -193,14 +203,14 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) u8 pwr_ctrl; 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 */ - otg_io_write(isp->otg, ISP1704_PWR_CTRL, + isp1704_write(isp, ISP1704_PWR_CTRL, ISP1704_PWR_CTRL_SWCTRL); /* 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_DPVSRC_EN); usleep_range(1000, 2000); @@ -208,7 +218,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) timeout = jiffies + msecs_to_jiffies(300); do { /* 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) { ret = isp1704_charger_verify(isp); break; @@ -216,7 +226,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) } while (!time_after(jiffies, timeout) && isp->online); /* recover original state */ - otg_io_write(isp->otg, ISP1704_PWR_CTRL, pwr_ctrl); + isp1704_write(isp, ISP1704_PWR_CTRL, pwr_ctrl); return ret; } @@ -264,8 +274,8 @@ static void isp1704_charger_work(struct work_struct *data) case POWER_SUPPLY_TYPE_USB: default: /* enable data pullups */ - if (isp->otg->gadget) - usb_gadget_connect(isp->otg->gadget); + if (isp->phy->gadget) + usb_gadget_connect(isp->phy->gadget); } break; case USB_EVENT_NONE: @@ -283,8 +293,8 @@ static void isp1704_charger_work(struct work_struct *data) * chargers. The pullups may be enabled elsewhere, so this can * not be the final solution. */ - if (isp->otg->gadget) - usb_gadget_disconnect(isp->otg->gadget); + if (isp->phy->gadget) + usb_gadget_disconnect(isp->phy->gadget); isp1704_charger_set_power(isp, 0); break; @@ -364,11 +374,11 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) int ret = -ENODEV; /* Test ULPI interface */ - ret = otg_io_write(isp->otg, ULPI_SCRATCH, 0xaa); + ret = isp1704_write(isp, ULPI_SCRATCH, 0xaa); if (ret < 0) return ret; - ret = otg_io_read(isp->otg, ULPI_SCRATCH); + ret = isp1704_read(isp, ULPI_SCRATCH); if (ret < 0) return ret; @@ -376,13 +386,13 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) return -ENODEV; /* Verify the product and vendor id matches */ - vendor = otg_io_read(isp->otg, ULPI_VENDOR_ID_LOW); - vendor |= otg_io_read(isp->otg, ULPI_VENDOR_ID_HIGH) << 8; + vendor = isp1704_read(isp, ULPI_VENDOR_ID_LOW); + vendor |= isp1704_read(isp, ULPI_VENDOR_ID_HIGH) << 8; if (vendor != NXP_VENDOR_ID) return -ENODEV; - product = otg_io_read(isp->otg, ULPI_PRODUCT_ID_LOW); - product |= otg_io_read(isp->otg, ULPI_PRODUCT_ID_HIGH) << 8; + product = isp1704_read(isp, ULPI_PRODUCT_ID_LOW); + product |= isp1704_read(isp, ULPI_PRODUCT_ID_HIGH) << 8; for (i = 0; i < ARRAY_SIZE(isp170x_id); i++) { if (product == isp170x_id[i]) { @@ -405,8 +415,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) if (!isp) return -ENOMEM; - isp->otg = otg_get_transceiver(); - if (!isp->otg) + isp->phy = usb_get_transceiver(); + if (!isp->phy) goto fail0; isp->dev = &pdev->dev; @@ -429,14 +439,14 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) 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. */ INIT_WORK(&isp->work, isp1704_charger_work); 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) goto fail2; @@ -449,13 +459,13 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) * enumerated. The charger driver should be always loaded before any * gadget is loaded. */ - if (isp->otg->gadget) - usb_gadget_disconnect(isp->otg->gadget); + if (isp->phy->gadget) + usb_gadget_disconnect(isp->phy->gadget); /* 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); - 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; schedule_work(&isp->work); } @@ -464,7 +474,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) fail2: power_supply_unregister(&isp->psy); fail1: - otg_put_transceiver(isp->otg); + usb_put_transceiver(isp->phy); fail0: kfree(isp); @@ -477,9 +487,9 @@ static int __devexit isp1704_charger_remove(struct platform_device *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); - otg_put_transceiver(isp->otg); + usb_put_transceiver(isp->phy); isp1704_charger_set_power(isp, 0); kfree(isp); diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index dcf07f55eb0..214468f4444 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c @@ -321,7 +321,7 @@ static int pda_power_probe(struct platform_device *pdev) } #ifdef CONFIG_USB_OTG_UTILS - transceiver = otg_get_transceiver(); + transceiver = usb_get_transceiver(); if (transceiver && !pdata->is_usb_online) { pdata->is_usb_online = otg_is_usb_online; } @@ -375,7 +375,7 @@ static int pda_power_probe(struct platform_device *pdev) #ifdef CONFIG_USB_OTG_UTILS if (transceiver && pdata->use_otg_notifier) { otg_nb.notifier_call = otg_handle_notification; - ret = otg_register_notifier(transceiver, &otg_nb); + ret = usb_register_notifier(transceiver, &otg_nb); if (ret) { dev_err(dev, "failure to register otg notifier\n"); goto otg_reg_notifier_failed; @@ -409,7 +409,7 @@ usb_supply_failed: free_irq(ac_irq->start, &pda_psy_ac); #ifdef CONFIG_USB_OTG_UTILS if (transceiver) - otg_put_transceiver(transceiver); + usb_put_transceiver(transceiver); #endif ac_irq_failed: if (pdata->is_ac_online) @@ -444,7 +444,7 @@ static int pda_power_remove(struct platform_device *pdev) power_supply_unregister(&pda_psy_ac); #ifdef CONFIG_USB_OTG_UTILS if (transceiver) - otg_put_transceiver(transceiver); + usb_put_transceiver(transceiver); #endif if (ac_draw) { regulator_put(ac_draw); diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index b3ead2305b4..fdad850c77d 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -70,7 +70,7 @@ struct twl4030_bci { struct power_supply ac; struct power_supply usb; struct usb_phy *transceiver; - struct notifier_block otg_nb; + struct notifier_block usb_nb; struct work_struct work; int irq_chg; int irq_bci; @@ -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, 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); @@ -479,10 +479,10 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) INIT_WORK(&bci->work, twl4030_bci_usb_work); - bci->transceiver = otg_get_transceiver(); + bci->transceiver = usb_get_transceiver(); if (bci->transceiver != NULL) { - bci->otg_nb.notifier_call = twl4030_bci_usb_ncb; - otg_register_notifier(bci->transceiver, &bci->otg_nb); + bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; + usb_register_notifier(bci->transceiver, &bci->usb_nb); } /* Enable interrupts now. */ @@ -508,8 +508,8 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) fail_unmask_interrupts: if (bci->transceiver != NULL) { - otg_unregister_notifier(bci->transceiver, &bci->otg_nb); - otg_put_transceiver(bci->transceiver); + usb_unregister_notifier(bci->transceiver, &bci->usb_nb); + usb_put_transceiver(bci->transceiver); } free_irq(bci->irq_bci, bci); fail_bci_irq: @@ -539,8 +539,8 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev) TWL4030_INTERRUPTS_BCIIMR2A); if (bci->transceiver != NULL) { - otg_unregister_notifier(bci->transceiver, &bci->otg_nb); - otg_put_transceiver(bci->transceiver); + usb_unregister_notifier(bci->transceiver, &bci->usb_nb); + usb_put_transceiver(bci->transceiver); } free_irq(bci->irq_bci, bci); free_irq(bci->irq_chg, bci); -- cgit v1.2.3-70-g09d2 From b1c711d629358576e8896a18e74cd5f4d811d7f7 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 13 Feb 2012 13:24:17 +0200 Subject: usb: otg: mv_otg: Start using struct usb_otg Use struct usb_otg members with OTG specific functions instead of usb_phy members. [ balbi@ti.com : fixed a compile error on isp1704_charger.c ] Signed-off-by: Heikki Krogerus Reviewed-by: Marek Vasut Acked-by: Neil Zhang Signed-off-by: Felipe Balbi --- drivers/power/isp1704_charger.c | 12 ++--- drivers/usb/otg/mv_otg.c | 110 ++++++++++++++++++++++------------------ drivers/usb/otg/mv_otg.h | 2 +- 3 files changed, 69 insertions(+), 55 deletions(-) (limited to 'drivers/power') diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c index 58ad6e998ca..1289a5f790a 100644 --- a/drivers/power/isp1704_charger.c +++ b/drivers/power/isp1704_charger.c @@ -274,8 +274,8 @@ static void isp1704_charger_work(struct work_struct *data) case POWER_SUPPLY_TYPE_USB: default: /* enable data pullups */ - if (isp->phy->gadget) - usb_gadget_connect(isp->phy->gadget); + if (isp->phy->otg->gadget) + usb_gadget_connect(isp->phy->otg->gadget); } break; case USB_EVENT_NONE: @@ -293,8 +293,8 @@ static void isp1704_charger_work(struct work_struct *data) * chargers. The pullups may be enabled elsewhere, so this can * not be the final solution. */ - if (isp->phy->gadget) - usb_gadget_disconnect(isp->phy->gadget); + if (isp->phy->otg->gadget) + usb_gadget_disconnect(isp->phy->otg->gadget); isp1704_charger_set_power(isp, 0); break; @@ -459,8 +459,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) * enumerated. The charger driver should be always loaded before any * gadget is loaded. */ - if (isp->phy->gadget) - usb_gadget_disconnect(isp->phy->gadget); + if (isp->phy->otg->gadget) + usb_gadget_disconnect(isp->phy->otg->gadget); /* Detect charger if VBUS is valid (the cable was already plugged). */ ret = isp1704_read(isp, ULPI_USB_INT_STS); diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c index 6e05d58effe..6cc6c3ffbb8 100644 --- a/drivers/usb/otg/mv_otg.c +++ b/drivers/usb/otg/mv_otg.c @@ -55,16 +55,16 @@ static char *state_string[] = { "a_vbus_err" }; -static int mv_otg_set_vbus(struct usb_phy *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) return -ENODEV; return mvotg->pdata->set_vbus(on); } -static int mv_otg_set_host(struct usb_phy *otg, +static int mv_otg_set_host(struct usb_otg *otg, struct usb_bus *host) { otg->host = host; @@ -72,7 +72,7 @@ static int mv_otg_set_host(struct usb_phy *otg, return 0; } -static int mv_otg_set_peripheral(struct usb_phy *otg, +static int mv_otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { otg->gadget = gadget; @@ -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) { #ifdef CONFIG_USB - struct usb_phy *otg = &mvotg->otg; + struct usb_otg *otg = mvotg->phy.otg; struct usb_hcd *hcd; if (!otg->host) @@ -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) { - struct usb_phy *otg = &mvotg->otg; + struct usb_otg *otg = mvotg->phy.otg; if (!otg->gadget) return; - dev_info(otg->dev, "gadget %s\n", on ? "on" : "off"); + dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off"); if (on) usb_gadget_vbus_connect(otg->gadget); @@ -343,69 +343,69 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg) static void mv_otg_update_state(struct mv_otg *mvotg) { struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; - struct usb_phy *otg = &mvotg->otg; - int old_state = otg->state; + struct usb_phy *phy = &mvotg->phy; + int old_state = phy->state; switch (old_state) { case OTG_STATE_UNDEFINED: - otg->state = OTG_STATE_B_IDLE; + phy->state = OTG_STATE_B_IDLE; /* FALL THROUGH */ case OTG_STATE_B_IDLE: if (otg_ctrl->id == 0) - otg->state = OTG_STATE_A_IDLE; + phy->state = OTG_STATE_A_IDLE; else if (otg_ctrl->b_sess_vld) - otg->state = OTG_STATE_B_PERIPHERAL; + phy->state = OTG_STATE_B_PERIPHERAL; break; case OTG_STATE_B_PERIPHERAL: if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) - otg->state = OTG_STATE_B_IDLE; + phy->state = OTG_STATE_B_IDLE; break; case OTG_STATE_A_IDLE: if (otg_ctrl->id) - otg->state = OTG_STATE_B_IDLE; + phy->state = OTG_STATE_B_IDLE; else if (!(otg_ctrl->a_bus_drop) && (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; case OTG_STATE_A_WAIT_VRISE: if (otg_ctrl->a_vbus_vld) - otg->state = OTG_STATE_A_WAIT_BCON; + phy->state = OTG_STATE_A_WAIT_BCON; break; case OTG_STATE_A_WAIT_BCON: if (otg_ctrl->id || otg_ctrl->a_bus_drop || otg_ctrl->a_wait_bcon_timeout) { mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); 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; } else if (!otg_ctrl->a_vbus_vld) { mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); 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) { mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mvotg->otg_ctrl.a_wait_bcon_timeout = 0; - otg->state = OTG_STATE_A_HOST; + phy->state = OTG_STATE_A_HOST; } break; case OTG_STATE_A_HOST: if (otg_ctrl->id || !otg_ctrl->b_conn || 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) - otg->state = OTG_STATE_A_VBUS_ERR; + phy->state = OTG_STATE_A_VBUS_ERR; break; case OTG_STATE_A_WAIT_VFALL: if (otg_ctrl->id || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) || otg_ctrl->a_bus_req) - otg->state = OTG_STATE_A_IDLE; + phy->state = OTG_STATE_A_IDLE; break; case OTG_STATE_A_VBUS_ERR: if (otg_ctrl->id || otg_ctrl->a_clr_err || otg_ctrl->a_bus_drop) { otg_ctrl->a_clr_err = 0; - otg->state = OTG_STATE_A_WAIT_VFALL; + phy->state = OTG_STATE_A_WAIT_VFALL; } break; default: @@ -416,15 +416,17 @@ static void mv_otg_update_state(struct mv_otg *mvotg) static void mv_otg_work(struct work_struct *work) { struct mv_otg *mvotg; - struct usb_phy *otg; + struct usb_phy *phy; + struct usb_otg *otg; int old_state; mvotg = container_of((struct delayed_work *)work, struct mv_otg, work); run: /* work queue is single thread, or we need spin_lock to protect */ - otg = &mvotg->otg; - old_state = otg->state; + phy = &mvotg->phy; + otg = phy->otg; + old_state = phy->state; if (!mvotg->active) return; @@ -432,14 +434,14 @@ run: mv_otg_update_inputs(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", state_string[old_state], - state_string[otg->state]); + state_string[phy->state]); - switch (otg->state) { + switch (phy->state) { case OTG_STATE_B_IDLE: - mvotg->otg.default_a = 0; + otg->default_a = 0; if (old_state == OTG_STATE_B_PERIPHERAL) mv_otg_start_periphrals(mvotg, 0); mv_otg_reset(mvotg); @@ -450,14 +452,14 @@ run: mv_otg_start_periphrals(mvotg, 1); break; case OTG_STATE_A_IDLE: - mvotg->otg.default_a = 1; + otg->default_a = 1; mv_otg_enable(mvotg); if (old_state == OTG_STATE_A_WAIT_VFALL) mv_otg_start_host(mvotg, 0); mv_otg_reset(mvotg); break; case OTG_STATE_A_WAIT_VRISE: - mv_otg_set_vbus(&mvotg->otg, 1); + mv_otg_set_vbus(otg, 1); break; case OTG_STATE_A_WAIT_BCON: if (old_state != OTG_STATE_A_HOST) @@ -479,7 +481,7 @@ run: * here. In fact, it need host driver to notify us. */ mvotg->otg_ctrl.b_conn = 0; - mv_otg_set_vbus(&mvotg->otg, 0); + mv_otg_set_vbus(otg, 0); break; case OTG_STATE_A_VBUS_ERR: break; @@ -548,8 +550,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr, return -1; /* We will use this interface to change to A device */ - if (mvotg->otg.state != OTG_STATE_B_IDLE - && mvotg->otg.state != OTG_STATE_A_IDLE) + if (mvotg->phy.state != OTG_STATE_B_IDLE + && mvotg->phy.state != OTG_STATE_A_IDLE) return -1; /* 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, const char *buf, size_t count) { struct mv_otg *mvotg = dev_get_drvdata(dev); - if (!mvotg->otg.default_a) + if (!mvotg->phy.otg->default_a) return -1; if (count > 2) @@ -615,7 +617,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct mv_otg *mvotg = dev_get_drvdata(dev); - if (!mvotg->otg.default_a) + if (!mvotg->phy.otg->default_a) return -1; if (count > 2) @@ -688,9 +690,10 @@ int mv_otg_remove(struct platform_device *pdev) for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++) clk_put(mvotg->clk[clk_i]); - otg_set_transceiver(NULL); + usb_set_transceiver(NULL); platform_set_drvdata(pdev, NULL); + kfree(mvotg->phy.otg); kfree(mvotg); return 0; @@ -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_otg *mvotg; + struct usb_otg *otg; struct resource *r; int retval = 0, clk_i, i; size_t size; @@ -716,6 +720,12 @@ static int mv_otg_probe(struct platform_device *pdev) return -ENOMEM; } + otg = kzalloc(sizeof *otg, GFP_KERNEL); + if (!otg) { + kfree(mvotg); + return -ENOMEM; + } + platform_set_drvdata(pdev, mvotg); mvotg->pdev = pdev; @@ -741,12 +751,15 @@ static int mv_otg_probe(struct platform_device *pdev) /* OTG common part */ mvotg->pdev = pdev; - mvotg->otg.dev = &pdev->dev; - mvotg->otg.label = driver_name; - mvotg->otg.set_host = mv_otg_set_host; - mvotg->otg.set_peripheral = mv_otg_set_peripheral; - mvotg->otg.set_vbus = mv_otg_set_vbus; - mvotg->otg.state = OTG_STATE_UNDEFINED; + mvotg->phy.dev = &pdev->dev; + mvotg->phy.otg = otg; + mvotg->phy.label = driver_name; + mvotg->phy.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++) init_timer(&mvotg->otg_ctrl.timer[i]); @@ -840,7 +853,7 @@ static int mv_otg_probe(struct platform_device *pdev) goto err_disable_clk; } - retval = otg_set_transceiver(&mvotg->otg); + retval = usb_set_transceiver(&mvotg->phy); if (retval < 0) { dev_err(&pdev->dev, "can't register transceiver, %d\n", retval); @@ -867,7 +880,7 @@ static int mv_otg_probe(struct platform_device *pdev) return 0; err_set_transceiver: - otg_set_transceiver(NULL); + usb_set_transceiver(NULL); err_free_irq: free_irq(mvotg->irq, mvotg); err_disable_clk: @@ -888,6 +901,7 @@ err_put_clk: clk_put(mvotg->clk[clk_i]); platform_set_drvdata(pdev, NULL); + kfree(otg); kfree(mvotg); return retval; @@ -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); - if (mvotg->otg.state != OTG_STATE_B_IDLE) { + if (mvotg->phy.state != OTG_STATE_B_IDLE) { dev_info(&pdev->dev, "OTG state is not B_IDLE, it is %d!\n", - mvotg->otg.state); + mvotg->phy.state); return -EAGAIN; } diff --git a/drivers/usb/otg/mv_otg.h b/drivers/usb/otg/mv_otg.h index a74ee07a272..8a9e351b36b 100644 --- a/drivers/usb/otg/mv_otg.h +++ b/drivers/usb/otg/mv_otg.h @@ -136,7 +136,7 @@ struct mv_otg_regs { }; struct mv_otg { - struct usb_phy otg; + struct usb_phy phy; struct mv_otg_ctrl otg_ctrl; /* base address */ -- cgit v1.2.3-70-g09d2