diff options
-rw-r--r-- | arch/mips/ath79/dev-usb.c | 111 |
1 files changed, 51 insertions, 60 deletions
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c index bcb165b17cae..02124d02cf6e 100644 --- a/arch/mips/ath79/dev-usb.c +++ b/arch/mips/ath79/dev-usb.c | |||
@@ -25,29 +25,11 @@ | |||
25 | #include "common.h" | 25 | #include "common.h" |
26 | #include "dev-usb.h" | 26 | #include "dev-usb.h" |
27 | 27 | ||
28 | static struct resource ath79_ohci_resources[2]; | 28 | static u64 ath79_usb_dmamask = DMA_BIT_MASK(32); |
29 | |||
30 | static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32); | ||
31 | 29 | ||
32 | static struct usb_ohci_pdata ath79_ohci_pdata = { | 30 | static struct usb_ohci_pdata ath79_ohci_pdata = { |
33 | }; | 31 | }; |
34 | 32 | ||
35 | static struct platform_device ath79_ohci_device = { | ||
36 | .name = "ohci-platform", | ||
37 | .id = -1, | ||
38 | .resource = ath79_ohci_resources, | ||
39 | .num_resources = ARRAY_SIZE(ath79_ohci_resources), | ||
40 | .dev = { | ||
41 | .dma_mask = &ath79_ohci_dmamask, | ||
42 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
43 | .platform_data = &ath79_ohci_pdata, | ||
44 | }, | ||
45 | }; | ||
46 | |||
47 | static struct resource ath79_ehci_resources[2]; | ||
48 | |||
49 | static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32); | ||
50 | |||
51 | static struct usb_ehci_pdata ath79_ehci_pdata_v1 = { | 33 | static struct usb_ehci_pdata ath79_ehci_pdata_v1 = { |
52 | .has_synopsys_hc_bug = 1, | 34 | .has_synopsys_hc_bug = 1, |
53 | }; | 35 | }; |
@@ -57,22 +39,16 @@ static struct usb_ehci_pdata ath79_ehci_pdata_v2 = { | |||
57 | .has_tt = 1, | 39 | .has_tt = 1, |
58 | }; | 40 | }; |
59 | 41 | ||
60 | static struct platform_device ath79_ehci_device = { | 42 | static void __init ath79_usb_register(const char *name, int id, |
61 | .name = "ehci-platform", | 43 | unsigned long base, unsigned long size, |
62 | .id = -1, | 44 | int irq, const void *data, |
63 | .resource = ath79_ehci_resources, | 45 | size_t data_size) |
64 | .num_resources = ARRAY_SIZE(ath79_ehci_resources), | ||
65 | .dev = { | ||
66 | .dma_mask = &ath79_ehci_dmamask, | ||
67 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
68 | }, | ||
69 | }; | ||
70 | |||
71 | static void __init ath79_usb_init_resource(struct resource res[2], | ||
72 | unsigned long base, | ||
73 | unsigned long size, | ||
74 | int irq) | ||
75 | { | 46 | { |
47 | struct resource res[2]; | ||
48 | struct platform_device *pdev; | ||
49 | |||
50 | memset(res, 0, sizeof(res)); | ||
51 | |||
76 | res[0].flags = IORESOURCE_MEM; | 52 | res[0].flags = IORESOURCE_MEM; |
77 | res[0].start = base; | 53 | res[0].start = base; |
78 | res[0].end = base + size - 1; | 54 | res[0].end = base + size - 1; |
@@ -80,6 +56,19 @@ static void __init ath79_usb_init_resource(struct resource res[2], | |||
80 | res[1].flags = IORESOURCE_IRQ; | 56 | res[1].flags = IORESOURCE_IRQ; |
81 | res[1].start = irq; | 57 | res[1].start = irq; |
82 | res[1].end = irq; | 58 | res[1].end = irq; |
59 | |||
60 | pdev = platform_device_register_resndata(NULL, name, id, | ||
61 | res, ARRAY_SIZE(res), | ||
62 | data, data_size); | ||
63 | |||
64 | if (IS_ERR(pdev)) { | ||
65 | pr_err("ath79: unable to register USB at %08lx, err=%d\n", | ||
66 | base, (int) PTR_ERR(pdev)); | ||
67 | return; | ||
68 | } | ||
69 | |||
70 | pdev->dev.dma_mask = &ath79_usb_dmamask; | ||
71 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
83 | } | 72 | } |
84 | 73 | ||
85 | #define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \ | 74 | #define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \ |
@@ -106,14 +95,15 @@ static void __init ath79_usb_setup(void) | |||
106 | 95 | ||
107 | mdelay(900); | 96 | mdelay(900); |
108 | 97 | ||
109 | ath79_usb_init_resource(ath79_ohci_resources, AR71XX_OHCI_BASE, | 98 | ath79_usb_register("ohci-platform", -1, |
110 | AR71XX_OHCI_SIZE, ATH79_MISC_IRQ(6)); | 99 | AR71XX_OHCI_BASE, AR71XX_OHCI_SIZE, |
111 | platform_device_register(&ath79_ohci_device); | 100 | ATH79_MISC_IRQ(6), |
101 | &ath79_ohci_pdata, sizeof(ath79_ohci_pdata)); | ||
112 | 102 | ||
113 | ath79_usb_init_resource(ath79_ehci_resources, AR71XX_EHCI_BASE, | 103 | ath79_usb_register("ehci-platform", -1, |
114 | AR71XX_EHCI_SIZE, ATH79_CPU_IRQ(3)); | 104 | AR71XX_EHCI_BASE, AR71XX_EHCI_SIZE, |
115 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1; | 105 | ATH79_CPU_IRQ(3), |
116 | platform_device_register(&ath79_ehci_device); | 106 | &ath79_ehci_pdata_v1, sizeof(ath79_ehci_pdata_v1)); |
117 | } | 107 | } |
118 | 108 | ||
119 | static void __init ar7240_usb_setup(void) | 109 | static void __init ar7240_usb_setup(void) |
@@ -135,9 +125,10 @@ static void __init ar7240_usb_setup(void) | |||
135 | 125 | ||
136 | iounmap(usb_ctrl_base); | 126 | iounmap(usb_ctrl_base); |
137 | 127 | ||
138 | ath79_usb_init_resource(ath79_ohci_resources, AR7240_OHCI_BASE, | 128 | ath79_usb_register("ohci-platform", -1, |
139 | AR7240_OHCI_SIZE, ATH79_CPU_IRQ(3)); | 129 | AR7240_OHCI_BASE, AR7240_OHCI_SIZE, |
140 | platform_device_register(&ath79_ohci_device); | 130 | ATH79_CPU_IRQ(3), |
131 | &ath79_ohci_pdata, sizeof(ath79_ohci_pdata)); | ||
141 | } | 132 | } |
142 | 133 | ||
143 | static void __init ar724x_usb_setup(void) | 134 | static void __init ar724x_usb_setup(void) |
@@ -151,10 +142,10 @@ static void __init ar724x_usb_setup(void) | |||
151 | ath79_device_reset_clear(AR724X_RESET_USB_PHY); | 142 | ath79_device_reset_clear(AR724X_RESET_USB_PHY); |
152 | mdelay(10); | 143 | mdelay(10); |
153 | 144 | ||
154 | ath79_usb_init_resource(ath79_ehci_resources, AR724X_EHCI_BASE, | 145 | ath79_usb_register("ehci-platform", -1, |
155 | AR724X_EHCI_SIZE, ATH79_CPU_IRQ(3)); | 146 | AR724X_EHCI_BASE, AR724X_EHCI_SIZE, |
156 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 147 | ATH79_CPU_IRQ(3), |
157 | platform_device_register(&ath79_ehci_device); | 148 | &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2)); |
158 | } | 149 | } |
159 | 150 | ||
160 | static void __init ar913x_usb_setup(void) | 151 | static void __init ar913x_usb_setup(void) |
@@ -168,10 +159,10 @@ static void __init ar913x_usb_setup(void) | |||
168 | ath79_device_reset_clear(AR913X_RESET_USB_PHY); | 159 | ath79_device_reset_clear(AR913X_RESET_USB_PHY); |
169 | mdelay(10); | 160 | mdelay(10); |
170 | 161 | ||
171 | ath79_usb_init_resource(ath79_ehci_resources, AR913X_EHCI_BASE, | 162 | ath79_usb_register("ehci-platform", -1, |
172 | AR913X_EHCI_SIZE, ATH79_CPU_IRQ(3)); | 163 | AR913X_EHCI_BASE, AR913X_EHCI_SIZE, |
173 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 164 | ATH79_CPU_IRQ(3), |
174 | platform_device_register(&ath79_ehci_device); | 165 | &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2)); |
175 | } | 166 | } |
176 | 167 | ||
177 | static void __init ar933x_usb_setup(void) | 168 | static void __init ar933x_usb_setup(void) |
@@ -185,10 +176,10 @@ static void __init ar933x_usb_setup(void) | |||
185 | ath79_device_reset_clear(AR933X_RESET_USB_PHY); | 176 | ath79_device_reset_clear(AR933X_RESET_USB_PHY); |
186 | mdelay(10); | 177 | mdelay(10); |
187 | 178 | ||
188 | ath79_usb_init_resource(ath79_ehci_resources, AR933X_EHCI_BASE, | 179 | ath79_usb_register("ehci-platform", -1, |
189 | AR933X_EHCI_SIZE, ATH79_CPU_IRQ(3)); | 180 | AR933X_EHCI_BASE, AR933X_EHCI_SIZE, |
190 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 181 | ATH79_CPU_IRQ(3), |
191 | platform_device_register(&ath79_ehci_device); | 182 | &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2)); |
192 | } | 183 | } |
193 | 184 | ||
194 | static void __init ar934x_usb_setup(void) | 185 | static void __init ar934x_usb_setup(void) |
@@ -211,10 +202,10 @@ static void __init ar934x_usb_setup(void) | |||
211 | ath79_device_reset_clear(AR934X_RESET_USB_HOST); | 202 | ath79_device_reset_clear(AR934X_RESET_USB_HOST); |
212 | udelay(1000); | 203 | udelay(1000); |
213 | 204 | ||
214 | ath79_usb_init_resource(ath79_ehci_resources, AR934X_EHCI_BASE, | 205 | ath79_usb_register("ehci-platform", -1, |
215 | AR934X_EHCI_SIZE, ATH79_CPU_IRQ(3)); | 206 | AR934X_EHCI_BASE, AR934X_EHCI_SIZE, |
216 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 207 | ATH79_CPU_IRQ(3), |
217 | platform_device_register(&ath79_ehci_device); | 208 | &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2)); |
218 | } | 209 | } |
219 | 210 | ||
220 | void __init ath79_register_usb(void) | 211 | void __init ath79_register_usb(void) |