From patchwork Fri Jun 28 22:34:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Silbe X-Patchwork-Id: 255688 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 045FD2C009D for ; Sat, 29 Jun 2013 08:35:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 01A8E4A044; Sat, 29 Jun 2013 00:35:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aJI1bf6ctE4T; Sat, 29 Jun 2013 00:35:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6DE234A039; Sat, 29 Jun 2013 00:35:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 64A3B4A03A for ; Sat, 29 Jun 2013 00:34:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R44tHYZZ4M5D for ; Sat, 29 Jun 2013 00:34:52 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from b.mx.chost.de (s15264669.onlinehome-server.info [87.106.8.89]) by theia.denx.de (Postfix) with ESMTPS id 57BA34A039 for ; Sat, 29 Jun 2013 00:34:44 +0200 (CEST) Received: from sshgate.chost.de (sshgate.chost.de [::ffff:87.106.80.19]) by b.mx.chost.de with esmtp; Sat, 29 Jun 2013 00:34:41 +0200 id 0C11B198.51CE0F81.00001C32 Received: by sshgate.chost.de (sSMTP sendmail emulation); Sat, 29 Jun 2013 00:34:41 +0200 Received: (nullmailer pid 12700 invoked by uid 8193); Fri, 28 Jun 2013 22:34:39 -0000 From: Sascha Silbe To: u-boot@lists.denx.de Date: Sat, 29 Jun 2013 00:34:31 +0200 Message-Id: <1372458871-11683-2-git-send-email-t-uboot@infra-silbe.de> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1372458871-11683-1-git-send-email-t-uboot@infra-silbe.de> References: <20130626140403.1434738047D@gemini.denx.de> <1372458871-11683-1-git-send-email-t-uboot@infra-silbe.de> Cc: Marek Vasut Subject: [U-Boot] [PATCH] usb: ehci-marvell: use structs for registers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Use structs instead of computing offsets for accessing individual registers. The base address of the USB controller is still an offset defined in SoC headers as it can differ between SoCs. Signed-off-by: Sascha Silbe --- Tested on CuBox Pro only. drivers/usb/host/ehci-marvell.c | 48 +++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 2b73e4a..e4d6881 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -36,17 +36,35 @@ DECLARE_GLOBAL_DATA_PTR; -#define rdl(off) readl(MVUSB0_BASE + (off)) -#define wrl(off, val) writel((val), MVUSB0_BASE + (off)) - -#define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4)) -#define USB_WINDOW_BASE(i) (0x324 + ((i) << 4)) #define USB_TARGET_DRAM 0x0 +/* USB 2.0 Bridge Address Decoding registers */ +struct mvusb_bad_window_regs { + u32 control; + u32 base; + u32 reserved[2]; +}; + +struct mvusb_bridge_regs { + u32 bridge_control; + u32 reserved1[3]; + u32 int_cause; /* Bridge Interrupt Cause Register */ + u32 int_mask; /* Bridge Interrupt Mask Register */ + u32 reserved2; + u32 error_addr; /* Bridge Error Address Register */ + struct mvusb_bad_window_regs window[4]; +}; + +struct mvusb_regs { + u32 unused1[0x40]; + u32 ehci_regs[0x80]; + struct mvusb_bridge_regs bridge; +}; + /* * USB 2.0 Bridge Address Decoding registers setup */ -static void usb_brg_adrdec_setup(void) +static void usb_brg_adrdec_setup(struct mvusb_regs *usb_base) { int i; u32 size, base, attrib; @@ -75,14 +93,15 @@ static void usb_brg_adrdec_setup(void) size = gd->bd->bi_dram[i].size; base = gd->bd->bi_dram[i].start; - if ((size) && (attrib)) - wrl(USB_WINDOW_CTRL(i), - MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM, - attrib, MVCPU_WIN_ENABLE)); + if (size && attrib) + writel(MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM, + attrib, MVCPU_WIN_ENABLE), + usb_base->bridge.window[i].control); else - wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE); + writel(MVCPU_WIN_DISABLE, + usb_base->bridge.window[i].control); - wrl(USB_WINDOW_BASE(i), base); + writel(base, usb_base->bridge.window[i].base); } } @@ -92,9 +111,10 @@ static void usb_brg_adrdec_setup(void) */ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { - usb_brg_adrdec_setup(); + struct mvusb_regs *usb_base = (struct mvusb_regs *)MVUSB0_BASE; - *hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100); + usb_brg_adrdec_setup(usb_base); + *hccr = (struct ehci_hccr *)(&usb_base->ehci_regs); *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));