USB: Add multiple PHYs of same type
Subsystems (14)
cover USB: Add multiple PHYs of same type
New platforms are being added which has multiple PHY's (of same type) and which has multiple USB controllers. The binding information has to be present in the PHY library (otg.c) in order for it to return the appropriate PHY whenever the USB controller request for the PHY. So added a new API to pass the binding information. This API should be called by platform specific initialization code.
So the binding should be done something like usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto"); specifying the USB controller device name, index, and the PHY device name.
I have done this binding for OMAP platforms, but it should be done for all the platforms.
After this design, the phy can be got by passing the USB controller device pointer and the index.
Developed this patch series ongit://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv after applying "usb: musb: add driver for control module" patch series.
Did basic enumeration testing in omap4 panda, omap4 sdp and omap3 beagle.
Kishon Vijay Abraham I (6):
usb: otg: Add an API to bind the USB controller and PHY
ARM: OMAP: USB: Add phy binding information
usb: otg: utils: change the phy lib to support multiple PHYs of same
type
ARM: dts: OMAP: Add phandle to bind PHY with USB controller
usb: otg: add device tree support to otg library
USB: MUSB: OMAP: get PHY by phandle for dt boot
Documentation/devicetree/bindings/usb/omap-usb.txt | 2 + arch/arm/boot/dts/omap3.dtsi | 1 + arch/arm/boot/dts/omap4.dtsi | 3 +- arch/arm/boot/dts/twl4030.dtsi | 2 +- arch/arm/mach-omap2/usb-musb.c | 7 +- arch/arm/mach-shmobile/board-marzen.c | 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/isp1704_charger.c | 2 +- drivers/power/pda_power.c | 2 +- drivers/power/twl4030_charger.c | 2 +- drivers/usb/chipidea/udc.c | 2 +- drivers/usb/dwc3/core.c | 4 +- drivers/usb/gadget/fsl_udc_core.c | 2 +- drivers/usb/gadget/mv_udc_core.c | 2 +- drivers/usb/gadget/omap_udc.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 2 +- drivers/usb/gadget/pxa27x_udc.c | 2 +- drivers/usb/gadget/s3c-hsudc.c | 2 +- drivers/usb/host/ehci-fsl.c | 2 +- drivers/usb/host/ehci-msm.c | 2 +- drivers/usb/host/ehci-mv.c | 2 +- drivers/usb/host/ehci-tegra.c | 2 +- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/musb/am35x.c | 2 +- drivers/usb/musb/blackfin.c | 2 +- drivers/usb/musb/da8xx.c | 2 +- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_dsps.c | 2 +- drivers/usb/musb/omap2430.c | 7 +- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/musb/ux500.c | 2 +- drivers/usb/otg/ab8500-usb.c | 3 +- drivers/usb/otg/fsl_otg.c | 5 +- drivers/usb/otg/gpio_vbus.c | 3 +- drivers/usb/otg/isp1301_omap.c | 3 +- drivers/usb/otg/msm_otg.c | 3 +- drivers/usb/otg/mv_otg.c | 3 +- drivers/usb/otg/nop-usb-xceiv.c | 3 +- drivers/usb/otg/otg.c | 175 ++++++++++++++++---- drivers/usb/otg/twl4030-usb.c | 3 +- drivers/usb/phy/mv_u3d_phy.c | 3 +- drivers/usb/phy/omap-usb2.c | 11 +- drivers/usb/phy/rcar-phy.c | 3 +- include/linux/usb/phy.h | 42 ++++- 44 files changed, 245 insertions(+), 89 deletions(-)
Signature · 1 line
1.7.9.5
RFC PATCH 1/6 usb: otg: Add an API to bind the USB controller and PHY
New platforms are added which has multiple PHY's (of same type) and which has multiple USB controllers. The binding information has to be present in the PHY library (otg.c) in order for it to return the appropriate PHY whenever the USB controller request for the PHY. So added a new API to pass the binding information. This API should be called by platform specific initialization code.
--- drivers/usb/otg/otg.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 22 ++++++++++++++++++++++ 2 files changed, 59 insertions(+)
drivers/usb/otg/otg.c +37 -0
@@ -18,6 +18,7 @@#include <linux/usb/otg.h> static LIST_HEAD (phy_list); +static LIST_HEAD (phy_bind_list);static DEFINE_SPINLOCK (phy_lock); static struct usb_phy *__usb_find_phy(struct list_head *list,
@@ -201,6 +202,42 @@ void usb_remove_phy(struct usb_phy *x) }EXPORT_SYMBOL (usb_remove_phy); +/** +* usb_bind_phy - bind the phy and the controller that uses the phy +* @dev_name: the device name of the device that will bind to the phy +* @index: index to specify the port number +* @phy_dev_name: the device name of the phy +* +* Fills the phy_bind structure with the dev_name and phy_dev_name. This will +* be used when the phy driver registers the phy and when the controller +* requests this phy. +* +* To be used by platform specific initialization code. +*/ +struct usb_phy_bind __init *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +struct usb_phy_bind *phy_bind; +unsigned long flags; + + phy_bind =kzalloc (sizeof (*phy_bind),GFP_KERNEL ); +if (!phy_bind) { +pr_err ("phy_bind(): No memory for phy_bind" ); +return ERR_PTR (-ENOMEM ); + } + + phy_bind->dev_name = dev_name; + phy_bind->phy_dev_name = phy_dev_name; + phy_bind->index = index; + +spin_lock_irqsave (&phy_lock, flags); +list_add_tail (&phy_bind->list, &phy_bind_list); +spin_unlock_irqrestore (&phy_lock, flags); + +return phy_bind; +} +EXPORT_SYMBOL_GPL (usb_bind_phy); +const char *otg_state_string (enum usb_otg_state state) {switch (state) {
include/linux/usb/phy.h +22 -0
@@ -106,6 +106,21 @@ struct usb_phy { enum usb_device_speed speed); }; +/** +* struct usb_phy_bind - represent the binding for the phy +* @dev_name: the device name of the device that will bind to the phy +* @phy_dev_name: the device name of the phy +* @index: used if a single controller uses multiple phys +* @phy: reference to the phy +* @list: to maintain a linked list of the binding information +*/ +struct usb_phy_bind { +const char *dev_name; +const char *phy_dev_name; +u8 index; +struct usb_phy *phy; +struct list_head list; +};/* for board-specific init logic */ extern int usb_add_phy (struct usb_phy *,enum usb_phy_type type);
@@ -151,6 +166,8 @@ extern struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type);extern void usb_put_phy (struct usb_phy *);extern void devm_usb_put_phy (struct device *dev,struct usb_phy *x); +extern struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name);#else static inline struct usb_phy *usb_get_phy (enum usb_phy_type type) {
@@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) { } +static inline struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +return NULL ; +}#endif static inline int
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 1/6] usb: otg: Add an API to bind the USB controller and PHY
Quoted 40 lines · Kishon Vijay Abraham I
New platforms are added which has multiple PHY's (of same type) and which has multiple USB controllers. The binding information has to be present in the PHY library (
otg.c) in order for it to return the appropriate PHY whenever the USB controller request for the PHY. So added a new API to pass the binding information. This API should be called by platform specific initialization code.Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/otg/otg.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 22 ++++++++++++++++++++++ 2 files changed, 59 insertions(+)drivers/usb/otg/otg.c +12
-0@@ -18,6 +18,7 @@#include <linux/usb/otg.h> static LIST_HEAD (phy_list); +static LIST_HEAD (phy_bind_list);static DEFINE_SPINLOCK (phy_lock); static struct usb_phy *__usb_find_phy(struct list_head *list,@@ -201,6 +202,42 @@ void usb_remove_phy(struct usb_phy *x) }EXPORT_SYMBOL (usb_remove_phy); +/** +* usb_bind_phy - bind the phy and the controller that uses the phy +* @dev_name: the device name of the device that will bind to the phy +* @index: index to specify the port number +* @phy_dev_name: the device name of the phy +* +* Fills the phy_bind structure with the dev_name and phy_dev_name. This will +* be used when the phy driver registers the phy and when the controller +* requests this phy. +* +* To be used by platform specific initialization code.
drivers/usb/otg/otg.c void usb_remove_phy(struct usb_phy *x) · line 225
Quoted 10 lines
drivers/usb/otg/otg.c +10
-0+*/ +struct usb_phy_bind __init *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +struct usb_phy_bind *phy_bind; +unsigned long flags; + + phy_bind =kzalloc (sizeof (*phy_bind),GFP_KERNEL ); +if (!phy_bind) { +pr_err ("phy_bind(): No memory for phy_bind" );
Function name in comment doesn't match the actual. Instead, you could use
pr_err("%s ...", __func__);Quoted 56 lines
drivers/usb/otg/otg.c +15
-0+return ERR_PTR (-ENOMEM ); + } + + phy_bind->dev_name = dev_name; + phy_bind->phy_dev_name = phy_dev_name; + phy_bind->index = index; + +spin_lock_irqsave (&phy_lock, flags); +list_add_tail (&phy_bind->list, &phy_bind_list); +spin_unlock_irqrestore (&phy_lock, flags); + +return phy_bind; +} +EXPORT_SYMBOL_GPL (usb_bind_phy); +const char *otg_state_string (enum usb_otg_state state) {switch (state) {include/linux/usb/phy.h +17
-0@@ -106,6 +106,21 @@ struct usb_phy { enum usb_device_speed speed); }; +/** +* struct usb_phy_bind - represent the binding for the phy +* @dev_name: the device name of the device that will bind to the phy +* @phy_dev_name: the device name of the phy +* @index: used if a single controller uses multiple phys +* @phy: reference to the phy +* @list: to maintain a linked list of the binding information +*/ +struct usb_phy_bind { +const char *dev_name; +const char *phy_dev_name; +u8 index; +struct usb_phy *phy; +struct list_head list; +};/* for board-specific init logic */ extern int usb_add_phy (struct usb_phy *,enum usb_phy_type type);@@ -151,6 +166,8 @@ extern struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type);extern void usb_put_phy (struct usb_phy *);extern void devm_usb_put_phy (struct device *dev,struct usb_phy *x); +extern struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name);#else static inline struct usb_phy *usb_get_phy (enum usb_phy_type type) {@@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) {
include/linux/usb/phy.h static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) · line 198
Quoted 10 lines
include/linux/usb/phy.h +5
-0} +static inline struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +return NULL ; +}#endif static inline int
Controllers like ehci-omap which don't need OTG functionality would benefit from this API. Can we make these PHY APIs not dependent on OTG / OTG_UTILS?
cheers,
-roger
Re: [RFC PATCH 1/6] usb: otg: Add an API to bind the USB controller and PHY
Hi,
Quoted 120 lines · Roger Quadros
Quoted 40 lines · Kishon Vijay Abraham I
New platforms are added which has multiple PHY's (of same type) and which has multiple USB controllers. The binding information has to be present in the PHY library (
otg.c) in order for it to return the appropriate PHY whenever the USB controller request for the PHY. So added a new API to pass the binding information. This API should be called by platform specific initialization code.Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/otg/otg.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 22 ++++++++++++++++++++++ 2 files changed, 59 insertions(+)drivers/usb/otg/otg.c +12
-0@@ -18,6 +18,7 @@#include <linux/usb/otg.h> static LIST_HEAD (phy_list); +static LIST_HEAD (phy_bind_list);static DEFINE_SPINLOCK (phy_lock); static struct usb_phy *__usb_find_phy(struct list_head *list,@@ -201,6 +202,42 @@ void usb_remove_phy(struct usb_phy *x) }EXPORT_SYMBOL (usb_remove_phy); +/** +* usb_bind_phy - bind the phy and the controller that uses the phy +* @dev_name: the device name of the device that will bind to the phy +* @index: index to specify the port number +* @phy_dev_name: the device name of the phy +* +* Fills the phy_bind structure with the dev_name and phy_dev_name. This will +* be used when the phy driver registers the phy and when the controller +* requests this phy. +* +* To be used by platform specific initialization code. drivers/usb/otg/otg.c void usb_remove_phy(struct usb_phy *x) · line 225
Quoted 10 lines
drivers/usb/otg/otg.c +10
-0+*/ +struct usb_phy_bind __init *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +struct usb_phy_bind *phy_bind; +unsigned long flags; + + phy_bind =kzalloc (sizeof (*phy_bind),GFP_KERNEL ); +if (!phy_bind) { +pr_err ("phy_bind(): No memory for phy_bind" );Function name in comment doesn't match the actual. Instead, you could use
pr_err("%s ...", __func__);Quoted 64 lines
drivers/usb/otg/otg.c +15
-0+return ERR_PTR (-ENOMEM ); + } + + phy_bind->dev_name = dev_name; + phy_bind->phy_dev_name = phy_dev_name; + phy_bind->index = index; + +spin_lock_irqsave (&phy_lock, flags); +list_add_tail (&phy_bind->list, &phy_bind_list); +spin_unlock_irqrestore (&phy_lock, flags); + +return phy_bind; +} +EXPORT_SYMBOL_GPL (usb_bind_phy); +const char *otg_state_string (enum usb_otg_state state) {switch (state) {include/linux/usb/phy.h +22
-0@@ -106,6 +106,21 @@ struct usb_phy { enum usb_device_speed speed); }; +/** +* struct usb_phy_bind - represent the binding for the phy +* @dev_name: the device name of the device that will bind to the phy +* @phy_dev_name: the device name of the phy +* @index: used if a single controller uses multiple phys +* @phy: reference to the phy +* @list: to maintain a linked list of the binding information +*/ +struct usb_phy_bind { +const char *dev_name; +const char *phy_dev_name; +u8 index; +struct usb_phy *phy; +struct list_head list; +};/* for board-specific init logic */ extern int usb_add_phy (struct usb_phy *,enum usb_phy_type type);@@ -151,6 +166,8 @@ extern struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type);extern void usb_put_phy (struct usb_phy *);extern void devm_usb_put_phy (struct device *dev,struct usb_phy *x); +extern struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name);#else static inline struct usb_phy *usb_get_phy (enum usb_phy_type type) {@@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) { } +static inline struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +return NULL ; +}#endif
Quoted 6 lines
include/linux/usb/phy.h static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) · line 198
Quoted 2 lines
include/linux/usb/phy.h +0
-0static inline intControllers like ehci-omap which don't need OTG functionality would benefit from this API. Can we make these PHY APIs not dependent on OTG /
OTG_UTILS?
Actually much of whatever is in otg.c can be used by controllers which don't have OTG functionality (except otg_state_string). I vaguely remember, there was a patch that renamed otg.c to phy.c etc.. I'm not sure what happened to that.
Thanks
Kishon
Re: [RFC PATCH 1/6] usb: otg: Add an API to bind the USB controller and PHY
Quoted 18 lines · kishon
Quoted 11 lines
Quoted 11 lines
include/linux/usb/phy.h +5
-0@@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) { } +static inline struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index, +const char *phy_dev_name) +{ +return NULL ; +}#endif Quoted 6 lines
include/linux/usb/phy.h static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) · line 198
Quoted 2 lines
include/linux/usb/phy.h +0
-0static inline intControllers like ehci-omap which don't need OTG functionality would benefit from this API. Can we make these PHY APIs not dependent on OTG /
OTG_UTILS?
Quoted 4 lines
Actually much of whatever is in
otg.ccan be used by controllers which don't have OTG functionality (exceptotg_state_string). I vaguely remember, there was a patch that renamedotg.ctophy.cetc.. I'm not sure what happened to that.
right, that has to be done eventually ;-)
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130118/b6f7337c/attachment.sig>
RFC PATCH 2/6 ARM: OMAP: USB: Add phy binding information
In reply to Kishon Vijay Abraham IThis is in preparation for the changes in PHY library to support adding and getting multiple PHYs of the same type. In the new design, the binding information between the PHY and the USB controller should be specified in the platform specific initialization code. So it's been done for OMAP platforms here.
---
This kind-of binding should be done in all the platforms (I've done only for OMAP platform).
arch/arm/mach-omap2/usb-musb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/usb-musb.c +6 -1
@@ -24,6 +24,7 @@#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/usb/musb.h> +#include <linux/usb/phy.h> #include "omap_device.h" #include "soc.h"
@@ -85,8 +86,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; +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"omap-usb2.1.auto" ); + }else if (cpu_is_omap34xx ()) { +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" ); + }if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ;
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information
Quoted 26 lines · Kishon Vijay Abraham I
This is in preparation for the changes in PHY library to support adding and getting multiple PHYs of the same type. In the new design, the binding information between the PHY and the USB controller should be specified in the platform specific initialization code. So it's been done for OMAP platforms here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
This kind-of binding should be done in all the platforms (I've done only for OMAP platform).arch/arm/mach-omap2/usb-musb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +1
-0@@ -24,6 +24,7 @@#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/usb/musb.h> +#include <linux/usb/phy.h> #include "omap_device.h" #include "soc.h"
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 94
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +5
-1@@ -85,8 +86,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; +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"omap-usb2.1.auto" ); + }else if (cpu_is_omap34xx ()) { +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" ); + }
Are you sure than these OMAP platforms cannot be wired in any other way to the PHY?
If they can be then this association must come from the board files or device tree.
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
Quoted 4 lines
arch/arm/mach-omap2/usb-musb.c +0
-0if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ;
--
cheers,
-roger
Re: [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information
Hi,
Quoted 41 lines · Roger Quadros
Quoted 26 lines · Kishon Vijay Abraham I
This is in preparation for the changes in PHY library to support adding and getting multiple PHYs of the same type. In the new design, the binding information between the PHY and the USB controller should be specified in the platform specific initialization code. So it's been done for OMAP platforms here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
This kind-of binding should be done in all the platforms (I've done only for OMAP platform).arch/arm/mach-omap2/usb-musb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +1
-0@@ -24,6 +24,7 @@#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/usb/musb.h> +#include <linux/usb/phy.h> #include "omap_device.h" #include "soc.h" arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 94
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +5
-1@@ -85,8 +86,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; +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"omap-usb2.1.auto" ); + }else if (cpu_is_omap34xx ()) { +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" ); + }Are you sure than these OMAP platforms cannot be wired in any other way to the PHY?
Quoted 2 lines
If they can be then this association must come from the board files or device tree.
I had given some thought about that and since all the existing OMAP platforms had it this way, I added it here.
You having pointed that out, I'll move these to board files.
Thanks
Kishon
Re: [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information
In reply to Kishon Vijay Abraham IHi Kishon,
Quoted 26 lines · Kishon Vijay Abraham I
This is in preparation for the changes in PHY library to support adding and getting multiple PHYs of the same type. In the new design, the binding information between the PHY and the USB controller should be specified in the platform specific initialization code. So it's been done for OMAP platforms here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
This kind-of binding should be done in all the platforms (I've done only for OMAP platform).arch/arm/mach-omap2/usb-musb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +1
-0@@ -24,6 +24,7 @@#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/usb/musb.h> +#include <linux/usb/phy.h> #include "omap_device.h" #include "soc.h"
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 94
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +5
-1@@ -85,8 +86,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; +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"omap-usb2.1.auto" ); + }else if (cpu_is_omap34xx ()) { +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" ); + }
Just trying to understand things here.
Is the device name we are using here the platform device name (pdev->name) ? If i am not wrong then for devices added through device tree
the device name would actually include the device address in the string, wouldn't that make things somewhat weird, since we will have to add such bindings
using this address string.
one more doubt please :)
is it possible to bind phy in the controllers' driver somehow ?
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +0
-1if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ; --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Thanks & Regards Vivek
Re: [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information
Hi,
Quoted 33 lines · Vivek Gautam
Hi Kishon,
Quoted 29 lines · Kishon Vijay Abraham I
This is in preparation for the changes in PHY library to support adding and getting multiple PHYs of the same type. In the new design, the binding information between the PHY and the USB controller should be specified in the platform specific initialization code. So it's been done for OMAP platforms here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
This kind-of binding should be done in all the platforms (I've done only for OMAP platform).arch/arm/mach-omap2/usb-musb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +1
-0@@ -24,6 +24,7 @@#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/usb/musb.h> +#include <linux/usb/phy.h> #include "omap_device.h" #include "soc.h" @@ -85,8 +86,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;
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 94
Quoted 7 lines
arch/arm/mach-omap2/usb-musb.c +5
-1-if (cpu_is_omap44xx ()) +if (cpu_is_omap44xx ()) { musb_plat.has_mailbox = true; +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"omap-usb2.1.auto" ); + }else if (cpu_is_omap34xx ()) { +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" ); + }Just trying to understand things here.
Is the device name we are using here the platform device name (pdev->name) ?
it's pdev->dev.name.
Quoted 2 lines
If i am not wrong then for devices added through device tree the device name would actually include the device address in the string,
Ideally for device tree, devm_usb_get_phy_by_phandle() introduced in the 5th patch of this series should be used.usb_bind_phy should be called from platform specific initialization files (like your board file), which won't get executed in dt boot.
Quoted 6 lines
wouldn't that make things somewhat weird, since we will have to add such bindings
using this address string.one more doubt please :)
is it possible to bind phy in the controllers' driver somehow ?
Thats not going to be good. Why do you need to do that?
Thanks
Kishon
Re: [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information
Hi Kishon,
Thanks for the explanation.
Quoted 56 lines · kishon
Hi,
Quoted 38 lines · Vivek Gautam
Hi Kishon,
Quoted 32 lines · Kishon Vijay Abraham I
This is in preparation for the changes in PHY library to support adding and getting multiple PHYs of the same type. In the new design, the binding information between the PHY and the USB controller should be specified in the platform specific initialization code. So it's been done for OMAP platforms here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
This kind-of binding should be done in all the platforms (I've done only for OMAP platform).arch/arm/mach-omap2/usb-musb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/arm/mach-omap2/usb-musb.c +1
-0@@ -24,6 +24,7 @@#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/usb/musb.h> +#include <linux/usb/phy.h> #include "omap_device.h" #include "soc.h" @@ -85,8 +86,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;Quoted 12 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) · line 94
Quoted 7 lines
arch/arm/mach-omap2/usb-musb.c +5
-1-if (cpu_is_omap44xx ()) +if (cpu_is_omap44xx ()) { musb_plat.has_mailbox = true; +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"omap-usb2.1.auto" ); + }else if (cpu_is_omap34xx ()) { +usb_bind_phy ("musb-hdrc.0.auto" ,0 ,"twl4030_usb" ); + }Just trying to understand things here.
Is the device name we are using here the platform device name (pdev->name) ?
Quoted 8 lines
it's
pdev->dev.name.Quoted 2 lines
If i am not wrong then for devices added through device tree the device name would actually include the device address in the string,
Ideally for device tree,
devm_usb_get_phy_by_phandle()introduced in the 5th patch of this series should be used.
Ok.
Quoted 3 lines
usb_bind_physhould be called from platform specific initialization files (like your board file), which won't get executed in dt boot.
Right.
Quoted 9 lines
Quoted 6 lines
wouldn't that make things somewhat weird, since we will have to add such bindings
using this address string.one more doubt please :)
is it possible to bind phy in the controllers' driver somehow ?Thats not going to be good. Why do you need to do that?
I was certainly missing something while understanding your patches. That's why got some doubt on this. :)
Quoted 2 lines
Thanks
Kishon
Signature · 2 lines
Thanks & Regards Vivek
RFC PATCH 3/6 usb: otg: utils: change the phy lib to support multiple PHYs of same type
In reply to Kishon Vijay Abraham IIn order to add support for multipe PHY's of the same type, the API's for adding PHY and getting PHY has been changed. Now the binding information of the PHY and controller should be done in platform file using usb_bind_phy API. And for getting a PHY, the device pointer of the USB controller and an index should be passed. Based on the binding information that is added in the platform file, get_phy will return the approappropriate PHY.
--- arch/arm/mach-shmobile/board-marzen.c | 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/isp1704_charger.c | 2 +- drivers/power/pda_power.c | 2 +- drivers/power/twl4030_charger.c | 2 +- drivers/usb/chipidea/udc.c | 2 +- drivers/usb/dwc3/core.c | 4 +- drivers/usb/gadget/fsl_udc_core.c | 2 +- drivers/usb/gadget/mv_udc_core.c | 2 +- drivers/usb/gadget/omap_udc.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 2 +- drivers/usb/gadget/pxa27x_udc.c | 2 +- drivers/usb/gadget/s3c-hsudc.c | 2 +- drivers/usb/host/ehci-fsl.c | 2 +- drivers/usb/host/ehci-msm.c | 2 +- drivers/usb/host/ehci-mv.c | 2 +- drivers/usb/host/ehci-tegra.c | 2 +- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/musb/am35x.c | 2 +- drivers/usb/musb/blackfin.c | 2 +- drivers/usb/musb/da8xx.c | 2 +- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_dsps.c | 2 +- drivers/usb/musb/omap2430.c | 2 +- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/musb/ux500.c | 2 +- drivers/usb/otg/ab8500-usb.c | 3 +- drivers/usb/otg/fsl_otg.c | 5 ++- drivers/usb/otg/gpio_vbus.c | 3 +- drivers/usb/otg/isp1301_omap.c | 3 +- drivers/usb/otg/msm_otg.c | 3 +- drivers/usb/otg/mv_otg.c | 3 +- drivers/usb/otg/nop-usb-xceiv.c | 3 +- drivers/usb/otg/otg.c | 67 +++++++++++++++------------------ drivers/usb/otg/twl4030-usb.c | 3 +- drivers/usb/phy/mv_u3d_phy.c | 3 +- drivers/usb/phy/omap-usb2.c | 11 ++---- drivers/usb/phy/rcar-phy.c | 3 +- include/linux/usb/phy.h | 12 +++--- 39 files changed, 87 insertions(+), 89 deletions(-)
arch/arm/mach-shmobile/board-marzen.c +1 -1
@@ -320,7 +320,7 @@ static struct platform_device *marzen_late_devices[] __initdata = {void __init marzen_init_late (void ) {/* get usb phy */ - phy =usb_get_phy (USB_PHY_TYPE_USB2 ); + phy =usb_get_phy (&ehci0_device.dev,0 );shmobile_init_late (); platform_add_devices(marzen_late_devices,
drivers/power/ab8500_charger.c +1 -1
@@ -2694,7 +2694,7 @@ static int ab8500_charger_probe(struct platform_device *pdev) goto free_ac; } - di->usb_phy =usb_get_phy (USB_PHY_TYPE_USB2 ); + di->usb_phy =usb_get_phy (di->dev,0 );if (IS_ERR_OR_NULL (di->usb_phy)) {dev_err (di->dev,"failed to get usb transceiver\n" ); ret = -EINVAL ;
drivers/power/isp1704_charger.c +1 -1
@@ -415,7 +415,7 @@ static int isp1704_charger_probe(struct platform_device *pdev)if (!isp)return -ENOMEM ; - isp->phy =usb_get_phy (USB_PHY_TYPE_USB2 ); + isp->phy =usb_get_phy (&pdev->dev,0 );if (IS_ERR_OR_NULL (isp->phy)) goto fail0;
drivers/power/pda_power.c +1 -1
@@ -316,7 +316,7 @@ static int pda_power_probe(struct platform_device *pdev) }#ifdef CONFIG_USB_OTG_UTILS - transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + transceiver =usb_get_phy (&pdev->dev,0 );if (!IS_ERR_OR_NULL (transceiver)) {if (!pdata->is_usb_online) pdata->is_usb_online = otg_is_usb_online;
drivers/power/twl4030_charger.c +1 -1
@@ -552,7 +552,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)INIT_WORK (&bci->work, twl4030_bci_usb_work); - bci->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + bci->transceiver =usb_get_phy (&pdev->dev,0 );if (!IS_ERR_OR_NULL (bci->transceiver)) { bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;usb_register_notifier (bci->transceiver, &bci->usb_nb);
drivers/usb/chipidea/udc.c +1 -1
@@ -1745,7 +1745,7 @@ static int udc_start(struct ci13xxx *ci) ci->gadget.ep0 = &ci->ep0in->ep;if (ci->global_phy) - ci->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + ci->transceiver =usb_get_phy (dev,0 );if (ci->platdata->flags &CI13XXX_REQUIRE_TRANSCEIVER ) {if (ci->transceiver ==NULL ) {
drivers/usb/dwc3/core.c +2 -2
@@ -420,13 +420,13 @@ static int dwc3_probe(struct platform_device *pdev)return -ENOMEM ; } - dwc->usb2_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 ); + dwc->usb2_phy =devm_usb_get_phy (dev,0 );if (IS_ERR_OR_NULL (dwc->usb2_phy)) {dev_err (dev,"no usb2 phy configured\n" );return -EPROBE_DEFER ; } - dwc->usb3_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB3 ); + dwc->usb3_phy =devm_usb_get_phy (dev,1 );if (IS_ERR_OR_NULL (dwc->usb3_phy)) {dev_err (dev,"no usb3 phy configured\n" );return -EPROBE_DEFER ;
drivers/usb/gadget/fsl_udc_core.c +1 -1
@@ -2456,7 +2456,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)#ifdef CONFIG_USB_OTG if (pdata->operating_mode ==FSL_USB2_DR_OTG ) { - udc_controller->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + udc_controller->transceiver =usb_get_phy (&pdev->dev,0 );if (IS_ERR_OR_NULL (udc_controller->transceiver)) {ERR ("Can't find OTG driver!\n" ); ret = -ENODEV ;
drivers/usb/gadget/mv_udc_core.c +1 -1
@@ -2218,7 +2218,7 @@ static int mv_udc_probe(struct platform_device *dev)#ifdef CONFIG_USB_OTG_UTILS if (pdata->mode ==MV_USB_MODE_OTG ) - udc->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + udc->transceiver =usb_get_phy (&dev->dev,0 );#endif udc->clknum = pdata->clknum;
drivers/usb/gadget/omap_udc.c +1 -1
@@ -2833,7 +2833,7 @@ static int omap_udc_probe(struct platform_device *pdev)* use it. Except for OTG, we don't _need_ to talk to one; * but not having one probably means no VBUS detection. */ - xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + xceiv =usb_get_phy (&pdev->dev,0 );if (!IS_ERR_OR_NULL (xceiv)) type = xceiv->label;else if (config->otg) {
drivers/usb/gadget/pxa25x_udc.c +1 -1
@@ -2157,7 +2157,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) dev->dev = &pdev->dev; dev->mach = pdev->dev.platform_data; - dev->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + dev->transceiver =usb_get_phy (dev->dev,0 ); if (gpio_is_valid(dev->mach->gpio_pullup)) { if ((retval = gpio_request(dev->mach->gpio_pullup,
drivers/usb/gadget/pxa27x_udc.c +1 -1
@@ -2465,7 +2465,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) udc->dev = &pdev->dev; udc->mach = pdev->dev.platform_data; - udc->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + udc->transceiver =usb_get_phy (udc->dev,0 ); gpio = udc->mach->gpio_pullup;if (gpio_is_valid (gpio)) {
drivers/usb/gadget/s3c-hsudc.c +1 -1
@@ -1281,7 +1281,7 @@ static int s3c_hsudc_probe(struct platform_device *pdev) hsudc->dev = dev; hsudc->pd = pdev->dev.platform_data; - hsudc->transceiver =usb_get_phy (USB_PHY_TYPE_USB2 ); + hsudc->transceiver =usb_get_phy (hsudc->dev,0 );for (i =0 ; i <ARRAY_SIZE (hsudc->supplies); i++) hsudc->supplies[i].supply = s3c_hsudc_supply_names[i];
drivers/usb/host/ehci-fsl.c +1 -1
@@ -143,7 +143,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,if (pdata->operating_mode ==FSL_USB2_DR_OTG ) {struct ehci_hcd *ehci =hcd_to_ehci (hcd); - hcd->phy =usb_get_phy (USB_PHY_TYPE_USB2 ); + hcd->phy =usb_get_phy (&pdev->dev,0 );dev_dbg (&pdev->dev,"hcd=0x%p ehci=0x%p, phy=0x%p\n" , hcd, ehci, hcd->phy);
drivers/usb/host/ehci-msm.c +1 -1
@@ -144,7 +144,7 @@ static int ehci_msm_probe(struct platform_device *pdev)* powering up VBUS, mapping of registers address space and power * management. */ - phy =devm_usb_get_phy (&pdev->dev,USB_PHY_TYPE_USB2 ); + phy =devm_usb_get_phy (&pdev->dev,0 );if (IS_ERR_OR_NULL (phy)) {dev_err (&pdev->dev,"unable to find transceiver\n" ); ret = -ENODEV ;
drivers/usb/host/ehci-mv.c +1 -1
@@ -241,7 +241,7 @@ static int mv_ehci_probe(struct platform_device *pdev) ehci_mv->mode = pdata->mode;if (ehci_mv->mode ==MV_USB_MODE_OTG ) {#ifdef CONFIG_USB_OTG_UTILS - ehci_mv->otg =devm_usb_get_phy (&pdev->dev,USB_PHY_TYPE_USB2 ); + ehci_mv->otg =devm_usb_get_phy (&pdev->dev,0 );if (IS_ERR_OR_NULL (ehci_mv->otg)) {dev_err (&pdev->dev,"unable to find transceiver\n" );
drivers/usb/host/ehci-tegra.c +1 -1
@@ -733,7 +733,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)#ifdef CONFIG_USB_OTG_UTILS if (pdata->operating_mode ==TEGRA_USB_OTG ) { tegra->transceiver = -devm_usb_get_phy (&pdev->dev,USB_PHY_TYPE_USB2 ); +devm_usb_get_phy (&pdev->dev,0 );if (!IS_ERR_OR_NULL (tegra->transceiver))otg_set_host (tegra->transceiver->otg, &hcd->self); }
drivers/usb/host/ohci-omap.c +1 -1
@@ -213,7 +213,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)#ifdef CONFIG_USB_OTG if (need_transceiver) { - hcd->phy =usb_get_phy (USB_PHY_TYPE_USB2 ); + hcd->phy =usb_get_phy (hcd->self.controller,0 );if (!IS_ERR_OR_NULL (hcd->phy)) {int status =otg_set_host (hcd->phy->otg, &ohci_to_hcd (ohci)->self);
drivers/usb/musb/am35x.c +1 -1
@@ -363,7 +363,7 @@ static int am35x_musb_init(struct musb *musb)return -ENODEV ;usb_nop_xceiv_register (); - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (dev,0 );if (IS_ERR_OR_NULL (musb->xceiv))return -ENODEV ;
drivers/usb/musb/blackfin.c +1 -1
@@ -403,7 +403,7 @@ static int bfin_musb_init(struct musb *musb)gpio_direction_output (musb->config->gpio_vrsel,0 );usb_nop_xceiv_register (); - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (musb->controller,0 );if (IS_ERR_OR_NULL (musb->xceiv)) {gpio_free (musb->config->gpio_vrsel);return -ENODEV ;
drivers/usb/musb/da8xx.c +1 -1
@@ -419,7 +419,7 @@ static int da8xx_musb_init(struct musb *musb) goto fail;usb_nop_xceiv_register (); - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (musb->controller,0 );if (IS_ERR_OR_NULL (musb->xceiv)) goto fail;
drivers/usb/musb/davinci.c +1 -1
@@ -382,7 +382,7 @@ static int davinci_musb_init(struct musb *musb)u32 revision;usb_nop_xceiv_register (); - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (musb->controller,0 );if (IS_ERR_OR_NULL (musb->xceiv)) goto unregister;
drivers/usb/musb/musb_dsps.c +1 -1
@@ -412,7 +412,7 @@ static int dsps_musb_init(struct musb *musb)/* NOP driver needs change if supporting dual instance */ usb_nop_xceiv_register (); - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (dev,0 );if (IS_ERR_OR_NULL (musb->xceiv))return -ENODEV ;
drivers/usb/musb/omap2430.c +1 -1
@@ -346,7 +346,7 @@ static int omap2430_musb_init(struct musb *musb)* up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - musb->xceiv =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 ); + musb->xceiv =devm_usb_get_phy (dev,0 );if (IS_ERR_OR_NULL (musb->xceiv)) {pr_err ("HS USB OTG: no transceiver configured\n" );return -ENODEV ;
drivers/usb/musb/tusb6010.c +1 -1
@@ -1067,7 +1067,7 @@ static int tusb_musb_init(struct musb *musb)int ret;usb_nop_xceiv_register (); - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (musb->controller,0 );if (IS_ERR_OR_NULL (musb->xceiv))return -ENODEV ;
drivers/usb/musb/ux500.c +1 -1
@@ -58,7 +58,7 @@ static irqreturn_t ux500_musb_interrupt(int irq, void *__hci)static int ux500_musb_init (struct musb *musb) { - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =usb_get_phy (musb->controller,0 );if (IS_ERR_OR_NULL (musb->xceiv)) {pr_err ("HS USB OTG: no transceiver configured\n" );return -ENODEV ;
drivers/usb/otg/ab8500-usb.c +2 -1
@@ -502,6 +502,7 @@ static int ab8500_usb_probe(struct platform_device *pdev) ab->phy.set_suspend = ab8500_usb_set_suspend; ab->phy.set_power = ab8500_usb_set_power; ab->phy.state =OTG_STATE_UNDEFINED ; + ab->phy.type =USB_PHY_TYPE_USB2 ; otg->phy = &ab->phy; otg->set_host = ab8500_usb_set_host;
@@ -529,7 +530,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)if (err <0 ) goto fail0; - err =usb_add_phy (&ab->phy,USB_PHY_TYPE_USB2 ); + err =usb_add_phy (&ab->phy);if (err) {dev_err (&pdev->dev,"Can't register transceiver\n" ); goto fail1;
drivers/usb/otg/fsl_otg.c +3 -2
@@ -810,6 +810,7 @@ static int fsl_otg_conf(struct platform_device *pdev)/* initialize the otg structure */ fsl_otg_tc->phy.label =DRIVER_DESC ; fsl_otg_tc->phy.set_power = fsl_otg_set_power; + fsl_otg_tc->phy.type =USB_PHY_TYPE_USB2 ; fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy; fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host;
@@ -820,7 +821,7 @@ static int fsl_otg_conf(struct platform_device *pdev) fsl_otg_dev = fsl_otg_tc;/* Store the otg transceiver */ - status =usb_add_phy (&fsl_otg_tc->phy,USB_PHY_TYPE_USB2 ); + status =usb_add_phy (&fsl_otg_tc->phy);if (status) {pr_warn (FSL_OTG_NAME ": unable to register OTG transceiver.\n" ); goto err;
@@ -838,7 +839,7 @@ err:int usb_otg_start (struct platform_device *pdev) {struct fsl_otg *p_otg; -struct usb_phy *otg_trans =usb_get_phy (USB_PHY_TYPE_USB2 ); +struct usb_phy *otg_trans =usb_get_phy (&pdev->dev,0 );struct otg_fsm *fsm;int status;struct resource *res;
drivers/usb/otg/gpio_vbus.c +2 -1
@@ -264,6 +264,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) gpio_vbus->phy.set_power = gpio_vbus_set_power; gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend; gpio_vbus->phy.state =OTG_STATE_UNDEFINED ; + gpio_vbus->phy.type =USB_PHY_TYPE_USB2 ; gpio_vbus->phy.otg->phy = &gpio_vbus->phy; gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
@@ -320,7 +321,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) }/* only active when a gadget is registered */ - err =usb_add_phy (&gpio_vbus->phy,USB_PHY_TYPE_USB2 ); + err =usb_add_phy (&gpio_vbus->phy);if (err) {dev_err (&pdev->dev,"can't register transceiver, err: %d\n" , err);
drivers/usb/otg/isp1301_omap.c +2 -1
@@ -1587,6 +1587,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) isp->phy.dev = &i2c->dev; isp->phy.label =DRIVER_NAME ; isp->phy.set_power = isp1301_set_power, + isp->phy.type =USB_PHY_TYPE_USB2 , isp->phy.otg->phy = &isp->phy; isp->phy.otg->set_host = isp1301_set_host,
@@ -1610,7 +1611,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)dev_dbg (&i2c->dev,"scheduled timer, %d min\n" ,TIMER_MINUTES );#endif - status =usb_add_phy (&isp->phy,USB_PHY_TYPE_USB2 ); + status =usb_add_phy (&isp->phy);if (status <0 )dev_err (&i2c->dev,"can't register transceiver, %d\n" , status);
drivers/usb/otg/msm_otg.c +2 -1
@@ -1548,6 +1548,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) phy->init = msm_otg_reset; phy->set_power = msm_otg_set_power; + phy->phy_type =USB_PHY_TYPE_USB2 ; phy->io_ops = &msm_otg_io_ops;
@@ -1555,7 +1556,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) phy->otg->set_host = msm_otg_set_host; phy->otg->set_peripheral = msm_otg_set_peripheral; - ret =usb_add_phy (&motg->phy,USB_PHY_TYPE_USB2 ); + ret =usb_add_phy (&motg->phy);if (ret) {dev_err (&pdev->dev,"usb_add_phy failed\n" ); goto free_irq;
drivers/usb/otg/mv_otg.c +2 -1
@@ -755,6 +755,7 @@ static int mv_otg_probe(struct platform_device *pdev) mvotg->phy.otg = otg; mvotg->phy.label = driver_name; mvotg->phy.state =OTG_STATE_UNDEFINED ; + mvotg->phy.type =USB_PHY_TYPE_USB2 ; otg->phy = &mvotg->phy; otg->set_host = mv_otg_set_host;
@@ -853,7 +854,7 @@ static int mv_otg_probe(struct platform_device *pdev) goto err_disable_clk; } - retval =usb_add_phy (&mvotg->phy,USB_PHY_TYPE_USB2 ); + retval =usb_add_phy (&mvotg->phy);if (retval <0 ) {dev_err (&pdev->dev,"can't register transceiver, %d\n" , retval);
drivers/usb/otg/nop-usb-xceiv.c +2 -1
@@ -118,12 +118,13 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) nop->phy.label ="nop-xceiv" ; nop->phy.set_suspend = nop_set_suspend; nop->phy.state =OTG_STATE_UNDEFINED ; + nop->phy.type = type; nop->phy.otg->phy = &nop->phy; nop->phy.otg->set_host = nop_set_host; nop->phy.otg->set_peripheral = nop_set_peripheral; - err =usb_add_phy (&nop->phy, type); + err =usb_add_phy (&nop->phy);if (err) {dev_err (&pdev->dev,"can't register transceiver, err: %d\n" , err);
drivers/usb/otg/otg.c +30 -37
141 lines not on this page · raw message
drivers/usb/otg/twl4030-usb.c +2 -1
@@ -611,6 +611,7 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl->phy.label ="twl4030" ; twl->phy.otg = otg; twl->phy.set_suspend = twl4030_set_suspend; + twl->phy.type =USB_PHY_TYPE_USB2 ; otg->phy = &twl->phy; otg->set_host = twl4030_set_host;
@@ -624,7 +625,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)dev_err (&pdev->dev,"ldo init failed\n" );return err; } -usb_add_phy (&twl->phy,USB_PHY_TYPE_USB2 ); +usb_add_phy (&twl->phy);platform_set_drvdata (pdev, twl);if (device_create_file (&pdev->dev, &dev_attr_vbus))
drivers/usb/phy/mv_u3d_phy.c +2 -1
@@ -298,10 +298,11 @@ static int mv_u3d_phy_probe(struct platform_device *pdev) mv_u3d_phy->base = phy_base; mv_u3d_phy->phy.dev = mv_u3d_phy->dev; mv_u3d_phy->phy.label ="mv-u3d-phy" ; + mv_u3d_phy->phy.type =USB_PHY_TYPE_USB3 ; mv_u3d_phy->phy.init = mv_u3d_phy_init; mv_u3d_phy->phy.shutdown = mv_u3d_phy_shutdown; - ret =usb_add_phy (&mv_u3d_phy->phy,USB_PHY_TYPE_USB3 ); + ret =usb_add_phy (&mv_u3d_phy->phy);if (ret) goto err;
drivers/usb/phy/omap-usb2.c +4 -7
@@ -29,6 +29,7 @@#include <linux/delay.h> #include <linux/usb/omap_control_usb.h> +static struct omap_usb *phy;/** * omap_usb2_set_comparator - links the comparator present in the sytem with * this phy
@@ -41,13 +42,9 @@*/ int omap_usb2_set_comparator (struct phy_companion *comparator) { -struct omap_usb *phy; -struct usb_phy *x =usb_get_phy (USB_PHY_TYPE_USB2 ); - -if (IS_ERR (x)) +if (!phy)return -ENODEV ; - phy =phy_to_omapusb (x); phy->comparator = comparator;return 0 ; }
@@ -121,7 +118,6 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)static int omap_usb2_probe (struct platform_device *pdev) { -struct omap_usb *phy;struct usb_otg *otg;struct resource *res;
@@ -141,6 +137,7 @@ static int omap_usb2_probe(struct platform_device *pdev) phy->phy.dev = phy->dev; phy->phy.label ="omap-usb2" ; + phy->phy.type =USB_PHY_TYPE_USB2 ; phy->phy.set_suspend = omap_usb2_suspend; phy->phy.otg = otg;
@@ -168,7 +165,7 @@ static int omap_usb2_probe(struct platform_device *pdev) }clk_prepare (phy->wkupclk); -usb_add_phy (&phy->phy,USB_PHY_TYPE_USB2 ); +usb_add_phy (&phy->phy);platform_set_drvdata (pdev, phy);
drivers/usb/phy/rcar-phy.c +2 -1
@@ -181,11 +181,12 @@ static int rcar_usb_phy_probe(struct platform_device *pdev) priv->counter =0 ; priv->phy.dev = dev; priv->phy.label =dev_name (dev); + priv->phy.type =USB_PHY_TYPE_USB2 ; priv->phy.init = rcar_usb_phy_init; priv->phy.shutdown = rcar_usb_phy_shutdown;spin_lock_init (&priv->lock); - ret =usb_add_phy (&priv->phy,USB_PHY_TYPE_USB2 ); + ret =usb_add_phy (&priv->phy);if (ret <0 ) {dev_err (dev,"usb phy addition error\n" );return ret;
include/linux/usb/phy.h +5 -7
@@ -123,7 +123,7 @@ struct usb_phy_bind { };/* for board-specific init logic */ -extern int usb_add_phy (struct usb_phy *,enum usb_phy_type type); +extern int usb_add_phy (struct usb_phy *);extern void usb_remove_phy (struct usb_phy *);/* helpers for direct access thru low-level io interface */
@@ -161,21 +161,19 @@ usb_phy_shutdown(struct usb_phy *x)/* for usb host and peripheral controller drivers */ #ifdef CONFIG_USB_OTG_UTILS -extern struct usb_phy *usb_get_phy (enum usb_phy_type type); -extern struct usb_phy *devm_usb_get_phy (struct device *dev, -enum usb_phy_type type); +extern struct usb_phy *usb_get_phy (struct device *dev,u8 index); +extern struct usb_phy *devm_usb_get_phy (struct device *dev,u8 index);extern void usb_put_phy (struct usb_phy *);extern void devm_usb_put_phy (struct device *dev,struct usb_phy *x);extern struct usb_phy_bind *usb_bind_phy (const char *dev_name,u8 index,const char *phy_dev_name);#else -static inline struct usb_phy *usb_get_phy (enum usb_phy_type type) +static inline struct usb_phy *usb_get_phy (struct device *dev,u8 index) {return NULL ; } -static inline struct usb_phy *devm_usb_get_phy (struct device *dev, -enum usb_phy_type type) +static inline struct usb_phy *devm_usb_get_phy (struct device *dev,u8 index) {return NULL ; }
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type
Quoted 11 lines · Kishon Vijay Abraham I
In order to add support for multipe PHY's of the same type, the API's for adding PHY and getting PHY has been changed. Now the binding information of the PHY and controller should be done in platform file using
usb_bind_phyAPI. And for getting a PHY, the device pointer of the USB controller and an index should be passed. Based on the binding information that is added in the platform file,get_phywill return the approappropriate PHY.Signed-off-by Kishon Vijay Abraham I <[email protected]>--- arch/arm/mach-shmobile/board-marzen.c | 2 +-
Modification to the above file:
Re: [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type
In reply to Kishon Vijay Abraham IQuoted 42 lines · Kishon Vijay Abraham I
In order to add support for multipe PHY's of the same type, the API's for adding PHY and getting PHY has been changed. Now the binding information of the PHY and controller should be done in platform file using
usb_bind_phyAPI. And for getting a PHY, the device pointer of the USB controller and an index should be passed. Based on the binding information that is added in the platform file,get_phywill return the approappropriate PHY.Signed-off-by Kishon Vijay Abraham I <[email protected]>--- arch/arm/mach-shmobile/board-marzen.c | 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/isp1704_charger.c | 2 +- drivers/power/pda_power.c | 2 +- drivers/power/twl4030_charger.c | 2 +- drivers/usb/chipidea/udc.c | 2 +- drivers/usb/dwc3/core.c | 4 +- drivers/usb/gadget/fsl_udc_core.c | 2 +- drivers/usb/gadget/mv_udc_core.c | 2 +- drivers/usb/gadget/omap_udc.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 2 +- drivers/usb/gadget/pxa27x_udc.c | 2 +- drivers/usb/gadget/s3c-hsudc.c | 2 +- drivers/usb/host/ehci-fsl.c | 2 +- drivers/usb/host/ehci-msm.c | 2 +- drivers/usb/host/ehci-mv.c | 2 +- drivers/usb/host/ehci-tegra.c | 2 +- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/musb/am35x.c | 2 +- drivers/usb/musb/blackfin.c | 2 +- drivers/usb/musb/da8xx.c | 2 +- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_dsps.c | 2 +- drivers/usb/musb/omap2430.c | 2 +- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/musb/ux500.c | 2 +- drivers/usb/otg/ab8500-usb.c | 3 +- drivers/usb/otg/fsl_otg.c | 5 ++- drivers/usb/otg/gpio_vbus.c | 3 +- drivers/usb/otg/isp1301_omap.c | 3 +- drivers/usb/otg/msm_otg.c | 3 +- drivers/usb/otg/mv_otg.c | 3 +-
Quoted 8 lines
drivers/usb/otg/nop-usb-xceiv.c | 3 +- drivers/usb/otg/otg.c | 67 +++++++++++++++------------------ drivers/usb/otg/twl4030-usb.c | 3 +- drivers/usb/phy/mv_u3d_phy.c | 3 +- drivers/usb/phy/omap-usb2.c | 11 ++---- drivers/usb/phy/rcar-phy.c | 3 +- include/linux/usb/phy.h | 12 +++--- 39 files changed, 87 insertions(+), 89 deletions(-)
I think it better to leave the existing add/get APIs as they are add add new APIs that support multiple PHYs. You could probably mark the old ones as deprecated.
That way you don't need to wait till all users are converted and tested.
e.g. you could name the new APIs as
usb_add_phy_dev(struct usb_phy *phy);usb_get_phy_dev(struct device *dev, int index);
--
cheers,
-roger
Re: [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type
Hi,
Quoted 52 lines · Roger Quadros
Quoted 42 lines · Kishon Vijay Abraham I
In order to add support for multipe PHY's of the same type, the API's for adding PHY and getting PHY has been changed. Now the binding information of the PHY and controller should be done in platform file using
usb_bind_phyAPI. And for getting a PHY, the device pointer of the USB controller and an index should be passed. Based on the binding information that is added in the platform file,get_phywill return the approappropriate PHY.Signed-off-by Kishon Vijay Abraham I <[email protected]>--- arch/arm/mach-shmobile/board-marzen.c | 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/isp1704_charger.c | 2 +- drivers/power/pda_power.c | 2 +- drivers/power/twl4030_charger.c | 2 +- drivers/usb/chipidea/udc.c | 2 +- drivers/usb/dwc3/core.c | 4 +- drivers/usb/gadget/fsl_udc_core.c | 2 +- drivers/usb/gadget/mv_udc_core.c | 2 +- drivers/usb/gadget/omap_udc.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 2 +- drivers/usb/gadget/pxa27x_udc.c | 2 +- drivers/usb/gadget/s3c-hsudc.c | 2 +- drivers/usb/host/ehci-fsl.c | 2 +- drivers/usb/host/ehci-msm.c | 2 +- drivers/usb/host/ehci-mv.c | 2 +- drivers/usb/host/ehci-tegra.c | 2 +- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/musb/am35x.c | 2 +- drivers/usb/musb/blackfin.c | 2 +- drivers/usb/musb/da8xx.c | 2 +- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_dsps.c | 2 +- drivers/usb/musb/omap2430.c | 2 +- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/musb/ux500.c | 2 +- drivers/usb/otg/ab8500-usb.c | 3 +- drivers/usb/otg/fsl_otg.c | 5 ++- drivers/usb/otg/gpio_vbus.c | 3 +- drivers/usb/otg/isp1301_omap.c | 3 +- drivers/usb/otg/msm_otg.c | 3 +- drivers/usb/otg/mv_otg.c | 3 +-Quoted 8 lines
drivers/usb/otg/nop-usb-xceiv.c | 3 +- drivers/usb/otg/otg.c | 67 +++++++++++++++------------------ drivers/usb/otg/twl4030-usb.c | 3 +- drivers/usb/phy/mv_u3d_phy.c | 3 +- drivers/usb/phy/omap-usb2.c | 11 ++---- drivers/usb/phy/rcar-phy.c | 3 +- include/linux/usb/phy.h | 12 +++--- 39 files changed, 87 insertions(+), 89 deletions(-)
Quoted 5 lines
I think it better to leave the existing add/get APIs as they are add add new APIs that support multiple PHYs. You could probably mark the old ones as deprecated.
That way you don't need to wait till all users are converted and tested.
Makes sense. Will do that :-)
Thanks
Kishon
RFC PATCH 4/6 ARM: dts: OMAP: Add phandle to bind PHY with USB controller
In reply to Kishon Vijay Abraham IAdded a phandle in the dt node for usb_otg to bind the PHY with the USB controller and also updated the documentation with the binding information.
---
I'll add this patch in this series "usb: musb: add driver for control module" which contains the dt data to get MUSB working in dt boot in OMAP platforms.
Documentation/devicetree/bindings/usb/omap-usb.txt | 2 ++ arch/arm/boot/dts/omap3.dtsi | 1 + arch/arm/boot/dts/omap4.dtsi | 3 ++- arch/arm/boot/dts/twl4030.dtsi | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/omap-usb.txt +2 -0
@@ -18,6 +18,7 @@ OMAP MUSB GLUE represents PERIPHERAL. - power : Should be "50". This signifies the controller can supply upto 100mA when operating in host mode. + - usb_phy : the phandle for the PHY device SOC specific device node entry usb_otg_hs: usb_otg_hs at 4a0ab000 {
@@ -27,6 +28,7 @@ usb_otg_hs: usb_otg_hs at 4a0ab000 { multipoint = <1>; num_eps = <16>; ram_bits = <12>; + usb_phy = <&phy>; }; Board specific device node entry
arch/arm/boot/dts/omap3.dtsi +1 -0
@@ -404,6 +404,7 @@ interrupts = <0 92 0x4>, <0 93 0x4>; interrupt-names = "mc", "dma"; ti,hwmods = "usb_otg_hs"; + usb_phy = <&phy>; multipoint = <1>; num_eps = <16>; ram_bits = <12>;
arch/arm/boot/dts/omap4.dtsi +2 -1
@@ -438,7 +438,7 @@ #size-cells = <1>; ranges; ti,hwmods = "ocp2scp_usb_phy"; - usb2phy at 4a0ad080 { + phy: usb2phy at 4a0ad080 { compatible = "ti,omap-usb2"; reg = <0x4a0ad080 0x58>; };
@@ -540,6 +540,7 @@ interrupts = <0 92 0x4>, <0 93 0x4>; interrupt-names = "mc", "dma"; ti,hwmods = "usb_otg_hs"; + usb_phy = <&phy>; multipoint = <1>; num_eps = <16>; ram_bits = <12>;
arch/arm/boot/dts/twl4030.dtsi +1 -1
@@ -67,7 +67,7 @@ #interrupt-cells = <1>; }; - twl4030-usb { + phy: twl4030-usb { compatible = "ti,twl4030-usb"; interrupts = <10>, <4>; usb1v5-supply = <&vusb1v5>;
Signature · 1 line
1.7.9.5
RFC PATCH 5/6 usb: otg: add device tree support to otg library
In reply to Kishon Vijay Abraham IAdded an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a device node phandle value. This function will return a pointer to the phy on success, -EPROBE_DEFER if there is a device_node for the phandle, but the phy has not been added, or a ERR_PTR() otherwise.
--- drivers/usb/otg/otg.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 8 +++++ 2 files changed, 85 insertions(+)
drivers/usb/otg/otg.c +77 -0
@@ -13,7 +13,9 @@#include <linux/export.h> #include <linux/err.h> #include <linux/device.h> +#include <linux/module.h> #include <linux/slab.h> +#include <linux/of.h> #include <linux/usb/otg.h>
@@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 index)return ERR_PTR (-ENODEV ); } +static struct usb_phy *__of_usb_find_phy (struct device_node *node) +{ +struct usb_phy *phy; + +list_for_each_entry (phy, &phy_list, head) { +if (node != phy->dev->of_node) +continue ; + +return phy; + } + +return ERR_PTR (-ENODEV ); +} +static void devm_usb_phy_release (struct device *dev,void *res) {struct usb_phy *phy = *(struct usb_phy **)res;
@@ -109,6 +125,67 @@ err0: }EXPORT_SYMBOL (usb_get_phy); +/** +* devm_usb_get_phy_by_phandle - find the USB PHY by phandle +* @dev - device that requests this phy +* @phandle - name of the property holding the phy phandle value +* @index - the index of the phy +* +* Returns the phy driver associated with the given phandle value, +* after getting a refcount to it, -ENODEV if there is no such phy or +* -EPROBE_DEFER if there is a phandle to the phy, but the device is +* not yet loaded. While at that, it also associates the device with +* the phy 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_phandle (struct device *dev, +const char *phandle,u8 index) +{ +struct usb_phy *phy =NULL , **ptr; +unsigned long flags; +struct device_node *node; + +if (!dev->of_node) { +dev_dbg (dev,"device does not have a device node entry\n" ); +return ERR_PTR (-EINVAL ); + } + + node =of_parse_phandle (dev->of_node, phandle, index); +if (!node) { +dev_dbg (dev,"failed to get %s phandle in %s node\n" , phandle, + dev->of_node->full_name); +return ERR_PTR (-ENODEV ); + } + + ptr =devres_alloc (devm_usb_phy_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) { +dev_dbg (dev,"failed to allocate memory for devres\n" ); +return ERR_PTR (-ENOMEM ); + } + +spin_lock_irqsave (&phy_lock, flags); + + phy =__of_usb_find_phy (node); +if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { + phy =ERR_PTR (-EPROBE_DEFER ); +devres_free (ptr); + goto err0; + } + + *ptr = phy; +devres_add (dev, ptr); + +get_device (phy->dev); + +err0: +spin_unlock_irqrestore (&phy_lock, flags); + +return phy; +} +EXPORT_SYMBOL (devm_usb_get_phy_by_phandle); +/** * devm_usb_put_phy - release the USB PHY * @dev - device that wants to release this phy
include/linux/usb/phy.h +8 -0
@@ -163,6 +163,8 @@ usb_phy_shutdown(struct usb_phy *x)#ifdef CONFIG_USB_OTG_UTILS extern struct usb_phy *usb_get_phy (struct device *dev,u8 index);extern struct usb_phy *devm_usb_get_phy (struct device *dev,u8 index); +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 *);extern void devm_usb_put_phy (struct device *dev,struct usb_phy *x); extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
@@ -178,6 +180,12 @@ static inline struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index)return NULL ; } +static inline struct usb_phy *devm_usb_get_phy_by_phandle (struct device *dev, +const char *phandle,u8 index) +{ +return NULL ; +} +static inline void usb_put_phy (struct usb_phy *x) { }
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library
Quoted 80 lines · Kishon Vijay Abraham I
Added an API
devm_usb_get_phy_by_phandle(), to get usb phy by passing a device node phandle value. This function will return a pointer to the phy on success, -EPROBE_DEFER if there is adevice_nodefor the phandle, but the phy has not been added, or aERR_PTR()otherwise.Cc Marc Kleine-Budde <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/otg/otg.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 8 +++++ 2 files changed, 85 insertions(+)drivers/usb/otg/otg.c +45
-0@@ -13,7 +13,9 @@#include <linux/export.h> #include <linux/err.h> #include <linux/device.h> +#include <linux/module.h> #include <linux/slab.h> +#include <linux/of.h> #include <linux/usb/otg.h> @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 index)return ERR_PTR (-ENODEV ); } +static struct usb_phy *__of_usb_find_phy (struct device_node *node) +{ +struct usb_phy *phy; + +list_for_each_entry (phy, &phy_list, head) { +if (node != phy->dev->of_node) +continue ; + +return phy; + } + +return ERR_PTR (-ENODEV ); +} +static void devm_usb_phy_release (struct device *dev,void *res) {struct usb_phy *phy = *(struct usb_phy **)res;@@ -109,6 +125,67 @@ err0: }EXPORT_SYMBOL (usb_get_phy); +/** +* devm_usb_get_phy_by_phandle - find the USB PHY by phandle +* @dev - device that requests this phy +* @phandle - name of the property holding the phy phandle value +* @index - the index of the phy +* +* Returns the phy driver associated with the given phandle value, +* after getting a refcount to it, -ENODEV if there is no such phy or +* -EPROBE_DEFER if there is a phandle to the phy, but the device is +* not yet loaded. While at that, it also associates the device with +* the phy 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_phandle (struct device *dev, +const char *phandle,u8 index) +{ +struct usb_phy *phy =NULL , **ptr; +unsigned long flags; +struct device_node *node; + +if (!dev->of_node) { +dev_dbg (dev,"device does not have a device node entry\n" ); +return ERR_PTR (-EINVAL ); + } + + node =of_parse_phandle (dev->of_node, phandle, index); +if (!node) {
drivers/usb/otg/otg.c err0: · line 166
Quoted 10 lines
drivers/usb/otg/otg.c +10
-0+dev_dbg (dev,"failed to get %s phandle in %s node\n" , phandle, + dev->of_node->full_name); +return ERR_PTR (-ENODEV ); + } + + ptr =devres_alloc (devm_usb_phy_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) { +dev_dbg (dev,"failed to allocate memory for devres\n" ); +return ERR_PTR (-ENOMEM ); + }
I fail to understand why you need ptr at all and why do devres_alloc() for it.
Quoted 12 lines
drivers/usb/otg/otg.c +12
-0+ +spin_lock_irqsave (&phy_lock, flags); + + phy =__of_usb_find_phy (node); +if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { + phy =ERR_PTR (-EPROBE_DEFER ); +devres_free (ptr); + goto err0; + } + + *ptr = phy; +devres_add (dev, ptr);
drivers/usb/otg/otg.c err0: · line 188
Quoted 10 lines
drivers/usb/otg/otg.c +10
-0+ +get_device (phy->dev); + +err0: +spin_unlock_irqrestore (&phy_lock, flags); + +return phy; +} +EXPORT_SYMBOL (devm_usb_get_phy_by_phandle); +
--
cheers,
-roger
Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library
Quoted 86 lines · Roger Quadros
Quoted 85 lines · Kishon Vijay Abraham I
Added an API
devm_usb_get_phy_by_phandle(), to get usb phy by passing a device node phandle value. This function will return a pointer to the phy on success, -EPROBE_DEFER if there is adevice_nodefor the phandle, but the phy has not been added, or aERR_PTR()otherwise.Cc Marc Kleine-Budde <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/otg/otg.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 8 +++++ 2 files changed, 85 insertions(+)drivers/usb/otg/otg.c +50
-0@@ -13,7 +13,9 @@#include <linux/export.h> #include <linux/err.h> #include <linux/device.h> +#include <linux/module.h> #include <linux/slab.h> +#include <linux/of.h> #include <linux/usb/otg.h> @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 index)return ERR_PTR (-ENODEV ); } +static struct usb_phy *__of_usb_find_phy (struct device_node *node) +{ +struct usb_phy *phy; + +list_for_each_entry (phy, &phy_list, head) { +if (node != phy->dev->of_node) +continue ; + +return phy; + } + +return ERR_PTR (-ENODEV ); +} +static void devm_usb_phy_release (struct device *dev,void *res) {struct usb_phy *phy = *(struct usb_phy **)res;@@ -109,6 +125,67 @@ err0: }EXPORT_SYMBOL (usb_get_phy); +/** +* devm_usb_get_phy_by_phandle - find the USB PHY by phandle +* @dev - device that requests this phy +* @phandle - name of the property holding the phy phandle value +* @index - the index of the phy +* +* Returns the phy driver associated with the given phandle value, +* after getting a refcount to it, -ENODEV if there is no such phy or +* -EPROBE_DEFER if there is a phandle to the phy, but the device is +* not yet loaded. While at that, it also associates the device with +* the phy 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_phandle (struct device *dev, +const char *phandle,u8 index) +{ +struct usb_phy *phy =NULL , **ptr; +unsigned long flags; +struct device_node *node; + +if (!dev->of_node) { +dev_dbg (dev,"device does not have a device node entry\n" ); +return ERR_PTR (-EINVAL ); + } + + node =of_parse_phandle (dev->of_node, phandle, index); +if (!node) { +dev_dbg (dev,"failed to get %s phandle in %s node\n" , phandle, + dev->of_node->full_name); +return ERR_PTR (-ENODEV ); + } +
Quoted 8 lines
drivers/usb/otg/otg.c err0: · line 166
Quoted 5 lines
drivers/usb/otg/otg.c +5
-0+ ptr =devres_alloc (devm_usb_phy_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) { +dev_dbg (dev,"failed to allocate memory for devres\n" ); +return ERR_PTR (-ENOMEM ); + }I fail to understand why you need ptr at all and why do
devres_alloc()for it.
Thats how we create a "managed device resource". You can have a look at Documentation/driver-model/devres.txt and drivers/base/devres.c.
I'm not sure if that is what you are looking for :-P
Thanks
Kishon
Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library
Quoted 99 lines · kishon
Quoted 89 lines · Roger Quadros
Quoted 88 lines · Kishon Vijay Abraham I
Added an API
devm_usb_get_phy_by_phandle(), to get usb phy by passing a device node phandle value. This function will return a pointer to the phy on success, -EPROBE_DEFER if there is adevice_nodefor the phandle,
but the phy has not been added, or aERR_PTR()otherwise.Cc Marc Kleine-Budde <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/otg/otg.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/phy.h | 8 +++++ 2 files changed, 85 insertions(+)drivers/usb/otg/otg.c +16
-0@@ -13,7 +13,9 @@#include <linux/export.h> #include <linux/err.h> #include <linux/device.h> +#include <linux/module.h> #include <linux/slab.h> +#include <linux/of.h> #include <linux/usb/otg.h> @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 index)return ERR_PTR (-ENODEV ); } +static struct usb_phy *__of_usb_find_phy (struct device_node *node) +{ +struct usb_phy *phy; + +list_for_each_entry (phy, &phy_list, head) { +if (node != phy->dev->of_node) +continue ; + +return phy; + } + +return ERR_PTR (-ENODEV ); +} +static void devm_usb_phy_release (struct device *dev,void *res) {struct usb_phy *phy = *(struct usb_phy **)res;drivers/usb/otg/otg.c +34
-0@@ -109,6 +125,67 @@ err0: }EXPORT_SYMBOL (usb_get_phy); +/** +* devm_usb_get_phy_by_phandle - find the USB PHY by phandle +* @dev - device that requests this phy +* @phandle - name of the property holding the phy phandle value +* @index - the index of the phy +* +* Returns the phy driver associated with the given phandle value, +* after getting a refcount to it, -ENODEV if there is no such phy or +* -EPROBE_DEFER if there is a phandle to the phy, but the device is +* not yet loaded. While at that, it also associates the device with +* the phy 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_phandle (struct device *dev, +const char *phandle,u8 index) +{ +struct usb_phy *phy =NULL , **ptr; +unsigned long flags; +struct device_node *node; + +if (!dev->of_node) { +dev_dbg (dev,"device does not have a device node entry\n" ); +return ERR_PTR (-EINVAL ); + } + + node =of_parse_phandle (dev->of_node, phandle, index); +if (!node) { +dev_dbg (dev,"failed to get %s phandle in %s node\n" , phandle, + dev->of_node->full_name); +return ERR_PTR (-ENODEV ); + } +Quoted 8 lines
drivers/usb/otg/otg.c err0: · line 166
Quoted 5 lines
drivers/usb/otg/otg.c +5
-0+ ptr =devres_alloc (devm_usb_phy_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) { +dev_dbg (dev,"failed to allocate memory for devres\n" ); +return ERR_PTR (-ENOMEM ); + }I fail to understand why you need ptr at all and why do
devres_alloc()for it.
Quoted 2 lines
Thats how we create a "managed device resource". You can have a look at
Documentation/driver-model/devres.txtanddrivers/base/devres.c.
OK, I get it now. You might want to update the text file too since you are adding a automagically managed interface.
regards,
-roger
RFC PATCH 6/6 USB: MUSB: OMAP: get PHY by phandle for dt boot
In reply to Kishon Vijay Abraham IThe OMAP glue has been modified to get PHY by phandle for dt boot.
--- drivers/usb/musb/omap2430.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/musb/omap2430.c +6 -1
@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)* up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - musb->xceiv =devm_usb_get_phy (dev,0 ); +if (dev->parent->of_node) + musb->xceiv =devm_usb_get_phy_by_phandle (dev->parent, +"usb_phy" ,0 ); +else + musb->xceiv =devm_usb_get_phy (dev,0 ); +if (IS_ERR_OR_NULL (musb->xceiv)) {pr_err ("HS USB OTG: no transceiver configured\n" );return -ENODEV ;
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot
Quoted 12 lines · Kishon Vijay Abraham I
The OMAP glue has been modified to get PHY by phandle for dt boot.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/musb/omap2430.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/musb/omap2430.c +0
-0
drivers/usb/musb/omap2430.c static int omap2430_musb_init(struct musb *musb) · line 351
Quoted 7 lines
drivers/usb/musb/omap2430.c +3
-1@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)* up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - musb->xceiv =devm_usb_get_phy (dev,0 ); +if (dev->parent->of_node) + musb->xceiv =devm_usb_get_phy_by_phandle (dev->parent, +"usb_phy" ,0 );
Why dev->parent and not just dev?
drivers/usb/musb/omap2430.c static int omap2430_musb_init(struct musb *musb) · line 357
Quoted 7 lines
drivers/usb/musb/omap2430.c +3
-0+else + musb->xceiv =devm_usb_get_phy (dev,0 ); +if (IS_ERR_OR_NULL (musb->xceiv)) {pr_err ("HS USB OTG: no transceiver configured\n" );return -ENODEV ;
--
cheers,
-roger
Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot
Hi,
Quoted 8 lines · Roger Quadros
Quoted 7 lines · Kishon Vijay Abraham I
The OMAP glue has been modified to get PHY by phandle for dt boot.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/musb/omap2430.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 14 lines
drivers/usb/musb/omap2430.c static int omap2430_musb_init(struct musb *musb) · line 351
Quoted 12 lines
drivers/usb/musb/omap2430.c +3
-1@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)* up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - musb->xceiv =devm_usb_get_phy (dev,0 ); +if (dev->parent->of_node) + musb->xceiv =devm_usb_get_phy_by_phandle (dev->parent, +"usb_phy" ,0 );Why
dev->parentand not just dev?
Right now MUSB core is not converted to dt and hence we don't have separate dt node for MUSB core.
So the PHY information is added to the glue dt data.
Thanks
Kishon
Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot
Quoted 26 lines · kishon
Hi,
Quoted 8 lines · Roger Quadros
Quoted 7 lines · Kishon Vijay Abraham I
The OMAP glue has been modified to get PHY by phandle for dt boot.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/musb/omap2430.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Quoted 14 lines
drivers/usb/musb/omap2430.c static int omap2430_musb_init(struct musb *musb) · line 351
Quoted 12 lines
drivers/usb/musb/omap2430.c +3
-1@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)* up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - musb->xceiv =devm_usb_get_phy (dev,0 ); +if (dev->parent->of_node) + musb->xceiv =devm_usb_get_phy_by_phandle (dev->parent, +"usb_phy" ,0 );Why
dev->parentand not just dev?
Quoted 4 lines
Right now MUSB core is not converted to dt and hence we don't have separate dt node for MUSB core.
So the PHY information is added to the glue dt data.
OK. Got it :).
--
cheers,
-roger
Quoted 13 lines · Kishon Vijay Abraham I
New platforms are being added which has multiple PHY's (of same type) and which has multiple USB controllers. The binding information has to be present in the PHY library (
otg.c) in order for it to return the appropriate PHY whenever the USB controller request for the PHY. So added a new API to pass the binding information. This API should be called by platform specific initialization code.So the binding should be done something like
usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto"); specifying the USB controller device name, index, and the PHY device name.
I have done this binding for OMAP platforms, but it should be done for all the platforms.
Quoted 8 lines
After this design, the phy can be got by passing the USB controller device pointer and the index.
Developed this patch series on
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.gitxceiv after applying "usb: musb: add driver for control module" patch series.Did basic enumeration testing in omap4 panda, omap4 sdp and omap3 beagle.
please resend without RFC so I can apply.
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130118/b16f5fe2/attachment.sig>
Quoted 17 lines · Felipe Balbi
Quoted 16 lines · Kishon Vijay Abraham I
New platforms are being added which has multiple PHY's (of same type) and which has multiple USB controllers. The binding information has to be present in the PHY library (
otg.c) in order for it to return the appropriate PHY whenever the USB controller request for the PHY. So added a new API to pass the binding information. This API should be called by platform specific initialization code.So the binding should be done something like
usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto"); specifying the USB controller device name, index, and the PHY device name.
I have done this binding for OMAP platforms, but it should be done for all the platforms.After this design, the phy can be got by passing the USB controller device pointer and the index.
Quoted 7 lines
Quoted 5 lines
Developed this patch series on
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.gitxceiv after applying "usb: musb: add driver for control module" patch series.Did basic enumeration testing in omap4 panda, omap4 sdp and omap3 beagle.
please resend without RFC so I can apply.
I'll resend after addressing Roger's comments in a while.
Thanks
Kishon