[PATCH 06/11] ARM: OMAP: USB: Host: USB TLL Device tree node Adaptation

2012-10-31 Thread Keshava Munegowda
The USB TLL device node is extracted and used in the probe
of the driver to initialize the driver data.
This TLL driver exports an API to usbhs driver to perform
the port configuration. The usb2 hs driver invoke the same
API in its driver probe to initialize the ports.

Signed-off-by: Keshava Munegowda keshava_mgo...@ti.com
---
 drivers/mfd/omap-usb-host.c|7 ++
 drivers/mfd/omap-usb-tll.c |  192 +++-
 include/linux/platform_data/usb-omap.h |2 +
 3 files changed, 124 insertions(+), 77 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 4b3af16..27aa85e 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -657,6 +657,11 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
platform_set_drvdata(pdev, omap);
dev-platform_data = pdata;
 
+   if (omap_tll_init(pdata-port_mode)) {
+   dev_err(dev, omap_tll_init failed\n);
+   goto err_tll;
+   }
+
omap_usbhs_init(dev);
ret = omap_usbhs_alloc_children(pdev);
if (ret) {
@@ -668,6 +673,8 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
 err_alloc:
omap_usbhs_deinit(pdev-dev);
+
+err_tll:
iounmap(omap-uhh_base);
 
 err_init_60m_fclk:
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 0db0dfa..f457883 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -24,6 +24,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/io.h
+#include linux/of.h
 #include linux/err.h
 #include linux/pm_runtime.h
 #include linux/platform_data/usb-omap.h
@@ -98,7 +99,9 @@
 struct usbtll_omap {
struct clk  *usbtll_p1_fck;
struct clk  *usbtll_p2_fck;
-   struct usbtll_omap_platform_dataplatdata;
+   void __iomem*base;
+   enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
+
/* secure the register updates */
spinlock_t  lock;
 };
@@ -196,17 +199,15 @@ static unsigned ohci_omap3_fslsmode(enum 
usbhs_omap_port_mode mode)
 }
 
 /**
- * usbtll_omap_probe - initialize TI-based HCDs
+ * usbtll_omap_initports - initialize TI-based HCDs
  *
- * Allocates basic resources for this USB host controller.
+ * initialize the usb tll ports. Maximum 3 ports
  */
-static int __devinit usbtll_omap_probe(struct platform_device *pdev)
+
+static int usbtll_initports(struct device *dev,
+   enum usbhs_omap_port_mode port_mode[])
 {
-   struct device   *dev =  pdev-dev;
-   struct usbtll_omap_platform_data*pdata = dev-platform_data;
-   void __iomem*base;
-   struct resource *res;
-   struct usbtll_omap  *tll;
+   struct usbtll_omap  *tll = dev_get_drvdata(dev);
unsignedreg;
unsigned long   flags;
int ret = 0;
@@ -214,53 +215,19 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
dev_dbg(dev, starting TI HSUSB TLL Controller\n);
 
-   tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL);
if (!tll) {
-   dev_err(dev, Memory allocation failed\n);
-   ret = -ENOMEM;
-   goto end;
+   dev_err(dev, %s: missing TLL Driver data\n, __func__);
+   return -ENOMEM;
}
 
-   spin_lock_init(tll-lock);
-
for (i = 0; i  OMAP3_HS_USB_PORTS; i++)
-   tll-platdata.port_mode[i] = pdata-port_mode[i];
+   tll-port_mode[i] = port_mode[i];
 
-   tll-usbtll_p1_fck = clk_get(dev, usb_tll_hs_usb_ch0_clk);
-   if (IS_ERR(tll-usbtll_p1_fck)) {
-   ret = PTR_ERR(tll-usbtll_p1_fck);
-   dev_err(dev, usbtll_p1_fck failed error:%d\n, ret);
-   goto err_tll;
-   }
-
-   tll-usbtll_p2_fck = clk_get(dev, usb_tll_hs_usb_ch1_clk);
-   if (IS_ERR(tll-usbtll_p2_fck)) {
-   ret = PTR_ERR(tll-usbtll_p2_fck);
-   dev_err(dev, usbtll_p2_fck failed error:%d\n, ret);
-   goto err_usbtll_p1_fck;
-   }
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(dev, usb tll get resource failed\n);
-   ret = -ENODEV;
-   goto err_usbtll_p2_fck;
-   }
-
-   base = ioremap(res-start, resource_size(res));
-   if (!base) {
-   dev_err(dev, TLL ioremap failed\n);
-   ret = -ENOMEM;
-   goto err_usbtll_p2_fck;
-   }
-
-   platform_set_drvdata(pdev, tll);
-   pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
 
   

