diff options
Diffstat (limited to 'arch/powerpc/sysdev/mv64x60_dev.c')
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_dev.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c index b618fa60aef3..548a32082e4a 100644 --- a/arch/powerpc/sysdev/mv64x60_dev.c +++ b/arch/powerpc/sysdev/mv64x60_dev.c | |||
@@ -390,6 +390,61 @@ error: | |||
390 | return err; | 390 | return err; |
391 | } | 391 | } |
392 | 392 | ||
393 | /* | ||
394 | * Create mv64x60_wdt platform devices | ||
395 | */ | ||
396 | static int __init mv64x60_wdt_device_setup(struct device_node *np, int id) | ||
397 | { | ||
398 | struct resource r; | ||
399 | struct platform_device *pdev; | ||
400 | struct mv64x60_wdt_pdata pdata; | ||
401 | const unsigned int *prop; | ||
402 | int err; | ||
403 | |||
404 | err = of_address_to_resource(np, 0, &r); | ||
405 | if (err) | ||
406 | return err; | ||
407 | |||
408 | memset(&pdata, 0, sizeof(pdata)); | ||
409 | |||
410 | prop = of_get_property(np, "timeout", NULL); | ||
411 | if (!prop) | ||
412 | return -ENODEV; | ||
413 | pdata.timeout = *prop; | ||
414 | |||
415 | np = of_get_parent(np); | ||
416 | if (!np) | ||
417 | return -ENODEV; | ||
418 | |||
419 | prop = of_get_property(np, "clock-frequency", NULL); | ||
420 | of_node_put(np); | ||
421 | if (!prop) | ||
422 | return -ENODEV; | ||
423 | pdata.bus_clk = *prop / 1000000; /* wdt driver wants freq in MHz */ | ||
424 | |||
425 | pdev = platform_device_alloc(MV64x60_WDT_NAME, id); | ||
426 | if (!pdev) | ||
427 | return -ENOMEM; | ||
428 | |||
429 | err = platform_device_add_resources(pdev, &r, 1); | ||
430 | if (err) | ||
431 | goto error; | ||
432 | |||
433 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); | ||
434 | if (err) | ||
435 | goto error; | ||
436 | |||
437 | err = platform_device_add(pdev); | ||
438 | if (err) | ||
439 | goto error; | ||
440 | |||
441 | return 0; | ||
442 | |||
443 | error: | ||
444 | platform_device_put(pdev); | ||
445 | return err; | ||
446 | } | ||
447 | |||
393 | static int __init mv64x60_device_setup(void) | 448 | static int __init mv64x60_device_setup(void) |
394 | { | 449 | { |
395 | struct device_node *np = NULL; | 450 | struct device_node *np = NULL; |
@@ -414,6 +469,15 @@ static int __init mv64x60_device_setup(void) | |||
414 | if ((err = mv64x60_i2c_device_setup(np, id))) | 469 | if ((err = mv64x60_i2c_device_setup(np, id))) |
415 | goto error; | 470 | goto error; |
416 | 471 | ||
472 | /* support up to one watchdog timer */ | ||
473 | np = of_find_compatible_node(np, NULL, "marvell,mv64x60-wdt"); | ||
474 | if (np) { | ||
475 | if ((err = mv64x60_wdt_device_setup(np, id))) | ||
476 | goto error; | ||
477 | of_node_put(np); | ||
478 | } | ||
479 | |||
480 | |||
417 | return 0; | 481 | return 0; |
418 | 482 | ||
419 | error: | 483 | error: |