diff options
Diffstat (limited to 'arch/powerpc/sysdev/mv64x60_dev.c')
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_dev.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c index 0ccc495340bb..4b0a9c88eeb3 100644 --- a/arch/powerpc/sysdev/mv64x60_dev.c +++ b/arch/powerpc/sysdev/mv64x60_dev.c | |||
@@ -323,6 +323,72 @@ error: | |||
323 | return err; | 323 | return err; |
324 | } | 324 | } |
325 | 325 | ||
326 | /* | ||
327 | * Create mv64x60_i2c platform devices | ||
328 | */ | ||
329 | static int __init mv64x60_i2c_device_setup(struct device_node *np, int id) | ||
330 | { | ||
331 | struct resource r[2]; | ||
332 | struct platform_device *pdev; | ||
333 | struct mv64xxx_i2c_pdata pdata; | ||
334 | const unsigned int *prop; | ||
335 | int err; | ||
336 | |||
337 | memset(r, 0, sizeof(r)); | ||
338 | |||
339 | err = of_address_to_resource(np, 0, &r[0]); | ||
340 | if (err) | ||
341 | return err; | ||
342 | |||
343 | of_irq_to_resource(np, 0, &r[1]); | ||
344 | |||
345 | memset(&pdata, 0, sizeof(pdata)); | ||
346 | |||
347 | prop = of_get_property(np, "freq_m", NULL); | ||
348 | if (!prop) | ||
349 | return -ENODEV; | ||
350 | pdata.freq_m = *prop; | ||
351 | |||
352 | prop = of_get_property(np, "freq_n", NULL); | ||
353 | if (!prop) | ||
354 | return -ENODEV; | ||
355 | pdata.freq_n = *prop; | ||
356 | |||
357 | prop = of_get_property(np, "timeout", NULL); | ||
358 | if (prop) | ||
359 | pdata.timeout = *prop; | ||
360 | else | ||
361 | pdata.timeout = 1000; /* 1 second */ | ||
362 | |||
363 | prop = of_get_property(np, "retries", NULL); | ||
364 | if (prop) | ||
365 | pdata.retries = *prop; | ||
366 | else | ||
367 | pdata.retries = 1; | ||
368 | |||
369 | pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, id); | ||
370 | if (!pdev) | ||
371 | return -ENOMEM; | ||
372 | |||
373 | err = platform_device_add_resources(pdev, r, 2); | ||
374 | if (err) | ||
375 | goto error; | ||
376 | |||
377 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); | ||
378 | if (err) | ||
379 | goto error; | ||
380 | |||
381 | err = platform_device_add(pdev); | ||
382 | if (err) | ||
383 | goto error; | ||
384 | |||
385 | return 0; | ||
386 | |||
387 | error: | ||
388 | platform_device_put(pdev); | ||
389 | return err; | ||
390 | } | ||
391 | |||
326 | static int __init mv64x60_device_setup(void) | 392 | static int __init mv64x60_device_setup(void) |
327 | { | 393 | { |
328 | struct device_node *np = NULL; | 394 | struct device_node *np = NULL; |
@@ -341,6 +407,12 @@ static int __init mv64x60_device_setup(void) | |||
341 | if ((err = mv64x60_eth_device_setup(np, id))) | 407 | if ((err = mv64x60_eth_device_setup(np, id))) |
342 | goto error; | 408 | goto error; |
343 | 409 | ||
410 | for (id = 0; | ||
411 | (np = of_find_compatible_node(np, "i2c", "marvell,mv64x60-i2c")); | ||
412 | id++) | ||
413 | if ((err = mv64x60_i2c_device_setup(np, id))) | ||
414 | goto error; | ||
415 | |||
344 | return 0; | 416 | return 0; |
345 | 417 | ||
346 | error: | 418 | error: |