linux-mips
[Top] [All Lists]

[PATCH v3 2/3] MIPS: ath79: add USB platform setup code for AR934X

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH v3 2/3] MIPS: ath79: add USB platform setup code for AR934X
From: Gabor Juhos <juhosg@openwrt.org>
Date: Sat, 4 Aug 2012 18:03:56 +0200
Cc: linux-mips@linux-mips.org, Gabor Juhos <juhosg@openwrt.org>
In-reply-to: <1344096237-25221-1-git-send-email-juhosg@openwrt.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1344096237-25221-1-git-send-email-juhosg@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/dev-usb.c                      |   28 ++++++++++++++++++++++++
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h |    7 ++++++
 2 files changed, 35 insertions(+)

diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c
index 87fe48e..072bb9b 100644
--- a/arch/mips/ath79/dev-usb.c
+++ b/arch/mips/ath79/dev-usb.c
@@ -193,6 +193,32 @@ static void __init ar933x_usb_setup(void)
        platform_device_register(&ath79_ehci_device);
 }
 
+static void __init ar934x_usb_setup(void)
+{
+       u32 bootstrap;
+
+       bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
+       if (bootstrap & AR934X_BOOTSTRAP_USB_MODE_DEVICE)
+               return;
+
+       ath79_device_reset_set(AR934X_RESET_USBSUS_OVERRIDE);
+       udelay(1000);
+
+       ath79_device_reset_clear(AR934X_RESET_USB_PHY);
+       udelay(1000);
+
+       ath79_device_reset_clear(AR934X_RESET_USB_PHY_ANALOG);
+       udelay(1000);
+
+       ath79_device_reset_clear(AR934X_RESET_USB_HOST);
+       udelay(1000);
+
+       ath79_usb_init_resource(ath79_ehci_resources, AR934X_EHCI_BASE,
+                               AR934X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
+       ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
+       platform_device_register(&ath79_ehci_device);
+}
+
 void __init ath79_register_usb(void)
 {
        if (soc_is_ar71xx())
@@ -205,6 +231,8 @@ void __init ath79_register_usb(void)
                ar913x_usb_setup();
        else if (soc_is_ar933x())
                ar933x_usb_setup();
+       else if (soc_is_ar934x())
+               ar934x_usb_setup();
        else
                BUG();
 }
diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h 
b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index dde5044..3ccae12 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -63,6 +63,8 @@
 
 #define AR934X_WMAC_BASE       (AR71XX_APB_BASE + 0x00100000)
 #define AR934X_WMAC_SIZE       0x20000
+#define AR934X_EHCI_BASE       0x1b000000
+#define AR934X_EHCI_SIZE       0x200
 
 /*
  * DDR_CTRL block
@@ -288,6 +290,11 @@
 #define AR933X_RESET_USB_PHY           BIT(4)
 #define AR933X_RESET_USBSUS_OVERRIDE   BIT(3)
 
+#define AR934X_RESET_USB_PHY_ANALOG    BIT(11)
+#define AR934X_RESET_USB_HOST          BIT(5)
+#define AR934X_RESET_USB_PHY           BIT(4)
+#define AR934X_RESET_USBSUS_OVERRIDE   BIT(3)
+
 #define AR933X_BOOTSTRAP_REF_CLK_40    BIT(0)
 
 #define AR934X_BOOTSTRAP_SW_OPTION8    BIT(23)
-- 
1.7.10


<Prev in Thread] Current Thread [Next in Thread>