···5656Grouping of BUCKs sharing ramp rate setting is as follow : BUCK[1, 6],5757BUCK[3, 4], and BUCK[7, 8, 10]58585959+On S2MPS14 the LDO10, LDO11 and LDO12 can be configured to external control6060+over GPIO. To turn this feature on this property must be added to the regulator6161+sub-node:6262+ - samsung,ext-control-gpios: GPIO specifier for one GPIO6363+ controlling this regulator (enable/disable);6464+Example:6565+ LDO12 {6666+ regulator-name = "V_EMMC_2.8V";6767+ regulator-min-microvolt = <2800000>;6868+ regulator-max-microvolt = <2800000>;6969+ samsung,ext-control-gpios = <&gpk0 2 0>;7070+ };7171+7272+5973The regulator constraints inside the regulator nodes use the standard regulator6074bindings which are documented elsewhere.6175
+26-132
drivers/regulator/palmas-regulator.c
···3636 int sleep_id;3737};38383939+static const struct regulator_linear_range smps_low_ranges[] = {4040+ REGULATOR_LINEAR_RANGE(500000, 0x1, 0x6, 0),4141+ REGULATOR_LINEAR_RANGE(510000, 0x7, 0x79, 10000),4242+ REGULATOR_LINEAR_RANGE(1650000, 0x7A, 0x7f, 0),4343+};4444+4545+static const struct regulator_linear_range smps_high_ranges[] = {4646+ REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x6, 0),4747+ REGULATOR_LINEAR_RANGE(1020000, 0x7, 0x79, 20000),4848+ REGULATOR_LINEAR_RANGE(3300000, 0x7A, 0x7f, 0),4949+};5050+3951static const struct regs_info palmas_regs_info[] = {4052 {4153 .name = "SMPS12",···292280 return regmap_write(palmas->regmap[REGULATOR_SLAVE], addr, value);293281}294282295295-static int palmas_is_enabled_smps(struct regulator_dev *dev)296296-{297297- struct palmas_pmic *pmic = rdev_get_drvdata(dev);298298- int id = rdev_get_id(dev);299299- unsigned int reg;300300-301301- palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®);302302-303303- reg &= PALMAS_SMPS12_CTRL_STATUS_MASK;304304- reg >>= PALMAS_SMPS12_CTRL_STATUS_SHIFT;305305-306306- return !!(reg);307307-}308308-309309-static int palmas_enable_smps(struct regulator_dev *dev)310310-{311311- struct palmas_pmic *pmic = rdev_get_drvdata(dev);312312- int id = rdev_get_id(dev);313313- unsigned int reg;314314-315315- palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®);316316-317317- reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;318318- if (pmic->current_reg_mode[id])319319- reg |= pmic->current_reg_mode[id];320320- else321321- reg |= SMPS_CTRL_MODE_ON;322322-323323- palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);324324-325325- return 0;326326-}327327-328328-static int palmas_disable_smps(struct regulator_dev *dev)329329-{330330- struct palmas_pmic *pmic = rdev_get_drvdata(dev);331331- int id = rdev_get_id(dev);332332- unsigned int reg;333333-334334- palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®);335335-336336- reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;337337-338338- palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);339339-340340- return 0;341341-}342342-343283static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)344284{345285 struct palmas_pmic *pmic = rdev_get_drvdata(dev);···346382 return 0;347383}348384349349-static int palmas_list_voltage_smps(struct regulator_dev *dev,350350- unsigned selector)351351-{352352- struct palmas_pmic *pmic = rdev_get_drvdata(dev);353353- int id = rdev_get_id(dev);354354- int mult = 1;355355-356356- /* Read the multiplier set in VSEL register to return357357- * the correct voltage.358358- */359359- if (pmic->range[id])360360- mult = 2;361361-362362- if (selector == 0)363363- return 0;364364- else if (selector < 6)365365- return 500000 * mult;366366- else367367- /* Voltage is linear mapping starting from selector 6,368368- * volt = (0.49V + ((selector - 5) * 0.01V)) * RANGE369369- * RANGE is either x1 or x2370370- */371371- return (490000 + ((selector - 5) * 10000)) * mult;372372-}373373-374374-static int palmas_map_voltage_smps(struct regulator_dev *rdev,375375- int min_uV, int max_uV)376376-{377377- struct palmas_pmic *pmic = rdev_get_drvdata(rdev);378378- int id = rdev_get_id(rdev);379379- int ret, voltage;380380-381381- if (min_uV == 0)382382- return 0;383383-384384- if (pmic->range[id]) { /* RANGE is x2 */385385- if (min_uV < 1000000)386386- min_uV = 1000000;387387- ret = DIV_ROUND_UP(min_uV - 1000000, 20000) + 6;388388- } else { /* RANGE is x1 */389389- if (min_uV < 500000)390390- min_uV = 500000;391391- ret = DIV_ROUND_UP(min_uV - 500000, 10000) + 6;392392- }393393-394394- /* Map back into a voltage to verify we're still in bounds */395395- voltage = palmas_list_voltage_smps(rdev, ret);396396- if (voltage < min_uV || voltage > max_uV)397397- return -EINVAL;398398-399399- return ret;400400-}401401-402402-static int palma_smps_set_voltage_smps_time_sel(struct regulator_dev *rdev,403403- unsigned int old_selector, unsigned int new_selector)404404-{405405- struct palmas_pmic *pmic = rdev_get_drvdata(rdev);406406- int id = rdev_get_id(rdev);407407- int old_uv, new_uv;408408- unsigned int ramp_delay = pmic->ramp_delay[id];409409-410410- if (!ramp_delay)411411- return 0;412412-413413- old_uv = palmas_list_voltage_smps(rdev, old_selector);414414- if (old_uv < 0)415415- return old_uv;416416-417417- new_uv = palmas_list_voltage_smps(rdev, new_selector);418418- if (new_uv < 0)419419- return new_uv;420420-421421- return DIV_ROUND_UP(abs(old_uv - new_uv), ramp_delay);422422-}423423-424385static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,425386 int ramp_delay)426387{···382493}383494384495static struct regulator_ops palmas_ops_smps = {385385- .is_enabled = palmas_is_enabled_smps,386386- .enable = palmas_enable_smps,387387- .disable = palmas_disable_smps,496496+ .is_enabled = regulator_is_enabled_regmap,497497+ .enable = regulator_enable_regmap,498498+ .disable = regulator_disable_regmap,388499 .set_mode = palmas_set_mode_smps,389500 .get_mode = palmas_get_mode_smps,390501 .get_voltage_sel = regulator_get_voltage_sel_regmap,391502 .set_voltage_sel = regulator_set_voltage_sel_regmap,392392- .list_voltage = palmas_list_voltage_smps,393393- .map_voltage = palmas_map_voltage_smps,394394- .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel,503503+ .list_voltage = regulator_list_voltage_linear_range,504504+ .map_voltage = regulator_map_voltage_linear_range,505505+ .set_voltage_time_sel = regulator_set_voltage_time_sel,395506 .set_ramp_delay = palmas_smps_set_ramp_delay,396507};397508···400511 .get_mode = palmas_get_mode_smps,401512 .get_voltage_sel = regulator_get_voltage_sel_regmap,402513 .set_voltage_sel = regulator_set_voltage_sel_regmap,403403- .list_voltage = palmas_list_voltage_smps,404404- .map_voltage = palmas_map_voltage_smps,405405- .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel,514514+ .list_voltage = regulator_list_voltage_linear_range,515515+ .map_voltage = regulator_map_voltage_linear_range,516516+ .set_voltage_time_sel = regulator_set_voltage_time_sel,406517 .set_ramp_delay = palmas_smps_set_ramp_delay,407518};408519···9311042 * ranges. Read the current smps mode for later use.9321043 */9331044 addr = palmas_regs_info[id].vsel_addr;10451045+ pmic->desc[id].n_linear_ranges = 3;93410469351047 ret = palmas_smps_read(pmic->palmas, addr, ®);9361048 if (ret)9371049 return ret;9381050 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE)9391051 pmic->range[id] = 1;10521052+ if (pmic->range[id])10531053+ pmic->desc[id].linear_ranges = smps_high_ranges;10541054+ else10551055+ pmic->desc[id].linear_ranges = smps_low_ranges;94010569411057 if (reg_init && reg_init->roof_floor)9421058 pmic->desc[id].ops =