[RFC][PATCH 1/7] USB: OHCI: make ohci-exynos a separate driver

2013-06-07 Thread Manjunath Goudar
Separate the  Samsung OHCI EXYNOS host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM.

Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
Cc: Arnd Bergmann a...@arndb.de
Cc: Jingoo Han jg1@samsung.com
Cc: Kukjin Kim kgene@samsung.com
Cc: Greg KH g...@kroah.com
Cc: Alan Stern st...@rowland.harvard.edu
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/host/Kconfig   |2 +-
 drivers/usb/host/Makefile  |1 +
 drivers/usb/host/ohci-exynos.c |  154 +---
 drivers/usb/host/ohci-hcd.c|   20 +-
 4 files changed, 70 insertions(+), 107 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 5391a38..f827386 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -484,7 +484,7 @@ config USB_OHCI_SH
  If you use the PCI OHCI controller, this option is not necessary.
 
 config USB_OHCI_EXYNOS
-   boolean OHCI support for Samsung EXYNOS SoC Series
+   tristate OHCI support for Samsung EXYNOS SoC Series
depends on ARCH_EXYNOS
help
 Enable support for the Samsung Exynos SOC's on-chip OHCI controller.
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 8a89c3d..2a4f11f 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o
 obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
 obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o
 obj-$(CONFIG_USB_OHCI_HCD_PLATFORM)+= ohci-platform.o
+obj-$(CONFIG_USB_OHCI_EXYNOS)  += ohci-exynos.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 07592c0..a5f4c33 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -12,24 +12,38 @@
  */
 
 #include linux/clk.h
+#include linux/dma-mapping.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
 #include linux/of.h
 #include linux/platform_device.h
 #include linux/platform_data/usb-ohci-exynos.h
 #include linux/usb/phy.h
 #include linux/usb/samsung_usb_phy.h
+#include linux/usb.h
+#include linux/usb/hcd.h
+#include linux/usb/otg.h
+
+#include ohci.h
+
+#define DRIVER_DESC OHCI exynos driver
+
+static const char hcd_name[] = ohci-exynos;
+static struct hc_driver __read_mostly exynos_ohci_hc_driver;
+
+#define to_exynos_ohci(hcd) (struct exynos_ohci_hcd *)(hcd_to_ohci(hcd)-priv)
 
 struct exynos_ohci_hcd {
-   struct device *dev;
-   struct usb_hcd *hcd;
struct clk *clk;
struct usb_phy *phy;
struct usb_otg *otg;
struct exynos4_ohci_platdata *pdata;
 };
 
-static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
+static void exynos_ohci_phy_enable(struct platform_device *pdev)
 {
-   struct platform_device *pdev = to_platform_device(exynos_ohci-dev);
+   struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
 
if (exynos_ohci-phy)
usb_phy_init(exynos_ohci-phy);
@@ -37,9 +51,9 @@ static void exynos_ohci_phy_enable(struct exynos_ohci_hcd 
*exynos_ohci)
exynos_ohci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST);
 }
 
-static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
+static void exynos_ohci_phy_disable(struct platform_device *pdev)
 {
-   struct platform_device *pdev = to_platform_device(exynos_ohci-dev);
+   struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
 
if (exynos_ohci-phy)
usb_phy_shutdown(exynos_ohci-phy);
@@ -47,57 +61,6 @@ static void exynos_ohci_phy_disable(struct exynos_ohci_hcd 
*exynos_ohci)
exynos_ohci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST);
 }
 
