···20842084EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);2085208520862086/**20872087+ * regulator_list_voltage_linear_range - List voltages for linear ranges20882088+ *20892089+ * @rdev: Regulator device20902090+ * @selector: Selector to convert into a voltage20912091+ *20922092+ * Regulators with a series of simple linear mappings between voltages20932093+ * and selectors can set linear_ranges in the regulator descriptor and20942094+ * then use this function as their list_voltage() operation,20952095+ */20962096+int regulator_list_voltage_linear_range(struct regulator_dev *rdev,20972097+ unsigned int selector)20982098+{20992099+ const struct regulator_linear_range *range;21002100+ int i;21012101+21022102+ if (!rdev->desc->n_linear_ranges) {21032103+ BUG_ON(!rdev->desc->n_linear_ranges);21042104+ return -EINVAL;21052105+ }21062106+21072107+ for (i = 0; i < rdev->desc->n_linear_ranges; i++) {21082108+ range = &rdev->desc->linear_ranges[i];21092109+21102110+ if (!(selector >= range->min_sel &&21112111+ selector <= range->max_sel))21122112+ continue;21132113+21142114+ selector -= range->min_sel;21152115+21162116+ return range->min_uV + (range->uV_step * selector);21172117+ }21182118+21192119+ return -EINVAL;21202120+}21212121+EXPORT_SYMBOL_GPL(regulator_list_voltage_linear_range);21222122+21232123+/**20872124 * regulator_list_voltage_table - List voltages with table based mapping20882125 *20892126 * @rdev: Regulator device···24092372 return ret;24102373}24112374EXPORT_SYMBOL_GPL(regulator_map_voltage_linear);23752375+23762376+/**23772377+ * regulator_map_voltage_linear - map_voltage() for multiple linear ranges23782378+ *23792379+ * @rdev: Regulator to operate on23802380+ * @min_uV: Lower bound for voltage23812381+ * @max_uV: Upper bound for voltage23822382+ *23832383+ * Drivers providing linear_ranges in their descriptor can use this as23842384+ * their map_voltage() callback.23852385+ */23862386+int regulator_map_voltage_linear_range(struct regulator_dev *rdev,23872387+ int min_uV, int max_uV)23882388+{23892389+ const struct regulator_linear_range *range;23902390+ int ret = -EINVAL;23912391+ int voltage, i;23922392+23932393+ if (!rdev->desc->n_linear_ranges) {23942394+ BUG_ON(!rdev->desc->n_linear_ranges);23952395+ return -EINVAL;23962396+ }23972397+23982398+ for (i = 0; i < rdev->desc->n_linear_ranges; i++) {23992399+ range = &rdev->desc->linear_ranges[i];24002400+24012401+ if (!(min_uV <= range->max_uV && max_uV >= range->min_uV))24022402+ continue;24032403+24042404+ if (min_uV <= range->min_uV)24052405+ min_uV = range->min_uV;24062406+24072407+ /* range->uV_step == 0 means fixed voltage range */24082408+ if (range->uV_step == 0) {24092409+ ret = 0;24102410+ } else {24112411+ ret = DIV_ROUND_UP(min_uV - range->min_uV,24122412+ range->uV_step);24132413+ if (ret < 0)24142414+ return ret;24152415+ }24162416+24172417+ ret += range->min_sel;24182418+24192419+ break;24202420+ }24212421+24222422+ if (i == rdev->desc->n_linear_ranges)24232423+ return -EINVAL;24242424+24252425+ /* Map back into a voltage to verify we're still in bounds */24262426+ voltage = rdev->desc->ops->list_voltage(rdev, ret);24272427+ if (voltage < min_uV || voltage > max_uV)24282428+ return -EINVAL;24292429+24302430+ return ret;24312431+}24322432+EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range);2412243324132434static int _regulator_do_set_voltage(struct regulator_dev *rdev,24142435 int min_uV, int max_uV)
···4040};41414242/**4343+ * Specify a range of voltages for regulator_map_linar_range() and4444+ * regulator_list_linear_range().4545+ *4646+ * @min_uV: Lowest voltage in range4747+ * @max_uV: Highest voltage in range4848+ * @min_sel: Lowest selector for range4949+ * @max_sel: Highest selector for range5050+ * @uV_step: Step size5151+ */5252+struct regulator_linear_range {5353+ unsigned int min_uV;5454+ unsigned int max_uV;5555+ unsigned int min_sel;5656+ unsigned int max_sel;5757+ unsigned int uV_step;5858+};5959+6060+/**4361 * struct regulator_ops - regulator operations.4462 *4563 * @enable: Configure the regulator as enabled.···241223 unsigned int linear_min_sel;242224 unsigned int ramp_delay;243225226226+ const struct regulator_linear_range *linear_ranges;227227+ int n_linear_ranges;228228+244229 const unsigned int *volt_table;245230246231 unsigned int vsel_reg;···347326348327int regulator_list_voltage_linear(struct regulator_dev *rdev,349328 unsigned int selector);329329+int regulator_list_voltage_linear_range(struct regulator_dev *rdev,330330+ unsigned int selector);350331int regulator_list_voltage_table(struct regulator_dev *rdev,351332 unsigned int selector);352333int regulator_map_voltage_linear(struct regulator_dev *rdev,353334 int min_uV, int max_uV);335335+int regulator_map_voltage_linear_range(struct regulator_dev *rdev,336336+ int min_uV, int max_uV);354337int regulator_map_voltage_iterate(struct regulator_dev *rdev,355338 int min_uV, int max_uV);356339int regulator_map_voltage_ascend(struct regulator_dev *rdev,