aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2008-03-27 14:51:39 -0400
committerNicolas Pitre <nico@marvell.com>2008-03-27 14:51:39 -0400
commit92aecfa95523384923b52c8ddaf948fc02a53e82 (patch)
tree0bea3d5d3ee86b1540cecd5aeab9afa48919ee7d
parent1f2223b12b62a97d66e39199db50ed3fae9222c0 (diff)
ehci-orion: mbus decode window support
Make it possible to pass mbus_dram_target_info to the ehci-orion driver via the platform data, make the ehci-orion driver program the window registers based on this data if it is passed in, and make the Orion platform setup code use this method instead of programming the EHCI mbus window registers by hand. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Reviewed-by: Tzachi Perelstein <tzachi@marvell.com> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Nicolas Pitre <nico@marvell.com>
-rw-r--r--arch/arm/mach-orion/addr-map.c49
-rw-r--r--arch/arm/mach-orion/common.c8
-rw-r--r--arch/arm/mach-orion/common.h1
-rw-r--r--drivers/usb/host/ehci-orion.c36
-rw-r--r--include/asm-arm/arch-orion/platform.h9
5 files changed, 50 insertions, 53 deletions
diff --git a/arch/arm/mach-orion/addr-map.c b/arch/arm/mach-orion/addr-map.c
index 69cd0876f6b..40bcb986ab9 100644
--- a/arch/arm/mach-orion/addr-map.c
+++ b/arch/arm/mach-orion/addr-map.c
@@ -104,15 +104,6 @@
104#define ETH_MAX_REMAP_WIN 4 104#define ETH_MAX_REMAP_WIN 4
105 105
106/* 106/*
107 * USB Address Decode Windows registers
108 */
109#define USB_WIN_CTRL(i, w) ((i == 0) ? ORION_USB0_REG(0x320 + ((w) << 4)) \
110 : ORION_USB1_REG(0x320 + ((w) << 4)))
111#define USB_WIN_BASE(i, w) ((i == 0) ? ORION_USB0_REG(0x324 + ((w) << 4)) \
112 : ORION_USB1_REG(0x324 + ((w) << 4)))
113#define USB_MAX_WIN 4
114
115/*
116 * SATA Address Decode Windows registers 107 * SATA Address Decode Windows registers
117 */ 108 */
118#define SATA_WIN_CTRL(win) ORION_SATA_REG(0x30 + ((win) * 0x10)) 109#define SATA_WIN_CTRL(win) ORION_SATA_REG(0x30 + ((win) * 0x10))
@@ -262,46 +253,6 @@ void __init orion_setup_cpu_wins(void)
262 orion_mbus_dram_info.num_cs = cs; 253 orion_mbus_dram_info.num_cs = cs;
263} 254}
264 255
265void __init orion_setup_usb_wins(void)
266{
267 int i;
268 u32 usb_if, dev, rev;
269 u32 max_usb_if = 1;
270
271 orion_pcie_id(&dev, &rev);
272 if (dev == MV88F5182_DEV_ID)
273 max_usb_if = 2;
274
275 for (usb_if = 0; usb_if < max_usb_if; usb_if++) {
276 /*
277 * First, disable and clear windows
278 */
279 for (i = 0; i < USB_MAX_WIN; i++) {
280 orion_write(USB_WIN_BASE(usb_if, i), 0);
281 orion_write(USB_WIN_CTRL(usb_if, i), 0);
282 }
283
284 /*
285 * Setup windows for DDR banks.
286 */
287 for (i = 0; i < DDR_MAX_CS; i++) {
288 u32 base, size;
289 size = orion_read(DDR_SIZE_CS(i));
290 base = orion_read(DDR_BASE_CS(i));
291 if (size & DDR_BANK_EN) {
292 base = DDR_REG_TO_BASE(base);
293 size = DDR_REG_TO_SIZE(size);
294 orion_write(USB_WIN_CTRL(usb_if, i),
295 ((size-1) & 0xffff0000) |
296 (ATTR_DDR_CS(i) << 8) |
297 (TARGET_DDR << 4) | WIN_EN);
298 orion_write(USB_WIN_BASE(usb_if, i),
299 base & 0xffff0000);
300 }
301 }
302 }
303}
304
305void __init orion_setup_eth_wins(void) 256void __init orion_setup_eth_wins(void)
306{ 257{
307 int i; 258 int i;
diff --git a/arch/arm/mach-orion/common.c b/arch/arm/mach-orion/common.c
index cc16588e8c0..d33c01dfc3f 100644
--- a/arch/arm/mach-orion/common.c
+++ b/arch/arm/mach-orion/common.c
@@ -23,6 +23,7 @@
23#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
24#include <asm/mach/map.h> 24#include <asm/mach/map.h>
25#include <asm/arch/hardware.h> 25#include <asm/arch/hardware.h>
26#include <asm/arch/platform.h>
26#include "common.h" 27#include "common.h"
27 28
28/***************************************************************************** 29/*****************************************************************************
@@ -149,6 +150,10 @@ static struct resource orion_ehci1_resources[] = {
149 }, 150 },
150}; 151};
151 152
153static struct orion_ehci_data orion_ehci_data = {
154 .dram = &orion_mbus_dram_info,
155};
156
152static u64 ehci_dmamask = 0xffffffffUL; 157static u64 ehci_dmamask = 0xffffffffUL;
153 158
154static struct platform_device orion_ehci0 = { 159static struct platform_device orion_ehci0 = {
@@ -157,6 +162,7 @@ static struct platform_device orion_ehci0 = {
157 .dev = { 162 .dev = {
158 .dma_mask = &ehci_dmamask, 163 .dma_mask = &ehci_dmamask,
159 .coherent_dma_mask = 0xffffffff, 164 .coherent_dma_mask = 0xffffffff,
165 .platform_data = &orion_ehci_data,
160 }, 166 },
161 .resource = orion_ehci0_resources, 167 .resource = orion_ehci0_resources,
162 .num_resources = ARRAY_SIZE(orion_ehci0_resources), 168 .num_resources = ARRAY_SIZE(orion_ehci0_resources),
@@ -168,6 +174,7 @@ static struct platform_device orion_ehci1 = {
168 .dev = { 174 .dev = {
169 .dma_mask = &ehci_dmamask, 175 .dma_mask = &ehci_dmamask,
170 .coherent_dma_mask = 0xffffffff, 176 .coherent_dma_mask = 0xffffffff,
177 .platform_data = &orion_ehci_data,
171 }, 178 },
172 .resource = orion_ehci1_resources, 179 .resource = orion_ehci1_resources,
173 .num_resources = ARRAY_SIZE(orion_ehci1_resources), 180 .num_resources = ARRAY_SIZE(orion_ehci1_resources),
@@ -334,7 +341,6 @@ void __init orion_init(void)
334 * Setup Orion address map 341 * Setup Orion address map
335 */ 342 */
336 orion_setup_cpu_wins(); 343 orion_setup_cpu_wins();
337 orion_setup_usb_wins();
338 orion_setup_eth_wins(); 344 orion_setup_eth_wins();
339 if (dev == MV88F5182_DEV_ID) 345 if (dev == MV88F5182_DEV_ID)
340 orion_setup_sata_wins(); 346 orion_setup_sata_wins();
diff --git a/arch/arm/mach-orion/common.h b/arch/arm/mach-orion/common.h
index 961daaa0b91..c100355754f 100644
--- a/arch/arm/mach-orion/common.h
+++ b/arch/arm/mach-orion/common.h
@@ -33,7 +33,6 @@ extern struct mbus_dram_target_info orion_mbus_dram_info;
33void orion_setup_cpu_win(enum orion_target target, u32 base, u32 size, int remap); 33void orion_setup_cpu_win(enum orion_target target, u32 base, u32 size, int remap);
34void orion_setup_cpu_wins(void); 34void orion_setup_cpu_wins(void);
35void orion_setup_eth_wins(void); 35void orion_setup_eth_wins(void);
36void orion_setup_usb_wins(void);
37void orion_setup_sata_wins(void); 36void orion_setup_sata_wins(void);
38 37
39/* 38/*
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index e129981f139..0f0eb89c8cf 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -11,15 +11,19 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/mbus.h>
14#include <asm/arch/orion.h> 15#include <asm/arch/orion.h>
16#include <asm/arch/platform.h>
15 17
16#define rdl(off) __raw_readl(hcd->regs + (off)) 18#define rdl(off) __raw_readl(hcd->regs + (off))
17#define wrl(off, val) __raw_writel((val), hcd->regs + (off)) 19#define wrl(off, val) __raw_writel((val), hcd->regs + (off))
18 20
19#define USB_CAUSE 0x310
20#define USB_MASK 0x314
21#define USB_CMD 0x140 21#define USB_CMD 0x140
22#define USB_MODE 0x1a8 22#define USB_MODE 0x1a8
23#define USB_CAUSE 0x310
24#define USB_MASK 0x314
25#define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
26#define USB_WINDOW_BASE(i) (0x324 + ((i) << 4))
23#define USB_IPG 0x360 27#define USB_IPG 0x360
24#define USB_PHY_PWR_CTRL 0x400 28#define USB_PHY_PWR_CTRL 0x400
25#define USB_PHY_TX_CTRL 0x420 29#define USB_PHY_TX_CTRL 0x420
@@ -162,8 +166,30 @@ static const struct hc_driver ehci_orion_hc_driver = {
162 .bus_resume = ehci_bus_resume, 166 .bus_resume = ehci_bus_resume,
163}; 167};
164 168
169static void __init
170ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
171 struct mbus_dram_target_info *dram)
172{
173 int i;
174
175 for (i = 0; i < 4; i++) {
176 wrl(USB_WINDOW_CTRL(i), 0);
177 wrl(USB_WINDOW_BASE(i), 0);
178 }
179
180 for (i = 0; i < dram->num_cs; i++) {
181 struct mbus_dram_window *cs = dram->cs + i;
182
183 wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) |
184 (cs->mbus_attr << 8) |
185 (dram->mbus_dram_target_id << 4) | 1);
186 wrl(USB_WINDOW_BASE(i), cs->base);
187 }
188}
189
165static int __init ehci_orion_drv_probe(struct platform_device *pdev) 190static int __init ehci_orion_drv_probe(struct platform_device *pdev)
166{ 191{
192 struct orion_ehci_data *pd = pdev->dev.platform_data;
167 struct resource *res; 193 struct resource *res;
168 struct usb_hcd *hcd; 194 struct usb_hcd *hcd;
169 struct ehci_hcd *ehci; 195 struct ehci_hcd *ehci;
@@ -227,6 +253,12 @@ static int __init ehci_orion_drv_probe(struct platform_device *pdev)
227 ehci->sbrn = 0x20; 253 ehci->sbrn = 0x20;
228 254
229 /* 255 /*
256 * (Re-)program MBUS remapping windows if we are asked to.
257 */
258 if (pd != NULL && pd->dram != NULL)
259 ehci_orion_conf_mbus_windows(hcd, pd->dram);
260
261 /*
230 * setup Orion USB controller 262 * setup Orion USB controller
231 */ 263 */
232 orion_usb_setup(hcd); 264 orion_usb_setup(hcd);
diff --git a/include/asm-arm/arch-orion/platform.h b/include/asm-arm/arch-orion/platform.h
index 143c38e2fa0..0e33fe536ef 100644
--- a/include/asm-arm/arch-orion/platform.h
+++ b/include/asm-arm/arch-orion/platform.h
@@ -12,6 +12,14 @@
12#define __ASM_ARCH_PLATFORM_H__ 12#define __ASM_ARCH_PLATFORM_H__
13 13
14/* 14/*
15 * Orion EHCI platform driver data.
16 */
17struct orion_ehci_data {
18 struct mbus_dram_target_info *dram;
19};
20
21
22/*
15 * Device bus NAND private data 23 * Device bus NAND private data
16 */ 24 */
17struct orion_nand_data { 25struct orion_nand_data {
@@ -22,4 +30,5 @@ struct orion_nand_data {
22 u8 width; /* buswidth */ 30 u8 width; /* buswidth */
23}; 31};
24 32
33
25#endif 34#endif