All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] drivers: usb: common: add common code for usb drivers to use
@ 2016-04-12 10:31 Mugunthan V N
  2016-04-13 11:19 ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Mugunthan V N @ 2016-04-12 10:31 UTC (permalink / raw)
  To: u-boot

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 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

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 */
-- 
2.8.1.101.g72d917a

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] drivers: usb: common: add common code for usb drivers to use
  2016-04-12 10:31 [U-Boot] [PATCH 1/1] drivers: usb: common: add common code for usb drivers to use Mugunthan V N
@ 2016-04-13 11:19 ` Simon Glass
  2016-04-13 11:47   ` Marek Vasut
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2016-04-13 11:19 UTC (permalink / raw)
  To: u-boot

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.
>
> [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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] drivers: usb: common: add common code for usb drivers to use
  2016-04-13 11:19 ` Simon Glass
@ 2016-04-13 11:47   ` Marek Vasut
  2016-05-07 19:03     ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2016-04-13 11:47 UTC (permalink / raw)
  To: u-boot

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.
>>
>> [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
> 
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] drivers: usb: common: add common code for usb drivers to use
  2016-04-13 11:47   ` Marek Vasut
@ 2016-05-07 19:03     ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2016-05-07 19:03 UTC (permalink / raw)
  To: u-boot

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.
>>>
>>> [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
>>
>> 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!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-07 19:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12 10:31 [U-Boot] [PATCH 1/1] drivers: usb: common: add common code for usb drivers to use Mugunthan V N
2016-04-13 11:19 ` Simon Glass
2016-04-13 11:47   ` Marek Vasut
2016-05-07 19:03     ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.