* [PATCH 0/2] regulator: Add FAN53880 support @ 2020-06-30 18:52 Christoph Fritz 2020-06-30 18:52 ` [PATCH 1/2] regulator: fan53880: Add initial support Christoph Fritz ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Christoph Fritz @ 2020-06-30 18:52 UTC (permalink / raw) To: Mark Brown; +Cc: Liam Girdwood, Rob Herring, linux-kernel, devicetree This patchset adds a regulator driver with dt-bindings documentation in the new yaml format for a power management IC from Fairchild (now ON Semiconductor) named FAN53880. The chip was found on a camera sensor board which will get a v4lsubdev driver in the future. The FAN53880 differs a lot compared to the older FAN53555 which already has driver support. Christoph Fritz (2): regulator: fan53880: Add initial support dt-bindings: regulator: Document bindings for fan53880 .../bindings/regulator/onnn,fan53880.yaml | 85 +++++++++ drivers/regulator/Kconfig | 10 + drivers/regulator/Makefile | 1 + drivers/regulator/fan53880.c | 179 ++++++++++++++++++ 4 files changed, 275 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/onnn,fan53880.yaml create mode 100644 drivers/regulator/fan53880.c -- 2.20.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] regulator: fan53880: Add initial support 2020-06-30 18:52 [PATCH 0/2] regulator: Add FAN53880 support Christoph Fritz @ 2020-06-30 18:52 ` Christoph Fritz 2020-07-01 18:09 ` Mark Brown 2020-06-30 18:52 ` [PATCH 2/2] dt-bindings: regulator: Document bindings for fan53880 Christoph Fritz 2020-07-03 17:04 ` [PATCH 0/2] regulator: Add FAN53880 support Mark Brown 2 siblings, 1 reply; 6+ messages in thread From: Christoph Fritz @ 2020-06-30 18:52 UTC (permalink / raw) To: Mark Brown; +Cc: Liam Girdwood, Rob Herring, linux-kernel, devicetree This patch adds support for ON Semiconductor FAN53880 regulator. The FAN53880 is an I2C porgrammable power management IC (PMIC) that contains a BUCK (step-down converter), four LDOs (low dropouts) and one BOOST (step-up converter). It is designed for mobile power applications. Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> --- drivers/regulator/Kconfig | 10 ++ drivers/regulator/Makefile | 1 + drivers/regulator/fan53880.c | 179 +++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 drivers/regulator/fan53880.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index edb1c4f8b496..69fcfdc50ada 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -326,6 +326,16 @@ config REGULATOR_FAN53555 input voltage supply of 2.5V to 5.5V. The output voltage is programmed through an I2C interface. +config REGULATOR_FAN53880 + tristate "Fairchild FAN53880 Regulator" + depends on I2C + select REGMAP_I2C + help + This driver supports Fairchild (ON Semiconductor) FAN53880 + regulator. The regulator is a programmable power management IC + (PMIC), it is controlled by I2C and provides one BUCK, one BOOST + and four LDO outputs. + config REGULATOR_GPIO tristate "GPIO regulator support" depends on GPIOLIB || COMPILE_TEST diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index e8f163371071..7b7d2eeb78c2 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_DA9211) += da9211-regulator.o obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o +obj-$(CONFIG_REGULATOR_FAN53880) += fan53880.o obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o obj-$(CONFIG_REGULATOR_HI6421V530) += hi6421v530-regulator.o diff --git a/drivers/regulator/fan53880.c b/drivers/regulator/fan53880.c new file mode 100644 index 000000000000..114c6bd3d962 --- /dev/null +++ b/drivers/regulator/fan53880.c @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/regmap.h> +#include <linux/regulator/driver.h> + +enum fan53880_regulator_ids { + FAN53880_LDO1, + FAN53880_LDO2, + FAN53880_LDO3, + FAN53880_LDO4, + FAN53880_BUCK, + FAN53880_BOOST, +}; + +enum fan53880_registers { + FAN53880_PRODUCT_ID = 0x00, + FAN53880_SILICON_REV, + FAN53880_BUCKVOUT, + FAN53880_BOOSTVOUT, + FAN53880_LDO1VOUT, + FAN53880_LDO2VOUT, + FAN53880_LDO3VOUT, + FAN53880_LDO4VOUT, + FAN53880_IOUT, + FAN53880_ENABLE, + FAN53880_ENABLE_BOOST, +}; + +#define FAN53880_ID 0x01 + +static const struct regulator_ops fan53880_ops = { + .list_voltage = regulator_list_voltage_linear_range, + .map_voltage = regulator_map_voltage_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, +}; + +#define FAN53880_LDO(_num, _supply, _default) \ + [FAN53880_LDO ## _num] = { \ + .name = "LDO"#_num, \ + .of_match = of_match_ptr("LDO"#_num), \ + .regulators_node = of_match_ptr("regulators"), \ + .type = REGULATOR_VOLTAGE, \ + .linear_ranges = (struct regulator_linear_range[]) { \ + REGULATOR_LINEAR_RANGE(_default, 0x0, 0x0, 0), \ + REGULATOR_LINEAR_RANGE(800000, 0xf, 0x73, 25000), \ + }, \ + .n_linear_ranges = 2, \ + .vsel_reg = FAN53880_LDO ## _num ## VOUT, \ + .vsel_mask = 0x7f, \ + .enable_reg = FAN53880_ENABLE, \ + .enable_mask = BIT(_num - 1), \ + .enable_time = 150, \ + .supply_name = _supply, \ + .ops = &fan53880_ops, \ + } + +static const struct regulator_desc fan53880_regulators[] = { + FAN53880_LDO(1, "VIN12", 2800000), + FAN53880_LDO(2, "VIN12", 2800000), + FAN53880_LDO(3, "VIN3", 1800000), + FAN53880_LDO(4, "VIN4", 1800000), + [FAN53880_BUCK] = { + .name = "BUCK", + .of_match = of_match_ptr("BUCK"), + .regulators_node = of_match_ptr("regulators"), + .type = REGULATOR_VOLTAGE, + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(1100000, 0x0, 0x0, 0), + REGULATOR_LINEAR_RANGE(600000, 0x1f, 0xf7, 12500), + }, + .n_linear_ranges = 2, + .vsel_reg = FAN53880_BUCKVOUT, + .vsel_mask = 0x7f, + .enable_reg = FAN53880_ENABLE, + .enable_mask = 0x10, + .enable_time = 480, + .supply_name = "PVIN", + .ops = &fan53880_ops, + }, + [FAN53880_BOOST] = { + .name = "BOOST", + .of_match = of_match_ptr("BOOST"), + .regulators_node = of_match_ptr("regulators"), + .type = REGULATOR_VOLTAGE, + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(5000000, 0x0, 0x0, 0), + REGULATOR_LINEAR_RANGE(3000000, 0x4, 0x70, 25000), + }, + .n_linear_ranges = 2, + .vsel_reg = FAN53880_BOOSTVOUT, + .vsel_mask = 0x7f, + .enable_reg = FAN53880_ENABLE_BOOST, + .enable_mask = 0xff, + .enable_time = 580, + .supply_name = "PVIN", + .ops = &fan53880_ops, + }, +}; + +static const struct regmap_config fan53880_regmap = { + .reg_bits = 8, + .val_bits = 8, + .max_register = FAN53880_ENABLE_BOOST, +}; + +static int fan53880_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct regulator_config config = { }; + struct regulator_dev *rdev; + struct regmap *regmap; + int i, ret; + unsigned int data; + + regmap = devm_regmap_init_i2c(i2c, &fan53880_regmap); + if (IS_ERR(regmap)) { + ret = PTR_ERR(regmap); + dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret); + return ret; + } + + ret = regmap_read(regmap, FAN53880_PRODUCT_ID, &data); + if (ret < 0) { + dev_err(&i2c->dev, "Failed to read PRODUCT_ID: %d\n", ret); + return ret; + } + if (data != FAN53880_ID) { + dev_err(&i2c->dev, "Unsupported device id: 0x%x.\n", data); + return -ENODEV; + } + + config.dev = &i2c->dev; + config.init_data = NULL; + + for (i = 0; i < ARRAY_SIZE(fan53880_regulators); i++) { + rdev = devm_regulator_register(&i2c->dev, + &fan53880_regulators[i], + &config); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); + dev_err(&i2c->dev, "Failed to register %s: %d\n", + fan53880_regulators[i].name, ret); + return ret; + } + } + + return 0; +} + +static const struct of_device_id fan53880_dt_ids[] = { + { .compatible = "onnn,fan53880", }, + {} +}; +MODULE_DEVICE_TABLE(of, fan53880_dt_ids); + +static const struct i2c_device_id fan53880_i2c_id[] = { + { "fan53880", }, + {} +}; +MODULE_DEVICE_TABLE(i2c, fan53880_i2c_id); + +static struct i2c_driver fan53880_regulator_driver = { + .driver = { + .name = "fan53880", + .of_match_table = of_match_ptr(fan53880_dt_ids), + }, + .probe = fan53880_i2c_probe, + .id_table = fan53880_i2c_id, +}; +module_i2c_driver(fan53880_regulator_driver); + +MODULE_DESCRIPTION("FAN53880 PMIC voltage regulator driver"); +MODULE_AUTHOR("Christoph Fritz <chf.fritz@googlemail.com>"); +MODULE_LICENSE("GPL"); -- 2.20.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] regulator: fan53880: Add initial support 2020-06-30 18:52 ` [PATCH 1/2] regulator: fan53880: Add initial support Christoph Fritz @ 2020-07-01 18:09 ` Mark Brown 2020-07-02 21:09 ` Christoph Fritz 0 siblings, 1 reply; 6+ messages in thread From: Mark Brown @ 2020-07-01 18:09 UTC (permalink / raw) To: Christoph Fritz; +Cc: Liam Girdwood, Rob Herring, linux-kernel, devicetree [-- Attachment #1: Type: text/plain, Size: 2126 bytes --] On Tue, Jun 30, 2020 at 08:52:02PM +0200, Christoph Fritz wrote: > This patch adds support for ON Semiconductor FAN53880 regulator. > > The FAN53880 is an I2C porgrammable power management IC (PMIC) > that contains a BUCK (step-down converter), four LDOs (low dropouts) > and one BOOST (step-up converter). It is designed for mobile power > applications. This doesn't build with current code, there are *many* errors in the form /mnt/kernel/drivers/regulator/fan53880.c:48:52: error: array type has incomplete element type 'struct regulator_linear_range' .linear_ranges = (struct regulator_linear_range[]) { \ ^ /mnt/kernel/drivers/regulator/fan53880.c:63:2: note: in expansion of macro 'FAN53880_LDO' FAN53880_LDO(1, "VIN12", 2800000), ^~~~~~~~~~~~ In file included from /mnt/kernel/drivers/regulator/fan53880.c:5: /mnt/kernel/include/linux/regulator/driver.h:46:2: error: field name not in record or union initializer .min = _min_uV, \ ^ /mnt/kernel/drivers/regulator/fan53880.c:49:9: note: in expansion of macro 'REGULATOR_LINEAR_RANGE' REGULATOR_LINEAR_RANGE(_default, 0x0, 0x0, 0), \ ^~~~~~~~~~~~~~~~~~~~~~ /mnt/kernel/drivers/regulator/fan53880.c:63:2: note: in expansion of macro 'FAN53880_LDO' FAN53880_LDO(1, "VIN12", 2800000), ^~~~~~~~~~~~ /mnt/kernel/include/linux/regulator/driver.h:46:2: note: (near initialization for '(anonymous)') .min = _min_uV, \ ^ /mnt/kernel/drivers/regulator/fan53880.c:49:9: note: in expansion of macro 'REGULATOR_LINEAR_RANGE' REGULATOR_LINEAR_RANGE(_default, 0x0, 0x0, 0), \ ^~~~~~~~~~~~~~~~~~~~~~ /mnt/kernel/drivers/regulator/fan53880.c:63:2: note: in expansion of macro 'FAN53880_LDO' FAN53880_LDO(1, "VIN12", 2800000), ^~~~~~~~~~~~ /mnt/kernel/include/linux/regulator/driver.h:47:2: error: field name not in record or union initializer .min_sel = _min_sel, \ ^ most likely due to the conversion introduced in 60ab7f4153b6af46 (regulator: use linear_ranges helper). Please rebase against current code. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 484 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] regulator: fan53880: Add initial support 2020-07-01 18:09 ` Mark Brown @ 2020-07-02 21:09 ` Christoph Fritz 0 siblings, 0 replies; 6+ messages in thread From: Christoph Fritz @ 2020-07-02 21:09 UTC (permalink / raw) To: Mark Brown; +Cc: Liam Girdwood, Rob Herring, linux-kernel, devicetree On Wed, 2020-07-01 at 19:09 +0100, Mark Brown wrote: > /mnt/kernel/drivers/regulator/fan53880.c:63:2: note: in expansion of > macro 'FAN53880_LDO' > FAN53880_LDO(1, "VIN12", 2800000), > ^~~~~~~~~~~~ > /mnt/kernel/include/linux/regulator/driver.h:47:2: error: field name > not in record or union initializer > .min_sel = _min_sel, \ > ^ > > most likely due to the conversion introduced in 60ab7f4153b6af46 > (regulator: use linear_ranges helper). Please rebase against current > code. Thanks for the hint, yeah that's it. After picking up a recent linux- next and adapting it works on current too. Please let me respin the patches in a v2. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] dt-bindings: regulator: Document bindings for fan53880 2020-06-30 18:52 [PATCH 0/2] regulator: Add FAN53880 support Christoph Fritz 2020-06-30 18:52 ` [PATCH 1/2] regulator: fan53880: Add initial support Christoph Fritz @ 2020-06-30 18:52 ` Christoph Fritz 2020-07-03 17:04 ` [PATCH 0/2] regulator: Add FAN53880 support Mark Brown 2 siblings, 0 replies; 6+ messages in thread From: Christoph Fritz @ 2020-06-30 18:52 UTC (permalink / raw) To: Mark Brown; +Cc: Liam Girdwood, Rob Herring, linux-kernel, devicetree Add device tree binding information for fan53880 regulator driver. Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> --- .../bindings/regulator/onnn,fan53880.yaml | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/onnn,fan53880.yaml diff --git a/Documentation/devicetree/bindings/regulator/onnn,fan53880.yaml b/Documentation/devicetree/bindings/regulator/onnn,fan53880.yaml new file mode 100644 index 000000000000..eb61e04ef852 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/onnn,fan53880.yaml @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/onnn,fan53880.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Onsemi FAN53880 PMIC + +maintainers: + - Christoph Fritz <chf.fritz@googlemail.com> + +description: | + The FAN53880 is an I2C porgrammable power management IC (PMIC) + that contains a BUCK (step-down converter), four low dropouts (LDO) + and one BOOST (step-up converter) output. It is designed for mobile + power applications. + +properties: + $nodename: + pattern: "pmic@[0-9a-f]{1,2}" + compatible: + enum: + - onnn,fan53880 + + reg: + maxItems: 1 + + VIN12-supply: + description: Input supply phandle(s) for LDO1 and LDO2 + + VIN3-supply: + description: Input supply phandle(s) for LDO3 + + VIN4-supply: + description: Input supply phandle(s) for LDO4 + + PVIN-supply: + description: Input supply phandle(s) for BUCK and BOOST + + regulators: + type: object + $ref: regulator.yaml# + description: | + list of regulators provided by this controller, must be named + after their hardware counterparts LDO[1-4], BUCK and BOOST + + patternProperties: + "^LDO[1-4]$": + type: object + $ref: regulator.yaml# + + "^BUCK|BOOST$": + type: object + $ref: regulator.yaml# + + additionalProperties: false + +required: + - compatible + - reg + - regulators + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@35 { + compatible = "onnn,fan53880"; + reg = <0x35>; + + PVIN-supply = <&fixreg_example_vcc>; + + regulators { + BUCK { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + }; + }; + }; +... -- 2.20.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] regulator: Add FAN53880 support 2020-06-30 18:52 [PATCH 0/2] regulator: Add FAN53880 support Christoph Fritz 2020-06-30 18:52 ` [PATCH 1/2] regulator: fan53880: Add initial support Christoph Fritz 2020-06-30 18:52 ` [PATCH 2/2] dt-bindings: regulator: Document bindings for fan53880 Christoph Fritz @ 2020-07-03 17:04 ` Mark Brown 2 siblings, 0 replies; 6+ messages in thread From: Mark Brown @ 2020-07-03 17:04 UTC (permalink / raw) To: Christoph Fritz; +Cc: linux-kernel, Liam Girdwood, Rob Herring, devicetree On Tue, 30 Jun 2020 20:52:01 +0200, Christoph Fritz wrote: > This patchset adds a regulator driver with dt-bindings documentation in > the new yaml format for a power management IC from Fairchild (now ON > Semiconductor) named FAN53880. > > The chip was found on a camera sensor board which will get a v4lsubdev > driver in the future. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next Thanks! [1/2] regulator: fan53880: Add initial support commit: e6dea51e2d41679d37a81d0b1247c039092af46b [2/2] dt-bindings: regulator: Document bindings for fan53880 commit: 643ddb618a5fd1819e790e86be85ae50c2c4abc4 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-07-03 17:04 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-06-30 18:52 [PATCH 0/2] regulator: Add FAN53880 support Christoph Fritz 2020-06-30 18:52 ` [PATCH 1/2] regulator: fan53880: Add initial support Christoph Fritz 2020-07-01 18:09 ` Mark Brown 2020-07-02 21:09 ` Christoph Fritz 2020-06-30 18:52 ` [PATCH 2/2] dt-bindings: regulator: Document bindings for fan53880 Christoph Fritz 2020-07-03 17:04 ` [PATCH 0/2] regulator: Add FAN53880 support Mark Brown
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.