[U-Boot] [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.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com ---
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@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
diff --git a/Makefile b/Makefile index 6bb5565..664c8cc 100644 --- a/Makefile +++ b/Makefile @@ -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/ diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile new file mode 100644 index 0000000..9be2cdc --- /dev/null +++ b/drivers/usb/common/Makefile @@ -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 diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c new file mode 100644 index 0000000..ed9d993 --- /dev/null +++ b/drivers/usb/common/common.c @@ -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; +} diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 7ec5550..8f8ac6a 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -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 */

On 12 April 2016 at 04:31, Mugunthan V N mugunthanvnm@ti.com wrote:
Add common usb code which usb drivers makes use of it.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
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.
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
Reviewed-by: Simon Glass sjg@chromium.org
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

On 04/13/2016 01:19 PM, Simon Glass wrote:
On 12 April 2016 at 04:31, Mugunthan V N mugunthanvnm@ti.com wrote:
Add common usb code which usb drivers makes use of it.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
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.
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
Reviewed-by: Simon Glass sjg@chromium.org
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.

On 13 April 2016 at 05:47, Marek Vasut marex@denx.de wrote:
On 04/13/2016 01:19 PM, Simon Glass wrote:
On 12 April 2016 at 04:31, Mugunthan V N mugunthanvnm@ti.com wrote:
Add common usb code which usb drivers makes use of it.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
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.
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
Reviewed-by: Simon Glass sjg@chromium.org
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.
-- Best regards, Marek Vasut
Applied to u-boot-dm, thanks!
participants (3)
-
Marek Vasut
-
Mugunthan V N
-
Simon Glass