Commit Graph

14 Commits

Author SHA1 Message Date
Chen-Yu Tsai 269cb04b60
regulator: Use bitfield values for range selectors
Right now the regulator helpers expect raw register values for the range
selectors. This is different from the voltage selectors, which are
normalized as bitfield values. This leads to a bit of confusion. Also,
raw values are harder to copy from datasheets or match up with them,
as datasheets will typically have bitfield values.

Make the helpers expect bitfield values, and convert existing users. The
field in regulator_desc is renamed to |linear_range_selectors_bitfield|.
This is intended to cause drivers added in the same merge window and
out-of-tree drivers using the incorrect variable and values to break,
preventing incorrect values being used on actual hardware and potentially
producing magic smoke.

Also include bitops.h explicitly for ffs(), and reorder the header include
statements. While at it, also replace module.h with export.h, since the
only use is EXPORT_SYMBOL_GPL.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/20230714081408.274567-1-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-25 12:14:27 +01:00
Douglas Anderson d3b81d97d5
regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 4.19 and 5.4
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS
for drivers that existed in 4.14") but changes regulators didn't exist
in Linux 4.19 but did exist in Linux 5.4.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20230316125351.3.I45bf925ca9537da5f647e2acb0ad207c0c98af81@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20 13:11:27 +00:00
Matti Vaittinen 60ab7f4153
regulator: use linear_ranges helper
Change the regulator helpers to use common linear_ranges code.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/64f01d5e381b8631a271616b7790f9d5640974fb.1588944082.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-08 18:18:13 +01:00
Bartosz Golaszewski 100a21100b
regulator: max77650: add of_match table
We need the of_match table if we want to use the compatible string in
the pmic's child node and get the regulator driver loaded automatically.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20191210100725.11005-1-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-11 16:47:33 +00:00
Bartosz Golaszewski 3c7577d442
regulator: max77650: use vsel_step
Use the new vsel_step field in the regulator description to instruct
the regulator API on the required voltage ramping. Switch to using the
generic regmap helpers for voltage setting and remove the old set_voltage
callback that handcoded the selector stepping.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20190703161035.31808-3-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-04 17:31:37 +01:00
Bartosz Golaszewski ba2bf340ad
regulator: max77650: add MODULE_ALIAS()
Define a MODULE_ALIAS() in the regulator sub-driver for max77650 so that
the appropriate module gets loaded together with the core mfd driver.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20190703084849.9668-1-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-03 13:02:59 +01:00
Nathan Chancellor 59dec1f0fa
regulator: max77650: Move max77651_SBB1_desc's declaration down
Clang warns:

drivers/regulator/max77650-regulator.c:32:39: warning: tentative
definition of variable with internal linkage has incomplete non-array
type 'struct max77650_regulator_desc'
[-Wtentative-definition-incomplete-type]
static struct max77650_regulator_desc max77651_SBB1_desc;
                                      ^
drivers/regulator/max77650-regulator.c:32:15: note: forward declaration
of 'struct max77650_regulator_desc'
static struct max77650_regulator_desc max77651_SBB1_desc;
              ^
1 warning generated.

Move max77651_SBB1_desc's declaration below max77650_regulator_desc's
definition so this warning does not happen.

Fixes: 3df4235ac4 ("regulator: max77650: Convert MAX77651 SBB1 to pickable linear range")
Link: https://github.com/ClangBuiltLinux/linux/issues/491
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-05-23 14:35:14 +01:00
Axel Lin 3df4235ac4
regulator: max77650: Convert MAX77651 SBB1 to pickable linear range
The pickable linear range is suitable for The MAX77651 SBB1.
According to MAX77651 TV_SBB1 Code Table:
Use BIT[1:0] as range selectors.
Use BIT[5:2] as selectors for each linear range.

The MAX77651 SBB1 supports up to selector 57, selector 58 ~ 63 are RSVD,
thus set n_voltage to 58.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-05-08 17:32:55 +09:00
Axel Lin 5fe0ed2437
regulator: max77650: Use unsigned int for max77651_sbb1_regulator_volt_table
Make it consistent as .volt_table should be const unsigned int *.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-18 12:11:00 +00:00
Axel Lin 6c98ac2a34
regulator: max77650: Convert to use regulator_set/get_current_limit_regmap
Use regulator_set/get_current_limit_regmap helpers to save some code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-03 23:47:26 +00:00
Axel Lin d3d1a6a72b
regulator: max77650: Fix set_current_limit implementation
Current code always return error, fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-22 15:16:33 +00:00
Axel Lin 721efb504d
regulator: max77650: Add missing .owner field in regulator_desc
Add missing .owner field in regulator_desc, which is used for refcounting.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-20 16:46:41 +00:00
Axel Lin 5358db5478
regulator: max77650: Fix include files
This is a platform driver, no need to include linux/i2c.h.
Include linux/of.h for of_match_ptr.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-30 15:20:05 +00:00
Bartosz Golaszewski bcc61f1c44
regulator: max77650: add regulator support
Add regulator support for max77650. We support all four variants of this
PMIC including non-linear voltage table for max77651 SBB1 rail.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-29 15:22:12 +00:00