[RESEND PATCH 06/11] ARM: OMAP: USB: Host: USB TLL Device tree node Adaptation

2012-10-31 Thread Keshava Munegowda
The USB TLL device node is extracted and used in the probe
of the driver to initialize the driver data.
This TLL driver exports an API to usbhs driver to perform
the port configuration. The usb2 hs driver invoke the same
API in its driver probe to initialize the ports.

Signed-off-by: Keshava Munegowda keshava_mgo...@ti.com
---
 drivers/mfd/omap-usb-host.c|7 ++
 drivers/mfd/omap-usb-tll.c |  192 +++-
 include/linux/platform_data/usb-omap.h |2 +
 3 files changed, 124 insertions(+), 77 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 4b3af16..27aa85e 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -657,6 +657,11 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
platform_set_drvdata(pdev, omap);
dev-platform_data = pdata;
 
+   if (omap_tll_init(pdata-port_mode)) {
+   dev_err(dev, omap_tll_init failed\n);
+   goto err_tll;
+   }
+
omap_usbhs_init(dev);
ret = omap_usbhs_alloc_children(pdev);
if (ret) {
@@ -668,6 +673,8 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
 err_alloc:
omap_usbhs_deinit(pdev-dev);
+
+err_tll:
iounmap(omap-uhh_base);
 
 err_init_60m_fclk:
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 0db0dfa..f457883 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -24,6 +24,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/io.h
+#include linux/of.h
 #include linux/err.h
 #include linux/pm_runtime.h
 #include linux/platform_data/usb-omap.h
@@ -98,7 +99,9 @@
 struct usbtll_omap {
struct clk  *usbtll_p1_fck;
struct clk  *usbtll_p2_fck;
-   struct usbtll_omap_platform_dataplatdata;
+   void __iomem*base;
+   enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
+
/* secure the register updates */
spinlock_t  lock;
 };
@@ -196,17 +199,15 @@ static unsigned ohci_omap3_fslsmode(enum 
usbhs_omap_port_mode mode)
 }
 
 /**
- * usbtll_omap_probe - initialize TI-based HCDs
+ * usbtll_omap_initports - initialize TI-based HCDs
  *
- * Allocates basic resources for this USB host controller.
+ * initialize the usb tll ports. Maximum 3 ports
  */
-static int __devinit usbtll_omap_probe(struct platform_device *pdev)
+
+static int usbtll_initports(struct device *dev,
+   enum usbhs_omap_port_mode port_mode[])
 {
-   struct device   *dev =  pdev-dev;
-   struct usbtll_omap_platform_data*pdata = dev-platform_data;
-   void __iomem*base;
-   struct resource *res;
-   struct usbtll_omap  *tll;
+   struct usbtll_omap  *tll = dev_get_drvdata(dev);
unsignedreg;
unsigned long   flags;
int ret = 0;
@@ -214,53 +215,19 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
dev_dbg(dev, starting TI HSUSB TLL Controller\n);
 
-   tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL);
if (!tll) {
-   dev_err(dev, Memory allocation failed\n);
-   ret = -ENOMEM;
-   goto end;
+   dev_err(dev, %s: missing TLL Driver data\n, __func__);
+   return -ENOMEM;
}
 
-   spin_lock_init(tll-lock);
-
for (i = 0; i  OMAP3_HS_USB_PORTS; i++)
-   tll-platdata.port_mode[i] = pdata-port_mode[i];
+   tll-port_mode[i] = port_mode[i];
 
-   tll-usbtll_p1_fck = clk_get(dev, usb_tll_hs_usb_ch0_clk);
-   if (IS_ERR(tll-usbtll_p1_fck)) {
-   ret = PTR_ERR(tll-usbtll_p1_fck);
-   dev_err(dev, usbtll_p1_fck failed error:%d\n, ret);
-   goto err_tll;
-   }
-
-   tll-usbtll_p2_fck = clk_get(dev, usb_tll_hs_usb_ch1_clk);
-   if (IS_ERR(tll-usbtll_p2_fck)) {
-   ret = PTR_ERR(tll-usbtll_p2_fck);
-   dev_err(dev, usbtll_p2_fck failed error:%d\n, ret);
-   goto err_usbtll_p1_fck;
-   }
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(dev, usb tll get resource failed\n);
-   ret = -ENODEV;
-   goto err_usbtll_p2_fck;
-   }
-
-   base = ioremap(res-start, resource_size(res));
-   if (!base) {
-   dev_err(dev, TLL ioremap failed\n);
-   ret = -ENOMEM;
-   goto err_usbtll_p2_fck;
-   }
-
-   platform_set_drvdata(pdev, tll);
-   pm_runtime_enable(dev);
pm_runtime_get_sync(dev);