From 9e1a54296ae6bdc2191e824a3f3ddebf5c834a37 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Tue, 18 Dec 2012 14:51:55 +0000
Subject: [PATCH] cns21xx: fix build errors on 3.6

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 34756
---
 .../003-arm-introduce-fa-platform.patch       |  2 +-
 .../patches-3.6/100-cns21xx-core.patch        |  2 +-
 .../103-cns21xx-usb-ohci-support.patch        | 56 ++++++++++++++++++-
 .../104-cns21xx-usb-ehci-support.patch        | 49 +++++++++++++++-
 4 files changed, 101 insertions(+), 8 deletions(-)

diff --git a/target/linux/cns21xx/patches-3.6/003-arm-introduce-fa-platform.patch b/target/linux/cns21xx/patches-3.6/003-arm-introduce-fa-platform.patch
index 018734e29f..902370e15b 100644
--- a/target/linux/cns21xx/patches-3.6/003-arm-introduce-fa-platform.patch
+++ b/target/linux/cns21xx/patches-3.6/003-arm-introduce-fa-platform.patch
@@ -1,6 +1,6 @@
 --- a/arch/arm/Kconfig
 +++ b/arch/arm/Kconfig
-@@ -1133,10 +1133,15 @@ source "arch/arm/mach-vt8500/Kconfig"
+@@ -1134,10 +1134,15 @@ source "arch/arm/mach-vt8500/Kconfig"
  
  source "arch/arm/mach-w90x900/Kconfig"
  
diff --git a/target/linux/cns21xx/patches-3.6/100-cns21xx-core.patch b/target/linux/cns21xx/patches-3.6/100-cns21xx-core.patch
index b386045faa..e0d6cd65f7 100644
--- a/target/linux/cns21xx/patches-3.6/100-cns21xx-core.patch
+++ b/target/linux/cns21xx/patches-3.6/100-cns21xx-core.patch
@@ -28,7 +28,7 @@
  config ARCH_CLPS711X
  	bool "Cirrus Logic CLPS711x/EP721x/EP731x-based"
  	select CPU_ARM720T
-@@ -1041,6 +1055,8 @@ source "arch/arm/mach-davinci/Kconfig"
+@@ -1042,6 +1056,8 @@ source "arch/arm/mach-davinci/Kconfig"
  
  source "arch/arm/mach-dove/Kconfig"
  
diff --git a/target/linux/cns21xx/patches-3.6/103-cns21xx-usb-ohci-support.patch b/target/linux/cns21xx/patches-3.6/103-cns21xx-usb-ohci-support.patch
index 5770c212dd..f5aa3434b8 100644
--- a/target/linux/cns21xx/patches-3.6/103-cns21xx-usb-ohci-support.patch
+++ b/target/linux/cns21xx/patches-3.6/103-cns21xx-usb-ohci-support.patch
@@ -30,9 +30,58 @@
  #ifdef CONFIG_USB_CNS3XXX_OHCI
  #include "ohci-cns3xxx.c"
  #define PLATFORM_DRIVER		ohci_hcd_cns3xxx_driver
