diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/power/max8925_power.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c index daa333bd7ebb..b5a3ccb16a14 100644 --- a/drivers/power/max8925_power.c +++ b/drivers/power/max8925_power.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
| 14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
| 15 | #include <linux/of.h> | ||
| 15 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
| 16 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
| 17 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
| @@ -426,6 +427,54 @@ static __devexit int max8925_deinit_charger(struct max8925_power_info *info) | |||
| 426 | return 0; | 427 | return 0; |
| 427 | } | 428 | } |
| 428 | 429 | ||
| 430 | #ifdef CONFIG_OF | ||
| 431 | static struct max8925_power_pdata * | ||
| 432 | max8925_power_dt_init(struct platform_device *pdev) | ||
| 433 | { | ||
| 434 | struct device_node *nproot = pdev->dev.parent->of_node; | ||
| 435 | struct device_node *np; | ||
| 436 | int batt_detect; | ||
| 437 | int topoff_threshold; | ||
| 438 | int fast_charge; | ||
| 439 | int no_temp_support; | ||
| 440 | int no_insert_detect; | ||
| 441 | struct max8925_power_pdata *pdata; | ||
| 442 | |||
| 443 | if (!nproot) | ||
| 444 | return pdev->dev.platform_data; | ||
| 445 | |||
| 446 | np = of_find_node_by_name(nproot, "charger"); | ||
| 447 | if (!np) { | ||
| 448 | dev_err(&pdev->dev, "failed to find charger node\n"); | ||
| 449 | return NULL; | ||
| 450 | } | ||
| 451 | |||
| 452 | pdata = devm_kzalloc(&pdev->dev, | ||
| 453 | sizeof(struct max8925_power_pdata), | ||
| 454 | GFP_KERNEL); | ||
| 455 | |||
| 456 | of_property_read_u32(np, "topoff-threshold", &topoff_threshold); | ||
| 457 | of_property_read_u32(np, "batt-detect", &batt_detect); | ||
| 458 | of_property_read_u32(np, "fast-charge", &fast_charge); | ||
| 459 | of_property_read_u32(np, "no-insert-detect", &no_insert_detect); | ||
| 460 | of_property_read_u32(np, "no-temp-support", &no_temp_support); | ||
| 461 | |||
| 462 | pdata->batt_detect = batt_detect; | ||
| 463 | pdata->fast_charge = fast_charge; | ||
| 464 | pdata->topoff_threshold = topoff_threshold; | ||
| 465 | pdata->no_insert_detect = no_insert_detect; | ||
| 466 | pdata->no_temp_support = no_temp_support; | ||
| 467 | |||
| 468 | return pdata; | ||
| 469 | } | ||
| 470 | #else | ||
| 471 | static struct max8925_power_pdata * | ||
| 472 | max8925_power_dt_init(struct platform_device *pdev) | ||
| 473 | { | ||
| 474 | return pdev->dev.platform_data; | ||
| 475 | } | ||
| 476 | #endif | ||
| 477 | |||
| 429 | static __devinit int max8925_power_probe(struct platform_device *pdev) | 478 | static __devinit int max8925_power_probe(struct platform_device *pdev) |
| 430 | { | 479 | { |
| 431 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); | 480 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); |
| @@ -433,7 +482,7 @@ static __devinit int max8925_power_probe(struct platform_device *pdev) | |||
| 433 | struct max8925_power_info *info; | 482 | struct max8925_power_info *info; |
| 434 | int ret; | 483 | int ret; |
| 435 | 484 | ||
| 436 | pdata = pdev->dev.platform_data; | 485 | pdata = max8925_power_dt_init(pdev); |
| 437 | if (!pdata) { | 486 | if (!pdata) { |
| 438 | dev_err(&pdev->dev, "platform data isn't assigned to " | 487 | dev_err(&pdev->dev, "platform data isn't assigned to " |
| 439 | "power supply\n"); | 488 | "power supply\n"); |
