Re: [PATCH 4/6] mfd: max77759: add Maxim MAX77759 core mfd driver
Hi Christophe, Thanks for your review! On Mon, 2025-02-24 at 21:20 +0100, Christophe JAILLET wrote: > Le 24/02/2025 à 11:28, André Draszik a écrit : > > The Maxim MAX77759 is a companion Power Management IC for USB Type-C > > applications with Battery Charger, Fuel Gauge, temperature sensors, USB > > Type-C Port Controller (TCPC), NVMEM, and additional GPIO interfaces. > > > > Fuel Gauge and TCPC have separate and independent I2C addresses, > > register maps, and interrupt lines and are therefore excluded from the > > MFD core device driver here. > > > > The GPIO and NVMEM interfaces are accessed via specific commands to the > > built-in microprocessor. This driver implements an API that client > > drivers can use for accessing those. > > Hi, > > ... > > > +int max77759_maxq_command(struct max77759_mfd *max77759_mfd, > > + const struct max77759_maxq_command *cmd, > > + struct max77759_maxq_response *rsp) > > +{ > > + DEFINE_FLEX(struct max77759_maxq_response, _rsp, rsp, length, 1); > > + int ret; > > + static const unsigned int timeout_ms = 200; > > + > > + if (cmd->length > MAX77759_MAXQ_REG_AP_MESSAGESZ_MAX) > > + return -EINVAL; > > + > > + /* rsp is allowed to be NULL. In that case we do need a temporary. */ > > + if (!rsp) > > + rsp = _rsp; > > + > > + BUILD_BUG_ON(MAX77759_MAXQ_OPCODE_MAXLENGTH > > + != MAX77759_MAXQ_REG_AP_MESSAGESZ_MAX); > > + if (!rsp->length || rsp->length > MAX77759_MAXQ_REG_AP_MESSAGESZ_MAX) > > + return -EINVAL; > > + > > + guard(mutex)(&max77759_mfd->maxq_lock); > > + > > + reinit_completion(&max77759_mfd->cmd_done); > > + > > + /* write the opcode and data */ > > + ret = regmap_bulk_write(max77759_mfd->regmap_maxq, > > + MAX77759_MAXQ_REG_AP_DATAOUT0, cmd->cmd, > > + cmd->length); > > + if (!ret && cmd->length < MAX77759_MAXQ_REG_AP_MESSAGESZ_MAX) { > > + /* writing the last byte triggers MaxQ */ > > + ret = regmap_write(max77759_mfd->regmap_maxq, > > + MAX77759_MAXQ_REG_AP_DATAOUT32, 0); > > + } > > + if (ret) > > + dev_warn(regmap_get_device(max77759_mfd->regmap_maxq), > > Maybe regmap_get_device(max77759_mfd->regmap_maxq) could be assigned to > a variable to simplify its usage? Sure, can do. > > > +"write data failed: %d\n", ret); > > + if (ret) > > + return ret; > > Merge with the if (ret) just above? (as done a few lines below) Definitely, that was an oversight somehow :-( > > > + > > + /* wait for response from MaxQ */ > > + if (!wait_for_completion_timeout(&max77759_mfd->cmd_done, > > +usecs_to_jiffies(timeout_ms))) { > > + dev_err(regmap_get_device(max77759_mfd->regmap_maxq), > > + "timed out waiting for data\n"); > > + return -ETIMEDOUT; > > + } > > + > > + ret = regmap_bulk_read(max77759_mfd->regmap_maxq, > > + MAX77759_MAXQ_REG_AP_DATAIN0, > > + rsp->rsp, rsp->length); > > + if (ret) { > > + dev_warn(regmap_get_device(max77759_mfd->regmap_maxq), > > +"read data failed: %d\n", ret); > > + return ret; > > + } > > + > > + /* > > +* As per the protocol, the first byte of the reply will match the > > +* request. > > +*/ > > + if (rsp->rsp[0] != cmd->cmd[0]) { > > + dev_warn(regmap_get_device(max77759_mfd->regmap_maxq), > > +"unexpected opcode response for %#.2x: %*ph\n", > > +cmd->cmd[0], (int)rsp->length, rsp->rsp); > > + return -EIO; > > + } > > + > > + return 0; > > +} > > ... > > > +static int max77759_probe(struct i2c_client *client) > > +{ > > + struct regmap *regmap_top; > > + unsigned int pmic_id; > > + int ret; > > + struct irq_data *irq_data; > > + struct max77759_mfd *max77759_mfd; > > + unsigned long irq_flags; > > + struct regmap_irq_chip_data *irq_chip_data_pmic; > > + > > + regmap_top = devm_regmap_init_i2c(client, &max77759_regmap_config_top); > > + if (IS_ERR(regmap_top)) >
Re: [PATCH 2/6] dt-bindings: gpio: add max77759 binding
Hi Rob, On Mon, 2025-02-24 at 09:38 -0600, Rob Herring wrote: > On Mon, Feb 24, 2025 at 10:28:50AM +0000, André Draszik wrote: > > Add the DT binding document for the GPIO module of the Maxim MAX77759. > > > > Signed-off-by: André Draszik > > --- > > .../bindings/gpio/maxim,max77759-gpio.yaml | 47 > > ++ > > 1 file changed, 47 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml > > b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml > > new file mode 100644 > > index ..9bafb16ad688 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml > > @@ -0,0 +1,47 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/gpio/maxim,max77759-gpio.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Maxim Integrated MAX77759 GPIO > > + > > +maintainers: > > + - André Draszik > > + > > +description: | > > + This module is part of the MAX77759 PMIC. For additional information, see > > + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. > > + > > + The MAX77759 is a PMIC integrating, amongst others, a GPIO controller > > + including interrupt support for 2 GPIO lines. > > + > > +properties: > > + compatible: > > + const: maxim,max77759-gpio > > + > > + "#interrupt-cells": > > + const: 2 > > + > > + interrupt-controller: true > > + > > + interrupts: > > + maxItems: 2 > > You need to define what each interrupt is. I think maybe the interrupts property is not needed after all: The PMIC has one external interrupt line (described by the top-level device), and the two interrupts here are just a representation of the PMIC's internal status register (i.e. top level interrupt is raised when status register for one of the gpio lines changes, amongst other things). The intention is for a gpio driver to just treat and model them as cascaded interrupts, but they don't need to be configured in any way via device tree, as everything happens internally inside the PMIC, there is no board-dependent routing or trigger type possible. (Of course, there can be drivers subscribing to one (or both) of the two cascaded interrupts here, but that shouldn't matter I believe). Does that make sense? I added the property because Documentation/devicetree/bindings/interrupt-controller/interrupts.txt says it's a requirement to have an interrupts property, but I believe it doesn't actually apply in this case as there's nothing than can be configured. Am I missing something? Cheers, Andre' > > > + > > + "#gpio-cells": > > + const: 2 > > + > > + gpio-controller: true > > + > > + gpio-line-names: > > + minItems: 1 > > + maxItems: 2 > > + > > +required: > > + - compatible > > + - "#gpio-cells" > > + - gpio-controller > > + - "#interrupt-cells" > > + - interrupt-controller > > + > > +additionalProperties: false > > > > -- > > 2.48.1.658.g4767266eb4-goog > >
[PATCH 1/6] dt-bindings: mfd: add max77759 binding
Add device tree binding for the Maxim MAX77759 companion PMIC for USB Type-C applications. The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes the core mfd device. Signed-off-by: André Draszik --- .../devicetree/bindings/mfd/maxim,max77759.yaml| 104 + MAINTAINERS| 6 ++ 2 files changed, 110 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml new file mode 100644 index ..1efb841289fb --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications + +maintainers: + - André Draszik + +description: | + This is a part of device tree bindings for the MAX77759 companion Power + Management IC for USB Type-C applications. + + The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. + +properties: + compatible: +const: maxim,max77759 + + interrupts: +maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": +const: 2 + + gpio-controller: true + + "#gpio-cells": +const: 2 + + gpio: +$ref: /schemas/gpio/maxim,max77759-gpio.yaml + + reg: +maxItems: 1 + + pmic-nvmem: +$ref: /schemas/nvmem/maxim,max77759-nvmem.yaml + +required: + - compatible + - interrupts + - reg + +additionalProperties: false + +examples: + - | +#include + +i2c { +#address-cells = <1>; +#size-cells = <0>; + +pmic@66 { +compatible = "maxim,max77759"; +reg = <0x66>; +interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>; + +interrupt-controller; +#interrupt-cells = <2>; + +gpio { +compatible = "maxim,max77759-gpio"; + +gpio-controller; +#gpio-cells = <2>; + +interrupt-controller; +#interrupt-cells = <2>; +}; + +pmic-nvmem { +compatible = "maxim,max77759-nvmem"; + +nvmem-layout { +compatible = "fixed-layout"; +#address-cells = <1>; +#size-cells = <1>; + +reboot-mode@0 { +reg = <0x0 0x4>; +}; + +boot-reason@4 { +reg = <0x4 0x4>; +}; + +shutdown-user-flag@8 { +reg = <0x8 0x1>; +}; + +rsoc@10 { +reg = <0xa 0x2>; +}; +}; +}; +}; +}; diff --git a/MAINTAINERS b/MAINTAINERS index f076360ce3c6..f2c19a1b4c05 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14322,6 +14322,12 @@ F: Documentation/devicetree/bindings/mfd/maxim,max77714.yaml F: drivers/mfd/max77714.c F: include/linux/mfd/max77714.h +MAXIM MAX77759 PMIC MFD DRIVER +M: André Draszik +L: linux-ker...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml + MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas L: linux-ker...@vger.kernel.org -- 2.48.1.658.g4767266eb4-goog
[PATCH 3/6] dt-bindings: nvmem: add max77759 binding
Add the DT binding document for the NVMEM module of the Maxim MAX77759. Signed-off-by: André Draszik --- .../bindings/nvmem/maxim,max77759-nvmem.yaml | 50 ++ 1 file changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml new file mode 100644 index ..d3b7430ef551 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/maxim,max77759-nvmem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 Non Volatile Memory + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, Non Volatile Memory + (NVMEM) with 30 bytes of storage which can be used by software to store + information or communicate with a boot loader. + +properties: + compatible: +const: maxim,max77759-nvmem + + wp-gpios: false + +required: + - compatible + +allOf: + - $ref: nvmem.yaml# + +unevaluatedProperties: false + +examples: + - | +nvmem { +compatible = "maxim,max77759-nvmem"; +#address-cells = <1>; +#size-cells = <1>; + +nvmem-layout { +compatible = "fixed-layout"; +#address-cells = <1>; +#size-cells = <1>; + +rsoc@a { +reg = <0xa 2>; +}; +}; +}; -- 2.48.1.658.g4767266eb4-goog
[PATCH 2/6] dt-bindings: gpio: add max77759 binding
Add the DT binding document for the GPIO module of the Maxim MAX77759. Signed-off-by: André Draszik --- .../bindings/gpio/maxim,max77759-gpio.yaml | 47 ++ 1 file changed, 47 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml new file mode 100644 index ..9bafb16ad688 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/maxim,max77759-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 GPIO + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, a GPIO controller + including interrupt support for 2 GPIO lines. + +properties: + compatible: +const: maxim,max77759-gpio + + "#interrupt-cells": +const: 2 + + interrupt-controller: true + + interrupts: +maxItems: 2 + + "#gpio-cells": +const: 2 + + gpio-controller: true + + gpio-line-names: +minItems: 1 +maxItems: 2 + +required: + - compatible + - "#gpio-cells" + - gpio-controller + - "#interrupt-cells" + - interrupt-controller + +additionalProperties: false -- 2.48.1.658.g4767266eb4-goog
[PATCH 6/6] nvmem: max77759: add Maxim MAX77759 NVMEM driver
The Maxim MAX77759 is a companion Power Management IC for USB Type-C applications with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and additional GPIO interfaces. This driver exposes the non volatile memory using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- MAINTAINERS| 1 + drivers/nvmem/Kconfig | 12 drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + 4 files changed, 171 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index d119ed1ff279..bbc92dee7af4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14329,6 +14329,7 @@ S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c +F: drivers/nvmem/max77759-nvmem.c F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 8671b7c974b9..3de07ef52490 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -154,6 +154,18 @@ config NVMEM_LPC18XX_OTP To compile this driver as a module, choose M here: the module will be called nvmem_lpc18xx_otp. +config NVMEM_MAX77759 + tristate "Maxim Integrated MAX77759 NVMEM Support" + depends on MFD_MAX77759 + default MFD_MAX77759 + help + Say Y here to include support for the user-accessible storage found + in Maxim Integrated MAX77759 PMICs. This IC provides space for 30 + bytes of storage. + + This driver can also be built as a module. If so, the module + will be called nvmem-max77759. + config NVMEM_MESON_EFUSE tristate "Amlogic Meson GX eFuse Support" depends on (ARCH_MESON || COMPILE_TEST) && MESON_SM diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 5b77bbb6488b..a9d03cfbbd27 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -34,6 +34,8 @@ obj-$(CONFIG_NVMEM_LPC18XX_EEPROM)+= nvmem_lpc18xx_eeprom.o nvmem_lpc18xx_eeprom-y := lpc18xx_eeprom.o obj-$(CONFIG_NVMEM_LPC18XX_OTP)+= nvmem_lpc18xx_otp.o nvmem_lpc18xx_otp-y:= lpc18xx_otp.o +obj-$(CONFIG_NVMEM_MAX77759) += nvmem-max77759.o +nvmem-max77759-y := max77759-nvmem.o obj-$(CONFIG_NVMEM_MESON_EFUSE)+= nvmem_meson_efuse.o nvmem_meson_efuse-y:= meson-efuse.o obj-$(CONFIG_NVMEM_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o diff --git a/drivers/nvmem/max77759-nvmem.c b/drivers/nvmem/max77759-nvmem.c new file mode 100644 index ..4c455b242542 --- /dev/null +++ b/drivers/nvmem/max77759-nvmem.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// NVMEM driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_NVMEM_OPCODE_HEADER_LEN 3 +/* + * NVMEM commands have a three byte header (which becomes part of the command), + * so we need to subtract that. + */ +#define MAX77759_NVMEM_SIZE (MAX77759_MAXQ_OPCODE_MAXLENGTH \ +- MAX77759_NVMEM_OPCODE_HEADER_LEN) + +struct max77759_nvmem { + struct device *dev; + struct max77759_mfd *max77759_mfd; +}; + +static bool max77759_nvmem_is_valid(unsigned int offset, size_t bytes) +{ + return (offset + bytes - 1 <= MAX77759_NVMEM_SIZE); +} + +static int max77759_nvmem_reg_read(void *priv, unsigned int offset, + void *val, size_t bytes) +{ + struct max77759_nvmem *nvmem = priv; + DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, + MAX77759_NVMEM_OPCODE_HEADER_LEN); + DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, + MAX77759_MAXQ_OPCODE_MAXLENGTH); + int ret; + + if (!max77759_nvmem_is_valid(offset, bytes)) { + dev_err(nvmem->dev, "outside NVMEM area: %u / %zu\n", + offset, bytes); + return -EINVAL; + } + + cmd->cmd[0] = MAX77759_MAXQ_OPCODE_USER_SPACE_READ; + cmd->cmd[1] = offset; + cmd->cmd[2] = bytes; + rsp->length = bytes + MAX77759_NVMEM_OPCODE_HEADER_LEN; + + ret = max77759_maxq_command(nvmem->max77759_mfd, cmd, rsp); + if (ret < 0) + return ret; + + if (memcmp(cmd->cmd, rsp->rsp, MAX77759_NVMEM_OPCODE_HEADER_LEN)) { + dev_warn(nvmem->dev, "protocol error (read)\n"); + return -EIO; + } + + memcpy(val, &rsp->rsp[MAX77759_NVMEM_OPCODE_HEADER_LEN], bytes); + +
[PATCH 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
The Maxim MAX77759 is a companion Power Management IC for USB Type-C applications with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and additional GPIO interfaces. This driver supports the GPIO functions using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- MAINTAINERS | 1 + drivers/gpio/Kconfig | 13 ++ drivers/gpio/Makefile| 1 + drivers/gpio/gpio-max77759.c | 522 +++ 4 files changed, 537 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index b1bbe7165e0d..d119ed1ff279 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14327,6 +14327,7 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c F: include/linux/mfd/max77759.h diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index f518f5458446..486b22438c76 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1462,6 +1462,19 @@ config GPIO_MAX77650 GPIO driver for MAX77650/77651 PMIC from Maxim Semiconductor. These chips have a single pin that can be configured as GPIO. +config GPIO_MAX77759 + tristate "Maxim Integrated MAX77759 GPIO support" + depends on MFD_MAX77759 + default MFD_MAX77759 + select GPIOLIB_IRQCHIP + help + GPIO driver for MAX77759 PMIC from Maxim Integrated. + There are two GPIOs available on these chips in total, both of + which can also generate interrupts. + + This driver can also be built as a module. If so, the module will be + called gpio-max77759. + config GPIO_PALMAS bool "TI PALMAS series PMICs GPIO" depends on MFD_PALMAS diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index af3ba4d81b58..d7a904047657 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -102,6 +102,7 @@ obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o obj-$(CONFIG_GPIO_MAX77620)+= gpio-max77620.o obj-$(CONFIG_GPIO_MAX77650)+= gpio-max77650.o +obj-$(CONFIG_GPIO_MAX77759)+= gpio-max77759.o obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o diff --git a/drivers/gpio/gpio-max77759.c b/drivers/gpio/gpio-max77759.c new file mode 100644 index ..9f21a6cf4567 --- /dev/null +++ b/drivers/gpio/gpio-max77759.c @@ -0,0 +1,522 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// GPIO driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_N_GPIOS ARRAY_SIZE(max77759_gpio_line_names) +static const char * const max77759_gpio_line_names[] = { "GPIO5", "GPIO6" }; + +struct max77759_gpio_chip { + struct regmap *map; + struct max77759_mfd *max77759_mfd; + struct gpio_chip gc; + struct mutex maxq_lock; /* protect MaxQ r/m/w operations */ + + struct mutex irq_lock; /* protect irq bus */ + int irq_mask; + int irq_mask_changed; + int irq_trig; + int irq_trig_changed; +}; + +#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs)) +#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0) +enum max77759_trigger_gpio_type { + MAX77759_GPIO_TRIGGER_RISING = 0, + MAX77759_GPIO_TRIGGER_FALLING = 1 +}; + +#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs +#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0) +enum max77759_control_gpio_dir { + MAX77759_GPIO_DIR_IN = 0, + MAX77759_GPIO_DIR_OUT = 1 +}; + +#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs +#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(offs, ~0) + +#define MAX77759_GPIOx_INVAL_MASK(offs) (BIT(4) << (3 * (offs))) + +static int max77759_gpio_maxq_gpio_trigger_read(struct max77759_gpio_chip *chip) +{ + DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, 1); + DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, 2); + int ret; + + cmd->cmd[0] = MAX77759_MAXQ_OPCODE_GPIO_TRIGGER_READ; + + ret = max77759_maxq_command(chip->max77759_mfd, cmd, rsp); + if (ret < 0) + return ret; + + return rsp->rsp[1]; +} + +static int max77759_gpio_maxq_gpio_trigger_write(struct max77759_gpio_chip *chip, +u8 trigger) +{ +
[PATCH 0/6] Maxim Integrated MAX77759 PMIC MFD-based drivers
Hi, This series improves support for the Maxim Integrated MAX77759 companion PMIC for USB Type-C applications using the MFD framework. In particular, this PMIC includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This series adds support for the top-level MFD device, the gpio, and nvmem cells. Other components are excluded for the following reasons: While in the same package, Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, interrupt lines, and aren't part of the top-level package interrupt hierarchy. Furthermore, a driver for the TCPC part exists already (in drivers/usb/typec/tcpm/tcpci_maxim_core.c). I'm leaving out temperature sensors and charger in this submission, because the former are not in use on Pixel 6 and I therefore can not test them, and the latter can be added later, once we look at the whole charging topic in more detail. This PMIC is used on the Google Pixel 6 (oriole). To make maintainers' work easier, I am planning to send the relevant DTS and defconfig changes via a different series, unless everything is expected to go via Lee's MFD tree in one series? Cheers, Andre' Signed-off-by: André Draszik --- André Draszik (6): dt-bindings: mfd: add max77759 binding dt-bindings: gpio: add max77759 binding dt-bindings: nvmem: add max77759 binding mfd: max77759: add Maxim MAX77759 core mfd driver gpio: max77759: add Maxim MAX77759 gpio driver nvmem: max77759: add Maxim MAX77759 NVMEM driver .../bindings/gpio/maxim,max77759-gpio.yaml | 47 ++ .../devicetree/bindings/mfd/maxim,max77759.yaml| 104 +++ .../bindings/nvmem/maxim,max77759-nvmem.yaml | 50 ++ MAINTAINERS| 10 + drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77759.c | 522 +++ drivers/mfd/Kconfig| 20 + drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 739 + drivers/nvmem/Kconfig | 12 + drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + include/linux/mfd/max77759.h | 74 +++ 14 files changed, 1751 insertions(+) --- base-commit: d4b0fd87ff0d4338b259dc79b2b3c6f7e70e8afa change-id: 20250224-max77759-mfd-aaa7a3121b62 Best regards, -- André Draszik
[PATCH 4/6] mfd: max77759: add Maxim MAX77759 core mfd driver
The Maxim MAX77759 is a companion Power Management IC for USB Type-C applications with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and additional GPIO interfaces. Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, and interrupt lines and are therefore excluded from the MFD core device driver here. The GPIO and NVMEM interfaces are accessed via specific commands to the built-in microprocessor. This driver implements an API that client drivers can use for accessing those. Signed-off-by: André Draszik --- MAINTAINERS | 2 + drivers/mfd/Kconfig | 20 ++ drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 739 +++ include/linux/mfd/max77759.h | 74 + 5 files changed, 836 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f2c19a1b4c05..b1bbe7165e0d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14327,6 +14327,8 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/mfd/max77759.c +F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index d44c69bb3dfd..1d72bf086401 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -930,6 +930,26 @@ config MFD_MAX77714 drivers must be enabled in order to use each functionality of the device. +config MFD_MAX77759 + tristate "Maxim Integrated MAX77759 PMIC" + depends on I2C + depends on OF + select IRQ_DOMAIN + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Say yes here to add support for Maxim Integrated MAX77759. + This is a companion Power Management IC for USB Type-C applications + with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C + Port Controller (TCPC), NVMEM, and additional GPIO interfaces. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + + To compile this driver as a module, choose M here: the module will be + called max77759. + config MFD_MAX77843 bool "Maxim Semiconductor MAX77843 PMIC Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 9220eaf7cf12..cc9362afd8f0 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o obj-$(CONFIG_MFD_MAX77714) += max77714.o +obj-$(CONFIG_MFD_MAX77759) += max77759.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o max8925-objs := max8925-core.o max8925-i2c.o diff --git a/drivers/mfd/max77759.c b/drivers/mfd/max77759.c new file mode 100644 index ..57e9a1e95df5 --- /dev/null +++ b/drivers/mfd/max77759.c @@ -0,0 +1,739 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// Core MFD driver for Maxim MAX77759 companion PMIC for USB Type-C + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* registers - registers useful to drivers are declared in the public header */ +/* PMIC / TOP */ +#define MAX77759_PMIC_REG_PMIC_ID 0x00 +#define MAX77759_PMIC_REG_PMIC_ID_MAX7775959 + +#define MAX77759_PMIC_REG_PMIC_REVISION 0x01 +#define MAX77759_PMIC_REG_OTP_REVISION0x02 + +#define MAX77759_PMIC_REG_INTSRC 0x22 +#define MAX77759_PMIC_REG_INTSRCMASK 0x23 +#define MAX77759_PMIC_REG_INTSRC_MAXQ BIT(3) +#define MAX77759_PMIC_REG_INTSRC_TOPSYS BIT(1) +#define MAX77759_PMIC_REG_INTSRC_CHGR BIT(0) + +#define MAX77759_PMIC_REG_TOPSYS_INT 0x24 +#define MAX77759_PMIC_REG_TOPSYS_INT_MASK 0x26 +#define MAX77759_PMIC_REG_TOPSYS_INT_TSHDNBIT(6) +#define MAX77759_PMIC_REG_TOPSYS_INT_SYSOVLO BIT(5) +#define MAX77759_PMIC_REG_TOPSYS_INT_SYSUVLO BIT(4) +#define MAX77759_PMIC_REG_TOPSYS_INT_FSHIPBIT(0) + +#define MAX77759_PMIC_REG_I2C_CNFG0x40 +#define MAX77759_PMIC_REG_SWRESET 0x50 +#define MAX77759_PMIC_REG_CONTROL_FG 0x51 +#define MAX77759_PMIC_REG_LAST_REGISTER MAX77759_PMIC_REG_CONTROL_FG + +/* MaxQ */ +#define MAX77759_MAXQ_REG_AP_DATAOUT0 0x81 +#define MAX77759_MAXQ_REG_AP_DATAOUT32 0xa1 +#define MAX77759_MAXQ_REG_AP_MESSAGESZ_MAX (MAX77759_M
Re: [PATCH 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
On Mon, 2025-02-24 at 10:28 +, André Draszik wrote: > [...] > > +#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs)) > +#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0) > +enum max77759_trigger_gpio_type { > + MAX77759_GPIO_TRIGGER_RISING = 0, > + MAX77759_GPIO_TRIGGER_FALLING = 1 > +}; > + > +#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs > +#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0) > +enum max77759_control_gpio_dir { > + MAX77759_GPIO_DIR_IN = 0, > + MAX77759_GPIO_DIR_OUT = 1 > +}; > + > +#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs > +#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(offs, ~0) > + > +#define MAX77759_GPIOx_INVAL_MASK(offs) (BIT(4) << (3 * (offs))) > + > +[...] > > +static int > +max77759_gpio_direction_from_control(int ctrl, unsigned int offset) > +{ > + return (((ctrl & MAX77759_GPIOx_DIR_MASK(offset)) > + == MAX77759_GPIO_DIR_OUT) > + ? GPIO_LINE_DIRECTION_OUT > + : GPIO_LINE_DIRECTION_IN); Eek, I made a last minute change that I shouldn't have :-( This should be something more like: static int max77759_gpio_direction_from_control(int ctrl, unsigned int offset) { enum max77759_control_gpio_dir dir; dir = !!(ctrl & MAX77759_GPIOx_DIR_MASK(offset)); return ((dir == MAX77759_GPIO_DIR_OUT) ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN); } I'll fix that for v2. A.
Re: [PATCH 1/6] dt-bindings: mfd: add max77759 binding
On Mon, 2025-02-24 at 06:48 -0600, Rob Herring (Arm) wrote: > > On Mon, 24 Feb 2025 10:28:49 +, André Draszik wrote: > > Add device tree binding for the Maxim MAX77759 companion PMIC for USB > > Type-C applications. > > > > The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, > > USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. > > > > This describes the core mfd device. > > > > Signed-off-by: André Draszik > > --- > > .../devicetree/bindings/mfd/maxim,max77759.yaml | 104 > > + > > MAINTAINERS | 6 ++ > > 2 files changed, 110 insertions(+) > > > > My bot found errors running 'make dt_binding_check' on your patch: > > yamllint warnings/errors: > > dtschema/dtc warnings/errors: > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: > pmic@66: gpio: False schema > does not allow {'compatible': ['maxim,max77759-gpio'], 'gpio-controller': > True, '#gpio-cells': 2, 'interrupt-controller': True, > '#interrupt-cells': 2} > from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: > pmic@66: pmic-nvmem: False > schema does not allow {'compatible': ['maxim,max77759-nvmem'], > 'nvmem-layout': {'compatible': ['fixed-layout'], '#address-cells': 1, > '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': > {'reg': [[4, 4]]}, 'shutdown-user-flag@8': {'reg': [[8, 1]]}, > 'rsoc@10': {'reg': [[10, 2]]}}} > from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# > Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: > /example-0/i2c/pmic@66/gpio: failed to match any schema with > compatible: ['maxim,max77759-gpio'] > Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: > /example-0/i2c/pmic@66/pmic-nvmem: failed to match any schema with > compatible: ['maxim,max77759-nvmem'] The top-level example in here references the two (MFD cell) bindings added in the two follow-up patches for gpio and nvmem. When all three binding patches exist in the tree, the errors are gone. Is this acceptable, or shall I add the top-level example only after the bindings? Thanks, Andre'
Re: [PATCH 1/6] dt-bindings: mfd: add max77759 binding
On Mon, 2025-02-24 at 14:07 +0100, Krzysztof Kozlowski wrote: > On 24/02/2025 11:28, André Draszik wrote: > > + gpio-controller: true > > + > > + "#gpio-cells": > > + const: 2 > > + > > + gpio: > > + $ref: /schemas/gpio/maxim,max77759-gpio.yaml > > There is no such file at this moment, so this is not bisectable. What's > more, even if you fix it, you will have dependency which you *must* > always clearly express in patch changelog or *top* (the first people > see) of cover letter. Thanks Krzysztof. You're right of course. I'll fix the dependency issues in the next version Cheers, Andre'
Re: [PATCH 1/6] dt-bindings: mfd: add max77759 binding
Hi Rob, Thanks for the review! On Mon, 2025-02-24 at 09:37 -0600, Rob Herring wrote: > On Mon, Feb 24, 2025 at 10:28:49AM +0000, André Draszik wrote: > > Add device tree binding for the Maxim MAX77759 companion PMIC for USB > > Type-C applications. > > > > The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, > > USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. > > > > This describes the core mfd device. > > > > Signed-off-by: André Draszik > > --- > > .../devicetree/bindings/mfd/maxim,max77759.yaml | 104 > > + > > MAINTAINERS | 6 ++ > > 2 files changed, 110 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > new file mode 100644 > > index ..1efb841289fb > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > @@ -0,0 +1,104 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications > > + > > +maintainers: > > + - André Draszik > > + > > +description: | > > + This is a part of device tree bindings for the MAX77759 companion Power > > + Management IC for USB Type-C applications. > > + > > + The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, > > USB > > + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. > > + > > +properties: > > + compatible: > > + const: maxim,max77759 > > + > > + interrupts: > > + maxItems: 1 > > + > > + interrupt-controller: true > > + > > + "#interrupt-cells": > > + const: 2 > > + > > + gpio-controller: true > > + > > + "#gpio-cells": > > + const: 2 > > + > > + gpio: > > + $ref: /schemas/gpio/maxim,max77759-gpio.yaml > > + > > + reg: > > + maxItems: 1 > > + > > + pmic-nvmem: > > Just 'nvmem' TBH, I'd prefer that as well, and I had just 'nvmem' initially, but that doesn't work: .../maxim,max77759.example.dtb: pmic@66: nvmem: {'compatible': ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed- layout'], '#address-cells': 1, '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]}, 'shutdown-user-flag@8': {'reg': [[8, 1]]}, 'rsoc@10': {'reg': [[10, 2]]}}} is not of type 'array' from schema $id: http://devicetree.org/schemas/nvmem/nvmem-consumer.yaml# I don't know if this can be made to work, i.e. can you have both in yaml? Can a type be declared as a oneOf or something like that? > > > + $ref: /schemas/nvmem/maxim,max77759-nvmem.yaml > > + > > +required: > > + - compatible > > + - interrupts > > + - reg > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > + #include > > + > > + i2c { > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + pmic@66 { > > + compatible = "maxim,max77759"; > > + reg = <0x66>; > > + interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>; > > + > > + interrupt-controller; > > + #interrupt-cells = <2>; > > + > > + gpio { > > + compatible = "maxim,max77759-gpio"; > > + > > + gpio-controller; > > + #gpio-cells = <2>; > > + > > + interrupt-controller; > > + #interrupt-cells = <2>; > > + }; > > + > > + pmic-nvmem { > > nvmem { dito Cheers, Andre' > > + compatible = "maxim,max77759-nvmem"; > > + > > + nvmem-layout { > > + compatible = "fixed-layout"; > > + #address-cells = <1>; > > + #size-cells = <1>; > > + > > + reboot-mode@0 { > > +
Re: [PATCH 3/6] dt-bindings: nvmem: add max77759 binding
On Mon, 2025-02-24 at 09:38 -0600, Rob Herring wrote: > On Mon, Feb 24, 2025 at 10:28:51AM +0000, André Draszik wrote: > > Add the DT binding document for the NVMEM module of the Maxim MAX77759. > > > > Signed-off-by: André Draszik > > --- > > .../bindings/nvmem/maxim,max77759-nvmem.yaml | 50 > > ++ > > 1 file changed, 50 insertions(+) > > > > diff --git > > a/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml > > b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml > > new file mode 100644 > > index ..d3b7430ef551 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml > > @@ -0,0 +1,50 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/nvmem/maxim,max77759-nvmem.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Maxim Integrated MAX77759 Non Volatile Memory > > + > > +maintainers: > > + - André Draszik > > + > > +description: | > > + This module is part of the MAX77759 PMIC. For additional information, see > > + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. > > + > > + The MAX77759 is a PMIC integrating, amongst others, Non Volatile Memory > > + (NVMEM) with 30 bytes of storage which can be used by software to store > > + information or communicate with a boot loader. > > + > > +properties: > > + compatible: > > + const: maxim,max77759-nvmem > > + > > + wp-gpios: false > > + > > +required: > > + - compatible > > + > > +allOf: > > + - $ref: nvmem.yaml# > > + > > +unevaluatedProperties: false > > + > > +examples: > > + - | > > + nvmem { > > Drop the example here. The MFD binding has a complete one. Will do Thanks Rob!
[PATCH v2 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This driver supports the GPIO functions using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- v2: * fix max77759_gpio_direction_from_control() * add missing error handling of devm_mutex_init() (Christophe) * align sentinel in max77759_gpio_of_id[] with other max77759 drivers (Christophe) --- MAINTAINERS | 1 + drivers/gpio/Kconfig | 13 ++ drivers/gpio/Makefile| 1 + drivers/gpio/gpio-max77759.c | 528 +++ 4 files changed, 543 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 38844ea24e464d0b58f8852b79e2b94f18d48998..ef3aadcf86ce35d8807733c94f790cde0f7255af 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,7 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c F: include/linux/mfd/max77759.h diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 3e9b174fee84142a8b50cdca5b967671eeda6dd3..216e80580fa443160c20da3e0916979fd08df99a 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1463,6 +1463,19 @@ config GPIO_MAX77650 GPIO driver for MAX77650/77651 PMIC from Maxim Semiconductor. These chips have a single pin that can be configured as GPIO. +config GPIO_MAX77759 + tristate "Maxim Integrated MAX77759 GPIO support" + depends on MFD_MAX77759 + default MFD_MAX77759 + select GPIOLIB_IRQCHIP + help + GPIO driver for MAX77759 PMIC from Maxim Integrated. + There are two GPIOs available on these chips in total, both of + which can also generate interrupts. + + This driver can also be built as a module. If so, the module will be + called gpio-max77759. + config GPIO_PALMAS bool "TI PALMAS series PMICs GPIO" depends on MFD_PALMAS diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index af130882ffeeef8b1d518867bfe1493ec4f21b5f..3b9a55f9f79eda33c135cfedb230ef7775b51bee 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -105,6 +105,7 @@ obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o obj-$(CONFIG_GPIO_MAX77620)+= gpio-max77620.o obj-$(CONFIG_GPIO_MAX77650)+= gpio-max77650.o +obj-$(CONFIG_GPIO_MAX77759)+= gpio-max77759.o obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o diff --git a/drivers/gpio/gpio-max77759.c b/drivers/gpio/gpio-max77759.c new file mode 100644 index ..b304c533dc9d6bf792d179c6c36b467c2c134e56 --- /dev/null +++ b/drivers/gpio/gpio-max77759.c @@ -0,0 +1,528 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// GPIO driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_N_GPIOS ARRAY_SIZE(max77759_gpio_line_names) +static const char * const max77759_gpio_line_names[] = { "GPIO5", "GPIO6" }; + +struct max77759_gpio_chip { + struct regmap *map; + struct max77759_mfd *max77759_mfd; + struct gpio_chip gc; + struct mutex maxq_lock; /* protect MaxQ r/m/w operations */ + + struct mutex irq_lock; /* protect irq bus */ + int irq_mask; + int irq_mask_changed; + int irq_trig; + int irq_trig_changed; +}; + +#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs)) +#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0) +enum max77759_trigger_gpio_type { + MAX77759_GPIO_TRIGGER_RISING = 0, + MAX77759_GPIO_TRIGGER_FALLING = 1 +}; + +#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs +#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0) +enum max77759_control_gpio_dir { + MAX77759_GPIO_DIR_IN = 0, + MAX77759_GPIO_DIR_OUT = 1 +}; + +#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs +#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(offs, ~0) + +#define MAX77759_GPIOx_INVAL_MASK(offs) (BIT(4) << (3 * (offs))) + +static int max77759_gpio_maxq_gpio_trigger_read(struct max77759_gpio_chip *chip) +{ + DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, 1); + DEFINE_FLEX(struct max7775
[PATCH v2 6/6] nvmem: max77759: add Maxim MAX77759 NVMEM driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This driver exposes the non volatile memory using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- v2: * align sentinel in max77759_nvmem_of_id[] with other max77759 drivers (Christophe) --- MAINTAINERS| 1 + drivers/nvmem/Kconfig | 12 drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + 4 files changed, 171 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ef3aadcf86ce35d8807733c94f790cde0f7255af..88c53e3fabe1760abf7914290c8729330739b0b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14354,6 +14354,7 @@ S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c +F: drivers/nvmem/max77759-nvmem.c F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 8671b7c974b933e147154bb40b5d41b5730518d2..3de07ef524906ad24a89e58abdfe93529a83c80f 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -154,6 +154,18 @@ config NVMEM_LPC18XX_OTP To compile this driver as a module, choose M here: the module will be called nvmem_lpc18xx_otp. +config NVMEM_MAX77759 + tristate "Maxim Integrated MAX77759 NVMEM Support" + depends on MFD_MAX77759 + default MFD_MAX77759 + help + Say Y here to include support for the user-accessible storage found + in Maxim Integrated MAX77759 PMICs. This IC provides space for 30 + bytes of storage. + + This driver can also be built as a module. If so, the module + will be called nvmem-max77759. + config NVMEM_MESON_EFUSE tristate "Amlogic Meson GX eFuse Support" depends on (ARCH_MESON || COMPILE_TEST) && MESON_SM diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 5b77bbb6488bf89bfb305750a1cbf4a6731a0a58..a9d03cfbbd27e68d40f8c330e72e20378b12a481 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -34,6 +34,8 @@ obj-$(CONFIG_NVMEM_LPC18XX_EEPROM)+= nvmem_lpc18xx_eeprom.o nvmem_lpc18xx_eeprom-y := lpc18xx_eeprom.o obj-$(CONFIG_NVMEM_LPC18XX_OTP)+= nvmem_lpc18xx_otp.o nvmem_lpc18xx_otp-y:= lpc18xx_otp.o +obj-$(CONFIG_NVMEM_MAX77759) += nvmem-max77759.o +nvmem-max77759-y := max77759-nvmem.o obj-$(CONFIG_NVMEM_MESON_EFUSE)+= nvmem_meson_efuse.o nvmem_meson_efuse-y:= meson-efuse.o obj-$(CONFIG_NVMEM_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o diff --git a/drivers/nvmem/max77759-nvmem.c b/drivers/nvmem/max77759-nvmem.c new file mode 100644 index ..bc535a73daaaf2caeb772cd17da61f8a030b6a6f --- /dev/null +++ b/drivers/nvmem/max77759-nvmem.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// NVMEM driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_NVMEM_OPCODE_HEADER_LEN 3 +/* + * NVMEM commands have a three byte header (which becomes part of the command), + * so we need to subtract that. + */ +#define MAX77759_NVMEM_SIZE (MAX77759_MAXQ_OPCODE_MAXLENGTH \ +- MAX77759_NVMEM_OPCODE_HEADER_LEN) + +struct max77759_nvmem { + struct device *dev; + struct max77759_mfd *max77759_mfd; +}; + +static bool max77759_nvmem_is_valid(unsigned int offset, size_t bytes) +{ + return (offset + bytes - 1 <= MAX77759_NVMEM_SIZE); +} + +static int max77759_nvmem_reg_read(void *priv, unsigned int offset, + void *val, size_t bytes) +{ + struct max77759_nvmem *nvmem = priv; + DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, + MAX77759_NVMEM_OPCODE_HEADER_LEN); + DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, + MAX77759_MAXQ_OPCODE_MAXLENGTH); + int ret; + + if (!max77759_nvmem_is_valid(offset, bytes)) { + dev_err(nvmem->dev, "outside NVMEM area: %u / %zu\n", + offset, bytes); + return -EINVAL; + } + + cmd->cmd[0] = MAX77759_MAXQ_OPCODE_USER_SPACE_READ; + cmd->cmd[1] = offset; + cmd->cmd[2] = bytes; + rsp->length = bytes + MAX77759_NVMEM_OPCODE_HEADER_LEN; + + ret = max77759_maxq_command(nvmem->max77759_mfd, cmd, rsp); + if (ret < 0) +
[PATCH v2 0/6] Maxim Integrated MAX77759 PMIC MFD-based drivers
Hi, This series improves support for the Maxim Integrated MAX77759 companion PMIC for USB Type-C applications using the MFD framework. This series must be applied in-order, due to interdependencies of some of the patches: * to avoid use of undocumented compatibles by the newly added drivers, the bindings are added first in this series * patch 1 ("dt-bindings: gpio: add max77759 binding") also creates a new MAINTAINERS entry, including a wildcard match for the other bindings in this series * patch 3 ("dt-bindings: mfd: add max77759 binding") references the bindings added in patch 1 and 2 and can not work if those aren't available * patch 4 ("mfd: max77759: add Maxim MAX77759 core mfd driver") adds the core MFD driver, which also exposes an API to its leaf drivers and is used by patches 5 and 6 * patches 5 and 6 won't compile without patch 4 The MAX77759 PMIC includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This PMIC is used on the Google Pixel 6 and 6 Pro (oriole / raven). This series adds support for the top-level MFD device, the gpio, and nvmem cells. Other components are excluded for the following reasons: While in the same package, Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, interrupt lines, and aren't part of the top-level package interrupt hierarchy. Furthermore, a driver for the TCPC part exists already (in drivers/usb/typec/tcpm/tcpci_maxim_core.c). I'm leaving out temperature sensors and charger in this submission, because the former are not in use on Pixel 6 and I therefore can not test them, and the latter can be added later, once we look at the whole charging topic in more detail. To make maintainers' work easier, I am planning to send the relevant DTS and defconfig changes via a different series, unless everything is expected to go via Lee's MFD tree in one series? Cheers, Andre' Signed-off-by: André Draszik --- Changes in v2: - reorder bindings patches to avoid validation failures - add dependency information to cover letter (Krzysztof) - fix max77759_gpio_direction_from_control() in gpio driver - Link to v1: https://lore.kernel.org/r/20250224-max77759-mfd-v1-0-2bff36f9d...@linaro.org --- André Draszik (6): dt-bindings: gpio: add max77759 binding dt-bindings: nvmem: add max77759 binding dt-bindings: mfd: add max77759 binding mfd: max77759: add Maxim MAX77759 core mfd driver gpio: max77759: add Maxim MAX77759 gpio driver nvmem: max77759: add Maxim MAX77759 NVMEM driver .../bindings/gpio/maxim,max77759-gpio.yaml | 44 ++ .../devicetree/bindings/mfd/maxim,max77759.yaml| 104 +++ .../bindings/nvmem/maxim,max77759-nvmem.yaml | 32 + MAINTAINERS| 10 + drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77759.c | 528 +++ drivers/mfd/Kconfig| 20 + drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 737 + drivers/nvmem/Kconfig | 12 + drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + include/linux/mfd/max77759.h | 98 +++ 14 files changed, 1758 insertions(+) --- base-commit: 0226d0ce98a477937ed295fb7df4cc30b46fc304 change-id: 20250224-max77759-mfd-aaa7a3121b62 Best regards, -- André Draszik
[PATCH v2 3/6] dt-bindings: mfd: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes the top-level device. Signed-off-by: André Draszik --- v2: * rename expected nvmem subdev nodename to 'nvmem-0' I'd have preferred just 'nvmem', but that matches nvmem-consumer.yaml and fails validation. Note: MAINTAINERS doesn't need updating, the binding update for the first leaf device (gpio) adds a wildcard matching all max77759 bindings --- .../devicetree/bindings/mfd/maxim,max77759.yaml| 104 + 1 file changed, 104 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml new file mode 100644 index ..87e3737896a289998a18b67932dbccacfb8e3150 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications + +maintainers: + - André Draszik + +description: | + This is a part of device tree bindings for the MAX77759 companion Power + Management IC for USB Type-C applications. + + The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. + +properties: + compatible: +const: maxim,max77759 + + interrupts: +maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": +const: 2 + + gpio-controller: true + + "#gpio-cells": +const: 2 + + gpio: +$ref: /schemas/gpio/maxim,max77759-gpio.yaml + + reg: +maxItems: 1 + + nvmem-0: +$ref: /schemas/nvmem/maxim,max77759-nvmem.yaml + +required: + - compatible + - interrupts + - reg + +additionalProperties: false + +examples: + - | +#include + +i2c { +#address-cells = <1>; +#size-cells = <0>; + +pmic@66 { +compatible = "maxim,max77759"; +reg = <0x66>; +interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>; + +interrupt-controller; +#interrupt-cells = <2>; + +gpio { +compatible = "maxim,max77759-gpio"; + +gpio-controller; +#gpio-cells = <2>; + +interrupt-controller; +#interrupt-cells = <2>; +}; + +nvmem-0 { +compatible = "maxim,max77759-nvmem"; + +nvmem-layout { +compatible = "fixed-layout"; +#address-cells = <1>; +#size-cells = <1>; + +reboot-mode@0 { +reg = <0x0 0x4>; +}; + +boot-reason@4 { +reg = <0x4 0x4>; +}; + +shutdown-user-flag@8 { +reg = <0x8 0x1>; +}; + +rsoc@10 { +reg = <0xa 0x2>; +}; +}; +}; +}; +}; -- 2.48.1.658.g4767266eb4-goog
[PATCH v2 1/6] dt-bindings: gpio: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes its GPIO module. Signed-off-by: André Draszik --- v2: * drop 'interrupts' property and sort properties alphabetically --- .../bindings/gpio/maxim,max77759-gpio.yaml | 44 ++ MAINTAINERS| 6 +++ 2 files changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml new file mode 100644 index ..55734190d5ebdbc351e1f916758a9db80cd7 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/maxim,max77759-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 GPIO + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, a GPIO controller + including interrupt support for 2 GPIO lines. + +properties: + compatible: +const: maxim,max77759-gpio + + "#gpio-cells": +const: 2 + + gpio-controller: true + + gpio-line-names: +minItems: 1 +maxItems: 2 + + "#interrupt-cells": +const: 2 + + interrupt-controller: true + +required: + - compatible + - "#gpio-cells" + - gpio-controller + - "#interrupt-cells" + - interrupt-controller + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 86fa62154d3b23bf84ce2d53cbbdc33f3d43006e..a45d1bd64d116d14bc05a64fa3da852a41e1de7f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14347,6 +14347,12 @@ F: Documentation/devicetree/bindings/mfd/maxim,max77714.yaml F: drivers/mfd/max77714.c F: include/linux/mfd/max77714.h +MAXIM MAX77759 PMIC MFD DRIVER +M: André Draszik +L: linux-ker...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml + MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas L: linux-ker...@vger.kernel.org -- 2.48.1.658.g4767266eb4-goog
Re: [PATCH 1/6] dt-bindings: mfd: add max77759 binding
On Mon, 2025-02-24 at 16:05 +, André Draszik wrote: > Hi Rob, > > Thanks for the review! > > On Mon, 2025-02-24 at 09:37 -0600, Rob Herring wrote: > > On Mon, Feb 24, 2025 at 10:28:49AM +, André Draszik wrote: > > > Add device tree binding for the Maxim MAX77759 companion PMIC for USB > > > Type-C applications. > > > > > > The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, > > > USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. > > > > > > This describes the core mfd device. > > > > > > Signed-off-by: André Draszik > > > --- > > > .../devicetree/bindings/mfd/maxim,max77759.yaml | 104 > > > + > > > MAINTAINERS | 6 ++ > > > 2 files changed, 110 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > > b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > > new file mode 100644 > > > index ..1efb841289fb > > > --- /dev/null > > > +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > > @@ -0,0 +1,104 @@ > > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > > +%YAML 1.2 > > > +--- > > > +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# > > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > > + > > > +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications > > > + > > > +maintainers: > > > + - André Draszik > > > + > > > +description: | > > > + This is a part of device tree bindings for the MAX77759 companion Power > > > + Management IC for USB Type-C applications. > > > + > > > + The MAX77759 includes Battery Charger, Fuel Gauge, temperature > > > sensors, USB > > > + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. > > > + > > > +properties: > > > + compatible: > > > + const: maxim,max77759 > > > + > > > + interrupts: > > > + maxItems: 1 > > > + > > > + interrupt-controller: true > > > + > > > + "#interrupt-cells": > > > + const: 2 > > > + > > > + gpio-controller: true > > > + > > > + "#gpio-cells": > > > + const: 2 > > > + > > > + gpio: > > > + $ref: /schemas/gpio/maxim,max77759-gpio.yaml > > > + > > > + reg: > > > + maxItems: 1 > > > + > > > + pmic-nvmem: > > > > Just 'nvmem' > > TBH, I'd prefer that as well, and I had just 'nvmem' initially, > but that doesn't work: > > .../maxim,max77759.example.dtb: pmic@66: nvmem: {'compatible': > ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed- > layout'], '#address-cells': 1, '#size-cells': 1, 'reboot-mode@0': {'reg': > [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]}, > 'shutdown-user-flag@8': {'reg': [[8, 1]]}, 'rsoc@10': {'reg': [[10, 2]]}}} is > not of type 'array' > from schema $id: > http://devicetree.org/schemas/nvmem/nvmem-consumer.yaml# > > I don't know if this can be made to work, i.e. can you have both > in yaml? Can a type be declared as a oneOf or something like that? I wasn't able to get this to work with a node name of just 'nvmem'. If anybody has any suggestions, I'll gladly try them. I've renamed the node from pmic-nvmem to nvmem-0 in v2, though. https://lore.kernel.org/all/20250226-max77759-mfd-v2-3-a65ebe2bc...@linaro.org/ Cheers, Andre
[PATCH v2 4/6] mfd: max77759: add Maxim MAX77759 core mfd driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, and interrupt lines and are therefore excluded from the MFD core device driver here. The GPIO and NVMEM interfaces are accessed via specific commands to the built-in microprocessor. This driver implements an API that client drivers can use for accessing those. Signed-off-by: André Draszik --- v2: * add kernel doc for max77759_maxq_command() and related structs * fix an msec / usec typo * add missing error handling of devm_mutex_init() (Christophe) * align sentinel in max77759_of_id[] with max77759_i2c_id[] (Christophe) * some tidy-ups in max77759_maxq_command() (Christophe) --- MAINTAINERS | 2 + drivers/mfd/Kconfig | 20 ++ drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 737 +++ include/linux/mfd/max77759.h | 98 ++ 5 files changed, 858 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index a45d1bd64d116d14bc05a64fa3da852a41e1de7f..38844ea24e464d0b58f8852b79e2b94f18d48998 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,8 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/mfd/max77759.c +F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index d44c69bb3dfd52d53fe26aa2d5e5ace346448f57..1d72bf086401064608cc41e9f9a0af044c6df68e 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -930,6 +930,26 @@ config MFD_MAX77714 drivers must be enabled in order to use each functionality of the device. +config MFD_MAX77759 + tristate "Maxim Integrated MAX77759 PMIC" + depends on I2C + depends on OF + select IRQ_DOMAIN + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Say yes here to add support for Maxim Integrated MAX77759. + This is a companion Power Management IC for USB Type-C applications + with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C + Port Controller (TCPC), NVMEM, and additional GPIO interfaces. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + + To compile this driver as a module, choose M here: the module will be + called max77759. + config MFD_MAX77843 bool "Maxim Semiconductor MAX77843 PMIC Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 9220eaf7cf1255a8922430fe3e50e41771bbaa60..cc9362afd8f060d64ca0f0f028a0d7cfe9cfe512 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o obj-$(CONFIG_MFD_MAX77714) += max77714.o +obj-$(CONFIG_MFD_MAX77759) += max77759.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o max8925-objs := max8925-core.o max8925-i2c.o diff --git a/drivers/mfd/max77759.c b/drivers/mfd/max77759.c new file mode 100644 index ..7391591129e3ccc7427839e2297b5fc33c1810b6 --- /dev/null +++ b/drivers/mfd/max77759.c @@ -0,0 +1,737 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// Core MFD driver for Maxim MAX77759 companion PMIC for USB Type-C + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* registers - registers useful to drivers are declared in the public header */ +/* PMIC / TOP */ +#define MAX77759_PMIC_REG_PMIC_ID 0x00 +#define MAX77759_PMIC_REG_PMIC_ID_MAX7775959 + +#define MAX77759_PMIC_REG_PMIC_REVISION 0x01 +#define MAX77759_PMIC_REG_OTP_REVISION0x02 + +#define MAX77759_PMIC_REG_INTSRC 0x22 +#define MAX77759_PMIC_REG_INTSRCMASK 0x23 +#define MAX77759_PMIC_REG_INTSRC_MAXQ BIT(3) +#define MAX77759_PMIC_REG_INTSRC_TOPSYS BIT(1) +#define MAX77759_PMIC_REG_INTSRC_CHGR BIT(0) + +#define MAX77759_PMIC_REG_TOPSYS_INT 0x24 +#define MAX77759_PMIC_REG_TOPSYS_INT_MASK 0x26 +#define MAX77759_PMIC_REG_TOPSYS_INT_TSHDNBIT(6) +#define MAX77759_PMIC_REG_TOPSYS_INT_SYSOVLO BIT(5) +#define MAX77759_PMIC_REG_TOPSYS_INT_SYSU
[PATCH v2 2/6] dt-bindings: nvmem: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes its storage module (NVMEM). Signed-off-by: André Draszik --- v2: * drop example as the MFD binding has a complete one (Rob) Note: MAINTAINERS doesn't need updating, the binding update for the first leaf device (gpio) adds a wildcard matching all max77759 bindings --- .../bindings/nvmem/maxim,max77759-nvmem.yaml | 32 ++ 1 file changed, 32 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml new file mode 100644 index ..1e3bd4433007341a11040f513bf444866b9e38a8 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/maxim,max77759-nvmem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 Non Volatile Memory + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, Non Volatile Memory + (NVMEM) with 30 bytes of storage which can be used by software to store + information or communicate with a boot loader. + +properties: + compatible: +const: maxim,max77759-nvmem + + wp-gpios: false + +required: + - compatible + +allOf: + - $ref: nvmem.yaml# + +unevaluatedProperties: false -- 2.48.1.658.g4767266eb4-goog
Re: [PATCH v2 1/6] dt-bindings: gpio: add max77759 binding
On Wed, 2025-02-26 at 14:30 -0600, Rob Herring (Arm) wrote: > > On Wed, 26 Feb 2025 17:51:20 +, André Draszik wrote: > > The Maxim MAX77759 is a companion PMIC for USB Type-C applications and > > includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C > > Port Controller (TCPC), NVMEM, and a GPIO expander. > > > > This describes its GPIO module. > > > > Signed-off-by: André Draszik > > > > --- > > v2: > > * drop 'interrupts' property and sort properties alphabetically > > --- > > .../bindings/gpio/maxim,max77759-gpio.yaml | 44 > > ++ > > MAINTAINERS | 6 +++ > > 2 files changed, 50 insertions(+) > > > > My bot found errors running 'make dt_binding_check' on your patch: > > yamllint warnings/errors: > > dtschema/dtc warnings/errors: > > > doc reference errors (make refcheckdocs): > Warning: Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml > references a file that doesn't exist: > Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml: > Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > See > https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250226-max77759-mfd-v2-1-a65ebe2bc...@linaro.org > > The base for the series is generally the latest rc1. A different dependency > should be noted in *this* patch. > > If you already ran 'make dt_binding_check' and didn't see the above > error(s), then make sure 'yamllint' is installed and dt-schema is up to > date: 'make dt_binding_check' doesn't invoke 'make refcheckdocs', unless I'm doing something wrong - and therefore 'make dt_binding_check' doesn't print any warning, contrary to what seems to be implied by the paragraph above, If I run 'make refcheckdocs', I do get the error, too, sure enough. I've never come across refcheckdocs, and it wasn't on my radar. The error is because the binding's 'description:' references the mfd binding using the complete path and the mfd binding is added in a later patch only in this version of the series: > ... For additional information, see > Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. the error goes away if a relative path is used instead: > ... For additional information, see > ../mfd/maxim,max77759.yaml. I'd like to keep the reference to the mfd binding, and keep refcheckdocs working as intended (i.e. keep using the full path), so I'll split the gpio binding patch into two, the first one without the path and a 2nd one to add the full mfd binding path, to be applied after the mfd binding. Same for the similar nvmem binding. Unless there is a different preference? Cheers, Andre'
Re: [PATCH v2 1/6] dt-bindings: gpio: add max77759 binding
On Thu, 2025-02-27 at 06:51 -0600, Rob Herring wrote: > On Thu, Feb 27, 2025 at 11:19:55AM +0000, André Draszik wrote: > > > The error is because the binding's 'description:' references the > > mfd binding using the complete path and the mfd binding is added > > in a later patch only in this version of the series: > > > > > ... For additional information, see > > > Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. > > > > the error goes away if a relative path is used instead: > > > > > ... For additional information, see > > > ../mfd/maxim,max77759.yaml. > > No, just ignore the error. I believe it gets fixed with the mfd binding > applied. I'm not too concerned if refcheckdocs is bisectable. Thanks Rob, and yes, it does go away then. Cheers, Andre'
Re: [PATCH v2 3/6] dt-bindings: mfd: add max77759 binding
On Thu, 2025-02-27 at 07:04 -0600, Rob Herring wrote: > On Wed, Feb 26, 2025 at 05:51:22PM +0000, André Draszik wrote: > > The Maxim MAX77759 is a companion PMIC for USB Type-C applications and > > includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C > > Port Controller (TCPC), NVMEM, and a GPIO expander. > > > > This describes the top-level device. > > > > Signed-off-by: André Draszik > > > > --- > > v2: > > * rename expected nvmem subdev nodename to 'nvmem-0' > > I'd have preferred just 'nvmem', but that matches nvmem-consumer.yaml > > and fails validation. > > > > Note: MAINTAINERS doesn't need updating, the binding update for the > > first leaf device (gpio) adds a wildcard matching all max77759 bindings > > --- > > .../devicetree/bindings/mfd/maxim,max77759.yaml | 104 > > + > > 1 file changed, 104 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > new file mode 100644 > > index > > ..87e3737896a289998a18b67932dbccacfb8e3150 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml > > @@ -0,0 +1,104 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications > > + > > +maintainers: > > + - André Draszik > > + > > +description: | > > + This is a part of device tree bindings for the MAX77759 companion Power > > + Management IC for USB Type-C applications. > > + > > + The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, > > USB > > + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. > > + > > +properties: > > + compatible: > > + const: maxim,max77759 > > + > > + interrupts: > > + maxItems: 1 > > + > > + interrupt-controller: true > > + > > + "#interrupt-cells": > > + const: 2 > > + > > + gpio-controller: true > > + > > + "#gpio-cells": > > + const: 2 > > Why do you have GPIO properties here and in the child node? Either would > be valid, but both probably not. Putting them here is actually > preferred. That's an oversight, I meant to put them into the child only, not here, since the child is the one providing the gpio functionality. What's the reason to have it preferred inside this parent node? At least some bindings do specify it in the child node, e.g.: delta,tn48m-gpio.yaml kontron,sl28cpld-gpio.yaml xylon,logicvc-gpio.yaml Cheers, Andre'
[PATCH v3 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This driver supports the GPIO functions using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- v3: * drop duplicate init of 'handled' variable in irq handler * use boolean with IRQ_RETVAL() (Linus) * drop 'virq' variable inside irq handler to avoid confusion (Linus) * drop assignment of struct gpio_chip::owner (Linus) v2: * fix max77759_gpio_direction_from_control() * add missing error handling of devm_mutex_init() (Christophe) * align sentinel in max77759_gpio_of_id[] with other max77759 drivers (Christophe) --- MAINTAINERS | 1 + drivers/gpio/Kconfig | 13 ++ drivers/gpio/Makefile| 1 + drivers/gpio/gpio-max77759.c | 524 +++ 4 files changed, 539 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 38844ea24e464d0b58f8852b79e2b94f18d48998..ef3aadcf86ce35d8807733c94f790cde0f7255af 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,7 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c F: include/linux/mfd/max77759.h diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 3e9b174fee84142a8b50cdca5b967671eeda6dd3..216e80580fa443160c20da3e0916979fd08df99a 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1463,6 +1463,19 @@ config GPIO_MAX77650 GPIO driver for MAX77650/77651 PMIC from Maxim Semiconductor. These chips have a single pin that can be configured as GPIO. +config GPIO_MAX77759 + tristate "Maxim Integrated MAX77759 GPIO support" + depends on MFD_MAX77759 + default MFD_MAX77759 + select GPIOLIB_IRQCHIP + help + GPIO driver for MAX77759 PMIC from Maxim Integrated. + There are two GPIOs available on these chips in total, both of + which can also generate interrupts. + + This driver can also be built as a module. If so, the module will be + called gpio-max77759. + config GPIO_PALMAS bool "TI PALMAS series PMICs GPIO" depends on MFD_PALMAS diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index af130882ffeeef8b1d518867bfe1493ec4f21b5f..3b9a55f9f79eda33c135cfedb230ef7775b51bee 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -105,6 +105,7 @@ obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o obj-$(CONFIG_GPIO_MAX77620)+= gpio-max77620.o obj-$(CONFIG_GPIO_MAX77650)+= gpio-max77650.o +obj-$(CONFIG_GPIO_MAX77759)+= gpio-max77759.o obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o diff --git a/drivers/gpio/gpio-max77759.c b/drivers/gpio/gpio-max77759.c new file mode 100644 index ..b0f5d839a347e472cbe0b8624b534ecf8f21f64c --- /dev/null +++ b/drivers/gpio/gpio-max77759.c @@ -0,0 +1,524 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// GPIO driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_N_GPIOS ARRAY_SIZE(max77759_gpio_line_names) +static const char * const max77759_gpio_line_names[] = { "GPIO5", "GPIO6" }; + +struct max77759_gpio_chip { + struct regmap *map; + struct max77759_mfd *max77759_mfd; + struct gpio_chip gc; + struct mutex maxq_lock; /* protect MaxQ r/m/w operations */ + + struct mutex irq_lock; /* protect irq bus */ + int irq_mask; + int irq_mask_changed; + int irq_trig; + int irq_trig_changed; +}; + +#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs)) +#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0) +enum max77759_trigger_gpio_type { + MAX77759_GPIO_TRIGGER_RISING = 0, + MAX77759_GPIO_TRIGGER_FALLING = 1 +}; + +#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs +#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0) +enum max77759_control_gpio_dir { + MAX77759_GPIO_DIR_IN = 0, + MAX77759_GPIO_DIR_OUT = 1 +}; + +#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs +#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(offs, ~0) + +#define MAX77759_GPIOx_INVAL_MASK(offs) (BIT(4) <
[PATCH v3 4/6] mfd: max77759: add Maxim MAX77759 core mfd driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, and interrupt lines and are therefore excluded from the MFD core device driver here. The GPIO and NVMEM interfaces are accessed via specific commands to the built-in microprocessor. This driver implements an API that client drivers can use for accessing those. Signed-off-by: André Draszik --- v2: * add kernel doc for max77759_maxq_command() and related structs * fix an msec / usec typo * add missing error handling of devm_mutex_init() (Christophe) * align sentinel in max77759_of_id[] with max77759_i2c_id[] (Christophe) * some tidy-ups in max77759_maxq_command() (Christophe) --- MAINTAINERS | 2 + drivers/mfd/Kconfig | 20 ++ drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 737 +++ include/linux/mfd/max77759.h | 98 ++ 5 files changed, 858 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index a45d1bd64d116d14bc05a64fa3da852a41e1de7f..38844ea24e464d0b58f8852b79e2b94f18d48998 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,8 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/mfd/max77759.c +F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index d44c69bb3dfd52d53fe26aa2d5e5ace346448f57..1d72bf086401064608cc41e9f9a0af044c6df68e 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -930,6 +930,26 @@ config MFD_MAX77714 drivers must be enabled in order to use each functionality of the device. +config MFD_MAX77759 + tristate "Maxim Integrated MAX77759 PMIC" + depends on I2C + depends on OF + select IRQ_DOMAIN + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Say yes here to add support for Maxim Integrated MAX77759. + This is a companion Power Management IC for USB Type-C applications + with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C + Port Controller (TCPC), NVMEM, and additional GPIO interfaces. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + + To compile this driver as a module, choose M here: the module will be + called max77759. + config MFD_MAX77843 bool "Maxim Semiconductor MAX77843 PMIC Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 9220eaf7cf1255a8922430fe3e50e41771bbaa60..cc9362afd8f060d64ca0f0f028a0d7cfe9cfe512 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o obj-$(CONFIG_MFD_MAX77714) += max77714.o +obj-$(CONFIG_MFD_MAX77759) += max77759.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o max8925-objs := max8925-core.o max8925-i2c.o diff --git a/drivers/mfd/max77759.c b/drivers/mfd/max77759.c new file mode 100644 index ..7391591129e3ccc7427839e2297b5fc33c1810b6 --- /dev/null +++ b/drivers/mfd/max77759.c @@ -0,0 +1,737 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// Core MFD driver for Maxim MAX77759 companion PMIC for USB Type-C + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* registers - registers useful to drivers are declared in the public header */ +/* PMIC / TOP */ +#define MAX77759_PMIC_REG_PMIC_ID 0x00 +#define MAX77759_PMIC_REG_PMIC_ID_MAX7775959 + +#define MAX77759_PMIC_REG_PMIC_REVISION 0x01 +#define MAX77759_PMIC_REG_OTP_REVISION0x02 + +#define MAX77759_PMIC_REG_INTSRC 0x22 +#define MAX77759_PMIC_REG_INTSRCMASK 0x23 +#define MAX77759_PMIC_REG_INTSRC_MAXQ BIT(3) +#define MAX77759_PMIC_REG_INTSRC_TOPSYS BIT(1) +#define MAX77759_PMIC_REG_INTSRC_CHGR BIT(0) + +#define MAX77759_PMIC_REG_TOPSYS_INT 0x24 +#define MAX77759_PMIC_REG_TOPSYS_INT_MASK 0x26 +#define MAX77759_PMIC_REG_TOPSYS_INT_TSHDNBIT(6) +#define MAX77759_PMIC_REG_TOPSYS_INT_SYSOVLO BIT(5) +#define MAX77759_PMIC_REG_TOPSYS_INT_SYSU
[PATCH v3 0/6] Maxim Integrated MAX77759 PMIC MFD-based drivers
Hi, This series improves support for the Maxim Integrated MAX77759 companion PMIC for USB Type-C applications using the MFD framework. This series must be applied in-order, due to interdependencies of some of the patches: * to avoid use of undocumented compatibles by the newly added drivers, the bindings are added first in this series * patch 1 ("dt-bindings: gpio: add max77759 binding") also creates a new MAINTAINERS entry, including a wildcard match for the other bindings in this series * patch 3 ("dt-bindings: mfd: add max77759 binding") references the bindings added in patch 1 and 2 and can not work if those aren't available * patch 4 ("mfd: max77759: add Maxim MAX77759 core mfd driver") adds the core MFD driver, which also exposes an API to its leaf drivers and is used by patches 5 and 6 * patches 5 and 6 won't compile without patch 4 The MAX77759 PMIC includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This PMIC is used on the Google Pixel 6 and 6 Pro (oriole / raven). This series adds support for the top-level MFD device, the gpio, and nvmem cells. Other components are excluded for the following reasons: While in the same package, Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, interrupt lines, and aren't part of the top-level package interrupt hierarchy. Furthermore, a driver for the TCPC part exists already (in drivers/usb/typec/tcpm/tcpci_maxim_core.c). I'm leaving out temperature sensors and charger in this submission, because the former are not in use on Pixel 6 and I therefore can not test them, and the latter can be added later, once we look at the whole charging topic in more detail. To make maintainers' work easier, I am planning to send the relevant DTS and defconfig changes via a different series, unless everything is expected to go via Lee's MFD tree in one series? Cheers, Andre' Signed-off-by: André Draszik --- Changes in v3: - collect tags - mfd: drop gpio-controller and gpio-cells, GPIO is provided by the child (Rob) - gpio: drop duplicate init of 'handled' variable in irq handler - gpio: use boolean with IRQ_RETVAL() (Linus) - gpio: drop 'virq' variable inside irq handler to avoid confusion (Linus) - gpio: drop assignment of struct gpio_chip::owner (Linus) - Link to v2: https://lore.kernel.org/r/20250226-max77759-mfd-v2-0-a65ebe2bc...@linaro.org Changes in v2: - reorder bindings patches to avoid validation failures - add dependency information to cover letter (Krzysztof) - fix max77759_gpio_direction_from_control() in gpio driver - gpio: drop 'interrupts' property from binding and sort properties alphabetically (Rob) - nvmem: drop example from nvmem binding as the MFD binding has a complete one (Rob) - nvmem: rename expected nvmem subdev nodename to 'nvmem-0' (Rob) - mfd: add kernel doc - mfd: fix an msec / usec typo - mfd: error handling of devm_mutex_init (Christophe) - whitespace fixes & tidy-ups (Christophe) - Link to v1: https://lore.kernel.org/r/20250224-max77759-mfd-v1-0-2bff36f9d...@linaro.org --- André Draszik (6): dt-bindings: gpio: add max77759 binding dt-bindings: nvmem: add max77759 binding dt-bindings: mfd: add max77759 binding mfd: max77759: add Maxim MAX77759 core mfd driver gpio: max77759: add Maxim MAX77759 gpio driver nvmem: max77759: add Maxim MAX77759 NVMEM driver .../bindings/gpio/maxim,max77759-gpio.yaml | 44 ++ .../devicetree/bindings/mfd/maxim,max77759.yaml| 99 +++ .../bindings/nvmem/maxim,max77759-nvmem.yaml | 32 + MAINTAINERS| 10 + drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77759.c | 524 +++ drivers/mfd/Kconfig| 20 + drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 737 + drivers/nvmem/Kconfig | 12 + drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + include/linux/mfd/max77759.h | 98 +++ 14 files changed, 1749 insertions(+) --- base-commit: 0226d0ce98a477937ed295fb7df4cc30b46fc304 change-id: 20250224-max77759-mfd-aaa7a3121b62 Best regards, -- André Draszik
[PATCH v3 3/6] dt-bindings: mfd: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes the top-level device. Signed-off-by: André Draszik --- v3: * drop gpio-controller and gpio-cells, GPIO is provided by the child (Rob) v2: * rename expected nvmem subdev nodename to 'nvmem-0' I'd have preferred just 'nvmem', but that matches nvmem-consumer.yaml and fails validation. Note: MAINTAINERS doesn't need updating, the binding update for the first leaf device (gpio) adds a wildcard matching all max77759 bindings --- .../devicetree/bindings/mfd/maxim,max77759.yaml| 99 ++ 1 file changed, 99 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml new file mode 100644 index ..525de9ab3c2b7b431e48497330640857540625b1 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications + +maintainers: + - André Draszik + +description: | + This is a part of device tree bindings for the MAX77759 companion Power + Management IC for USB Type-C applications. + + The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. + +properties: + compatible: +const: maxim,max77759 + + interrupts: +maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": +const: 2 + + reg: +maxItems: 1 + + gpio: +$ref: /schemas/gpio/maxim,max77759-gpio.yaml + + nvmem-0: +$ref: /schemas/nvmem/maxim,max77759-nvmem.yaml + +required: + - compatible + - interrupts + - reg + +additionalProperties: false + +examples: + - | +#include + +i2c { +#address-cells = <1>; +#size-cells = <0>; + +pmic@66 { +compatible = "maxim,max77759"; +reg = <0x66>; +interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>; + +interrupt-controller; +#interrupt-cells = <2>; + +gpio { +compatible = "maxim,max77759-gpio"; + +gpio-controller; +#gpio-cells = <2>; + +interrupt-controller; +#interrupt-cells = <2>; +}; + +nvmem-0 { +compatible = "maxim,max77759-nvmem"; + +nvmem-layout { +compatible = "fixed-layout"; +#address-cells = <1>; +#size-cells = <1>; + +reboot-mode@0 { +reg = <0x0 0x4>; +}; + +boot-reason@4 { +reg = <0x4 0x4>; +}; + +shutdown-user-flag@8 { +reg = <0x8 0x1>; +}; + +rsoc@10 { +reg = <0xa 0x2>; +}; +}; +}; +}; +}; -- 2.48.1.711.g2feabab25a-goog
[PATCH v3 1/6] dt-bindings: gpio: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes its GPIO module. Reviewed-by: Rob Herring (Arm) Signed-off-by: André Draszik --- v2: * drop 'interrupts' property and sort properties alphabetically --- .../bindings/gpio/maxim,max77759-gpio.yaml | 44 ++ MAINTAINERS| 6 +++ 2 files changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml new file mode 100644 index ..55734190d5ebdbc351e1f916758a9db80cd7 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/maxim,max77759-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 GPIO + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, a GPIO controller + including interrupt support for 2 GPIO lines. + +properties: + compatible: +const: maxim,max77759-gpio + + "#gpio-cells": +const: 2 + + gpio-controller: true + + gpio-line-names: +minItems: 1 +maxItems: 2 + + "#interrupt-cells": +const: 2 + + interrupt-controller: true + +required: + - compatible + - "#gpio-cells" + - gpio-controller + - "#interrupt-cells" + - interrupt-controller + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 86fa62154d3b23bf84ce2d53cbbdc33f3d43006e..a45d1bd64d116d14bc05a64fa3da852a41e1de7f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14347,6 +14347,12 @@ F: Documentation/devicetree/bindings/mfd/maxim,max77714.yaml F: drivers/mfd/max77714.c F: include/linux/mfd/max77714.h +MAXIM MAX77759 PMIC MFD DRIVER +M: André Draszik +L: linux-ker...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml + MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas L: linux-ker...@vger.kernel.org -- 2.48.1.711.g2feabab25a-goog
[PATCH v3 6/6] nvmem: max77759: add Maxim MAX77759 NVMEM driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This driver exposes the non volatile memory using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- v2: * align sentinel in max77759_nvmem_of_id[] with other max77759 drivers (Christophe) --- MAINTAINERS| 1 + drivers/nvmem/Kconfig | 12 drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + 4 files changed, 171 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ef3aadcf86ce35d8807733c94f790cde0f7255af..88c53e3fabe1760abf7914290c8729330739b0b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14354,6 +14354,7 @@ S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c +F: drivers/nvmem/max77759-nvmem.c F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 8671b7c974b933e147154bb40b5d41b5730518d2..3de07ef524906ad24a89e58abdfe93529a83c80f 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -154,6 +154,18 @@ config NVMEM_LPC18XX_OTP To compile this driver as a module, choose M here: the module will be called nvmem_lpc18xx_otp. +config NVMEM_MAX77759 + tristate "Maxim Integrated MAX77759 NVMEM Support" + depends on MFD_MAX77759 + default MFD_MAX77759 + help + Say Y here to include support for the user-accessible storage found + in Maxim Integrated MAX77759 PMICs. This IC provides space for 30 + bytes of storage. + + This driver can also be built as a module. If so, the module + will be called nvmem-max77759. + config NVMEM_MESON_EFUSE tristate "Amlogic Meson GX eFuse Support" depends on (ARCH_MESON || COMPILE_TEST) && MESON_SM diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 5b77bbb6488bf89bfb305750a1cbf4a6731a0a58..a9d03cfbbd27e68d40f8c330e72e20378b12a481 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -34,6 +34,8 @@ obj-$(CONFIG_NVMEM_LPC18XX_EEPROM)+= nvmem_lpc18xx_eeprom.o nvmem_lpc18xx_eeprom-y := lpc18xx_eeprom.o obj-$(CONFIG_NVMEM_LPC18XX_OTP)+= nvmem_lpc18xx_otp.o nvmem_lpc18xx_otp-y:= lpc18xx_otp.o +obj-$(CONFIG_NVMEM_MAX77759) += nvmem-max77759.o +nvmem-max77759-y := max77759-nvmem.o obj-$(CONFIG_NVMEM_MESON_EFUSE)+= nvmem_meson_efuse.o nvmem_meson_efuse-y:= meson-efuse.o obj-$(CONFIG_NVMEM_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o diff --git a/drivers/nvmem/max77759-nvmem.c b/drivers/nvmem/max77759-nvmem.c new file mode 100644 index ..bc535a73daaaf2caeb772cd17da61f8a030b6a6f --- /dev/null +++ b/drivers/nvmem/max77759-nvmem.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// NVMEM driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_NVMEM_OPCODE_HEADER_LEN 3 +/* + * NVMEM commands have a three byte header (which becomes part of the command), + * so we need to subtract that. + */ +#define MAX77759_NVMEM_SIZE (MAX77759_MAXQ_OPCODE_MAXLENGTH \ +- MAX77759_NVMEM_OPCODE_HEADER_LEN) + +struct max77759_nvmem { + struct device *dev; + struct max77759_mfd *max77759_mfd; +}; + +static bool max77759_nvmem_is_valid(unsigned int offset, size_t bytes) +{ + return (offset + bytes - 1 <= MAX77759_NVMEM_SIZE); +} + +static int max77759_nvmem_reg_read(void *priv, unsigned int offset, + void *val, size_t bytes) +{ + struct max77759_nvmem *nvmem = priv; + DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, + MAX77759_NVMEM_OPCODE_HEADER_LEN); + DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, + MAX77759_MAXQ_OPCODE_MAXLENGTH); + int ret; + + if (!max77759_nvmem_is_valid(offset, bytes)) { + dev_err(nvmem->dev, "outside NVMEM area: %u / %zu\n", + offset, bytes); + return -EINVAL; + } + + cmd->cmd[0] = MAX77759_MAXQ_OPCODE_USER_SPACE_READ; + cmd->cmd[1] = offset; + cmd->cmd[2] = bytes; + rsp->length = bytes + MAX77759_NVMEM_OPCODE_HEADER_LEN; + + ret = max77759_maxq_command(nvmem->max77759_mfd, cmd, rsp); + if (ret < 0) +
Re: [PATCH v2 3/6] dt-bindings: mfd: add max77759 binding
On Fri, 2025-02-28 at 07:01 -0600, Rob Herring wrote: > On Thu, Feb 27, 2025 at 7:14 AM André Draszik > wrote: > > > > On Thu, 2025-02-27 at 07:04 -0600, Rob Herring wrote: > > > > > > > > > Why do you have GPIO properties here and in the child node? Either would > > > be valid, but both probably not. Putting them here is actually > > > preferred. > > > > That's an oversight, I meant to put them into the child only, not here, > > since the child is the one providing the gpio functionality. > > > > What's the reason to have it preferred inside this parent node? > > It really depends whether the GPIO block is a separate sub-block which > is going to get reused or has its own resources or not. It's the same > thing in system controllers which are often just a collection of > leftover control bits. > > We just don't want child nodes created just for the ease of > instantiating drivers in Linux. While it's nice if drivers and nodes > are 1 to 1, but that's specific to an OS. > > You already need other child nodes here, so I don't care too much in this > case. Thanks Rob for taking the time and for the explanation! I'll keep that in mind for the future. Cheers, Andre'
Re: [PATCH v2 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
On Fri, 2025-02-28 at 10:58 +, André Draszik wrote: > Hi Linus, > > Thanks for you review! > > On Fri, 2025-02-28 at 08:10 +0100, Linus Walleij wrote: > > Hi André, > > > > thanks for your patch! > > > > mostly looks fine, given the MFD design is accepted. > > Nitpicks below: > > > > On Wed, Feb 26, 2025 at 6:51 PM André Draszik > > wrote: > > > > > +static irqreturn_t max77759_gpio_irqhandler(int irq, void *data) > > > +{ > > > + int handled = 0; > > > > bool handled = false; > > > > (...) > > > + for_each_set_bit(offset, &pending, MAX77759_N_GPIOS) { > > > + unsigned int virq; > > > > I usually just call this "irq", as it's not any more virtual than any other > > Linux magic number, and it can confuse people working with > > actual virtualization when we call things virtual like this. > > Calling it 'irq' would shadow the first argument of this irq > handler function, which is also and usually called irq and which > I'd like to avoid shadowing. > > Are you OK with 'subirq'? Or any other preference? Actually, there's no real need for that variable, I'll just drop it altogether: handle_nested_irq(irq_find_mapping(gc->irq.domain, offset)); A.
Re: [PATCH v2 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
Hi Linus, Thanks for you review! On Fri, 2025-02-28 at 08:10 +0100, Linus Walleij wrote: > Hi André, > > thanks for your patch! > > mostly looks fine, given the MFD design is accepted. > Nitpicks below: > > On Wed, Feb 26, 2025 at 6:51 PM André Draszik > wrote: > > > +static irqreturn_t max77759_gpio_irqhandler(int irq, void *data) > > +{ > > + int handled = 0; > > bool handled = false; > > (...) > > + for_each_set_bit(offset, &pending, MAX77759_N_GPIOS) { > > + unsigned int virq; > > I usually just call this "irq", as it's not any more virtual than any other > Linux magic number, and it can confuse people working with > actual virtualization when we call things virtual like this. Calling it 'irq' would shadow the first argument of this irq handler function, which is also and usually called irq and which I'd like to avoid shadowing. Are you OK with 'subirq'? Or any other preference? Cheers, Andre'
[PATCH v3 2/6] dt-bindings: nvmem: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes its storage module (NVMEM). Reviewed-by: Rob Herring (Arm) Signed-off-by: André Draszik --- v2: * drop example as the MFD binding has a complete one (Rob) Note: MAINTAINERS doesn't need updating, the binding update for the first leaf device (gpio) adds a wildcard matching all max77759 bindings --- .../bindings/nvmem/maxim,max77759-nvmem.yaml | 32 ++ 1 file changed, 32 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml new file mode 100644 index ..1e3bd4433007341a11040f513bf444866b9e38a8 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/maxim,max77759-nvmem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 Non Volatile Memory + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, Non Volatile Memory + (NVMEM) with 30 bytes of storage which can be used by software to store + information or communicate with a boot loader. + +properties: + compatible: +const: maxim,max77759-nvmem + + wp-gpios: false + +required: + - compatible + +allOf: + - $ref: nvmem.yaml# + +unevaluatedProperties: false -- 2.48.1.711.g2feabab25a-goog
[PATCH v4 4/6] mfd: max77759: add Maxim MAX77759 core mfd driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, and interrupt lines and are therefore excluded from the MFD core device driver here. The GPIO and NVMEM interfaces are accessed via specific commands to the built-in microprocessor. This driver implements an API that client drivers can use for accessing those. Signed-off-by: André Draszik --- v4: * add missing build_bug.h include * update an irq chip comment * fix a whitespace in register definitions v2: * add kernel doc for max77759_maxq_command() and related structs * fix an msec / usec typo * add missing error handling of devm_mutex_init() (Christophe) * align sentinel in max77759_of_id[] with max77759_i2c_id[] (Christophe) * some tidy-ups in max77759_maxq_command() (Christophe) --- MAINTAINERS | 2 + drivers/mfd/Kconfig | 20 ++ drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 738 +++ include/linux/mfd/max77759.h | 98 ++ 5 files changed, 859 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index a45d1bd64d116d14bc05a64fa3da852a41e1de7f..38844ea24e464d0b58f8852b79e2b94f18d48998 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,8 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/mfd/max77759.c +F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index d44c69bb3dfd52d53fe26aa2d5e5ace346448f57..1d72bf086401064608cc41e9f9a0af044c6df68e 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -930,6 +930,26 @@ config MFD_MAX77714 drivers must be enabled in order to use each functionality of the device. +config MFD_MAX77759 + tristate "Maxim Integrated MAX77759 PMIC" + depends on I2C + depends on OF + select IRQ_DOMAIN + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Say yes here to add support for Maxim Integrated MAX77759. + This is a companion Power Management IC for USB Type-C applications + with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C + Port Controller (TCPC), NVMEM, and additional GPIO interfaces. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + + To compile this driver as a module, choose M here: the module will be + called max77759. + config MFD_MAX77843 bool "Maxim Semiconductor MAX77843 PMIC Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 9220eaf7cf1255a8922430fe3e50e41771bbaa60..cc9362afd8f060d64ca0f0f028a0d7cfe9cfe512 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o obj-$(CONFIG_MFD_MAX77714) += max77714.o +obj-$(CONFIG_MFD_MAX77759) += max77759.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o max8925-objs := max8925-core.o max8925-i2c.o diff --git a/drivers/mfd/max77759.c b/drivers/mfd/max77759.c new file mode 100644 index ..a4f1616d600bde250a73b69464ada1fbf6d7e67e --- /dev/null +++ b/drivers/mfd/max77759.c @@ -0,0 +1,738 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// Core MFD driver for Maxim MAX77759 companion PMIC for USB Type-C + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* registers - registers useful to drivers are declared in the public header */ +/* PMIC / TOP */ +#define MAX77759_PMIC_REG_PMIC_ID 0x00 +#define MAX77759_PMIC_REG_PMIC_ID_MAX7775959 + +#define MAX77759_PMIC_REG_PMIC_REVISION 0x01 +#define MAX77759_PMIC_REG_OTP_REVISION0x02 + +#define MAX77759_PMIC_REG_INTSRC 0x22 +#define MAX77759_PMIC_REG_INTSRCMASK 0x23 +#define MAX77759_PMIC_REG_INTSRC_MAXQ BIT(3) +#define MAX77759_PMIC_REG_INTSRC_TOPSYS BIT(1) +#define MAX77759_PMIC_REG_INTSRC_CHGR BIT(0) + +#define MAX77759_PMIC_REG_TOPSYS_INT 0x24 +#define MAX77759_PMIC_REG_TOPSYS_INT_MASK 0x26 +#define MAX77759_PMIC_
[PATCH v4 5/6] gpio: max77759: add Maxim MAX77759 gpio driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This driver supports the GPIO functions using the platform device registered by the core MFD driver. Reviewed-by: Linus Walleij Acked-by: Bartosz Golaszewski Signed-off-by: André Draszik --- v3: * drop duplicate init of 'handled' variable in irq handler * use boolean with IRQ_RETVAL() (Linus) * drop 'virq' variable inside irq handler to avoid confusion (Linus) * drop assignment of struct gpio_chip::owner (Linus) v2: * fix max77759_gpio_direction_from_control() * add missing error handling of devm_mutex_init() (Christophe) * align sentinel in max77759_gpio_of_id[] with other max77759 drivers (Christophe) --- MAINTAINERS | 1 + drivers/gpio/Kconfig | 13 ++ drivers/gpio/Makefile| 1 + drivers/gpio/gpio-max77759.c | 524 +++ 4 files changed, 539 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 38844ea24e464d0b58f8852b79e2b94f18d48998..ef3aadcf86ce35d8807733c94f790cde0f7255af 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,7 @@ M: André Draszik L: linux-ker...@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml +F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c F: include/linux/mfd/max77759.h diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 3e9b174fee84142a8b50cdca5b967671eeda6dd3..216e80580fa443160c20da3e0916979fd08df99a 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1463,6 +1463,19 @@ config GPIO_MAX77650 GPIO driver for MAX77650/77651 PMIC from Maxim Semiconductor. These chips have a single pin that can be configured as GPIO. +config GPIO_MAX77759 + tristate "Maxim Integrated MAX77759 GPIO support" + depends on MFD_MAX77759 + default MFD_MAX77759 + select GPIOLIB_IRQCHIP + help + GPIO driver for MAX77759 PMIC from Maxim Integrated. + There are two GPIOs available on these chips in total, both of + which can also generate interrupts. + + This driver can also be built as a module. If so, the module will be + called gpio-max77759. + config GPIO_PALMAS bool "TI PALMAS series PMICs GPIO" depends on MFD_PALMAS diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index af130882ffeeef8b1d518867bfe1493ec4f21b5f..3b9a55f9f79eda33c135cfedb230ef7775b51bee 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -105,6 +105,7 @@ obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o obj-$(CONFIG_GPIO_MAX77620)+= gpio-max77620.o obj-$(CONFIG_GPIO_MAX77650)+= gpio-max77650.o +obj-$(CONFIG_GPIO_MAX77759)+= gpio-max77759.o obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o diff --git a/drivers/gpio/gpio-max77759.c b/drivers/gpio/gpio-max77759.c new file mode 100644 index ..b0f5d839a347e472cbe0b8624b534ecf8f21f64c --- /dev/null +++ b/drivers/gpio/gpio-max77759.c @@ -0,0 +1,524 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// GPIO driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_N_GPIOS ARRAY_SIZE(max77759_gpio_line_names) +static const char * const max77759_gpio_line_names[] = { "GPIO5", "GPIO6" }; + +struct max77759_gpio_chip { + struct regmap *map; + struct max77759_mfd *max77759_mfd; + struct gpio_chip gc; + struct mutex maxq_lock; /* protect MaxQ r/m/w operations */ + + struct mutex irq_lock; /* protect irq bus */ + int irq_mask; + int irq_mask_changed; + int irq_trig; + int irq_trig_changed; +}; + +#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs)) +#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0) +enum max77759_trigger_gpio_type { + MAX77759_GPIO_TRIGGER_RISING = 0, + MAX77759_GPIO_TRIGGER_FALLING = 1 +}; + +#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs +#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0) +enum max77759_control_gpio_dir { + MAX77759_GPIO_DIR_IN = 0, + MAX77759_GPIO_DIR_OUT = 1 +}; + +#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs +#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(o
[PATCH v4 6/6] nvmem: max77759: add Maxim MAX77759 NVMEM driver
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This driver exposes the non volatile memory using the platform device registered by the core MFD driver. Signed-off-by: André Draszik --- v2: * align sentinel in max77759_nvmem_of_id[] with other max77759 drivers (Christophe) --- MAINTAINERS| 1 + drivers/nvmem/Kconfig | 12 drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + 4 files changed, 171 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ef3aadcf86ce35d8807733c94f790cde0f7255af..88c53e3fabe1760abf7914290c8729330739b0b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14354,6 +14354,7 @@ S: Maintained F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml F: drivers/gpio/gpio-max77759.c F: drivers/mfd/max77759.c +F: drivers/nvmem/max77759-nvmem.c F: include/linux/mfd/max77759.h MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 8671b7c974b933e147154bb40b5d41b5730518d2..3de07ef524906ad24a89e58abdfe93529a83c80f 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -154,6 +154,18 @@ config NVMEM_LPC18XX_OTP To compile this driver as a module, choose M here: the module will be called nvmem_lpc18xx_otp. +config NVMEM_MAX77759 + tristate "Maxim Integrated MAX77759 NVMEM Support" + depends on MFD_MAX77759 + default MFD_MAX77759 + help + Say Y here to include support for the user-accessible storage found + in Maxim Integrated MAX77759 PMICs. This IC provides space for 30 + bytes of storage. + + This driver can also be built as a module. If so, the module + will be called nvmem-max77759. + config NVMEM_MESON_EFUSE tristate "Amlogic Meson GX eFuse Support" depends on (ARCH_MESON || COMPILE_TEST) && MESON_SM diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 5b77bbb6488bf89bfb305750a1cbf4a6731a0a58..a9d03cfbbd27e68d40f8c330e72e20378b12a481 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -34,6 +34,8 @@ obj-$(CONFIG_NVMEM_LPC18XX_EEPROM)+= nvmem_lpc18xx_eeprom.o nvmem_lpc18xx_eeprom-y := lpc18xx_eeprom.o obj-$(CONFIG_NVMEM_LPC18XX_OTP)+= nvmem_lpc18xx_otp.o nvmem_lpc18xx_otp-y:= lpc18xx_otp.o +obj-$(CONFIG_NVMEM_MAX77759) += nvmem-max77759.o +nvmem-max77759-y := max77759-nvmem.o obj-$(CONFIG_NVMEM_MESON_EFUSE)+= nvmem_meson_efuse.o nvmem_meson_efuse-y:= meson-efuse.o obj-$(CONFIG_NVMEM_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o diff --git a/drivers/nvmem/max77759-nvmem.c b/drivers/nvmem/max77759-nvmem.c new file mode 100644 index ..bc535a73daaaf2caeb772cd17da61f8a030b6a6f --- /dev/null +++ b/drivers/nvmem/max77759-nvmem.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright 2020 Google Inc +// Copyright 2025 Linaro Ltd. +// +// NVMEM driver for Maxim MAX77759 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX77759_NVMEM_OPCODE_HEADER_LEN 3 +/* + * NVMEM commands have a three byte header (which becomes part of the command), + * so we need to subtract that. + */ +#define MAX77759_NVMEM_SIZE (MAX77759_MAXQ_OPCODE_MAXLENGTH \ +- MAX77759_NVMEM_OPCODE_HEADER_LEN) + +struct max77759_nvmem { + struct device *dev; + struct max77759_mfd *max77759_mfd; +}; + +static bool max77759_nvmem_is_valid(unsigned int offset, size_t bytes) +{ + return (offset + bytes - 1 <= MAX77759_NVMEM_SIZE); +} + +static int max77759_nvmem_reg_read(void *priv, unsigned int offset, + void *val, size_t bytes) +{ + struct max77759_nvmem *nvmem = priv; + DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, + MAX77759_NVMEM_OPCODE_HEADER_LEN); + DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, + MAX77759_MAXQ_OPCODE_MAXLENGTH); + int ret; + + if (!max77759_nvmem_is_valid(offset, bytes)) { + dev_err(nvmem->dev, "outside NVMEM area: %u / %zu\n", + offset, bytes); + return -EINVAL; + } + + cmd->cmd[0] = MAX77759_MAXQ_OPCODE_USER_SPACE_READ; + cmd->cmd[1] = offset; + cmd->cmd[2] = bytes; + rsp->length = bytes + MAX77759_NVMEM_OPCODE_HEADER_LEN; + + ret = max77759_maxq_command(nvmem->max77759_mfd, cmd, rsp); + if (ret < 0) +
[PATCH v4 3/6] dt-bindings: mfd: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes the top-level device. Reviewed-by: Rob Herring (Arm) Signed-off-by: André Draszik --- v3: * drop gpio-controller and gpio-cells, GPIO is provided by the child (Rob) v2: * rename expected nvmem subdev nodename to 'nvmem-0' I'd have preferred just 'nvmem', but that matches nvmem-consumer.yaml and fails validation. Note: MAINTAINERS doesn't need updating, the binding update for the first leaf device (gpio) adds a wildcard matching all max77759 bindings --- .../devicetree/bindings/mfd/maxim,max77759.yaml| 99 ++ 1 file changed, 99 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml new file mode 100644 index ..525de9ab3c2b7b431e48497330640857540625b1 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications + +maintainers: + - André Draszik + +description: | + This is a part of device tree bindings for the MAX77759 companion Power + Management IC for USB Type-C applications. + + The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB + Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. + +properties: + compatible: +const: maxim,max77759 + + interrupts: +maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": +const: 2 + + reg: +maxItems: 1 + + gpio: +$ref: /schemas/gpio/maxim,max77759-gpio.yaml + + nvmem-0: +$ref: /schemas/nvmem/maxim,max77759-nvmem.yaml + +required: + - compatible + - interrupts + - reg + +additionalProperties: false + +examples: + - | +#include + +i2c { +#address-cells = <1>; +#size-cells = <0>; + +pmic@66 { +compatible = "maxim,max77759"; +reg = <0x66>; +interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>; + +interrupt-controller; +#interrupt-cells = <2>; + +gpio { +compatible = "maxim,max77759-gpio"; + +gpio-controller; +#gpio-cells = <2>; + +interrupt-controller; +#interrupt-cells = <2>; +}; + +nvmem-0 { +compatible = "maxim,max77759-nvmem"; + +nvmem-layout { +compatible = "fixed-layout"; +#address-cells = <1>; +#size-cells = <1>; + +reboot-mode@0 { +reg = <0x0 0x4>; +}; + +boot-reason@4 { +reg = <0x4 0x4>; +}; + +shutdown-user-flag@8 { +reg = <0x8 0x1>; +}; + +rsoc@10 { +reg = <0xa 0x2>; +}; +}; +}; +}; +}; -- 2.49.0.rc0.332.g42c0ae87b1-goog
[PATCH v4 2/6] dt-bindings: nvmem: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes its storage module (NVMEM). Reviewed-by: Rob Herring (Arm) Signed-off-by: André Draszik --- v2: * drop example as the MFD binding has a complete one (Rob) Note: MAINTAINERS doesn't need updating, the binding update for the first leaf device (gpio) adds a wildcard matching all max77759 bindings --- .../bindings/nvmem/maxim,max77759-nvmem.yaml | 32 ++ 1 file changed, 32 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml new file mode 100644 index ..1e3bd4433007341a11040f513bf444866b9e38a8 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/maxim,max77759-nvmem.yaml @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/maxim,max77759-nvmem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 Non Volatile Memory + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, Non Volatile Memory + (NVMEM) with 30 bytes of storage which can be used by software to store + information or communicate with a boot loader. + +properties: + compatible: +const: maxim,max77759-nvmem + + wp-gpios: false + +required: + - compatible + +allOf: + - $ref: nvmem.yaml# + +unevaluatedProperties: false -- 2.49.0.rc0.332.g42c0ae87b1-goog
[PATCH v4 1/6] dt-bindings: gpio: add max77759 binding
The Maxim MAX77759 is a companion PMIC for USB Type-C applications and includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This describes its GPIO module. Reviewed-by: Rob Herring (Arm) Signed-off-by: André Draszik --- v2: * drop 'interrupts' property and sort properties alphabetically --- .../bindings/gpio/maxim,max77759-gpio.yaml | 44 ++ MAINTAINERS| 6 +++ 2 files changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml new file mode 100644 index ..55734190d5ebdbc351e1f916758a9db80cd7 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/maxim,max77759-gpio.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/maxim,max77759-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX77759 GPIO + +maintainers: + - André Draszik + +description: | + This module is part of the MAX77759 PMIC. For additional information, see + Documentation/devicetree/bindings/mfd/maxim,max77759.yaml. + + The MAX77759 is a PMIC integrating, amongst others, a GPIO controller + including interrupt support for 2 GPIO lines. + +properties: + compatible: +const: maxim,max77759-gpio + + "#gpio-cells": +const: 2 + + gpio-controller: true + + gpio-line-names: +minItems: 1 +maxItems: 2 + + "#interrupt-cells": +const: 2 + + interrupt-controller: true + +required: + - compatible + - "#gpio-cells" + - gpio-controller + - "#interrupt-cells" + - interrupt-controller + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 86fa62154d3b23bf84ce2d53cbbdc33f3d43006e..a45d1bd64d116d14bc05a64fa3da852a41e1de7f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14347,6 +14347,12 @@ F: Documentation/devicetree/bindings/mfd/maxim,max77714.yaml F: drivers/mfd/max77714.c F: include/linux/mfd/max77714.h +MAXIM MAX77759 PMIC MFD DRIVER +M: André Draszik +L: linux-ker...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/*/maxim,max77759*.yaml + MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas L: linux-ker...@vger.kernel.org -- 2.49.0.rc0.332.g42c0ae87b1-goog
[PATCH v4 0/6] Maxim Integrated MAX77759 PMIC MFD-based drivers
Hi, This series improves support for the Maxim Integrated MAX77759 companion PMIC for USB Type-C applications using the MFD framework. This series must be applied in-order, due to interdependencies of some of the patches: * to avoid use of undocumented compatibles by the newly added drivers, the bindings are added first in this series * patch 1 ("dt-bindings: gpio: add max77759 binding") also creates a new MAINTAINERS entry, including a wildcard match for the other bindings in this series * patch 3 ("dt-bindings: mfd: add max77759 binding") references the bindings added in patch 1 and 2 and can not work if those aren't available * patch 4 ("mfd: max77759: add Maxim MAX77759 core mfd driver") adds the core MFD driver, which also exposes an API to its leaf drivers and is used by patches 5 and 6 * patches 5 and 6 won't compile without patch 4 The MAX77759 PMIC includes Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander. This PMIC is used on the Google Pixel 6 and 6 Pro (oriole / raven). This series adds support for the top-level MFD device, the gpio, and nvmem cells. Other components are excluded for the following reasons: While in the same package, Fuel Gauge and TCPC have separate and independent I2C addresses, register maps, interrupt lines, and aren't part of the top-level package interrupt hierarchy. Furthermore, a driver for the TCPC part exists already (in drivers/usb/typec/tcpm/tcpci_maxim_core.c). I'm leaving out temperature sensors and charger in this submission, because the former are not in use on Pixel 6 and I therefore can not test them, and the latter can be added later, once we look at the whole charging topic in more detail. To make maintainers' work easier, I am planning to send the relevant DTS and defconfig changes via a different series, unless everything is expected to go via Lee's MFD tree in one series? Cheers, Andre' Signed-off-by: André Draszik --- Changes in v4: - collect tags - mfd: add missing build_bug.h include - mfd: update an irq chip comment - mfd: fix a whitespace in register definitions - Link to v3: https://lore.kernel.org/r/20250228-max77759-mfd-v3-0-0c3627d42...@linaro.org Changes in v3: - collect tags - mfd: drop gpio-controller and gpio-cells, GPIO is provided by the child (Rob) - gpio: drop duplicate init of 'handled' variable in irq handler - gpio: use boolean with IRQ_RETVAL() (Linus) - gpio: drop 'virq' variable inside irq handler to avoid confusion (Linus) - gpio: drop assignment of struct gpio_chip::owner (Linus) - Link to v2: https://lore.kernel.org/r/20250226-max77759-mfd-v2-0-a65ebe2bc...@linaro.org Changes in v2: - reorder bindings patches to avoid validation failures - add dependency information to cover letter (Krzysztof) - fix max77759_gpio_direction_from_control() in gpio driver - gpio: drop 'interrupts' property from binding and sort properties alphabetically (Rob) - nvmem: drop example from nvmem binding as the MFD binding has a complete one (Rob) - nvmem: rename expected nvmem subdev nodename to 'nvmem-0' (Rob) - mfd: add kernel doc - mfd: fix an msec / usec typo - mfd: error handling of devm_mutex_init (Christophe) - whitespace fixes & tidy-ups (Christophe) - Link to v1: https://lore.kernel.org/r/20250224-max77759-mfd-v1-0-2bff36f9d...@linaro.org --- André Draszik (6): dt-bindings: gpio: add max77759 binding dt-bindings: nvmem: add max77759 binding dt-bindings: mfd: add max77759 binding mfd: max77759: add Maxim MAX77759 core mfd driver gpio: max77759: add Maxim MAX77759 gpio driver nvmem: max77759: add Maxim MAX77759 NVMEM driver .../bindings/gpio/maxim,max77759-gpio.yaml | 44 ++ .../devicetree/bindings/mfd/maxim,max77759.yaml| 99 +++ .../bindings/nvmem/maxim,max77759-nvmem.yaml | 32 + MAINTAINERS| 10 + drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77759.c | 524 +++ drivers/mfd/Kconfig| 20 + drivers/mfd/Makefile | 1 + drivers/mfd/max77759.c | 738 + drivers/nvmem/Kconfig | 12 + drivers/nvmem/Makefile | 2 + drivers/nvmem/max77759-nvmem.c | 156 + include/linux/mfd/max77759.h | 98 +++ 14 files changed, 1750 insertions(+) --- base-commit: 0226d0ce98a477937ed295fb7df4cc30b46fc304 change-id: 20250224-max77759-mfd-aaa7a3121b62 Best regards, -- André Draszik