aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/cavium-octeon/octeon-platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/cavium-octeon/octeon-platform.c')
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index be711dd2d918..cfdb4c2ac5c3 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -159,6 +159,94 @@ out:
159} 159}
160device_initcall(octeon_rng_device_init); 160device_initcall(octeon_rng_device_init);
161 161
162/* Octeon SMI/MDIO interface. */
163static int __init octeon_mdiobus_device_init(void)
164{
165 struct platform_device *pd;
166 int ret = 0;
167
168 if (octeon_is_simulation())
169 return 0; /* No mdio in the simulator. */
170
171 /* The bus number is the platform_device id. */
172 pd = platform_device_alloc("mdio-octeon", 0);
173 if (!pd) {
174 ret = -ENOMEM;
175 goto out;
176 }
177
178 ret = platform_device_add(pd);
179 if (ret)
180 goto fail;
181
182 return ret;
183fail:
184 platform_device_put(pd);
185
186out:
187 return ret;
188
189}
190device_initcall(octeon_mdiobus_device_init);
191
192/* Octeon mgmt port Ethernet interface. */
193static 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;
241fail:
242 platform_device_put(pd);
243
244out:
245 return ret;
246
247}
248device_initcall(octeon_mgmt_device_init);
249
162MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>"); 250MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
163MODULE_LICENSE("GPL"); 251MODULE_LICENSE("GPL");
164MODULE_DESCRIPTION("Platform driver for Octeon SOC"); 252MODULE_DESCRIPTION("Platform driver for Octeon SOC");