drivers: usb: common: add common code for usb drivers to use
PATCH 1/1 drivers: usb: common: add common code for usb drivers to use
Add common usb code which usb drivers makes use of it.
---
This was in my musb dm bringup patch list, and I did dwc3 over the same branch so missed submitting this patch for dwc3 bringup. So submitting the dwc3 dependent patch separately and will drop this while submitting v2 for musb.
Simon, before applying [1], can you apply this first so that the dependents are met.
[1]: https://www.mail-archive.com/u-boot at lists.denx.de/msg206602.html
--- Makefile | 1 + drivers/usb/common/Makefile | 8 ++++++++ drivers/usb/common/common.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ 4 files changed, 58 insertions(+) create mode 100644 drivers/usb/common/Makefile create mode 100644 drivers/usb/common/common.c
Makefile +1 -0
@@ -657,6 +657,7 @@ libs-y += drivers/usb/musb/ libs-y += drivers/usb/musb-new/ libs-y += drivers/usb/phy/ libs-y += drivers/usb/ulpi/ +libs-y += drivers/usb/common/ libs-y += cmd/ libs-y += common/ libs-$(CONFIG_API) += api/
drivers/usb/common/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# (C) Copyright 2016 +# Texas Instruments Incorporated, <www.ti.com> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-$(CONFIG_DM_USB) += common.o
drivers/usb/common/common.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Provides code common for host and device side USB. +* +* (C) Copyright 2016 +* Texas Instruments Incorporated, <www.ti.com> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <libfdt.h> +#include <linux/usb/otg.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static const char *const usb_dr_modes[] = { + [USB_DR_MODE_UNKNOWN ] ="" , + [USB_DR_MODE_HOST ] ="host" , + [USB_DR_MODE_PERIPHERAL ] ="peripheral" , + [USB_DR_MODE_OTG ] ="otg" , +}; + +enum usb_dr_mode usb_get_dr_mode (int node) +{ +const void *fdt = gd->fdt_blob; +const char *dr_mode; +int i; + + dr_mode =fdt_getprop (fdt, node,"dr_mode" ,NULL ); +if (!dr_mode) { +error ("usb dr_mode not found\n" ); +return USB_DR_MODE_UNKNOWN ; + } + +for (i =0 ; i <ARRAY_SIZE (usb_dr_modes); i++) +if (!strcmp (dr_mode, usb_dr_modes[i])) +return i; + +return USB_DR_MODE_UNKNOWN ; +}
include/linux/usb/otg.h +9 -0
@@ -17,4 +17,13 @@ enum usb_dr_mode { USB_DR_MODE_OTG, }; +/** +* usb_get_dr_mode() - Get dual role mode for given device +* @node: Node offset to the given device +* +* The function gets phy interface string from property 'dr_mode', +* and returns the correspondig enum usb_dr_mode +*/ +enum usb_dr_mode usb_get_dr_mode (int node); +#endif /* __LINUX_USB_OTG_H */
Signature · 1 line
2.8.1.101.g72d917a
PATCH 1/1 drivers: usb: common: add common code for usb drivers to use
Quoted 15 lines · Mugunthan V N
Add common usb code which usb drivers makes use of it.
Signed-off-by Mugunthan V N <[email protected]>---
This was in my musb dm bringup patch list, and I did dwc3 over the same branch so missed submitting this patch for dwc3 bringup. So submitting the dwc3 dependent patch separately and will drop this while submitting v2 for musb.
Simon, before applying [1], can you apply this first so that the dependents are met.
[1]: https://www.mail-archive.com/u-boot at lists.denx.de/msg206602.html
Quoted 8 lines
--- Makefile | 1 + drivers/usb/common/Makefile | 8 ++++++++ drivers/usb/common/common.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ 4 files changed, 58 insertions(+) create mode 100644 drivers/usb/common/Makefile create mode 100644 drivers/usb/common/common.c
Marek, if you are OK with it, i'd like to bring this into u-boot-dm as it is a prerequisite for a series in my patchwork todo list.
Regards,
Simon
PATCH 1/1 drivers: usb: common: add common code for usb drivers to use
Quoted 25 lines · Simon Glass
Quoted 15 lines · Mugunthan V N
Add common usb code which usb drivers makes use of it.
Signed-off-by Mugunthan V N <[email protected]>---
This was in my musb dm bringup patch list, and I did dwc3 over the same branch so missed submitting this patch for dwc3 bringup. So submitting the dwc3 dependent patch separately and will drop this while submitting v2 for musb.
Simon, before applying [1], can you apply this first so that the dependents are met.
[1]: https://www.mail-archive.com/u-boot at lists.denx.de/msg206602.html
Quoted 8 lines
--- Makefile | 1 + drivers/usb/common/Makefile | 8 ++++++++ drivers/usb/common/common.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ 4 files changed, 58 insertions(+) create mode 100644 drivers/usb/common/Makefile create mode 100644 drivers/usb/common/common.c
Quoted 4 lines
Reviewed-by Simon Glass <[email protected]>Marek, if you are OK with it, i'd like to bring this into u-boot-dm as it is a prerequisite for a series in my patchwork todo list.
That's fine, thanks.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 drivers: usb: common: add common code for usb drivers to use
Quoted 31 lines · Marek Vasut
Quoted 25 lines · Simon Glass
Quoted 15 lines · Mugunthan V N
Add common usb code which usb drivers makes use of it.
Signed-off-by Mugunthan V N <[email protected]>---
This was in my musb dm bringup patch list, and I did dwc3 over the same branch so missed submitting this patch for dwc3 bringup. So submitting the dwc3 dependent patch separately and will drop this while submitting v2 for musb.
Simon, before applying [1], can you apply this first so that the dependents are met.
[1]: https://www.mail-archive.com/u-boot at lists.denx.de/msg206602.html
Quoted 8 lines
--- Makefile | 1 + drivers/usb/common/Makefile | 8 ++++++++ drivers/usb/common/common.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ 4 files changed, 58 insertions(+) create mode 100644 drivers/usb/common/Makefile create mode 100644 drivers/usb/common/common.cQuoted 4 lines
Reviewed-by Simon Glass <[email protected]>Marek, if you are OK with it, i'd like to bring this into u-boot-dm as it is a prerequisite for a series in my patchwork todo list.
Quoted 6 lines
That's fine, thanks.
--
Best regards,
Marek Vasut
Applied to u-boot-dm, thanks!