Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branch 'regulator/topic/s5m8767' into regulator-next

+437 -67
+152
Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt
··· 1 + * Samsung S5M8767 Voltage and Current Regulator 2 + 3 + The Samsung S5M8767 is a multi-function device which includes volatage and 4 + current regulators, rtc, charger controller and other sub-blocks. It is 5 + interfaced to the host controller using a i2c interface. Each sub-block is 6 + addressed by the host system using different i2c slave address. This document 7 + describes the bindings for 'pmic' sub-block of s5m8767. 8 + 9 + Required properties: 10 + - compatible: Should be "samsung,s5m8767-pmic". 11 + - reg: Specifies the i2c slave address of the pmic block. It should be 0x66. 12 + 13 + - s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) 14 + units for buck2 when changing voltage using gpio dvs. Refer to [1] below 15 + for additional information. 16 + 17 + - s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt (uV) 18 + units for buck3 when changing voltage using gpio dvs. Refer to [1] below 19 + for additional information. 20 + 21 + - s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt (uV) 22 + units for buck4 when changing voltage using gpio dvs. Refer to [1] below 23 + for additional information. 24 + 25 + - s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used 26 + for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. 27 + 28 + [1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional 29 + property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage' 30 + property should specify atleast one voltage level (which would be a 31 + safe operating voltage). 32 + 33 + If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional 34 + property is specified, then all the eight voltage values for the 35 + 's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. 36 + 37 + Optional properties: 38 + - interrupt-parent: Specifies the phandle of the interrupt controller to which 39 + the interrupts from s5m8767 are delivered to. 40 + - interrupts: Interrupt specifiers for two interrupt sources. 41 + - First interrupt specifier is for 'irq1' interrupt. 42 + - Second interrupt specifier is for 'alert' interrupt. 43 + - s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. 44 + - s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. 45 + - s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. 46 + 47 + Additional properties required if either of the optional properties are used: 48 + 49 + - s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from 50 + the possible 8 options selectable by the dvs gpios. The value of this 51 + property should be between 0 and 7. If not specified or if out of range, the 52 + default value of this property is set to 0. 53 + 54 + - s5m8767,pmic-buck-dvs-gpios: GPIO specifiers for three host gpio's used 55 + for dvs. The format of the gpio specifier depends in the gpio controller. 56 + 57 + Regulators: The regulators of s5m8767 that have to be instantiated should be 58 + included in a sub-node named 'regulators'. Regulator nodes included in this 59 + sub-node should be of the format as listed below. 60 + 61 + regulator_name { 62 + ldo1_reg: LDO1 { 63 + regulator-name = "VDD_ALIVE_1.0V"; 64 + regulator-min-microvolt = <1100000>; 65 + regulator-max-microvolt = <1100000>; 66 + regulator-always-on; 67 + regulator-boot-on; 68 + op_mode = <1>; /* Normal Mode */ 69 + }; 70 + }; 71 + The above regulator entries are defined in regulator bindings documentation 72 + except op_mode description. 73 + - op_mode: describes the different operating modes of the LDO's with 74 + power mode change in SOC. The different possible values are, 75 + 0 - always off mode 76 + 1 - on in normal mode 77 + 2 - low power mode 78 + 3 - suspend mode 79 + 80 + The following are the names of the regulators that the s5m8767 pmic block 81 + supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number 82 + as per the datasheet of s5m8767. 83 + 84 + - LDOn 85 + - valid values for n are 1 to 28 86 + - Example: LDO0, LD01, LDO28 87 + - BUCKn 88 + - valid values for n are 1 to 9. 89 + - Example: BUCK1, BUCK2, BUCK9 90 + 91 + The bindings inside the regulator nodes use the standard regulator bindings 92 + which are documented elsewhere. 93 + 94 + Example: 95 + 96 + s5m8767_pmic@66 { 97 + compatible = "samsung,s5m8767-pmic"; 98 + reg = <0x66>; 99 + 100 + s5m8767,pmic-buck2-uses-gpio-dvs; 101 + s5m8767,pmic-buck3-uses-gpio-dvs; 102 + s5m8767,pmic-buck4-uses-gpio-dvs; 103 + 104 + s5m8767,pmic-buck-default-dvs-idx = <0>; 105 + 106 + s5m8767,pmic-buck-dvs-gpios = <&gpx0 0 1 0 0>, /* DVS1 */ 107 + <&gpx0 1 1 0 0>, /* DVS2 */ 108 + <&gpx0 2 1 0 0>; /* DVS3 */ 109 + 110 + s5m8767,pmic-buck-ds-gpios = <&gpx2 3 1 0 0>, /* SET1 */ 111 + <&gpx2 4 1 0 0>, /* SET2 */ 112 + <&gpx2 5 1 0 0>; /* SET3 */ 113 + 114 + s5m8767,pmic-buck2-dvs-voltage = <1350000>, <1300000>, 115 + <1250000>, <1200000>, 116 + <1150000>, <1100000>, 117 + <1000000>, <950000>; 118 + 119 + s5m8767,pmic-buck3-dvs-voltage = <1100000>, <1100000>, 120 + <1100000>, <1100000>, 121 + <1000000>, <1000000>, 122 + <1000000>, <1000000>; 123 + 124 + s5m8767,pmic-buck4-dvs-voltage = <1200000>, <1200000>, 125 + <1200000>, <1200000>, 126 + <1200000>, <1200000>, 127 + <1200000>, <1200000>; 128 + 129 + regulators { 130 + ldo1_reg: LDO1 { 131 + regulator-name = "VDD_ABB_3.3V"; 132 + regulator-min-microvolt = <3300000>; 133 + regulator-max-microvolt = <3300000>; 134 + op_mode = <1>; /* Normal Mode */ 135 + }; 136 + 137 + ldo2_reg: LDO2 { 138 + regulator-name = "VDD_ALIVE_1.1V"; 139 + regulator-min-microvolt = <1100000>; 140 + regulator-max-microvolt = <1100000>; 141 + regulator-always-on; 142 + }; 143 + 144 + buck1_reg: BUCK1 { 145 + regulator-name = "VDD_MIF_1.2V"; 146 + regulator-min-microvolt = <950000>; 147 + regulator-max-microvolt = <1350000>; 148 + regulator-always-on; 149 + regulator-boot-on; 150 + }; 151 + }; 152 + };
+72 -1
drivers/mfd/sec-core.c
··· 17 17 #include <linux/err.h> 18 18 #include <linux/slab.h> 19 19 #include <linux/i2c.h> 20 + #include <linux/of_irq.h> 20 21 #include <linux/interrupt.h> 21 22 #include <linux/pm_runtime.h> 22 23 #include <linux/mutex.h> ··· 61 60 }, 62 61 }; 63 62 63 + #ifdef CONFIG_OF 64 + static struct of_device_id sec_dt_match[] = { 65 + { .compatible = "samsung,s5m8767-pmic", 66 + .data = (void *)S5M8767X, 67 + }, 68 + {}, 69 + }; 70 + #endif 71 + 64 72 int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest) 65 73 { 66 74 return regmap_read(sec_pmic->regmap, reg, dest); ··· 105 95 .val_bits = 8, 106 96 }; 107 97 98 + 99 + #ifdef CONFIG_OF 100 + /* 101 + * Only the common platform data elements for s5m8767 are parsed here from the 102 + * device tree. Other sub-modules of s5m8767 such as pmic, rtc , charger and 103 + * others have to parse their own platform data elements from device tree. 104 + * 105 + * The s5m8767 platform data structure is instantiated here and the drivers for 106 + * the sub-modules need not instantiate another instance while parsing their 107 + * platform data. 108 + */ 109 + static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( 110 + struct device *dev) 111 + { 112 + struct sec_platform_data *pd; 113 + 114 + pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); 115 + if (!pd) { 116 + dev_err(dev, "could not allocate memory for pdata\n"); 117 + return ERR_PTR(-ENOMEM); 118 + } 119 + 120 + /* 121 + * ToDo: the 'wakeup' member in the platform data is more of a linux 122 + * specfic information. Hence, there is no binding for that yet and 123 + * not parsed here. 124 + */ 125 + 126 + return pd; 127 + } 128 + #else 129 + static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( 130 + struct device *dev) 131 + { 132 + return 0; 133 + } 134 + #endif 135 + 136 + static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, 137 + const struct i2c_device_id *id) 138 + { 139 + #ifdef CONFIG_OF 140 + if (i2c->dev.of_node) { 141 + const struct of_device_id *match; 142 + match = of_match_node(sec_dt_match, i2c->dev.of_node); 143 + return (int)match->data; 144 + } 145 + #endif 146 + return (int)id->driver_data; 147 + } 148 + 108 149 static int sec_pmic_probe(struct i2c_client *i2c, 109 150 const struct i2c_device_id *id) 110 151 { ··· 172 111 sec_pmic->dev = &i2c->dev; 173 112 sec_pmic->i2c = i2c; 174 113 sec_pmic->irq = i2c->irq; 175 - sec_pmic->type = id->driver_data; 114 + sec_pmic->type = sec_i2c_get_driver_data(i2c, id); 176 115 116 + if (sec_pmic->dev->of_node) { 117 + pdata = sec_pmic_i2c_parse_dt_pdata(sec_pmic->dev); 118 + if (IS_ERR(pdata)) { 119 + ret = PTR_ERR(pdata); 120 + return ret; 121 + } 122 + pdata->device_type = sec_pmic->type; 123 + } 177 124 if (pdata) { 178 125 sec_pmic->device_type = pdata->device_type; 179 126 sec_pmic->ono = pdata->ono; 180 127 sec_pmic->irq_base = pdata->irq_base; 181 128 sec_pmic->wakeup = pdata->wakeup; 129 + sec_pmic->pdata = pdata; 182 130 } 183 131 184 132 sec_pmic->regmap = devm_regmap_init_i2c(i2c, &sec_regmap_config); ··· 262 192 .driver = { 263 193 .name = "sec_pmic", 264 194 .owner = THIS_MODULE, 195 + .of_match_table = of_match_ptr(sec_dt_match), 265 196 }, 266 197 .probe = sec_pmic_probe, 267 198 .remove = sec_pmic_remove,
+206 -62
drivers/regulator/s5m8767.c
··· 14 14 #include <linux/bug.h> 15 15 #include <linux/err.h> 16 16 #include <linux/gpio.h> 17 + #include <linux/of_gpio.h> 17 18 #include <linux/slab.h> 18 19 #include <linux/module.h> 19 20 #include <linux/platform_device.h> ··· 22 21 #include <linux/regulator/machine.h> 23 22 #include <linux/mfd/samsung/core.h> 24 23 #include <linux/mfd/samsung/s5m8767.h> 24 + #include <linux/regulator/of_regulator.h> 25 + 26 + #define S5M8767_OPMODE_NORMAL_MODE 0x1 25 27 26 28 struct s5m8767_info { 27 29 struct device *dev; ··· 259 255 return sec_reg_update(s5m8767->iodev, reg, ~mask, mask); 260 256 } 261 257 262 - static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) 258 + static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) 263 259 { 264 - struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 265 - int reg_id = rdev_get_id(rdev); 266 260 int reg; 267 261 268 262 switch (reg_id) { ··· 298 296 return -EINVAL; 299 297 } 300 298 301 - *_reg = reg; 302 - 303 - return 0; 299 + return reg; 304 300 } 305 301 306 - static int s5m8767_get_voltage_sel(struct regulator_dev *rdev) 307 - { 308 - struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 309 - int reg, mask, ret; 310 - int reg_id = rdev_get_id(rdev); 311 - unsigned int val; 312 - 313 - ret = s5m8767_get_voltage_register(rdev, &reg); 314 - if (ret) 315 - return ret; 316 - 317 - mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff; 318 - 319 - ret = sec_reg_read(s5m8767->iodev, reg, &val); 320 - if (ret) 321 - return ret; 322 - 323 - val &= mask; 324 - 325 - return val; 326 - } 327 - 328 - static int s5m8767_convert_voltage_to_sel( 329 - const struct sec_voltage_desc *desc, 330 - int min_vol, int max_vol) 302 + static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc, 303 + int min_vol) 331 304 { 332 305 int selector = 0; 333 306 334 307 if (desc == NULL) 335 308 return -EINVAL; 336 309 337 - if (max_vol < desc->min || min_vol > desc->max) 310 + if (min_vol > desc->max) 338 311 return -EINVAL; 339 312 340 313 if (min_vol < desc->min) ··· 317 340 318 341 selector = DIV_ROUND_UP(min_vol - desc->min, desc->step); 319 342 320 - if (desc->min + desc->step * selector > max_vol) 343 + if (desc->min + desc->step * selector > desc->max) 321 344 return -EINVAL; 322 345 323 346 return selector; ··· 350 373 { 351 374 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 352 375 int reg_id = rdev_get_id(rdev); 353 - int reg, mask, ret = 0, old_index, index = 0; 376 + int old_index, index = 0; 354 377 u8 *buck234_vol = NULL; 355 378 356 379 switch (reg_id) { 357 380 case S5M8767_LDO1 ... S5M8767_LDO28: 358 - mask = 0x3f; 359 381 break; 360 382 case S5M8767_BUCK1 ... S5M8767_BUCK6: 361 - mask = 0xff; 362 383 if (reg_id == S5M8767_BUCK2 && s5m8767->buck2_gpiodvs) 363 384 buck234_vol = &s5m8767->buck2_vol[0]; 364 385 else if (reg_id == S5M8767_BUCK3 && s5m8767->buck3_gpiodvs) ··· 367 392 case S5M8767_BUCK7 ... S5M8767_BUCK8: 368 393 return -EINVAL; 369 394 case S5M8767_BUCK9: 370 - mask = 0xff; 371 395 break; 372 396 default: 373 397 return -EINVAL; ··· 386 412 else 387 413 return s5m8767_set_low(s5m8767); 388 414 } else { 389 - ret = s5m8767_get_voltage_register(rdev, &reg); 390 - if (ret) 391 - return ret; 392 - 393 - return sec_reg_update(s5m8767->iodev, reg, selector, mask); 415 + return regulator_set_voltage_sel_regmap(rdev, selector); 394 416 } 395 417 } 396 418 ··· 411 441 .is_enabled = s5m8767_reg_is_enabled, 412 442 .enable = s5m8767_reg_enable, 413 443 .disable = s5m8767_reg_disable, 414 - .get_voltage_sel = s5m8767_get_voltage_sel, 444 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 415 445 .set_voltage_sel = s5m8767_set_voltage_sel, 416 446 .set_voltage_time_sel = s5m8767_set_voltage_time_sel, 417 447 }; ··· 478 508 s5m8767_regulator_desc(BUCK9), 479 509 }; 480 510 511 + #ifdef CONFIG_OF 512 + static int s5m8767_pmic_dt_parse_dvs_gpio(struct sec_pmic_dev *iodev, 513 + struct sec_platform_data *pdata, 514 + struct device_node *pmic_np) 515 + { 516 + int i, gpio; 517 + 518 + for (i = 0; i < 3; i++) { 519 + gpio = of_get_named_gpio(pmic_np, 520 + "s5m8767,pmic-buck-dvs-gpios", i); 521 + if (!gpio_is_valid(gpio)) { 522 + dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio); 523 + return -EINVAL; 524 + } 525 + pdata->buck_gpios[i] = gpio; 526 + } 527 + return 0; 528 + } 529 + 530 + static int s5m8767_pmic_dt_parse_ds_gpio(struct sec_pmic_dev *iodev, 531 + struct sec_platform_data *pdata, 532 + struct device_node *pmic_np) 533 + { 534 + int i, gpio; 535 + 536 + for (i = 0; i < 3; i++) { 537 + gpio = of_get_named_gpio(pmic_np, 538 + "s5m8767,pmic-buck-ds-gpios", i); 539 + if (!gpio_is_valid(gpio)) { 540 + dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio); 541 + return -EINVAL; 542 + } 543 + pdata->buck_ds[i] = gpio; 544 + } 545 + return 0; 546 + } 547 + 548 + static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, 549 + struct sec_platform_data *pdata) 550 + { 551 + struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 552 + struct device_node *pmic_np, *regulators_np, *reg_np; 553 + struct sec_regulator_data *rdata; 554 + struct sec_opmode_data *rmode; 555 + unsigned int i, dvs_voltage_nr = 1, ret; 556 + 557 + pmic_np = iodev->dev->of_node; 558 + if (!pmic_np) { 559 + dev_err(iodev->dev, "could not find pmic sub-node\n"); 560 + return -ENODEV; 561 + } 562 + 563 + regulators_np = of_find_node_by_name(pmic_np, "regulators"); 564 + if (!regulators_np) { 565 + dev_err(iodev->dev, "could not find regulators sub-node\n"); 566 + return -EINVAL; 567 + } 568 + 569 + /* count the number of regulators to be supported in pmic */ 570 + pdata->num_regulators = of_get_child_count(regulators_np); 571 + 572 + rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * 573 + pdata->num_regulators, GFP_KERNEL); 574 + if (!rdata) { 575 + dev_err(iodev->dev, 576 + "could not allocate memory for regulator data\n"); 577 + return -ENOMEM; 578 + } 579 + 580 + rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) * 581 + pdata->num_regulators, GFP_KERNEL); 582 + if (!rdata) { 583 + dev_err(iodev->dev, 584 + "could not allocate memory for regulator mode\n"); 585 + return -ENOMEM; 586 + } 587 + 588 + pdata->regulators = rdata; 589 + pdata->opmode = rmode; 590 + for_each_child_of_node(regulators_np, reg_np) { 591 + for (i = 0; i < ARRAY_SIZE(regulators); i++) 592 + if (!of_node_cmp(reg_np->name, regulators[i].name)) 593 + break; 594 + 595 + if (i == ARRAY_SIZE(regulators)) { 596 + dev_warn(iodev->dev, 597 + "don't know how to configure regulator %s\n", 598 + reg_np->name); 599 + continue; 600 + } 601 + 602 + rdata->id = i; 603 + rdata->initdata = of_get_regulator_init_data( 604 + &pdev->dev, reg_np); 605 + rdata->reg_node = reg_np; 606 + rdata++; 607 + rmode->id = i; 608 + if (of_property_read_u32(reg_np, "op_mode", 609 + &rmode->mode)) { 610 + dev_warn(iodev->dev, 611 + "no op_mode property property at %s\n", 612 + reg_np->full_name); 613 + 614 + rmode->mode = S5M8767_OPMODE_NORMAL_MODE; 615 + } 616 + rmode++; 617 + } 618 + 619 + if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) 620 + pdata->buck2_gpiodvs = true; 621 + 622 + if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) 623 + pdata->buck3_gpiodvs = true; 624 + 625 + if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) 626 + pdata->buck4_gpiodvs = true; 627 + 628 + if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || 629 + pdata->buck4_gpiodvs) { 630 + ret = s5m8767_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); 631 + if (ret) 632 + return -EINVAL; 633 + 634 + if (of_property_read_u32(pmic_np, 635 + "s5m8767,pmic-buck-default-dvs-idx", 636 + &pdata->buck_default_idx)) { 637 + pdata->buck_default_idx = 0; 638 + } else { 639 + if (pdata->buck_default_idx >= 8) { 640 + pdata->buck_default_idx = 0; 641 + dev_info(iodev->dev, 642 + "invalid value for default dvs index, use 0\n"); 643 + } 644 + } 645 + dvs_voltage_nr = 8; 646 + } 647 + 648 + ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np); 649 + if (ret) 650 + return -EINVAL; 651 + 652 + if (of_property_read_u32_array(pmic_np, 653 + "s5m8767,pmic-buck2-dvs-voltage", 654 + pdata->buck2_voltage, dvs_voltage_nr)) { 655 + dev_err(iodev->dev, "buck2 voltages not specified\n"); 656 + return -EINVAL; 657 + } 658 + 659 + if (of_property_read_u32_array(pmic_np, 660 + "s5m8767,pmic-buck3-dvs-voltage", 661 + pdata->buck3_voltage, dvs_voltage_nr)) { 662 + dev_err(iodev->dev, "buck3 voltages not specified\n"); 663 + return -EINVAL; 664 + } 665 + 666 + if (of_property_read_u32_array(pmic_np, 667 + "s5m8767,pmic-buck4-dvs-voltage", 668 + pdata->buck4_voltage, dvs_voltage_nr)) { 669 + dev_err(iodev->dev, "buck4 voltages not specified\n"); 670 + return -EINVAL; 671 + } 672 + 673 + return 0; 674 + } 675 + #else 676 + static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, 677 + struct sec_platform_data *pdata) 678 + { 679 + return 0; 680 + } 681 + #endif /* CONFIG_OF */ 682 + 481 683 static int s5m8767_pmic_probe(struct platform_device *pdev) 482 684 { 483 685 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 484 - struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); 686 + struct sec_platform_data *pdata = iodev->pdata; 485 687 struct regulator_config config = { }; 486 688 struct regulator_dev **rdev; 487 689 struct s5m8767_info *s5m8767; ··· 662 520 if (!pdata) { 663 521 dev_err(pdev->dev.parent, "Platform data not supplied\n"); 664 522 return -ENODEV; 523 + } 524 + 525 + if (iodev->dev->of_node) { 526 + ret = s5m8767_pmic_dt_parse_pdata(pdev, pdata); 527 + if (ret) 528 + return ret; 665 529 } 666 530 667 531 if (pdata->buck2_gpiodvs) { ··· 725 577 s5m8767->opmode = pdata->opmode; 726 578 727 579 buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, 728 - pdata->buck2_init, 729 - pdata->buck2_init + 730 - buck_voltage_val2.step); 580 + pdata->buck2_init); 731 581 732 582 sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init); 733 583 734 584 buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, 735 - pdata->buck3_init, 736 - pdata->buck3_init + 737 - buck_voltage_val2.step); 585 + pdata->buck3_init); 738 586 739 587 sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init); 740 588 741 589 buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, 742 - pdata->buck4_init, 743 - pdata->buck4_init + 744 - buck_voltage_val2.step); 590 + pdata->buck4_init); 745 591 746 592 sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init); 747 593 ··· 744 602 s5m8767->buck2_vol[i] = 745 603 s5m8767_convert_voltage_to_sel( 746 604 &buck_voltage_val2, 747 - pdata->buck2_voltage[i], 748 - pdata->buck2_voltage[i] + 749 - buck_voltage_val2.step); 605 + pdata->buck2_voltage[i]); 750 606 } 751 607 752 608 if (s5m8767->buck3_gpiodvs) { 753 609 s5m8767->buck3_vol[i] = 754 610 s5m8767_convert_voltage_to_sel( 755 611 &buck_voltage_val2, 756 - pdata->buck3_voltage[i], 757 - pdata->buck3_voltage[i] + 758 - buck_voltage_val2.step); 612 + pdata->buck3_voltage[i]); 759 613 } 760 614 761 615 if (s5m8767->buck4_gpiodvs) { 762 616 s5m8767->buck4_vol[i] = 763 617 s5m8767_convert_voltage_to_sel( 764 618 &buck_voltage_val2, 765 - pdata->buck4_voltage[i], 766 - pdata->buck4_voltage[i] + 767 - buck_voltage_val2.step); 619 + pdata->buck4_voltage[i]); 768 620 } 769 621 } 770 622 ··· 896 760 (desc->max - desc->min) / desc->step + 1; 897 761 regulators[id].min_uV = desc->min; 898 762 regulators[id].uV_step = desc->step; 763 + regulators[id].vsel_reg = 764 + s5m8767_get_vsel_reg(id, s5m8767); 765 + if (id < S5M8767_BUCK1) 766 + regulators[id].vsel_mask = 0x3f; 767 + else 768 + regulators[id].vsel_mask = 0xff; 899 769 } 900 770 901 771 config.dev = s5m8767->dev; 902 772 config.init_data = pdata->regulators[i].initdata; 903 773 config.driver_data = s5m8767; 774 + config.regmap = iodev->regmap; 775 + config.of_node = pdata->regulators[i].reg_node; 904 776 905 777 rdev[i] = regulator_register(&regulators[id], &config); 906 778 if (IS_ERR(rdev[i])) {
+7 -4
include/linux/mfd/samsung/core.h
··· 26 26 /** 27 27 * struct sec_pmic_dev - s5m87xx master device for sub-drivers 28 28 * @dev: master device of the chip (can be used to access platform data) 29 + * @pdata: pointer to private data used to pass platform data to child 29 30 * @i2c: i2c client private data for regulator 30 31 * @rtc: i2c client private data for rtc 31 32 * @iolock: mutex for serializing io access ··· 40 39 */ 41 40 struct sec_pmic_dev { 42 41 struct device *dev; 42 + struct sec_platform_data *pdata; 43 43 struct regmap *regmap; 44 44 struct i2c_client *i2c; 45 45 struct i2c_client *rtc; ··· 84 82 85 83 int buck_gpios[3]; 86 84 int buck_ds[3]; 87 - int buck2_voltage[8]; 85 + unsigned int buck2_voltage[8]; 88 86 bool buck2_gpiodvs; 89 - int buck3_voltage[8]; 87 + unsigned int buck3_voltage[8]; 90 88 bool buck3_gpiodvs; 91 - int buck4_voltage[8]; 89 + unsigned int buck4_voltage[8]; 92 90 bool buck4_gpiodvs; 93 91 94 92 int buck_set1; ··· 129 127 struct sec_regulator_data { 130 128 int id; 131 129 struct regulator_init_data *initdata; 130 + struct device_node *reg_node; 132 131 }; 133 132 134 133 /* ··· 139 136 */ 140 137 struct sec_opmode_data { 141 138 int id; 142 - int mode; 139 + unsigned int mode; 143 140 }; 144 141 145 142 /*