diff options
author | Maarten ter Huurne <maarten@treewalker.org> | 2016-03-17 10:05:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-28 15:34:20 -0400 |
commit | c5c9c2df4d97e20cd4e05c848dc8ceff926d162f (patch) | |
tree | 356150f4f4d0d12ab9c50d29ece0891ccfb04789 | |
parent | 005e46857ed598bcf76035366cd2841e3b7f8c54 (diff) |
regulator: act8865: Configure register access for act8600
This can be used to expose the act8600 registers via debugfs.
Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/act8865-regulator.c | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 527926b045d5..a1cd0d4f8257 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c | |||
@@ -139,6 +139,74 @@ struct act8865 { | |||
139 | int off_mask; | 139 | int off_mask; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static const struct regmap_range act8600_reg_ranges[] = { | ||
143 | regmap_reg_range(0x00, 0x01), | ||
144 | regmap_reg_range(0x10, 0x10), | ||
145 | regmap_reg_range(0x12, 0x12), | ||
146 | regmap_reg_range(0x20, 0x20), | ||
147 | regmap_reg_range(0x22, 0x22), | ||
148 | regmap_reg_range(0x30, 0x30), | ||
149 | regmap_reg_range(0x32, 0x32), | ||
150 | regmap_reg_range(0x40, 0x41), | ||
151 | regmap_reg_range(0x50, 0x51), | ||
152 | regmap_reg_range(0x60, 0x61), | ||
153 | regmap_reg_range(0x70, 0x71), | ||
154 | regmap_reg_range(0x80, 0x81), | ||
155 | regmap_reg_range(0x91, 0x91), | ||
156 | regmap_reg_range(0xA1, 0xA1), | ||
157 | regmap_reg_range(0xA8, 0xAA), | ||
158 | regmap_reg_range(0xB0, 0xB0), | ||
159 | regmap_reg_range(0xB2, 0xB2), | ||
160 | regmap_reg_range(0xC1, 0xC1), | ||
161 | }; | ||
162 | |||
163 | static const struct regmap_range act8600_reg_ro_ranges[] = { | ||
164 | regmap_reg_range(0xAA, 0xAA), | ||
165 | regmap_reg_range(0xC1, 0xC1), | ||
166 | }; | ||
167 | |||
168 | static const struct regmap_range act8600_reg_volatile_ranges[] = { | ||
169 | regmap_reg_range(0x00, 0x01), | ||
170 | regmap_reg_range(0x12, 0x12), | ||
171 | regmap_reg_range(0x22, 0x22), | ||
172 | regmap_reg_range(0x32, 0x32), | ||
173 | regmap_reg_range(0x41, 0x41), | ||
174 | regmap_reg_range(0x51, 0x51), | ||
175 | regmap_reg_range(0x61, 0x61), | ||
176 | regmap_reg_range(0x71, 0x71), | ||
177 | regmap_reg_range(0x81, 0x81), | ||
178 | regmap_reg_range(0xA8, 0xA8), | ||
179 | regmap_reg_range(0xAA, 0xAA), | ||
180 | regmap_reg_range(0xB0, 0xB0), | ||
181 | regmap_reg_range(0xC1, 0xC1), | ||
182 | }; | ||
183 | |||
184 | static const struct regmap_access_table act8600_write_ranges_table = { | ||
185 | .yes_ranges = act8600_reg_ranges, | ||
186 | .n_yes_ranges = ARRAY_SIZE(act8600_reg_ranges), | ||
187 | .no_ranges = act8600_reg_ro_ranges, | ||
188 | .n_no_ranges = ARRAY_SIZE(act8600_reg_ro_ranges), | ||
189 | }; | ||
190 | |||
191 | static const struct regmap_access_table act8600_read_ranges_table = { | ||
192 | .yes_ranges = act8600_reg_ranges, | ||
193 | .n_yes_ranges = ARRAY_SIZE(act8600_reg_ranges), | ||
194 | }; | ||
195 | |||
196 | static const struct regmap_access_table act8600_volatile_ranges_table = { | ||
197 | .yes_ranges = act8600_reg_volatile_ranges, | ||
198 | .n_yes_ranges = ARRAY_SIZE(act8600_reg_volatile_ranges), | ||
199 | }; | ||
200 | |||
201 | static const struct regmap_config act8600_regmap_config = { | ||
202 | .reg_bits = 8, | ||
203 | .val_bits = 8, | ||
204 | .max_register = 0xFF, | ||
205 | .wr_table = &act8600_write_ranges_table, | ||
206 | .rd_table = &act8600_read_ranges_table, | ||
207 | .volatile_table = &act8600_volatile_ranges_table, | ||
208 | }; | ||
209 | |||
142 | static const struct regmap_config act8865_regmap_config = { | 210 | static const struct regmap_config act8865_regmap_config = { |
143 | .reg_bits = 8, | 211 | .reg_bits = 8, |
144 | .val_bits = 8, | 212 | .val_bits = 8, |
@@ -418,6 +486,7 @@ static int act8865_pmic_probe(struct i2c_client *client, | |||
418 | struct device *dev = &client->dev; | 486 | struct device *dev = &client->dev; |
419 | int i, ret, num_regulators; | 487 | int i, ret, num_regulators; |
420 | struct act8865 *act8865; | 488 | struct act8865 *act8865; |
489 | const struct regmap_config *regmap_config; | ||
421 | unsigned long type; | 490 | unsigned long type; |
422 | int off_reg, off_mask; | 491 | int off_reg, off_mask; |
423 | int voltage_select = 0; | 492 | int voltage_select = 0; |
@@ -444,12 +513,14 @@ static int act8865_pmic_probe(struct i2c_client *client, | |||
444 | case ACT8600: | 513 | case ACT8600: |
445 | regulators = act8600_regulators; | 514 | regulators = act8600_regulators; |
446 | num_regulators = ARRAY_SIZE(act8600_regulators); | 515 | num_regulators = ARRAY_SIZE(act8600_regulators); |
516 | regmap_config = &act8600_regmap_config; | ||
447 | off_reg = -1; | 517 | off_reg = -1; |
448 | off_mask = -1; | 518 | off_mask = -1; |
449 | break; | 519 | break; |
450 | case ACT8846: | 520 | case ACT8846: |
451 | regulators = act8846_regulators; | 521 | regulators = act8846_regulators; |
452 | num_regulators = ARRAY_SIZE(act8846_regulators); | 522 | num_regulators = ARRAY_SIZE(act8846_regulators); |
523 | regmap_config = &act8865_regmap_config; | ||
453 | off_reg = ACT8846_GLB_OFF_CTRL; | 524 | off_reg = ACT8846_GLB_OFF_CTRL; |
454 | off_mask = ACT8846_OFF_SYSMASK; | 525 | off_mask = ACT8846_OFF_SYSMASK; |
455 | break; | 526 | break; |
@@ -461,6 +532,7 @@ static int act8865_pmic_probe(struct i2c_client *client, | |||
461 | regulators = act8865_regulators; | 532 | regulators = act8865_regulators; |
462 | num_regulators = ARRAY_SIZE(act8865_regulators); | 533 | num_regulators = ARRAY_SIZE(act8865_regulators); |
463 | } | 534 | } |
535 | regmap_config = &act8865_regmap_config; | ||
464 | off_reg = ACT8865_SYS_CTRL; | 536 | off_reg = ACT8865_SYS_CTRL; |
465 | off_mask = ACT8865_MSTROFF; | 537 | off_mask = ACT8865_MSTROFF; |
466 | break; | 538 | break; |
@@ -481,7 +553,7 @@ static int act8865_pmic_probe(struct i2c_client *client, | |||
481 | if (!act8865) | 553 | if (!act8865) |
482 | return -ENOMEM; | 554 | return -ENOMEM; |
483 | 555 | ||
484 | act8865->regmap = devm_regmap_init_i2c(client, &act8865_regmap_config); | 556 | act8865->regmap = devm_regmap_init_i2c(client, regmap_config); |
485 | if (IS_ERR(act8865->regmap)) { | 557 | if (IS_ERR(act8865->regmap)) { |
486 | ret = PTR_ERR(act8865->regmap); | 558 | ret = PTR_ERR(act8865->regmap); |
487 | dev_err(dev, "Failed to allocate register map: %d\n", ret); | 559 | dev_err(dev, "Failed to allocate register map: %d\n", ret); |