Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'regulator-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
"This was a very quiet release, aside from some smaller improvements we
have:

- Support for power budgeting on regulators, initially targeted at
some still in review support for PSE controllers but generally
useful

- Support for error interrupts from ROHM BD96801 devices

- Support for NXP PCA9452"

* tag 'regulator-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
regulator: dt-bindings: Add regulator-power-budget-milliwatt property
regulator: Add support for power budget
regulator: core: Resolve supply using of_node from regulator_config
regulator: of: Implement the unwind path of of_regulator_match()
regulator: tps65219: Remove debugging helper function
regulator: tps65219: Remove MODULE_ALIAS
regulator: tps65219: Update driver name
regulator: tps65219: Use dev_err_probe() instead of dev_err()
regulator: dt-bindings: mt6315: Drop regulator-compatible property
regulator: pca9450: Add PMIC pca9452 support
regulator: dt-bindings: pca9450: Add pca9452 support
regulator: pca9450: Use dev_err_probe() to simplify code
regulator: pca9450: add enable_value for all bucks
regulator: bd96801: Add ERRB IRQ

+373 -113
-6
Documentation/devicetree/bindings/regulator/mt6315-regulator.yaml
··· 35 35 $ref: regulator.yaml# 36 36 unevaluatedProperties: false 37 37 38 - properties: 39 - regulator-compatible: 40 - pattern: "^vbuck[1-4]$" 41 - 42 38 additionalProperties: false 43 39 44 40 required: ··· 52 56 53 57 regulators { 54 58 vbuck1 { 55 - regulator-compatible = "vbuck1"; 56 59 regulator-min-microvolt = <300000>; 57 60 regulator-max-microvolt = <1193750>; 58 61 regulator-enable-ramp-delay = <256>; ··· 59 64 }; 60 65 61 66 vbuck3 { 62 - regulator-compatible = "vbuck3"; 63 67 regulator-min-microvolt = <300000>; 64 68 regulator-max-microvolt = <1193750>; 65 69 regulator-enable-ramp-delay = <256>;
+1
Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
··· 29 29 - nxp,pca9450b 30 30 - nxp,pca9450c 31 31 - nxp,pca9451a 32 + - nxp,pca9452 32 33 33 34 reg: 34 35 maxItems: 1
+3
Documentation/devicetree/bindings/regulator/regulator.yaml
··· 34 34 regulator-input-current-limit-microamp: 35 35 description: maximum input current regulator allows 36 36 37 + regulator-power-budget-milliwatt: 38 + description: power budget of the regulator 39 + 37 40 regulator-always-on: 38 41 description: boolean, regulator should never be disabled 39 42 type: boolean
+115 -15
drivers/regulator/bd96801-regulator.c
··· 5 5 /* 6 6 * This version of the "BD86801 scalable PMIC"'s driver supports only very 7 7 * basic set of the PMIC features. Most notably, there is no support for 8 - * the ERRB interrupt and the configurations which should be done when the 9 - * PMIC is in STBY mode. 10 - * 11 - * Supporting the ERRB interrupt would require dropping the regmap-IRQ 12 - * usage or working around (or accepting a presense of) a naming conflict 13 - * in debugFS IRQs. 8 + * the configurations which should be done when the PMIC is in STBY mode. 14 9 * 15 10 * Being able to reliably do the configurations like changing the 16 11 * regulator safety limits (like limits for the over/under -voltages, over ··· 17 22 * be the need to configure these safety limits. Hence it's not simple to 18 23 * come up with a generic solution. 19 24 * 20 - * Users who require the ERRB handling and STBY state configurations can 21 - * have a look at the original RFC: 25 + * Users who require the STBY state configurations can have a look at the 26 + * original RFC: 22 27 * https://lore.kernel.org/all/cover.1712920132.git.mazziesaccount@gmail.com/ 23 - * which implements a workaround to debugFS naming conflict and some of 24 - * the safety limit configurations - but leaves the state change handling 25 - * and synchronization to be implemented. 28 + * which implements some of the safety limit configurations - but leaves the 29 + * state change handling and synchronization to be implemented. 26 30 * 27 31 * It would be great to hear (and receive a patch!) if you implement the 28 - * STBY configuration support or a proper fix to the debugFS naming 29 - * conflict in your downstream driver ;) 32 + * STBY configuration support in your downstream driver ;) 30 33 */ 31 34 32 35 #include <linux/cleanup.h> ··· 721 728 return 0; 722 729 } 723 730 731 + static int bd96801_map_event_all(int irq, struct regulator_irq_data *rid, 732 + unsigned long *dev_mask) 733 + { 734 + int i; 735 + 736 + for (i = 0; i < rid->num_states; i++) { 737 + rid->states[i].notifs = REGULATOR_EVENT_FAIL; 738 + rid->states[i].errors = REGULATOR_ERROR_FAIL; 739 + *dev_mask |= BIT(i); 740 + } 741 + 742 + return 0; 743 + } 744 + 745 + static int bd96801_rdev_errb_irqs(struct platform_device *pdev, 746 + struct regulator_dev *rdev) 747 + { 748 + int i; 749 + void *retp; 750 + static const char * const single_out_errb_irqs[] = { 751 + "bd96801-%s-pvin-err", "bd96801-%s-ovp-err", 752 + "bd96801-%s-uvp-err", "bd96801-%s-shdn-err", 753 + }; 754 + 755 + for (i = 0; i < ARRAY_SIZE(single_out_errb_irqs); i++) { 756 + struct regulator_irq_desc id = { 757 + .map_event = bd96801_map_event_all, 758 + .irq_off_ms = 1000, 759 + }; 760 + struct regulator_dev *rdev_arr[1]; 761 + char tmp[255]; 762 + int irq; 763 + 764 + snprintf(tmp, 255, single_out_errb_irqs[i], rdev->desc->name); 765 + tmp[254] = 0; 766 + id.name = tmp; 767 + 768 + irq = platform_get_irq_byname(pdev, tmp); 769 + if (irq < 0) 770 + continue; 771 + 772 + rdev_arr[0] = rdev; 773 + retp = devm_regulator_irq_helper(&pdev->dev, &id, irq, 0, 774 + REGULATOR_ERROR_FAIL, NULL, 775 + rdev_arr, 1); 776 + if (IS_ERR(retp)) 777 + return PTR_ERR(retp); 778 + 779 + } 780 + return 0; 781 + } 782 + 783 + static int bd96801_global_errb_irqs(struct platform_device *pdev, 784 + struct regulator_dev **rdev, int num_rdev) 785 + { 786 + int i, num_irqs; 787 + void *retp; 788 + static const char * const global_errb_irqs[] = { 789 + "bd96801-otp-err", "bd96801-dbist-err", "bd96801-eep-err", 790 + "bd96801-abist-err", "bd96801-prstb-err", "bd96801-drmoserr1", 791 + "bd96801-drmoserr2", "bd96801-slave-err", "bd96801-vref-err", 792 + "bd96801-tsd", "bd96801-uvlo-err", "bd96801-ovlo-err", 793 + "bd96801-osc-err", "bd96801-pon-err", "bd96801-poff-err", 794 + "bd96801-cmd-shdn-err", "bd96801-int-shdn-err" 795 + }; 796 + 797 + num_irqs = ARRAY_SIZE(global_errb_irqs); 798 + for (i = 0; i < num_irqs; i++) { 799 + int irq; 800 + struct regulator_irq_desc id = { 801 + .name = global_errb_irqs[i], 802 + .map_event = bd96801_map_event_all, 803 + .irq_off_ms = 1000, 804 + }; 805 + 806 + irq = platform_get_irq_byname(pdev, global_errb_irqs[i]); 807 + if (irq < 0) 808 + continue; 809 + 810 + retp = devm_regulator_irq_helper(&pdev->dev, &id, irq, 0, 811 + REGULATOR_ERROR_FAIL, NULL, 812 + rdev, num_rdev); 813 + if (IS_ERR(retp)) 814 + return PTR_ERR(retp); 815 + } 816 + 817 + return 0; 818 + } 819 + 724 820 static int bd96801_rdev_intb_irqs(struct platform_device *pdev, 725 821 struct bd96801_pmic_data *pdata, 726 822 struct bd96801_irqinfo *iinfo, ··· 865 783 return 0; 866 784 } 867 785 868 - 869 - 870 786 static int bd96801_probe(struct platform_device *pdev) 871 787 { 872 788 struct regulator_dev *ldo_errs_rdev_arr[BD96801_NUM_LDOS]; 789 + struct regulator_dev *all_rdevs[BD96801_NUM_REGULATORS]; 873 790 struct bd96801_regulator_data *rdesc; 874 791 struct regulator_config config = {}; 875 792 int ldo_errs_arr[BD96801_NUM_LDOS]; ··· 876 795 int temp_notif_ldos = 0; 877 796 struct device *parent; 878 797 int i, ret; 798 + bool use_errb; 879 799 void *retp; 880 800 881 801 parent = pdev->dev.parent; ··· 901 819 config.regmap = pdata->regmap; 902 820 config.dev = parent; 903 821 822 + ret = of_property_match_string(pdev->dev.parent->of_node, 823 + "interrupt-names", "errb"); 824 + if (ret < 0) 825 + use_errb = false; 826 + else 827 + use_errb = true; 828 + 904 829 ret = bd96801_walk_regulator_dt(&pdev->dev, pdata->regmap, rdesc, 905 830 BD96801_NUM_REGULATORS); 906 831 if (ret) ··· 926 837 rdesc[i].desc.name); 927 838 return PTR_ERR(rdev); 928 839 } 840 + all_rdevs[i] = rdev; 929 841 /* 930 842 * LDOs don't have own temperature monitoring. If temperature 931 843 * notification was requested for this LDO from DT then we will ··· 943 853 for (j = 0; j < idesc->num_irqs; j++) { 944 854 ret = bd96801_rdev_intb_irqs(pdev, pdata, 945 855 &idesc->irqinfo[j], rdev); 856 + if (ret) 857 + return ret; 858 + } 859 + /* Register per regulator ERRB notifiers */ 860 + if (use_errb) { 861 + ret = bd96801_rdev_errb_irqs(pdev, rdev); 946 862 if (ret) 947 863 return ret; 948 864 } ··· 972 876 if (IS_ERR(retp)) 973 877 return PTR_ERR(retp); 974 878 } 879 + 880 + if (use_errb) 881 + return bd96801_global_errb_irqs(pdev, all_rdevs, 882 + ARRAY_SIZE(all_rdevs)); 975 883 976 884 return 0; 977 885 }
+142 -11
drivers/regulator/core.c
··· 917 917 } 918 918 static DEVICE_ATTR_RO(bypass); 919 919 920 + static ssize_t power_budget_milliwatt_show(struct device *dev, 921 + struct device_attribute *attr, 922 + char *buf) 923 + { 924 + struct regulator_dev *rdev = dev_get_drvdata(dev); 925 + 926 + return sprintf(buf, "%d\n", rdev->constraints->pw_budget_mW); 927 + } 928 + static DEVICE_ATTR_RO(power_budget_milliwatt); 929 + 930 + static ssize_t power_requested_milliwatt_show(struct device *dev, 931 + struct device_attribute *attr, 932 + char *buf) 933 + { 934 + struct regulator_dev *rdev = dev_get_drvdata(dev); 935 + 936 + return sprintf(buf, "%d\n", rdev->pw_requested_mW); 937 + } 938 + static DEVICE_ATTR_RO(power_requested_milliwatt); 939 + 920 940 #define REGULATOR_ERROR_ATTR(name, bit) \ 921 941 static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \ 922 942 char *buf) \ ··· 1168 1148 count += scnprintf(buf + count, len - count, "idle "); 1169 1149 if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY) 1170 1150 count += scnprintf(buf + count, len - count, "standby "); 1151 + 1152 + if (constraints->pw_budget_mW) 1153 + count += scnprintf(buf + count, len - count, "%d mW budget", 1154 + constraints->pw_budget_mW); 1171 1155 1172 1156 if (!count) 1173 1157 count = scnprintf(buf, len, "no parameters"); ··· 1651 1627 rdev->last_off = ktime_get(); 1652 1628 } 1653 1629 1630 + if (!rdev->constraints->pw_budget_mW) 1631 + rdev->constraints->pw_budget_mW = INT_MAX; 1632 + 1654 1633 print_constraints(rdev); 1655 1634 return 0; 1656 1635 } ··· 1963 1936 return dev ? dev_to_rdev(dev) : NULL; 1964 1937 } 1965 1938 1939 + static struct regulator_dev *regulator_dt_lookup(struct device *dev, 1940 + const char *supply) 1941 + { 1942 + struct regulator_dev *r = NULL; 1943 + 1944 + if (dev_of_node(dev)) { 1945 + r = of_regulator_dev_lookup(dev, dev_of_node(dev), supply); 1946 + if (PTR_ERR(r) == -ENODEV) 1947 + r = NULL; 1948 + } 1949 + 1950 + return r; 1951 + } 1952 + 1966 1953 /** 1967 1954 * regulator_dev_lookup - lookup a regulator device. 1968 1955 * @dev: device for regulator "consumer". ··· 2001 1960 regulator_supply_alias(&dev, &supply); 2002 1961 2003 1962 /* first do a dt based lookup */ 2004 - if (dev_of_node(dev)) { 2005 - r = of_regulator_dev_lookup(dev, dev_of_node(dev), supply); 2006 - if (!IS_ERR(r)) 2007 - return r; 2008 - if (PTR_ERR(r) == -EPROBE_DEFER) 2009 - return r; 2010 - 2011 - if (PTR_ERR(r) == -ENODEV) 2012 - r = NULL; 2013 - } 1963 + r = regulator_dt_lookup(dev, supply); 1964 + if (r) 1965 + return r; 2014 1966 2015 1967 /* if not found, try doing it non-dt way */ 2016 1968 if (dev) ··· 2049 2015 if (rdev->supply) 2050 2016 return 0; 2051 2017 2052 - r = regulator_dev_lookup(dev, rdev->supply_name); 2018 + /* first do a dt based lookup on the node described in the virtual 2019 + * device. 2020 + */ 2021 + r = regulator_dt_lookup(&rdev->dev, rdev->supply_name); 2022 + 2023 + /* If regulator not found use usual search path in the parent 2024 + * device. 2025 + */ 2026 + if (!r) 2027 + r = regulator_dev_lookup(dev, rdev->supply_name); 2028 + 2053 2029 if (IS_ERR(r)) { 2054 2030 ret = PTR_ERR(r); 2055 2031 ··· 4629 4585 EXPORT_SYMBOL_GPL(regulator_get_current_limit); 4630 4586 4631 4587 /** 4588 + * regulator_get_unclaimed_power_budget - get regulator unclaimed power budget 4589 + * @regulator: regulator source 4590 + * 4591 + * Return: Unclaimed power budget of the regulator in mW. 4592 + */ 4593 + int regulator_get_unclaimed_power_budget(struct regulator *regulator) 4594 + { 4595 + return regulator->rdev->constraints->pw_budget_mW - 4596 + regulator->rdev->pw_requested_mW; 4597 + } 4598 + EXPORT_SYMBOL_GPL(regulator_get_unclaimed_power_budget); 4599 + 4600 + /** 4601 + * regulator_request_power_budget - request power budget on a regulator 4602 + * @regulator: regulator source 4603 + * @pw_req: Power requested 4604 + * 4605 + * Return: 0 on success or a negative error number on failure. 4606 + */ 4607 + int regulator_request_power_budget(struct regulator *regulator, 4608 + unsigned int pw_req) 4609 + { 4610 + struct regulator_dev *rdev = regulator->rdev; 4611 + int ret = 0, pw_tot_req; 4612 + 4613 + regulator_lock(rdev); 4614 + if (rdev->supply) { 4615 + ret = regulator_request_power_budget(rdev->supply, pw_req); 4616 + if (ret < 0) 4617 + goto out; 4618 + } 4619 + 4620 + pw_tot_req = rdev->pw_requested_mW + pw_req; 4621 + if (pw_tot_req > rdev->constraints->pw_budget_mW) { 4622 + rdev_warn(rdev, "power requested %d mW out of budget %d mW", 4623 + pw_req, 4624 + rdev->constraints->pw_budget_mW - rdev->pw_requested_mW); 4625 + regulator_notifier_call_chain(rdev, 4626 + REGULATOR_EVENT_OVER_CURRENT_WARN, 4627 + NULL); 4628 + ret = -ERANGE; 4629 + goto out; 4630 + } 4631 + 4632 + rdev->pw_requested_mW = pw_tot_req; 4633 + out: 4634 + regulator_unlock(rdev); 4635 + return ret; 4636 + } 4637 + EXPORT_SYMBOL_GPL(regulator_request_power_budget); 4638 + 4639 + /** 4640 + * regulator_free_power_budget - free power budget on a regulator 4641 + * @regulator: regulator source 4642 + * @pw: Power to be released. 4643 + * 4644 + * Return: Power budget of the regulator in mW. 4645 + */ 4646 + void regulator_free_power_budget(struct regulator *regulator, 4647 + unsigned int pw) 4648 + { 4649 + struct regulator_dev *rdev = regulator->rdev; 4650 + int pw_tot_req; 4651 + 4652 + regulator_lock(rdev); 4653 + if (rdev->supply) 4654 + regulator_free_power_budget(rdev->supply, pw); 4655 + 4656 + pw_tot_req = rdev->pw_requested_mW - pw; 4657 + if (pw_tot_req >= 0) 4658 + rdev->pw_requested_mW = pw_tot_req; 4659 + else 4660 + rdev_warn(rdev, 4661 + "too much power freed %d mW (already requested %d mW)", 4662 + pw, rdev->pw_requested_mW); 4663 + 4664 + regulator_unlock(rdev); 4665 + } 4666 + EXPORT_SYMBOL_GPL(regulator_free_power_budget); 4667 + 4668 + /** 4632 4669 * regulator_set_mode - set regulator operating mode 4633 4670 * @regulator: regulator source 4634 4671 * @mode: operating mode - one of the REGULATOR_MODE constants ··· 5347 5222 &dev_attr_suspend_standby_mode.attr, 5348 5223 &dev_attr_suspend_mem_mode.attr, 5349 5224 &dev_attr_suspend_disk_mode.attr, 5225 + &dev_attr_power_budget_milliwatt.attr, 5226 + &dev_attr_power_requested_milliwatt.attr, 5350 5227 NULL 5351 5228 }; 5352 5229 ··· 5429 5302 attr == &dev_attr_suspend_mem_mode.attr || 5430 5303 attr == &dev_attr_suspend_disk_mode.attr) 5431 5304 return ops->set_suspend_mode ? mode : 0; 5305 + 5306 + if (attr == &dev_attr_power_budget_milliwatt.attr || 5307 + attr == &dev_attr_power_requested_milliwatt.attr) 5308 + return rdev->constraints->pw_budget_mW != INT_MAX ? mode : 0; 5432 5309 5433 5310 return mode; 5434 5311 }
+16 -1
drivers/regulator/of_regulator.c
··· 125 125 if (constraints->min_uA != constraints->max_uA) 126 126 constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; 127 127 128 + if (!of_property_read_u32(np, "regulator-power-budget-milliwatt", &pval)) 129 + constraints->pw_budget_mW = pval; 130 + 128 131 constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); 129 132 constraints->always_on = of_property_read_bool(np, "regulator-always-on"); 130 133 if (!constraints->always_on) /* status change should be possible. */ ··· 449 446 "failed to parse DT for regulator %pOFn\n", 450 447 child); 451 448 of_node_put(child); 452 - return -EINVAL; 449 + goto err_put; 453 450 } 454 451 match->of_node = of_node_get(child); 455 452 count++; ··· 458 455 } 459 456 460 457 return count; 458 + 459 + err_put: 460 + for (i = 0; i < num_matches; i++) { 461 + struct of_regulator_match *match = &matches[i]; 462 + 463 + match->init_data = NULL; 464 + if (match->of_node) { 465 + of_node_put(match->of_node); 466 + match->of_node = NULL; 467 + } 468 + } 469 + return -EINVAL; 461 470 } 462 471 EXPORT_SYMBOL_GPL(of_regulator_match); 463 472
+65 -46
drivers/regulator/pca9450-regulator.c
··· 247 247 .ramp_mask = BUCK1_RAMP_MASK, 248 248 .ramp_delay_table = pca9450_dvs_buck_ramp_table, 249 249 .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), 250 + .enable_val = BUCK_ENMODE_ONREQ, 250 251 .owner = THIS_MODULE, 251 252 .of_parse_cb = pca9450_set_dvs_levels, 252 253 }, ··· 273 272 .vsel_mask = BUCK2OUT_DVS0_MASK, 274 273 .enable_reg = PCA9450_REG_BUCK2CTRL, 275 274 .enable_mask = BUCK2_ENMODE_MASK, 275 + .enable_val = BUCK_ENMODE_ONREQ_STBYREQ, 276 276 .ramp_reg = PCA9450_REG_BUCK2CTRL, 277 277 .ramp_mask = BUCK2_RAMP_MASK, 278 278 .ramp_delay_table = pca9450_dvs_buck_ramp_table, ··· 303 301 .vsel_mask = BUCK3OUT_DVS0_MASK, 304 302 .enable_reg = PCA9450_REG_BUCK3CTRL, 305 303 .enable_mask = BUCK3_ENMODE_MASK, 304 + .enable_val = BUCK_ENMODE_ONREQ, 306 305 .ramp_reg = PCA9450_REG_BUCK3CTRL, 307 306 .ramp_mask = BUCK3_RAMP_MASK, 308 307 .ramp_delay_table = pca9450_dvs_buck_ramp_table, ··· 333 330 .vsel_mask = BUCK4OUT_MASK, 334 331 .enable_reg = PCA9450_REG_BUCK4CTRL, 335 332 .enable_mask = BUCK4_ENMODE_MASK, 333 + .enable_val = BUCK_ENMODE_ONREQ, 336 334 .owner = THIS_MODULE, 337 335 }, 338 336 }, ··· 352 348 .vsel_mask = BUCK5OUT_MASK, 353 349 .enable_reg = PCA9450_REG_BUCK5CTRL, 354 350 .enable_mask = BUCK5_ENMODE_MASK, 351 + .enable_val = BUCK_ENMODE_ONREQ, 355 352 .owner = THIS_MODULE, 356 353 }, 357 354 }, ··· 371 366 .vsel_mask = BUCK6OUT_MASK, 372 367 .enable_reg = PCA9450_REG_BUCK6CTRL, 373 368 .enable_mask = BUCK6_ENMODE_MASK, 369 + .enable_val = BUCK_ENMODE_ONREQ, 374 370 .owner = THIS_MODULE, 375 371 }, 376 372 }, ··· 487 481 .vsel_mask = BUCK1OUT_DVS0_MASK, 488 482 .enable_reg = PCA9450_REG_BUCK1CTRL, 489 483 .enable_mask = BUCK1_ENMODE_MASK, 484 + .enable_val = BUCK_ENMODE_ONREQ, 490 485 .ramp_reg = PCA9450_REG_BUCK1CTRL, 491 486 .ramp_mask = BUCK1_RAMP_MASK, 492 487 .ramp_delay_table = pca9450_dvs_buck_ramp_table, ··· 517 510 .vsel_mask = BUCK2OUT_DVS0_MASK, 518 511 .enable_reg = PCA9450_REG_BUCK2CTRL, 519 512 .enable_mask = BUCK2_ENMODE_MASK, 513 + .enable_val = BUCK_ENMODE_ONREQ_STBYREQ, 520 514 .ramp_reg = PCA9450_REG_BUCK2CTRL, 521 515 .ramp_mask = BUCK2_RAMP_MASK, 522 516 .ramp_delay_table = pca9450_dvs_buck_ramp_table, ··· 547 539 .vsel_mask = BUCK4OUT_MASK, 548 540 .enable_reg = PCA9450_REG_BUCK4CTRL, 549 541 .enable_mask = BUCK4_ENMODE_MASK, 542 + .enable_val = BUCK_ENMODE_ONREQ, 550 543 .owner = THIS_MODULE, 551 544 }, 552 545 }, ··· 566 557 .vsel_mask = BUCK5OUT_MASK, 567 558 .enable_reg = PCA9450_REG_BUCK5CTRL, 568 559 .enable_mask = BUCK5_ENMODE_MASK, 560 + .enable_val = BUCK_ENMODE_ONREQ, 569 561 .owner = THIS_MODULE, 570 562 }, 571 563 }, ··· 585 575 .vsel_mask = BUCK6OUT_MASK, 586 576 .enable_reg = PCA9450_REG_BUCK6CTRL, 587 577 .enable_mask = BUCK6_ENMODE_MASK, 578 + .enable_val = BUCK_ENMODE_ONREQ, 588 579 .owner = THIS_MODULE, 589 580 }, 590 581 }, ··· 817 806 }, 818 807 { 819 808 .desc = { 809 + .name = "ldo3", 810 + .of_match = of_match_ptr("LDO3"), 811 + .regulators_node = of_match_ptr("regulators"), 812 + .id = PCA9450_LDO3, 813 + .ops = &pca9450_ldo_regulator_ops, 814 + .type = REGULATOR_VOLTAGE, 815 + .n_voltages = PCA9450_LDO3_VOLTAGE_NUM, 816 + .linear_ranges = pca9450_ldo34_volts, 817 + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo34_volts), 818 + .vsel_reg = PCA9450_REG_LDO3CTRL, 819 + .vsel_mask = LDO3OUT_MASK, 820 + .enable_reg = PCA9450_REG_LDO3CTRL, 821 + .enable_mask = LDO3_EN_MASK, 822 + .owner = THIS_MODULE, 823 + }, 824 + }, 825 + { 826 + .desc = { 820 827 .name = "ldo4", 821 828 .of_match = of_match_ptr("LDO4"), 822 829 .regulators_node = of_match_ptr("regulators"), ··· 934 905 pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); 935 906 break; 936 907 case PCA9450_TYPE_PCA9451A: 908 + case PCA9450_TYPE_PCA9452: 937 909 regulator_desc = pca9451a_regulators; 938 910 pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); 939 911 break; ··· 951 921 952 922 pca9450->regmap = devm_regmap_init_i2c(i2c, 953 923 &pca9450_regmap_config); 954 - if (IS_ERR(pca9450->regmap)) { 955 - dev_err(&i2c->dev, "regmap initialization failed\n"); 956 - return PTR_ERR(pca9450->regmap); 957 - } 924 + if (IS_ERR(pca9450->regmap)) 925 + return dev_err_probe(&i2c->dev, PTR_ERR(pca9450->regmap), 926 + "regmap initialization failed\n"); 958 927 959 928 ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, &device_id); 960 - if (ret) { 961 - dev_err(&i2c->dev, "Read device id error\n"); 962 - return ret; 963 - } 929 + if (ret) 930 + return dev_err_probe(&i2c->dev, ret, "Read device id error\n"); 964 931 965 932 /* Check your board and dts for match the right pmic */ 966 933 if (((device_id >> 4) != 0x1 && type == PCA9450_TYPE_PCA9450A) || 967 934 ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC) || 968 - ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9451A)) { 969 - dev_err(&i2c->dev, "Device id(%x) mismatched\n", 970 - device_id >> 4); 971 - return -EINVAL; 972 - } 935 + ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9451A) || 936 + ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9452)) 937 + return dev_err_probe(&i2c->dev, -EINVAL, 938 + "Device id(%x) mismatched\n", device_id >> 4); 973 939 974 940 for (i = 0; i < pca9450->rcnt; i++) { 975 941 const struct regulator_desc *desc; ··· 975 949 r = &regulator_desc[i]; 976 950 desc = &r->desc; 977 951 952 + if (type == PCA9450_TYPE_PCA9451A && !strcmp(desc->name, "ldo3")) 953 + continue; 954 + 978 955 config.regmap = pca9450->regmap; 979 956 config.dev = pca9450->dev; 980 957 981 958 rdev = devm_regulator_register(pca9450->dev, desc, &config); 982 - if (IS_ERR(rdev)) { 983 - ret = PTR_ERR(rdev); 984 - dev_err(pca9450->dev, 985 - "Failed to register regulator(%s): %d\n", 986 - desc->name, ret); 987 - return ret; 988 - } 959 + if (IS_ERR(rdev)) 960 + return dev_err_probe(pca9450->dev, PTR_ERR(rdev), 961 + "Failed to register regulator(%s)\n", desc->name); 989 962 } 990 963 991 964 if (pca9450->irq) { ··· 992 967 pca9450_irq_handler, 993 968 (IRQF_TRIGGER_FALLING | IRQF_ONESHOT), 994 969 "pca9450-irq", pca9450); 995 - if (ret != 0) { 996 - dev_err(pca9450->dev, "Failed to request IRQ: %d\n", 997 - pca9450->irq); 998 - return ret; 999 - } 970 + if (ret != 0) 971 + return dev_err_probe(pca9450->dev, ret, "Failed to request IRQ: %d\n", 972 + pca9450->irq); 973 + 1000 974 /* Unmask all interrupt except PWRON/WDOG/RSVD */ 1001 975 ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_INT1_MSK, 1002 976 IRQ_VR_FLT1 | IRQ_VR_FLT2 | IRQ_LOWVSYS | 1003 977 IRQ_THERM_105 | IRQ_THERM_125, 1004 978 IRQ_PWRON | IRQ_WDOGB | IRQ_RSVD); 1005 - if (ret) { 1006 - dev_err(&i2c->dev, "Unmask irq error\n"); 1007 - return ret; 1008 - } 979 + if (ret) 980 + return dev_err_probe(&i2c->dev, ret, "Unmask irq error\n"); 1009 981 } 1010 982 1011 983 /* Clear PRESET_EN bit in BUCK123_DVS to use DVS registers */ 1012 984 ret = regmap_clear_bits(pca9450->regmap, PCA9450_REG_BUCK123_DVS, 1013 985 BUCK123_PRESET_EN); 1014 - if (ret) { 1015 - dev_err(&i2c->dev, "Failed to clear PRESET_EN bit: %d\n", ret); 1016 - return ret; 1017 - } 986 + if (ret) 987 + return dev_err_probe(&i2c->dev, ret, "Failed to clear PRESET_EN bit\n"); 1018 988 1019 989 if (of_property_read_bool(i2c->dev.of_node, "nxp,wdog_b-warm-reset")) 1020 990 reset_ctrl = WDOG_B_CFG_WARM; ··· 1019 999 /* Set reset behavior on assertion of WDOG_B signal */ 1020 1000 ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_RESET_CTRL, 1021 1001 WDOG_B_CFG_MASK, reset_ctrl); 1022 - if (ret) { 1023 - dev_err(&i2c->dev, "Failed to set WDOG_B reset behavior\n"); 1024 - return ret; 1025 - } 1002 + if (ret) 1003 + return dev_err_probe(&i2c->dev, ret, "Failed to set WDOG_B reset behavior\n"); 1026 1004 1027 1005 if (of_property_read_bool(i2c->dev.of_node, "nxp,i2c-lt-enable")) { 1028 1006 /* Enable I2C Level Translator */ 1029 1007 ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_CONFIG2, 1030 1008 I2C_LT_MASK, I2C_LT_ON_STANDBY_RUN); 1031 - if (ret) { 1032 - dev_err(&i2c->dev, 1033 - "Failed to enable I2C level translator\n"); 1034 - return ret; 1035 - } 1009 + if (ret) 1010 + return dev_err_probe(&i2c->dev, ret, 1011 + "Failed to enable I2C level translator\n"); 1036 1012 } 1037 1013 1038 1014 /* ··· 1038 1022 */ 1039 1023 pca9450->sd_vsel_gpio = gpiod_get_optional(pca9450->dev, "sd-vsel", GPIOD_OUT_HIGH); 1040 1024 1041 - if (IS_ERR(pca9450->sd_vsel_gpio)) { 1042 - dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n"); 1043 - return PTR_ERR(pca9450->sd_vsel_gpio); 1044 - } 1025 + if (IS_ERR(pca9450->sd_vsel_gpio)) 1026 + return dev_err_probe(&i2c->dev, PTR_ERR(pca9450->sd_vsel_gpio), 1027 + "Failed to get SD_VSEL GPIO\n"); 1045 1028 1046 1029 dev_info(&i2c->dev, "%s probed.\n", 1047 1030 type == PCA9450_TYPE_PCA9450A ? "pca9450a" : ··· 1065 1050 { 1066 1051 .compatible = "nxp,pca9451a", 1067 1052 .data = (void *)PCA9450_TYPE_PCA9451A, 1053 + }, 1054 + { 1055 + .compatible = "nxp,pca9452", 1056 + .data = (void *)PCA9450_TYPE_PCA9452, 1068 1057 }, 1069 1058 { } 1070 1059 };
+5 -34
drivers/regulator/tps65219-regulator.c
··· 287 287 return IRQ_HANDLED; 288 288 } 289 289 290 - static int tps65219_get_rdev_by_name(const char *regulator_name, 291 - struct regulator_dev *rdevtbl[7], 292 - struct regulator_dev **dev) 293 - { 294 - int i; 295 - 296 - for (i = 0; i < ARRAY_SIZE(regulators); i++) { 297 - if (strcmp(regulator_name, regulators[i].name) == 0) { 298 - *dev = rdevtbl[i]; 299 - return 0; 300 - } 301 - } 302 - return -EINVAL; 303 - } 304 - 305 290 static int tps65219_regulator_probe(struct platform_device *pdev) 306 291 { 307 292 struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent); ··· 297 312 int irq; 298 313 struct tps65219_regulator_irq_data *irq_data; 299 314 struct tps65219_regulator_irq_type *irq_type; 300 - struct regulator_dev *rdevtbl[7]; 301 315 302 316 config.dev = tps->dev; 303 317 config.driver_data = tps; 304 318 config.regmap = tps->regmap; 305 319 306 320 for (i = 0; i < ARRAY_SIZE(regulators); i++) { 307 - dev_dbg(tps->dev, "%s regul i= %d START", __func__, i); 308 321 rdev = devm_regulator_register(&pdev->dev, &regulators[i], 309 322 &config); 310 - if (IS_ERR(rdev)) { 311 - dev_err(tps->dev, "failed to register %s regulator\n", 312 - regulators[i].name); 313 - return PTR_ERR(rdev); 314 - } 315 - rdevtbl[i] = rdev; 316 - dev_dbg(tps->dev, "%s regul i= %d COMPLETED", __func__, i); 323 + if (IS_ERR(rdev)) 324 + return dev_err_probe(tps->dev, PTR_ERR(rdev), 325 + "Failed to register %s regulator\n", 326 + regulators[i].name); 317 327 } 318 328 319 329 irq_data = devm_kmalloc(tps->dev, ··· 327 347 328 348 irq_data[i].dev = tps->dev; 329 349 irq_data[i].type = irq_type; 330 - 331 - tps65219_get_rdev_by_name(irq_type->regulator_name, rdevtbl, &rdev); 332 - if (IS_ERR(rdev)) { 333 - dev_err(tps->dev, "Failed to get rdev for %s\n", 334 - irq_type->regulator_name); 335 - return -EINVAL; 336 - } 337 - irq_data[i].rdev = rdev; 338 350 339 351 error = devm_request_threaded_irq(tps->dev, irq, NULL, 340 352 tps65219_regulator_irq_handler, ··· 351 379 352 380 static struct platform_driver tps65219_regulator_driver = { 353 381 .driver = { 354 - .name = "tps65219-pmic", 382 + .name = "tps65219-regulator", 355 383 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 356 384 }, 357 385 .probe = tps65219_regulator_probe, ··· 362 390 363 391 MODULE_AUTHOR("Jerome Neanne <j-neanne@baylibre.com>"); 364 392 MODULE_DESCRIPTION("TPS65219 voltage regulator driver"); 365 - MODULE_ALIAS("platform:tps65219-pmic"); 366 393 MODULE_LICENSE("GPL");
+21
include/linux/regulator/consumer.h
··· 233 233 int regulator_set_current_limit(struct regulator *regulator, 234 234 int min_uA, int max_uA); 235 235 int regulator_get_current_limit(struct regulator *regulator); 236 + int regulator_get_unclaimed_power_budget(struct regulator *regulator); 237 + int regulator_request_power_budget(struct regulator *regulator, 238 + unsigned int pw_req); 239 + void regulator_free_power_budget(struct regulator *regulator, 240 + unsigned int pw); 236 241 237 242 int regulator_set_mode(struct regulator *regulator, unsigned int mode); 238 243 unsigned int regulator_get_mode(struct regulator *regulator); ··· 529 524 static inline int regulator_get_current_limit(struct regulator *regulator) 530 525 { 531 526 return 0; 527 + } 528 + 529 + static inline int regulator_get_unclaimed_power_budget(struct regulator *regulator) 530 + { 531 + return INT_MAX; 532 + } 533 + 534 + static inline int regulator_request_power_budget(struct regulator *regulator, 535 + unsigned int pw_req) 536 + { 537 + return -EOPNOTSUPP; 538 + } 539 + 540 + static inline void regulator_free_power_budget(struct regulator *regulator, 541 + unsigned int pw) 542 + { 532 543 } 533 544 534 545 static inline int regulator_set_mode(struct regulator *regulator,
+2
include/linux/regulator/driver.h
··· 656 656 int cached_err; 657 657 bool use_cached_err; 658 658 spinlock_t err_lock; 659 + 660 + int pw_requested_mW; 659 661 }; 660 662 661 663 /*
+2
include/linux/regulator/machine.h
··· 113 113 * @min_uA: Smallest current consumers may set. 114 114 * @max_uA: Largest current consumers may set. 115 115 * @ilim_uA: Maximum input current. 116 + * @pw_budget_mW: Power budget for the regulator in mW. 116 117 * @system_load: Load that isn't captured by any consumer requests. 117 118 * 118 119 * @over_curr_limits: Limits for acting on over current. ··· 186 185 int max_uA; 187 186 int ilim_uA; 188 187 188 + int pw_budget_mW; 189 189 int system_load; 190 190 191 191 /* used for coupled regulators */
+1
include/linux/regulator/pca9450.h
··· 10 10 PCA9450_TYPE_PCA9450A = 0, 11 11 PCA9450_TYPE_PCA9450BC, 12 12 PCA9450_TYPE_PCA9451A, 13 + PCA9450_TYPE_PCA9452, 13 14 PCA9450_TYPE_AMOUNT, 14 15 }; 15 16