arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
Subsystems (5)
v3 cover arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
The Qualcomm PM8008 PMIC is a so called QPNP PMIC with seven LDO regulators, a temperature alarm block and two GPIO pins (which are also used for interrupt signalling and reset).
Unlike previous QPNP PMICs it uses an I2C rather than SPMI interface, which has implications for how interrupts are handled.
A previous attempt by Qualcomm to upstream support for PM8008 stalled two years ago at version 15 after a lot of back and forth discussion on how best to describe this device in the devicetree. [1]
After reviewing the backstory on this and surveying the current SPMI PMIC bindings and implementation, I opted for a new approach that does not describe internal details like register offsets and interrupts in the devicetree.
The original decision to include registers offsets and internal interrupts for SPMI PMICs has led to a number of PMIC dtsi being created to avoid copying lots of boiler plate declarations. This in turn causes trouble when the PMIC USID address is configurable as the address is included in every interrupt specifier.
The current SPMI bindings still do not describe the devices fully and additional data is therefore already provided by drivers (e.g. additional register blocks, supplies, additional interrupt specifiers).
The fact that PMICs which use two USIDs (addresses) are modelled as two separate devices causes trouble, for example, when there are dependencies between subfunctions. [2]
Subfunctions also do not necessarily map neatly onto the 256-register block partitioning of the SPMI register space, something which has lead to unresolved inconsistencies in how functions like PWM are described.
[3]
In short, it's a bit of a mess.
With the new style of bindings, by contrast, only essential information that actually differs between machines would be included in the devicetree. The bindings would also be mostly decoupled from the implementation, which has started to leak out into the binding (e.g. how the QPNP interrupts are handled). This also allows for extending the implementation without having to update the binding, which is especially important as Qualcomm does not publish any documentation (e.g. to later enable regulator over-current protection).
Some PMICs support both I2C and SPMI interfaces (e.g. PM8010) and we want to be able to reuse the same bindings regardless of the interface.
As a proof concept I have written a new pmc8280 driver for one of the SPMI PMICs in the Lenovo ThinkPad X13s that uses the new style of bindings and I've been using that one to control backlight and peripheral regulators for a while now. Specifically, the gpio and temperature-alarm blocks can be used with some minor updates to the current drivers.
That work still needs a bit of polish before posting, but my working PoC means that I'm confident enough that the new model will work and that we can go ahead and merge regulator support for the PM8008.
This series is specifically needed for the camera sensors in the X13s, for which camera subsystem (camss) support has now been merged for 6.10.
The first seven patches are preparatory and can possibly be merged separately from the rest of the series. The next two patches drop the broken GPIO support for PM8008 which had already been upstreamed (dropped in v3). The last five patches rework the binding and MFD driver, add support for the regulators and enable the camera PMIC on the X13s.
Johan
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/lkml/[email protected]
[3] https://lore.kernel.org/r/[email protected]
Changes in v3
- capitalise MFD commit summaries
- drop pinctrl patches which have been applied for 6.10
- amend binding commit message to clarify that the binding is unused
- move pinctrl subschema under pinctrl node in binding
Changes in v2
- use IRQ_TYPE_SENSE_MASK in regmap_irq table
- add post-reset delay
- reorder pinctrl binding and driver update
- split out binding cleanups
- use platform_device_id matching
- replace underscore in supply names with dash
- use more fine-grained includes in regulator driver
- rework regulator driver and update authorship
Johan Hovold (12):
dt-bindings: mfd: pm8008: Add reset gpio
mfd: pm8008: Fix regmap irq chip initialisation
mfd: pm8008: Deassert reset on probe
mfd: pm8008: Mark regmap structures as const
mfd: pm8008: Use lower case hex notation
mfd: pm8008: Rename irq chip
mfd: pm8008: Drop unused driver data
dt-bindings: mfd: pm8008: Drop redundant descriptions
dt-bindings: mfd: pm8008: Rework binding
mfd: pm8008: Rework to match new DT binding
regulator: add pm8008 pmic regulator driver
arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
.../devicetree/bindings/mfd/qcom,pm8008.yaml | 144 +++++++------ .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 123 +++++++++++ drivers/mfd/Kconfig | 1 + drivers/mfd/qcom-pm8008.c | 169 ++++++++++----- drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-pm8008-regulator.c | 198 ++++++++++++++++++ include/dt-bindings/mfd/qcom-pm8008.h | 19 -- 8 files changed, 532 insertions(+), 130 deletions(-) create mode 100644 drivers/regulator/qcom-pm8008-regulator.c delete mode 100644 include/dt-bindings/mfd/qcom-pm8008.h
Signature · 1 line
2.44.1
PATCH v3 1/12 dt-bindings: mfd: pm8008: Add reset gpio
Describe the optional reset gpio (which may not be wired up).
--- Documentation/devicetree/bindings/mfd/qcom,pm8008.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/mfd/qcom,pm8008.yaml +6 -0
@@ -29,6 +29,9 @@ properties: description: Parent interrupt. + reset-gpios: + maxItems: 1 + "#interrupt-cells": const: 2
@@ -97,6 +100,7 @@ additionalProperties: false examples: - | + #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/mfd/qcom-pm8008.h> #include <dt-bindings/interrupt-controller/irq.h>
@@ -115,6 +119,8 @@ examples: interrupt-parent = <&tlmm>; interrupts = <32 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&tlmm 42 GPIO_ACTIVE_LOW>; + pm8008_gpios: gpio@c000 { compatible = "qcom,pm8008-gpio", "qcom,spmi-gpio"; reg = <0xc000>;
Signature · 1 line
2.44.1
PATCH v3 2/12 mfd: pm8008: Fix regmap irq chip initialisation
In reply to Johan HovoldThe regmap irq array is potentially shared between multiple PMICs and should only contain static data.
Use a custom macro to initialise also the type fields and drop the unnecessary updates on each probe.
--- drivers/mfd/qcom-pm8008.c | 64 ++++++++++++++------------------------- 1 file changed, 23 insertions(+), 41 deletions(-)
drivers/mfd/qcom-pm8008.c +23 -41
@@ -56,15 +56,25 @@ static unsigned int pm8008_config_regs[] = { INT_POL_LOW_OFFSET, }; -static struct regmap_irq pm8008_irqs[] = { -REGMAP_IRQ_REG (PM8008_IRQ_MISC_UVLO ,PM8008_MISC ,BIT (0 )), -REGMAP_IRQ_REG (PM8008_IRQ_MISC_OVLO ,PM8008_MISC ,BIT (1 )), -REGMAP_IRQ_REG (PM8008_IRQ_MISC_OTST2 ,PM8008_MISC ,BIT (2 )), -REGMAP_IRQ_REG (PM8008_IRQ_MISC_OTST3 ,PM8008_MISC ,BIT (3 )), -REGMAP_IRQ_REG (PM8008_IRQ_MISC_LDO_OCP ,PM8008_MISC ,BIT (4 )), -REGMAP_IRQ_REG (PM8008_IRQ_TEMP_ALARM ,PM8008_TEMP_ALARM ,BIT (0 )), -REGMAP_IRQ_REG (PM8008_IRQ_GPIO1 ,PM8008_GPIO1 ,BIT (0 )), -REGMAP_IRQ_REG (PM8008_IRQ_GPIO2 ,PM8008_GPIO2 ,BIT (0 )), +#define _IRQ (_irq, _off, _mask, _types) \ + [_irq] = { \ + .reg_offset = (_off), \ + .mask = (_mask), \ + .type = { \ + .type_reg_offset = (_off), \ + .types_supported = (_types), \ + }, \ + } + +static const struct regmap_irq pm8008_irqs[] = { +_IRQ (PM8008_IRQ_MISC_UVLO ,PM8008_MISC ,BIT (0 ),IRQ_TYPE_EDGE_RISING ), +_IRQ (PM8008_IRQ_MISC_OVLO ,PM8008_MISC ,BIT (1 ),IRQ_TYPE_EDGE_RISING ), +_IRQ (PM8008_IRQ_MISC_OTST2 ,PM8008_MISC ,BIT (2 ),IRQ_TYPE_EDGE_RISING ), +_IRQ (PM8008_IRQ_MISC_OTST3 ,PM8008_MISC ,BIT (3 ),IRQ_TYPE_EDGE_RISING ), +_IRQ (PM8008_IRQ_MISC_LDO_OCP ,PM8008_MISC ,BIT (4 ),IRQ_TYPE_EDGE_RISING ), +_IRQ (PM8008_IRQ_TEMP_ALARM ,PM8008_TEMP_ALARM ,BIT (0 ),IRQ_TYPE_SENSE_MASK ), +_IRQ (PM8008_IRQ_GPIO1 ,PM8008_GPIO1 ,BIT (0 ),IRQ_TYPE_SENSE_MASK ), +_IRQ (PM8008_IRQ_GPIO2 ,PM8008_GPIO2 ,BIT (0 ),IRQ_TYPE_SENSE_MASK ), };static const unsigned int pm8008_periph_base[] = {
@@ -143,38 +153,9 @@ static struct regmap_config qcom_mfd_regmap_cfg = { .max_register = 0xFFFF, }; -static int pm8008_probe_irq_peripherals (struct device *dev, -struct regmap *regmap, -int client_irq) -{ -int rc, i; -struct regmap_irq_type *type; -struct regmap_irq_chip_data *irq_data; - -for (i =0 ; i <ARRAY_SIZE (pm8008_irqs); i++) { - type = &pm8008_irqs[i].type; - - type->type_reg_offset = pm8008_irqs[i].reg_offset; - -if (type->type_reg_offset ==PM8008_MISC ) - type->types_supported =IRQ_TYPE_EDGE_RISING ; -else - type->types_supported = (IRQ_TYPE_EDGE_BOTH | -IRQ_TYPE_LEVEL_HIGH |IRQ_TYPE_LEVEL_LOW ); - } - - rc =devm_regmap_add_irq_chip (dev, regmap, client_irq, -IRQF_SHARED ,0 , &pm8008_irq_chip, &irq_data); -if (rc) { -dev_err (dev,"Failed to add IRQ chip: %d\n" , rc); -return rc; - } - -return 0 ; -} -static int pm8008_probe (struct i2c_client *client) { +struct regmap_irq_chip_data *irq_data;int rc;struct device *dev;struct regmap *regmap;
@@ -187,9 +168,10 @@ static int pm8008_probe(struct i2c_client *client)i2c_set_clientdata (client, regmap);if (of_property_read_bool (dev->of_node,"interrupt-controller" )) { - rc =pm8008_probe_irq_peripherals (dev, regmap, client->irq); + rc =devm_regmap_add_irq_chip (dev, regmap, client->irq, +IRQF_SHARED ,0 , &pm8008_irq_chip, &irq_data);if (rc) -dev_err (dev,"Failed to probe irq periphs: %d\n" , rc); +dev_err (dev,"failed to add IRQ chip: %d\n" , rc); }return devm_of_platform_populate (dev);
Signature · 1 line
2.44.1
PATCH v3 3/12 mfd: pm8008: Deassert reset on probe
In reply to Johan HovoldRequest and deassert any (optional) reset gpio during probe in case it has been left asserted by the boot firmware.
Note the reset line is not asserted to avoid reverting to the default I2C address in case the firmware has configured an alternate address.
--- drivers/mfd/qcom-pm8008.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/mfd/qcom-pm8008.c +12 -0
@@ -4,6 +4,7 @@*/ #include <linux/bitops.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -156,6 +157,7 @@ static struct regmap_config qcom_mfd_regmap_cfg = {static int pm8008_probe (struct i2c_client *client) {struct regmap_irq_chip_data *irq_data; +struct gpio_desc *reset;int rc;struct device *dev;struct regmap *regmap;
@@ -167,6 +169,16 @@ static int pm8008_probe(struct i2c_client *client)i2c_set_clientdata (client, regmap); + reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW ); +if (IS_ERR (reset)) +return PTR_ERR (reset); + +/* +* The PMIC does not appear to require a post-reset delay, but wait +* for a millisecond for now anyway. +*/ +usleep_range (1000 ,2000 ); +if (of_property_read_bool (dev->of_node,"interrupt-controller" )) { rc =devm_regmap_add_irq_chip (dev, regmap, client->irq,IRQF_SHARED ,0 , &pm8008_irq_chip, &irq_data);
Signature · 1 line
2.44.1
PATCH v3 4/12 mfd: pm8008: Mark regmap structures as const
In reply to Johan HovoldThe regmap irq chip structures can be const so mark them as such.
--- drivers/mfd/qcom-pm8008.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/qcom-pm8008.c +2 -2
@@ -51,7 +51,7 @@ enum { POLARITY_LO_INDEX, }; -static unsigned int pm8008_config_regs[] = { +static const unsigned int pm8008_config_regs[] = {INT_SET_TYPE_OFFSET ,INT_POL_HIGH_OFFSET ,INT_POL_LOW_OFFSET ,
@@ -129,7 +129,7 @@ static int pm8008_set_type_config(unsigned int **buf, unsigned int type,return 0 ; } -static struct regmap_irq_chip pm8008_irq_chip = { +static const struct regmap_irq_chip pm8008_irq_chip = { .name ="pm8008_irq" , .main_status =I2C_INTR_STATUS_BASE , .num_main_regs =1 ,
Signature · 1 line
2.44.1
PATCH v3 5/12 mfd: pm8008: Use lower case hex notation
In reply to Johan HovoldUse lower case hex notation for consistency.
--- drivers/mfd/qcom-pm8008.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mfd/qcom-pm8008.c +3 -3
@@ -38,8 +38,8 @@ enum {#define PM8008_PERIPH_0_BASE 0x900#define PM8008_PERIPH_1_BASE 0x2400 -#define PM8008_PERIPH_2_BASE 0xC000 -#define PM8008_PERIPH_3_BASE 0xC100 +#define PM8008_PERIPH_2_BASE 0xc000 +#define PM8008_PERIPH_3_BASE 0xc100#define PM8008_TEMP_ALARM_ADDR PM8008_PERIPH_1_BASE#define PM8008_GPIO1_ADDR PM8008_PERIPH_2_BASE
@@ -151,7 +151,7 @@ static const struct regmap_irq_chip pm8008_irq_chip = {static struct regmap_config qcom_mfd_regmap_cfg = { .reg_bits =16 , .val_bits =8 , - .max_register =0xFFFF , + .max_register =0xffff , };static int pm8008_probe (struct i2c_client *client)
Signature · 1 line
2.44.1
PATCH v3 6/12 mfd: pm8008: Rename irq chip
In reply to Johan HovoldDrop the redundant "irq" suffix from the irq chip name.
--- drivers/mfd/qcom-pm8008.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/qcom-pm8008.c +1 -1
@@ -130,7 +130,7 @@ static int pm8008_set_type_config(unsigned int **buf, unsigned int type, }static const struct regmap_irq_chip pm8008_irq_chip = { - .name ="pm8008_irq" , + .name ="pm8008" , .main_status =I2C_INTR_STATUS_BASE , .num_main_regs =1 , .irqs = pm8008_irqs,
Signature · 1 line
2.44.1
PATCH v3 7/12 mfd: pm8008: Drop unused driver data
In reply to Johan HovoldThe i2c client driver data pointer has never been used so drop the unnecessary assignment.
--- drivers/mfd/qcom-pm8008.c | 2 -- 1 file changed, 2 deletions(-)
drivers/mfd/qcom-pm8008.c +0 -2
@@ -167,8 +167,6 @@ static int pm8008_probe(struct i2c_client *client)if (IS_ERR (regmap))return PTR_ERR (regmap); -i2c_set_clientdata (client, regmap); - reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW );if (IS_ERR (reset))return PTR_ERR (reset);
Signature · 1 line
2.44.1
PATCH v3 8/12 dt-bindings: mfd: pm8008: Drop redundant descriptions
In reply to Johan HovoldIn preparation for reworking the binding, drop the redundant descriptions of the standard 'reg' and 'interrupts' properties.
--- Documentation/devicetree/bindings/mfd/qcom,pm8008.yaml | 5 ----- 1 file changed, 5 deletions(-)
Documentation/devicetree/bindings/mfd/qcom,pm8008.yaml +0 -5
@@ -19,16 +19,11 @@ properties: const: qcom,pm8008 reg: - description: - I2C slave address. - maxItems: 1 interrupts: maxItems: 1 - description: Parent interrupt. - reset-gpios: maxItems: 1
Signature · 1 line
2.44.1
PATCH v3 9/12 dt-bindings: mfd: pm8008: Rework binding
In reply to Johan HovoldRework the pm8008 binding, which is currently unused, by dropping internal details like register offsets and interrupts and by adding the missing regulator and temperature alarm properties.
Note that child nodes are still used for pinctrl and regulator configuration.
Also note that the pinctrl state definition will be extended later and could eventually also be shared with other PMICs (e.g. by breaking out bits of qcom,pmic-gpio.yaml).
--- .../devicetree/bindings/mfd/qcom,pm8008.yaml | 135 +++++++++++------- 1 file changed, 80 insertions(+), 55 deletions(-)
Documentation/devicetree/bindings/mfd/qcom,pm8008.yaml +80 -55
@@ -27,103 +27,128 @@ properties: reset-gpios: maxItems: 1 - "#interrupt-cells": + vdd-l1-l2-supply: true + vdd-l3-l4-supply: true + vdd-l5-supply: true + vdd-l6-supply: true + vdd-l7-supply: true + + gpio-controller: true + + "#gpio-cells": const: 2 - description: | - The first cell is the IRQ number, the second cell is the IRQ trigger - flag. All interrupts are listed in include/dt-bindings/mfd/qcom-pm8008.h. + gpio-ranges: + maxItems: 1 interrupt-controller: true - "#address-cells": - const: 1 + "#interrupt-cells": + const: 2 - "#size-cells": + "#thermal-sensor-cells": const: 0 -patternProperties: - "^gpio@[0-9a-f]+$": + pinctrl: type: object + additionalProperties: false + patternProperties: + "-state$": + type: object - description: | - The GPIO peripheral. This node may be specified twice, one for each GPIO. - - properties: - compatible: - items: - - const: qcom,pm8008-gpio - - const: qcom,spmi-gpio - - reg: - description: Peripheral address of one of the two GPIO peripherals. - maxItems: 1 - - gpio-controller: true - - gpio-ranges: - maxItems: 1 + allOf: + - $ref: /schemas/pinctrl/pinmux-node.yaml + - $ref: /schemas/pinctrl/pincfg-node.yaml - interrupt-controller: true + properties: + pins: + items: + pattern: "^gpio[12]$" - "#interrupt-cells": - const: 2 + function: + items: + - enum: + - normal - "#gpio-cells": - const: 2 + required: + - pins + - function - required: - - compatible - - reg - - gpio-controller - - interrupt-controller - - "#gpio-cells" - - gpio-ranges - - "#interrupt-cells" + additionalProperties: false + regulators: + type: object additionalProperties: false + patternProperties: + "^ldo[1-7]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false required: - compatible - reg - interrupts - - "#address-cells" - - "#size-cells" + - vdd-l1-l2-supply + - vdd-l3-l4-supply + - vdd-l5-supply + - vdd-l6-supply + - vdd-l7-supply + - gpio-controller + - "#gpio-cells" + - gpio-ranges + - interrupt-controller - "#interrupt-cells" + - "#thermal-sensor-cells" additionalProperties: false examples: - | #include <dt-bindings/gpio/gpio.h> - #include <dt-bindings/mfd/qcom-pm8008.h> #include <dt-bindings/interrupt-controller/irq.h> i2c { #address-cells = <1>; #size-cells = <0>; - pmic@8 { + pm8008: pmic@8 { compatible = "qcom,pm8008"; reg = <0x8>; - #address-cells = <1>; - #size-cells = <0>; - interrupt-controller; - #interrupt-cells = <2>; interrupt-parent = <&tlmm>; interrupts = <32 IRQ_TYPE_EDGE_RISING>; reset-gpios = <&tlmm 42 GPIO_ACTIVE_LOW>; - pm8008_gpios: gpio@c000 { - compatible = "qcom,pm8008-gpio", "qcom,spmi-gpio"; - reg = <0xc000>; - gpio-controller; - gpio-ranges = <&pm8008_gpios 0 0 2>; - #gpio-cells = <2>; - interrupt-controller; - #interrupt-cells = <2>; + vdd-l1-l2-supply = <&vreg_s8b_1p2>; + vdd-l3-l4-supply = <&vreg_s1b_1p8>; + vdd-l5-supply = <&vreg_bob>; + vdd-l6-supply = <&vreg_bob>; + vdd-l7-supply = <&vreg_bob>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pm8008 0 0 2>; + + interrupt-controller; + #interrupt-cells = <2>; + + #thermal-sensor-cells = <0>; + + pinctrl { + gpio-keys-state { + pins = "gpio1"; + function = "normal"; + }; + }; + + regulators { + ldo1 { + regulator-name = "vreg_l1"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1300000>; + }; }; }; };
Signature · 1 line
2.44.1
Re: [PATCH v3 09/12] dt-bindings: mfd: pm8008: Rework binding
Quoted 7 lines · Johan Hovold
Rework the pm8008 binding, which is currently unused, by dropping internal details like register offsets and interrupts and by adding the missing regulator and temperature alarm properties.
Note that child nodes are still used for pinctrl and regulator configuration.
Quoted 9 lines
Also note that the pinctrl state definition will be extended later and could eventually also be shared with other PMICs (e.g. by breaking out bits of qcom,pmic-gpio.yaml).
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/mfd/qcom,pm8008.yaml | 135 +++++++++++------- 1 file changed, 80 insertions(+), 55 deletions(-)
PATCH v3 10/12 mfd: pm8008: Rework to match new DT binding
In reply to Johan HovoldRework the pm8008 driver to match the new devicetree binding which no longer describes internal details like interrupts and register offsets (including which of the two consecutive I2C addresses the registers belong to).
Instead make the interrupt controller implementation internal and pass interrupts to the subdrivers using MFD cell resources.
Note that subdrivers may either get their resources, like register block offsets, from the parent MFD or this can be included in the subdrivers directly.
In the current implementation, the temperature alarm driver is generic enough to just get its base address and alarm interrupt from the parent driver, which already uses this information to implement the interrupt controller.
The regulator driver, however, needs additional information like parent supplies and regulator characteristics so in that case it is easier to just augment its table with the regulator register base addresses.
Similarly, the current GPIO driver already holds the number of pins and that lookup table can therefore also be extended with register offsets.
Note that subdrivers can now access the two regmaps by name, even if the primary regmap is registered last so that it is returned by default when no name is provided in lookups.
Finally, note that the temperature alarm and GPIO subdrivers need some minor rework before they can be used with non-SPMI devices like the PM8008. The temperature alarm MFD cell name specifically uses a "qpnp" rather than "spmi" prefix to prevent binding until the driver has been updated.
--- drivers/mfd/Kconfig | 1 + drivers/mfd/qcom-pm8008.c | 97 +++++++++++++++++++++++---- include/dt-bindings/mfd/qcom-pm8008.h | 19 ------ 3 files changed, 86 insertions(+), 31 deletions(-) delete mode 100644 include/dt-bindings/mfd/qcom-pm8008.h
drivers/mfd/Kconfig +1 -0
@@ -2208,6 +2208,7 @@ config MFD_ACER_A500_EC config MFD_QCOM_PM8008 tristate "QCOM PM8008 Power Management IC" depends on I2C && OF + select MFD_CORE select REGMAP_I2C select REGMAP_IRQ help
drivers/mfd/qcom-pm8008.c +85 -12
142 lines not on this page · raw message
include/dt-bindings/mfd/qcom-pm8008.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (c) 2021 The Linux Foundation. All rights reserved. -*/ - -#ifndef __DT_BINDINGS_MFD_QCOM_PM8008_H -#define __DT_BINDINGS_MFD_QCOM_PM8008_H - -/* PM8008 IRQ numbers */ -#define PM8008_IRQ_MISC_UVLO 0 -#define PM8008_IRQ_MISC_OVLO 1 -#define PM8008_IRQ_MISC_OTST2 2 -#define PM8008_IRQ_MISC_OTST3 3 -#define PM8008_IRQ_MISC_LDO_OCP 4 -#define PM8008_IRQ_TEMP_ALARM 5 -#define PM8008_IRQ_GPIO1 6 -#define PM8008_IRQ_GPIO2 7 - -#endif
Signature · 1 line
2.44.1
PATCH v3 11/12 regulator: add pm8008 pmic regulator driver
In reply to Johan HovoldThe Qualcomm PM8008 is an I2C-controlled PMIC containing seven LDO regulators.
The driver is based on a driver submitted by Satya Priya, but it has been cleaned up and reworked to match the new devicetree binding which no longer describes each regulator as a separate device.
This avoids describing internal details like register offsets in the devicetree and allows for extending the implementation with features like over-current protection without having to update the binding.
Specifically note that the regulator interrupts are shared between all regulators.
Note that the secondary regmap is looked up by name and that if the driver ever needs to be generalised to support regulators provided by the primary regmap (I2C address) such information could be added to the device-id table.
This also fixes the original implementation, which looked up regulators by 'regulator-name' property rather than devicetree node name and which prevented the regulators from being named to match board schematics.
--- drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-pm8008-regulator.c | 198 ++++++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 drivers/regulator/qcom-pm8008-regulator.c
drivers/regulator/Kconfig +7 -0
@@ -1027,6 +1027,13 @@ config REGULATOR_PWM This driver supports PWM controlled voltage regulators. PWM duty cycle can increase or decrease the voltage. +config REGULATOR_QCOM_PM8008 + tristate "Qualcomm PM8008 PMIC regulators" + depends on MFD_QCOM_PM8008 + help + Select this option to enable support for the voltage regulators in + Qualcomm PM8008 PMICs. + config REGULATOR_QCOM_REFGEN tristate "Qualcomm REFGEN regulator driver" depends on ARCH_QCOM || COMPILE_TEST
drivers/regulator/Makefile +1 -0
@@ -112,6 +112,7 @@ obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_MTK_DVFSRC) += mtk-dvfsrc-regulator.o obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o +obj-$(CONFIG_REGULATOR_QCOM_PM8008) += qcom-pm8008-regulator.o obj-$(CONFIG_REGULATOR_QCOM_REFGEN) += qcom-refgen-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o
drivers/regulator/qcom-pm8008-regulator.c new file +198 -0
198 lines not on this page · raw message
Signature · 1 line
2.44.1
Re: [PATCH v3 11/12] regulator: add pm8008 pmic regulator driver
Quoted 6 lines · Johan Hovold
The Qualcomm PM8008 is an I2C-controlled PMIC containing seven LDO regulators.
The driver is based on a driver submitted by Satya Priya, but it has been cleaned up and reworked to match the new devicetree binding which no longer describes each regulator as a separate device.
PATCH v3 12/12 arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
In reply to Johan HovoldEnable the PM8008 PMIC which is used to power the camera sensors.
--- .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+)
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +123 -0
@@ -297,6 +297,27 @@ linux,cma { }; thermal-zones { + pm8008-thermal { + polling-delay-passive = <100>; + polling-delay = <0>; + + thermal-sensors = <&pm8008>; + + trips { + trip0 { + temperature = <95000>; + hysteresis = <0>; + type = "passive"; + }; + + trip1 { + temperature = <115000>; + hysteresis = <0>; + type = "critical"; + }; + }; + }; + skin-temp-thermal { polling-delay-passive = <250>; polling-delay = <0>;
@@ -671,6 +692,85 @@ touchscreen@10 { }; }; +&i2c11 { + clock-frequency = <400000>; + + pinctrl-names = "default"; + pinctrl-0 = <&i2c11_default>; + + status = "okay"; + + pm8008: pmic@c { + compatible = "qcom,pm8008"; + reg = <0xc>; + + interrupts-extended = <&tlmm 41 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&tlmm 42 GPIO_ACTIVE_LOW>; + + vdd-l1-l2-supply = <&vreg_s11b>; + vdd-l3-l4-supply = <&vreg_bob>; + vdd-l5-supply = <&vreg_bob>; + vdd-l6-supply = <&vreg_bob>; + vdd-l7-supply = <&vreg_bob>; + + pinctrl-names = "default"; + pinctrl-0 = <&pm8008_default>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pm8008 0 0 2>; + + interrupt-controller; + #interrupt-cells = <2>; + + #thermal-sensor-cells = <0>; + + regulators { + vreg_l1q: ldo1 { + regulator-name = "vreg_l1q"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + vreg_l2q: ldo2 { + regulator-name = "vreg_l2q"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + vreg_l3q: ldo3 { + regulator-name = "vreg_l3q"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + vreg_l4q: ldo4 { + regulator-name = "vreg_l4q"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + vreg_l5q: ldo5 { + regulator-name = "vreg_l5q"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + vreg_l6q: ldo6 { + regulator-name = "vreg_l6q"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + vreg_l7q: ldo7 { + regulator-name = "vreg_l7q"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + }; + }; +}; + &i2c21 { clock-frequency = <400000>;
@@ -1361,6 +1461,13 @@ i2c4_default: i2c4-default-state { bias-disable; }; + i2c11_default: i2c11-default-state { + pins = "gpio18", "gpio19"; + function = "qup11"; + drive-strength = <16>; + bias-disable; + }; + i2c21_default: i2c21-default-state { pins = "gpio81", "gpio82"; function = "qup21";
@@ -1464,6 +1571,22 @@ wake-n-pins { }; }; + pm8008_default: pm8008-default-state { + int-pins { + pins = "gpio41"; + function = "gpio"; + drive-strength = <2>; + bias-pull-down; + }; + + reset-n-pins { + pins = "gpio42"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + }; + spkr_1_sd_n_default: spkr-1-sd-n-default-state { perst-n-pins { pins = "gpio178";
Signature · 1 line
2.44.1
Quoted 16 lines · Johan Hovold
Enable the PM8008 PMIC which is used to power the camera sensors.
Reviewed-by Bryan O'Donoghue <[email protected]>Tested-by Bryan O'Donoghue <[email protected]>Signed-off-by Johan Hovold <[email protected]>---
.../qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+)arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +0
-0
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts linux,cma { · line 302
Quoted 6 lines
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +3
-0@@ -297,6 +297,27 @@ linux,cma { }; thermal-zones { + pm8008-thermal { + polling-delay-passive = <100>; + polling-delay = <0>;
This single line can be dropped now
Konrad
Lee Jones
maintainerQuoted 3 lines · Johan Hovold
The Qualcomm PM8008 PMIC is a so called QPNP PMIC with seven LDO regulators, a temperature alarm block and two GPIO pins (which are also used for interrupt signalling and reset).
[...]
Quoted 38 lines
Johan
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/lkml/[email protected]
[3] https://lore.kernel.org/r/[email protected]Changes in v3
- capitalise MFD commit summaries
- drop pinctrl patches which have been applied for 6.10
- amend binding commit message to clarify that the binding is unused
- move pinctrl subschema under pinctrl node in bindingChanges in v2
- useIRQ_TYPE_SENSE_MASKinregmap_irqtable
- add post-reset delay
- reorder pinctrl binding and driver update
- split out binding cleanups
- useplatform_device_idmatching
- replace underscore in supply names with dash
- use more fine-grained includes in regulator driver
- rework regulator driver and update authorshipJohan Hovold (12):
dt-bindings: mfd: pm8008: Add reset gpio
mfd: pm8008: Fix regmap irq chip initialisation
mfd: pm8008: Deassert reset on probe
mfd: pm8008: Mark regmap structures as const
mfd: pm8008: Use lower case hex notation
mfd: pm8008: Rename irq chip
mfd: pm8008: Drop unused driver data
dt-bindings: mfd: pm8008: Drop redundant descriptions
dt-bindings: mfd: pm8008: Rework binding
mfd: pm8008: Rework to match new DT binding
regulator: add pm8008 pmic regulator driver
arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
Quoted 11 lines
.../devicetree/bindings/mfd/qcom,pm8008.yaml | 144 +++++++------ .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 123 +++++++++++ drivers/mfd/Kconfig | 1 + drivers/mfd/qcom-pm8008.c | 169 ++++++++++----- drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-pm8008-regulator.c | 198 ++++++++++++++++++ include/dt-bindings/mfd/qcom-pm8008.h | 19 -- 8 files changed, 532 insertions(+), 130 deletions(-) create mode 100644 drivers/regulator/qcom-pm8008-regulator.c delete mode 100644 include/dt-bindings/mfd/qcom-pm8008.h
Applied patches 1-11 and submitted for build testing.
Once complete, I'll get the pull-request out for Mark.
Signature · 1 line
Lee Jones [李琼斯]
Lee Jones
maintainer[GIT PULL] Immutable branch between MFD and Regulator due for the v6.10 merge window
In reply to Johan HovoldEnjoy!
The following changes since commit 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0:
Linux 6.10-rc1 (2024-05-26 15:20:12 -0700)
are available in the Git repository at:
ssh://[email protected]/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-regulator-pm8008-v6.10
for you to fetch changes up to 11d861d227ed1c4068597289267247aac5ac50fa:
regulator: add pm8008 pmic regulator driver (2024-06-13 18:42:21 +0100)
----------------------------------------------------------------
Immutable branch between MFD and Regulator due for the v6.10 merge window
----------------------------------------------------------------
Johan Hovold (11):
dt-bindings: mfd: pm8008: Add reset gpio
mfd: pm8008: Fix regmap irq chip initialisation
mfd: pm8008: Deassert reset on probe
mfd: pm8008: Mark regmap structures as const
mfd: pm8008: Use lower case hex notation
mfd: pm8008: Rename irq chip
mfd: pm8008: Drop unused driver data
dt-bindings: mfd: pm8008: Drop redundant descriptions
dt-bindings: mfd: pm8008: Rework binding
mfd: pm8008: Rework to match new DT binding
regulator: add pm8008 pmic regulator driver
.../devicetree/bindings/mfd/qcom,pm8008.yaml | 144 +++++++++------ drivers/mfd/Kconfig | 1 + drivers/mfd/qcom-pm8008.c | 169 ++++++++++++------ drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-pm8008-regulator.c | 198 +++++++++++++++++++++ include/dt-bindings/mfd/qcom-pm8008.h | 19 -- 7 files changed, 409 insertions(+), 130 deletions(-) create mode 100644 drivers/regulator/qcom-pm8008-regulator.c delete mode 100644 include/dt-bindings/mfd/qcom-pm8008.h
Signature · 1 line
Lee Jones [李琼斯]
Lee Jones
maintainerRe: [GIT PULL] Immutable branch between MFD and Regulator due for the v6.10 merge window
Quoted 9 lines · Lee Jones
Enjoy!
The following changes since commit
1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0:Linux 6.10-rc1 (2024-05-26 15:20:12 -0700)
are available in the Git repository at:
ssh://[email protected]/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-regulator-pm8008-v6.10
Whoa! We're en-route to v6.11 already.
Kill this one - I'll submit a new one.
Signature · 1 line
Lee Jones [李琼斯]
Lee Jones
maintainer[GIT v2 PULL] Immutable branch between MFD and Regulator due for the v6.11 merge window
In reply to Johan HovoldLet's try this again with the appropriate v6.11 based tag.
The following changes since commit 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0:
Linux 6.10-rc1 (2024-05-26 15:20:12 -0700)
are available in the Git repository at:
ssh://[email protected]/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-regulator-pm8008-v6.11
for you to fetch changes up to 11d861d227ed1c4068597289267247aac5ac50fa:
regulator: add pm8008 pmic regulator driver (2024-06-13 18:42:21 +0100)
----------------------------------------------------------------
Immutable branch between MFD and Regulator due for the v6.11 merge window
----------------------------------------------------------------
Johan Hovold (11):
dt-bindings: mfd: pm8008: Add reset gpio
mfd: pm8008: Fix regmap irq chip initialisation
mfd: pm8008: Deassert reset on probe
mfd: pm8008: Mark regmap structures as const
mfd: pm8008: Use lower case hex notation
mfd: pm8008: Rename irq chip
mfd: pm8008: Drop unused driver data
dt-bindings: mfd: pm8008: Drop redundant descriptions
dt-bindings: mfd: pm8008: Rework binding
mfd: pm8008: Rework to match new DT binding
regulator: add pm8008 pmic regulator driver
.../devicetree/bindings/mfd/qcom,pm8008.yaml | 144 +++++++++------ drivers/mfd/Kconfig | 1 + drivers/mfd/qcom-pm8008.c | 169 ++++++++++++------ drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-pm8008-regulator.c | 198 +++++++++++++++++++++ include/dt-bindings/mfd/qcom-pm8008.h | 19 -- 7 files changed, 409 insertions(+), 130 deletions(-) create mode 100644 drivers/regulator/qcom-pm8008-regulator.c delete mode 100644 include/dt-bindings/mfd/qcom-pm8008.h
Signature · 1 line
Lee Jones [李琼斯]
Re: (subset) [PATCH v3 00/12] arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
In reply to Johan HovoldQuoted 8 lines · Johan Hovold
The Qualcomm PM8008 PMIC is a so called QPNP PMIC with seven LDO regulators, a temperature alarm block and two GPIO pins (which are also used for interrupt signalling and reset).
Unlike previous QPNP PMICs it uses an I2C rather than SPMI interface, which has implications for how interrupts are handled.
[...]
Applied, thanks!
[01/12] dt-bindings: mfd: pm8008: Add reset gpio
commit: 0682cfa3325fefe8a3cb1c02854135ee73b8ae16
[02/12] mfd: pm8008: Fix regmap irq chip initialisation
commit: 6ad7f80b53251dbbca81e18a17cf6f8bcd34cb20
[03/12] mfd: pm8008: Deassert reset on probe
commit: c251befb097ef1ebb509d48bb3e1181b94fd4d2a
[04/12] mfd: pm8008: Mark regmap structures as const
commit: 742bdd99aa9acace13385b66c6f3946f26b109fe
[05/12] mfd: pm8008: Use lower case hex notation
commit: a4b3225f06e4f8fa7266236407ab7de34b66f044
[06/12] mfd: pm8008: Rename irq chip
commit: 3162cd961eba14fbb377d4f13c853c586cd5d063
[07/12] mfd: pm8008: Drop unused driver data
commit: 40ac32d19985836348313b7087c8f37232084c54
[08/12] dt-bindings: mfd: pm8008: Drop redundant descriptions
commit: 8643ef1213eeaf99ee529f35a6c2976ea1e316bc
[09/12] dt-bindings: mfd: pm8008: Rework binding
commit: 8c72db5884a3c821de6ba9c387c8fe52e13e5a34
[10/12] mfd: pm8008: Rework to match new DT binding
commit: 288b550463cf5dd21ad34f736b8c5ccb7ff69ceb
[11/12] regulator: add pm8008 pmic regulator driver
commit: 11d861d227ed1c4068597289267247aac5ac50fa--
Lee Jones [李琼斯]
Re: (subset) [PATCH v3 00/12] arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
In reply to Johan HovoldQuoted 8 lines · Johan Hovold
The Qualcomm PM8008 PMIC is a so called QPNP PMIC with seven LDO regulators, a temperature alarm block and two GPIO pins (which are also used for interrupt signalling and reset).
Unlike previous QPNP PMICs it uses an I2C rather than SPMI interface, which has implications for how interrupts are handled.
[...]
Applied, thanks!
[12/12] arm64: dts: qcom: sc8280xp-x13s: enable pm8008 camera pmic
commit: b5477d5f5272a079e2ddeffd00490528884f5aa5
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>