regulator: add the Will Semiconductor WL2868C camera PMIC
Subsystems (3)
v11 cover regulator: add the Will Semiconductor WL2868C camera PMIC
*** AI-assistance disclosure ***
This cover letter and the two patches below were prepared with the help of an LLM coding assistant. The author reviewed every line, ran every gate quoted in this letter himself, and takes full responsibility for the content.
This is v11 of the WL2868C binding+driver series. It supersedes v10 (<[email protected]>) and differs from it in one place only: the LDOx_SEQ handling Mark asked about.
What changed in v11
===================
Mark Brown asked on v10 2/2 (<[email protected]>):
Quoted 3 lines
Should the driver not also override the
LDOx_SEQregisters to make sure we have software control of them, or hide the enable/disable ops if they're non-zero?
Taken the first way: the four slot registers are cleared in probe.
The datasheet (WL2868C, Will Semiconductor, Rev 1.4, April 2022, "0x0A, 0x0B, 0x0C and 0x0D: LDOx_SEQ", p.35) defines LDOx_SEQ[3:0] as the power-up sequencer slot of each output:
- 0000, the reset value: the output is controlled by its LDOx_EN bit
in 0x0E;
- x001..x111: the output is controlled by the sequencer, which brings the LDO up once SEQ_ON in 0x0F is set and SEQ_COUNT[2:0] reaches the slot; writes to the LDOx_EN bit have no effect on it.
So a non-zero slot silently defeats enable()/disable(): the register write succeeds, is_enabled() reports the LDOx_EN bit, and the output still follows the sequencer. The binding describes no sequencing at all, so clearing the slots and keeping 0x0E as the only control path is the way to make the enable ops truthful. The other option, hiding enable/disable when a slot is non-zero, would leave the outputs uncontrollable on exactly the boards where software needs them.
Measured on the reference board (Lenovo Legion Y700 Gen4, SM8750; Linux 7.3.1, driver bound, read-only through regmap debugfs):
0x0a..0x0d = 00 00 00 00, 0x0e = 0x80, 0x0f = 0x00. The firmware left every slot at its reset value and the sequencer disabled, so the clear is a no-op on this board today; it is there so that a board whose firmware does program the slots does not end up with silently uncontrolled outputs. Clearing a non-zero slot switches off the outputs it had turned on; at probe time no consumer is up yet, and the core re-enables whatever it needs through the enable register.
Everything else is unchanged from v10, so the v10 changelog (sashiko's three Medium findings and the two Low binding points) still applies as written.
Gates for v11
=============
- git am of the two patches onto pristine v7.2 (25f7927e6ccb) leaves no local changes after the series.
- checkpatch --strict on the driver change: 0 errors, 0 warnings, 0 checks.
- W=1 build of drivers/regulator/wl2868c-regulator.o with REGULATOR_WL2868C=y and its dependencies: rc=0, no warnings.
- dt_binding_check: unchanged and passing; the binding is not touched in v11.
Qianhui Xu (2):
regulator: dt-bindings: willsemi,wl2868c: add the WL2868C camera PMIC
regulator: willsemi,wl2868c: add the WL2868C camera PMIC driver
.../bindings/regulator/willsemi,wl2868c.yaml | 99 ++++++ MAINTAINERS | 7 + drivers/regulator/Kconfig | 11 + drivers/regulator/Makefile | 1 + drivers/regulator/wl2868c-regulator.c | 301 ++++++++++++++++++ 5 files changed, 419 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/willsemi,wl2868c.yaml create mode 100644 drivers/regulator/wl2868c-regulator.c
Signature · 1 line
2.53.0
PATCH v11 1/2 regulator: dt-bindings: willsemi,wl2868c: add the WL2868C camera PMIC
The WL2868C is an I2C-controlled camera power management IC from Will Semiconductor. It provides seven programmable LDOs: LDO1 and LDO2 are fed from a shared VIN12 input and cover 0.496 V to 1.512 V, LDO3 and LDO4 share VIN34, and LDO5 to LDO7 each have their own input, covering 1.504 V to 3.544 V. All outputs are programmable in 8 mV steps and are gated by per-output enable bits with a chip-wide SYS_EN master. The chip also exposes an optional active-low RST_N input.
VIN7 and VSYS are both inputs of the internal control logic, which is powered from the higher of the two voltages, so a device tree has to describe at least one of them. The remaining inputs only feed LDOs, so they stay optional: an input can be left unconnected when the outputs it feeds are unused on a given board.
The example enables ldo1, which is fed from VIN12, so it also describes vin12-supply; the binding says an input may only be left out when the outputs it feeds are unused on a given board.
--- .../bindings/regulator/willsemi,wl2868c.yaml | 99 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/willsemi,wl2868c.yaml
Documentation/devicetree/bindings/regulator/willsemi,wl2868c.yaml new file +99 -0
@@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/willsemi,wl2868c.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Will Semiconductor WL2868C camera power management IC + +maintainers: + - Qianhui Xu <[email protected]> + +description: > + The WL2868C is a camera power management IC with seven programmable LDOs. + LDO1 and LDO2 share the VIN12 input and cover 0.496 V to 1.512 V; LDO3 and + LDO4 share VIN34, and LDO5 to LDO7 have one input each, covering 1.504 V to + 3.544 V. All outputs are programmable in 8 mV steps. + + VIN7 and VSYS feed the internal control logic, which is powered from the + higher of the two, so at least one of them has to be connected. The other + inputs only feed LDOs, so an input may be left unconnected on a board that + does not use the outputs it feeds, which is why they are not mandatory. + +properties: + compatible: + const: willsemi,wl2868c + + reg: + maxItems: 1 + + reset-gpios: + maxItems: 1 + description: Active-low RST_N input. + + vin12-supply: + description: Input supply for LDO1 and LDO2. + + vin34-supply: + description: Input supply for LDO3 and LDO4. + + vin5-supply: + description: Input supply for LDO5. + + vin6-supply: + description: Input supply for LDO6. + + vin7-supply: + description: > + Input supply for LDO7 and one of the two supplies of the internal + control logic. + + vsys-supply: + description: > + System supply, the other supply of the internal control logic. The + control logic is powered from the higher of VIN7 and VSYS. + + regulators: + type: object + additionalProperties: false + + patternProperties: + "^ldo[1-7]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + +required: + - compatible + - reg + - regulators + +anyOf: + - required: + - vin7-supply + - required: + - vsys-supply + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@2f { + compatible = "willsemi,wl2868c"; + reg = <0x2f>; + vsys-supply = <&vreg_vsys>; + vin12-supply = <&vreg_vin12>; + + regulators { + ldo1 { + regulator-max-microvolt = <1128000>; + regulator-min-microvolt = <1128000>; + }; + }; + }; + }; +...
MAINTAINERS +6 -0
@@ -29058,6 +29058,12 @@ L: [email protected] S: Maintained F: drivers/hid/hid-wiimote* +WILLSEMI WL2868C CAMERA PMIC +M: Qianhui Xu <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/regulator/willsemi,wl2868c.yaml + WILOCITY WIL6210 WIRELESS DRIVER L: [email protected] S: Orphan
Signature · 1 line
2.53.0
PATCH v11 2/2 regulator: willsemi,wl2868c: add the WL2868C camera PMIC driver
In reply to Qianhui XuThe WL2868C is an I2C camera power management IC with seven LDOs. LDO1 and LDO2 are fed from VIN12 and cover 0.496 V to 1.512 V with a 7-bit voltage selector; LDO3 and LDO4 share VIN34, and LDO5 to LDO7 have one input each, covering 1.504 V to 3.544 V with an 8-bit selector. All outputs step by 8 mV.
Every output is gated by a per-LDO bit in the enable register, and the whole chip is additionally gated by the SYS_EN bit in the same register. The driver sets SYS_EN together with the LDO bit on enable and requires both to read back before reporting the regulator as enabled, because no output comes up while SYS_EN is clear. An optional active-low RST_N GPIO starts asserted, is released only after the control supply is up, followed by a delay for the device to come up, and is asserted again before the supply is disabled on unbind.
The enable register is written as a whole rather than updated bit by
bit: the per-LDO bits can be preset by the firmware while SYS_EN is clear, and setting SYS_EN together with a single LDO bit would then switch the preset outputs on as well. The driver therefore tracks the set of LDOs enabled by consumers and writes exactly those bits, so enabling one output cannot power another one. That set is seeded from the register during probe, but only when SYS_EN is already set: with SYS_EN clear the per-LDO bits are presets for outputs that are off, and seeding them would make the first enable() of one output switch all of them on. disable() commits the tracked state only after the register write went through, so a failed write cannot make a later enable() switch off an output that the core still believes is on.
The control logic and the I2C interface are powered from the higher of VIN7 and VSYS. The driver enables VSYS, falling back to VIN7 on boards that do not describe VSYS, and keeps it enabled for as long as it is
bound: without it the device does not answer on the bus. The device ID is read only after the control supply is up and RST_N has been released.
The LDOx_SEQ fields also have to be taken over: a non-zero slot moves that output from the LDOx_EN bit to the power-up sequencer, and writes to the enable register then have no effect on it (datasheet WL2868C Rev 1.4, "0x0A, 0x0B, 0x0C and 0x0D: LDOx_SEQ", p.35). The binding describes no sequencing, so the driver clears the four slot registers during probe and keeps the enable register as the only control path; otherwise enable() and disable() would silently do nothing for an output a slot had claimed. The reset value is 0 and no known board programs it, but firmware runs before us and may.
--- MAINTAINERS | 1 + drivers/regulator/Kconfig | 11 + drivers/regulator/Makefile | 1 + drivers/regulator/wl2868c-regulator.c | 301 ++++++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 drivers/regulator/wl2868c-regulator.c
MAINTAINERS +1 -0
@@ -29063,6 +29063,7 @@ M: Qianhui Xu <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/regulator/willsemi,wl2868c.yaml +F: drivers/regulator/wl2868c-regulator.c WILOCITY WIL6210 WIRELESS DRIVER L: [email protected]
drivers/regulator/Kconfig +11 -0
@@ -1851,6 +1851,17 @@ config REGULATOR_VQMMC_IPQ4019 This driver provides support for the VQMMC LDO I/0 voltage regulator of the IPQ4019 SD/EMMC controller. +config REGULATOR_WL2868C + tristate "Will Semiconductor WL2868C regulator" + depends on I2C + select REGMAP_I2C + help + Support the seven LDO outputs of the Will Semiconductor WL2868C + camera power management IC. + + To compile this driver as a module, choose M here: the + module will be called wl2868c-regulator. + config REGULATOR_WM831X tristate "Wolfson Microelectronics WM831x PMIC regulators" depends on MFD_WM831X
drivers/regulator/Makefile +1 -0
@@ -211,6 +211,7 @@ obj-$(CONFIG_REGULATOR_RZG2L_VBCTRL) += renesas-usb-vbus-regulator.o obj-$(CONFIG_REGULATOR_VCTRL) += vctrl-regulator.o obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress-regulator.o obj-$(CONFIG_REGULATOR_VQMMC_IPQ4019) += vqmmc-ipq4019-regulator.o +obj-$(CONFIG_REGULATOR_WL2868C) += wl2868c-regulator.o obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
drivers/regulator/wl2868c-regulator.c new file +301 -0
301 lines not on this page · raw message
Signature · 1 line
2.53.0