diff options
Diffstat (limited to 'drivers/regulator/pfuze100-regulator.c')
| -rw-r--r-- | drivers/regulator/pfuze100-regulator.c | 204 |
1 files changed, 148 insertions, 56 deletions
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index ab174f20ca11..67e678c4301c 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c | |||
| @@ -56,6 +56,8 @@ | |||
| 56 | #define PFUZE100_VGEN5VOL 0x70 | 56 | #define PFUZE100_VGEN5VOL 0x70 |
| 57 | #define PFUZE100_VGEN6VOL 0x71 | 57 | #define PFUZE100_VGEN6VOL 0x71 |
| 58 | 58 | ||
| 59 | enum chips { PFUZE100, PFUZE200 }; | ||
| 60 | |||
| 59 | struct pfuze_regulator { | 61 | struct pfuze_regulator { |
| 60 | struct regulator_desc desc; | 62 | struct regulator_desc desc; |
| 61 | unsigned char stby_reg; | 63 | unsigned char stby_reg; |
| @@ -63,6 +65,7 @@ struct pfuze_regulator { | |||
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| 65 | struct pfuze_chip { | 67 | struct pfuze_chip { |
| 68 | int chip_id; | ||
| 66 | struct regmap *regmap; | 69 | struct regmap *regmap; |
| 67 | struct device *dev; | 70 | struct device *dev; |
| 68 | struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; | 71 | struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; |
| @@ -78,21 +81,23 @@ static const int pfuze100_vsnvs[] = { | |||
| 78 | }; | 81 | }; |
| 79 | 82 | ||
| 80 | static const struct i2c_device_id pfuze_device_id[] = { | 83 | static const struct i2c_device_id pfuze_device_id[] = { |
| 81 | {.name = "pfuze100"}, | 84 | {.name = "pfuze100", .driver_data = PFUZE100}, |
| 82 | {}, | 85 | {.name = "pfuze200", .driver_data = PFUZE200}, |
| 86 | { } | ||
| 83 | }; | 87 | }; |
| 84 | MODULE_DEVICE_TABLE(i2c, pfuze_device_id); | 88 | MODULE_DEVICE_TABLE(i2c, pfuze_device_id); |
| 85 | 89 | ||
| 86 | static const struct of_device_id pfuze_dt_ids[] = { | 90 | static const struct of_device_id pfuze_dt_ids[] = { |
| 87 | { .compatible = "fsl,pfuze100" }, | 91 | { .compatible = "fsl,pfuze100", .data = (void *)PFUZE100}, |
| 88 | {}, | 92 | { .compatible = "fsl,pfuze200", .data = (void *)PFUZE200}, |
| 93 | { } | ||
| 89 | }; | 94 | }; |
| 90 | MODULE_DEVICE_TABLE(of, pfuze_dt_ids); | 95 | MODULE_DEVICE_TABLE(of, pfuze_dt_ids); |
| 91 | 96 | ||
| 92 | static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) | 97 | static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) |
| 93 | { | 98 | { |
| 94 | struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev); | 99 | struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev); |
| 95 | int id = rdev->desc->id; | 100 | int id = rdev_get_id(rdev); |
| 96 | unsigned int ramp_bits; | 101 | unsigned int ramp_bits; |
| 97 | int ret; | 102 | int ret; |
| 98 | 103 | ||
| @@ -139,14 +144,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = { | |||
| 139 | 144 | ||
| 140 | }; | 145 | }; |
| 141 | 146 | ||
| 142 | #define PFUZE100_FIXED_REG(_name, base, voltage) \ | 147 | #define PFUZE100_FIXED_REG(_chip, _name, base, voltage) \ |
| 143 | [PFUZE100_ ## _name] = { \ | 148 | [_chip ## _ ## _name] = { \ |
| 144 | .desc = { \ | 149 | .desc = { \ |
| 145 | .name = #_name, \ | 150 | .name = #_name, \ |
| 146 | .n_voltages = 1, \ | 151 | .n_voltages = 1, \ |
| 147 | .ops = &pfuze100_fixed_regulator_ops, \ | 152 | .ops = &pfuze100_fixed_regulator_ops, \ |
| 148 | .type = REGULATOR_VOLTAGE, \ | 153 | .type = REGULATOR_VOLTAGE, \ |
| 149 | .id = PFUZE100_ ## _name, \ | 154 | .id = _chip ## _ ## _name, \ |
| 150 | .owner = THIS_MODULE, \ | 155 | .owner = THIS_MODULE, \ |
| 151 | .min_uV = (voltage), \ | 156 | .min_uV = (voltage), \ |
| 152 | .enable_reg = (base), \ | 157 | .enable_reg = (base), \ |
| @@ -154,14 +159,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = { | |||
| 154 | }, \ | 159 | }, \ |
| 155 | } | 160 | } |
| 156 | 161 | ||
| 157 | #define PFUZE100_SW_REG(_name, base, min, max, step) \ | 162 | #define PFUZE100_SW_REG(_chip, _name, base, min, max, step) \ |
| 158 | [PFUZE100_ ## _name] = { \ | 163 | [_chip ## _ ## _name] = { \ |
| 159 | .desc = { \ | 164 | .desc = { \ |
| 160 | .name = #_name,\ | 165 | .name = #_name,\ |
| 161 | .n_voltages = ((max) - (min)) / (step) + 1, \ | 166 | .n_voltages = ((max) - (min)) / (step) + 1, \ |
| 162 | .ops = &pfuze100_sw_regulator_ops, \ | 167 | .ops = &pfuze100_sw_regulator_ops, \ |
| 163 | .type = REGULATOR_VOLTAGE, \ | 168 | .type = REGULATOR_VOLTAGE, \ |
| 164 | .id = PFUZE100_ ## _name, \ | 169 | .id = _chip ## _ ## _name, \ |
| 165 | .owner = THIS_MODULE, \ | 170 | .owner = THIS_MODULE, \ |
| 166 | .min_uV = (min), \ | 171 | .min_uV = (min), \ |
| 167 | .uV_step = (step), \ | 172 | .uV_step = (step), \ |
| @@ -172,14 +177,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = { | |||
| 172 | .stby_mask = 0x3f, \ | 177 | .stby_mask = 0x3f, \ |
| 173 | } | 178 | } |
| 174 | 179 | ||
| 175 | #define PFUZE100_SWB_REG(_name, base, mask, voltages) \ | 180 | #define PFUZE100_SWB_REG(_chip, _name, base, mask, voltages) \ |
| 176 | [PFUZE100_ ## _name] = { \ | 181 | [_chip ## _ ## _name] = { \ |
| 177 | .desc = { \ | 182 | .desc = { \ |
| 178 | .name = #_name, \ | 183 | .name = #_name, \ |
| 179 | .n_voltages = ARRAY_SIZE(voltages), \ | 184 | .n_voltages = ARRAY_SIZE(voltages), \ |
| 180 | .ops = &pfuze100_swb_regulator_ops, \ | 185 | .ops = &pfuze100_swb_regulator_ops, \ |
| 181 | .type = REGULATOR_VOLTAGE, \ | 186 | .type = REGULATOR_VOLTAGE, \ |
| 182 | .id = PFUZE100_ ## _name, \ | 187 | .id = _chip ## _ ## _name, \ |
| 183 | .owner = THIS_MODULE, \ | 188 | .owner = THIS_MODULE, \ |
| 184 | .volt_table = voltages, \ | 189 | .volt_table = voltages, \ |
| 185 | .vsel_reg = (base), \ | 190 | .vsel_reg = (base), \ |
| @@ -187,14 +192,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = { | |||
| 187 | }, \ | 192 | }, \ |
| 188 | } | 193 | } |
| 189 | 194 | ||
| 190 | #define PFUZE100_VGEN_REG(_name, base, min, max, step) \ | 195 | #define PFUZE100_VGEN_REG(_chip, _name, base, min, max, step) \ |
| 191 | [PFUZE100_ ## _name] = { \ | 196 | [_chip ## _ ## _name] = { \ |
| 192 | .desc = { \ | 197 | .desc = { \ |
| 193 | .name = #_name, \ | 198 | .name = #_name, \ |
| 194 | .n_voltages = ((max) - (min)) / (step) + 1, \ | 199 | .n_voltages = ((max) - (min)) / (step) + 1, \ |
| 195 | .ops = &pfuze100_ldo_regulator_ops, \ | 200 | .ops = &pfuze100_ldo_regulator_ops, \ |
| 196 | .type = REGULATOR_VOLTAGE, \ | 201 | .type = REGULATOR_VOLTAGE, \ |
| 197 | .id = PFUZE100_ ## _name, \ | 202 | .id = _chip ## _ ## _name, \ |
| 198 | .owner = THIS_MODULE, \ | 203 | .owner = THIS_MODULE, \ |
| 199 | .min_uV = (min), \ | 204 | .min_uV = (min), \ |
| 200 | .uV_step = (step), \ | 205 | .uV_step = (step), \ |
| @@ -207,25 +212,45 @@ static struct regulator_ops pfuze100_swb_regulator_ops = { | |||
| 207 | .stby_mask = 0x20, \ | 212 | .stby_mask = 0x20, \ |
| 208 | } | 213 | } |
| 209 | 214 | ||
| 215 | /* PFUZE100 */ | ||
| 210 | static struct pfuze_regulator pfuze100_regulators[] = { | 216 | static struct pfuze_regulator pfuze100_regulators[] = { |
| 211 | PFUZE100_SW_REG(SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000), | 217 | PFUZE100_SW_REG(PFUZE100, SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000), |
| 212 | PFUZE100_SW_REG(SW1C, PFUZE100_SW1CVOL, 300000, 1875000, 25000), | 218 | PFUZE100_SW_REG(PFUZE100, SW1C, PFUZE100_SW1CVOL, 300000, 1875000, 25000), |
| 213 | PFUZE100_SW_REG(SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000), | 219 | PFUZE100_SW_REG(PFUZE100, SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000), |
| 214 | PFUZE100_SW_REG(SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000), | 220 | PFUZE100_SW_REG(PFUZE100, SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000), |
| 215 | PFUZE100_SW_REG(SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000), | 221 | PFUZE100_SW_REG(PFUZE100, SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000), |
| 216 | PFUZE100_SW_REG(SW4, PFUZE100_SW4VOL, 400000, 1975000, 25000), | 222 | PFUZE100_SW_REG(PFUZE100, SW4, PFUZE100_SW4VOL, 400000, 1975000, 25000), |
| 217 | PFUZE100_SWB_REG(SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst), | 223 | PFUZE100_SWB_REG(PFUZE100, SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst), |
| 218 | PFUZE100_SWB_REG(VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs), | 224 | PFUZE100_SWB_REG(PFUZE100, VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs), |
| 219 | PFUZE100_FIXED_REG(VREFDDR, PFUZE100_VREFDDRCON, 750000), | 225 | PFUZE100_FIXED_REG(PFUZE100, VREFDDR, PFUZE100_VREFDDRCON, 750000), |
| 220 | PFUZE100_VGEN_REG(VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000), | 226 | PFUZE100_VGEN_REG(PFUZE100, VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000), |
| 221 | PFUZE100_VGEN_REG(VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000), | 227 | PFUZE100_VGEN_REG(PFUZE100, VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000), |
| 222 | PFUZE100_VGEN_REG(VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000), | 228 | PFUZE100_VGEN_REG(PFUZE100, VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000), |
| 223 | PFUZE100_VGEN_REG(VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000), | 229 | PFUZE100_VGEN_REG(PFUZE100, VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000), |
| 224 | PFUZE100_VGEN_REG(VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000), | 230 | PFUZE100_VGEN_REG(PFUZE100, VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000), |
| 225 | PFUZE100_VGEN_REG(VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), | 231 | PFUZE100_VGEN_REG(PFUZE100, VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), |
| 232 | }; | ||
| 233 | |||
| 234 | static struct pfuze_regulator pfuze200_regulators[] = { | ||
| 235 | PFUZE100_SW_REG(PFUZE200, SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000), | ||
| 236 | PFUZE100_SW_REG(PFUZE200, SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000), | ||
| 237 | PFUZE100_SW_REG(PFUZE200, SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000), | ||
| 238 | PFUZE100_SW_REG(PFUZE200, SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000), | ||
| 239 | PFUZE100_SWB_REG(PFUZE200, SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst), | ||
| 240 | PFUZE100_SWB_REG(PFUZE200, VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs), | ||
| 241 | PFUZE100_FIXED_REG(PFUZE200, VREFDDR, PFUZE100_VREFDDRCON, 750000), | ||
| 242 | PFUZE100_VGEN_REG(PFUZE200, VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000), | ||
| 243 | PFUZE100_VGEN_REG(PFUZE200, VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000), | ||
| 244 | PFUZE100_VGEN_REG(PFUZE200, VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000), | ||
| 245 | PFUZE100_VGEN_REG(PFUZE200, VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000), | ||
| 246 | PFUZE100_VGEN_REG(PFUZE200, VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000), | ||
| 247 | PFUZE100_VGEN_REG(PFUZE200, VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), | ||
| 226 | }; | 248 | }; |
| 227 | 249 | ||
| 250 | static struct pfuze_regulator *pfuze_regulators; | ||
| 251 | |||
| 228 | #ifdef CONFIG_OF | 252 | #ifdef CONFIG_OF |
| 253 | /* PFUZE100 */ | ||
| 229 | static struct of_regulator_match pfuze100_matches[] = { | 254 | static struct of_regulator_match pfuze100_matches[] = { |
| 230 | { .name = "sw1ab", }, | 255 | { .name = "sw1ab", }, |
| 231 | { .name = "sw1c", }, | 256 | { .name = "sw1c", }, |
| @@ -244,24 +269,56 @@ static struct of_regulator_match pfuze100_matches[] = { | |||
| 244 | { .name = "vgen6", }, | 269 | { .name = "vgen6", }, |
| 245 | }; | 270 | }; |
| 246 | 271 | ||
| 272 | /* PFUZE200 */ | ||
| 273 | static struct of_regulator_match pfuze200_matches[] = { | ||
| 274 | |||
| 275 | { .name = "sw1ab", }, | ||
| 276 | { .name = "sw2", }, | ||
| 277 | { .name = "sw3a", }, | ||
| 278 | { .name = "sw3b", }, | ||
| 279 | { .name = "swbst", }, | ||
| 280 | { .name = "vsnvs", }, | ||
| 281 | { .name = "vrefddr", }, | ||
| 282 | { .name = "vgen1", }, | ||
| 283 | { .name = "vgen2", }, | ||
| 284 | { .name = "vgen3", }, | ||
| 285 | { .name = "vgen4", }, | ||
| 286 | { .name = "vgen5", }, | ||
| 287 | { .name = "vgen6", }, | ||
| 288 | }; | ||
| 289 | |||
| 290 | static struct of_regulator_match *pfuze_matches; | ||
| 291 | |||
| 247 | static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) | 292 | static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) |
| 248 | { | 293 | { |
| 249 | struct device *dev = chip->dev; | 294 | struct device *dev = chip->dev; |
| 250 | struct device_node *np, *parent; | 295 | struct device_node *np, *parent; |
| 251 | int ret; | 296 | int ret; |
| 252 | 297 | ||
| 253 | np = of_node_get(dev->parent->of_node); | 298 | np = of_node_get(dev->of_node); |
| 254 | if (!np) | 299 | if (!np) |
| 255 | return 0; | 300 | return -EINVAL; |
| 256 | 301 | ||
| 257 | parent = of_find_node_by_name(np, "regulators"); | 302 | parent = of_get_child_by_name(np, "regulators"); |
| 258 | if (!parent) { | 303 | if (!parent) { |
| 259 | dev_err(dev, "regulators node not found\n"); | 304 | dev_err(dev, "regulators node not found\n"); |
| 260 | return -EINVAL; | 305 | return -EINVAL; |
| 261 | } | 306 | } |
| 262 | 307 | ||
| 263 | ret = of_regulator_match(dev, parent, pfuze100_matches, | 308 | switch (chip->chip_id) { |
| 264 | ARRAY_SIZE(pfuze100_matches)); | 309 | case PFUZE200: |
| 310 | pfuze_matches = pfuze200_matches; | ||
| 311 | ret = of_regulator_match(dev, parent, pfuze200_matches, | ||
| 312 | ARRAY_SIZE(pfuze200_matches)); | ||
| 313 | break; | ||
| 314 | |||
| 315 | case PFUZE100: | ||
| 316 | default: | ||
| 317 | pfuze_matches = pfuze100_matches; | ||
| 318 | ret = of_regulator_match(dev, parent, pfuze100_matches, | ||
| 319 | ARRAY_SIZE(pfuze100_matches)); | ||
| 320 | break; | ||
| 321 | } | ||
| 265 | 322 | ||
| 266 | of_node_put(parent); | 323 | of_node_put(parent); |
| 267 | if (ret < 0) { | 324 | if (ret < 0) { |
| @@ -275,12 +332,12 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) | |||
| 275 | 332 | ||
| 276 | static inline struct regulator_init_data *match_init_data(int index) | 333 | static inline struct regulator_init_data *match_init_data(int index) |
| 277 | { | 334 | { |
| 278 | return pfuze100_matches[index].init_data; | 335 | return pfuze_matches[index].init_data; |
| 279 | } | 336 | } |
| 280 | 337 | ||
| 281 | static inline struct device_node *match_of_node(int index) | 338 | static inline struct device_node *match_of_node(int index) |
| 282 | { | 339 | { |
| 283 | return pfuze100_matches[index].of_node; | 340 | return pfuze_matches[index].of_node; |
| 284 | } | 341 | } |
| 285 | #else | 342 | #else |
| 286 | static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) | 343 | static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) |
| @@ -308,16 +365,14 @@ static int pfuze_identify(struct pfuze_chip *pfuze_chip) | |||
| 308 | if (ret) | 365 | if (ret) |
| 309 | return ret; | 366 | return ret; |
| 310 | 367 | ||
| 311 | switch (value & 0x0f) { | 368 | if (((value & 0x0f) == 0x8) && (pfuze_chip->chip_id == PFUZE100)) { |
| 312 | /* | 369 | /* |
| 313 | * Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 | 370 | * Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 |
| 314 | * as ID=8 | 371 | * as ID=8 in PFUZE100 |
| 315 | */ | 372 | */ |
| 316 | case 0x8: | ||
| 317 | dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); | 373 | dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); |
| 318 | case 0x0: | 374 | } else if ((value & 0x0f) != pfuze_chip->chip_id) { |
| 319 | break; | 375 | /* device id NOT match with your setting */ |
| 320 | default: | ||
| 321 | dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); | 376 | dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); |
| 322 | return -ENODEV; | 377 | return -ENODEV; |
| 323 | } | 378 | } |
| @@ -353,17 +408,31 @@ static int pfuze100_regulator_probe(struct i2c_client *client, | |||
| 353 | dev_get_platdata(&client->dev); | 408 | dev_get_platdata(&client->dev); |
| 354 | struct regulator_config config = { }; | 409 | struct regulator_config config = { }; |
| 355 | int i, ret; | 410 | int i, ret; |
| 411 | const struct of_device_id *match; | ||
| 412 | u32 regulator_num; | ||
| 413 | u32 sw_check_start, sw_check_end; | ||
| 356 | 414 | ||
| 357 | pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip), | 415 | pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip), |
| 358 | GFP_KERNEL); | 416 | GFP_KERNEL); |
| 359 | if (!pfuze_chip) | 417 | if (!pfuze_chip) |
| 360 | return -ENOMEM; | 418 | return -ENOMEM; |
| 361 | 419 | ||
| 362 | i2c_set_clientdata(client, pfuze_chip); | 420 | if (client->dev.of_node) { |
| 363 | 421 | match = of_match_device(of_match_ptr(pfuze_dt_ids), | |
| 364 | memcpy(pfuze_chip->regulator_descs, pfuze100_regulators, | 422 | &client->dev); |
| 365 | sizeof(pfuze_chip->regulator_descs)); | 423 | if (!match) { |
| 424 | dev_err(&client->dev, "Error: No device match found\n"); | ||
| 425 | return -ENODEV; | ||
| 426 | } | ||
| 427 | pfuze_chip->chip_id = (int)(long)match->data; | ||
| 428 | } else if (id) { | ||
| 429 | pfuze_chip->chip_id = id->driver_data; | ||
| 430 | } else { | ||
| 431 | dev_err(&client->dev, "No dts match or id table match found\n"); | ||
| 432 | return -ENODEV; | ||
| 433 | } | ||
| 366 | 434 | ||
| 435 | i2c_set_clientdata(client, pfuze_chip); | ||
| 367 | pfuze_chip->dev = &client->dev; | 436 | pfuze_chip->dev = &client->dev; |
| 368 | 437 | ||
| 369 | pfuze_chip->regmap = devm_regmap_init_i2c(client, &pfuze_regmap_config); | 438 | pfuze_chip->regmap = devm_regmap_init_i2c(client, &pfuze_regmap_config); |
| @@ -380,11 +449,34 @@ static int pfuze100_regulator_probe(struct i2c_client *client, | |||
| 380 | return ret; | 449 | return ret; |
| 381 | } | 450 | } |
| 382 | 451 | ||
| 452 | /* use the right regulators after identify the right device */ | ||
| 453 | switch (pfuze_chip->chip_id) { | ||
| 454 | case PFUZE200: | ||
| 455 | pfuze_regulators = pfuze200_regulators; | ||
| 456 | regulator_num = ARRAY_SIZE(pfuze200_regulators); | ||
| 457 | sw_check_start = PFUZE200_SW2; | ||
| 458 | sw_check_end = PFUZE200_SW3B; | ||
| 459 | break; | ||
| 460 | |||
| 461 | case PFUZE100: | ||
| 462 | default: | ||
| 463 | pfuze_regulators = pfuze100_regulators; | ||
| 464 | regulator_num = ARRAY_SIZE(pfuze100_regulators); | ||
| 465 | sw_check_start = PFUZE100_SW2; | ||
| 466 | sw_check_end = PFUZE100_SW4; | ||
| 467 | break; | ||
| 468 | } | ||
| 469 | dev_info(&client->dev, "pfuze%s found.\n", | ||
| 470 | (pfuze_chip->chip_id == PFUZE100) ? "100" : "200"); | ||
| 471 | |||
| 472 | memcpy(pfuze_chip->regulator_descs, pfuze_regulators, | ||
| 473 | sizeof(pfuze_chip->regulator_descs)); | ||
| 474 | |||
| 383 | ret = pfuze_parse_regulators_dt(pfuze_chip); | 475 | ret = pfuze_parse_regulators_dt(pfuze_chip); |
| 384 | if (ret) | 476 | if (ret) |
| 385 | return ret; | 477 | return ret; |
| 386 | 478 | ||
| 387 | for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) { | 479 | for (i = 0; i < regulator_num; i++) { |
| 388 | struct regulator_init_data *init_data; | 480 | struct regulator_init_data *init_data; |
| 389 | struct regulator_desc *desc; | 481 | struct regulator_desc *desc; |
| 390 | int val; | 482 | int val; |
| @@ -397,7 +489,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client, | |||
| 397 | init_data = match_init_data(i); | 489 | init_data = match_init_data(i); |
| 398 | 490 | ||
| 399 | /* SW2~SW4 high bit check and modify the voltage value table */ | 491 | /* SW2~SW4 high bit check and modify the voltage value table */ |
| 400 | if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) { | 492 | if (i >= sw_check_start && i <= sw_check_end) { |
| 401 | regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val); | 493 | regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val); |
| 402 | if (val & 0x40) { | 494 | if (val & 0x40) { |
| 403 | desc->min_uV = 800000; | 495 | desc->min_uV = 800000; |
| @@ -415,7 +507,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client, | |||
| 415 | devm_regulator_register(&client->dev, desc, &config); | 507 | devm_regulator_register(&client->dev, desc, &config); |
| 416 | if (IS_ERR(pfuze_chip->regulators[i])) { | 508 | if (IS_ERR(pfuze_chip->regulators[i])) { |
| 417 | dev_err(&client->dev, "register regulator%s failed\n", | 509 | dev_err(&client->dev, "register regulator%s failed\n", |
| 418 | pfuze100_regulators[i].desc.name); | 510 | pfuze_regulators[i].desc.name); |
| 419 | return PTR_ERR(pfuze_chip->regulators[i]); | 511 | return PTR_ERR(pfuze_chip->regulators[i]); |
| 420 | } | 512 | } |
| 421 | } | 513 | } |
| @@ -435,6 +527,6 @@ static struct i2c_driver pfuze_driver = { | |||
| 435 | module_i2c_driver(pfuze_driver); | 527 | module_i2c_driver(pfuze_driver); |
| 436 | 528 | ||
| 437 | MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); | 529 | MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); |
| 438 | MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100 PMIC"); | 530 | MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/PFUZE200 PMIC"); |
| 439 | MODULE_LICENSE("GPL v2"); | 531 | MODULE_LICENSE("GPL v2"); |
| 440 | MODULE_ALIAS("i2c:pfuze100-regulator"); | 532 | MODULE_ALIAS("i2c:pfuze100-regulator"); |