+@@ -1117,7 +1124,7 @@ MODULE_LICENSE ("GPL");
+ 
+ #ifdef CONFIG_USB_OHCI_HCD_PLATFORM
+ #include "ohci-platform.c"
+-#define PLATFORM_DRIVER		ohci_platform_driver
++#define OHCI_PLATFORM_DRIVER		ohci_platform_driver
+ #endif
+ 
+ #if	!defined(PCI_DRIVER) &&		\
+@@ -1128,7 +1135,8 @@ MODULE_LICENSE ("GPL");
+ 	!defined(SA1111_DRIVER) &&	\
+ 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
+ 	!defined(SM501_OHCI_DRIVER) && \
+-	!defined(TMIO_OHCI_DRIVER)
++	!defined(TMIO_OHCI_DRIVER) && \
++	!defined(OHCI_PLATFORM_DRIVER)
+ #error "missing bus glue for ohci-hcd"
+ #endif
+ 
+@@ -1206,9 +1214,19 @@ static int __init ohci_hcd_mod_init(void
+ 		goto error_tmio;
+ #endif
+ 
++#ifdef OHCI_PLATFORM_DRIVER
++	retval = platform_driver_register(&OHCI_PLATFORM_DRIVER);
++	if (retval < 0)
++		goto error_ohci;
++#endif
++
+ 	return retval;
+ 
+ 	/* Error path */
++#ifdef OHCI_PLATFORM_DRIVER
++	platform_driver_unregister(&OHCI_PLATFORM_DRIVER);
++ error_ohci:
++#endif
+ #ifdef TMIO_OHCI_DRIVER
+ 	platform_driver_unregister(&TMIO_OHCI_DRIVER);
+  error_tmio:
+@@ -1258,6 +1276,9 @@ module_init(ohci_hcd_mod_init);
+ 
+ static void __exit ohci_hcd_mod_exit(void)
+ {
++#ifdef OHCI_PLATFORM_DRIVER
++	platform_driver_unregister(&OHCI_PLATFORM_DRIVER);
++#endif
+ #ifdef TMIO_OHCI_DRIVER
+ 	platform_driver_unregister(&TMIO_OHCI_DRIVER);
+ #endif
 --- /dev/null
 +++ b/drivers/usb/host/ohci-cns21xx.c
-@@ -0,0 +1,175 @@
+@@ -0,0 +1,176 @@
 +/*
 + *  Copyright (c) 2008 Cavium Networks
 + *  Copyright (c) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
@@ -59,7 +108,8 @@
 +
 +	ret = ohci_run(ohci);
 +	if (ret) {
-+		err("can't start %s", ohci_to_hcd(ohci)->self.bus_name);
++		ohci_err(ohci, "can't start %s",
++			 ohci_to_hcd(ohci)->self.bus_name);
 +		goto err;
 +	}
 +
@@ -214,7 +264,7 @@
  #define	OHCI_QUIRK_HUB_POWER	0x100			/* distrust firmware power/oc setup */
  #define	OHCI_QUIRK_AMD_PLL	0x200			/* AMD PLL quirk*/
  #define	OHCI_QUIRK_AMD_PREFETCH	0x400			/* pre-fetch for ISO transfer */
-+#define OHCI_QUIRK_INIT_FMINTERVAL 0x1000		/* fminterval must be initialized */
++#define	OHCI_QUIRK_INIT_FMINTERVAL 0x1000		/* fminterval must be initialized */
  	// there are also chip quirks/bugs in init logic
  
  	struct work_struct	nec_work;	/* Worker for NEC quirk */
diff --git a/target/linux/cns21xx/patches-3.6/104-cns21xx-usb-ehci-support.patch b/target/linux/cns21xx/patches-3.6/104-cns21xx-usb-ehci-support.patch
index 3936d10f08..55b3af3858 100644
--- a/target/linux/cns21xx/patches-3.6/104-cns21xx-usb-ehci-support.patch
+++ b/target/linux/cns21xx/patches-3.6/104-cns21xx-usb-ehci-support.patch
@@ -189,8 +189,8 @@
 +MODULE_ALIAS("platform:" DRIVER_NAME);
 --- a/drivers/usb/host/ehci-hcd.c
 +++ b/drivers/usb/host/ehci-hcd.c
-@@ -1339,6 +1339,11 @@ MODULE_LICENSE ("GPL");
- #define PLATFORM_DRIVER		ehci_platform_driver
+@@ -1334,14 +1334,19 @@ MODULE_LICENSE ("GPL");
+ #define	PLATFORM_DRIVER		ehci_hcd_sead3_driver
  #endif
  
 +#ifdef CONFIG_ARCH_CNS21XX
@@ -198,9 +198,52 @@
 +#define PLATFORM_DRIVER		ehci_cns21xx_driver
 +#endif
 +
+ #ifdef CONFIG_USB_EHCI_HCD_PLATFORM
+ #include "ehci-platform.c"
+-#define PLATFORM_DRIVER		ehci_platform_driver
++#define EHCI_PLATFORM_DRIVER	ehci_platform_driver
+ #endif
+ 
  #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
      !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
-     !defined(XILINX_OF_PLATFORM_DRIVER)
+-    !defined(XILINX_OF_PLATFORM_DRIVER)
++    !defined(XILINX_OF_PLATFORM_DRIVER) && !defined(EHCI_PLATFORM_DRIVER)
+ #error "missing bus glue for ehci-hcd"
+ #endif
+ 
+@@ -1401,10 +1406,21 @@ static int __init ehci_hcd_init(void)
+ 	if (retval < 0)
+ 		goto clean4;
+ #endif
++
++#ifdef EHCI_PLATFORM_DRIVER
++	retval = platform_driver_register(&EHCI_PLATFORM_DRIVER);
++	if (retval < 0)
++		goto clean5;
++#endif
++
+ 	return retval;
+ 
++#ifdef EHCI_PLATFORM_DRIVER
++	platform_driver_unregister(&EHCI_PLATFORM_DRIVER);
++clean5:
++#endif
+ #ifdef XILINX_OF_PLATFORM_DRIVER
+-	/* platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER); */
++	platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER);
+ clean4:
+ #endif
+ #ifdef OF_PLATFORM_DRIVER
+@@ -1435,6 +1451,9 @@ module_init(ehci_hcd_init);
+ 
+ static void __exit ehci_hcd_cleanup(void)
+ {
++#ifdef EHCI_PLATFORM_DRIVER
++	platform_driver_unregister(&EHCI_PLATFORM_DRIVER);
++#endif
+ #ifdef XILINX_OF_PLATFORM_DRIVER
+ 	platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER);
+ #endif
 --- a/arch/arm/Kconfig
 +++ b/arch/arm/Kconfig
 @@ -394,6 +394,7 @@ config ARCH_CNS21XX
-- 
2.30.2