[PATCH 1/5 V2 RESEND] ARM: OMAP: USB: HOST TLL platform driver

2012-06-20 Thread Keshava Munegowda
The platform driver for the TLL component of the OMAP USB host controller
is implemented. Depending on the TLL hardware revision , the TLL channels
are configured. The USB HS core driver uses this driver through exported
APIs from the TLL platform driver.
usb_tll_enable and usb_tll_disble are the exported APIs of the USB TLL
platform driver.

Signed-off-by: Keshava Munegowda 
Reviewed-by: Partha Basak 
---
 arch/arm/plat-omap/include/plat/usb.h |6 +
 drivers/mfd/Kconfig   |2 +-
 drivers/mfd/Makefile  |2 +-
 drivers/mfd/omap-usb-tll.c|  471 +
 4 files changed, 479 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mfd/omap-usb-tll.c

diff --git a/arch/arm/plat-omap/include/plat/usb.h 
b/arch/arm/plat-omap/include/plat/usb.h
index 762eeb0..b8a9d5e 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -62,6 +62,10 @@ struct usbhs_omap_platform_data {
struct ehci_hcd_omap_platform_data  *ehci_data;
struct ohci_hcd_omap_platform_data  *ohci_data;
 };
+
+struct usbtll_omap_platform_data {
+   enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
+};
 /*-*/
 
 #define OMAP1_OTG_BASE 0xfffb0400
@@ -100,6 +104,8 @@ enum musb_interface{MUSB_INTERFACE_ULPI, 
MUSB_INTERFACE_UTMI};
 extern void usb_musb_init(struct omap_musb_board_data *board_data);
 
 extern void usbhs_init(const struct usbhs_omap_board_data *pdata);
+extern int omap_tll_enable(void);
+extern int omap_tll_disable(void);
 
 extern int omap4430_phy_power(struct device *dev, int ID, int on);
 extern int omap4430_phy_set_clk(struct device *dev, int on);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e129c82..74abd60 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -823,7 +823,7 @@ config MFD_WL1273_CORE
  audio codec.
 
 config MFD_OMAP_USB_HOST
-   bool "Support OMAP USBHS core driver"
+   bool "Support OMAP USBHS core and TLL driver"
depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
default y
help
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 75f6ed6..6de605d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -107,7 +107,7 @@ obj-$(CONFIG_MFD_TPS6586X)  += tps6586x.o
 obj-$(CONFIG_MFD_VX855)+= vx855.o
 obj-$(CONFIG_MFD_WL1273_CORE)  += wl1273-core.o
 obj-$(CONFIG_MFD_CS5535)   += cs5535-mfd.o
-obj-$(CONFIG_MFD_OMAP_USB_HOST)+= omap-usb-host.o
+obj-$(CONFIG_MFD_OMAP_USB_HOST)+= omap-usb-host.o omap-usb-tll.o
 obj-$(CONFIG_MFD_PM8921_CORE)  += pm8921-core.o
 obj-$(CONFIG_MFD_PM8XXX_IRQ)   += pm8xxx-irq.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
new file mode 100644
index 000..516059b
--- /dev/null
+++ b/drivers/mfd/omap-usb-tll.c
@@ -0,0 +1,471 @@
+/**
+ * omap-usb-tll.c - The USB TLL driver for OMAP EHCI & OHCI
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * Author: Keshava Munegowda 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * 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, see .
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define USBTLL_DRIVER_NAME "usbhs_tll"
+
+/* TLL Register Set */
+#defineOMAP_USBTLL_REVISION(0x00)
+#defineOMAP_USBTLL_SYSCONFIG   (0x10)
+#defineOMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
+#defineOMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
+#defineOMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
+#defineOMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
+#defineOMAP_USBTLL_SYSCONFIG_AUTOIDLE  (1 << 0)
+
+#defineOMAP_USBTLL_SYSSTATUS   (0x14)
+#defineOMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
+
+#defineOMAP_USBTLL_IRQSTATUS   (0x18)
+#defineOMAP_USBTLL_IRQENABLE   (0x1C)
+
+#defineOMAP_TLL_SHARED_CONF(0x30)
+#defineOMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
+#defineOMAP

