1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright (C) 2019 ROHM Semiconductors 3 // bd71828-regulator.c ROHM BD71828GW-DS1 regulator driver 4 // 5 6 #include <linux/cleanup.h> 7 #include <linux/delay.h> 8 #include <linux/err.h> 9 #include <linux/interrupt.h> 10 #include <linux/kernel.h> 11 #include <linux/mfd/rohm-bd71828.h> 12 #include <linux/mfd/rohm-bd72720.h> 13 #include <linux/module.h> 14 #include <linux/mod_devicetable.h> 15 #include <linux/of.h> 16 #include <linux/platform_device.h> 17 #include <linux/regmap.h> 18 #include <linux/regulator/driver.h> 19 #include <linux/regulator/machine.h> 20 #include <linux/regulator/of_regulator.h> 21 22 #define BD72720_MASK_LDON_HEAD GENMASK(2, 0) 23 struct reg_init { 24 unsigned int reg; 25 unsigned int mask; 26 unsigned int val; 27 }; 28 struct bd71828_regulator_data { 29 struct regulator_desc desc; 30 const struct rohm_dvs_config dvs; 31 const struct reg_init *reg_inits; 32 int reg_init_amnt; 33 }; 34 35 static const struct reg_init bd71828_buck1_inits[] = { 36 /* 37 * DVS Buck voltages can be changed by register values or via GPIO. 38 * Use register accesses by default. 39 */ 40 { 41 .reg = BD71828_REG_PS_CTRL_1, 42 .mask = BD71828_MASK_DVS_BUCK1_CTRL, 43 .val = BD71828_DVS_BUCK1_CTRL_I2C, 44 }, 45 }; 46 47 static const struct reg_init bd71828_buck2_inits[] = { 48 { 49 .reg = BD71828_REG_PS_CTRL_1, 50 .mask = BD71828_MASK_DVS_BUCK2_CTRL, 51 .val = BD71828_DVS_BUCK2_CTRL_I2C, 52 }, 53 }; 54 55 static const struct reg_init bd71828_buck6_inits[] = { 56 { 57 .reg = BD71828_REG_PS_CTRL_1, 58 .mask = BD71828_MASK_DVS_BUCK6_CTRL, 59 .val = BD71828_DVS_BUCK6_CTRL_I2C, 60 }, 61 }; 62 63 static const struct reg_init bd71828_buck7_inits[] = { 64 { 65 .reg = BD71828_REG_PS_CTRL_1, 66 .mask = BD71828_MASK_DVS_BUCK7_CTRL, 67 .val = BD71828_DVS_BUCK7_CTRL_I2C, 68 }, 69 }; 70 71 #define BD72720_MASK_DVS_BUCK1_CTRL BIT(4) 72 #define BD72720_MASK_DVS_LDO1_CTRL BIT(5) 73 74 static const struct reg_init bd72720_buck1_inits[] = { 75 { 76 .reg = BD72720_REG_PS_CTRL_2, 77 .mask = BD72720_MASK_DVS_BUCK1_CTRL, 78 .val = 0, /* Disable "run-level" control */ 79 }, 80 }; 81 82 static const struct reg_init bd72720_ldo1_inits[] = { 83 { 84 .reg = BD72720_REG_PS_CTRL_2, 85 .mask = BD72720_MASK_DVS_LDO1_CTRL, 86 .val = 0, /* Disable "run-level" control */ 87 }, 88 }; 89 90 /* BD71828 Buck voltages */ 91 static const struct linear_range bd71828_buck1267_volts[] = { 92 REGULATOR_LINEAR_RANGE(500000, 0x00, 0xef, 6250), 93 REGULATOR_LINEAR_RANGE(2000000, 0xf0, 0xff, 0), 94 }; 95 96 static const struct linear_range bd71828_buck3_volts[] = { 97 REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x0f, 50000), 98 REGULATOR_LINEAR_RANGE(2000000, 0x10, 0x1f, 0), 99 }; 100 101 static const struct linear_range bd71828_buck4_volts[] = { 102 REGULATOR_LINEAR_RANGE(1000000, 0x00, 0x1f, 25000), 103 REGULATOR_LINEAR_RANGE(1800000, 0x20, 0x3f, 0), 104 }; 105 106 static const struct linear_range bd71828_buck5_volts[] = { 107 REGULATOR_LINEAR_RANGE(2500000, 0x00, 0x0f, 50000), 108 REGULATOR_LINEAR_RANGE(3300000, 0x10, 0x1f, 0), 109 }; 110 111 /* BD71828 LDO voltages */ 112 static const struct linear_range bd71828_ldo_volts[] = { 113 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x31, 50000), 114 REGULATOR_LINEAR_RANGE(3300000, 0x32, 0x3f, 0), 115 }; 116 117 /* BD72720 Buck voltages */ 118 static const struct linear_range bd72720_buck1234_volts[] = { 119 REGULATOR_LINEAR_RANGE(500000, 0x00, 0xc0, 6250), 120 REGULATOR_LINEAR_RANGE(1700000, 0xc1, 0xff, 0), 121 }; 122 123 static const struct linear_range bd72720_buck589_volts[] = { 124 REGULATOR_LINEAR_RANGE(500000, 0x00, 0x78, 10000), 125 REGULATOR_LINEAR_RANGE(1700000, 0x79, 0xff, 0), 126 }; 127 128 static const struct linear_range bd72720_buck67_volts[] = { 129 REGULATOR_LINEAR_RANGE(1500000, 0x00, 0xb4, 10000), 130 REGULATOR_LINEAR_RANGE(3300000, 0xb5, 0xff, 0), 131 }; 132 133 /* 134 * The BUCK10 on BD72720 has two modes of operation, depending on a LDON_HEAD 135 * setting. When LDON_HEAD is 0x0, the behaviour is as with other bucks, eg. 136 * voltage can be set to a values indicated below using the VSEL register. 137 * 138 * However, when LDON_HEAD is set to 0x1 ... 0x7, BUCK 10 voltage is, according 139 * to the data-sheet, "automatically adjusted following LDON_HEAD setting and 140 * clamped to BUCK10_VID setting". 141 * 142 * Again, reading the data-sheet shows a "typical connection" where the BUCK10 143 * is used to supply the LDOs 1-4. My assumption is that in practice, this 144 * means that the BUCK10 voltage will be adjusted based on the maximum output 145 * of the LDO 1-4 (to minimize power loss). This makes sense. 146 * 147 * Auto-adjusting regulators aren't something I really like to model in the 148 * driver though - and, if the auto-adjustment works as intended, then there 149 * should really be no need to software to care about the buck10 voltages. 150 * If enable/disable control is still needed, we can implement buck10 as a 151 * regulator with only the enable/disable ops - and device-tree can be used 152 * to model the supply-relations. I believe this could allow the regulator 153 * framework to automagically disable the BUCK10 if all LDOs that are being 154 * supplied by it are disabled. 155 */ 156 static const struct linear_range bd72720_buck10_volts[] = { 157 REGULATOR_LINEAR_RANGE(500000, 0x00, 0xc0, 6250), 158 REGULATOR_LINEAR_RANGE(1700000, 0xc1, 0xff, 0), 159 }; 160 161 /* BD72720 LDO voltages */ 162 static const struct linear_range bd72720_ldo1234_volts[] = { 163 REGULATOR_LINEAR_RANGE(500000, 0x00, 0x50, 6250), 164 REGULATOR_LINEAR_RANGE(1000000, 0x51, 0x7f, 0), 165 }; 166 167 static const struct linear_range bd72720_ldo57891011_volts[] = { 168 REGULATOR_LINEAR_RANGE(750000, 0x00, 0xff, 10000), 169 }; 170 171 static const struct linear_range bd72720_ldo6_volts[] = { 172 REGULATOR_LINEAR_RANGE(600000, 0x00, 0x78, 10000), 173 REGULATOR_LINEAR_RANGE(1800000, 0x79, 0x7f, 0), 174 }; 175 176 static const unsigned int bd71828_ramp_delay[] = { 2500, 5000, 10000, 20000 }; 177 178 /* 179 * BD72720 supports setting both the ramp-up and ramp-down values 180 * separately. Do we need to support ramp-down setting? 181 */ 182 static const unsigned int bd72720_ramp_delay[] = { 5000, 7500, 10000, 12500 }; 183 184 static int buck_set_hw_dvs_levels(struct device_node *np, 185 const struct regulator_desc *desc, 186 struct regulator_config *cfg) 187 { 188 const struct bd71828_regulator_data *data; 189 190 data = container_of_const(desc, struct bd71828_regulator_data, desc); 191 192 return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap); 193 } 194 195 static int bd71828_ldo6_parse_dt(struct device_node *np, 196 const struct regulator_desc *desc, 197 struct regulator_config *cfg) 198 { 199 int ret, i; 200 uint32_t uv = 0; 201 unsigned int en; 202 struct regmap *regmap = cfg->regmap; 203 static const char * const props[] = { "rohm,dvs-run-voltage", 204 "rohm,dvs-idle-voltage", 205 "rohm,dvs-suspend-voltage", 206 "rohm,dvs-lpsr-voltage" }; 207 unsigned int mask[] = { BD71828_MASK_RUN_EN, BD71828_MASK_IDLE_EN, 208 BD71828_MASK_SUSP_EN, BD71828_MASK_LPSR_EN }; 209 210 for (i = 0; i < ARRAY_SIZE(props); i++) { 211 ret = of_property_read_u32(np, props[i], &uv); 212 if (ret) { 213 if (ret != -EINVAL) 214 return ret; 215 continue; 216 } 217 if (uv) 218 en = 0xffffffff; 219 else 220 en = 0; 221 222 ret = regmap_update_bits(regmap, desc->enable_reg, mask[i], en); 223 if (ret) 224 return ret; 225 } 226 return 0; 227 } 228 229 static const struct regulator_ops bd71828_buck_ops = { 230 .enable = regulator_enable_regmap, 231 .disable = regulator_disable_regmap, 232 .is_enabled = regulator_is_enabled_regmap, 233 .list_voltage = regulator_list_voltage_linear_range, 234 .set_voltage_sel = regulator_set_voltage_sel_regmap, 235 .get_voltage_sel = regulator_get_voltage_sel_regmap, 236 }; 237 238 static const struct regulator_ops bd71828_dvs_buck_ops = { 239 .enable = regulator_enable_regmap, 240 .disable = regulator_disable_regmap, 241 .is_enabled = regulator_is_enabled_regmap, 242 .list_voltage = regulator_list_voltage_linear_range, 243 .set_voltage_sel = regulator_set_voltage_sel_regmap, 244 .get_voltage_sel = regulator_get_voltage_sel_regmap, 245 .set_voltage_time_sel = regulator_set_voltage_time_sel, 246 .set_ramp_delay = regulator_set_ramp_delay_regmap, 247 }; 248 249 static const struct regulator_ops bd71828_ldo_ops = { 250 .enable = regulator_enable_regmap, 251 .disable = regulator_disable_regmap, 252 .is_enabled = regulator_is_enabled_regmap, 253 .list_voltage = regulator_list_voltage_linear_range, 254 .set_voltage_sel = regulator_set_voltage_sel_regmap, 255 .get_voltage_sel = regulator_get_voltage_sel_regmap, 256 }; 257 258 static const struct regulator_ops bd71828_ldo6_ops = { 259 .enable = regulator_enable_regmap, 260 .disable = regulator_disable_regmap, 261 .is_enabled = regulator_is_enabled_regmap, 262 }; 263 264 static const struct regulator_ops bd72720_regulator_ops = { 265 .enable = regulator_enable_regmap, 266 .disable = regulator_disable_regmap, 267 .is_enabled = regulator_is_enabled_regmap, 268 .list_voltage = regulator_list_voltage_linear_range, 269 .set_voltage_sel = regulator_set_voltage_sel_regmap, 270 .get_voltage_sel = regulator_get_voltage_sel_regmap, 271 .set_voltage_time_sel = regulator_set_voltage_time_sel, 272 .set_ramp_delay = regulator_set_ramp_delay_regmap, 273 }; 274 275 static const struct regulator_ops bd72720_buck10_ldon_head_op = { 276 .enable = regulator_enable_regmap, 277 .disable = regulator_disable_regmap, 278 .is_enabled = regulator_is_enabled_regmap, 279 .set_ramp_delay = regulator_set_ramp_delay_regmap, 280 }; 281 282 static const struct bd71828_regulator_data bd71828_rdata[] = { 283 { 284 .desc = { 285 .name = "buck1", 286 .of_match = of_match_ptr("BUCK1"), 287 .regulators_node = of_match_ptr("regulators"), 288 .id = BD71828_BUCK1, 289 .ops = &bd71828_dvs_buck_ops, 290 .type = REGULATOR_VOLTAGE, 291 .linear_ranges = bd71828_buck1267_volts, 292 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts), 293 .n_voltages = BD71828_BUCK1267_VOLTS, 294 .enable_reg = BD71828_REG_BUCK1_EN, 295 .enable_mask = BD71828_MASK_RUN_EN, 296 .vsel_reg = BD71828_REG_BUCK1_VOLT, 297 .vsel_mask = BD71828_MASK_BUCK1267_VOLT, 298 .ramp_delay_table = bd71828_ramp_delay, 299 .n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay), 300 .ramp_reg = BD71828_REG_BUCK1_MODE, 301 .ramp_mask = BD71828_MASK_RAMP_DELAY, 302 .owner = THIS_MODULE, 303 .of_parse_cb = buck_set_hw_dvs_levels, 304 }, 305 .dvs = { 306 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 307 ROHM_DVS_LEVEL_SUSPEND | 308 ROHM_DVS_LEVEL_LPSR, 309 .run_reg = BD71828_REG_BUCK1_VOLT, 310 .run_mask = BD71828_MASK_BUCK1267_VOLT, 311 .idle_reg = BD71828_REG_BUCK1_IDLE_VOLT, 312 .idle_mask = BD71828_MASK_BUCK1267_VOLT, 313 .idle_on_mask = BD71828_MASK_IDLE_EN, 314 .suspend_reg = BD71828_REG_BUCK1_SUSP_VOLT, 315 .suspend_mask = BD71828_MASK_BUCK1267_VOLT, 316 .suspend_on_mask = BD71828_MASK_SUSP_EN, 317 /* 318 * LPSR voltage is same as SUSPEND voltage. Allow 319 * only enabling/disabling regulator for LPSR state 320 */ 321 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 322 }, 323 .reg_inits = bd71828_buck1_inits, 324 .reg_init_amnt = ARRAY_SIZE(bd71828_buck1_inits), 325 }, 326 { 327 .desc = { 328 .name = "buck2", 329 .of_match = of_match_ptr("BUCK2"), 330 .regulators_node = of_match_ptr("regulators"), 331 .id = BD71828_BUCK2, 332 .ops = &bd71828_dvs_buck_ops, 333 .type = REGULATOR_VOLTAGE, 334 .linear_ranges = bd71828_buck1267_volts, 335 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts), 336 .n_voltages = BD71828_BUCK1267_VOLTS, 337 .enable_reg = BD71828_REG_BUCK2_EN, 338 .enable_mask = BD71828_MASK_RUN_EN, 339 .vsel_reg = BD71828_REG_BUCK2_VOLT, 340 .vsel_mask = BD71828_MASK_BUCK1267_VOLT, 341 .ramp_delay_table = bd71828_ramp_delay, 342 .n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay), 343 .ramp_reg = BD71828_REG_BUCK2_MODE, 344 .ramp_mask = BD71828_MASK_RAMP_DELAY, 345 .owner = THIS_MODULE, 346 .of_parse_cb = buck_set_hw_dvs_levels, 347 }, 348 .dvs = { 349 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 350 ROHM_DVS_LEVEL_SUSPEND | 351 ROHM_DVS_LEVEL_LPSR, 352 .run_reg = BD71828_REG_BUCK2_VOLT, 353 .run_mask = BD71828_MASK_BUCK1267_VOLT, 354 .idle_reg = BD71828_REG_BUCK2_IDLE_VOLT, 355 .idle_mask = BD71828_MASK_BUCK1267_VOLT, 356 .idle_on_mask = BD71828_MASK_IDLE_EN, 357 .suspend_reg = BD71828_REG_BUCK2_SUSP_VOLT, 358 .suspend_mask = BD71828_MASK_BUCK1267_VOLT, 359 .suspend_on_mask = BD71828_MASK_SUSP_EN, 360 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 361 .lpsr_reg = BD71828_REG_BUCK2_SUSP_VOLT, 362 .lpsr_mask = BD71828_MASK_BUCK1267_VOLT, 363 }, 364 .reg_inits = bd71828_buck2_inits, 365 .reg_init_amnt = ARRAY_SIZE(bd71828_buck2_inits), 366 }, 367 { 368 .desc = { 369 .name = "buck3", 370 .of_match = of_match_ptr("BUCK3"), 371 .regulators_node = of_match_ptr("regulators"), 372 .id = BD71828_BUCK3, 373 .ops = &bd71828_buck_ops, 374 .type = REGULATOR_VOLTAGE, 375 .linear_ranges = bd71828_buck3_volts, 376 .n_linear_ranges = ARRAY_SIZE(bd71828_buck3_volts), 377 .n_voltages = BD71828_BUCK3_VOLTS, 378 .enable_reg = BD71828_REG_BUCK3_EN, 379 .enable_mask = BD71828_MASK_RUN_EN, 380 .vsel_reg = BD71828_REG_BUCK3_VOLT, 381 .vsel_mask = BD71828_MASK_BUCK3_VOLT, 382 .owner = THIS_MODULE, 383 .of_parse_cb = buck_set_hw_dvs_levels, 384 }, 385 .dvs = { 386 /* 387 * BUCK3 only supports single voltage for all states. 388 * voltage can be individually enabled for each state 389 * though => allow setting all states to support 390 * enabling power rail on different states. 391 */ 392 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 393 ROHM_DVS_LEVEL_SUSPEND | 394 ROHM_DVS_LEVEL_LPSR, 395 .run_reg = BD71828_REG_BUCK3_VOLT, 396 .run_mask = BD71828_MASK_BUCK3_VOLT, 397 .idle_on_mask = BD71828_MASK_IDLE_EN, 398 .suspend_on_mask = BD71828_MASK_SUSP_EN, 399 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 400 }, 401 }, 402 { 403 .desc = { 404 .name = "buck4", 405 .of_match = of_match_ptr("BUCK4"), 406 .regulators_node = of_match_ptr("regulators"), 407 .id = BD71828_BUCK4, 408 .ops = &bd71828_buck_ops, 409 .type = REGULATOR_VOLTAGE, 410 .linear_ranges = bd71828_buck4_volts, 411 .n_linear_ranges = ARRAY_SIZE(bd71828_buck4_volts), 412 .n_voltages = BD71828_BUCK4_VOLTS, 413 .enable_reg = BD71828_REG_BUCK4_EN, 414 .enable_mask = BD71828_MASK_RUN_EN, 415 .vsel_reg = BD71828_REG_BUCK4_VOLT, 416 .vsel_mask = BD71828_MASK_BUCK4_VOLT, 417 .owner = THIS_MODULE, 418 .of_parse_cb = buck_set_hw_dvs_levels, 419 }, 420 .dvs = { 421 /* 422 * BUCK4 only supports single voltage for all states. 423 * voltage can be individually enabled for each state 424 * though => allow setting all states to support 425 * enabling power rail on different states. 426 */ 427 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 428 ROHM_DVS_LEVEL_SUSPEND | 429 ROHM_DVS_LEVEL_LPSR, 430 .run_reg = BD71828_REG_BUCK4_VOLT, 431 .run_mask = BD71828_MASK_BUCK4_VOLT, 432 .idle_on_mask = BD71828_MASK_IDLE_EN, 433 .suspend_on_mask = BD71828_MASK_SUSP_EN, 434 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 435 }, 436 }, 437 { 438 .desc = { 439 .name = "buck5", 440 .of_match = of_match_ptr("BUCK5"), 441 .regulators_node = of_match_ptr("regulators"), 442 .id = BD71828_BUCK5, 443 .ops = &bd71828_buck_ops, 444 .type = REGULATOR_VOLTAGE, 445 .linear_ranges = bd71828_buck5_volts, 446 .n_linear_ranges = ARRAY_SIZE(bd71828_buck5_volts), 447 .n_voltages = BD71828_BUCK5_VOLTS, 448 .enable_reg = BD71828_REG_BUCK5_EN, 449 .enable_mask = BD71828_MASK_RUN_EN, 450 .vsel_reg = BD71828_REG_BUCK5_VOLT, 451 .vsel_mask = BD71828_MASK_BUCK5_VOLT, 452 .owner = THIS_MODULE, 453 .of_parse_cb = buck_set_hw_dvs_levels, 454 }, 455 .dvs = { 456 /* 457 * BUCK5 only supports single voltage for all states. 458 * voltage can be individually enabled for each state 459 * though => allow setting all states to support 460 * enabling power rail on different states. 461 */ 462 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 463 ROHM_DVS_LEVEL_SUSPEND | 464 ROHM_DVS_LEVEL_LPSR, 465 .run_reg = BD71828_REG_BUCK5_VOLT, 466 .run_mask = BD71828_MASK_BUCK5_VOLT, 467 .idle_on_mask = BD71828_MASK_IDLE_EN, 468 .suspend_on_mask = BD71828_MASK_SUSP_EN, 469 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 470 }, 471 }, 472 { 473 .desc = { 474 .name = "buck6", 475 .of_match = of_match_ptr("BUCK6"), 476 .regulators_node = of_match_ptr("regulators"), 477 .id = BD71828_BUCK6, 478 .ops = &bd71828_dvs_buck_ops, 479 .type = REGULATOR_VOLTAGE, 480 .linear_ranges = bd71828_buck1267_volts, 481 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts), 482 .n_voltages = BD71828_BUCK1267_VOLTS, 483 .enable_reg = BD71828_REG_BUCK6_EN, 484 .enable_mask = BD71828_MASK_RUN_EN, 485 .vsel_reg = BD71828_REG_BUCK6_VOLT, 486 .vsel_mask = BD71828_MASK_BUCK1267_VOLT, 487 .ramp_delay_table = bd71828_ramp_delay, 488 .n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay), 489 .ramp_reg = BD71828_REG_BUCK6_MODE, 490 .ramp_mask = BD71828_MASK_RAMP_DELAY, 491 .owner = THIS_MODULE, 492 .of_parse_cb = buck_set_hw_dvs_levels, 493 }, 494 .dvs = { 495 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 496 ROHM_DVS_LEVEL_SUSPEND | 497 ROHM_DVS_LEVEL_LPSR, 498 .run_reg = BD71828_REG_BUCK6_VOLT, 499 .run_mask = BD71828_MASK_BUCK1267_VOLT, 500 .idle_reg = BD71828_REG_BUCK6_IDLE_VOLT, 501 .idle_mask = BD71828_MASK_BUCK1267_VOLT, 502 .idle_on_mask = BD71828_MASK_IDLE_EN, 503 .suspend_reg = BD71828_REG_BUCK6_SUSP_VOLT, 504 .suspend_mask = BD71828_MASK_BUCK1267_VOLT, 505 .suspend_on_mask = BD71828_MASK_SUSP_EN, 506 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 507 .lpsr_reg = BD71828_REG_BUCK6_SUSP_VOLT, 508 .lpsr_mask = BD71828_MASK_BUCK1267_VOLT, 509 }, 510 .reg_inits = bd71828_buck6_inits, 511 .reg_init_amnt = ARRAY_SIZE(bd71828_buck6_inits), 512 }, 513 { 514 .desc = { 515 .name = "buck7", 516 .of_match = of_match_ptr("BUCK7"), 517 .regulators_node = of_match_ptr("regulators"), 518 .id = BD71828_BUCK7, 519 .ops = &bd71828_dvs_buck_ops, 520 .type = REGULATOR_VOLTAGE, 521 .linear_ranges = bd71828_buck1267_volts, 522 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts), 523 .n_voltages = BD71828_BUCK1267_VOLTS, 524 .enable_reg = BD71828_REG_BUCK7_EN, 525 .enable_mask = BD71828_MASK_RUN_EN, 526 .vsel_reg = BD71828_REG_BUCK7_VOLT, 527 .vsel_mask = BD71828_MASK_BUCK1267_VOLT, 528 .ramp_delay_table = bd71828_ramp_delay, 529 .n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay), 530 .ramp_reg = BD71828_REG_BUCK7_MODE, 531 .ramp_mask = BD71828_MASK_RAMP_DELAY, 532 .owner = THIS_MODULE, 533 .of_parse_cb = buck_set_hw_dvs_levels, 534 }, 535 .dvs = { 536 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 537 ROHM_DVS_LEVEL_SUSPEND | 538 ROHM_DVS_LEVEL_LPSR, 539 .run_reg = BD71828_REG_BUCK7_VOLT, 540 .run_mask = BD71828_MASK_BUCK1267_VOLT, 541 .idle_reg = BD71828_REG_BUCK7_IDLE_VOLT, 542 .idle_mask = BD71828_MASK_BUCK1267_VOLT, 543 .idle_on_mask = BD71828_MASK_IDLE_EN, 544 .suspend_reg = BD71828_REG_BUCK7_SUSP_VOLT, 545 .suspend_mask = BD71828_MASK_BUCK1267_VOLT, 546 .suspend_on_mask = BD71828_MASK_SUSP_EN, 547 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 548 .lpsr_reg = BD71828_REG_BUCK7_SUSP_VOLT, 549 .lpsr_mask = BD71828_MASK_BUCK1267_VOLT, 550 }, 551 .reg_inits = bd71828_buck7_inits, 552 .reg_init_amnt = ARRAY_SIZE(bd71828_buck7_inits), 553 }, 554 { 555 .desc = { 556 .name = "ldo1", 557 .of_match = of_match_ptr("LDO1"), 558 .regulators_node = of_match_ptr("regulators"), 559 .id = BD71828_LDO1, 560 .ops = &bd71828_ldo_ops, 561 .type = REGULATOR_VOLTAGE, 562 .linear_ranges = bd71828_ldo_volts, 563 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts), 564 .n_voltages = BD71828_LDO_VOLTS, 565 .enable_reg = BD71828_REG_LDO1_EN, 566 .enable_mask = BD71828_MASK_RUN_EN, 567 .vsel_reg = BD71828_REG_LDO1_VOLT, 568 .vsel_mask = BD71828_MASK_LDO_VOLT, 569 .owner = THIS_MODULE, 570 .of_parse_cb = buck_set_hw_dvs_levels, 571 }, 572 .dvs = { 573 /* 574 * LDO1 only supports single voltage for all states. 575 * voltage can be individually enabled for each state 576 * though => allow setting all states to support 577 * enabling power rail on different states. 578 */ 579 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 580 ROHM_DVS_LEVEL_SUSPEND | 581 ROHM_DVS_LEVEL_LPSR, 582 .run_reg = BD71828_REG_LDO1_VOLT, 583 .run_mask = BD71828_MASK_LDO_VOLT, 584 .idle_on_mask = BD71828_MASK_IDLE_EN, 585 .suspend_on_mask = BD71828_MASK_SUSP_EN, 586 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 587 }, 588 }, { 589 .desc = { 590 .name = "ldo2", 591 .of_match = of_match_ptr("LDO2"), 592 .regulators_node = of_match_ptr("regulators"), 593 .id = BD71828_LDO2, 594 .ops = &bd71828_ldo_ops, 595 .type = REGULATOR_VOLTAGE, 596 .linear_ranges = bd71828_ldo_volts, 597 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts), 598 .n_voltages = BD71828_LDO_VOLTS, 599 .enable_reg = BD71828_REG_LDO2_EN, 600 .enable_mask = BD71828_MASK_RUN_EN, 601 .vsel_reg = BD71828_REG_LDO2_VOLT, 602 .vsel_mask = BD71828_MASK_LDO_VOLT, 603 .owner = THIS_MODULE, 604 .of_parse_cb = buck_set_hw_dvs_levels, 605 }, 606 .dvs = { 607 /* 608 * LDO2 only supports single voltage for all states. 609 * voltage can be individually enabled for each state 610 * though => allow setting all states to support 611 * enabling power rail on different states. 612 */ 613 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 614 ROHM_DVS_LEVEL_SUSPEND | 615 ROHM_DVS_LEVEL_LPSR, 616 .run_reg = BD71828_REG_LDO2_VOLT, 617 .run_mask = BD71828_MASK_LDO_VOLT, 618 .idle_on_mask = BD71828_MASK_IDLE_EN, 619 .suspend_on_mask = BD71828_MASK_SUSP_EN, 620 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 621 }, 622 }, { 623 .desc = { 624 .name = "ldo3", 625 .of_match = of_match_ptr("LDO3"), 626 .regulators_node = of_match_ptr("regulators"), 627 .id = BD71828_LDO3, 628 .ops = &bd71828_ldo_ops, 629 .type = REGULATOR_VOLTAGE, 630 .linear_ranges = bd71828_ldo_volts, 631 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts), 632 .n_voltages = BD71828_LDO_VOLTS, 633 .enable_reg = BD71828_REG_LDO3_EN, 634 .enable_mask = BD71828_MASK_RUN_EN, 635 .vsel_reg = BD71828_REG_LDO3_VOLT, 636 .vsel_mask = BD71828_MASK_LDO_VOLT, 637 .owner = THIS_MODULE, 638 .of_parse_cb = buck_set_hw_dvs_levels, 639 }, 640 .dvs = { 641 /* 642 * LDO3 only supports single voltage for all states. 643 * voltage can be individually enabled for each state 644 * though => allow setting all states to support 645 * enabling power rail on different states. 646 */ 647 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 648 ROHM_DVS_LEVEL_SUSPEND | 649 ROHM_DVS_LEVEL_LPSR, 650 .run_reg = BD71828_REG_LDO3_VOLT, 651 .run_mask = BD71828_MASK_LDO_VOLT, 652 .idle_on_mask = BD71828_MASK_IDLE_EN, 653 .suspend_on_mask = BD71828_MASK_SUSP_EN, 654 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 655 }, 656 657 }, { 658 .desc = { 659 .name = "ldo4", 660 .of_match = of_match_ptr("LDO4"), 661 .regulators_node = of_match_ptr("regulators"), 662 .id = BD71828_LDO4, 663 .ops = &bd71828_ldo_ops, 664 .type = REGULATOR_VOLTAGE, 665 .linear_ranges = bd71828_ldo_volts, 666 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts), 667 .n_voltages = BD71828_LDO_VOLTS, 668 .enable_reg = BD71828_REG_LDO4_EN, 669 .enable_mask = BD71828_MASK_RUN_EN, 670 .vsel_reg = BD71828_REG_LDO4_VOLT, 671 .vsel_mask = BD71828_MASK_LDO_VOLT, 672 .owner = THIS_MODULE, 673 .of_parse_cb = buck_set_hw_dvs_levels, 674 }, 675 .dvs = { 676 /* 677 * LDO1 only supports single voltage for all states. 678 * voltage can be individually enabled for each state 679 * though => allow setting all states to support 680 * enabling power rail on different states. 681 */ 682 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 683 ROHM_DVS_LEVEL_SUSPEND | 684 ROHM_DVS_LEVEL_LPSR, 685 .run_reg = BD71828_REG_LDO4_VOLT, 686 .run_mask = BD71828_MASK_LDO_VOLT, 687 .idle_on_mask = BD71828_MASK_IDLE_EN, 688 .suspend_on_mask = BD71828_MASK_SUSP_EN, 689 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 690 }, 691 }, { 692 .desc = { 693 .name = "ldo5", 694 .of_match = of_match_ptr("LDO5"), 695 .regulators_node = of_match_ptr("regulators"), 696 .id = BD71828_LDO5, 697 .ops = &bd71828_ldo_ops, 698 .type = REGULATOR_VOLTAGE, 699 .linear_ranges = bd71828_ldo_volts, 700 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts), 701 .n_voltages = BD71828_LDO_VOLTS, 702 .enable_reg = BD71828_REG_LDO5_EN, 703 .enable_mask = BD71828_MASK_RUN_EN, 704 .vsel_reg = BD71828_REG_LDO5_VOLT, 705 .vsel_mask = BD71828_MASK_LDO_VOLT, 706 .of_parse_cb = buck_set_hw_dvs_levels, 707 .owner = THIS_MODULE, 708 }, 709 /* 710 * LDO5 is special. It can choose vsel settings to be configured 711 * from 2 different registers (by GPIO). 712 * 713 * This driver supports only configuration where 714 * BD71828_REG_LDO5_VOLT_L is used. 715 */ 716 .dvs = { 717 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 718 ROHM_DVS_LEVEL_SUSPEND | 719 ROHM_DVS_LEVEL_LPSR, 720 .run_reg = BD71828_REG_LDO5_VOLT, 721 .run_mask = BD71828_MASK_LDO_VOLT, 722 .idle_on_mask = BD71828_MASK_IDLE_EN, 723 .suspend_on_mask = BD71828_MASK_SUSP_EN, 724 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 725 }, 726 727 }, { 728 .desc = { 729 .name = "ldo6", 730 .of_match = of_match_ptr("LDO6"), 731 .regulators_node = of_match_ptr("regulators"), 732 .id = BD71828_LDO6, 733 .ops = &bd71828_ldo6_ops, 734 .type = REGULATOR_VOLTAGE, 735 .fixed_uV = BD71828_LDO_6_VOLTAGE, 736 .n_voltages = 1, 737 .enable_reg = BD71828_REG_LDO6_EN, 738 .enable_mask = BD71828_MASK_RUN_EN, 739 .owner = THIS_MODULE, 740 /* 741 * LDO6 only supports enable/disable for all states. 742 * Voltage for LDO6 is fixed. 743 */ 744 .of_parse_cb = bd71828_ldo6_parse_dt, 745 }, 746 }, { 747 .desc = { 748 /* SNVS LDO in data-sheet */ 749 .name = "ldo7", 750 .of_match = of_match_ptr("LDO7"), 751 .regulators_node = of_match_ptr("regulators"), 752 .id = BD71828_LDO_SNVS, 753 .ops = &bd71828_ldo_ops, 754 .type = REGULATOR_VOLTAGE, 755 .linear_ranges = bd71828_ldo_volts, 756 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts), 757 .n_voltages = BD71828_LDO_VOLTS, 758 .enable_reg = BD71828_REG_LDO7_EN, 759 .enable_mask = BD71828_MASK_RUN_EN, 760 .vsel_reg = BD71828_REG_LDO7_VOLT, 761 .vsel_mask = BD71828_MASK_LDO_VOLT, 762 .owner = THIS_MODULE, 763 .of_parse_cb = buck_set_hw_dvs_levels, 764 }, 765 .dvs = { 766 /* 767 * LDO7 only supports single voltage for all states. 768 * voltage can be individually enabled for each state 769 * though => allow setting all states to support 770 * enabling power rail on different states. 771 */ 772 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 773 ROHM_DVS_LEVEL_SUSPEND | 774 ROHM_DVS_LEVEL_LPSR, 775 .run_reg = BD71828_REG_LDO7_VOLT, 776 .idle_reg = BD71828_REG_LDO7_VOLT, 777 .suspend_reg = BD71828_REG_LDO7_VOLT, 778 .lpsr_reg = BD71828_REG_LDO7_VOLT, 779 .run_mask = BD71828_MASK_LDO_VOLT, 780 .idle_on_mask = BD71828_MASK_IDLE_EN, 781 .suspend_on_mask = BD71828_MASK_SUSP_EN, 782 .lpsr_on_mask = BD71828_MASK_LPSR_EN, 783 }, 784 785 }, 786 }; 787 788 #define BD72720_BUCK10_DESC_INDEX 10 789 #define BD72720_NUM_BUCK_VOLTS 0x100 790 #define BD72720_NUM_LDO_VOLTS 0x100 791 #define BD72720_NUM_LDO12346_VOLTS 0x80 792 793 static const struct bd71828_regulator_data bd72720_rdata[] = { 794 { 795 .desc = { 796 .name = "buck1", 797 .of_match = of_match_ptr("buck1"), 798 .regulators_node = of_match_ptr("regulators"), 799 .id = BD72720_BUCK1, 800 .type = REGULATOR_VOLTAGE, 801 802 /* 803 * The BD72720 BUCK1 and LDO1 support GPIO toggled 804 * sub-RUN states called RUN0, RUN1, RUN2 and RUN3. 805 * The "operating mode" (sub-RUN states or normal) 806 * can be changed by a register. 807 * 808 * When the sub-RUN states are used, the voltage and 809 * enable state depend on a state specific 810 * configuration. The voltage and enable configuration 811 * for BUCK1 and LDO1 can be defined for each sub-RUN 812 * state using BD72720_REG_[BUCK,LDO]1_VSEL_R[0,1,2,3] 813 * voltage selection registers and the bits 814 * BD72720_MASK_RUN_[0,1,2,3]_EN in the enable registers. 815 * The PMIC will change both the BUCK1 and LDO1 voltages 816 * to the states defined in these registers when 817 * "DVS GPIOs" are toggled. 818 * 819 * If RUN 0 .. RUN 4 states are to be used, the normal 820 * voltage configuration mechanisms do not apply 821 * and we should overwrite the ops and ignore the 822 * voltage setting/getting registers which are setup 823 * here. This is not supported for now. If you need 824 * this functionality, you may try merging functionality 825 * from a downstream driver: 826 * https://rohmsemiconductor.github.io/Linux-Kernel-PMIC-Drivers/BD72720/ 827 */ 828 .ops = &bd72720_regulator_ops, 829 .linear_ranges = bd72720_buck1234_volts, 830 .n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts), 831 .n_voltages = BD72720_NUM_BUCK_VOLTS, 832 .enable_reg = BD72720_REG_BUCK1_ON, 833 .enable_mask = BD72720_MASK_RUN_B_EN, 834 .vsel_reg = BD72720_REG_BUCK1_VSEL_RB, 835 .vsel_mask = BD72720_MASK_BUCK_VSEL, 836 837 .ramp_delay_table = bd72720_ramp_delay, 838 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 839 .ramp_reg = BD72720_REG_BUCK1_MODE, 840 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 841 .owner = THIS_MODULE, 842 .of_parse_cb = buck_set_hw_dvs_levels, 843 }, 844 .dvs = { 845 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 846 ROHM_DVS_LEVEL_SUSPEND | 847 ROHM_DVS_LEVEL_LPSR, /* Deep idle in data-sheet */ 848 .run_reg = BD72720_REG_BUCK1_VSEL_RB, 849 .run_mask = BD72720_MASK_BUCK_VSEL, 850 .idle_reg = BD72720_REG_BUCK1_VSEL_I, 851 .idle_mask = BD72720_MASK_BUCK_VSEL, 852 .idle_on_mask = BD72720_MASK_IDLE_EN, 853 .suspend_reg = BD72720_REG_BUCK1_VSEL_S, 854 .suspend_mask = BD72720_MASK_BUCK_VSEL, 855 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 856 .lpsr_reg = BD72720_REG_BUCK1_VSEL_DI, 857 .lpsr_mask = BD72720_MASK_BUCK_VSEL, 858 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 859 }, 860 .reg_inits = bd72720_buck1_inits, 861 .reg_init_amnt = ARRAY_SIZE(bd72720_buck1_inits), 862 }, { 863 .desc = { 864 .name = "buck2", 865 .of_match = of_match_ptr("buck2"), 866 .regulators_node = of_match_ptr("regulators"), 867 .id = BD72720_BUCK2, 868 .type = REGULATOR_VOLTAGE, 869 .ops = &bd72720_regulator_ops, 870 .linear_ranges = bd72720_buck1234_volts, 871 .n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts), 872 .n_voltages = BD72720_NUM_BUCK_VOLTS, 873 .enable_reg = BD72720_REG_BUCK2_ON, 874 .enable_mask = BD72720_MASK_RUN_B_EN, 875 .vsel_reg = BD72720_REG_BUCK2_VSEL_R, 876 .vsel_mask = BD72720_MASK_BUCK_VSEL, 877 878 .ramp_delay_table = bd72720_ramp_delay, 879 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 880 .ramp_reg = BD72720_REG_BUCK2_MODE, 881 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 882 .owner = THIS_MODULE, 883 .of_parse_cb = buck_set_hw_dvs_levels, 884 }, 885 .dvs = { 886 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 887 ROHM_DVS_LEVEL_SUSPEND | 888 ROHM_DVS_LEVEL_LPSR, 889 .run_reg = BD72720_REG_BUCK2_VSEL_R, 890 .run_mask = BD72720_MASK_BUCK_VSEL, 891 .idle_reg = BD72720_REG_BUCK2_VSEL_I, 892 .idle_mask = BD72720_MASK_BUCK_VSEL, 893 .idle_on_mask = BD72720_MASK_IDLE_EN, 894 .suspend_reg = BD72720_REG_BUCK2_VSEL_S, 895 .suspend_mask = BD72720_MASK_BUCK_VSEL, 896 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 897 .lpsr_reg = BD72720_REG_BUCK2_VSEL_DI, 898 .lpsr_mask = BD72720_MASK_BUCK_VSEL, 899 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 900 }, 901 }, { 902 .desc = { 903 .name = "buck3", 904 .of_match = of_match_ptr("buck3"), 905 .regulators_node = of_match_ptr("regulators"), 906 .id = BD72720_BUCK3, 907 .type = REGULATOR_VOLTAGE, 908 .ops = &bd72720_regulator_ops, 909 .linear_ranges = bd72720_buck1234_volts, 910 .n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts), 911 .n_voltages = BD72720_NUM_BUCK_VOLTS, 912 .enable_reg = BD72720_REG_BUCK3_ON, 913 .enable_mask = BD72720_MASK_RUN_B_EN, 914 .vsel_reg = BD72720_REG_BUCK3_VSEL_R, 915 .vsel_mask = BD72720_MASK_BUCK_VSEL, 916 917 .ramp_delay_table = bd72720_ramp_delay, 918 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 919 .ramp_reg = BD72720_REG_BUCK3_MODE, 920 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 921 .owner = THIS_MODULE, 922 .of_parse_cb = buck_set_hw_dvs_levels, 923 }, 924 .dvs = { 925 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 926 ROHM_DVS_LEVEL_SUSPEND | 927 ROHM_DVS_LEVEL_LPSR, 928 .run_reg = BD72720_REG_BUCK3_VSEL_R, 929 .run_mask = BD72720_MASK_BUCK_VSEL, 930 .idle_reg = BD72720_REG_BUCK3_VSEL_I, 931 .idle_mask = BD72720_MASK_BUCK_VSEL, 932 .idle_on_mask = BD72720_MASK_IDLE_EN, 933 .suspend_reg = BD72720_REG_BUCK3_VSEL_S, 934 .suspend_mask = BD72720_MASK_BUCK_VSEL, 935 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 936 .lpsr_reg = BD72720_REG_BUCK3_VSEL_DI, 937 .lpsr_mask = BD72720_MASK_BUCK_VSEL, 938 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 939 }, 940 }, { 941 .desc = { 942 .name = "buck4", 943 .of_match = of_match_ptr("buck4"), 944 .regulators_node = of_match_ptr("regulators"), 945 .id = BD72720_BUCK4, 946 .type = REGULATOR_VOLTAGE, 947 .ops = &bd72720_regulator_ops, 948 .linear_ranges = bd72720_buck1234_volts, 949 .n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts), 950 .n_voltages = BD72720_NUM_BUCK_VOLTS, 951 .enable_reg = BD72720_REG_BUCK4_ON, 952 .enable_mask = BD72720_MASK_RUN_B_EN, 953 .vsel_reg = BD72720_REG_BUCK4_VSEL_R, 954 .vsel_mask = BD72720_MASK_BUCK_VSEL, 955 956 .ramp_delay_table = bd72720_ramp_delay, 957 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 958 .ramp_reg = BD72720_REG_BUCK4_MODE, 959 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 960 .owner = THIS_MODULE, 961 .of_parse_cb = buck_set_hw_dvs_levels, 962 }, 963 .dvs = { 964 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 965 ROHM_DVS_LEVEL_SUSPEND | 966 ROHM_DVS_LEVEL_LPSR, 967 .run_reg = BD72720_REG_BUCK4_VSEL_R, 968 .run_mask = BD72720_MASK_BUCK_VSEL, 969 .idle_reg = BD72720_REG_BUCK4_VSEL_I, 970 .idle_mask = BD72720_MASK_BUCK_VSEL, 971 .idle_on_mask = BD72720_MASK_IDLE_EN, 972 .suspend_reg = BD72720_REG_BUCK4_VSEL_S, 973 .suspend_mask = BD72720_MASK_BUCK_VSEL, 974 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 975 .lpsr_reg = BD72720_REG_BUCK4_VSEL_DI, 976 .lpsr_mask = BD72720_MASK_BUCK_VSEL, 977 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 978 }, 979 }, { 980 .desc = { 981 .name = "buck5", 982 .of_match = of_match_ptr("buck5"), 983 .regulators_node = of_match_ptr("regulators"), 984 .id = BD72720_BUCK5, 985 .type = REGULATOR_VOLTAGE, 986 .ops = &bd72720_regulator_ops, 987 .linear_ranges = bd72720_buck589_volts, 988 .n_linear_ranges = ARRAY_SIZE(bd72720_buck589_volts), 989 .n_voltages = BD72720_NUM_BUCK_VOLTS, 990 .enable_reg = BD72720_REG_BUCK5_ON, 991 .enable_mask = BD72720_MASK_RUN_B_EN, 992 .vsel_reg = BD72720_REG_BUCK5_VSEL, 993 .vsel_mask = BD72720_MASK_BUCK_VSEL, 994 995 .ramp_delay_table = bd72720_ramp_delay, 996 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 997 .ramp_reg = BD72720_REG_BUCK5_MODE, 998 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 999 .owner = THIS_MODULE, 1000 .of_parse_cb = buck_set_hw_dvs_levels, 1001 }, 1002 .dvs = { 1003 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1004 ROHM_DVS_LEVEL_SUSPEND | 1005 ROHM_DVS_LEVEL_LPSR, 1006 .run_reg = BD72720_REG_BUCK5_VSEL, 1007 .run_mask = BD72720_MASK_BUCK_VSEL, 1008 .idle_on_mask = BD72720_MASK_IDLE_EN, 1009 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1010 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1011 }, 1012 }, { 1013 .desc = { 1014 .name = "buck6", 1015 .of_match = of_match_ptr("buck6"), 1016 .regulators_node = of_match_ptr("regulators"), 1017 .id = BD72720_BUCK6, 1018 .type = REGULATOR_VOLTAGE, 1019 .ops = &bd72720_regulator_ops, 1020 .linear_ranges = bd72720_buck67_volts, 1021 .n_linear_ranges = ARRAY_SIZE(bd72720_buck67_volts), 1022 .n_voltages = BD72720_NUM_BUCK_VOLTS, 1023 .enable_reg = BD72720_REG_BUCK6_ON, 1024 .enable_mask = BD72720_MASK_RUN_B_EN, 1025 .vsel_reg = BD72720_REG_BUCK6_VSEL, 1026 .vsel_mask = BD72720_MASK_BUCK_VSEL, 1027 1028 .ramp_delay_table = bd72720_ramp_delay, 1029 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1030 .ramp_reg = BD72720_REG_BUCK6_MODE, 1031 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1032 .owner = THIS_MODULE, 1033 .of_parse_cb = buck_set_hw_dvs_levels, 1034 }, 1035 .dvs = { 1036 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1037 ROHM_DVS_LEVEL_SUSPEND | 1038 ROHM_DVS_LEVEL_LPSR, 1039 .run_reg = BD72720_REG_BUCK6_VSEL, 1040 .run_mask = BD72720_MASK_BUCK_VSEL, 1041 .idle_on_mask = BD72720_MASK_IDLE_EN, 1042 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1043 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1044 }, 1045 }, { 1046 .desc = { 1047 .name = "buck7", 1048 .of_match = of_match_ptr("buck7"), 1049 .regulators_node = of_match_ptr("regulators"), 1050 .id = BD72720_BUCK7, 1051 .type = REGULATOR_VOLTAGE, 1052 .ops = &bd72720_regulator_ops, 1053 .linear_ranges = bd72720_buck67_volts, 1054 .n_linear_ranges = ARRAY_SIZE(bd72720_buck67_volts), 1055 .n_voltages = BD72720_NUM_BUCK_VOLTS, 1056 .enable_reg = BD72720_REG_BUCK7_ON, 1057 .enable_mask = BD72720_MASK_RUN_B_EN, 1058 .vsel_reg = BD72720_REG_BUCK7_VSEL, 1059 .vsel_mask = BD72720_MASK_BUCK_VSEL, 1060 1061 .ramp_delay_table = bd72720_ramp_delay, 1062 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1063 .ramp_reg = BD72720_REG_BUCK7_MODE, 1064 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1065 .owner = THIS_MODULE, 1066 .of_parse_cb = buck_set_hw_dvs_levels, 1067 }, 1068 .dvs = { 1069 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1070 ROHM_DVS_LEVEL_SUSPEND | 1071 ROHM_DVS_LEVEL_LPSR, 1072 .run_reg = BD72720_REG_BUCK7_VSEL, 1073 .run_mask = BD72720_MASK_BUCK_VSEL, 1074 .idle_on_mask = BD72720_MASK_IDLE_EN, 1075 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1076 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1077 }, 1078 }, { 1079 .desc = { 1080 .name = "buck8", 1081 .of_match = of_match_ptr("buck8"), 1082 .regulators_node = of_match_ptr("regulators"), 1083 .id = BD72720_BUCK8, 1084 .type = REGULATOR_VOLTAGE, 1085 .ops = &bd72720_regulator_ops, 1086 .linear_ranges = bd72720_buck589_volts, 1087 .n_linear_ranges = ARRAY_SIZE(bd72720_buck589_volts), 1088 .n_voltages = BD72720_NUM_BUCK_VOLTS, 1089 .enable_reg = BD72720_REG_BUCK8_ON, 1090 .enable_mask = BD72720_MASK_RUN_B_EN, 1091 .vsel_reg = BD72720_REG_BUCK8_VSEL, 1092 .vsel_mask = BD72720_MASK_BUCK_VSEL, 1093 1094 .ramp_delay_table = bd72720_ramp_delay, 1095 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1096 .ramp_reg = BD72720_REG_BUCK8_MODE, 1097 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1098 .owner = THIS_MODULE, 1099 .of_parse_cb = buck_set_hw_dvs_levels, 1100 }, 1101 .dvs = { 1102 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1103 ROHM_DVS_LEVEL_SUSPEND | 1104 ROHM_DVS_LEVEL_LPSR, 1105 .run_reg = BD72720_REG_BUCK8_VSEL, 1106 .run_mask = BD72720_MASK_BUCK_VSEL, 1107 .idle_on_mask = BD72720_MASK_IDLE_EN, 1108 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1109 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1110 }, 1111 }, { 1112 .desc = { 1113 .name = "buck9", 1114 .of_match = of_match_ptr("buck9"), 1115 .regulators_node = of_match_ptr("regulators"), 1116 .id = BD72720_BUCK9, 1117 .type = REGULATOR_VOLTAGE, 1118 .ops = &bd72720_regulator_ops, 1119 .linear_ranges = bd72720_buck589_volts, 1120 .n_linear_ranges = ARRAY_SIZE(bd72720_buck589_volts), 1121 .n_voltages = BD72720_NUM_BUCK_VOLTS, 1122 .enable_reg = BD72720_REG_BUCK9_ON, 1123 .enable_mask = BD72720_MASK_RUN_B_EN, 1124 .vsel_reg = BD72720_REG_BUCK9_VSEL, 1125 .vsel_mask = BD72720_MASK_BUCK_VSEL, 1126 1127 .ramp_delay_table = bd72720_ramp_delay, 1128 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1129 .ramp_reg = BD72720_REG_BUCK9_MODE, 1130 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1131 .owner = THIS_MODULE, 1132 .of_parse_cb = buck_set_hw_dvs_levels, 1133 }, 1134 .dvs = { 1135 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1136 ROHM_DVS_LEVEL_SUSPEND | 1137 ROHM_DVS_LEVEL_LPSR, 1138 .run_reg = BD72720_REG_BUCK9_VSEL, 1139 .run_mask = BD72720_MASK_BUCK_VSEL, 1140 .idle_on_mask = BD72720_MASK_IDLE_EN, 1141 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1142 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1143 }, 1144 }, { 1145 .desc = { 1146 .name = "buck10", 1147 .of_match = of_match_ptr("buck10"), 1148 .regulators_node = of_match_ptr("regulators"), 1149 .id = BD72720_BUCK10, 1150 .type = REGULATOR_VOLTAGE, 1151 .ops = &bd72720_regulator_ops, 1152 .linear_ranges = bd72720_buck10_volts, 1153 .n_linear_ranges = ARRAY_SIZE(bd72720_buck10_volts), 1154 .n_voltages = BD72720_NUM_BUCK_VOLTS, 1155 .enable_reg = BD72720_REG_BUCK10_ON, 1156 .enable_mask = BD72720_MASK_RUN_B_EN, 1157 .vsel_reg = BD72720_REG_BUCK10_VSEL, 1158 .vsel_mask = BD72720_MASK_BUCK_VSEL, 1159 1160 .ramp_delay_table = bd72720_ramp_delay, 1161 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1162 .ramp_reg = BD72720_REG_BUCK10_MODE, 1163 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1164 .owner = THIS_MODULE, 1165 .of_parse_cb = buck_set_hw_dvs_levels, 1166 }, 1167 .dvs = { 1168 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1169 ROHM_DVS_LEVEL_SUSPEND | 1170 ROHM_DVS_LEVEL_LPSR, 1171 .run_reg = BD72720_REG_BUCK10_VSEL, 1172 .run_mask = BD72720_MASK_BUCK_VSEL, 1173 .idle_on_mask = BD72720_MASK_IDLE_EN, 1174 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1175 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1176 }, 1177 }, { 1178 .desc = { 1179 .name = "ldo1", 1180 .of_match = of_match_ptr("ldo1"), 1181 .regulators_node = of_match_ptr("regulators"), 1182 .id = BD72720_LDO1, 1183 .type = REGULATOR_VOLTAGE, 1184 .ops = &bd72720_regulator_ops, 1185 .linear_ranges = bd72720_ldo1234_volts, 1186 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts), 1187 .n_voltages = BD72720_NUM_LDO12346_VOLTS, 1188 .enable_reg = BD72720_REG_LDO1_ON, 1189 .enable_mask = BD72720_MASK_RUN_B_EN, 1190 .vsel_reg = BD72720_REG_LDO1_VSEL_RB, 1191 .vsel_mask = BD72720_MASK_LDO12346_VSEL, 1192 1193 .ramp_delay_table = bd72720_ramp_delay, 1194 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1195 .ramp_reg = BD72720_REG_LDO1_MODE1, 1196 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1197 .owner = THIS_MODULE, 1198 .of_parse_cb = buck_set_hw_dvs_levels, 1199 }, 1200 .dvs = { 1201 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1202 ROHM_DVS_LEVEL_SUSPEND | 1203 ROHM_DVS_LEVEL_LPSR, 1204 .run_reg = BD72720_REG_LDO1_VSEL_RB, 1205 .run_mask = BD72720_MASK_LDO12346_VSEL, 1206 .idle_reg = BD72720_REG_LDO1_VSEL_I, 1207 .idle_mask = BD72720_MASK_LDO12346_VSEL, 1208 .idle_on_mask = BD72720_MASK_IDLE_EN, 1209 .suspend_reg = BD72720_REG_LDO1_VSEL_S, 1210 .suspend_mask = BD72720_MASK_LDO12346_VSEL, 1211 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1212 .lpsr_reg = BD72720_REG_LDO1_VSEL_DI, 1213 .lpsr_mask = BD72720_MASK_LDO12346_VSEL, 1214 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1215 }, 1216 .reg_inits = bd72720_ldo1_inits, 1217 .reg_init_amnt = ARRAY_SIZE(bd72720_ldo1_inits), 1218 }, { 1219 .desc = { 1220 .name = "ldo2", 1221 .of_match = of_match_ptr("ldo2"), 1222 .regulators_node = of_match_ptr("regulators"), 1223 .id = BD72720_LDO2, 1224 .type = REGULATOR_VOLTAGE, 1225 .ops = &bd72720_regulator_ops, 1226 .linear_ranges = bd72720_ldo1234_volts, 1227 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts), 1228 .n_voltages = BD72720_NUM_LDO12346_VOLTS, 1229 .enable_reg = BD72720_REG_LDO2_ON, 1230 .enable_mask = BD72720_MASK_RUN_B_EN, 1231 .vsel_reg = BD72720_REG_LDO2_VSEL_R, 1232 .vsel_mask = BD72720_MASK_LDO12346_VSEL, 1233 1234 .ramp_delay_table = bd72720_ramp_delay, 1235 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1236 .ramp_reg = BD72720_REG_LDO2_MODE, 1237 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1238 .owner = THIS_MODULE, 1239 .of_parse_cb = buck_set_hw_dvs_levels, 1240 }, 1241 .dvs = { 1242 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1243 ROHM_DVS_LEVEL_SUSPEND | 1244 ROHM_DVS_LEVEL_LPSR, 1245 .run_reg = BD72720_REG_LDO2_VSEL_R, 1246 .run_mask = BD72720_MASK_LDO12346_VSEL, 1247 .idle_reg = BD72720_REG_LDO2_VSEL_I, 1248 .idle_mask = BD72720_MASK_LDO12346_VSEL, 1249 .idle_on_mask = BD72720_MASK_IDLE_EN, 1250 .suspend_reg = BD72720_REG_LDO2_VSEL_S, 1251 .suspend_mask = BD72720_MASK_LDO12346_VSEL, 1252 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1253 .lpsr_reg = BD72720_REG_LDO2_VSEL_DI, 1254 .lpsr_mask = BD72720_MASK_LDO12346_VSEL, 1255 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1256 }, 1257 }, { 1258 .desc = { 1259 .name = "ldo3", 1260 .of_match = of_match_ptr("ldo3"), 1261 .regulators_node = of_match_ptr("regulators"), 1262 .id = BD72720_LDO3, 1263 .type = REGULATOR_VOLTAGE, 1264 .ops = &bd72720_regulator_ops, 1265 .linear_ranges = bd72720_ldo1234_volts, 1266 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts), 1267 .n_voltages = BD72720_NUM_LDO12346_VOLTS, 1268 .enable_reg = BD72720_REG_LDO3_ON, 1269 .enable_mask = BD72720_MASK_RUN_B_EN, 1270 .vsel_reg = BD72720_REG_LDO3_VSEL_R, 1271 .vsel_mask = BD72720_MASK_LDO12346_VSEL, 1272 1273 .ramp_delay_table = bd72720_ramp_delay, 1274 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1275 .ramp_reg = BD72720_REG_LDO3_MODE, 1276 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1277 .owner = THIS_MODULE, 1278 .of_parse_cb = buck_set_hw_dvs_levels, 1279 }, 1280 .dvs = { 1281 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1282 ROHM_DVS_LEVEL_SUSPEND | 1283 ROHM_DVS_LEVEL_LPSR, 1284 .run_reg = BD72720_REG_LDO3_VSEL_R, 1285 .run_mask = BD72720_MASK_LDO12346_VSEL, 1286 .idle_reg = BD72720_REG_LDO3_VSEL_I, 1287 .idle_mask = BD72720_MASK_LDO12346_VSEL, 1288 .idle_on_mask = BD72720_MASK_IDLE_EN, 1289 .suspend_reg = BD72720_REG_LDO3_VSEL_S, 1290 .suspend_mask = BD72720_MASK_LDO12346_VSEL, 1291 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1292 .lpsr_reg = BD72720_REG_LDO3_VSEL_DI, 1293 .lpsr_mask = BD72720_MASK_LDO12346_VSEL, 1294 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1295 }, 1296 }, { 1297 .desc = { 1298 .name = "ldo4", 1299 .of_match = of_match_ptr("ldo4"), 1300 .regulators_node = of_match_ptr("regulators"), 1301 .id = BD72720_LDO4, 1302 .type = REGULATOR_VOLTAGE, 1303 .ops = &bd72720_regulator_ops, 1304 .linear_ranges = bd72720_ldo1234_volts, 1305 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts), 1306 .n_voltages = BD72720_NUM_LDO12346_VOLTS, 1307 .enable_reg = BD72720_REG_LDO4_ON, 1308 .enable_mask = BD72720_MASK_RUN_B_EN, 1309 .vsel_reg = BD72720_REG_LDO4_VSEL_R, 1310 .vsel_mask = BD72720_MASK_LDO12346_VSEL, 1311 1312 .ramp_delay_table = bd72720_ramp_delay, 1313 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1314 .ramp_reg = BD72720_REG_LDO4_MODE, 1315 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1316 .owner = THIS_MODULE, 1317 .of_parse_cb = buck_set_hw_dvs_levels, 1318 }, 1319 .dvs = { 1320 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1321 ROHM_DVS_LEVEL_SUSPEND | 1322 ROHM_DVS_LEVEL_LPSR, 1323 .run_reg = BD72720_REG_LDO4_VSEL_R, 1324 .run_mask = BD72720_MASK_LDO12346_VSEL, 1325 .idle_reg = BD72720_REG_LDO4_VSEL_I, 1326 .idle_mask = BD72720_MASK_LDO12346_VSEL, 1327 .idle_on_mask = BD72720_MASK_IDLE_EN, 1328 .suspend_reg = BD72720_REG_LDO4_VSEL_S, 1329 .suspend_mask = BD72720_MASK_LDO12346_VSEL, 1330 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1331 .lpsr_reg = BD72720_REG_LDO4_VSEL_DI, 1332 .lpsr_mask = BD72720_MASK_LDO12346_VSEL, 1333 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1334 }, 1335 }, { 1336 .desc = { 1337 .name = "ldo5", 1338 .of_match = of_match_ptr("ldo5"), 1339 .regulators_node = of_match_ptr("regulators"), 1340 .id = BD72720_LDO5, 1341 .type = REGULATOR_VOLTAGE, 1342 .ops = &bd72720_regulator_ops, 1343 .linear_ranges = bd72720_ldo57891011_volts, 1344 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts), 1345 .n_voltages = BD72720_NUM_LDO_VOLTS, 1346 .enable_reg = BD72720_REG_LDO5_ON, 1347 .enable_mask = BD72720_MASK_RUN_B_EN, 1348 .vsel_reg = BD72720_REG_LDO5_VSEL, 1349 .vsel_mask = BD72720_MASK_LDO_VSEL, 1350 1351 .ramp_delay_table = bd72720_ramp_delay, 1352 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1353 .ramp_reg = BD72720_REG_LDO5_MODE, 1354 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1355 .owner = THIS_MODULE, 1356 .of_parse_cb = buck_set_hw_dvs_levels, 1357 }, 1358 .dvs = { 1359 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1360 ROHM_DVS_LEVEL_SUSPEND | 1361 ROHM_DVS_LEVEL_LPSR, 1362 .run_reg = BD72720_REG_LDO5_VSEL, 1363 .run_mask = BD72720_MASK_LDO_VSEL, 1364 .idle_on_mask = BD72720_MASK_IDLE_EN, 1365 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1366 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1367 }, 1368 }, { 1369 .desc = { 1370 .name = "ldo6", 1371 .of_match = of_match_ptr("ldo6"), 1372 .regulators_node = of_match_ptr("regulators"), 1373 .id = BD72720_LDO6, 1374 .type = REGULATOR_VOLTAGE, 1375 .ops = &bd72720_regulator_ops, 1376 .linear_ranges = bd72720_ldo6_volts, 1377 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo6_volts), 1378 .n_voltages = BD72720_NUM_LDO12346_VOLTS, 1379 .enable_reg = BD72720_REG_LDO6_ON, 1380 .enable_mask = BD72720_MASK_RUN_B_EN, 1381 .vsel_reg = BD72720_REG_LDO6_VSEL, 1382 .vsel_mask = BD72720_MASK_LDO12346_VSEL, 1383 1384 .ramp_delay_table = bd72720_ramp_delay, 1385 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1386 .ramp_reg = BD72720_REG_LDO6_MODE, 1387 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1388 .owner = THIS_MODULE, 1389 .of_parse_cb = buck_set_hw_dvs_levels, 1390 }, 1391 .dvs = { 1392 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1393 ROHM_DVS_LEVEL_SUSPEND | 1394 ROHM_DVS_LEVEL_LPSR, 1395 .run_reg = BD72720_REG_LDO6_VSEL, 1396 .run_mask = BD72720_MASK_LDO12346_VSEL, 1397 .idle_on_mask = BD72720_MASK_IDLE_EN, 1398 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1399 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1400 }, 1401 }, { 1402 .desc = { 1403 .name = "ldo7", 1404 .of_match = of_match_ptr("ldo7"), 1405 .regulators_node = of_match_ptr("regulators"), 1406 .id = BD72720_LDO7, 1407 .type = REGULATOR_VOLTAGE, 1408 .ops = &bd72720_regulator_ops, 1409 .linear_ranges = bd72720_ldo57891011_volts, 1410 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts), 1411 .n_voltages = BD72720_NUM_LDO_VOLTS, 1412 .enable_reg = BD72720_REG_LDO7_ON, 1413 .enable_mask = BD72720_MASK_RUN_B_EN, 1414 .vsel_reg = BD72720_REG_LDO7_VSEL, 1415 .vsel_mask = BD72720_MASK_LDO_VSEL, 1416 1417 .ramp_delay_table = bd72720_ramp_delay, 1418 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1419 .ramp_reg = BD72720_REG_LDO7_MODE, 1420 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1421 .owner = THIS_MODULE, 1422 .of_parse_cb = buck_set_hw_dvs_levels, 1423 }, 1424 .dvs = { 1425 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1426 ROHM_DVS_LEVEL_SUSPEND | 1427 ROHM_DVS_LEVEL_LPSR, 1428 .run_reg = BD72720_REG_LDO7_VSEL, 1429 .run_mask = BD72720_MASK_LDO_VSEL, 1430 .idle_on_mask = BD72720_MASK_IDLE_EN, 1431 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1432 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1433 }, 1434 }, { 1435 .desc = { 1436 .name = "ldo8", 1437 .of_match = of_match_ptr("ldo8"), 1438 .regulators_node = of_match_ptr("regulators"), 1439 .id = BD72720_LDO8, 1440 .type = REGULATOR_VOLTAGE, 1441 .ops = &bd72720_regulator_ops, 1442 .linear_ranges = bd72720_ldo57891011_volts, 1443 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts), 1444 .n_voltages = BD72720_NUM_LDO_VOLTS, 1445 .enable_reg = BD72720_REG_LDO8_ON, 1446 .enable_mask = BD72720_MASK_RUN_B_EN, 1447 .vsel_reg = BD72720_REG_LDO8_VSEL, 1448 .vsel_mask = BD72720_MASK_LDO_VSEL, 1449 1450 .ramp_delay_table = bd72720_ramp_delay, 1451 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1452 .ramp_reg = BD72720_REG_LDO8_MODE, 1453 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1454 .owner = THIS_MODULE, 1455 .of_parse_cb = buck_set_hw_dvs_levels, 1456 }, 1457 .dvs = { 1458 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1459 ROHM_DVS_LEVEL_SUSPEND | 1460 ROHM_DVS_LEVEL_LPSR, 1461 .run_reg = BD72720_REG_LDO8_VSEL, 1462 .run_mask = BD72720_MASK_LDO_VSEL, 1463 .idle_on_mask = BD72720_MASK_IDLE_EN, 1464 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1465 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1466 }, 1467 }, { 1468 .desc = { 1469 .name = "ldo9", 1470 .of_match = of_match_ptr("ldo9"), 1471 .regulators_node = of_match_ptr("regulators"), 1472 .id = BD72720_LDO9, 1473 .type = REGULATOR_VOLTAGE, 1474 .ops = &bd72720_regulator_ops, 1475 .linear_ranges = bd72720_ldo57891011_volts, 1476 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts), 1477 .n_voltages = BD72720_NUM_LDO_VOLTS, 1478 .enable_reg = BD72720_REG_LDO9_ON, 1479 .enable_mask = BD72720_MASK_RUN_B_EN, 1480 .vsel_reg = BD72720_REG_LDO9_VSEL, 1481 .vsel_mask = BD72720_MASK_LDO_VSEL, 1482 1483 .ramp_delay_table = bd72720_ramp_delay, 1484 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1485 .ramp_reg = BD72720_REG_LDO9_MODE, 1486 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1487 .owner = THIS_MODULE, 1488 .of_parse_cb = buck_set_hw_dvs_levels, 1489 }, 1490 .dvs = { 1491 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1492 ROHM_DVS_LEVEL_SUSPEND | 1493 ROHM_DVS_LEVEL_LPSR, 1494 .run_reg = BD72720_REG_LDO9_VSEL, 1495 .run_mask = BD72720_MASK_LDO_VSEL, 1496 .idle_on_mask = BD72720_MASK_IDLE_EN, 1497 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1498 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1499 }, 1500 }, { 1501 .desc = { 1502 .name = "ldo10", 1503 .of_match = of_match_ptr("ldo10"), 1504 .regulators_node = of_match_ptr("regulators"), 1505 .id = BD72720_LDO10, 1506 .type = REGULATOR_VOLTAGE, 1507 .ops = &bd72720_regulator_ops, 1508 .linear_ranges = bd72720_ldo57891011_volts, 1509 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts), 1510 .n_voltages = BD72720_NUM_LDO_VOLTS, 1511 .enable_reg = BD72720_REG_LDO10_ON, 1512 .enable_mask = BD72720_MASK_RUN_B_EN, 1513 .vsel_reg = BD72720_REG_LDO10_VSEL, 1514 .vsel_mask = BD72720_MASK_LDO_VSEL, 1515 1516 .ramp_delay_table = bd72720_ramp_delay, 1517 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1518 .ramp_reg = BD72720_REG_LDO10_MODE, 1519 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1520 .owner = THIS_MODULE, 1521 .of_parse_cb = buck_set_hw_dvs_levels, 1522 }, 1523 .dvs = { 1524 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1525 ROHM_DVS_LEVEL_SUSPEND | 1526 ROHM_DVS_LEVEL_LPSR, 1527 .run_reg = BD72720_REG_LDO10_VSEL, 1528 .run_mask = BD72720_MASK_LDO_VSEL, 1529 .idle_on_mask = BD72720_MASK_IDLE_EN, 1530 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1531 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1532 }, 1533 }, { 1534 .desc = { 1535 .name = "ldo11", 1536 .of_match = of_match_ptr("ldo11"), 1537 .regulators_node = of_match_ptr("regulators"), 1538 .id = BD72720_LDO11, 1539 .type = REGULATOR_VOLTAGE, 1540 .ops = &bd72720_regulator_ops, 1541 .linear_ranges = bd72720_ldo57891011_volts, 1542 .n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts), 1543 .n_voltages = BD72720_NUM_LDO_VOLTS, 1544 .enable_reg = BD72720_REG_LDO11_ON, 1545 .enable_mask = BD72720_MASK_RUN_B_EN, 1546 .vsel_reg = BD72720_REG_LDO11_VSEL, 1547 .vsel_mask = BD72720_MASK_LDO_VSEL, 1548 1549 .ramp_delay_table = bd72720_ramp_delay, 1550 .n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay), 1551 .ramp_reg = BD72720_REG_LDO11_MODE, 1552 .ramp_mask = BD72720_MASK_RAMP_UP_DELAY, 1553 .owner = THIS_MODULE, 1554 .of_parse_cb = buck_set_hw_dvs_levels, 1555 }, 1556 .dvs = { 1557 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE | 1558 ROHM_DVS_LEVEL_SUSPEND | 1559 ROHM_DVS_LEVEL_LPSR, 1560 .run_reg = BD72720_REG_LDO11_VSEL, 1561 .run_mask = BD72720_MASK_LDO_VSEL, 1562 .idle_on_mask = BD72720_MASK_IDLE_EN, 1563 .suspend_on_mask = BD72720_MASK_SUSPEND_EN, 1564 .lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN, 1565 }, 1566 }, 1567 }; 1568 1569 static int bd72720_buck10_ldon_head_mode(struct device *dev, 1570 struct device_node *npreg, 1571 struct regmap *regmap, 1572 struct regulator_desc *buck10_desc) 1573 { 1574 struct device_node *np __free(device_node) = 1575 of_get_child_by_name(npreg, "buck10"); 1576 uint32_t ldon_head; 1577 int ldon_val; 1578 int ret; 1579 1580 if (!np) { 1581 dev_err(dev, "failed to find buck10 regulator node\n"); 1582 return -ENODEV; 1583 } 1584 1585 ret = of_property_read_u32(np, "rohm,ldon-head-microvolt", &ldon_head); 1586 if (ret == -EINVAL) 1587 return 0; 1588 if (ret) 1589 return ret; 1590 1591 /* 1592 * LDON_HEAD mode means the BUCK10 is used to supply LDOs 1-4 and 1593 * the BUCK 10 voltage is automatically set to follow LDO 1-4 1594 * settings. Thus the BUCK10 should not allow voltage [g/s]etting. 1595 */ 1596 buck10_desc->ops = &bd72720_buck10_ldon_head_op; 1597 1598 ldon_val = ldon_head / 50000 + 1; 1599 if (ldon_head > 300000) { 1600 dev_warn(dev, "Unsupported LDON_HEAD, clamping to 300 mV\n"); 1601 ldon_val = 7; 1602 } 1603 1604 return regmap_update_bits(regmap, BD72720_REG_LDO1_MODE2, 1605 BD72720_MASK_LDON_HEAD, ldon_val); 1606 } 1607 1608 static int bd72720_dt_parse(struct device *dev, 1609 struct regulator_desc *buck10_desc, 1610 struct regmap *regmap) 1611 { 1612 struct device_node *nproot __free(device_node) = 1613 of_get_child_by_name(dev->parent->of_node, "regulators"); 1614 1615 if (!nproot) { 1616 dev_err(dev, "failed to find regulators node\n"); 1617 return -ENODEV; 1618 } 1619 1620 return bd72720_buck10_ldon_head_mode(dev, nproot, regmap, buck10_desc); 1621 } 1622 1623 static int bd71828_probe(struct platform_device *pdev) 1624 { 1625 int i, j, ret, num_regulators; 1626 struct regulator_config config = { 1627 .dev = pdev->dev.parent, 1628 }; 1629 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; 1630 struct bd71828_regulator_data *rdata; 1631 1632 config.regmap = dev_get_regmap(pdev->dev.parent, NULL); 1633 if (!config.regmap) 1634 return -ENODEV; 1635 1636 switch (chip) { 1637 case ROHM_CHIP_TYPE_BD72720: 1638 rdata = devm_kmemdup(&pdev->dev, bd72720_rdata, 1639 sizeof(bd72720_rdata), GFP_KERNEL); 1640 if (!rdata) 1641 return -ENOMEM; 1642 1643 ret = bd72720_dt_parse(&pdev->dev, &rdata[BD72720_BUCK10_DESC_INDEX].desc, 1644 config.regmap); 1645 if (ret) 1646 return ret; 1647 1648 num_regulators = ARRAY_SIZE(bd72720_rdata); 1649 break; 1650 1651 case ROHM_CHIP_TYPE_BD71828: 1652 rdata = devm_kmemdup(&pdev->dev, bd71828_rdata, 1653 sizeof(bd71828_rdata), GFP_KERNEL); 1654 if (!rdata) 1655 return -ENOMEM; 1656 1657 num_regulators = ARRAY_SIZE(bd71828_rdata); 1658 1659 break; 1660 default: 1661 return dev_err_probe(&pdev->dev, -EINVAL, 1662 "Unsupported device\n"); 1663 } 1664 1665 for (i = 0; i < num_regulators; i++) { 1666 struct regulator_dev *rdev; 1667 struct bd71828_regulator_data *rd; 1668 1669 rd = &rdata[i]; 1670 1671 config.driver_data = rd; 1672 rdev = devm_regulator_register(&pdev->dev, 1673 &rd->desc, &config); 1674 if (IS_ERR(rdev)) 1675 return dev_err_probe(&pdev->dev, PTR_ERR(rdev), 1676 "failed to register %s regulator\n", 1677 rd->desc.name); 1678 1679 for (j = 0; j < rd->reg_init_amnt; j++) { 1680 ret = regmap_update_bits(config.regmap, 1681 rd->reg_inits[j].reg, 1682 rd->reg_inits[j].mask, 1683 rd->reg_inits[j].val); 1684 if (ret) 1685 return dev_err_probe(&pdev->dev, ret, 1686 "regulator %s init failed\n", 1687 rd->desc.name); 1688 } 1689 } 1690 return 0; 1691 } 1692 1693 static const struct platform_device_id bd71828_pmic_id[] = { 1694 { "bd71828-pmic", ROHM_CHIP_TYPE_BD71828 }, 1695 { "bd72720-pmic", ROHM_CHIP_TYPE_BD72720 }, 1696 { }, 1697 }; 1698 MODULE_DEVICE_TABLE(platform, bd71828_pmic_id); 1699 1700 static struct platform_driver bd71828_regulator = { 1701 .driver = { 1702 .name = "bd71828-pmic", 1703 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1704 }, 1705 .probe = bd71828_probe, 1706 .id_table = bd71828_pmic_id, 1707 }; 1708 1709 module_platform_driver(bd71828_regulator); 1710 1711 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); 1712 MODULE_DESCRIPTION("BD71828 voltage regulator driver"); 1713 MODULE_LICENSE("GPL"); 1714