Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Regulator driver for TI TPS6586x
0004  *
0005  * Copyright (C) 2010 Compulab Ltd.
0006  * Author: Mike Rapoport <mike@compulab.co.il>
0007  *
0008  * Based on da903x
0009  * Copyright (C) 2006-2008 Marvell International Ltd.
0010  * Copyright (C) 2008 Compulab Ltd.
0011  */
0012 
0013 #include <linux/kernel.h>
0014 #include <linux/module.h>
0015 #include <linux/init.h>
0016 #include <linux/err.h>
0017 #include <linux/of.h>
0018 #include <linux/slab.h>
0019 #include <linux/platform_device.h>
0020 #include <linux/regulator/driver.h>
0021 #include <linux/regulator/machine.h>
0022 #include <linux/regulator/of_regulator.h>
0023 #include <linux/mfd/tps6586x.h>
0024 
0025 /* supply control and voltage setting  */
0026 #define TPS6586X_SUPPLYENA  0x10
0027 #define TPS6586X_SUPPLYENB  0x11
0028 #define TPS6586X_SUPPLYENC  0x12
0029 #define TPS6586X_SUPPLYEND  0x13
0030 #define TPS6586X_SUPPLYENE  0x14
0031 #define TPS6586X_VCC1       0x20
0032 #define TPS6586X_VCC2       0x21
0033 #define TPS6586X_SM1V1      0x23
0034 #define TPS6586X_SM1V2      0x24
0035 #define TPS6586X_SM1SL      0x25
0036 #define TPS6586X_SM0V1      0x26
0037 #define TPS6586X_SM0V2      0x27
0038 #define TPS6586X_SM0SL      0x28
0039 #define TPS6586X_LDO2AV1    0x29
0040 #define TPS6586X_LDO2AV2    0x2A
0041 #define TPS6586X_LDO2BV1    0x2F
0042 #define TPS6586X_LDO2BV2    0x30
0043 #define TPS6586X_LDO4V1     0x32
0044 #define TPS6586X_LDO4V2     0x33
0045 
0046 /* converter settings  */
0047 #define TPS6586X_SUPPLYV1   0x41
0048 #define TPS6586X_SUPPLYV2   0x42
0049 #define TPS6586X_SUPPLYV3   0x43
0050 #define TPS6586X_SUPPLYV4   0x44
0051 #define TPS6586X_SUPPLYV5   0x45
0052 #define TPS6586X_SUPPLYV6   0x46
0053 #define TPS6586X_SMODE1     0x47
0054 #define TPS6586X_SMODE2     0x48
0055 
0056 struct tps6586x_regulator {
0057     struct regulator_desc desc;
0058 
0059     int enable_bit[2];
0060     int enable_reg[2];
0061 };
0062 
0063 static const struct regulator_ops tps6586x_rw_regulator_ops = {
0064     .list_voltage = regulator_list_voltage_table,
0065     .map_voltage = regulator_map_voltage_ascend,
0066     .get_voltage_sel = regulator_get_voltage_sel_regmap,
0067     .set_voltage_sel = regulator_set_voltage_sel_regmap,
0068 
0069     .is_enabled = regulator_is_enabled_regmap,
0070     .enable = regulator_enable_regmap,
0071     .disable = regulator_disable_regmap,
0072 };
0073 
0074 static const struct regulator_ops tps6586x_rw_linear_regulator_ops = {
0075     .list_voltage = regulator_list_voltage_linear,
0076     .get_voltage_sel = regulator_get_voltage_sel_regmap,
0077     .set_voltage_sel = regulator_set_voltage_sel_regmap,
0078 
0079     .is_enabled = regulator_is_enabled_regmap,
0080     .enable = regulator_enable_regmap,
0081     .disable = regulator_disable_regmap,
0082 };
0083 
0084 static const struct regulator_ops tps6586x_ro_regulator_ops = {
0085     .list_voltage = regulator_list_voltage_table,
0086     .map_voltage = regulator_map_voltage_ascend,
0087     .get_voltage_sel = regulator_get_voltage_sel_regmap,
0088 
0089     .is_enabled = regulator_is_enabled_regmap,
0090     .enable = regulator_enable_regmap,
0091     .disable = regulator_disable_regmap,
0092 };
0093 
0094 static const struct regulator_ops tps6586x_sys_regulator_ops = {
0095 };
0096 
0097 static const unsigned int tps6586x_ldo0_voltages[] = {
0098     1200000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000,
0099 };
0100 
0101 static const unsigned int tps6586x_ldo_voltages[] = {
0102     1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000,
0103 };
0104 
0105 static const unsigned int tps658640_rtc_voltages[] = {
0106     2500000, 2850000, 3100000, 3300000,
0107 };
0108 
0109 #define TPS6586X_REGULATOR(_id, _ops, _pin_name, vdata, vreg, shift, nbits, \
0110                ereg0, ebit0, ereg1, ebit1, goreg, gobit)    \
0111     .desc   = {                         \
0112         .supply_name = _pin_name,               \
0113         .name   = "REG-" #_id,                  \
0114         .ops    = &tps6586x_## _ops ## _regulator_ops,      \
0115         .type   = REGULATOR_VOLTAGE,                \
0116         .id = TPS6586X_ID_##_id,                \
0117         .n_voltages = ARRAY_SIZE(vdata##_voltages),     \
0118         .volt_table = vdata##_voltages,             \
0119         .owner  = THIS_MODULE,                  \
0120         .enable_reg = TPS6586X_SUPPLY##ereg0,           \
0121         .enable_mask = 1 << (ebit0),                \
0122         .vsel_reg = TPS6586X_##vreg,                \
0123         .vsel_mask = ((1 << (nbits)) - 1) << (shift),       \
0124         .apply_reg = (goreg),               \
0125         .apply_bit = (gobit),               \
0126     },                              \
0127     .enable_reg[0]  = TPS6586X_SUPPLY##ereg0,           \
0128     .enable_bit[0]  = (ebit0),                  \
0129     .enable_reg[1]  = TPS6586X_SUPPLY##ereg1,           \
0130     .enable_bit[1]  = (ebit1),
0131 
0132 #define TPS6586X_REGULATOR_LINEAR(_id, _ops, _pin_name, n_volt, min_uv, \
0133                   uv_step, vreg, shift, nbits, ereg0,   \
0134                   ebit0, ereg1, ebit1, goreg, gobit)    \
0135     .desc   = {                         \
0136         .supply_name = _pin_name,               \
0137         .name   = "REG-" #_id,                  \
0138         .ops    = &tps6586x_## _ops ## _regulator_ops,      \
0139         .type   = REGULATOR_VOLTAGE,                \
0140         .id = TPS6586X_ID_##_id,                \
0141         .n_voltages = n_volt,                   \
0142         .min_uV = min_uv,                   \
0143         .uV_step = uv_step,                 \
0144         .owner  = THIS_MODULE,                  \
0145         .enable_reg = TPS6586X_SUPPLY##ereg0,           \
0146         .enable_mask = 1 << (ebit0),                \
0147         .vsel_reg = TPS6586X_##vreg,                \
0148         .vsel_mask = ((1 << (nbits)) - 1) << (shift),       \
0149         .apply_reg = (goreg),               \
0150         .apply_bit = (gobit),               \
0151     },                              \
0152     .enable_reg[0]  = TPS6586X_SUPPLY##ereg0,           \
0153     .enable_bit[0]  = (ebit0),                  \
0154     .enable_reg[1]  = TPS6586X_SUPPLY##ereg1,           \
0155     .enable_bit[1]  = (ebit1),
0156 
0157 #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits,        \
0158              ereg0, ebit0, ereg1, ebit1)            \
0159 {                                   \
0160     TPS6586X_REGULATOR(_id, rw, _pname, vdata, vreg, shift, nbits,  \
0161                ereg0, ebit0, ereg1, ebit1, 0, 0)        \
0162 }
0163 
0164 #define TPS6586X_LDO_LINEAR(_id, _pname, n_volt, min_uv, uv_step, vreg, \
0165                 shift, nbits, ereg0, ebit0, ereg1, ebit1)   \
0166 {                                   \
0167     TPS6586X_REGULATOR_LINEAR(_id, rw_linear, _pname, n_volt,   \
0168                   min_uv, uv_step, vreg, shift, nbits,  \
0169                   ereg0, ebit0, ereg1, ebit1, 0, 0) \
0170 }
0171 
0172 #define TPS6586X_FIXED_LDO(_id, _pname, vdata, vreg, shift, nbits,  \
0173               ereg0, ebit0, ereg1, ebit1)           \
0174 {                                   \
0175     TPS6586X_REGULATOR(_id, ro, _pname, vdata, vreg, shift, nbits,  \
0176                ereg0, ebit0, ereg1, ebit1, 0, 0)        \
0177 }
0178 
0179 #define TPS6586X_DVM(_id, _pname, n_volt, min_uv, uv_step, vreg, shift, \
0180              nbits, ereg0, ebit0, ereg1, ebit1, goreg, gobit)   \
0181 {                                   \
0182     TPS6586X_REGULATOR_LINEAR(_id, rw_linear, _pname, n_volt,   \
0183                   min_uv, uv_step, vreg, shift, nbits,  \
0184                   ereg0, ebit0, ereg1, ebit1, goreg,    \
0185                   gobit)                \
0186 }
0187 
0188 #define TPS6586X_SYS_REGULATOR()                    \
0189 {                                   \
0190     .desc   = {                         \
0191         .supply_name = "sys",                   \
0192         .name   = "REG-SYS",                    \
0193         .ops    = &tps6586x_sys_regulator_ops,          \
0194         .type   = REGULATOR_VOLTAGE,                \
0195         .id = TPS6586X_ID_SYS,              \
0196         .owner  = THIS_MODULE,                  \
0197     },                              \
0198 }
0199 
0200 static struct tps6586x_regulator tps6586x_regulator[] = {
0201     TPS6586X_SYS_REGULATOR(),
0202     TPS6586X_LDO(LDO_0, "vinldo01", tps6586x_ldo0, SUPPLYV1, 5, 3, ENC, 0,
0203                     END, 0),
0204     TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo, SUPPLYV4, 0, 3, ENC, 2,
0205                     END, 2),
0206     TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo, SUPPLYV6, 0, 3, ENE, 6,
0207                     ENE, 6),
0208     TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo, SUPPLYV3, 0, 3, ENC, 4,
0209                     END, 4),
0210     TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo, SUPPLYV3, 3, 3, ENC, 5,
0211                     END, 5),
0212     TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo, SUPPLYV2, 5, 3, ENC, 6,
0213                     END, 6),
0214     TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo, SUPPLYV6, 3, 3, ENE, 7,
0215                     ENE, 7),
0216     TPS6586X_LDO(LDO_RTC, "REG-SYS", tps6586x_ldo, SUPPLYV4, 3, 3, V4, 7,
0217                     V4, 7),
0218     TPS6586X_LDO_LINEAR(LDO_1, "vinldo01", 32, 725000, 25000, SUPPLYV1,
0219                 0, 5, ENC, 1, END, 1),
0220     TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 3000000, 50000, SUPPLYV2,
0221                 0, 5, ENC, 7, END, 7),
0222     TPS6586X_DVM(LDO_2, "vinldo23", 32, 725000, 25000, LDO2BV1, 0, 5,
0223              ENA, 3, ENB, 3, TPS6586X_VCC2, BIT(6)),
0224     TPS6586X_DVM(LDO_4, "vinldo4", 32, 1700000, 25000, LDO4V1, 0, 5,
0225              ENC, 3, END, 3, TPS6586X_VCC1, BIT(6)),
0226     TPS6586X_DVM(SM_0, "vin-sm0", 32, 725000, 25000, SM0V1, 0, 5,
0227              ENA, 1, ENB, 1, TPS6586X_VCC1, BIT(2)),
0228     TPS6586X_DVM(SM_1, "vin-sm1", 32, 725000, 25000, SM1V1, 0, 5,
0229              ENA, 0, ENB, 0, TPS6586X_VCC1, BIT(0)),
0230 };
0231 
0232 static struct tps6586x_regulator tps658623_regulator[] = {
0233     TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 1700000, 25000, SUPPLYV2,
0234                 0, 5, ENC, 7, END, 7),
0235 };
0236 
0237 static struct tps6586x_regulator tps658640_regulator[] = {
0238     TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo0, SUPPLYV4, 0, 3,
0239                     ENC, 2, END, 2),
0240     TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo0, SUPPLYV6, 0, 3,
0241                     ENE, 6, ENE, 6),
0242     TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo0, SUPPLYV3, 0, 3,
0243                     ENC, 4, END, 4),
0244     TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo0, SUPPLYV3, 3, 3,
0245                     ENC, 5, END, 5),
0246     TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo0, SUPPLYV2, 5, 3,
0247                     ENC, 6, END, 6),
0248     TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo0, SUPPLYV6, 3, 3,
0249                     ENE, 7, ENE, 7),
0250     TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 2150000, 50000, SUPPLYV2,
0251                 0, 5, ENC, 7, END, 7),
0252 
0253     TPS6586X_FIXED_LDO(LDO_RTC, "REG-SYS", tps658640_rtc, SUPPLYV4, 3, 2,
0254                     V4, 7, V4, 7),
0255 };
0256 
0257 static struct tps6586x_regulator tps658643_regulator[] = {
0258     TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 1025000, 25000, SUPPLYV2,
0259                 0, 5, ENC, 7, END, 7),
0260 };
0261 
0262 /*
0263  * TPS6586X has 2 enable bits that are OR'ed to determine the actual
0264  * regulator state. Clearing one of this bits allows switching
0265  * regulator on and of with single register write.
0266  */
0267 static inline int tps6586x_regulator_preinit(struct device *parent,
0268                          struct tps6586x_regulator *ri)
0269 {
0270     uint8_t val1, val2;
0271     int ret;
0272 
0273     if (ri->enable_reg[0] == ri->enable_reg[1] &&
0274         ri->enable_bit[0] == ri->enable_bit[1])
0275             return 0;
0276 
0277     ret = tps6586x_read(parent, ri->enable_reg[0], &val1);
0278     if (ret)
0279         return ret;
0280 
0281     ret = tps6586x_read(parent, ri->enable_reg[1], &val2);
0282     if (ret)
0283         return ret;
0284 
0285     if (!(val2 & (1 << ri->enable_bit[1])))
0286         return 0;
0287 
0288     /*
0289      * The regulator is on, but it's enabled with the bit we don't
0290      * want to use, so we switch the enable bits
0291      */
0292     if (!(val1 & (1 << ri->enable_bit[0]))) {
0293         ret = tps6586x_set_bits(parent, ri->enable_reg[0],
0294                     1 << ri->enable_bit[0]);
0295         if (ret)
0296             return ret;
0297     }
0298 
0299     return tps6586x_clr_bits(parent, ri->enable_reg[1],
0300                  1 << ri->enable_bit[1]);
0301 }
0302 
0303 static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev,
0304             int id, struct regulator_init_data *p)
0305 {
0306     struct device *parent = pdev->dev.parent;
0307     struct tps6586x_settings *setting = p->driver_data;
0308     uint8_t reg;
0309 
0310     if (setting == NULL)
0311         return 0;
0312 
0313     if (!(setting->slew_rate & TPS6586X_SLEW_RATE_SET))
0314         return 0;
0315 
0316     /* only SM0 and SM1 can have the slew rate settings */
0317     switch (id) {
0318     case TPS6586X_ID_SM_0:
0319         reg = TPS6586X_SM0SL;
0320         break;
0321     case TPS6586X_ID_SM_1:
0322         reg = TPS6586X_SM1SL;
0323         break;
0324     default:
0325         dev_err(&pdev->dev, "Only SM0/SM1 can set slew rate\n");
0326         return -EINVAL;
0327     }
0328 
0329     return tps6586x_write(parent, reg,
0330             setting->slew_rate & TPS6586X_SLEW_RATE_MASK);
0331 }
0332 
0333 static struct tps6586x_regulator *find_regulator_info(int id, int version)
0334 {
0335     struct tps6586x_regulator *ri;
0336     struct tps6586x_regulator *table = NULL;
0337     int num;
0338     int i;
0339 
0340     switch (version) {
0341     case TPS658623:
0342     case TPS658624:
0343         table = tps658623_regulator;
0344         num = ARRAY_SIZE(tps658623_regulator);
0345         break;
0346     case TPS658640:
0347     case TPS658640v2:
0348         table = tps658640_regulator;
0349         num = ARRAY_SIZE(tps658640_regulator);
0350         break;
0351     case TPS658643:
0352         table = tps658643_regulator;
0353         num = ARRAY_SIZE(tps658643_regulator);
0354         break;
0355     }
0356 
0357     /* Search version specific table first */
0358     if (table) {
0359         for (i = 0; i < num; i++) {
0360             ri = &table[i];
0361             if (ri->desc.id == id)
0362                 return ri;
0363         }
0364     }
0365 
0366     for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) {
0367         ri = &tps6586x_regulator[i];
0368         if (ri->desc.id == id)
0369             return ri;
0370     }
0371     return NULL;
0372 }
0373 
0374 #ifdef CONFIG_OF
0375 static struct of_regulator_match tps6586x_matches[] = {
0376     { .name = "sys",     .driver_data = (void *)TPS6586X_ID_SYS     },
0377     { .name = "sm0",     .driver_data = (void *)TPS6586X_ID_SM_0    },
0378     { .name = "sm1",     .driver_data = (void *)TPS6586X_ID_SM_1    },
0379     { .name = "sm2",     .driver_data = (void *)TPS6586X_ID_SM_2    },
0380     { .name = "ldo0",    .driver_data = (void *)TPS6586X_ID_LDO_0   },
0381     { .name = "ldo1",    .driver_data = (void *)TPS6586X_ID_LDO_1   },
0382     { .name = "ldo2",    .driver_data = (void *)TPS6586X_ID_LDO_2   },
0383     { .name = "ldo3",    .driver_data = (void *)TPS6586X_ID_LDO_3   },
0384     { .name = "ldo4",    .driver_data = (void *)TPS6586X_ID_LDO_4   },
0385     { .name = "ldo5",    .driver_data = (void *)TPS6586X_ID_LDO_5   },
0386     { .name = "ldo6",    .driver_data = (void *)TPS6586X_ID_LDO_6   },
0387     { .name = "ldo7",    .driver_data = (void *)TPS6586X_ID_LDO_7   },
0388     { .name = "ldo8",    .driver_data = (void *)TPS6586X_ID_LDO_8   },
0389     { .name = "ldo9",    .driver_data = (void *)TPS6586X_ID_LDO_9   },
0390     { .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC },
0391 };
0392 
0393 static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
0394         struct platform_device *pdev,
0395         struct of_regulator_match **tps6586x_reg_matches)
0396 {
0397     const unsigned int num = ARRAY_SIZE(tps6586x_matches);
0398     struct device_node *np = pdev->dev.parent->of_node;
0399     struct device_node *regs;
0400     const char *sys_rail = NULL;
0401     unsigned int i;
0402     struct tps6586x_platform_data *pdata;
0403     int err;
0404 
0405     regs = of_get_child_by_name(np, "regulators");
0406     if (!regs) {
0407         dev_err(&pdev->dev, "regulator node not found\n");
0408         return NULL;
0409     }
0410 
0411     err = of_regulator_match(&pdev->dev, regs, tps6586x_matches, num);
0412     of_node_put(regs);
0413     if (err < 0) {
0414         dev_err(&pdev->dev, "Regulator match failed, e %d\n", err);
0415         return NULL;
0416     }
0417 
0418     pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
0419     if (!pdata)
0420         return NULL;
0421 
0422     for (i = 0; i < num; i++) {
0423         uintptr_t id;
0424         if (!tps6586x_matches[i].init_data)
0425             continue;
0426 
0427         pdata->reg_init_data[i] = tps6586x_matches[i].init_data;
0428         id = (uintptr_t)tps6586x_matches[i].driver_data;
0429         if (id == TPS6586X_ID_SYS)
0430             sys_rail = pdata->reg_init_data[i]->constraints.name;
0431 
0432         if ((id == TPS6586X_ID_LDO_5) || (id == TPS6586X_ID_LDO_RTC))
0433             pdata->reg_init_data[i]->supply_regulator = sys_rail;
0434     }
0435     *tps6586x_reg_matches = tps6586x_matches;
0436     return pdata;
0437 }
0438 #else
0439 static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
0440         struct platform_device *pdev,
0441         struct of_regulator_match **tps6586x_reg_matches)
0442 {
0443     *tps6586x_reg_matches = NULL;
0444     return NULL;
0445 }
0446 #endif
0447 
0448 static int tps6586x_regulator_probe(struct platform_device *pdev)
0449 {
0450     struct tps6586x_regulator *ri = NULL;
0451     struct regulator_config config = { };
0452     struct regulator_dev *rdev;
0453     struct regulator_init_data *reg_data;
0454     struct tps6586x_platform_data *pdata;
0455     struct of_regulator_match *tps6586x_reg_matches = NULL;
0456     int version;
0457     int id;
0458     int err;
0459 
0460     dev_dbg(&pdev->dev, "Probing regulator\n");
0461 
0462     pdata = dev_get_platdata(pdev->dev.parent);
0463     if ((!pdata) && (pdev->dev.parent->of_node))
0464         pdata = tps6586x_parse_regulator_dt(pdev,
0465                     &tps6586x_reg_matches);
0466 
0467     if (!pdata) {
0468         dev_err(&pdev->dev, "Platform data not available, exiting\n");
0469         return -ENODEV;
0470     }
0471 
0472     version = tps6586x_get_version(pdev->dev.parent);
0473 
0474     for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) {
0475         reg_data = pdata->reg_init_data[id];
0476 
0477         ri = find_regulator_info(id, version);
0478 
0479         if (!ri) {
0480             dev_err(&pdev->dev, "invalid regulator ID specified\n");
0481             return -EINVAL;
0482         }
0483 
0484         err = tps6586x_regulator_preinit(pdev->dev.parent, ri);
0485         if (err) {
0486             dev_err(&pdev->dev,
0487                 "regulator %d preinit failed, e %d\n", id, err);
0488             return err;
0489         }
0490 
0491         config.dev = pdev->dev.parent;
0492         config.init_data = reg_data;
0493         config.driver_data = ri;
0494 
0495         if (tps6586x_reg_matches)
0496             config.of_node = tps6586x_reg_matches[id].of_node;
0497 
0498         rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
0499         if (IS_ERR(rdev)) {
0500             dev_err(&pdev->dev, "failed to register regulator %s\n",
0501                     ri->desc.name);
0502             return PTR_ERR(rdev);
0503         }
0504 
0505         if (reg_data) {
0506             err = tps6586x_regulator_set_slew_rate(pdev, id,
0507                     reg_data);
0508             if (err < 0) {
0509                 dev_err(&pdev->dev,
0510                     "Slew rate config failed, e %d\n", err);
0511                 return err;
0512             }
0513         }
0514     }
0515 
0516     platform_set_drvdata(pdev, rdev);
0517     return 0;
0518 }
0519 
0520 static struct platform_driver tps6586x_regulator_driver = {
0521     .driver = {
0522         .name   = "tps6586x-regulator",
0523     },
0524     .probe      = tps6586x_regulator_probe,
0525 };
0526 
0527 static int __init tps6586x_regulator_init(void)
0528 {
0529     return platform_driver_register(&tps6586x_regulator_driver);
0530 }
0531 subsys_initcall(tps6586x_regulator_init);
0532 
0533 static void __exit tps6586x_regulator_exit(void)
0534 {
0535     platform_driver_unregister(&tps6586x_regulator_driver);
0536 }
0537 module_exit(tps6586x_regulator_exit);
0538 
0539 MODULE_LICENSE("GPL");
0540 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
0541 MODULE_DESCRIPTION("Regulator Driver for TI TPS6586X PMIC");
0542 MODULE_ALIAS("platform:tps6586x-regulator");