diff options
author | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2013-06-13 10:59:55 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-17 16:47:09 -0400 |
commit | 1c9af65357a309b60d78a442bd61d27cad458d00 (patch) | |
tree | 5768aa043e4597b4691fcebe8bc7706487379ce8 /drivers/usb/phy/of.c | |
parent | 2e270412968d961ecde347343ffa67dfe39f6c95 (diff) |
usb: add devicetree helpers for determining dr_mode and phy_type
This adds two little devicetree helper functions for determining the
dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from
the devicetree.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/phy/of.c')
-rw-r--r-- | drivers/usb/phy/of.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c new file mode 100644 index 000000000000..7ea0154da9d5 --- /dev/null +++ b/drivers/usb/phy/of.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * USB of helper code | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | */ | ||
9 | |||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/of.h> | ||
13 | #include <linux/usb/of.h> | ||
14 | #include <linux/usb/otg.h> | ||
15 | |||
16 | static const char *const usbphy_modes[] = { | ||
17 | [USBPHY_INTERFACE_MODE_UNKNOWN] = "", | ||
18 | [USBPHY_INTERFACE_MODE_UTMI] = "utmi", | ||
19 | [USBPHY_INTERFACE_MODE_UTMIW] = "utmi_wide", | ||
20 | [USBPHY_INTERFACE_MODE_ULPI] = "ulpi", | ||
21 | [USBPHY_INTERFACE_MODE_SERIAL] = "serial", | ||
22 | [USBPHY_INTERFACE_MODE_HSIC] = "hsic", | ||
23 | }; | ||
24 | |||
25 | /** | ||
26 | * of_usb_get_phy_mode - Get phy mode for given device_node | ||
27 | * @np: Pointer to the given device_node | ||
28 | * | ||
29 | * The function gets phy interface string from property 'phy_type', | ||
30 | * and returns the correspondig enum usb_phy_interface | ||
31 | */ | ||
32 | enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) | ||
33 | { | ||
34 | const char *phy_type; | ||
35 | int err, i; | ||
36 | |||
37 | err = of_property_read_string(np, "phy_type", &phy_type); | ||
38 | if (err < 0) | ||
39 | return USBPHY_INTERFACE_MODE_UNKNOWN; | ||
40 | |||
41 | for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++) | ||
42 | if (!strcmp(phy_type, usbphy_modes[i])) | ||
43 | return i; | ||
44 | |||
45 | return USBPHY_INTERFACE_MODE_UNKNOWN; | ||
46 | } | ||
47 | EXPORT_SYMBOL_GPL(of_usb_get_phy_mode); | ||