diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-24 20:11:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-05-20 09:13:36 -0400 |
commit | d781009ca6bb5b9711c74700242855e0a70ee7a3 (patch) | |
tree | 310ac48498eaca141f5643803bebe21383dca965 /drivers/mfd/arizona-core.c | |
parent | 67c992969172473e129984a51ceb77950a2aa16c (diff) |
mfd: Add device tree bindings for Arizona class devices
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/mfd/arizona-core.c')
-rw-r--r-- | drivers/mfd/arizona-core.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 549db0ad7257..d8d30c0a488d 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -16,6 +16,9 @@ | |||
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | #include <linux/mfd/core.h> | 17 | #include <linux/mfd/core.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/of.h> | ||
20 | #include <linux/of_device.h> | ||
21 | #include <linux/of_gpio.h> | ||
19 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
20 | #include <linux/regmap.h> | 23 | #include <linux/regmap.h> |
21 | #include <linux/regulator/consumer.h> | 24 | #include <linux/regulator/consumer.h> |
@@ -462,6 +465,70 @@ const struct dev_pm_ops arizona_pm_ops = { | |||
462 | }; | 465 | }; |
463 | EXPORT_SYMBOL_GPL(arizona_pm_ops); | 466 | EXPORT_SYMBOL_GPL(arizona_pm_ops); |
464 | 467 | ||
468 | #ifdef CONFIG_OF | ||
469 | int arizona_of_get_type(struct device *dev) | ||
470 | { | ||
471 | const struct of_device_id *id = of_match_device(arizona_of_match, dev); | ||
472 | |||
473 | if (id) | ||
474 | return (int)id->data; | ||
475 | else | ||
476 | return 0; | ||
477 | } | ||
478 | EXPORT_SYMBOL_GPL(arizona_of_get_type); | ||
479 | |||
480 | static int arizona_of_get_core_pdata(struct arizona *arizona) | ||
481 | { | ||
482 | int ret, i; | ||
483 | |||
484 | arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node, | ||
485 | "wlf,reset", 0); | ||
486 | if (arizona->pdata.reset < 0) | ||
487 | arizona->pdata.reset = 0; | ||
488 | |||
489 | arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node, | ||
490 | "wlf,ldoena", 0); | ||
491 | if (arizona->pdata.ldoena < 0) | ||
492 | arizona->pdata.ldoena = 0; | ||
493 | |||
494 | ret = of_property_read_u32_array(arizona->dev->of_node, | ||
495 | "wlf,gpio-defaults", | ||
496 | arizona->pdata.gpio_defaults, | ||
497 | ARRAY_SIZE(arizona->pdata.gpio_defaults)); | ||
498 | if (ret >= 0) { | ||
499 | /* | ||
500 | * All values are literal except out of range values | ||
501 | * which are chip default, translate into platform | ||
502 | * data which uses 0 as chip default and out of range | ||
503 | * as zero. | ||
504 | */ | ||
505 | for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) { | ||
506 | if (arizona->pdata.gpio_defaults[i] > 0xffff) | ||
507 | arizona->pdata.gpio_defaults[i] = 0; | ||
508 | if (arizona->pdata.gpio_defaults[i] == 0) | ||
509 | arizona->pdata.gpio_defaults[i] = 0x10000; | ||
510 | } | ||
511 | } else { | ||
512 | dev_err(arizona->dev, "Failed to parse GPIO defaults: %d\n", | ||
513 | ret); | ||
514 | } | ||
515 | |||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | const struct of_device_id arizona_of_match[] = { | ||
520 | { .compatible = "wlf,wm5102", .data = (void *)WM5102 }, | ||
521 | { .compatible = "wlf,wm5110", .data = (void *)WM5110 }, | ||
522 | {}, | ||
523 | }; | ||
524 | EXPORT_SYMBOL_GPL(arizona_of_match); | ||
525 | #else | ||
526 | static inline int arizona_of_get_core_pdata(struct arizona *arizona) | ||
527 | { | ||
528 | return 0; | ||
529 | } | ||
530 | #endif | ||
531 | |||
465 | static struct mfd_cell early_devs[] = { | 532 | static struct mfd_cell early_devs[] = { |
466 | { .name = "arizona-ldo1" }, | 533 | { .name = "arizona-ldo1" }, |
467 | }; | 534 | }; |
@@ -495,6 +562,8 @@ int arizona_dev_init(struct arizona *arizona) | |||
495 | dev_set_drvdata(arizona->dev, arizona); | 562 | dev_set_drvdata(arizona->dev, arizona); |
496 | mutex_init(&arizona->clk_lock); | 563 | mutex_init(&arizona->clk_lock); |
497 | 564 | ||
565 | arizona_of_get_core_pdata(arizona); | ||
566 | |||
498 | if (dev_get_platdata(arizona->dev)) | 567 | if (dev_get_platdata(arizona->dev)) |
499 | memcpy(&arizona->pdata, dev_get_platdata(arizona->dev), | 568 | memcpy(&arizona->pdata, dev_get_platdata(arizona->dev), |
500 | sizeof(arizona->pdata)); | 569 | sizeof(arizona->pdata)); |