Re: [PATCH 2/4] USB OTG: Add driver for NXP's ISP1504 transceiver

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

 



On Fri, Aug 14, 2009 at 07:58:23AM +0200, Daniel Mack wrote:
> diff --git a/include/linux/usb/isp1504.h b/include/linux/usb/isp1504.h
> new file mode 100644
> index 0000000..2c14a18
> --- /dev/null
> +++ b/include/linux/usb/isp1504.h
> @@ -0,0 +1,6 @@
> +#ifndef __LINUX_USB_ISP1504_XCVR_H
> +#define __LINUX_USB_ISP1504_XCVR_H
> +
> +extern struct otg_transceiver *otg_isp1504_create(struct otg_io_access_ops *ops);
> +
> +#endif /* __LINUX_USB_ISP1504_XCVR_H */

Ah, sorry - as Valentin pointed out, that 'extern' shouldn't be there.
Take the patch below instead please.

Daniel


>From 382c09a6fbce8272d71fa7f62d13fc7f4b1a5b35 Mon Sep 17 00:00:00 2001
From: Daniel Mack <daniel@xxxxxxxx>
Date: Thu, 25 Jun 2009 13:33:48 +0200
Subject: [PATCH] USB OTG: Add driver for NXP's ISP1504 transceiver

This adds a minimal driver for NXP's ISP1504 transceivers, using the OTG
framework functions recently introduced.

Signed-off-by: Daniel Mack <daniel@xxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxx>
Cc: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx>
Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
Cc: linux-usb@xxxxxxxxxxxxxxx
---
 drivers/usb/Makefile        |    2 +
 drivers/usb/otg/Kconfig     |    6 ++
 drivers/usb/otg/Makefile    |    1 +
 drivers/usb/otg/isp1504.c   |  108 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1504.h |    6 ++
 5 files changed, 123 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/otg/isp1504.c
 create mode 100644 include/linux/usb/isp1504.h

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 19cb7d5..3ecf7e6 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -42,3 +42,5 @@ obj-$(CONFIG_USB)		+= misc/
 
 obj-$(CONFIG_USB_ATM)		+= atm/
 obj-$(CONFIG_USB_SPEEDTOUCH)	+= atm/
+
+obj-$(CONFIG_USB_ISP1504)	+= otg/
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index aa884d0..c393aba 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -41,6 +41,12 @@ config ISP1301_OMAP
 	  This driver can also be built as a module.  If so, the module
 	  will be called isp1301_omap.
 
+config USB_ISP1504
+	bool "NXP ISP1504 Transceiver Driver"
+	help
+	  Enable this to support the NXP ISP1504 USB OTG transceiver which
+	  are likely found on embedded boards.
+
 config TWL4030_USB
 	tristate "TWL4030 USB Transceiver Driver"
 	depends on TWL4030_CORE && REGULATOR_TWL4030
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index 2081678..718b896 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_USB_ISP1504)	+= isp1504.o
 
 ccflags-$(CONFIG_USB_DEBUG)	+= -DDEBUG
 ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
diff --git a/drivers/usb/otg/isp1504.c b/drivers/usb/otg/isp1504.c
new file mode 100644
index 0000000..8a449db
--- /dev/null
+++ b/drivers/usb/otg/isp1504.c
@@ -0,0 +1,108 @@
+/*
+ * 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/otg.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 otg_transceiver *otg)
+{
+	int vid, pid;
+
+	vid = (otg_io_read(otg, ISP1504_VID_HIGH) << 8) |
+	       otg_io_read(otg, ISP1504_VID_LOW);
+	pid = (otg_io_read(otg, ISP1504_PID_HIGH) << 8) |
+	       otg_io_read(otg, 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 otg_transceiver *otg, bool on)
+{
+	if (on)
+		return otg_io_write(otg, DRV_VBUS_EXT | DRV_VBUS |
+					 USE_EXT_VBUS_IND | CHRG_VBUS,
+					 ISP1504_OTGCTL + ISP1504_REG_SET);
+	else {
+		int ret = otg_io_write(otg, DRV_VBUS_EXT | DRV_VBUS,
+					    ISP1504_OTGCTL + ISP1504_REG_CLEAR);
+		if (ret)
+			return ret;
+
+		return otg_io_write(otg, USE_EXT_VBUS_IND | DISCHRG_VBUS,
+					 ISP1504_OTGCTL + ISP1504_REG_SET);
+	}
+}
+
+struct otg_transceiver *
+otg_isp1504_create(struct otg_io_access_ops *ops)
+{
+	struct otg_transceiver *otg;
+
+	otg = kzalloc(sizeof(*otg), GFP_KERNEL);
+	if (!otg)
+		return NULL;
+
+	otg->label	= "ISP1504";
+	otg->io_ops	= ops;
+	otg->init	= isp1504_init;
+	otg->set_vbus	= isp1504_set_vbus;
+
+	return otg;
+}
+EXPORT_SYMBOL_GPL(otg_isp1504_create);
diff --git a/include/linux/usb/isp1504.h b/include/linux/usb/isp1504.h
new file mode 100644
index 0000000..5bbd55c
--- /dev/null
+++ b/include/linux/usb/isp1504.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_USB_ISP1504_XCVR_H
+#define __LINUX_USB_ISP1504_XCVR_H
+
+struct otg_transceiver *otg_isp1504_create(struct otg_io_access_ops *ops);
+
+#endif /* __LINUX_USB_ISP1504_XCVR_H */
-- 
1.6.3.3

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