Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 //
0003 // pv88080-regulator.c - Regulator device driver for PV88080
0004 // Copyright (C) 2016  Powerventure Semiconductor Ltd.
0005 
0006 #include <linux/err.h>
0007 #include <linux/i2c.h>
0008 #include <linux/module.h>
0009 #include <linux/of.h>
0010 #include <linux/init.h>
0011 #include <linux/slab.h>
0012 #include <linux/regulator/driver.h>
0013 #include <linux/regulator/machine.h>
0014 #include <linux/regmap.h>
0015 #include <linux/irq.h>
0016 #include <linux/interrupt.h>
0017 #include <linux/regulator/of_regulator.h>
0018 #include "pv88080-regulator.h"
0019 
0020 #define PV88080_MAX_REGULATORS  4
0021 
0022 /* PV88080 REGULATOR IDs */
0023 enum {
0024     /* BUCKs */
0025     PV88080_ID_BUCK1,
0026     PV88080_ID_BUCK2,
0027     PV88080_ID_BUCK3,
0028     PV88080_ID_HVBUCK,
0029 };
0030 
0031 enum pv88080_types {
0032     TYPE_PV88080_AA,
0033     TYPE_PV88080_BA,
0034 };
0035 
0036 struct pv88080_regulator {
0037     struct regulator_desc desc;
0038     unsigned int mode_reg;
0039     unsigned int conf2;
0040     unsigned int conf5;
0041 };
0042 
0043 struct pv88080 {
0044     struct device *dev;
0045     struct regmap *regmap;
0046     struct regulator_dev *rdev[PV88080_MAX_REGULATORS];
0047     unsigned long type;
0048     const struct pv88080_compatible_regmap *regmap_config;
0049 };
0050 
0051 struct pv88080_buck_voltage {
0052     int min_uV;
0053     int max_uV;
0054     int uV_step;
0055 };
0056 
0057 struct pv88080_buck_regmap {
0058     /* REGS */
0059     int buck_enable_reg;
0060     int buck_vsel_reg;
0061     int buck_mode_reg;
0062     int buck_limit_reg;
0063     int buck_vdac_range_reg;
0064     int buck_vrange_gain_reg;
0065     /* MASKS */
0066     int buck_enable_mask;
0067     int buck_vsel_mask;
0068     int buck_limit_mask;
0069 };
0070 
0071 struct pv88080_compatible_regmap {
0072     /* BUCK1, 2, 3 */
0073     struct pv88080_buck_regmap buck_regmap[PV88080_MAX_REGULATORS-1];
0074     /* HVBUCK */
0075     int hvbuck_enable_reg;
0076     int hvbuck_vsel_reg;
0077     int hvbuck_enable_mask;
0078     int hvbuck_vsel_mask;
0079 };
0080 
0081 static const struct regmap_config pv88080_regmap_config = {
0082     .reg_bits = 8,
0083     .val_bits = 8,
0084 };
0085 
0086 /* Current limits array (in uA) for BUCK1, BUCK2, BUCK3.
0087  * Entry indexes corresponds to register values.
0088  */
0089 
0090 static const unsigned int pv88080_buck1_limits[] = {
0091     3230000, 5130000, 6960000, 8790000
0092 };
0093 
0094 static const unsigned int pv88080_buck23_limits[] = {
0095     1496000, 2393000, 3291000, 4189000
0096 };
0097 
0098 static const struct pv88080_buck_voltage pv88080_buck_vol[2] = {
0099     {
0100         .min_uV = 600000,
0101         .max_uV = 1393750,
0102         .uV_step = 6250,
0103     },
0104     {
0105         .min_uV = 1400000,
0106         .max_uV = 2193750,
0107         .uV_step = 6250,
0108     },
0109 };
0110 
0111 static const struct pv88080_compatible_regmap pv88080_aa_regs = {
0112     /* BUCK1 */
0113     .buck_regmap[0] = {
0114         .buck_enable_reg      = PV88080AA_REG_BUCK1_CONF0,
0115         .buck_vsel_reg        = PV88080AA_REG_BUCK1_CONF0,
0116         .buck_mode_reg        = PV88080AA_REG_BUCK1_CONF1,
0117         .buck_limit_reg       = PV88080AA_REG_BUCK1_CONF1,
0118         .buck_vdac_range_reg  = PV88080AA_REG_BUCK1_CONF2,
0119         .buck_vrange_gain_reg = PV88080AA_REG_BUCK1_CONF5,
0120         .buck_enable_mask     = PV88080_BUCK1_EN,
0121         .buck_vsel_mask       = PV88080_VBUCK1_MASK,
0122         .buck_limit_mask      = PV88080_BUCK1_ILIM_MASK,
0123     },
0124     /* BUCK2 */
0125     .buck_regmap[1] = {
0126         .buck_enable_reg      = PV88080AA_REG_BUCK2_CONF0,
0127         .buck_vsel_reg        = PV88080AA_REG_BUCK2_CONF0,
0128         .buck_mode_reg        = PV88080AA_REG_BUCK2_CONF1,
0129         .buck_limit_reg       = PV88080AA_REG_BUCK2_CONF1,
0130         .buck_vdac_range_reg  = PV88080AA_REG_BUCK2_CONF2,
0131         .buck_vrange_gain_reg = PV88080AA_REG_BUCK2_CONF5,
0132         .buck_enable_mask     = PV88080_BUCK2_EN,
0133         .buck_vsel_mask       = PV88080_VBUCK2_MASK,
0134         .buck_limit_mask      = PV88080_BUCK2_ILIM_MASK,
0135     },
0136     /* BUCK3 */
0137     .buck_regmap[2] = {
0138         .buck_enable_reg      = PV88080AA_REG_BUCK3_CONF0,
0139         .buck_vsel_reg        = PV88080AA_REG_BUCK3_CONF0,
0140         .buck_mode_reg        = PV88080AA_REG_BUCK3_CONF1,
0141         .buck_limit_reg       = PV88080AA_REG_BUCK3_CONF1,
0142         .buck_vdac_range_reg  = PV88080AA_REG_BUCK3_CONF2,
0143         .buck_vrange_gain_reg = PV88080AA_REG_BUCK3_CONF5,
0144         .buck_enable_mask     = PV88080_BUCK3_EN,
0145         .buck_vsel_mask       = PV88080_VBUCK3_MASK,
0146         .buck_limit_mask      = PV88080_BUCK3_ILIM_MASK,
0147     },
0148     /* HVBUCK */
0149     .hvbuck_enable_reg        = PV88080AA_REG_HVBUCK_CONF2,
0150     .hvbuck_vsel_reg          = PV88080AA_REG_HVBUCK_CONF1,
0151     .hvbuck_enable_mask       = PV88080_HVBUCK_EN,
0152     .hvbuck_vsel_mask         = PV88080_VHVBUCK_MASK,
0153 };
0154 
0155 static const struct pv88080_compatible_regmap pv88080_ba_regs = {
0156     /* BUCK1 */
0157     .buck_regmap[0] = {
0158         .buck_enable_reg      = PV88080BA_REG_BUCK1_CONF0,
0159         .buck_vsel_reg        = PV88080BA_REG_BUCK1_CONF0,
0160         .buck_mode_reg        = PV88080BA_REG_BUCK1_CONF1,
0161         .buck_limit_reg       = PV88080BA_REG_BUCK1_CONF1,
0162         .buck_vdac_range_reg  = PV88080BA_REG_BUCK1_CONF2,
0163         .buck_vrange_gain_reg = PV88080BA_REG_BUCK1_CONF5,
0164         .buck_enable_mask     = PV88080_BUCK1_EN,
0165         .buck_vsel_mask       = PV88080_VBUCK1_MASK,
0166         .buck_limit_mask      = PV88080_BUCK1_ILIM_MASK,
0167     },
0168     /* BUCK2 */
0169     .buck_regmap[1] = {
0170         .buck_enable_reg      = PV88080BA_REG_BUCK2_CONF0,
0171         .buck_vsel_reg        = PV88080BA_REG_BUCK2_CONF0,
0172         .buck_mode_reg        = PV88080BA_REG_BUCK2_CONF1,
0173         .buck_limit_reg       = PV88080BA_REG_BUCK2_CONF1,
0174         .buck_vdac_range_reg  = PV88080BA_REG_BUCK2_CONF2,
0175         .buck_vrange_gain_reg = PV88080BA_REG_BUCK2_CONF5,
0176         .buck_enable_mask     = PV88080_BUCK2_EN,
0177         .buck_vsel_mask       = PV88080_VBUCK2_MASK,
0178         .buck_limit_mask      = PV88080_BUCK2_ILIM_MASK,
0179     },
0180     /* BUCK3 */
0181     .buck_regmap[2] = {
0182         .buck_enable_reg      = PV88080BA_REG_BUCK3_CONF0,
0183         .buck_vsel_reg        = PV88080BA_REG_BUCK3_CONF0,
0184         .buck_mode_reg        = PV88080BA_REG_BUCK3_CONF1,
0185         .buck_limit_reg       = PV88080BA_REG_BUCK3_CONF1,
0186         .buck_vdac_range_reg  = PV88080BA_REG_BUCK3_CONF2,
0187         .buck_vrange_gain_reg = PV88080BA_REG_BUCK3_CONF5,
0188         .buck_enable_mask     = PV88080_BUCK3_EN,
0189         .buck_vsel_mask       = PV88080_VBUCK3_MASK,
0190         .buck_limit_mask      = PV88080_BUCK3_ILIM_MASK,
0191     },
0192     /* HVBUCK */
0193     .hvbuck_enable_reg        = PV88080BA_REG_HVBUCK_CONF2,
0194     .hvbuck_vsel_reg          = PV88080BA_REG_HVBUCK_CONF1,
0195     .hvbuck_enable_mask       = PV88080_HVBUCK_EN,
0196     .hvbuck_vsel_mask         = PV88080_VHVBUCK_MASK,
0197 };
0198 
0199 #ifdef CONFIG_OF
0200 static const struct of_device_id pv88080_dt_ids[] = {
0201     { .compatible = "pvs,pv88080",    .data = (void *)TYPE_PV88080_AA },
0202     { .compatible = "pvs,pv88080-aa", .data = (void *)TYPE_PV88080_AA },
0203     { .compatible = "pvs,pv88080-ba", .data = (void *)TYPE_PV88080_BA },
0204     {},
0205 };
0206 MODULE_DEVICE_TABLE(of, pv88080_dt_ids);
0207 #endif
0208 
0209 static unsigned int pv88080_buck_get_mode(struct regulator_dev *rdev)
0210 {
0211     struct pv88080_regulator *info = rdev_get_drvdata(rdev);
0212     unsigned int data;
0213     int ret, mode = 0;
0214 
0215     ret = regmap_read(rdev->regmap, info->mode_reg, &data);
0216     if (ret < 0)
0217         return ret;
0218 
0219     switch (data & PV88080_BUCK1_MODE_MASK) {
0220     case PV88080_BUCK_MODE_SYNC:
0221         mode = REGULATOR_MODE_FAST;
0222         break;
0223     case PV88080_BUCK_MODE_AUTO:
0224         mode = REGULATOR_MODE_NORMAL;
0225         break;
0226     case PV88080_BUCK_MODE_SLEEP:
0227         mode = REGULATOR_MODE_STANDBY;
0228         break;
0229     default:
0230         return -EINVAL;
0231     }
0232 
0233     return mode;
0234 }
0235 
0236 static int pv88080_buck_set_mode(struct regulator_dev *rdev,
0237                     unsigned int mode)
0238 {
0239     struct pv88080_regulator *info = rdev_get_drvdata(rdev);
0240     int val = 0;
0241 
0242     switch (mode) {
0243     case REGULATOR_MODE_FAST:
0244         val = PV88080_BUCK_MODE_SYNC;
0245         break;
0246     case REGULATOR_MODE_NORMAL:
0247         val = PV88080_BUCK_MODE_AUTO;
0248         break;
0249     case REGULATOR_MODE_STANDBY:
0250         val = PV88080_BUCK_MODE_SLEEP;
0251         break;
0252     default:
0253         return -EINVAL;
0254     }
0255 
0256     return regmap_update_bits(rdev->regmap, info->mode_reg,
0257                     PV88080_BUCK1_MODE_MASK, val);
0258 }
0259 
0260 static const struct regulator_ops pv88080_buck_ops = {
0261     .get_mode = pv88080_buck_get_mode,
0262     .set_mode = pv88080_buck_set_mode,
0263     .enable = regulator_enable_regmap,
0264     .disable = regulator_disable_regmap,
0265     .is_enabled = regulator_is_enabled_regmap,
0266     .set_voltage_sel = regulator_set_voltage_sel_regmap,
0267     .get_voltage_sel = regulator_get_voltage_sel_regmap,
0268     .list_voltage = regulator_list_voltage_linear,
0269     .set_current_limit = regulator_set_current_limit_regmap,
0270     .get_current_limit = regulator_get_current_limit_regmap,
0271 };
0272 
0273 static const struct regulator_ops pv88080_hvbuck_ops = {
0274     .enable = regulator_enable_regmap,
0275     .disable = regulator_disable_regmap,
0276     .is_enabled = regulator_is_enabled_regmap,
0277     .set_voltage_sel = regulator_set_voltage_sel_regmap,
0278     .get_voltage_sel = regulator_get_voltage_sel_regmap,
0279     .list_voltage = regulator_list_voltage_linear,
0280 };
0281 
0282 #define PV88080_BUCK(chip, regl_name, min, step, max, limits_array) \
0283 {\
0284     .desc   =   {\
0285         .id = chip##_ID_##regl_name,\
0286         .name = __stringify(chip##_##regl_name),\
0287         .of_match = of_match_ptr(#regl_name),\
0288         .regulators_node = of_match_ptr("regulators"),\
0289         .type = REGULATOR_VOLTAGE,\
0290         .owner = THIS_MODULE,\
0291         .ops = &pv88080_buck_ops,\
0292         .min_uV = min, \
0293         .uV_step = step, \
0294         .n_voltages = ((max) - (min))/(step) + 1, \
0295         .curr_table = limits_array, \
0296         .n_current_limits = ARRAY_SIZE(limits_array), \
0297     },\
0298 }
0299 
0300 #define PV88080_HVBUCK(chip, regl_name, min, step, max) \
0301 {\
0302     .desc   =   {\
0303         .id = chip##_ID_##regl_name,\
0304         .name = __stringify(chip##_##regl_name),\
0305         .of_match = of_match_ptr(#regl_name),\
0306         .regulators_node = of_match_ptr("regulators"),\
0307         .type = REGULATOR_VOLTAGE,\
0308         .owner = THIS_MODULE,\
0309         .ops = &pv88080_hvbuck_ops,\
0310         .min_uV = min, \
0311         .uV_step = step, \
0312         .n_voltages = ((max) - (min))/(step) + 1, \
0313     },\
0314 }
0315 
0316 static struct pv88080_regulator pv88080_regulator_info[] = {
0317     PV88080_BUCK(PV88080, BUCK1, 600000, 6250, 1393750,
0318         pv88080_buck1_limits),
0319     PV88080_BUCK(PV88080, BUCK2, 600000, 6250, 1393750,
0320         pv88080_buck23_limits),
0321     PV88080_BUCK(PV88080, BUCK3, 600000, 6250, 1393750,
0322         pv88080_buck23_limits),
0323     PV88080_HVBUCK(PV88080, HVBUCK, 0, 5000, 1275000),
0324 };
0325 
0326 static irqreturn_t pv88080_irq_handler(int irq, void *data)
0327 {
0328     struct pv88080 *chip = data;
0329     int i, reg_val, err, ret = IRQ_NONE;
0330 
0331     err = regmap_read(chip->regmap, PV88080_REG_EVENT_A, &reg_val);
0332     if (err < 0)
0333         goto error_i2c;
0334 
0335     if (reg_val & PV88080_E_VDD_FLT) {
0336         for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
0337             if (chip->rdev[i] != NULL)
0338                 regulator_notifier_call_chain(chip->rdev[i],
0339                     REGULATOR_EVENT_UNDER_VOLTAGE,
0340                     NULL);
0341         }
0342 
0343         err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
0344             PV88080_E_VDD_FLT);
0345         if (err < 0)
0346             goto error_i2c;
0347 
0348         ret = IRQ_HANDLED;
0349     }
0350 
0351     if (reg_val & PV88080_E_OVER_TEMP) {
0352         for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
0353             if (chip->rdev[i] != NULL)
0354                 regulator_notifier_call_chain(chip->rdev[i],
0355                     REGULATOR_EVENT_OVER_TEMP,
0356                     NULL);
0357         }
0358 
0359         err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
0360             PV88080_E_OVER_TEMP);
0361         if (err < 0)
0362             goto error_i2c;
0363 
0364         ret = IRQ_HANDLED;
0365     }
0366 
0367     return ret;
0368 
0369 error_i2c:
0370     dev_err(chip->dev, "I2C error : %d\n", err);
0371     return IRQ_NONE;
0372 }
0373 
0374 /*
0375  * I2C driver interface functions
0376  */
0377 static int pv88080_i2c_probe(struct i2c_client *i2c,
0378         const struct i2c_device_id *id)
0379 {
0380     struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev);
0381     struct pv88080 *chip;
0382     const struct pv88080_compatible_regmap *regmap_config;
0383     const struct of_device_id *match;
0384     struct regulator_config config = { };
0385     int i, error, ret;
0386     unsigned int conf2, conf5;
0387 
0388     chip = devm_kzalloc(&i2c->dev, sizeof(struct pv88080), GFP_KERNEL);
0389     if (!chip)
0390         return -ENOMEM;
0391 
0392     chip->dev = &i2c->dev;
0393     chip->regmap = devm_regmap_init_i2c(i2c, &pv88080_regmap_config);
0394     if (IS_ERR(chip->regmap)) {
0395         error = PTR_ERR(chip->regmap);
0396         dev_err(chip->dev, "Failed to allocate register map: %d\n",
0397             error);
0398         return error;
0399     }
0400 
0401     if (i2c->dev.of_node) {
0402         match = of_match_node(pv88080_dt_ids, i2c->dev.of_node);
0403         if (!match) {
0404             dev_err(chip->dev, "Failed to get of_match_node\n");
0405             return -EINVAL;
0406         }
0407         chip->type = (unsigned long)match->data;
0408     } else {
0409         chip->type = id->driver_data;
0410     }
0411 
0412     i2c_set_clientdata(i2c, chip);
0413 
0414     if (i2c->irq != 0) {
0415         ret = regmap_write(chip->regmap, PV88080_REG_MASK_A, 0xFF);
0416         if (ret < 0) {
0417             dev_err(chip->dev,
0418                 "Failed to mask A reg: %d\n", ret);
0419             return ret;
0420         }
0421         ret = regmap_write(chip->regmap, PV88080_REG_MASK_B, 0xFF);
0422         if (ret < 0) {
0423             dev_err(chip->dev,
0424                 "Failed to mask B reg: %d\n", ret);
0425             return ret;
0426         }
0427         ret = regmap_write(chip->regmap, PV88080_REG_MASK_C, 0xFF);
0428         if (ret < 0) {
0429             dev_err(chip->dev,
0430                 "Failed to mask C reg: %d\n", ret);
0431             return ret;
0432         }
0433 
0434         ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
0435                     pv88080_irq_handler,
0436                     IRQF_TRIGGER_LOW|IRQF_ONESHOT,
0437                     "pv88080", chip);
0438         if (ret != 0) {
0439             dev_err(chip->dev, "Failed to request IRQ: %d\n",
0440                 i2c->irq);
0441             return ret;
0442         }
0443 
0444         ret = regmap_update_bits(chip->regmap, PV88080_REG_MASK_A,
0445             PV88080_M_VDD_FLT | PV88080_M_OVER_TEMP, 0);
0446         if (ret < 0) {
0447             dev_err(chip->dev,
0448                 "Failed to update mask reg: %d\n", ret);
0449             return ret;
0450         }
0451     } else {
0452         dev_warn(chip->dev, "No IRQ configured\n");
0453     }
0454 
0455     switch (chip->type) {
0456     case TYPE_PV88080_AA:
0457         chip->regmap_config = &pv88080_aa_regs;
0458         break;
0459     case TYPE_PV88080_BA:
0460         chip->regmap_config = &pv88080_ba_regs;
0461         break;
0462     }
0463 
0464     regmap_config = chip->regmap_config;
0465     config.dev = chip->dev;
0466     config.regmap = chip->regmap;
0467 
0468     /* Registeration for BUCK1, 2, 3 */
0469     for (i = 0; i < PV88080_MAX_REGULATORS-1; i++) {
0470         if (init_data)
0471             config.init_data = &init_data[i];
0472 
0473         pv88080_regulator_info[i].desc.csel_reg
0474             = regmap_config->buck_regmap[i].buck_limit_reg;
0475         pv88080_regulator_info[i].desc.csel_mask
0476             = regmap_config->buck_regmap[i].buck_limit_mask;
0477         pv88080_regulator_info[i].mode_reg
0478             = regmap_config->buck_regmap[i].buck_mode_reg;
0479         pv88080_regulator_info[i].conf2
0480             = regmap_config->buck_regmap[i].buck_vdac_range_reg;
0481         pv88080_regulator_info[i].conf5
0482             = regmap_config->buck_regmap[i].buck_vrange_gain_reg;
0483         pv88080_regulator_info[i].desc.enable_reg
0484             = regmap_config->buck_regmap[i].buck_enable_reg;
0485         pv88080_regulator_info[i].desc.enable_mask
0486             = regmap_config->buck_regmap[i].buck_enable_mask;
0487         pv88080_regulator_info[i].desc.vsel_reg
0488             = regmap_config->buck_regmap[i].buck_vsel_reg;
0489         pv88080_regulator_info[i].desc.vsel_mask
0490             = regmap_config->buck_regmap[i].buck_vsel_mask;
0491 
0492         ret = regmap_read(chip->regmap,
0493                 pv88080_regulator_info[i].conf2, &conf2);
0494         if (ret < 0)
0495             return ret;
0496         conf2 = ((conf2 >> PV88080_BUCK_VDAC_RANGE_SHIFT) &
0497             PV88080_BUCK_VDAC_RANGE_MASK);
0498 
0499         ret = regmap_read(chip->regmap,
0500                 pv88080_regulator_info[i].conf5, &conf5);
0501         if (ret < 0)
0502             return ret;
0503         conf5 = ((conf5 >> PV88080_BUCK_VRANGE_GAIN_SHIFT) &
0504             PV88080_BUCK_VRANGE_GAIN_MASK);
0505 
0506         pv88080_regulator_info[i].desc.min_uV =
0507             pv88080_buck_vol[conf2].min_uV * (conf5+1);
0508         pv88080_regulator_info[i].desc.uV_step =
0509             pv88080_buck_vol[conf2].uV_step * (conf5+1);
0510         pv88080_regulator_info[i].desc.n_voltages =
0511             ((pv88080_buck_vol[conf2].max_uV * (conf5+1))
0512             - (pv88080_regulator_info[i].desc.min_uV))
0513             /(pv88080_regulator_info[i].desc.uV_step) + 1;
0514 
0515         config.driver_data = (void *)&pv88080_regulator_info[i];
0516         chip->rdev[i] = devm_regulator_register(chip->dev,
0517             &pv88080_regulator_info[i].desc, &config);
0518         if (IS_ERR(chip->rdev[i])) {
0519             dev_err(chip->dev,
0520                 "Failed to register PV88080 regulator\n");
0521             return PTR_ERR(chip->rdev[i]);
0522         }
0523     }
0524 
0525     pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_reg
0526         = regmap_config->hvbuck_enable_reg;
0527     pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_mask
0528         = regmap_config->hvbuck_enable_mask;
0529     pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_reg
0530         = regmap_config->hvbuck_vsel_reg;
0531     pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_mask
0532         = regmap_config->hvbuck_vsel_mask;
0533 
0534     /* Registeration for HVBUCK */
0535     if (init_data)
0536         config.init_data = &init_data[PV88080_ID_HVBUCK];
0537 
0538     config.driver_data = (void *)&pv88080_regulator_info[PV88080_ID_HVBUCK];
0539     chip->rdev[PV88080_ID_HVBUCK] = devm_regulator_register(chip->dev,
0540         &pv88080_regulator_info[PV88080_ID_HVBUCK].desc, &config);
0541     if (IS_ERR(chip->rdev[PV88080_ID_HVBUCK])) {
0542         dev_err(chip->dev, "Failed to register PV88080 regulator\n");
0543         return PTR_ERR(chip->rdev[PV88080_ID_HVBUCK]);
0544     }
0545 
0546     return 0;
0547 }
0548 
0549 static const struct i2c_device_id pv88080_i2c_id[] = {
0550     { "pv88080",    TYPE_PV88080_AA },
0551     { "pv88080-aa", TYPE_PV88080_AA },
0552     { "pv88080-ba", TYPE_PV88080_BA },
0553     {},
0554 };
0555 MODULE_DEVICE_TABLE(i2c, pv88080_i2c_id);
0556 
0557 static struct i2c_driver pv88080_regulator_driver = {
0558     .driver = {
0559         .name = "pv88080",
0560         .of_match_table = of_match_ptr(pv88080_dt_ids),
0561     },
0562     .probe = pv88080_i2c_probe,
0563     .id_table = pv88080_i2c_id,
0564 };
0565 
0566 module_i2c_driver(pv88080_regulator_driver);
0567 
0568 MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>");
0569 MODULE_DESCRIPTION("Regulator device driver for Powerventure PV88080");
0570 MODULE_LICENSE("GPL");