[PATCH 1/5 V2 RESEND] ARM: OMAP: USB: HOST TLL platform driver

2012-06-26 Thread Keshava Munegowda
The platform driver for the TLL component of the OMAP USB host controller
is implemented. Depending on the TLL hardware revision , the TLL channels
are configured. The USB HS core driver uses this driver through exported
APIs from the TLL platform driver.
usb_tll_enable and usb_tll_disble are the exported APIs of the USB TLL
platform driver.

Signed-off-by: Keshava Munegowda 
Reviewed-by: Partha Basak 
---
 arch/arm/plat-omap/include/plat/usb.h |6 +
 drivers/mfd/Kconfig   |2 +-
 drivers/mfd/Makefile  |2 +-
 drivers/mfd/omap-usb-tll.c|  471 +
 4 files changed, 479 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mfd/omap-usb-tll.c

diff --git a/arch/arm/plat-omap/include/plat/usb.h 
b/arch/arm/plat-omap/include/plat/usb.h
index 762eeb0..b8a9d5e 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -62,6 +62,10 @@ struct usbhs_omap_platform_data {
struct ehci_hcd_omap_platform_data  *ehci_data;
struct ohci_hcd_omap_platform_data  *ohci_data;
 };
+
+struct usbtll_omap_platform_data {
+   enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
+};
 /*-*/
 
 #define OMAP1_OTG_BASE 0xfffb0400
@@ -100,6 +104,8 @@ enum musb_interface{MUSB_INTERFACE_ULPI, 
MUSB_INTERFACE_UTMI};
 extern void usb_musb_init(struct omap_musb_board_data *board_data);
 
 extern void usbhs_init(const struct usbhs_omap_board_data *pdata);
+extern int omap_tll_enable(void);
+extern int omap_tll_disable(void);
 
 extern int omap4430_phy_power(struct device *dev, int ID, int on);
 extern int omap4430_phy_set_clk(struct device *dev, int on);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e129c82..74abd60 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -823,7 +823,7 @@ config MFD_WL1273_CORE
  audio codec.
 
 config MFD_OMAP_USB_HOST
-   bool "Support OMAP USBHS core driver"
+   bool "Support OMAP USBHS core and TLL driver"
depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
default y
help
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 75f6ed6..6de605d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -107,7 +107,7 @@ obj-$(CONFIG_MFD_TPS6586X)  += tps6586x.o
 obj-$(CONFIG_MFD_VX855)+= vx855.o
 obj-$(CONFIG_MFD_WL1273_CORE)  += wl1273-core.o
 obj-$(CONFIG_MFD_CS5535)   += cs5535-mfd.o
-obj-$(CONFIG_MFD_OMAP_USB_HOST)+= omap-usb-host.o
+obj-$(CONFIG_MFD_OMAP_USB_HOST)+= omap-usb-host.o omap-usb-tll.o
 obj-$(CONFIG_MFD_PM8921_CORE)  += pm8921-core.o
 obj-$(CONFIG_MFD_PM8XXX_IRQ)   += pm8xxx-irq.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
new file mode 100644
index 000..516059b
--- /dev/null
+++ b/drivers/mfd/omap-usb-tll.c
@@ -0,0 +1,471 @@
+/**
+ * omap-usb-tll.c - The USB TLL driver for OMAP EHCI & OHCI
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * Author: Keshava Munegowda 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * 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, see .
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define USBTLL_DRIVER_NAME "usbhs_tll"
+
+/* TLL Register Set */
+#defineOMAP_USBTLL_REVISION(0x00)
+#defineOMAP_USBTLL_SYSCONFIG   (0x10)
+#defineOMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
+#defineOMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
+#defineOMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
+#defineOMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
+#defineOMAP_USBTLL_SYSCONFIG_AUTOIDLE  (1 << 0)
+
+#defineOMAP_USBTLL_SYSSTATUS   (0x14)
+#defineOMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
+
+#defineOMAP_USBTLL_IRQSTATUS   (0x18)
+#defineOMAP_USBTLL_IRQENABLE   (0x1C)
+
+#defineOMAP_TLL_SHARED_CONF(0x30)
+#defineOMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
+#defineOMAP