imx6: use upstream gateworks board names
[openwrt.git] / target / linux / imx6 / patches-3.10 / 0026-regulator-pfuze100-Fix-n_voltages-setting-for-SW2-SW.patch
1 From: Axel Lin <axel.lin@ingics.com>
2 Subject: [PATCH] regulator: pfuze100: Fix n_voltages setting for SW2~SW4 with
3  high bit set
4
5 Current code adjust min_uV and uV_step but missed adjusting the n_voltages
6 setting.
7
8 When BIT6 is clear:
9         n_voltages = (1975000 - 400000) / 25000 + 1 = 64
10 When BIT6 is set:
11         n_voltages = (3300000 - 800000) / 50000 + 1 = 51
12
13 The n_voltages needs update because when BIT6 is set 0x73 ~ 0x7f are reserved.
14 When using regulator_list_voltage_linear, the n_voltages does matter here
15 because wrong n_voltages setting make the equation return wrong result.
16 e.g. if selector is 63, regulator_list_voltage_linear returns
17      800000 + (50000 * 63) = 4000000
18      It should return -EINVAL if the selector is in the range of 51 ~ 63.
19
20 Signed-off-by: Axel Lin <axel.lin@ingics.com>
21 Signed-off-by: Mark Brown <broonie@linaro.org>
22 ---
23  drivers/regulator/pfuze100-regulator.c | 16 ++++++++--------
24  1 file changed, 8 insertions(+), 8 deletions(-)
25
26 --- a/drivers/regulator/pfuze100-regulator.c
27 +++ b/drivers/regulator/pfuze100-regulator.c
28 @@ -388,8 +388,11 @@ static int pfuze100_regulator_probe(stru
29  
30         for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) {
31                 struct regulator_init_data *init_data;
32 +               struct regulator_desc *desc;
33                 int val;
34  
35 +               desc = &pfuze_chip->regulator_descs[i].desc;
36 +
37                 if (pdata)
38                         init_data = pdata->init_data[i];
39                 else
40 @@ -397,13 +400,11 @@ static int pfuze100_regulator_probe(stru
41  
42                 /* SW2~SW4 high bit check and modify the voltage value table */
43                 if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) {
44 -                       regmap_read(pfuze_chip->regmap, PFUZE100_SW2VOL +
45 -                                       (i - PFUZE100_SW2) * 7, &val);
46 +                       regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val);
47                         if (val & 0x40) {
48 -                               pfuze_chip->regulator_descs[i].desc.min_uV
49 -                               = 800000;
50 -                               pfuze_chip->regulator_descs[i].desc.uV_step
51 -                               = 50000;
52 +                               desc->min_uV = 800000;
53 +                               desc->uV_step = 50000;
54 +                               desc->n_voltages = 51;
55                         }
56                 }
57  
58 @@ -412,8 +413,7 @@ static int pfuze100_regulator_probe(stru
59                 config.driver_data = pfuze_chip;
60                 config.of_node = match_of_node(i);
61  
62 -               pfuze_chip->regulators[i] = regulator_register(&pfuze_chip
63 -                       ->regulator_descs[i].desc, &config);
64 +               pfuze_chip->regulators[i] = regulator_register(desc, &config);
65                 if (IS_ERR(pfuze_chip->regulators[i])) {
66                         dev_err(&client->dev, "register regulator%s failed\n",
67                                 pfuze100_regulators[i].desc.name);