aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-01-03 05:31:38 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-01-03 05:31:38 -0500
commit50401d77ee4904673042dd737eed436067cc23f5 (patch)
treec92e6a9cc0f9a81fb5f9a9f8a69b0c7d7397b400
parent206323c181371f3d5fab36c6d33e1fac09b61082 (diff)
parent760efe6910d5743084b586d3d0a3b65aea96fb2f (diff)
Merge branch 'master' of git://git.infradead.org/users/cbou/linux-cns3xxx into devel-stable
-rw-r--r--arch/arm/mach-cns3xxx/cns3420vb.c54
-rw-r--r--arch/arm/mach-cns3xxx/core.h2
-rw-r--r--arch/arm/mach-cns3xxx/devices.c1
-rw-r--r--arch/arm/mach-cns3xxx/include/mach/cns3xxx.h2
-rw-r--r--arch/arm/mach-cns3xxx/include/mach/pm.h23
-rw-r--r--arch/arm/mach-cns3xxx/pm.c23
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/host/Kconfig15
-rw-r--r--drivers/usb/host/ehci-cns3xxx.c171
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/host/ohci-cns3xxx.c165
-rw-r--r--drivers/usb/host/ohci-hcd.c5
12 files changed, 464 insertions, 4 deletions
diff --git a/arch/arm/mach-cns3xxx/cns3420vb.c b/arch/arm/mach-cns3xxx/cns3420vb.c
index 90fe9ab8591d..08e5c8759502 100644
--- a/arch/arm/mach-cns3xxx/cns3420vb.c
+++ b/arch/arm/mach-cns3xxx/cns3420vb.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/compiler.h> 18#include <linux/compiler.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/dma-mapping.h>
20#include <linux/serial_core.h> 21#include <linux/serial_core.h>
21#include <linux/serial_8250.h> 22#include <linux/serial_8250.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
@@ -108,10 +109,63 @@ static void __init cns3420_early_serial_setup(void)
108} 109}
109 110
110/* 111/*
112 * USB
113 */
114static struct resource cns3xxx_usb_ehci_resources[] = {
115 [0] = {
116 .start = CNS3XXX_USB_BASE,
117 .end = CNS3XXX_USB_BASE + SZ_16M - 1,
118 .flags = IORESOURCE_MEM,
119 },
120 [1] = {
121 .start = IRQ_CNS3XXX_USB_EHCI,
122 .flags = IORESOURCE_IRQ,
123 },
124};
125
126static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32);
127
128static struct platform_device cns3xxx_usb_ehci_device = {
129 .name = "cns3xxx-ehci",
130 .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources),
131 .resource = cns3xxx_usb_ehci_resources,
132 .dev = {
133 .dma_mask = &cns3xxx_usb_ehci_dma_mask,
134 .coherent_dma_mask = DMA_BIT_MASK(32),
135 },
136};
137
138static struct resource cns3xxx_usb_ohci_resources[] = {
139 [0] = {
140 .start = CNS3XXX_USB_OHCI_BASE,
141 .end = CNS3XXX_USB_OHCI_BASE + SZ_16M - 1,
142 .flags = IORESOURCE_MEM,
143 },
144 [1] = {
145 .start = IRQ_CNS3XXX_USB_OHCI,
146 .flags = IORESOURCE_IRQ,
147 },
148};
149
150static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32);
151
152static struct platform_device cns3xxx_usb_ohci_device = {
153 .name = "cns3xxx-ohci",
154 .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources),
155 .resource = cns3xxx_usb_ohci_resources,
156 .dev = {
157 .dma_mask = &cns3xxx_usb_ohci_dma_mask,
158 .coherent_dma_mask = DMA_BIT_MASK(32),
159 },
160};
161
162/*
111 * Initialization 163 * Initialization
112 */ 164 */
113static struct platform_device *cns3420_pdevs[] __initdata = { 165static struct platform_device *cns3420_pdevs[] __initdata = {
114 &cns3420_nor_pdev, 166 &cns3420_nor_pdev,
167 &cns3xxx_usb_ehci_device,
168 &cns3xxx_usb_ohci_device,
115}; 169};
116 170
117static void __init cns3420_init(void) 171static void __init cns3420_init(void)
diff --git a/arch/arm/mach-cns3xxx/core.h b/arch/arm/mach-cns3xxx/core.h
index 6b33ec11346e..73898a7835d3 100644
--- a/arch/arm/mach-cns3xxx/core.h
+++ b/arch/arm/mach-cns3xxx/core.h
@@ -17,7 +17,5 @@ extern struct sys_timer cns3xxx_timer;
17void __init cns3xxx_map_io(void); 17void __init cns3xxx_map_io(void);
18void __init cns3xxx_init_irq(void); 18void __init cns3xxx_init_irq(void);
19void cns3xxx_power_off(void); 19void cns3xxx_power_off(void);
20void cns3xxx_pwr_power_up(unsigned int block);
21void cns3xxx_pwr_power_down(unsigned int block);
22 20
23#endif /* __CNS3XXX_CORE_H */ 21#endif /* __CNS3XXX_CORE_H */
diff --git a/arch/arm/mach-cns3xxx/devices.c b/arch/arm/mach-cns3xxx/devices.c
index 50b4d31c27c0..79d1fb02c23f 100644
--- a/arch/arm/mach-cns3xxx/devices.c
+++ b/arch/arm/mach-cns3xxx/devices.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <mach/cns3xxx.h> 19#include <mach/cns3xxx.h>
20#include <mach/irqs.h> 20#include <mach/irqs.h>
21#include <mach/pm.h>
21#include "core.h" 22#include "core.h"
22#include "devices.h" 23#include "devices.h"
23 24
diff --git a/arch/arm/mach-cns3xxx/include/mach/cns3xxx.h b/arch/arm/mach-cns3xxx/include/mach/cns3xxx.h
index 6dbce13771ca..191c8e57f289 100644
--- a/arch/arm/mach-cns3xxx/include/mach/cns3xxx.h
+++ b/arch/arm/mach-cns3xxx/include/mach/cns3xxx.h
@@ -165,7 +165,6 @@
165#define CNS3XXX_USBOTG_BASE_VIRT 0xFFF15000 165#define CNS3XXX_USBOTG_BASE_VIRT 0xFFF15000
166 166
167#define CNS3XXX_USB_BASE 0x82000000 /* USB Host Control */ 167#define CNS3XXX_USB_BASE 0x82000000 /* USB Host Control */
168#define CNS3XXX_USB_BASE_VIRT 0xFFF16000
169 168
170#define CNS3XXX_SATA2_BASE 0x83000000 /* SATA */ 169#define CNS3XXX_SATA2_BASE 0x83000000 /* SATA */
171#define CNS3XXX_SATA2_SIZE SZ_16M 170#define CNS3XXX_SATA2_SIZE SZ_16M
@@ -184,7 +183,6 @@
184#define CNS3XXX_2DG_BASE_VIRT 0xFFF1B000 183#define CNS3XXX_2DG_BASE_VIRT 0xFFF1B000
185 184
186#define CNS3XXX_USB_OHCI_BASE 0x88000000 /* USB OHCI */ 185#define CNS3XXX_USB_OHCI_BASE 0x88000000 /* USB OHCI */
187#define CNS3XXX_USB_OHCI_BASE_VIRT 0xFFF1C000
188 186
189#define CNS3XXX_L2C_BASE 0x92000000 /* L2 Cache Control */ 187#define CNS3XXX_L2C_BASE 0x92000000 /* L2 Cache Control */
190#define CNS3XXX_L2C_BASE_VIRT 0xFFF27000 188#define CNS3XXX_L2C_BASE_VIRT 0xFFF27000
diff --git a/arch/arm/mach-cns3xxx/include/mach/pm.h b/arch/arm/mach-cns3xxx/include/mach/pm.h
new file mode 100644
index 000000000000..6eae7f764d1d
--- /dev/null
+++ b/arch/arm/mach-cns3xxx/include/mach/pm.h
@@ -0,0 +1,23 @@
1/*
2 * Copyright 2000 Deep Blue Solutions Ltd
3 * Copyright 2004 ARM Limited
4 * Copyright 2008 Cavium Networks
5 *
6 * This file is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, Version 2, as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __CNS3XXX_PM_H
12#define __CNS3XXX_PM_H
13
14#include <asm/atomic.h>
15
16void cns3xxx_pwr_clk_en(unsigned int block);
17void cns3xxx_pwr_clk_dis(unsigned int block);
18void cns3xxx_pwr_power_up(unsigned int block);
19void cns3xxx_pwr_power_down(unsigned int block);
20
21extern atomic_t usb_pwr_ref;
22
23#endif /* __CNS3XXX_PM_H */
diff --git a/arch/arm/mach-cns3xxx/pm.c b/arch/arm/mach-cns3xxx/pm.c
index 38e44706feab..5e579552aa54 100644
--- a/arch/arm/mach-cns3xxx/pm.c
+++ b/arch/arm/mach-cns3xxx/pm.c
@@ -6,10 +6,14 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#include <linux/init.h>
10#include <linux/module.h>
9#include <linux/io.h> 11#include <linux/io.h>
10#include <linux/delay.h> 12#include <linux/delay.h>
13#include <asm/atomic.h>
11#include <mach/system.h> 14#include <mach/system.h>
12#include <mach/cns3xxx.h> 15#include <mach/cns3xxx.h>
16#include <mach/pm.h>
13 17
14void cns3xxx_pwr_clk_en(unsigned int block) 18void cns3xxx_pwr_clk_en(unsigned int block)
15{ 19{
@@ -18,6 +22,16 @@ void cns3xxx_pwr_clk_en(unsigned int block)
18 reg |= (block & PM_CLK_GATE_REG_MASK); 22 reg |= (block & PM_CLK_GATE_REG_MASK);
19 __raw_writel(reg, PM_CLK_GATE_REG); 23 __raw_writel(reg, PM_CLK_GATE_REG);
20} 24}
25EXPORT_SYMBOL(cns3xxx_pwr_clk_en);
26
27void cns3xxx_pwr_clk_dis(unsigned int block)
28{
29 u32 reg = __raw_readl(PM_CLK_GATE_REG);
30
31 reg &= ~(block & PM_CLK_GATE_REG_MASK);
32 __raw_writel(reg, PM_CLK_GATE_REG);
33}
34EXPORT_SYMBOL(cns3xxx_pwr_clk_dis);
21 35
22void cns3xxx_pwr_power_up(unsigned int block) 36void cns3xxx_pwr_power_up(unsigned int block)
23{ 37{
@@ -29,6 +43,7 @@ void cns3xxx_pwr_power_up(unsigned int block)
29 /* Wait for 300us for the PLL output clock locked. */ 43 /* Wait for 300us for the PLL output clock locked. */
30 udelay(300); 44 udelay(300);
31}; 45};
46EXPORT_SYMBOL(cns3xxx_pwr_power_up);
32 47
33void cns3xxx_pwr_power_down(unsigned int block) 48void cns3xxx_pwr_power_down(unsigned int block)
34{ 49{
@@ -38,6 +53,7 @@ void cns3xxx_pwr_power_down(unsigned int block)
38 reg |= (block & CNS3XXX_PWR_PLL_ALL); 53 reg |= (block & CNS3XXX_PWR_PLL_ALL);
39 __raw_writel(reg, PM_PLL_HM_PD_CTRL_REG); 54 __raw_writel(reg, PM_PLL_HM_PD_CTRL_REG);
40}; 55};
56EXPORT_SYMBOL(cns3xxx_pwr_power_down);
41 57
42static void cns3xxx_pwr_soft_rst_force(unsigned int block) 58static void cns3xxx_pwr_soft_rst_force(unsigned int block)
43{ 59{
@@ -51,11 +67,13 @@ static void cns3xxx_pwr_soft_rst_force(unsigned int block)
51 reg &= ~(block & PM_SOFT_RST_REG_MASK); 67 reg &= ~(block & PM_SOFT_RST_REG_MASK);
52 } else { 68 } else {
53 reg &= ~(block & PM_SOFT_RST_REG_MASK); 69 reg &= ~(block & PM_SOFT_RST_REG_MASK);
70 __raw_writel(reg, PM_SOFT_RST_REG);
54 reg |= (block & PM_SOFT_RST_REG_MASK); 71 reg |= (block & PM_SOFT_RST_REG_MASK);
55 } 72 }
56 73
57 __raw_writel(reg, PM_SOFT_RST_REG); 74 __raw_writel(reg, PM_SOFT_RST_REG);
58} 75}
76EXPORT_SYMBOL(cns3xxx_pwr_soft_rst_force);
59 77
60void cns3xxx_pwr_soft_rst(unsigned int block) 78void cns3xxx_pwr_soft_rst(unsigned int block)
61{ 79{
@@ -69,6 +87,7 @@ void cns3xxx_pwr_soft_rst(unsigned int block)
69 } 87 }
70 cns3xxx_pwr_soft_rst_force(block); 88 cns3xxx_pwr_soft_rst_force(block);
71} 89}
90EXPORT_SYMBOL(cns3xxx_pwr_soft_rst);
72 91
73void arch_reset(char mode, const char *cmd) 92void arch_reset(char mode, const char *cmd)
74{ 93{
@@ -99,3 +118,7 @@ int cns3xxx_cpu_clock(void)
99 118
100 return cpu; 119 return cpu;
101} 120}
121EXPORT_SYMBOL(cns3xxx_cpu_clock);
122
123atomic_t usb_pwr_ref = ATOMIC_INIT(0);
124EXPORT_SYMBOL(usb_pwr_ref);
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 67eb3770868f..5a7c8f1d76c6 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -41,6 +41,7 @@ config USB_ARCH_HAS_OHCI
41 default y if MFD_TC6393XB 41 default y if MFD_TC6393XB
42 default y if ARCH_W90X900 42 default y if ARCH_W90X900
43 default y if ARCH_DAVINCI_DA8XX 43 default y if ARCH_DAVINCI_DA8XX
44 default y if ARCH_CNS3XXX
44 # PPC: 45 # PPC:
45 default y if STB03xxx 46 default y if STB03xxx
46 default y if PPC_MPC52xx 47 default y if PPC_MPC52xx
@@ -66,6 +67,7 @@ config USB_ARCH_HAS_EHCI
66 default y if ARCH_AT91SAM9G45 67 default y if ARCH_AT91SAM9G45
67 default y if ARCH_MXC 68 default y if ARCH_MXC
68 default y if ARCH_OMAP3 69 default y if ARCH_OMAP3
70 default y if ARCH_CNS3XXX
69 default PCI 71 default PCI
70 72
71# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. 73# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 6f4f8e6a40c7..f8970d151d2a 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -147,6 +147,14 @@ config USB_W90X900_EHCI
147 ---help--- 147 ---help---
148 Enables support for the W90X900 USB controller 148 Enables support for the W90X900 USB controller
149 149
150config USB_CNS3XXX_EHCI
151 bool "Cavium CNS3XXX EHCI Module"
152 depends on USB_EHCI_HCD && ARCH_CNS3XXX
153 ---help---
154 Enable support for the CNS3XXX SOC's on-chip EHCI controller.
155 It is needed for high-speed (480Mbit/sec) USB 2.0 device
156 support.
157
150config USB_OXU210HP_HCD 158config USB_OXU210HP_HCD
151 tristate "OXU210HP HCD support" 159 tristate "OXU210HP HCD support"
152 depends on USB 160 depends on USB
@@ -286,6 +294,13 @@ config USB_OHCI_HCD_SSB
286 294
287 If unsure, say N. 295 If unsure, say N.
288 296
297config USB_CNS3XXX_OHCI
298 bool "Cavium CNS3XXX OHCI Module"
299 depends on USB_OHCI_HCD && ARCH_CNS3XXX
300 ---help---
301 Enable support for the CNS3XXX SOC's on-chip OHCI controller.
302 It is needed for low-speed USB 1.0 device support.
303
289config USB_OHCI_BIG_ENDIAN_DESC 304config USB_OHCI_BIG_ENDIAN_DESC
290 bool 305 bool
291 depends on USB_OHCI_HCD 306 depends on USB_OHCI_HCD
diff --git a/drivers/usb/host/ehci-cns3xxx.c b/drivers/usb/host/ehci-cns3xxx.c
new file mode 100644
index 000000000000..708a05b5d258
--- /dev/null
+++ b/drivers/usb/host/ehci-cns3xxx.c
@@ -0,0 +1,171 @@
1/*
2 * Copyright 2008 Cavium Networks
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, Version 2, as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/platform_device.h>
10#include <linux/atomic.h>
11#include <mach/cns3xxx.h>
12#include <mach/pm.h>
13
14static int cns3xxx_ehci_init(struct usb_hcd *hcd)
15{
16 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
17 int retval;
18
19 /*
20 * EHCI and OHCI share the same clock and power,
21 * resetting twice would cause the 1st controller been reset.
22 * Therefore only do power up at the first up device, and
23 * power down at the last down device.
24 *
25 * Set USB AHB INCR length to 16
26 */
27 if (atomic_inc_return(&usb_pwr_ref) == 1) {
28 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
29 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
30 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
31 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
32 MISC_CHIP_CONFIG_REG);
33 }
34
35 ehci->caps = hcd->regs;
36 ehci->regs = hcd->regs
37 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
38 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
39
40 hcd->has_tt = 0;
41 ehci_reset(ehci);
42
43 retval = ehci_init(hcd);
44 if (retval)
45 return retval;
46
47 ehci_port_power(ehci, 0);
48
49 return retval;
50}
51
52static const struct hc_driver cns3xxx_ehci_hc_driver = {
53 .description = hcd_name,
54 .product_desc = "CNS3XXX EHCI Host Controller",
55 .hcd_priv_size = sizeof(struct ehci_hcd),
56 .irq = ehci_irq,
57 .flags = HCD_MEMORY | HCD_USB2,
58 .reset = cns3xxx_ehci_init,
59 .start = ehci_run,
60 .stop = ehci_stop,
61 .shutdown = ehci_shutdown,
62 .urb_enqueue = ehci_urb_enqueue,
63 .urb_dequeue = ehci_urb_dequeue,
64 .endpoint_disable = ehci_endpoint_disable,
65 .endpoint_reset = ehci_endpoint_reset,
66 .get_frame_number = ehci_get_frame,
67 .hub_status_data = ehci_hub_status_data,
68 .hub_control = ehci_hub_control,
69#ifdef CONFIG_PM
70 .bus_suspend = ehci_bus_suspend,
71 .bus_resume = ehci_bus_resume,
72#endif
73 .relinquish_port = ehci_relinquish_port,
74 .port_handed_over = ehci_port_handed_over,
75
76 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
77};
78
79static int cns3xxx_ehci_probe(struct platform_device *pdev)
80{
81 struct device *dev = &pdev->dev;
82 struct usb_hcd *hcd;
83 const struct hc_driver *driver = &cns3xxx_ehci_hc_driver;
84 struct resource *res;
85 int irq;
86 int retval;
87
88 if (usb_disabled())
89 return -ENODEV;
90
91 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
92 if (!res) {
93 dev_err(dev, "Found HC with no IRQ.\n");
94 return -ENODEV;
95 }
96 irq = res->start;
97
98 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
99 if (!hcd)
100 return -ENOMEM;
101
102 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
103 if (!res) {
104 dev_err(dev, "Found HC with no register addr.\n");
105 retval = -ENODEV;
106 goto err1;
107 }
108
109 hcd->rsrc_start = res->start;
110 hcd->rsrc_len = res->end - res->start + 1;
111
112 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
113 driver->description)) {
114 dev_dbg(dev, "controller already in use\n");
115 retval = -EBUSY;
116 goto err1;
117 }
118
119 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
120 if (hcd->regs == NULL) {
121 dev_dbg(dev, "error mapping memory\n");
122 retval = -EFAULT;
123 goto err2;
124 }
125
126 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
127 if (retval == 0)
128 return retval;
129
130 iounmap(hcd->regs);
131err2:
132 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
133err1:
134 usb_put_hcd(hcd);
135
136 return retval;
137}
138
139static int cns3xxx_ehci_remove(struct platform_device *pdev)
140{
141 struct usb_hcd *hcd = platform_get_drvdata(pdev);
142
143 usb_remove_hcd(hcd);
144 iounmap(hcd->regs);
145 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
146
147 /*
148 * EHCI and OHCI share the same clock and power,
149 * resetting twice would cause the 1st controller been reset.
150 * Therefore only do power up at the first up device, and
151 * power down at the last down device.
152 */
153 if (atomic_dec_return(&usb_pwr_ref) == 0)
154 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
155
156 usb_put_hcd(hcd);
157
158 platform_set_drvdata(pdev, NULL);
159
160 return 0;
161}
162
163MODULE_ALIAS("platform:cns3xxx-ehci");
164
165static struct platform_driver cns3xxx_ehci_driver = {
166 .probe = cns3xxx_ehci_probe,
167 .remove = cns3xxx_ehci_remove,
168 .driver = {
169 .name = "cns3xxx-ehci",
170 },
171};
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index e9062806d4a2..d0c8f7c03e05 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1216,6 +1216,11 @@ MODULE_LICENSE ("GPL");
1216#define PLATFORM_DRIVER ehci_octeon_driver 1216#define PLATFORM_DRIVER ehci_octeon_driver
1217#endif 1217#endif
1218 1218
1219#ifdef CONFIG_USB_CNS3XXX_EHCI
1220#include "ehci-cns3xxx.c"
1221#define PLATFORM_DRIVER cns3xxx_ehci_driver
1222#endif
1223
1219#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1224#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
1220 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ 1225 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
1221 !defined(XILINX_OF_PLATFORM_DRIVER) 1226 !defined(XILINX_OF_PLATFORM_DRIVER)
diff --git a/drivers/usb/host/ohci-cns3xxx.c b/drivers/usb/host/ohci-cns3xxx.c
new file mode 100644
index 000000000000..f05ef87e934c
--- /dev/null
+++ b/drivers/usb/host/ohci-cns3xxx.c
@@ -0,0 +1,165 @@
1/*
2 * Copyright 2008 Cavium Networks
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, Version 2, as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/platform_device.h>
10#include <linux/atomic.h>
11#include <mach/cns3xxx.h>
12#include <mach/pm.h>
13
14static int __devinit
15cns3xxx_ohci_start(struct usb_hcd *hcd)
16{
17 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
18 int ret;
19
20 /*
21 * EHCI and OHCI share the same clock and power,
22 * resetting twice would cause the 1st controller been reset.
23 * Therefore only do power up at the first up device, and
24 * power down at the last down device.
25 *
26 * Set USB AHB INCR length to 16
27 */
28 if (atomic_inc_return(&usb_pwr_ref) == 1) {
29 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
30 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
31 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
32 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
33 MISC_CHIP_CONFIG_REG);
34 }
35
36 ret = ohci_init(ohci);
37 if (ret < 0)
38 return ret;
39
40 ohci->num_ports = 1;
41
42 ret = ohci_run(ohci);
43 if (ret < 0) {
44 err("can't start %s", hcd->self.bus_name);
45 ohci_stop(hcd);
46 return ret;
47 }
48 return 0;
49}
50
51static const struct hc_driver cns3xxx_ohci_hc_driver = {
52 .description = hcd_name,
53 .product_desc = "CNS3XXX OHCI Host controller",
54 .hcd_priv_size = sizeof(struct ohci_hcd),
55 .irq = ohci_irq,
56 .flags = HCD_USB11 | HCD_MEMORY,
57 .start = cns3xxx_ohci_start,
58 .stop = ohci_stop,
59 .shutdown = ohci_shutdown,
60 .urb_enqueue = ohci_urb_enqueue,
61 .urb_dequeue = ohci_urb_dequeue,
62 .endpoint_disable = ohci_endpoint_disable,
63 .get_frame_number = ohci_get_frame,
64 .hub_status_data = ohci_hub_status_data,
65 .hub_control = ohci_hub_control,
66#ifdef CONFIG_PM
67 .bus_suspend = ohci_bus_suspend,
68 .bus_resume = ohci_bus_resume,
69#endif
70 .start_port_reset = ohci_start_port_reset,
71};
72
73static int cns3xxx_ohci_probe(struct platform_device *pdev)
74{
75 struct device *dev = &pdev->dev;
76 struct usb_hcd *hcd;
77 const struct hc_driver *driver = &cns3xxx_ohci_hc_driver;
78 struct resource *res;
79 int irq;
80 int retval;
81
82 if (usb_disabled())
83 return -ENODEV;
84
85 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
86 if (!res) {
87 dev_err(dev, "Found HC with no IRQ.\n");
88 return -ENODEV;
89 }
90 irq = res->start;
91
92 hcd = usb_create_hcd(driver, dev, dev_name(dev));
93 if (!hcd)
94 return -ENOMEM;
95
96 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
97 if (!res) {
98 dev_err(dev, "Found HC with no register addr.\n");
99 retval = -ENODEV;
100 goto err1;
101 }
102 hcd->rsrc_start = res->start;
103 hcd->rsrc_len = res->end - res->start + 1;
104
105 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
106 driver->description)) {
107 dev_dbg(dev, "controller already in use\n");
108 retval = -EBUSY;
109 goto err1;
110 }
111
112 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
113 if (!hcd->regs) {
114 dev_dbg(dev, "error mapping memory\n");
115 retval = -EFAULT;
116 goto err2;
117 }
118
119 ohci_hcd_init(hcd_to_ohci(hcd));
120
121 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
122 if (retval == 0)
123 return retval;
124
125 iounmap(hcd->regs);
126err2:
127 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
128err1:
129 usb_put_hcd(hcd);
130 return retval;
131}
132
133static int cns3xxx_ohci_remove(struct platform_device *pdev)
134{
135 struct usb_hcd *hcd = platform_get_drvdata(pdev);
136
137 usb_remove_hcd(hcd);
138 iounmap(hcd->regs);
139 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
140
141 /*
142 * EHCI and OHCI share the same clock and power,
143 * resetting twice would cause the 1st controller been reset.
144 * Therefore only do power up at the first up device, and
145 * power down at the last down device.
146 */
147 if (atomic_dec_return(&usb_pwr_ref) == 0)
148 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
149
150 usb_put_hcd(hcd);
151
152 platform_set_drvdata(pdev, NULL);
153
154 return 0;
155}
156
157MODULE_ALIAS("platform:cns3xxx-ohci");
158
159static struct platform_driver ohci_hcd_cns3xxx_driver = {
160 .probe = cns3xxx_ohci_probe,
161 .remove = cns3xxx_ohci_remove,
162 .driver = {
163 .name = "cns3xxx-ohci",
164 },
165};
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 5179acb7aa2f..5cb6731ba443 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1111,6 +1111,11 @@ MODULE_LICENSE ("GPL");
1111#define PLATFORM_DRIVER ohci_octeon_driver 1111#define PLATFORM_DRIVER ohci_octeon_driver
1112#endif 1112#endif
1113 1113
1114#ifdef CONFIG_USB_CNS3XXX_OHCI
1115#include "ohci-cns3xxx.c"
1116#define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver
1117#endif
1118
1114#if !defined(PCI_DRIVER) && \ 1119#if !defined(PCI_DRIVER) && \
1115 !defined(PLATFORM_DRIVER) && \ 1120 !defined(PLATFORM_DRIVER) && \
1116 !defined(OMAP1_PLATFORM_DRIVER) && \ 1121 !defined(OMAP1_PLATFORM_DRIVER) && \