[PATCH 7/8] USB: Add xcvr functions for NXP's ISP1504 transceiver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds support for NXP's ISP1504 transceivers using the xcvr
abstraction framework.

Signed-off-by: Daniel Mack <daniel@xxxxxxxx>
---
 drivers/usb/Makefile             |    2 +
 drivers/usb/otg/Kconfig          |    6 ++
 drivers/usb/otg/Makefile         |    1 +
 drivers/usb/otg/isp1504-xcvr.c   |   97 ++++++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1504_xcvr.h |    6 ++
 5 files changed, 112 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/otg/isp1504-xcvr.c
 create mode 100644 include/linux/usb/isp1504_xcvr.h

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 0a3dc5e..f0f1ae7 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -41,3 +41,5 @@ obj-$(CONFIG_USB)		+= misc/
 
 obj-$(CONFIG_USB_ATM)		+= atm/
 obj-$(CONFIG_USB_SPEEDTOUCH)	+= atm/
+
+obj-$(CONFIG_ISP1504_XCVR)	+= otg/
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index aa884d0..dc86620 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -59,4 +59,10 @@ config NOP_USB_XCEIV
 	 built-in with usb ip or which are autonomous and doesn't require any
 	 phy programming such as ISP1x04 etc.
 
+config ISP1504_XCVR
+	tristate "NXP ISP1504 Transceiver Driver"
+	help
+	  Enable this to support the NXP ISP1504 USB OTG transceiver which
+	  are likely found on embedded boards.
+
 endif # USB || OTG
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index 2081678..d573904 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_USB_GPIO_VBUS)	+= gpio_vbus.o
 obj-$(CONFIG_ISP1301_OMAP)	+= isp1301_omap.o
 obj-$(CONFIG_TWL4030_USB)	+= twl4030-usb.o
 obj-$(CONFIG_NOP_USB_XCEIV)	+= nop-usb-xceiv.o
+obj-$(CONFIG_ISP1504_XCVR)	+= isp1504-xcvr.o
 
 ccflags-$(CONFIG_USB_DEBUG)	+= -DDEBUG
 ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
diff --git a/drivers/usb/otg/isp1504-xcvr.c b/drivers/usb/otg/isp1504-xcvr.c
new file mode 100644
index 0000000..087985b
--- /dev/null
+++ b/drivers/usb/otg/isp1504-xcvr.c
@@ -0,0 +1,97 @@
+/*
+ * isp1504 - NXP ISP 1504 USB transceiver
+ *
+ * Copyright (C) 2009 Daniel Mack <daniel@xxxxxxxx>
+ *
+ * Based on sources from
+ *
+ *   Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
+ *   Freescale Semiconductors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/usb.h>
+#include <linux/usb/xcvr.h>
+
+
+/* ISP 1504 register addresses */
+#define ISP1504_VID_LOW         0x00    /* Vendor ID low */
+#define ISP1504_VID_HIGH        0x01    /* Vendor ID high */
+#define ISP1504_PID_LOW         0x02    /* Product ID low */
+#define ISP1504_PID_HIGH        0x03    /* Product ID high */
+#define ISP1504_ITFCTL          0x07    /* Interface Control */
+#define ISP1504_OTGCTL          0x0A    /* OTG Control */
+
+/* add to above register address to access Set/Clear functions */
+#define ISP1504_REG_SET         0x01
+#define ISP1504_REG_CLEAR       0x02
+
+/* 1504 OTG Control Register bits */
+#define USE_EXT_VBUS_IND        (1 << 7)        /* Use ext. Vbus indicator */
+#define DRV_VBUS_EXT            (1 << 6)        /* Drive Vbus external */
+#define DRV_VBUS                (1 << 5)        /* Drive Vbus */
+#define CHRG_VBUS               (1 << 4)        /* Charge Vbus */
+#define DISCHRG_VBUS            (1 << 3)        /* Discharge Vbus */
+#define DM_PULL_DOWN            (1 << 2)        /* enable DM Pull Down */
+#define DP_PULL_DOWN            (1 << 1)        /* enable DP Pull Down */
+#define ID_PULL_UP              (1 << 0)        /* enable ID Pull Up */
+
+/* 1504 hardcoded IDs, used for probing */
+#define ISP1504_ULPI_VID 0x04cc
+#define ISP1504_ULPI_PID 0x1504
+
+static int isp1504_init(struct usb_xcvr *xcvr)
+{
+	int vid, pid;
+
+	vid = (usb_xcvr_read(xcvr, ISP1504_VID_HIGH) << 8) |
+	       usb_xcvr_read(xcvr, ISP1504_VID_LOW);
+	pid = (usb_xcvr_read(xcvr, ISP1504_PID_HIGH) << 8) |
+	       usb_xcvr_read(xcvr, ISP1504_PID_LOW);
+
+	pr_info("ULPI transceiver vendor/product ID 0x%x/0x%x\n", vid, pid);
+	if (vid != ISP1504_ULPI_VID || pid != ISP1504_ULPI_PID) {
+		pr_err("No ISP1504 found\n");
+		return -ENODEV;
+       }
+
+       return 0;
+}
+
+static int isp1504_set_vbus(struct usb_xcvr *xcvr, bool on)
+{
+	if (on)
+		return usb_xcvr_write(xcvr, DRV_VBUS_EXT | DRV_VBUS |
+					 USE_EXT_VBUS_IND | CHRG_VBUS,
+					 ISP1504_OTGCTL + ISP1504_REG_SET);
+       else {
+		int ret = usb_xcvr_write(xcvr, DRV_VBUS_EXT | DRV_VBUS,
+					ISP1504_OTGCTL + ISP1504_REG_CLEAR);
+		if (ret)
+			return ret;
+
+		return usb_xcvr_write(xcvr, USE_EXT_VBUS_IND | DISCHRG_VBUS,
+					ISP1504_OTGCTL + ISP1504_REG_SET);
+       }
+}
+
+struct usb_xcvr_driver isp1504_xcvr_driver = {
+	.init		= isp1504_init,
+	.set_vbus	= isp1504_set_vbus,
+};
+EXPORT_SYMBOL_GPL(isp1504_xcvr_driver);
+
diff --git a/include/linux/usb/isp1504_xcvr.h b/include/linux/usb/isp1504_xcvr.h
new file mode 100644
index 0000000..5a53958
--- /dev/null
+++ b/include/linux/usb/isp1504_xcvr.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_USB_ISP1504_XCVR_H
+#define __LINUX_USB_ISP1504_XCVR_H
+
+extern struct usb_xcvr_driver isp1504_xcvr_driver;
+
+#endif /* __LINUX_USB_ISP1504_XCVR_H */
-- 
1.6.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux