summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2012-03-24 18:00:36 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2012-04-02 09:32:53 +0200
commit2079f13611ba75d9eb88fcaa6d63a91087f99b73 (patch)
tree66fcbba2be5f9e2e89614e0f260c33e07fdb3914 /drivers
parent9c01d10dab293fc93257a823332ecc1270ceeba3 (diff)
downloadbarebox-2079f13611ba75d9eb88fcaa6d63a91087f99b73.tar.gz
barebox-2079f13611ba75d9eb88fcaa6d63a91087f99b73.tar.xz
Add ULPI detection function.
Added ULPI detection function. Same function from isp1504 driver removed. Used implementation from Linux kernel. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/otg/isp1504.c12
-rw-r--r--drivers/usb/otg/ulpi.c45
2 files changed, 47 insertions, 10 deletions
diff --git a/drivers/usb/otg/isp1504.c b/drivers/usb/otg/isp1504.c
index 9884df463b..c093a3a451 100644
--- a/drivers/usb/otg/isp1504.c
+++ b/drivers/usb/otg/isp1504.c
@@ -4,18 +4,10 @@
int isp1504_set_vbus_power(void __iomem *view, int on)
{
- int vid, pid, ret = 0;
+ int ret = 0;
- vid = (ulpi_read(ULPI_VID_HIGH, view) << 8) |
- ulpi_read(ULPI_VID_LOW, view);
- pid = (ulpi_read(ULPI_PID_HIGH, view) << 8) |
- ulpi_read(ULPI_PID_LOW, view);
-
- pr_info("ULPI Vendor ID 0x%x Product ID 0x%x\n", vid, pid);
- if (vid != 0x4cc || pid != 0x1504) {
- pr_err("No ISP1504 found\n");
+ if (ulpi_init(view))
return -1;
- }
if (on) {
ret = ulpi_set(DRV_VBUS_EXT | /* enable external Vbus */
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index 575ed94b06..ad13b4b26e 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -116,3 +116,48 @@ int ulpi_clear(u8 bits, int reg, void __iomem *view)
}
EXPORT_SYMBOL(ulpi_clear);
+struct ulpi_info {
+ uint32_t id;
+ char *name;
+};
+
+#define ULPI_ID(vendor, product) (((vendor) << 16) | (product))
+#define ULPI_INFO(_id, _name) \
+ { \
+ .id = (_id), \
+ .name = (_name), \
+ }
+
+/* ULPI hardcoded IDs, used for probing */
+static struct ulpi_info ulpi_ids[] = {
+ ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"),
+ ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"),
+};
+
+int ulpi_init(void __iomem *view)
+{
+ int i, vid, pid, ret;
+ uint32_t ulpi_id = 0;
+
+ for (i = 0; i < 4; i++) {
+ ret = ulpi_read(ULPI_PID_HIGH - i, view);
+ if (ret < 0)
+ return ret;
+ ulpi_id = (ulpi_id << 8) | ret;
+ }
+ vid = ulpi_id & 0xffff;
+ pid = ulpi_id >> 16;
+
+ for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) {
+ if (ulpi_ids[i].id == ULPI_ID(vid, pid)) {
+ pr_info("Found %s ULPI transceiver (0x%04x:0x%04x).\n",
+ ulpi_ids[i].name, vid, pid);
+ return 0;
+ }
+ }
+
+ pr_err("No ULPI found.\n");
+
+ return -1;
+}
+EXPORT_SYMBOL(ulpi_init);