usb: musb: fix USB enumeration issue in OMAP3 platform
Subsystems (6)
cover usb: musb: fix USB enumeration issue in OMAP3 platform
In the case of non-dt boot, the platform specific initialization file (board file) will do usb_bind_phy that binds the usb controller with the PHY using device names. After the device names are created using PLATFORM_DEVID_AUTO, our original method of binding by device names doesn't work reliably (since the device name changes). Hence the usb controller is made to use labels for getting the PHY.
Here the PHY name is added in the plat data of USB controller device which should be used by the controller driver to get the PHY.
Two new APIs usb_get_phy_by_name and devm_usb_get_phy_by_name are added to be used by the controller to get the PHY by name.
Changes from RFC
*) Changed the signature of usb_get_phy_by_name() not to use struct device *
Kishon Vijay Abraham I (4):
arm: omap: Add phy binding info for musb in plat data
usb: phy: add a new API to get PHY ref by label
usb: musb: omap: use the new API to get PHY reference by label
arm: omap: remove using usb_bind_phy for binding musb and phy
arch/arm/mach-omap2/board-2430sdp.c | 1 - arch/arm/mach-omap2/board-3430sdp.c | 1 - arch/arm/mach-omap2/board-4430sdp.c | 1 - arch/arm/mach-omap2/board-cm-t35.c | 1 - arch/arm/mach-omap2/board-devkit8000.c | 1 - arch/arm/mach-omap2/board-igep0020.c | 1 - arch/arm/mach-omap2/board-ldp.c | 1 - arch/arm/mach-omap2/board-omap3beagle.c | 1 - arch/arm/mach-omap2/board-omap3evm.c | 1 - arch/arm/mach-omap2/board-omap3logic.c | 1 - arch/arm/mach-omap2/board-omap3pandora.c | 1 - arch/arm/mach-omap2/board-omap3stalker.c | 1 - arch/arm/mach-omap2/board-omap3touchbook.c | 1 - arch/arm/mach-omap2/board-omap4panda.c | 1 - arch/arm/mach-omap2/board-overo.c | 1 - arch/arm/mach-omap2/board-rm680.c | 1 - arch/arm/mach-omap2/board-rx51.c | 1 - arch/arm/mach-omap2/board-zoom-peripherals.c | 1 - arch/arm/mach-omap2/usb-musb.c | 6 +- drivers/usb/musb/musb_core.c | 1 + drivers/usb/musb/musb_core.h | 1 + drivers/usb/musb/omap2430.c | 2 +- drivers/usb/phy/phy.c | 77 ++++++++++++++++++++++++++ include/linux/usb/musb.h | 3 + include/linux/usb/phy.h | 14 +++++ 25 files changed, 102 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/4 arm: omap: Add phy binding info for musb in plat data
In order for controllers to get PHY in case of non dt boot, the phy binding information (phy label) should be added in the platform data of the controller.
--- arch/arm/mach-omap2/usb-musb.c | 6 +++++- include/linux/usb/musb.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/usb-musb.c +5 -1
@@ -85,8 +85,12 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; -if (cpu_is_omap44xx ()) +if (cpu_is_omap44xx ()) { musb_plat.has_mailbox = true; + musb_plat.phy_name ="omap-usb2" ; + }else if (cpu_is_omap34xx ()) { + musb_plat.phy_name ="twl4030" ; + }if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ;
include/linux/usb/musb.h +3 -0
@@ -104,6 +104,9 @@ struct musb_hdrc_platform_data {/* for clk_get() */ const char *clock; +/* phy device label */ +const char *phy_name; +/* (HOST or OTG) switch VBUS on/off */ int (*set_vbus)(struct device *dev,int is_on);
Signature · 1 line
1.7.10.4
PATCH 2/4 usb: phy: add a new API to get PHY ref by label
In reply to Kishon Vijay Abraham IAfter the devices are created using PLATFORM_DEVID_AUTO, devm_usb_get_phy_dev and usb_get_phy_dev can't be used reliably as it relies on the device_names passed in usb_bind_phy. So added a new API to get the PHY reference by PHY label (PHY label should be filled which creating the PHY).
--- drivers/usb/phy/phy.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 14 +++++++++ 2 files changed, 91 insertions(+)
drivers/usb/phy/phy.c +77 -0
@@ -55,6 +55,21 @@ static struct usb_phy *__usb_find_phy_dev(struct device *dev,return ERR_PTR (-ENODEV ); } +static struct usb_phy *__usb_find_phy_by_name (struct list_head *list, +const char *name) +{ +struct usb_phy *phy =NULL ; + +list_for_each_entry (phy, list, head) { +if (strcmp (name, phy->label)) +continue ; + +return phy; + } + +return ERR_PTR (-ENODEV ); +} +static struct usb_phy *__of_usb_find_phy (struct device_node *node) {struct usb_phy *phy;
@@ -272,6 +287,68 @@ struct usb_phy *devm_usb_get_phy_dev(struct device *dev, u8 index)EXPORT_SYMBOL_GPL (devm_usb_get_phy_dev);/** +* usb_get_phy_by_name - find the USB PHY using device ptr and phy label +* @name - the name of the phy +* +* Returns the phy driver, after getting a refcount to it; or +* -ENODEV if there is no such phy. The caller is responsible for +* calling usb_put_phy() to release that count. +* +* For use by USB host and peripheral drivers. +*/ +struct usb_phy *usb_get_phy_by_name (const char *name) +{ +struct usb_phy *phy =NULL ; +unsigned long flags; + +spin_lock_irqsave (&phy_lock, flags); + + phy =__usb_find_phy_by_name (&phy_list, name); +if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { +pr_err ("unable to find transceiver\n" ); + goto err0; + } + +get_device (phy->dev); + +err0: +spin_unlock_irqrestore (&phy_lock, flags); + +return phy; +} +EXPORT_SYMBOL_GPL (usb_get_phy_by_name); + +/** +* devm_usb_get_phy_by_name - find the USB PHY using device ptr and phy label +* @dev - device that requests this phy +* @name - the label of the phy +* +* Gets the phy using usb_get_phy_by_name(), and associates a device with it +* using devres. On driver detach, release function is invoked on the devres +* data, then, devres data is freed. +* +* For use by USB host and peripheral drivers. +*/ +struct usb_phy *devm_usb_get_phy_by_name (struct device *dev,const char *name) +{ +struct usb_phy **ptr, *phy; + + ptr =devres_alloc (devm_usb_phy_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return NULL ; + + phy =usb_get_phy_by_name (name); +if (!IS_ERR (phy)) { + *ptr = phy; +devres_add (dev, ptr); + }else +devres_free (ptr); + +return phy; +} +EXPORT_SYMBOL_GPL (devm_usb_get_phy_by_name); + +/** * devm_usb_put_phy - release the USB PHY * @dev - device that wants to release this phy * @phy - the phy returned by devm_usb_get_phy()
include/linux/usb/phy.h +14 -0
@@ -188,6 +188,9 @@ extern struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type);extern struct usb_phy *usb_get_phy_dev (struct device *dev,u8 index);extern struct usb_phy *devm_usb_get_phy_dev (struct device *dev,u8 index); +extern struct usb_phy *usb_get_phy_by_name (const char *name); +extern struct usb_phy *devm_usb_get_phy_by_name (struct device *dev, +const char *name);extern struct usb_phy *devm_usb_get_phy_by_phandle (struct device *dev,const char *phandle,u8 index);extern void usb_put_phy (struct usb_phy *);
@@ -216,6 +219,17 @@ static inline struct usb_phy *devm_usb_get_phy_dev(struct device *dev, u8 index)return ERR_PTR (-ENXIO ); } +static inline struct usb_phy *usb_get_phy_by_name (const char *name) +{ +return ERR_PTR (-ENXIO ); +} + +static inline struct usb_phy *devm_usb_get_phy_by_name (struct device *dev, +const char *name) +{ +return ERR_PTR (-ENXIO ); +} +static inline struct usb_phy *devm_usb_get_phy_by_phandle (struct device *dev,const char *phandle,u8 index) {
Signature · 1 line
1.7.10.4
PATCH 3/4 usb: musb: omap: use the new API to get PHY reference by label
In reply to Kishon Vijay Abraham IAfter the devices are created using PLATFORM_DEVID_AUTO, devm_usb_get_phy_dev and usb_get_phy_dev can't be used reliably as it relies on the device_names passed in usb_bind_phy. So used the new API devm_usb_get_phy_by_name to get the PHY reference.
--- drivers/usb/musb/musb_core.c | 1 + drivers/usb/musb/musb_core.h | 1 + drivers/usb/musb/omap2430.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/usb/musb/musb_core.c +1 -0
@@ -1864,6 +1864,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) musb->board_set_power = plat->set_power; musb->min_power = plat->min_power; musb->ops = plat->platform_ops; + musb->phy_name = plat->phy_name;/* The musb_platform_init() call: * - adjusts musb->mregs
drivers/usb/musb/musb_core.h +1 -0
@@ -434,6 +434,7 @@ struct musb { unsigned double_buffer_not_ok:1;struct musb_hdrc_config *config; +const char *phy_name;#ifdef MUSB_CONFIG_PROC_FS struct proc_dir_entry *proc_entry;
drivers/usb/musb/omap2430.c +1 -1
@@ -352,7 +352,7 @@ static int omap2430_musb_init(struct musb *musb) musb->xceiv =devm_usb_get_phy_by_phandle (dev->parent,"usb-phy" ,0 ); else - musb->xceiv = devm_usb_get_phy_dev(dev, 0); + musb->xceiv = devm_usb_get_phy_by_name(dev, musb->phy_name);if (IS_ERR (musb->xceiv)) { status =PTR_ERR (musb->xceiv);
Signature · 1 line
1.7.10.4
PATCH 4/4 arm: omap: remove using usb_bind_phy for binding musb and phy
In reply to Kishon Vijay Abraham INow that MUSB for OMAP started using devm_usb_get_phy_by_name which does not require PHY library to already have the binding information, removed usb_bind_phy calls that binds the MUSB controller with the PHY from the board files.
--- arch/arm/mach-omap2/board-2430sdp.c | 1 - arch/arm/mach-omap2/board-3430sdp.c | 1 - arch/arm/mach-omap2/board-4430sdp.c | 1 - arch/arm/mach-omap2/board-cm-t35.c | 1 - arch/arm/mach-omap2/board-devkit8000.c | 1 - arch/arm/mach-omap2/board-igep0020.c | 1 - arch/arm/mach-omap2/board-ldp.c | 1 - arch/arm/mach-omap2/board-omap3beagle.c | 1 - arch/arm/mach-omap2/board-omap3evm.c | 1 - arch/arm/mach-omap2/board-omap3logic.c | 1 - arch/arm/mach-omap2/board-omap3pandora.c | 1 - arch/arm/mach-omap2/board-omap3stalker.c | 1 - arch/arm/mach-omap2/board-omap3touchbook.c | 1 - arch/arm/mach-omap2/board-omap4panda.c | 1 - arch/arm/mach-omap2/board-overo.c | 1 - arch/arm/mach-omap2/board-rm680.c | 1 - arch/arm/mach-omap2/board-rx51.c | 1 - arch/arm/mach-omap2/board-zoom-peripherals.c | 1 - 18 files changed, 18 deletions(-)
arch/arm/mach-omap2/board-2430sdp.c +0 -1
@@ -233,7 +233,6 @@ static void __init omap_2430sdp_init(void)omap_hsmmc_init (mmc);omap_mux_init_signal ("usb0hs_stp" ,OMAP_PULL_ENA |OMAP_PULL_UP ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );board_smc91x_init ();
arch/arm/mach-omap2/board-3430sdp.c +0 -1
@@ -590,7 +590,6 @@ static void __init omap_3430sdp_init(void)omap_ads7846_init (1 , gpio_pendown,310 ,NULL );omap_serial_init ();omap_sdrc_init (hyb18m512160af6_sdrc_params,NULL ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );board_smc91x_init ();board_flash_init (sdp_flash_partitions, chip_sel_3430,0 );
arch/arm/mach-omap2/board-4430sdp.c +0 -1
@@ -730,7 +730,6 @@ static void __init omap_4430sdp_init(void)omap4_sdp4430_wifi_init ();omap4_twl6030_hsmmc_init (mmc); -usb_bind_phy ("musb-hdrc.2.auto" ,0 ,"omap-usb2.3.auto" );usb_musb_init (&musb_board_data); status =omap_ethernet_init ();
arch/arm/mach-omap2/board-cm-t35.c +0 -1
@@ -690,7 +690,6 @@ static void __init cm_t3x_common_init(void)cm_t35_init_display ();omap_twl4030_audio_init ("cm-t3x" ,NULL ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );cm_t35_init_usbh ();cm_t35_init_camera ();
arch/arm/mach-omap2/board-devkit8000.c +0 -1
@@ -593,7 +593,6 @@ static void __init devkit8000_init(void)omap_ads7846_init (2 ,OMAP3_DEVKIT_TS_GPIO ,0 ,NULL ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );usbhs_init (&usbhs_bdata); board_nand_init(devkit8000_nand_partitions,
arch/arm/mach-omap2/board-igep0020.c +0 -1
@@ -628,7 +628,6 @@ static void __init igep_init(void)omap_serial_init ();omap_sdrc_init (m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );igep_flash_init ();
arch/arm/mach-omap2/board-ldp.c +0 -1
@@ -376,7 +376,6 @@ static void __init omap_ldp_init(void)omap_ads7846_init (1 ,54 ,310 ,NULL );omap_serial_init ();omap_sdrc_init (NULL ,NULL ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );board_nand_init (ldp_nand_partitions,ARRAY_SIZE (ldp_nand_partitions),ZOOM_NAND_CS ,0 , nand_default_timings);
arch/arm/mach-omap2/board-omap3beagle.c +0 -1
@@ -551,7 +551,6 @@ static void __init omap3_beagle_init(void)omap_sdrc_init (mt46h32m32lf6_sdrc_params, mt46h32m32lf6_sdrc_params); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );usbhs_init (&usbhs_bdata);
arch/arm/mach-omap2/board-omap3evm.c +0 -1
@@ -704,7 +704,6 @@ static void __init omap3_evm_init(void)omap_mux_init_gpio (135 ,OMAP_PIN_OUTPUT ); phy_data[0 ].reset_gpio =135 ; } -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (&musb_board_data);usbhs_init_phys (phy_data,ARRAY_SIZE (phy_data));
arch/arm/mach-omap2/board-omap3logic.c +0 -1
@@ -216,7 +216,6 @@ static void __init omap3logic_init(void)board_mmc_init ();board_smsc911x_init (); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );/* Ensure SDRC pins are mux'd for self-refresh */
arch/arm/mach-omap2/board-omap3pandora.c +0 -1
@@ -610,7 +610,6 @@ static void __init omap3pandora_init(void)usbhs_init_phys (phy_data,ARRAY_SIZE (phy_data));usbhs_init (&usbhs_bdata); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );gpmc_nand_init (&pandora_nand_data,NULL );
arch/arm/mach-omap2/board-omap3stalker.c +0 -1
@@ -394,7 +394,6 @@ static void __init omap3_stalker_init(void)omap_serial_init ();omap_sdrc_init (mt46h32m32lf6_sdrc_params,NULL ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );usbhs_init_phys (phy_data,ARRAY_SIZE (phy_data));
arch/arm/mach-omap2/board-omap3touchbook.c +0 -1
@@ -367,7 +367,6 @@ static void __init omap3_touchbook_init(void)/* Touchscreen and accelerometer */ omap_ads7846_init (4 ,OMAP3_TS_GPIO ,310 , &ads7846_pdata); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );usbhs_init_phys (phy_data,ARRAY_SIZE (phy_data));
arch/arm/mach-omap2/board-omap4panda.c +0 -1
@@ -435,7 +435,6 @@ static void __init omap4_panda_init(void)omap_sdrc_init (NULL ,NULL );omap4_twl6030_hsmmc_init (mmc);omap4_ehci_init (); -usb_bind_phy ("musb-hdrc.2.auto" ,0 ,"omap-usb2.3.auto" );usb_musb_init (&musb_board_data);omap4_panda_display_init (); }
arch/arm/mach-omap2/board-overo.c +0 -1
@@ -472,7 +472,6 @@ static void __init overo_init(void) mt46h32m32lf6_sdrc_params);board_nand_init (overo_nand_partitions,ARRAY_SIZE (overo_nand_partitions),NAND_CS ,0 ,NULL ); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );usbhs_init_phys (phy_data,ARRAY_SIZE (phy_data));
arch/arm/mach-omap2/board-rm680.c +0 -1
@@ -135,7 +135,6 @@ static void __init rm680_init(void) sdrc_params =nokia_get_sdram_timings ();omap_sdrc_init (sdrc_params, sdrc_params); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );rm680_peripherals_init (); }
arch/arm/mach-omap2/board-rx51.c +0 -1
@@ -99,7 +99,6 @@ static void __init rx51_init(void) sdrc_params =nokia_get_sdram_timings ();omap_sdrc_init (sdrc_params, sdrc_params); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (&musb_board_data);rx51_peripherals_init ();
arch/arm/mach-omap2/board-zoom-peripherals.c +0 -1
@@ -353,7 +353,6 @@ void __init zoom_peripherals_init(void)omap_i2c_init ();pwm_add_table (zoom_pwm_lookup,ARRAY_SIZE (zoom_pwm_lookup));platform_add_devices (zoom_devices,ARRAY_SIZE (zoom_devices)); -usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" );usb_musb_init (NULL );enable_board_wakeup_source ();omap_serial_init ();
Signature · 1 line
1.7.10.4
Tony Lindgren
maintainerRe: [PATCH 1/4] arm: omap: Add phy binding info for musb in plat data
In reply to Kishon Vijay Abraham IQuoted 20 lines · Kishon Vijay Abraham I
In order for controllers to get PHY in case of non dt boot, the phy binding information (phy label) should be added in the platform data of the controller.
Signed-off-by Kishon Vijay Abraham I <[email protected]>Acked-by Felipe Balbi <[email protected]>Tested-by Tomi Valkeinen <[email protected]>--- arch/arm/mach-omap2/usb-musb.c | 6 +++++- include/linux/usb/musb.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +0
-0@@ -85,8 +85,12 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus;
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 96
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +5
-1-if (cpu_is_omap44xx ()) +if (cpu_is_omap44xx ()) { musb_plat.has_mailbox = true; + musb_plat.phy_name ="omap-usb2" ; + }else if (cpu_is_omap34xx ()) { + musb_plat.phy_name ="twl4030" ; + }if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ;
Care to refresh this patch against the current mainline tree? Now omap4 is DT only, so this part won't apply. Mostly I'm wondering what the phy_name should be for am35xx that's not covered by this patch.
Also let me know if the last patch is safe to queue alone as a fix or if it depends on the driver related changes in this series.
Regards,
Tony
Re: [PATCH 1/4] arm: omap: Add phy binding info for musb in plat data
Hi,
Quoted 29 lines · Tony Lindgren
Quoted 28 lines · Kishon Vijay Abraham I
In order for controllers to get PHY in case of non dt boot, the phy binding information (phy label) should be added in the platform data of the controller.
Signed-off-by Kishon Vijay Abraham I <[email protected]>Acked-by Felipe Balbi <[email protected]>Tested-by Tomi Valkeinen <[email protected]>--- arch/arm/mach-omap2/usb-musb.c | 6 +++++- include/linux/usb/musb.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +5
-1@@ -85,8 +85,12 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; -if (cpu_is_omap44xx ()) +if (cpu_is_omap44xx ()) { musb_plat.has_mailbox = true; + musb_plat.phy_name ="omap-usb2" ; + }else if (cpu_is_omap34xx ()) { + musb_plat.phy_name ="twl4030" ; + }
Quoted 4 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 96
Quoted 2 lines
arch/arm/mach-omap2/usb-musb.c +0
-0if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ;Care to refresh this patch against the current mainline tree?
I'll do that on monday as I'm not in office and I dont have any boards to test at my disposal now.
Quoted 3 lines
Now omap4 is DT only, so this part won't apply. Mostly I'm wondering what the
phy_nameshould be for am35xx that's not covered by this patch.
am35xx doesn't have a separate PHY driver yet (I guess the programming is done in the controller code now). So this binding is not needed for am35xx.
Quoted 3 lines
Also let me know if the last patch is safe to queue alone as a fix or if it depends on the driver related changes in this series.
No. The last patch is kind-of cleanup needed after applying the first 3 patches. It's better it's applied along with the other patches.
Thanks
Kishon