diff options
-rw-r--r-- | arch/mips/cavium-octeon/octeon-platform.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index febfdd73309f..cfdb4c2ac5c3 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c | |||
@@ -189,6 +189,64 @@ out: | |||
189 | } | 189 | } |
190 | device_initcall(octeon_mdiobus_device_init); | 190 | device_initcall(octeon_mdiobus_device_init); |
191 | 191 | ||
192 | /* Octeon mgmt port Ethernet interface. */ | ||
193 | static int __init octeon_mgmt_device_init(void) | ||
194 | { | ||
195 | struct platform_device *pd; | ||
196 | int ret = 0; | ||
197 | int port, num_ports; | ||
198 | |||
199 | struct resource mgmt_port_resource = { | ||
200 | .flags = IORESOURCE_IRQ, | ||
201 | .start = -1, | ||
202 | .end = -1 | ||
203 | }; | ||
204 | |||
205 | if (!OCTEON_IS_MODEL(OCTEON_CN56XX) && !OCTEON_IS_MODEL(OCTEON_CN52XX)) | ||
206 | return 0; | ||
207 | |||
208 | if (OCTEON_IS_MODEL(OCTEON_CN56XX)) | ||
209 | num_ports = 1; | ||
210 | else | ||
211 | num_ports = 2; | ||
212 | |||
213 | for (port = 0; port < num_ports; port++) { | ||
214 | pd = platform_device_alloc("octeon_mgmt", port); | ||
215 | if (!pd) { | ||
216 | ret = -ENOMEM; | ||
217 | goto out; | ||
218 | } | ||
219 | switch (port) { | ||
220 | case 0: | ||
221 | mgmt_port_resource.start = OCTEON_IRQ_MII0; | ||
222 | break; | ||
223 | case 1: | ||
224 | mgmt_port_resource.start = OCTEON_IRQ_MII1; | ||
225 | break; | ||
226 | default: | ||
227 | BUG(); | ||
228 | } | ||
229 | mgmt_port_resource.end = mgmt_port_resource.start; | ||
230 | |||
231 | ret = platform_device_add_resources(pd, &mgmt_port_resource, 1); | ||
232 | |||
233 | if (ret) | ||
234 | goto fail; | ||
235 | |||
236 | ret = platform_device_add(pd); | ||
237 | if (ret) | ||
238 | goto fail; | ||
239 | } | ||
240 | return ret; | ||
241 | fail: | ||
242 | platform_device_put(pd); | ||
243 | |||
244 | out: | ||
245 | return ret; | ||
246 | |||
247 | } | ||
248 | device_initcall(octeon_mgmt_device_init); | ||
249 | |||
192 | MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>"); | 250 | MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>"); |
193 | MODULE_LICENSE("GPL"); | 251 | MODULE_LICENSE("GPL"); |
194 | MODULE_DESCRIPTION("Platform driver for Octeon SOC"); | 252 | MODULE_DESCRIPTION("Platform driver for Octeon SOC"); |