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

Merge remote-tracking branches 'regulator/topic/of', 'regulator/topic/pv88080', 'regulator/topic/rk808', 'regulator/topic/set-voltage' and 'regulator/topic/tps65218' into regulator-next

+429 -135
+18 -5
Documentation/devicetree/bindings/regulator/pv88080.txt
··· 1 1 * Powerventure Semiconductor PV88080 Voltage Regulator 2 2 3 3 Required properties: 4 - - compatible: "pvs,pv88080". 5 - - reg: I2C slave address, usually 0x49. 4 + - compatible: Must be one of the following, depending on the 5 + silicon version: 6 + - "pvs,pv88080" (DEPRECATED) 7 + 8 + - "pvs,pv88080-aa" for PV88080 AA or AB silicon 9 + - "pvs,pv88080-ba" for PV88080 BA or BB silicon 10 + NOTE: The use of the compatibles with no silicon version is deprecated. 11 + - reg: I2C slave address, usually 0x49 6 12 - interrupts: the interrupt outputs of the controller 7 13 - regulators: A node that houses a sub-node for each regulator within the 8 14 device. Each sub-node is identified using the node's name, with valid 9 15 values listed below. The content of each sub-node is defined by the 10 16 standard binding for regulators; see regulator.txt. 11 - BUCK1, BUCK2, and BUCK3. 17 + BUCK1, BUCK2, BUCK3 and HVBUCK. 12 18 13 19 Optional properties: 14 20 - Any optional property defined in regulator.txt 15 21 16 - Example 22 + Example: 17 23 18 24 pmic: pv88080@49 { 19 - compatible = "pvs,pv88080"; 25 + compatible = "pvs,pv88080-ba"; 20 26 reg = <0x49>; 21 27 interrupt-parent = <&gpio>; 22 28 interrupts = <24 24>; ··· 51 45 regulator-min-microamp = <1496000>; 52 46 regulator-max-microamp = <4189000>; 53 47 }; 48 + 49 + HVBUCK { 50 + regulator-name = "hvbuck"; 51 + regulator-min-microvolt = < 5000>; 52 + regulator-max-microvolt = <1275000>; 53 + }; 54 54 }; 55 55 }; 56 +
+1 -1
Documentation/devicetree/bindings/regulator/regulator.txt
··· 13 13 - regulator-allow-bypass: allow the regulator to go into bypass mode 14 14 - regulator-allow-set-load: allow the regulator performance level to be configured 15 15 - <name>-supply: phandle to the parent supply/regulator node 16 - - regulator-ramp-delay: ramp delay for regulator(in uV/uS) 16 + - regulator-ramp-delay: ramp delay for regulator(in uV/us) 17 17 For hardware which supports disabling ramp rate, it should be explicitly 18 18 initialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay. 19 19 - regulator-enable-ramp-delay: The time taken, in microseconds, for the supply
+9
drivers/mfd/tps65218.c
··· 219 219 struct tps65218 *tps; 220 220 const struct of_device_id *match; 221 221 int ret; 222 + unsigned int chipid; 222 223 223 224 match = of_match_device(of_tps65218_match_table, &client->dev); 224 225 if (!match) { ··· 250 249 &tps->irq_data); 251 250 if (ret < 0) 252 251 return ret; 252 + 253 + ret = tps65218_reg_read(tps, TPS65218_REG_CHIPID, &chipid); 254 + if (ret) { 255 + dev_err(tps->dev, "Failed to read chipid: %d\n", ret); 256 + return ret; 257 + } 258 + 259 + tps->rev = chipid & TPS65218_CHIPID_REV_MASK; 253 260 254 261 ret = of_platform_populate(client->dev.of_node, NULL, NULL, 255 262 &client->dev);
+73 -41
drivers/regulator/core.c
··· 2743 2743 return ret; 2744 2744 } 2745 2745 2746 + static int _regulator_set_voltage_time(struct regulator_dev *rdev, 2747 + int old_uV, int new_uV) 2748 + { 2749 + unsigned int ramp_delay = 0; 2750 + 2751 + if (rdev->constraints->ramp_delay) 2752 + ramp_delay = rdev->constraints->ramp_delay; 2753 + else if (rdev->desc->ramp_delay) 2754 + ramp_delay = rdev->desc->ramp_delay; 2755 + 2756 + if (ramp_delay == 0) { 2757 + rdev_warn(rdev, "ramp_delay not set\n"); 2758 + return 0; 2759 + } 2760 + 2761 + return DIV_ROUND_UP(abs(new_uV - old_uV), ramp_delay); 2762 + } 2763 + 2746 2764 static int _regulator_do_set_voltage(struct regulator_dev *rdev, 2747 2765 int min_uV, int max_uV) 2748 2766 { ··· 2769 2751 int best_val = 0; 2770 2752 unsigned int selector; 2771 2753 int old_selector = -1; 2754 + const struct regulator_ops *ops = rdev->desc->ops; 2755 + int old_uV = _regulator_get_voltage(rdev); 2772 2756 2773 2757 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); 2774 2758 ··· 2782 2762 * info to call set_voltage_time_sel(). 2783 2763 */ 2784 2764 if (_regulator_is_enabled(rdev) && 2785 - rdev->desc->ops->set_voltage_time_sel && 2786 - rdev->desc->ops->get_voltage_sel) { 2787 - old_selector = rdev->desc->ops->get_voltage_sel(rdev); 2765 + ops->set_voltage_time_sel && ops->get_voltage_sel) { 2766 + old_selector = ops->get_voltage_sel(rdev); 2788 2767 if (old_selector < 0) 2789 2768 return old_selector; 2790 2769 } 2791 2770 2792 - if (rdev->desc->ops->set_voltage) { 2771 + if (ops->set_voltage) { 2793 2772 ret = _regulator_call_set_voltage(rdev, min_uV, max_uV, 2794 2773 &selector); 2795 2774 2796 2775 if (ret >= 0) { 2797 - if (rdev->desc->ops->list_voltage) 2798 - best_val = rdev->desc->ops->list_voltage(rdev, 2799 - selector); 2776 + if (ops->list_voltage) 2777 + best_val = ops->list_voltage(rdev, 2778 + selector); 2800 2779 else 2801 2780 best_val = _regulator_get_voltage(rdev); 2802 2781 } 2803 2782 2804 - } else if (rdev->desc->ops->set_voltage_sel) { 2783 + } else if (ops->set_voltage_sel) { 2805 2784 ret = regulator_map_voltage(rdev, min_uV, max_uV); 2806 2785 if (ret >= 0) { 2807 - best_val = rdev->desc->ops->list_voltage(rdev, ret); 2786 + best_val = ops->list_voltage(rdev, ret); 2808 2787 if (min_uV <= best_val && max_uV >= best_val) { 2809 2788 selector = ret; 2810 2789 if (old_selector == selector) ··· 2819 2800 ret = -EINVAL; 2820 2801 } 2821 2802 2822 - /* Call set_voltage_time_sel if successfully obtained old_selector */ 2823 - if (ret == 0 && !rdev->constraints->ramp_disable && old_selector >= 0 2824 - && old_selector != selector) { 2803 + if (ret) 2804 + goto out; 2825 2805 2826 - delay = rdev->desc->ops->set_voltage_time_sel(rdev, 2827 - old_selector, selector); 2828 - if (delay < 0) { 2829 - rdev_warn(rdev, "set_voltage_time_sel() failed: %d\n", 2830 - delay); 2831 - delay = 0; 2832 - } 2833 - 2834 - /* Insert any necessary delays */ 2835 - if (delay >= 1000) { 2836 - mdelay(delay / 1000); 2837 - udelay(delay % 1000); 2838 - } else if (delay) { 2839 - udelay(delay); 2806 + if (ops->set_voltage_time_sel) { 2807 + /* 2808 + * Call set_voltage_time_sel if successfully obtained 2809 + * old_selector 2810 + */ 2811 + if (old_selector >= 0 && old_selector != selector) 2812 + delay = ops->set_voltage_time_sel(rdev, old_selector, 2813 + selector); 2814 + } else { 2815 + if (old_uV != best_val) { 2816 + if (ops->set_voltage_time) 2817 + delay = ops->set_voltage_time(rdev, old_uV, 2818 + best_val); 2819 + else 2820 + delay = _regulator_set_voltage_time(rdev, 2821 + old_uV, 2822 + best_val); 2840 2823 } 2841 2824 } 2842 2825 2843 - if (ret == 0 && best_val >= 0) { 2826 + if (delay < 0) { 2827 + rdev_warn(rdev, "failed to get delay: %d\n", delay); 2828 + delay = 0; 2829 + } 2830 + 2831 + /* Insert any necessary delays */ 2832 + if (delay >= 1000) { 2833 + mdelay(delay / 1000); 2834 + udelay(delay % 1000); 2835 + } else if (delay) { 2836 + udelay(delay); 2837 + } 2838 + 2839 + if (best_val >= 0) { 2844 2840 unsigned long data = best_val; 2845 2841 2846 2842 _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, 2847 2843 (void *)data); 2848 2844 } 2849 2845 2846 + out: 2850 2847 trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val); 2851 2848 2852 2849 return ret; ··· 3033 2998 int voltage; 3034 2999 int i; 3035 3000 3001 + if (ops->set_voltage_time) 3002 + return ops->set_voltage_time(rdev, old_uV, new_uV); 3003 + else if (!ops->set_voltage_time_sel) 3004 + return _regulator_set_voltage_time(rdev, old_uV, new_uV); 3005 + 3036 3006 /* Currently requires operations to do this */ 3037 - if (!ops->list_voltage || !ops->set_voltage_time_sel 3038 - || !rdev->desc->n_voltages) 3007 + if (!ops->list_voltage || !rdev->desc->n_voltages) 3039 3008 return -EINVAL; 3040 3009 3041 3010 for (i = 0; i < rdev->desc->n_voltages; i++) { ··· 3078 3039 unsigned int old_selector, 3079 3040 unsigned int new_selector) 3080 3041 { 3081 - unsigned int ramp_delay = 0; 3082 3042 int old_volt, new_volt; 3083 - 3084 - if (rdev->constraints->ramp_delay) 3085 - ramp_delay = rdev->constraints->ramp_delay; 3086 - else if (rdev->desc->ramp_delay) 3087 - ramp_delay = rdev->desc->ramp_delay; 3088 - 3089 - if (ramp_delay == 0) { 3090 - rdev_warn(rdev, "ramp_delay not set\n"); 3091 - return 0; 3092 - } 3093 3043 3094 3044 /* sanity check */ 3095 3045 if (!rdev->desc->ops->list_voltage) ··· 3087 3059 old_volt = rdev->desc->ops->list_voltage(rdev, old_selector); 3088 3060 new_volt = rdev->desc->ops->list_voltage(rdev, new_selector); 3089 3061 3090 - return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay); 3062 + if (rdev->desc->ops->set_voltage_time) 3063 + return rdev->desc->ops->set_voltage_time(rdev, old_volt, 3064 + new_volt); 3065 + else 3066 + return _regulator_set_voltage_time(rdev, old_volt, new_volt); 3091 3067 } 3092 3068 EXPORT_SYMBOL_GPL(regulator_set_voltage_time_sel); 3093 3069
+234 -29
drivers/regulator/pv88080-regulator.c
··· 16 16 #include <linux/err.h> 17 17 #include <linux/i2c.h> 18 18 #include <linux/module.h> 19 + #include <linux/of.h> 19 20 #include <linux/init.h> 20 21 #include <linux/slab.h> 21 22 #include <linux/regulator/driver.h> ··· 27 26 #include <linux/regulator/of_regulator.h> 28 27 #include "pv88080-regulator.h" 29 28 30 - #define PV88080_MAX_REGULATORS 3 29 + #define PV88080_MAX_REGULATORS 4 31 30 32 31 /* PV88080 REGULATOR IDs */ 33 32 enum { ··· 35 34 PV88080_ID_BUCK1, 36 35 PV88080_ID_BUCK2, 37 36 PV88080_ID_BUCK3, 37 + PV88080_ID_HVBUCK, 38 + }; 39 + 40 + enum pv88080_types { 41 + TYPE_PV88080_AA, 42 + TYPE_PV88080_BA, 38 43 }; 39 44 40 45 struct pv88080_regulator { ··· 49 42 unsigned int n_current_limits; 50 43 const int *current_limits; 51 44 unsigned int limit_mask; 52 - unsigned int conf; 45 + unsigned int mode_reg; 46 + unsigned int limit_reg; 53 47 unsigned int conf2; 54 48 unsigned int conf5; 55 49 }; ··· 59 51 struct device *dev; 60 52 struct regmap *regmap; 61 53 struct regulator_dev *rdev[PV88080_MAX_REGULATORS]; 54 + unsigned long type; 55 + const struct pv88080_compatible_regmap *regmap_config; 62 56 }; 63 57 64 58 struct pv88080_buck_voltage { 65 59 int min_uV; 66 60 int max_uV; 67 61 int uV_step; 62 + }; 63 + 64 + struct pv88080_buck_regmap { 65 + /* REGS */ 66 + int buck_enable_reg; 67 + int buck_vsel_reg; 68 + int buck_mode_reg; 69 + int buck_limit_reg; 70 + int buck_vdac_range_reg; 71 + int buck_vrange_gain_reg; 72 + /* MASKS */ 73 + int buck_enable_mask; 74 + int buck_vsel_mask; 75 + int buck_limit_mask; 76 + }; 77 + 78 + struct pv88080_compatible_regmap { 79 + /* BUCK1, 2, 3 */ 80 + struct pv88080_buck_regmap buck_regmap[PV88080_MAX_REGULATORS-1]; 81 + /* HVBUCK */ 82 + int hvbuck_enable_reg; 83 + int hvbuck_vsel_reg; 84 + int hvbuck_enable_mask; 85 + int hvbuck_vsel_mask; 68 86 }; 69 87 70 88 static const struct regmap_config pv88080_regmap_config = { ··· 123 89 }, 124 90 }; 125 91 92 + static const struct pv88080_compatible_regmap pv88080_aa_regs = { 93 + /* BUCK1 */ 94 + .buck_regmap[0] = { 95 + .buck_enable_reg = PV88080AA_REG_BUCK1_CONF0, 96 + .buck_vsel_reg = PV88080AA_REG_BUCK1_CONF0, 97 + .buck_mode_reg = PV88080AA_REG_BUCK1_CONF1, 98 + .buck_limit_reg = PV88080AA_REG_BUCK1_CONF1, 99 + .buck_vdac_range_reg = PV88080AA_REG_BUCK1_CONF2, 100 + .buck_vrange_gain_reg = PV88080AA_REG_BUCK1_CONF5, 101 + .buck_enable_mask = PV88080_BUCK1_EN, 102 + .buck_vsel_mask = PV88080_VBUCK1_MASK, 103 + .buck_limit_mask = PV88080_BUCK1_ILIM_MASK, 104 + }, 105 + /* BUCK2 */ 106 + .buck_regmap[1] = { 107 + .buck_enable_reg = PV88080AA_REG_BUCK2_CONF0, 108 + .buck_vsel_reg = PV88080AA_REG_BUCK2_CONF0, 109 + .buck_mode_reg = PV88080AA_REG_BUCK2_CONF1, 110 + .buck_limit_reg = PV88080AA_REG_BUCK2_CONF1, 111 + .buck_vdac_range_reg = PV88080AA_REG_BUCK2_CONF2, 112 + .buck_vrange_gain_reg = PV88080AA_REG_BUCK2_CONF5, 113 + .buck_enable_mask = PV88080_BUCK2_EN, 114 + .buck_vsel_mask = PV88080_VBUCK2_MASK, 115 + .buck_limit_mask = PV88080_BUCK2_ILIM_MASK, 116 + }, 117 + /* BUCK3 */ 118 + .buck_regmap[2] = { 119 + .buck_enable_reg = PV88080AA_REG_BUCK3_CONF0, 120 + .buck_vsel_reg = PV88080AA_REG_BUCK3_CONF0, 121 + .buck_mode_reg = PV88080AA_REG_BUCK3_CONF1, 122 + .buck_limit_reg = PV88080AA_REG_BUCK3_CONF1, 123 + .buck_vdac_range_reg = PV88080AA_REG_BUCK3_CONF2, 124 + .buck_vrange_gain_reg = PV88080AA_REG_BUCK3_CONF5, 125 + .buck_enable_mask = PV88080_BUCK3_EN, 126 + .buck_vsel_mask = PV88080_VBUCK3_MASK, 127 + .buck_limit_mask = PV88080_BUCK3_ILIM_MASK, 128 + }, 129 + /* HVBUCK */ 130 + .hvbuck_enable_reg = PV88080AA_REG_HVBUCK_CONF2, 131 + .hvbuck_vsel_reg = PV88080AA_REG_HVBUCK_CONF1, 132 + .hvbuck_enable_mask = PV88080_HVBUCK_EN, 133 + .hvbuck_vsel_mask = PV88080_VHVBUCK_MASK, 134 + }; 135 + 136 + static const struct pv88080_compatible_regmap pv88080_ba_regs = { 137 + /* BUCK1 */ 138 + .buck_regmap[0] = { 139 + .buck_enable_reg = PV88080BA_REG_BUCK1_CONF0, 140 + .buck_vsel_reg = PV88080BA_REG_BUCK1_CONF0, 141 + .buck_mode_reg = PV88080BA_REG_BUCK1_CONF1, 142 + .buck_limit_reg = PV88080BA_REG_BUCK1_CONF1, 143 + .buck_vdac_range_reg = PV88080BA_REG_BUCK1_CONF2, 144 + .buck_vrange_gain_reg = PV88080BA_REG_BUCK1_CONF5, 145 + .buck_enable_mask = PV88080_BUCK1_EN, 146 + .buck_vsel_mask = PV88080_VBUCK1_MASK, 147 + .buck_limit_mask = PV88080_BUCK1_ILIM_MASK, 148 + }, 149 + /* BUCK2 */ 150 + .buck_regmap[1] = { 151 + .buck_enable_reg = PV88080BA_REG_BUCK2_CONF0, 152 + .buck_vsel_reg = PV88080BA_REG_BUCK2_CONF0, 153 + .buck_mode_reg = PV88080BA_REG_BUCK2_CONF1, 154 + .buck_limit_reg = PV88080BA_REG_BUCK2_CONF1, 155 + .buck_vdac_range_reg = PV88080BA_REG_BUCK2_CONF2, 156 + .buck_vrange_gain_reg = PV88080BA_REG_BUCK2_CONF5, 157 + .buck_enable_mask = PV88080_BUCK2_EN, 158 + .buck_vsel_mask = PV88080_VBUCK2_MASK, 159 + .buck_limit_mask = PV88080_BUCK2_ILIM_MASK, 160 + }, 161 + /* BUCK3 */ 162 + .buck_regmap[2] = { 163 + .buck_enable_reg = PV88080BA_REG_BUCK3_CONF0, 164 + .buck_vsel_reg = PV88080BA_REG_BUCK3_CONF0, 165 + .buck_mode_reg = PV88080BA_REG_BUCK3_CONF1, 166 + .buck_limit_reg = PV88080BA_REG_BUCK3_CONF1, 167 + .buck_vdac_range_reg = PV88080BA_REG_BUCK3_CONF2, 168 + .buck_vrange_gain_reg = PV88080BA_REG_BUCK3_CONF5, 169 + .buck_enable_mask = PV88080_BUCK3_EN, 170 + .buck_vsel_mask = PV88080_VBUCK3_MASK, 171 + .buck_limit_mask = PV88080_BUCK3_ILIM_MASK, 172 + }, 173 + /* HVBUCK */ 174 + .hvbuck_enable_reg = PV88080BA_REG_HVBUCK_CONF2, 175 + .hvbuck_vsel_reg = PV88080BA_REG_HVBUCK_CONF1, 176 + .hvbuck_enable_mask = PV88080_HVBUCK_EN, 177 + .hvbuck_vsel_mask = PV88080_VHVBUCK_MASK, 178 + }; 179 + 180 + #ifdef CONFIG_OF 181 + static const struct of_device_id pv88080_dt_ids[] = { 182 + { .compatible = "pvs,pv88080", .data = (void *)TYPE_PV88080_AA }, 183 + { .compatible = "pvs,pv88080-aa", .data = (void *)TYPE_PV88080_AA }, 184 + { .compatible = "pvs,pv88080-ba", .data = (void *)TYPE_PV88080_BA }, 185 + {}, 186 + }; 187 + MODULE_DEVICE_TABLE(of, pv88080_dt_ids); 188 + #endif 189 + 126 190 static unsigned int pv88080_buck_get_mode(struct regulator_dev *rdev) 127 191 { 128 192 struct pv88080_regulator *info = rdev_get_drvdata(rdev); 129 193 unsigned int data; 130 194 int ret, mode = 0; 131 195 132 - ret = regmap_read(rdev->regmap, info->conf, &data); 196 + ret = regmap_read(rdev->regmap, info->mode_reg, &data); 133 197 if (ret < 0) 134 198 return ret; 135 199 ··· 268 136 return -EINVAL; 269 137 } 270 138 271 - return regmap_update_bits(rdev->regmap, info->conf, 139 + return regmap_update_bits(rdev->regmap, info->mode_reg, 272 140 PV88080_BUCK1_MODE_MASK, val); 273 141 } 274 142 ··· 283 151 if (min <= info->current_limits[i] 284 152 && max >= info->current_limits[i]) { 285 153 return regmap_update_bits(rdev->regmap, 286 - info->conf, 154 + info->limit_reg, 287 155 info->limit_mask, 288 156 i << PV88080_BUCK1_ILIM_SHIFT); 289 157 } ··· 298 166 unsigned int data; 299 167 int ret; 300 168 301 - ret = regmap_read(rdev->regmap, info->conf, &data); 169 + ret = regmap_read(rdev->regmap, info->limit_reg, &data); 302 170 if (ret < 0) 303 171 return ret; 304 172 ··· 319 187 .get_current_limit = pv88080_get_current_limit, 320 188 }; 321 189 190 + static struct regulator_ops pv88080_hvbuck_ops = { 191 + .enable = regulator_enable_regmap, 192 + .disable = regulator_disable_regmap, 193 + .is_enabled = regulator_is_enabled_regmap, 194 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 195 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 196 + .list_voltage = regulator_list_voltage_linear, 197 + }; 198 + 322 199 #define PV88080_BUCK(chip, regl_name, min, step, max, limits_array) \ 323 200 {\ 324 201 .desc = {\ ··· 341 200 .min_uV = min, \ 342 201 .uV_step = step, \ 343 202 .n_voltages = ((max) - (min))/(step) + 1, \ 344 - .enable_reg = PV88080_REG_##regl_name##_CONF0, \ 345 - .enable_mask = PV88080_##regl_name##_EN, \ 346 - .vsel_reg = PV88080_REG_##regl_name##_CONF0, \ 347 - .vsel_mask = PV88080_V##regl_name##_MASK, \ 348 203 },\ 349 204 .current_limits = limits_array, \ 350 205 .n_current_limits = ARRAY_SIZE(limits_array), \ 351 - .limit_mask = PV88080_##regl_name##_ILIM_MASK, \ 352 - .conf = PV88080_REG_##regl_name##_CONF1, \ 353 - .conf2 = PV88080_REG_##regl_name##_CONF2, \ 354 - .conf5 = PV88080_REG_##regl_name##_CONF5, \ 206 + } 207 + 208 + #define PV88080_HVBUCK(chip, regl_name, min, step, max) \ 209 + {\ 210 + .desc = {\ 211 + .id = chip##_ID_##regl_name,\ 212 + .name = __stringify(chip##_##regl_name),\ 213 + .of_match = of_match_ptr(#regl_name),\ 214 + .regulators_node = of_match_ptr("regulators"),\ 215 + .type = REGULATOR_VOLTAGE,\ 216 + .owner = THIS_MODULE,\ 217 + .ops = &pv88080_hvbuck_ops,\ 218 + .min_uV = min, \ 219 + .uV_step = step, \ 220 + .n_voltages = ((max) - (min))/(step) + 1, \ 221 + },\ 355 222 } 356 223 357 224 static struct pv88080_regulator pv88080_regulator_info[] = { ··· 369 220 pv88080_buck23_limits), 370 221 PV88080_BUCK(PV88080, BUCK3, 600000, 6250, 1393750, 371 222 pv88080_buck23_limits), 223 + PV88080_HVBUCK(PV88080, HVBUCK, 0, 5000, 1275000), 372 224 }; 373 225 374 226 static irqreturn_t pv88080_irq_handler(int irq, void *data) ··· 430 280 { 431 281 struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); 432 282 struct pv88080 *chip; 283 + const struct pv88080_compatible_regmap *regmap_config; 284 + const struct of_device_id *match; 433 285 struct regulator_config config = { }; 434 286 int i, error, ret; 435 287 unsigned int conf2, conf5; ··· 447 295 dev_err(chip->dev, "Failed to allocate register map: %d\n", 448 296 error); 449 297 return error; 298 + } 299 + 300 + if (i2c->dev.of_node) { 301 + match = of_match_node(pv88080_dt_ids, i2c->dev.of_node); 302 + if (!match) { 303 + dev_err(chip->dev, "Failed to get of_match_node\n"); 304 + return -EINVAL; 305 + } 306 + chip->type = (unsigned long)match->data; 307 + } else { 308 + chip->type = id->driver_data; 450 309 } 451 310 452 311 i2c_set_clientdata(i2c, chip); ··· 499 336 "Failed to update mask reg: %d\n", ret); 500 337 return ret; 501 338 } 502 - 503 339 } else { 504 340 dev_warn(chip->dev, "No IRQ configured\n"); 505 341 } 506 342 343 + switch (chip->type) { 344 + case TYPE_PV88080_AA: 345 + chip->regmap_config = &pv88080_aa_regs; 346 + break; 347 + case TYPE_PV88080_BA: 348 + chip->regmap_config = &pv88080_ba_regs; 349 + break; 350 + } 351 + 352 + regmap_config = chip->regmap_config; 507 353 config.dev = chip->dev; 508 354 config.regmap = chip->regmap; 509 355 510 - for (i = 0; i < PV88080_MAX_REGULATORS; i++) { 356 + /* Registeration for BUCK1, 2, 3 */ 357 + for (i = 0; i < PV88080_MAX_REGULATORS-1; i++) { 511 358 if (init_data) 512 359 config.init_data = &init_data[i]; 513 360 361 + pv88080_regulator_info[i].limit_reg 362 + = regmap_config->buck_regmap[i].buck_limit_reg; 363 + pv88080_regulator_info[i].limit_mask 364 + = regmap_config->buck_regmap[i].buck_limit_mask; 365 + pv88080_regulator_info[i].mode_reg 366 + = regmap_config->buck_regmap[i].buck_mode_reg; 367 + pv88080_regulator_info[i].conf2 368 + = regmap_config->buck_regmap[i].buck_vdac_range_reg; 369 + pv88080_regulator_info[i].conf5 370 + = regmap_config->buck_regmap[i].buck_vrange_gain_reg; 371 + pv88080_regulator_info[i].desc.enable_reg 372 + = regmap_config->buck_regmap[i].buck_enable_reg; 373 + pv88080_regulator_info[i].desc.enable_mask 374 + = regmap_config->buck_regmap[i].buck_enable_mask; 375 + pv88080_regulator_info[i].desc.vsel_reg 376 + = regmap_config->buck_regmap[i].buck_vsel_reg; 377 + pv88080_regulator_info[i].desc.vsel_mask 378 + = regmap_config->buck_regmap[i].buck_vsel_mask; 379 + 514 380 ret = regmap_read(chip->regmap, 515 - pv88080_regulator_info[i].conf2, &conf2); 381 + pv88080_regulator_info[i].conf2, &conf2); 516 382 if (ret < 0) 517 383 return ret; 518 - 519 384 conf2 = ((conf2 >> PV88080_BUCK_VDAC_RANGE_SHIFT) & 520 385 PV88080_BUCK_VDAC_RANGE_MASK); 521 386 522 387 ret = regmap_read(chip->regmap, 523 - pv88080_regulator_info[i].conf5, &conf5); 388 + pv88080_regulator_info[i].conf5, &conf5); 524 389 if (ret < 0) 525 390 return ret; 526 - 527 391 conf5 = ((conf5 >> PV88080_BUCK_VRANGE_GAIN_SHIFT) & 528 392 PV88080_BUCK_VRANGE_GAIN_MASK); 529 393 ··· 573 383 } 574 384 } 575 385 386 + pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_reg 387 + = regmap_config->hvbuck_enable_reg; 388 + pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_mask 389 + = regmap_config->hvbuck_enable_mask; 390 + pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_reg 391 + = regmap_config->hvbuck_vsel_reg; 392 + pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_mask 393 + = regmap_config->hvbuck_vsel_mask; 394 + 395 + /* Registeration for HVBUCK */ 396 + if (init_data) 397 + config.init_data = &init_data[PV88080_ID_HVBUCK]; 398 + 399 + config.driver_data = (void *)&pv88080_regulator_info[PV88080_ID_HVBUCK]; 400 + chip->rdev[PV88080_ID_HVBUCK] = devm_regulator_register(chip->dev, 401 + &pv88080_regulator_info[PV88080_ID_HVBUCK].desc, &config); 402 + if (IS_ERR(chip->rdev[PV88080_ID_HVBUCK])) { 403 + dev_err(chip->dev, "Failed to register PV88080 regulator\n"); 404 + return PTR_ERR(chip->rdev[PV88080_ID_HVBUCK]); 405 + } 406 + 576 407 return 0; 577 408 } 578 409 579 410 static const struct i2c_device_id pv88080_i2c_id[] = { 580 - {"pv88080", 0}, 411 + { "pv88080", TYPE_PV88080_AA }, 412 + { "pv88080-aa", TYPE_PV88080_AA }, 413 + { "pv88080-ba", TYPE_PV88080_BA }, 581 414 {}, 582 415 }; 583 416 MODULE_DEVICE_TABLE(i2c, pv88080_i2c_id); 584 - 585 - #ifdef CONFIG_OF 586 - static const struct of_device_id pv88080_dt_ids[] = { 587 - { .compatible = "pvs,pv88080", .data = &pv88080_i2c_id[0] }, 588 - {}, 589 - }; 590 - MODULE_DEVICE_TABLE(of, pv88080_dt_ids); 591 - #endif 592 417 593 418 static struct i2c_driver pv88080_regulator_driver = { 594 419 .driver = {
+71 -45
drivers/regulator/pv88080-regulator.h
··· 17 17 #define __PV88080_REGISTERS_H__ 18 18 19 19 /* System Control and Event Registers */ 20 - #define PV88080_REG_EVENT_A 0x04 21 - #define PV88080_REG_MASK_A 0x09 22 - #define PV88080_REG_MASK_B 0x0a 23 - #define PV88080_REG_MASK_C 0x0b 20 + #define PV88080_REG_EVENT_A 0x04 21 + #define PV88080_REG_MASK_A 0x09 22 + #define PV88080_REG_MASK_B 0x0A 23 + #define PV88080_REG_MASK_C 0x0B 24 24 25 - /* Regulator Registers */ 26 - #define PV88080_REG_BUCK1_CONF0 0x27 27 - #define PV88080_REG_BUCK1_CONF1 0x28 28 - #define PV88080_REG_BUCK1_CONF2 0x59 29 - #define PV88080_REG_BUCK1_CONF5 0x5c 30 - #define PV88080_REG_BUCK2_CONF0 0x29 31 - #define PV88080_REG_BUCK2_CONF1 0x2a 32 - #define PV88080_REG_BUCK2_CONF2 0x61 33 - #define PV88080_REG_BUCK2_CONF5 0x64 34 - #define PV88080_REG_BUCK3_CONF0 0x2b 35 - #define PV88080_REG_BUCK3_CONF1 0x2c 36 - #define PV88080_REG_BUCK3_CONF2 0x69 37 - #define PV88080_REG_BUCK3_CONF5 0x6c 25 + /* Regulator Registers - rev. AA */ 26 + #define PV88080AA_REG_HVBUCK_CONF1 0x2D 27 + #define PV88080AA_REG_HVBUCK_CONF2 0x2E 28 + #define PV88080AA_REG_BUCK1_CONF0 0x27 29 + #define PV88080AA_REG_BUCK1_CONF1 0x28 30 + #define PV88080AA_REG_BUCK1_CONF2 0x59 31 + #define PV88080AA_REG_BUCK1_CONF5 0x5C 32 + #define PV88080AA_REG_BUCK2_CONF0 0x29 33 + #define PV88080AA_REG_BUCK2_CONF1 0x2A 34 + #define PV88080AA_REG_BUCK2_CONF2 0x61 35 + #define PV88080AA_REG_BUCK2_CONF5 0x64 36 + #define PV88080AA_REG_BUCK3_CONF0 0x2B 37 + #define PV88080AA_REG_BUCK3_CONF1 0x2C 38 + #define PV88080AA_REG_BUCK3_CONF2 0x69 39 + #define PV88080AA_REG_BUCK3_CONF5 0x6C 40 + 41 + /* Regulator Registers - rev. BA */ 42 + #define PV88080BA_REG_HVBUCK_CONF1 0x33 43 + #define PV88080BA_REG_HVBUCK_CONF2 0x34 44 + #define PV88080BA_REG_BUCK1_CONF0 0x2A 45 + #define PV88080BA_REG_BUCK1_CONF1 0x2C 46 + #define PV88080BA_REG_BUCK1_CONF2 0x5A 47 + #define PV88080BA_REG_BUCK1_CONF5 0x5D 48 + #define PV88080BA_REG_BUCK2_CONF0 0x2D 49 + #define PV88080BA_REG_BUCK2_CONF1 0x2F 50 + #define PV88080BA_REG_BUCK2_CONF2 0x63 51 + #define PV88080BA_REG_BUCK2_CONF5 0x66 52 + #define PV88080BA_REG_BUCK3_CONF0 0x30 53 + #define PV88080BA_REG_BUCK3_CONF1 0x32 54 + #define PV88080BA_REG_BUCK3_CONF2 0x6C 55 + #define PV88080BA_REG_BUCK3_CONF5 0x6F 38 56 39 57 /* PV88080_REG_EVENT_A (addr=0x04) */ 40 58 #define PV88080_E_VDD_FLT 0x01 41 - #define PV88080_E_OVER_TEMP 0x02 59 + #define PV88080_E_OVER_TEMP 0x02 42 60 43 61 /* PV88080_REG_MASK_A (addr=0x09) */ 44 62 #define PV88080_M_VDD_FLT 0x01 45 - #define PV88080_M_OVER_TEMP 0x02 63 + #define PV88080_M_OVER_TEMP 0x02 46 64 47 - /* PV88080_REG_BUCK1_CONF0 (addr=0x27) */ 65 + /* PV88080_REG_BUCK1_CONF0 (addr=0x27|0x2A) */ 48 66 #define PV88080_BUCK1_EN 0x80 49 - #define PV88080_VBUCK1_MASK 0x7F 50 - /* PV88080_REG_BUCK2_CONF0 (addr=0x29) */ 51 - #define PV88080_BUCK2_EN 0x80 52 - #define PV88080_VBUCK2_MASK 0x7F 53 - /* PV88080_REG_BUCK3_CONF0 (addr=0x2b) */ 54 - #define PV88080_BUCK3_EN 0x80 55 - #define PV88080_VBUCK3_MASK 0x7F 67 + #define PV88080_VBUCK1_MASK 0x7F 56 68 57 - /* PV88080_REG_BUCK1_CONF1 (addr=0x28) */ 58 - #define PV88080_BUCK1_ILIM_SHIFT 2 69 + /* PV88080_REG_BUCK2_CONF0 (addr=0x29|0x2D) */ 70 + #define PV88080_BUCK2_EN 0x80 71 + #define PV88080_VBUCK2_MASK 0x7F 72 + 73 + /* PV88080_REG_BUCK3_CONF0 (addr=0x2B|0x30) */ 74 + #define PV88080_BUCK3_EN 0x80 75 + #define PV88080_VBUCK3_MASK 0x7F 76 + 77 + /* PV88080_REG_BUCK1_CONF1 (addr=0x28|0x2C) */ 78 + #define PV88080_BUCK1_ILIM_SHIFT 2 59 79 #define PV88080_BUCK1_ILIM_MASK 0x0C 60 80 #define PV88080_BUCK1_MODE_MASK 0x03 61 81 62 - /* PV88080_REG_BUCK2_CONF1 (addr=0x2a) */ 63 - #define PV88080_BUCK2_ILIM_SHIFT 2 82 + /* PV88080_REG_BUCK2_CONF1 (addr=0x2A|0x2F) */ 83 + #define PV88080_BUCK2_ILIM_SHIFT 2 64 84 #define PV88080_BUCK2_ILIM_MASK 0x0C 65 85 #define PV88080_BUCK2_MODE_MASK 0x03 66 86 67 - /* PV88080_REG_BUCK3_CONF1 (addr=0x2c) */ 68 - #define PV88080_BUCK3_ILIM_SHIFT 2 87 + /* PV88080_REG_BUCK3_CONF1 (addr=0x2C|0x32) */ 88 + #define PV88080_BUCK3_ILIM_SHIFT 2 69 89 #define PV88080_BUCK3_ILIM_MASK 0x0C 70 90 #define PV88080_BUCK3_MODE_MASK 0x03 71 91 ··· 93 73 #define PV88080_BUCK_MODE_AUTO 0x01 94 74 #define PV88080_BUCK_MODE_SYNC 0x02 95 75 96 - /* PV88080_REG_BUCK2_CONF2 (addr=0x61) */ 97 - /* PV88080_REG_BUCK3_CONF2 (addr=0x69) */ 98 - #define PV88080_BUCK_VDAC_RANGE_SHIFT 7 99 - #define PV88080_BUCK_VDAC_RANGE_MASK 0x01 76 + /* PV88080_REG_HVBUCK_CONF1 (addr=0x2D|0x33) */ 77 + #define PV88080_VHVBUCK_MASK 0xFF 100 78 101 - #define PV88080_BUCK_VDAC_RANGE_1 0x00 102 - #define PV88080_BUCK_VDAC_RANGE_2 0x01 79 + /* PV88080_REG_HVBUCK_CONF1 (addr=0x2E|0x34) */ 80 + #define PV88080_HVBUCK_EN 0x01 103 81 104 - /* PV88080_REG_BUCK2_CONF5 (addr=0x64) */ 105 - /* PV88080_REG_BUCK3_CONF5 (addr=0x6c) */ 106 - #define PV88080_BUCK_VRANGE_GAIN_SHIFT 0 107 - #define PV88080_BUCK_VRANGE_GAIN_MASK 0x01 82 + /* PV88080_REG_BUCK2_CONF2 (addr=0x61|0x63) */ 83 + /* PV88080_REG_BUCK3_CONF2 (addr=0x69|0x6C) */ 84 + #define PV88080_BUCK_VDAC_RANGE_SHIFT 7 85 + #define PV88080_BUCK_VDAC_RANGE_MASK 0x01 108 86 109 - #define PV88080_BUCK_VRANGE_GAIN_1 0x00 110 - #define PV88080_BUCK_VRANGE_GAIN_2 0x01 87 + #define PV88080_BUCK_VDAC_RANGE_1 0x00 88 + #define PV88080_BUCK_VDAC_RANGE_2 0x01 89 + 90 + /* PV88080_REG_BUCK2_CONF5 (addr=0x64|0x66) */ 91 + /* PV88080_REG_BUCK3_CONF5 (addr=0x6C|0x6F) */ 92 + #define PV88080_BUCK_VRANGE_GAIN_SHIFT 0 93 + #define PV88080_BUCK_VRANGE_GAIN_MASK 0x01 94 + 95 + #define PV88080_BUCK_VRANGE_GAIN_1 0x00 96 + #define PV88080_BUCK_VRANGE_GAIN_2 0x01 111 97 112 98 #endif /* __PV88080_REGISTERS_H__ */
-10
drivers/regulator/pwm-regulator.c
··· 10 10 * published by the Free Software Foundation. 11 11 */ 12 12 13 - #include <linux/delay.h> 14 13 #include <linux/module.h> 15 14 #include <linux/init.h> 16 15 #include <linux/err.h> ··· 193 194 unsigned int min_uV_duty = drvdata->continuous.min_uV_dutycycle; 194 195 unsigned int max_uV_duty = drvdata->continuous.max_uV_dutycycle; 195 196 unsigned int duty_unit = drvdata->continuous.dutycycle_unit; 196 - unsigned int ramp_delay = rdev->constraints->ramp_delay; 197 197 int min_uV = rdev->constraints->min_uV; 198 198 int max_uV = rdev->constraints->max_uV; 199 199 int diff_uV = max_uV - min_uV; 200 200 struct pwm_state pstate; 201 - int old_uV = pwm_regulator_get_voltage(rdev); 202 201 unsigned int diff_duty; 203 202 unsigned int dutycycle; 204 203 int ret; ··· 229 232 dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret); 230 233 return ret; 231 234 } 232 - 233 - if ((ramp_delay == 0) || !pwm_regulator_is_enabled(rdev)) 234 - return 0; 235 - 236 - /* Ramp delay is in uV/uS. Adjust to uS and delay */ 237 - ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay); 238 - usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10)); 239 235 240 236 return 0; 241 237 }
+1 -2
drivers/regulator/rk808-regulator.c
··· 533 533 static struct platform_driver rk808_regulator_driver = { 534 534 .probe = rk808_regulator_probe, 535 535 .driver = { 536 - .name = "rk808-regulator", 537 - .owner = THIS_MODULE, 536 + .name = "rk808-regulator" 538 537 }, 539 538 }; 540 539
+8
drivers/regulator/tps65218-regulator.c
··· 180 180 if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1) 181 181 return -EINVAL; 182 182 183 + /* 184 + * Certain revisions of TPS65218 will need to have DCDC3 regulator 185 + * enabled always, otherwise an immediate system reboot will occur 186 + * during poweroff. 187 + */ 188 + if (rid == TPS65218_DCDC_3 && tps->rev == TPS65218_REV_2_1) 189 + return 0; 190 + 183 191 if (!tps->info[rid]->strobe) { 184 192 if (rid == TPS65218_DCDC_3) 185 193 tps->info[rid]->strobe = 3;
+6
include/linux/mfd/tps65218.h
··· 63 63 #define TPS65218_CHIPID_CHIP_MASK 0xF8 64 64 #define TPS65218_CHIPID_REV_MASK 0x07 65 65 66 + #define TPS65218_REV_1_0 0x0 67 + #define TPS65218_REV_1_1 0x1 68 + #define TPS65218_REV_2_0 0x2 69 + #define TPS65218_REV_2_1 0x3 70 + 66 71 #define TPS65218_INT1_VPRG BIT(5) 67 72 #define TPS65218_INT1_AC BIT(4) 68 73 #define TPS65218_INT1_PB BIT(3) ··· 272 267 struct tps65218 { 273 268 struct device *dev; 274 269 unsigned int id; 270 + u8 rev; 275 271 276 272 struct mutex tps_lock; /* lock guarding the data structure */ 277 273 /* IRQ Data */
+8 -2
include/linux/regulator/driver.h
··· 113 113 * stabilise after being enabled, in microseconds. 114 114 * @set_ramp_delay: Set the ramp delay for the regulator. The driver should 115 115 * select ramp delay equal to or less than(closest) ramp_delay. 116 + * @set_voltage_time: Time taken for the regulator voltage output voltage 117 + * to stabilise after being set to a new value, in microseconds. 118 + * The function receives the from and to voltage as input, it 119 + * should return the worst case. 116 120 * @set_voltage_time_sel: Time taken for the regulator voltage output voltage 117 121 * to stabilise after being set to a new value, in microseconds. 118 - * The function provides the from and to voltage selector, the 119 - * function should return the worst case. 122 + * The function receives the from and to voltage selector as 123 + * input, it should return the worst case. 120 124 * @set_soft_start: Enable soft start for the regulator. 121 125 * 122 126 * @set_suspend_voltage: Set the voltage for the regulator when the system ··· 172 168 /* Time taken to enable or set voltage on the regulator */ 173 169 int (*enable_time) (struct regulator_dev *); 174 170 int (*set_ramp_delay) (struct regulator_dev *, int ramp_delay); 171 + int (*set_voltage_time) (struct regulator_dev *, int old_uV, 172 + int new_uV); 175 173 int (*set_voltage_time_sel) (struct regulator_dev *, 176 174 unsigned int old_selector, 177 175 unsigned int new_selector);