diff options
author | Ido Shayevitz <idos@codeaurora.org> | 2012-04-24 07:18:39 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-04-24 08:37:04 -0400 |
commit | 51249dca627d9d0e6b41531e716cbc308554a62c (patch) | |
tree | 02338bf0474d5e03c366e180acc9c86b8d65c5cd | |
parent | ab5e59dbdb6d2e2d784381bd194e0229b8b990b5 (diff) |
usb: dwc3: core: split host address space
This fix prevents a problem with dwc3 and host mode where
we were requesting the entire memory region in dwc3/core.c,
thus preventing xhci-plat from ever ioremapping its own address space.
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc3/core.c | 31 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.h | 15 | ||||
-rw-r--r-- | drivers/usb/dwc3/host.c | 19 | ||||
-rw-r--r-- | drivers/usb/dwc3/io.h | 16 |
4 files changed, 46 insertions, 35 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 7bd815a507e8..b2b417223694 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -410,7 +410,6 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
410 | struct device *dev = &pdev->dev; | 410 | struct device *dev = &pdev->dev; |
411 | 411 | ||
412 | int ret = -ENOMEM; | 412 | int ret = -ENOMEM; |
413 | int irq; | ||
414 | 413 | ||
415 | void __iomem *regs; | 414 | void __iomem *regs; |
416 | void *mem; | 415 | void *mem; |
@@ -425,15 +424,28 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
425 | dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); | 424 | dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); |
426 | dwc->mem = mem; | 425 | dwc->mem = mem; |
427 | 426 | ||
428 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 427 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
429 | if (!res) { | 428 | if (!res) { |
430 | dev_err(dev, "missing resource\n"); | 429 | dev_err(dev, "missing IRQ\n"); |
431 | return -ENODEV; | 430 | return -ENODEV; |
432 | } | 431 | } |
432 | dwc->xhci_resources[1] = *res; | ||
433 | 433 | ||
434 | dwc->res = res; | 434 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
435 | 435 | if (!res) { | |
436 | res = devm_request_mem_region(dev, res->start, resource_size(res), | 436 | dev_err(dev, "missing memory resource\n"); |
437 | return -ENODEV; | ||
438 | } | ||
439 | dwc->xhci_resources[0] = *res; | ||
440 | dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + | ||
441 | DWC3_XHCI_REGS_END; | ||
442 | |||
443 | /* | ||
444 | * Request memory region but exclude xHCI regs, | ||
445 | * since it will be requested by the xhci-plat driver. | ||
446 | */ | ||
447 | res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, | ||
448 | resource_size(res) - DWC3_GLOBALS_REGS_START, | ||
437 | dev_name(dev)); | 449 | dev_name(dev)); |
438 | if (!res) { | 450 | if (!res) { |
439 | dev_err(dev, "can't request mem region\n"); | 451 | dev_err(dev, "can't request mem region\n"); |
@@ -446,19 +458,12 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
446 | return -ENOMEM; | 458 | return -ENOMEM; |
447 | } | 459 | } |
448 | 460 | ||
449 | irq = platform_get_irq(pdev, 0); | ||
450 | if (irq < 0) { | ||
451 | dev_err(dev, "missing IRQ\n"); | ||
452 | return -ENODEV; | ||
453 | } | ||
454 | |||
455 | spin_lock_init(&dwc->lock); | 461 | spin_lock_init(&dwc->lock); |
456 | platform_set_drvdata(pdev, dwc); | 462 | platform_set_drvdata(pdev, dwc); |
457 | 463 | ||
458 | dwc->regs = regs; | 464 | dwc->regs = regs; |
459 | dwc->regs_size = resource_size(res); | 465 | dwc->regs_size = resource_size(res); |
460 | dwc->dev = dev; | 466 | dwc->dev = dev; |
461 | dwc->irq = irq; | ||
462 | 467 | ||
463 | if (!strncmp("super", maximum_speed, 5)) | 468 | if (!strncmp("super", maximum_speed, 5)) |
464 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | 469 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index a32c2b503fe1..c7b3ca037bbc 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -52,6 +52,7 @@ | |||
52 | 52 | ||
53 | /* Global constants */ | 53 | /* Global constants */ |
54 | #define DWC3_ENDPOINTS_NUM 32 | 54 | #define DWC3_ENDPOINTS_NUM 32 |
55 | #define DWC3_XHCI_RESOURCES_NUM 2 | ||
55 | 56 | ||
56 | #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE | 57 | #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE |
57 | #define DWC3_EVENT_TYPE_MASK 0xfe | 58 | #define DWC3_EVENT_TYPE_MASK 0xfe |
@@ -75,6 +76,16 @@ | |||
75 | #define DWC3_GSNPSID_MASK 0xffff0000 | 76 | #define DWC3_GSNPSID_MASK 0xffff0000 |
76 | #define DWC3_GSNPSREV_MASK 0xffff | 77 | #define DWC3_GSNPSREV_MASK 0xffff |
77 | 78 | ||
79 | /* DWC3 registers memory space boundries */ | ||
80 | #define DWC3_XHCI_REGS_START 0x0 | ||
81 | #define DWC3_XHCI_REGS_END 0x7fff | ||
82 | #define DWC3_GLOBALS_REGS_START 0xc100 | ||
83 | #define DWC3_GLOBALS_REGS_END 0xc6ff | ||
84 | #define DWC3_DEVICE_REGS_START 0xc700 | ||
85 | #define DWC3_DEVICE_REGS_END 0xcbff | ||
86 | #define DWC3_OTG_REGS_START 0xcc00 | ||
87 | #define DWC3_OTG_REGS_END 0xccff | ||
88 | |||
78 | /* Global Registers */ | 89 | /* Global Registers */ |
79 | #define DWC3_GSBUSCFG0 0xc100 | 90 | #define DWC3_GSBUSCFG0 0xc100 |
80 | #define DWC3_GSBUSCFG1 0xc104 | 91 | #define DWC3_GSBUSCFG1 0xc104 |
@@ -583,7 +594,7 @@ struct dwc3 { | |||
583 | struct device *dev; | 594 | struct device *dev; |
584 | 595 | ||
585 | struct platform_device *xhci; | 596 | struct platform_device *xhci; |
586 | struct resource *res; | 597 | struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM]; |
587 | 598 | ||
588 | struct dwc3_event_buffer **ev_buffs; | 599 | struct dwc3_event_buffer **ev_buffs; |
589 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; | 600 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; |
@@ -594,8 +605,6 @@ struct dwc3 { | |||
594 | void __iomem *regs; | 605 | void __iomem *regs; |
595 | size_t regs_size; | 606 | size_t regs_size; |
596 | 607 | ||
597 | int irq; | ||
598 | |||
599 | u32 num_event_buffers; | 608 | u32 num_event_buffers; |
600 | u32 u1u2; | 609 | u32 u1u2; |
601 | u32 maximum_speed; | 610 | u32 maximum_speed; |
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index b108d18fd40d..56a62342884d 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c | |||
@@ -39,15 +39,6 @@ | |||
39 | 39 | ||
40 | #include "core.h" | 40 | #include "core.h" |
41 | 41 | ||
42 | static struct resource generic_resources[] = { | ||
43 | { | ||
44 | .flags = IORESOURCE_IRQ, | ||
45 | }, | ||
46 | { | ||
47 | .flags = IORESOURCE_MEM, | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | int dwc3_host_init(struct dwc3 *dwc) | 42 | int dwc3_host_init(struct dwc3 *dwc) |
52 | { | 43 | { |
53 | struct platform_device *xhci; | 44 | struct platform_device *xhci; |
@@ -68,14 +59,8 @@ int dwc3_host_init(struct dwc3 *dwc) | |||
68 | 59 | ||
69 | dwc->xhci = xhci; | 60 | dwc->xhci = xhci; |
70 | 61 | ||
71 | /* setup resources */ | 62 | ret = platform_device_add_resources(xhci, dwc->xhci_resources, |
72 | generic_resources[0].start = dwc->irq; | 63 | DWC3_XHCI_RESOURCES_NUM); |
73 | |||
74 | generic_resources[1].start = dwc->res->start; | ||
75 | generic_resources[1].end = dwc->res->start + 0x7fff; | ||
76 | |||
77 | ret = platform_device_add_resources(xhci, generic_resources, | ||
78 | ARRAY_SIZE(generic_resources)); | ||
79 | if (ret) { | 64 | if (ret) { |
80 | dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); | 65 | dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); |
81 | goto err1; | 66 | goto err1; |
diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index 071d561f3e68..a50f76b9d19b 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h | |||
@@ -41,14 +41,26 @@ | |||
41 | 41 | ||
42 | #include <linux/io.h> | 42 | #include <linux/io.h> |
43 | 43 | ||
44 | #include "core.h" | ||
45 | |||
44 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) | 46 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) |
45 | { | 47 | { |
46 | return readl(base + offset); | 48 | /* |
49 | * We requested the mem region starting from the Globals address | ||
50 | * space, see dwc3_probe in core.c. | ||
51 | * However, the offsets are given starting from xHCI address space. | ||
52 | */ | ||
53 | return readl(base + (offset - DWC3_GLOBALS_REGS_START)); | ||
47 | } | 54 | } |
48 | 55 | ||
49 | static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) | 56 | static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) |
50 | { | 57 | { |
51 | writel(value, base + offset); | 58 | /* |
59 | * We requested the mem region starting from the Globals address | ||
60 | * space, see dwc3_probe in core.c. | ||
61 | * However, the offsets are given starting from xHCI address space. | ||
62 | */ | ||
63 | writel(value, base + (offset - DWC3_GLOBALS_REGS_START)); | ||
52 | } | 64 | } |
53 | 65 | ||
54 | #endif /* __DRIVERS_USB_DWC3_IO_H */ | 66 | #endif /* __DRIVERS_USB_DWC3_IO_H */ |