All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vignesh R <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/11] drivers: usb: common: add support to get maximum speed from dt
Date: Tue, 23 May 2017 17:25:41 +0530	[thread overview]
Message-ID: <20170523115546.399-7-vigneshr@ti.com> (raw)
In-Reply-To: <20170523115546.399-1-vigneshr@ti.com>

From: Mugunthan V N <mugunthanvnm@ti.com>

Add support to get maximum speed from dt so that usb drivers
makes use of it for DT parsing.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/usb/common/common.c | 29 +++++++++++++++++++++++++++++
 include/linux/usb/otg.h     |  9 +++++++++
 scripts/Makefile.spl        |  1 +
 3 files changed, 39 insertions(+)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 35c2dc18d955..c11689dc36fa 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <libfdt.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/ch9.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -38,3 +39,31 @@ enum usb_dr_mode usb_get_dr_mode(int node)
 
 	return USB_DR_MODE_UNKNOWN;
 }
+
+static const char *const speed_names[] = {
+	[USB_SPEED_UNKNOWN] = "UNKNOWN",
+	[USB_SPEED_LOW] = "low-speed",
+	[USB_SPEED_FULL] = "full-speed",
+	[USB_SPEED_HIGH] = "high-speed",
+	[USB_SPEED_WIRELESS] = "wireless",
+	[USB_SPEED_SUPER] = "super-speed",
+};
+
+enum usb_device_speed usb_get_maximum_speed(int node)
+{
+	const void *fdt = gd->fdt_blob;
+	const char *max_speed;
+	int i;
+
+	max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
+	if (!max_speed) {
+		error("usb dr_mode not found\n");
+		return USB_DR_MODE_UNKNOWN;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(speed_names); i++)
+		if (!strcmp(max_speed, speed_names[i]))
+			return i;
+
+	return USB_SPEED_UNKNOWN;
+}
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 8f8ac6aeefe3..b61ef19b22f3 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -26,4 +26,13 @@ enum usb_dr_mode {
  */
 enum usb_dr_mode usb_get_dr_mode(int node);
 
+/**
+ * usb_get_maximum_speed() - Get maximum speed for given device
+ * @node: Node offset to the given device
+ *
+ * The function gets phy interface string from property 'maximum-speed',
+ * and returns the correspondig enum usb_device_speed
+ */
+enum usb_device_speed usb_get_maximum_speed(int node);
+
 #endif /* __LINUX_USB_OTG_H */
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 135706f21de1..bba84c92f0f0 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -78,6 +78,7 @@ endif
 
 libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
 libs-y += drivers/
+libs-y += drivers/usb/common/
 libs-$(CONFIG_SPL_USB_GADGET_SUPPORT) += drivers/usb/dwc3/
 libs-y += dts/
 libs-y += fs/
-- 
2.13.0

  parent reply	other threads:[~2017-05-23 11:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23 11:55 [U-Boot] [PATCH 00/11] driver model bring-up of dwc3 usb peripheral Vignesh R
2017-05-23 11:55 ` [U-Boot] [PATCH 01/11] drivers: usb: dwc3: remove devm_zalloc from linux_compact Vignesh R
2017-05-31  3:50   ` Simon Glass
2017-05-23 11:55 ` [U-Boot] [PATCH 02/11] drivers: usb: dwc3-omap: move usb_gadget_handle_interrupts from board files to drivers Vignesh R
2017-05-31  3:50   ` Simon Glass
2017-05-23 11:55 ` [U-Boot] [PATCH 03/11] am437x: board: do not register usb devices when CONFIG_DM_USB is defined Vignesh R
2017-05-31  3:50   ` Simon Glass
2017-05-23 11:55 ` [U-Boot] [PATCH 04/11] omap5/am57xx/dra7xx: " Vignesh R
2017-05-31  3:50   ` Simon Glass
2017-05-23 11:55 ` [U-Boot] [PATCH 05/11] drivers: usb: dwc3: add ti dwc3 misc driver for wrapper Vignesh R
2017-05-31  3:50   ` Simon Glass
2017-05-31  5:06     ` Vignesh R
2017-05-31  5:06     ` Vignesh R
2017-05-23 11:55 ` Vignesh R [this message]
2017-05-31  3:50   ` [U-Boot] [PATCH 06/11] drivers: usb: common: add support to get maximum speed from dt Simon Glass
2017-05-23 11:55 ` [U-Boot] [PATCH 07/11] drivers: usb: dwc3: add ti dwc3 peripheral driver with driver model support Vignesh R
2017-05-23 11:55 ` [U-Boot] [PATCH 08/11] dwc3: Add support for USB device boot Vignesh R
2017-05-31  3:50   ` Simon Glass
2017-05-31  6:03     ` Vignesh R
2017-05-23 11:55 ` [U-Boot] [PATCH 09/11] am43xx: Add USB device boot support Vignesh R
2017-05-23 11:55 ` [U-Boot] [PATCH 10/11] configs: am43xx: Enable configs to support USB device boot Vignesh R
2017-05-23 11:55 ` [U-Boot] [PATCH 11/11] ARM: am437x-gp-evm-u-boot.dtsi: Enable nodes for " Vignesh R
2017-05-24  4:25   ` Lokesh Vutla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170523115546.399-7-vigneshr@ti.com \
    --to=vigneshr@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.