-static int ohci_exynos_reset(struct usb_hcd *hcd)
-{
-   return ohci_init(hcd_to_ohci(hcd));
-}
-
-static int ohci_exynos_start(struct usb_hcd *hcd)
-{
-   struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-   int ret;
-
-   ohci_dbg(ohci, ohci_exynos_start, ohci:%p, ohci);
-
-   ret = ohci_run(ohci);
-   if (ret  0) {
-   dev_err(hcd-self.controller, can't start %s\n,
-   hcd-self.bus_name);
-   ohci_stop(hcd);
-   return ret;
-   }
-
-   return 0;
-}
-
-static const struct hc_driver exynos_ohci_hc_driver = {
-   .description= hcd_name,
-   .product_desc   = EXYNOS OHCI Host Controller,
-   .hcd_priv_size  = sizeof(struct ohci_hcd),
-
-   .irq= ohci_irq,
-   .flags  = HCD_MEMORY|HCD_USB11,
-
-   .reset  = ohci_exynos_reset,
-   .start  = ohci_exynos_start,
-   .stop   = ohci_stop,
-   .shutdown   = ohci_shutdown,
-
-   .get_frame_number 

Re: [RFC][PATCH 1/7] USB: OHCI: make ohci-exynos a separate driver

2013-06-07 Thread Arnd Bergmann
On Friday 07 June 2013 11:33:27 Manjunath Goudar wrote:
 
  #if!IS_ENABLED(CONFIG_USB_OHCI_HCD_PCI)  \
 !IS_ENABLED(CONFIG_USB_OHCI_HCD_PLATFORM)  \
 +   !IS_ENABLED(CONFIG_USB_OHCI_EXYNOS)  \
 !defined(PLATFORM_DRIVER) \
 !defined(OMAP1_PLATFORM_DRIVER)   \
 !defined(OMAP3_PLATFORM_DRIVER)   \
 @@ -1269,7 +1265,6 @@ MODULE_LICENSE (GPL);
 !defined(SM501_OHCI_DRIVER)  \
 !defined(TMIO_OHCI_DRIVER)  \
 !defined(S3C2410_PLATFORM_DRIVER)  \
 -   !defined(EXYNOS_PLATFORM_DRIVER)  \
 !defined(EP93XX_PLATFORM_DRIVER)  \
 !defined(AT91_PLATFORM_DRIVER)  \
 !defined(NXP_PLATFORM_DRIVER)  \

Hi Manjunath,

please note that Greg just merged my patch to remove this entire list and
the #error statement. The next time you rebase your patch, you will have
to remove this hunk in each of your patches.

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


Re: [RFC][PATCH 1/7] USB: OHCI: make ohci-exynos a separate driver

2013-06-07 Thread Alan Stern
On Fri, 7 Jun 2013, Manjunath Goudar wrote:

 Separate the  Samsung OHCI EXYNOS host controller driver from ohci-hcd
 host code so that it can be built as a separate driver module.
 This work is part of enabling multi-platform kernels on ARM.

 -static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
 +static void exynos_ohci_phy_enable(struct platform_device *pdev)
  {
 - struct platform_device *pdev = to_platform_device(exynos_ohci-dev);
 + struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);

This is wrong.  platform_get_drvdata() will return the hcd, not the 
exynos_ohci_hcd structure.

 @@ -37,9 +51,9 @@ static void exynos_ohci_phy_enable(struct exynos_ohci_hcd 
 *exynos_ohci)
   exynos_ohci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST);
  }
  
 -static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
 +static void exynos_ohci_phy_disable(struct platform_device *pdev)
  {
 - struct platform_device *pdev = to_platform_device(exynos_ohci-dev);
 + struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);

Same problem here.

 @@ -121,15 +83,18 @@ static int exynos_ohci_probe(struct platform_device 
 *pdev)
   if (!pdev-dev.coherent_dma_mask)
   pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
  
 - exynos_ohci = devm_kzalloc(pdev-dev, sizeof(struct exynos_ohci_hcd),
 - GFP_KERNEL);
 - if (!exynos_ohci)
 + hcd = usb_create_hcd(exynos_ohci_hc_driver,
 + pdev-dev, dev_name(pdev-dev));
 + if (!hcd) {
 + dev_err(pdev-dev, Unable to create HCD\n);
   return -ENOMEM;
  
   if (of_device_is_compatible(pdev-dev.of_node,
   samsung,exynos5440-ohci))
   goto skip_phy;
  
 + }

This close brace belongs with the previous if statement.

 @@ -146,7 +111,6 @@ static int exynos_ohci_probe(struct platform_device *pdev)
  
  skip_phy:
  
 - exynos_ohci-dev = pdev-dev;
  
   hcd = usb_create_hcd(exynos_ohci_hc_driver, pdev-dev,
   dev_name(pdev-dev));

This needs to be deleted, because it was done already.

Manjunath, I have already asked you to proof-read your patches before 
posting them.  Please do so.  New patches should _not_ have this kind 
of error.

 @@ -192,13 +155,11 @@ skip_phy:
   }
  
   if (exynos_ohci-otg)
 - exynos_ohci-otg-set_host(exynos_ohci-otg,
 - exynos_ohci-hcd-self);
 + exynos_ohci-otg-set_host(exynos_ohci-otg, hcd-self);
  
 - exynos_ohci_phy_enable(exynos_ohci);
 + exynos_ohci_phy_enable(pdev);

This call will not work, because you don't set pdev's platform_data
until later.  The call to platform_set_drvdata() must be moved before
this line.

  
 - ohci = hcd_to_ohci(hcd);
 - ohci_hcd_init(ohci);
 + ohci_setup(hcd);

There's no need to call ohci_setup(), because it will get called anyway
as the .reset member of the ohci_hc_driver structure.

Alan Stern

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