Add support for Maxim Integrated MAX77705 MFD
Subsystems (7)
v6 cover Add support for Maxim Integrated MAX77705 MFD
The Maxim MAX77705 is a Companion Power Management and Type-C interface IC which includes charger, fuelgauge, LED, haptic motor driver and Type-C management IC. It's used in Samsung S series smart phones starting from S9 model.
Add features:
- charger
- fuelgauge
- haptic
- led
---
Changes in v6:
- fix binding review comments
- update trailers
- Link to v5: https://lore.kernel.org/r/20240617-starqltechn_integration_upstream-v5-0-e0033f141d17@gmail.com
Changes in v5:
- Split patchset per subsystem
- Link to v4: https://lore.kernel.org/r/20240913-starqltechn_integration_upstream-v4-0-2d2efd5c5877@gmail.com
Changes in v4:
- Rewrite max77705, max77705_charger, max77705_fuel_gauge from scratch
- Reorder patches:
- squash max77705 subdevice bindings in core file because
no resources there
- split device tree changes
- Use _ as space for filenames in power/supply like the majority
- Link to v3: https://lore.kernel.org/r/20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com
---
Dzmitry Sankouski (7):
power: supply: add undervoltage health status property
dt-bindings: mfd: add maxim,max77705
mfd: Add new driver for MAX77705 PMIC
input: max77693: add max77705 haptic support
power: supply: max77705: Add charger driver for Maxim 77705
power: supply: max77705: Add fuel gauge driver for Maxim 77705
leds: max77705: Add LEDs support
Documentation/ABI/testing/sysfs-class-power | 2 +- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 174 +++++++++++++++++++++++++++++++ MAINTAINERS | 4 + drivers/input/misc/Kconfig | 4 +- drivers/input/misc/Makefile | 1 + drivers/input/misc/max77693-haptic.c | 15 ++- drivers/leds/Kconfig | 6 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 157 ++++++++++++++++++++++++++++ drivers/mfd/Kconfig | 12 +++ drivers/mfd/Makefile | 2 + drivers/mfd/max77705.c | 248 +++++++++++++++++++++++++++++++++++++++++++++ drivers/power/supply/Kconfig | 13 +++ drivers/power/supply/Makefile | 2 + drivers/power/supply/max77705_charger.c | 585 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/power/supply/max77705_fuel_gauge.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/mfd/max77693-common.h | 6 +- include/linux/mfd/max77705-private.h | 180 +++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 215 +++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_fuelgauge.h | 65 ++++++++++++ include/linux/power_supply.h | 1 + 22 files changed, 2037 insertions(+), 5 deletions(-)
---
base-commit: 58ca61c1a866bfdaa5e19fb19a2416764f847d75
change-id: 20240617-starqltechn_integration_upstream-bc86850b2fe3
Best regards,
Signature · 1 line
Dzmitry Sankouski <[email protected]>
PATCH v6 1/7 power: supply: add undervoltage health status property
Add POWER_SUPPLY_HEALTH_UNDERVOLTAGE status for power supply to report under voltage lockout failures.
---
Changes for v5:
- update Documentation/ABI/testing/sysfs-class-power and drivers/power/supply/power_supply_sysfs.c
--- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-class-power +1 -1
@@ -433,7 +433,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", - "Over voltage", "Unspecified failure", "Cold", + "Over voltage", "Under voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", "Over current", "Calibration required", "Warm", "Cool", "Hot", "No battery"
drivers/power/supply/power_supply_sysfs.c +1 -0
@@ -99,6 +99,7 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_OVERHEAT] = "Overheat", [POWER_SUPPLY_HEALTH_DEAD] = "Dead", [POWER_SUPPLY_HEALTH_OVERVOLTAGE] = "Over voltage", + [POWER_SUPPLY_HEALTH_UNDERVOLTAGE] = "Under voltage", [POWER_SUPPLY_HEALTH_UNSPEC_FAILURE] = "Unspecified failure", [POWER_SUPPLY_HEALTH_COLD] = "Cold", [POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE] = "Watchdog timer expire",
include/linux/power_supply.h +1 -0
@@ -58,6 +58,7 @@ enum {POWER_SUPPLY_HEALTH_OVERHEAT ,POWER_SUPPLY_HEALTH_DEAD ,POWER_SUPPLY_HEALTH_OVERVOLTAGE , +POWER_SUPPLY_HEALTH_UNDERVOLTAGE ,POWER_SUPPLY_HEALTH_UNSPEC_FAILURE ,POWER_SUPPLY_HEALTH_COLD , POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,
Signature · 1 line
2.39.2
PATCH v6 2/7 dt-bindings: mfd: add maxim,max77705
In reply to Dzmitry SankouskiAdd maxim,max77705 core binding part.
---
Changes in v6:
- unevaluatedProperties must be false
- drop excessive sentence from description,
just describe the device
Changes in v5:
- formatting changes
- add unevaluatedProperties: false for nodes referencing common schemas
- remove additionalProperties on nodes with
unevaluatedProperties: false
- add min and max to led index
Changes in v4:
- change dts example intendation from tabs
to spaces
- remove interrupt-names property
- remove obvious reg description
- split long(>80) lines
--- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 175 insertions(+)
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +174 -0
@@ -0,0 +1,174 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC + +maintainers: + - Dzmitry Sankouski <[email protected]> + +description: | + The Maxim MAX77705 is a Companion Power Management and Type-C + interface IC which includes charger, fuelgauge, LED, haptic motor driver and + Type-C management IC. + +properties: + compatible: + const: maxim,max77705 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + charger: + $ref: /schemas/power/supply/power-supply.yaml + unevaluatedProperties: false + properties: + compatible: + const: maxim,max77705-charger + + required: + - compatible + - monitored-battery + + fuel-gauge: + $ref: /schemas/power/supply/power-supply.yaml + type: object + unevaluatedProperties: false + description: MAX77705 fuel gauge with ModelGauge m5 EZ algorithm support. + + properties: + compatible: + const: maxim,max77705-fuel-gauge + + shunt-resistor-micro-ohms: + description: + The value of current sense resistor in microohms. + + required: + - compatible + - shunt-resistor-micro-ohms + - monitored-battery + - power-supplies + + haptic: + type: object + additionalProperties: false + + properties: + compatible: + const: maxim,max77705-haptic + + haptic-supply: true + + pwms: + maxItems: 1 + + required: + - compatible + - haptic-supply + - pwms + + leds: + type: object + additionalProperties: false + description: + Up to 4 LEDs supported. One LED is represented by one child node. + + properties: + compatible: + const: maxim,max77705-led + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[0-3]$": + $ref: /schemas/leds/common.yaml# + type: object + unevaluatedProperties: false + + properties: + reg: + description: LED index. + minimum: 0 + maximum: 3 + + required: + - reg + + required: + - compatible + - "#address-cells" + - "#size-cells" + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/leds/common.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max77705"; + reg = <0x66>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&chg_int_default>; + pinctrl-names = "default"; + + leds { + compatible = "maxim,max77705-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + label = "red:usr1"; + }; + + led@2 { + reg = <2>; + label = "green:usr2"; + }; + + led@3 { + reg = <3>; + label = "blue:usr3"; + }; + }; + + max77705_charger: charger { + compatible = "maxim,max77705-charger"; + monitored-battery = <&battery>; + }; + + fuel-gauge { + compatible = "maxim,max77705-fuel-gauge"; + monitored-battery = <&battery>; + power-supplies = <&max77705_charger>; + shunt-resistor-micro-ohms = <5000>; + }; + + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; + };
MAINTAINERS +1 -0
@@ -14071,6 +14071,7 @@ B: mailto:[email protected] F: Documentation/devicetree/bindings/*/maxim,max14577.yaml F: Documentation/devicetree/bindings/*/maxim,max77686.yaml F: Documentation/devicetree/bindings/*/maxim,max77693.yaml +F: Documentation/devicetree/bindings/*/maxim,max77705*.yaml F: Documentation/devicetree/bindings/*/maxim,max77843.yaml F: Documentation/devicetree/bindings/clock/maxim,max77686.txt F: drivers/*/*max77843.c
Signature · 1 line
2.39.2
Re: [PATCH v6 2/7] dt-bindings: mfd: add maxim,max77705
Quoted 23 lines · Dzmitry Sankouski
Add maxim,max77705 core binding part.
Signed-off-by Dzmitry Sankouski <[email protected]>---
Changes in v6:
- unevaluatedProperties must be false
- drop excessive sentence from description,
just describe the deviceChanges in v5:
- formatting changes
- add unevaluatedProperties: false for nodes referencing common schemas
- remove additionalProperties on nodes with
unevaluatedProperties: false
- add min and max to led index
Changes in v4:
- change dts example intendation from tabs
to spaces
- remove interrupt-names property
- remove obvious reg description
- split long(>80) lines
Quoted 5 lines
--- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 175 insertions(+)
PATCH v6 3/7 mfd: Add new driver for MAX77705 PMIC
In reply to Dzmitry SankouskiAdd the core MFD driver for max77705 PMIC. We define five sub-devices for which the drivers will be added in subsequent patches.
---
Changes for v5:
- license change to 2.0
- use same hardware name in Kconfig and module descriptions Changes for v4:
- rework driver from scratch
- migrate to regmap_add_irq_chip, remove max77705-irq.c, rename max77705-core.c to max77705.c
- cleanup headers
- remove debugfs code
- migrate to use max77693_dev structure
- remove max77705.h
--- MAINTAINERS | 2 ++ drivers/mfd/Kconfig | 12 +++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/max77705.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 6 +++- include/linux/mfd/max77705-private.h | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 449 insertions(+), 1 deletion(-)
MAINTAINERS +2 -0
@@ -14078,6 +14078,7 @@ F: drivers/*/*max77843.c F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c +F: drivers/*/max77705*.c F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.c
@@ -14085,6 +14086,7 @@ F: drivers/rtc/rtc-max77686.c F: include/linux/mfd/max14577*.h F: include/linux/mfd/max77686*.h F: include/linux/mfd/max77693*.h +F: include/linux/mfd/max77705*.h MAXIRADIO FM RADIO RECEIVER DRIVER M: Hans Verkuil <[email protected]>
drivers/mfd/Kconfig +12 -0
@@ -904,6 +904,18 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77705 + tristate "Maxim MAX77705 PMIC Support" + depends on I2C + select MFD_CORE + help + Say yes here to add support for Maxim Integrated MAX77705. + This is a Power Management IC with Charger, safe LDOs, Flash, Haptic + and MUIC controls on chip. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MAX77714 tristate "Maxim Semiconductor MAX77714 PMIC Support" depends on I2C
drivers/mfd/Makefile +2 -0
@@ -167,6 +167,7 @@ obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o +obj-$(CONFIG_MFD_MAX77705) += max77705.o obj-$(CONFIG_MFD_MAX77714) += max77714.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o
@@ -232,6 +233,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o +obj-$(CONFIG_MFD_S2DOS05) += s2dos05.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.o
drivers/mfd/max77705.c new file +248 -0
248 lines not on this page · raw message
include/linux/mfd/max77693-common.h +5 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* -* Common data shared between Maxim 77693 and 77843 drivers +* Common data shared between Maxim 77693, 77705 and 77843 drivers * * Copyright (C) 2015 Samsung Electronics */
@@ -11,6 +11,7 @@enum max77693_types {TYPE_MAX77693_UNKNOWN ,TYPE_MAX77693 , +TYPE_MAX77705 ,TYPE_MAX77843 ,TYPE_MAX77693_NUM ,
@@ -25,6 +26,7 @@ struct max77693_dev {struct i2c_client *i2c_muic;/* 0x4A , MUIC */ struct i2c_client *i2c_haptic;/* MAX77693: 0x90 , Haptic */ struct i2c_client *i2c_chg;/* MAX77843: 0xD2, Charger */ +struct i2c_client *i2c_fg;/* MAX77843: 0xD2, Charger */ enum max77693_types type;
@@ -32,6 +34,8 @@ struct max77693_dev {struct regmap *regmap_muic;struct regmap *regmap_haptic;/* Only MAX77693 */ struct regmap *regmap_chg;/* Only MAX77843 */ +struct regmap *regmap_fg;/* Only MAX77705 */ +struct regmap *regmap_leds;/* Only MAX77705 */ struct regmap_irq_chip_data *irq_data_led;struct regmap_irq_chip_data *irq_data_topsys;
include/linux/mfd/max77705-private.h new file +180 -0
180 lines not on this page · raw message
Signature · 1 line
2.39.2
Lee Jones
maintainerRe: [PATCH v6 3/7] mfd: Add new driver for MAX77705 PMIC
Quoted 51 lines · Dzmitry Sankouski
Add the core MFD driver for max77705 PMIC. We define five sub-devices for which the drivers will be added in subsequent patches.
Signed-off-by Dzmitry Sankouski <[email protected]>---
Changes for v5:
- license change to 2.0
- use same hardware name inKconfigand module descriptions Changes for v4:
- rework driver from scratch
- migrate toregmap_add_irq_chip, removemax77705-irq.c, renamemax77705-core.ctomax77705.c
- cleanup headers
- remove debugfs code
- migrate to usemax77693_devstructure
- removemax77705.h--- MAINTAINERS | 2 ++ drivers/mfd/Kconfig | 12 +++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/max77705.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 6 +++- include/linux/mfd/max77705-private.h | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 449 insertions(+), 1 deletion(-)MAINTAINERS +2
-0@@ -14078,6 +14078,7 @@ F: drivers/*/*max77843.c F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c +F: drivers/*/max77705*.c F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.c@@ -14085,6 +14086,7 @@ F: drivers/rtc/rtc-max77686.c F: include/linux/mfd/max14577*.h F: include/linux/mfd/max77686*.h F: include/linux/mfd/max77693*.h +F: include/linux/mfd/max77705*.h MAXIRADIO FM RADIO RECEIVER DRIVER M: Hans Verkuil <[email protected]>drivers/mfd/Kconfig +0
-0
drivers/mfd/Kconfig config MFD_MAX77693 · line 912
Quoted 9 lines
drivers/mfd/Kconfig +6
-0@@ -904,6 +904,18 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77705 + tristate "Maxim MAX77705 PMIC Support" + depends on I2C + select MFD_CORE + help + Say yes here to add support for Maxim Integrated MAX77705.
"Integrated MAX77705 PMIC."
Quoted 35 lines
drivers/mfd/Kconfig +6
-0+ This is a Power Management IC with Charger, safe LDOs, Flash, Haptic + and MUIC controls on chip. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MAX77714 tristate "Maxim Semiconductor MAX77714 PMIC Support" depends on I2Cdrivers/mfd/Makefile +2
-0@@ -167,6 +167,7 @@ obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o +obj-$(CONFIG_MFD_MAX77705) += max77705.o obj-$(CONFIG_MFD_MAX77714) += max77714.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o@@ -232,6 +233,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o +obj-$(CONFIG_MFD_S2DOS05) += s2dos05.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.odrivers/mfd/max77705.c new file +0
-0
drivers/mfd/max77705.c line 3
Quoted 3 lines
drivers/mfd/max77705.c new file +3
-0@@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// max77705.c - mfd core driver for the MAX77705
No filenames in headers please - they have a habit of going out of date.
Drop references to "MFD":
* Maxim MAX77705 PMIC core driver
drivers/mfd/max77705.c line 4
Quoted 1 line
drivers/mfd/max77705.c new file +1
-0+// Copyright (C) 2024 Dzmitry Sankouski <[email protected]>
Only the SPDX in C++ comments please.
drivers/mfd/max77705.c line 14
Quoted 9 lines
drivers/mfd/max77705.c new file +9
-0+ +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/mfd/core.h> +#include <linux/mfd/max77705-private.h> +#include <linux/mfd/max77693-common.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/regmap.h>
Alphabetical please.
drivers/mfd/max77705.c line 17
Quoted 3 lines
drivers/mfd/max77705.c new file +3
-0+ +#define I2C_ADDR_CHG (0xD2 >> 1) +#define I2C_ADDR_FG (0x6C >> 1)
Why are these being shifted?
drivers/mfd/max77705.c line 21
Quoted 4 lines
drivers/mfd/max77705.c new file +4
-0+ +static struct mfd_cell max77705_devs[] = { + { + .name ="leds-max77705-rgb" ,
Why is 'leds' prefixed here?
drivers/mfd/max77705.c line 22
Quoted 1 line
drivers/mfd/max77705.c new file +1
-0+ .of_compatible = "maxim,max77705-led",
Is it a straight LED or RGB?
Quoted 96 lines
drivers/mfd/max77705.c new file +96
-0+ }, + { + .name = "max77705-fuel-gauge", + .of_compatible = "maxim,max77705-fuel-gauge", + }, + { + .name = "max77705-charger", + .of_compatible = "maxim,max77705-charger", + }, + { + .name = "max77705-haptic", + .of_compatible = "maxim,max77705-haptic", + }, +}; + +static const struct regmap_range max77705_readable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_PMICID1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), +}; + +static const struct regmap_range max77705_writable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_MAINCTRL1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), + +}; + +static const struct regmap_access_table max77705_readable_table = { + .yes_ranges = max77705_readable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_readable_ranges), +}; + +static const struct regmap_access_table max77705_writable_table = { + .yes_ranges = max77705_writable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_writable_ranges), +}; + +static const struct regmap_config max77705_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .rd_table = &max77705_readable_table, + .wr_table = &max77705_writable_table, + .max_register = MAX77705_PMIC_REG_USBC_RESET, +}; + +static const struct regmap_config max77705_leds_regmap_config = { + .reg_base = MAX77705_RGBLED_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_LED_REG_END, +}; + +static const struct regmap_config max77705_chg_regmap_config = { + .reg_base = MAX77705_CHG_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_CHG_REG_SAFEOUT_CTRL, +}; + +static const struct regmap_config max77705_fg_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_FG_END, +}; + +static const struct regmap_irq max77705_topsys_irqs[] = { + { .mask = MAX77705_SYSTEM_IRQ_BSTEN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSUVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSOVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TSHDN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TM_INT, }, +}; + +static const struct regmap_irq_chip max77705_topsys_irq_chip = { + .name = "max77705-topsys", + .status_base = MAX77705_PMIC_REG_SYSTEM_INT, + .mask_base = MAX77705_PMIC_REG_SYSTEM_INT_MASK, + .num_regs = 1, + .irqs = max77705_topsys_irqs, + .num_irqs = ARRAY_SIZE(max77705_topsys_irqs), +}; + +static int max77705_i2c_probe(struct i2c_client *i2c) +{ + struct max77693_dev *max77705;
drivers/mfd/max77705.c line 128
Quoted 10 lines
drivers/mfd/max77705.c new file +10
-0+struct i2c_client *i2c_chg; +struct i2c_client *i2c_fg; +struct regmap_irq_chip_data *irq_data; +struct irq_domain *domain; +int ret; +unsigned int pmic_rev_value; +u8 pmic_ver, pmic_rev; + + + max77705 = devm_kzalloc(&i2c->dev, sizeof(struct max77693_dev),
sizeof(*max77705)
drivers/mfd/max77705.c line 129
Quoted 1 line
drivers/mfd/max77705.c new file +1
-0+ GFP_KERNEL);
Why wrap here? You're using 100-chars above.
Quoted 7 lines
drivers/mfd/max77705.c new file +7
-0+if (!max77705) +return -ENOMEM ; + + max77705->dev = &i2c->dev; + max77705->irq = i2c->irq; + max77705->type =TYPE_MAX77705 ; +i2c_set_clientdata (i2c, max77705);
drivers/mfd/max77705.c line 146
Quoted 10 lines
drivers/mfd/max77705.c new file +10
-0+ + max77705->regmap =devm_regmap_init_i2c (i2c, &max77705_regmap_config); +if (IS_ERR (max77705->regmap)) +return PTR_ERR (max77705->regmap); + +if (regmap_read (max77705->regmap,MAX77705_PMIC_REG_PMICREV , &pmic_rev_value) <0 ) +return -ENODEV ; + + pmic_rev = (pmic_rev_value &MAX77705_REVISION_MASK ); + pmic_ver = ((pmic_rev_value &MAX77705_VERSION_MASK ) >>MAX77705_VERSION_SHIFT );
Over-bracketing.
drivers/mfd/max77705.c line 148
Quoted 2 lines
drivers/mfd/max77705.c new file +2
-0+dev_dbg (max77705->dev,"device found: rev.0x%x, ver.0x%x\n" , + pmic_rev, pmic_ver);
Is this ever going to be useful after initial development?
drivers/mfd/max77705.c line 151
Quoted 3 lines
drivers/mfd/max77705.c new file +3
-0+if (pmic_rev !=MAX77705_PASS3 ) { +dev_err (max77705->dev,"rev.0x%x is not tested" , + pmic_rev);
... especially since you're going to print unexpected values out anyway.
drivers/mfd/max77705.c line 160
Quoted 9 lines
drivers/mfd/max77705.c new file +9
-0+return -ENODEV ; + } + + max77705->regmap_leds =devm_regmap_init_i2c (i2c, &max77705_leds_regmap_config); +if (IS_ERR (max77705->regmap_leds)) +return PTR_ERR (max77705->regmap_leds); + + i2c_chg =devm_i2c_new_dummy_device (max77705->dev, + i2c->adapter,I2C_ADDR_CHG );
'\n' here.
drivers/mfd/max77705.c line 162
Quoted 2 lines
drivers/mfd/max77705.c new file +2
-0+ max77705->regmap_chg =devm_regmap_init_i2c (i2c_chg, + &max77705_chg_regmap_config);
Why not create this in the CHG driver?
drivers/mfd/max77705.c line 169
Quoted 7 lines
drivers/mfd/max77705.c new file +7
-0+if (IS_ERR (max77705->regmap_chg)) +return PTR_ERR (max77705->regmap_chg); + + i2c_fg =devm_i2c_new_dummy_device (max77705->dev, i2c->adapter, +I2C_ADDR_FG ); + max77705->regmap_fg =devm_regmap_init_i2c (i2c_fg, + &max77705_fg_regmap_config);
Why not create this in the FG driver?
Quoted 5 lines
drivers/mfd/max77705.c new file +5
-0+if (IS_ERR (max77705->regmap_fg)) +return PTR_ERR (max77705->regmap_fg); + + ret = devm_regmap_add_irq_chip(max77705->dev, max77705->regmap, + max77705->irq,
drivers/mfd/max77705.c line 184
Quoted 10 lines
drivers/mfd/max77705.c new file +10
-0+IRQF_ONESHOT |IRQF_SHARED ,0 , + &max77705_topsys_irq_chip, + &irq_data); +if (ret) +dev_err (max77705->dev,"failed to add irq chip: %d\n" , ret); + +/* Unmask interrupts from all blocks in interrupt source register */ + ret =regmap_update_bits (max77705->regmap, +MAX77705_PMIC_REG_INTSRC_MASK , +MAX77705_SRC_IRQ_ALL , (unsigned int )~MAX77705_SRC_IRQ_ALL );
Why the cast?
drivers/mfd/max77705.c line 187
Quoted 3 lines
drivers/mfd/max77705.c new file +3
-0+if (ret <0 ) +dev_err (max77705->dev, +"Could not unmask interrupts in INTSRC: %d\n" , ret);
If it's an error, you should return.
drivers/mfd/max77705.c line 189
Quoted 1 line
drivers/mfd/max77705.c new file +1
-0+ domain =regmap_irq_get_domain (irq_data);
'\n' here.
drivers/mfd/max77705.c line 194
Quoted 5 lines
drivers/mfd/max77705.c new file +5
-0+ ret =devm_mfd_add_devices (max77705->dev,PLATFORM_DEVID_NONE , + max77705_devs,ARRAY_SIZE (max77705_devs), +NULL ,0 , domain); +if (ret) { +dev_err (max77705->dev,"failed to add MFD devices: %d\n" , ret);
Failed to register child devices.
Quoted 4 lines
drivers/mfd/max77705.c new file +4
-0+return ret; + } + +device_init_wakeup (max77705->dev, true);
drivers/mfd/max77705.c line 208
Quoted 10 lines
drivers/mfd/max77705.c new file +10
-0+ +return 0 ; +} + +static int max77705_suspend (struct device *dev) +{ +struct i2c_client *i2c =to_i2c_client (dev); +struct max77693_dev *max77705 =i2c_get_clientdata (i2c); + +disable_irq (max77705->irq);
'\n' here.
drivers/mfd/max77705.c line 221
Quoted 13 lines
drivers/mfd/max77705.c new file +13
-0+if (device_may_wakeup (dev)) +enable_irq_wake (max77705->irq); + +return 0 ; +} + +static int max77705_resume (struct device *dev) +{ +struct i2c_client *i2c =to_i2c_client (dev); +struct max77693_dev *max77705 =i2c_get_clientdata (i2c); + +if (device_may_wakeup (dev)) +disable_irq_wake (max77705->irq);
'\n' here.
drivers/mfd/max77705.c line 226
Quoted 5 lines
drivers/mfd/max77705.c new file +5
-0+enable_irq (max77705->irq); + +return 0 ; +} +
Remove this line.
drivers/mfd/max77705.c line 229
Quoted 3 lines
drivers/mfd/max77705.c new file +3
-0+DEFINE_SIMPLE_DEV_PM_OPS (max77705_pm_ops, max77705_suspend, max77705_resume); + +static const struct of_device_id max77705_i2c_dt_ids[] = {
max77705_i2c_of_match
drivers/mfd/max77705.c line 242
Quoted 13 lines
drivers/mfd/max77705.c new file +13
-0+ { .compatible = "maxim,max77705" }, + { }, +}; +MODULE_DEVICE_TABLE (of, max77705_i2c_dt_ids); + +static struct i2c_driver max77705_i2c_driver = { + .driver = { + .name ="max77705" , + .of_match_table = max77705_i2c_dt_ids, + .pm =pm_sleep_ptr (&max77705_pm_ops), + .suppress_bind_attrs = true, + }, + .probe = max77705_i2c_probe,
Please get rid of all of this ugly tabbing.
drivers/mfd/max77705.c line 246
Quoted 4 lines
drivers/mfd/max77705.c new file +4
-0+}; +module_i2c_driver (max77705_i2c_driver); + +MODULE_DESCRIPTION ("Maxim MAX77705 MFD core driver" );
Not "MFD" - as above.
Quoted 45 lines
drivers/mfd/max77705.c new file +2
-0+MODULE_AUTHOR ("Dzmitry Sankouski <[email protected]>" ); +MODULE_LICENSE ("GPL" );include/linux/mfd/max77693-common.h +5
-1@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* -* Common data shared between Maxim 77693 and 77843 drivers +* Common data shared between Maxim 77693, 77705 and 77843 drivers * * Copyright (C) 2015 Samsung Electronics */ @@ -11,6 +11,7 @@enum max77693_types {TYPE_MAX77693_UNKNOWN ,TYPE_MAX77693 , +TYPE_MAX77705 ,TYPE_MAX77843 ,TYPE_MAX77693_NUM ,@@ -25,6 +26,7 @@ struct max77693_dev {struct i2c_client *i2c_muic;/* 0x4A , MUIC */ struct i2c_client *i2c_haptic;/* MAX77693: 0x90 , Haptic */ struct i2c_client *i2c_chg;/* MAX77843: 0xD2, Charger */ +struct i2c_client *i2c_fg;/* MAX77843: 0xD2, Charger */ enum max77693_types type;@@ -32,6 +34,8 @@ struct max77693_dev {struct regmap *regmap_muic;struct regmap *regmap_haptic;/* Only MAX77693 */ struct regmap *regmap_chg;/* Only MAX77843 */ +struct regmap *regmap_fg;/* Only MAX77705 */ +struct regmap *regmap_leds;/* Only MAX77705 */ struct regmap_irq_chip_data *irq_data_led;struct regmap_irq_chip_data *irq_data_topsys;include/linux/mfd/max77705-private.h new file +0
-0
include/linux/mfd/max77705-private.h line 6
Quoted 6 lines
include/linux/mfd/max77705-private.h new file +6
-0@@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// +// Maxim MAX77705 definitions. +// +// Copyright (C) 2015 Samsung Electronics, Inc. +// Copyright (C) 2024 Dzmitry Sankouski <[email protected]>
No C++ please.
Quoted 4 lines
include/linux/mfd/max77705-private.h new file +4
-0+ +#ifndef __LINUX_MFD_MAX77705_PRIV_H +#define __LINUX_MFD_MAX77705_PRIV_H +
include/linux/mfd/max77705-private.h line 20
Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10
-0+#include <linux/pm.h> + +#define MAX77705_SRC_IRQ_CHG BIT(0) +#define MAX77705_SRC_IRQ_TOP BIT(1) +#define MAX77705_SRC_IRQ_FG BIT(2) +#define MAX77705_SRC_IRQ_USBC BIT(3) +#define MAX77705_SRC_IRQ_ALL (MAX77705_SRC_IRQ_CHG | MAX77705_SRC_IRQ_TOP | \ + MAX77705_SRC_IRQ_FG | MAX77705_SRC_IRQ_USBC) + +// MAX77705_PMIC_REG_PMICREV register
No C++ please.
Quoted 40 lines
include/linux/mfd/max77705-private.h new file +40
-0+#define MAX77705_VERSION_SHIFT 3 +#define MAX77705_REVISION_MASK GENMASK(2, 0) +#define MAX77705_VERSION_MASK GENMASK(7, MAX77705_VERSION_SHIFT) +// MAX77705_PMIC_REG_MAINCTRL1 register +#define MAX77705_MAINCTRL1_BIASEN_SHIFT 7 +#define MAX77705_MAINCTRL1_BIASEN_MASK BIT(MAX77705_MAINCTRL1_BIASEN_SHIFT) +// MAX77705_PMIC_REG_MCONFIG2 (haptics) register +#define MAX77705_CONFIG2_MEN_SHIFT 6 +#define MAX77705_CONFIG2_MODE_SHIFT 7 +#define MAX77705_CONFIG2_HTYP_SHIFT 5 +// MAX77705_PMIC_REG_SYSTEM_INT_MASK register +#define MAX77705_SYSTEM_IRQ_BSTEN_INT BIT(3) +#define MAX77705_SYSTEM_IRQ_SYSUVLO_INT BIT(4) +#define MAX77705_SYSTEM_IRQ_SYSOVLO_INT BIT(5) +#define MAX77705_SYSTEM_IRQ_TSHDN_INT BIT(6) +#define MAX77705_SYSTEM_IRQ_TM_INT BIT(7) + +enum max77705_hw_rev { +MAX77705_PASS1 =1 , +MAX77705_PASS2 , +MAX77705_PASS3 , +}; + +enum max77705_reg { +MAX77705_PMIC_REG_PMICID1 =0x00 , +MAX77705_PMIC_REG_PMICREV =0x01 , +MAX77705_PMIC_REG_MAINCTRL1 =0x02 , +MAX77705_PMIC_REG_BSTOUT_MASK =0x03 , +MAX77705_PMIC_REG_FORCE_EN_MASK =0x08 , +MAX77705_PMIC_REG_MCONFIG =0x10 , +MAX77705_PMIC_REG_MCONFIG2 =0x11 , +MAX77705_PMIC_REG_INTSRC =0x22 , +MAX77705_PMIC_REG_INTSRC_MASK =0x23 , +MAX77705_PMIC_REG_SYSTEM_INT =0x24 , +MAX77705_PMIC_REG_RESERVED_25 =0x25 , +MAX77705_PMIC_REG_SYSTEM_INT_MASK =0x26 , +MAX77705_PMIC_REG_RESERVED_27 =0x27 , +MAX77705_PMIC_REG_RESERVED_28 =0x28 , +MAX77705_PMIC_REG_RESERVED_29 =0x29 , +MAX77705_PMIC_REG_BOOSTCONTROL1 =0x4C ,
include/linux/mfd/max77705-private.h line 70
Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10
-0+MAX77705_PMIC_REG_BOOSTCONTROL2 =0x4F , +MAX77705_PMIC_REG_SW_RESET =0x50 , +MAX77705_PMIC_REG_USBC_RESET =0x51 , + + MAX77705_PMIC_REG_END, +}; + +enum max77705_chg_reg { +MAX77705_CHG_REG_BASE =0xB0 , + MAX77705_CHG_REG_INT = 0,
Tab these out like above and below.
Quoted 71 lines
include/linux/mfd/max77705-private.h new file +71
-0+MAX77705_CHG_REG_INT_MASK , +MAX77705_CHG_REG_INT_OK , +MAX77705_CHG_REG_DETAILS_00 , +MAX77705_CHG_REG_DETAILS_01 , +MAX77705_CHG_REG_DETAILS_02 , +MAX77705_CHG_REG_DTLS_03 , +MAX77705_CHG_REG_CNFG_00 , +MAX77705_CHG_REG_CNFG_01 , +MAX77705_CHG_REG_CNFG_02 , +MAX77705_CHG_REG_CNFG_03 , +MAX77705_CHG_REG_CNFG_04 , +MAX77705_CHG_REG_CNFG_05 , +MAX77705_CHG_REG_CNFG_06 , +MAX77705_CHG_REG_CNFG_07 , +MAX77705_CHG_REG_CNFG_08 , +MAX77705_CHG_REG_CNFG_09 , +MAX77705_CHG_REG_CNFG_10 , +MAX77705_CHG_REG_CNFG_11 , +MAX77705_CHG_REG_CNFG_12 , +MAX77705_CHG_REG_CNFG_13 , +MAX77705_CHG_REG_CNFG_14 , + MAX77705_CHG_REG_SAFEOUT_CTRL, +}; + +enum max77705_fuelgauge_reg { +STATUS_REG =0x00 , +VALRT_THRESHOLD_REG =0x01 , +TALRT_THRESHOLD_REG =0x02 , +SALRT_THRESHOLD_REG =0x03 , +REMCAP_REP_REG =0x05 , +SOCREP_REG =0x06 , +TEMPERATURE_REG =0x08 , +VCELL_REG =0x09 , +TIME_TO_EMPTY_REG =0x11 , +FULLSOCTHR_REG =0x13 , +CURRENT_REG =0x0A , +AVG_CURRENT_REG =0x0B , +SOCMIX_REG =0x0D , +SOCAV_REG =0x0E , +REMCAP_MIX_REG =0x0F , +FULLCAP_REG =0x10 , +RFAST_REG =0x15 , +AVR_TEMPERATURE_REG =0x16 , +CYCLES_REG =0x17 , +DESIGNCAP_REG =0x18 , +AVR_VCELL_REG =0x19 , +TIME_TO_FULL_REG =0x20 , +CONFIG_REG =0x1D , +ICHGTERM_REG =0x1E , +REMCAP_AV_REG =0x1F , +FULLCAP_NOM_REG =0x23 , +LEARN_CFG_REG =0x28 , +FILTER_CFG_REG =0x29 , +MISCCFG_REG =0x2B , +QRTABLE20_REG =0x32 , +FULLCAP_REP_REG =0x35 , +RCOMP_REG =0x38 , +VEMPTY_REG =0x3A , +FSTAT_REG =0x3D , +DISCHARGE_THRESHOLD_REG =0x40 , +QRTABLE30_REG =0x42 , +ISYS_REG =0x43 , +DQACC_REG =0x45 , +DPACC_REG =0x46 , +AVGISYS_REG =0x4B , +QH_REG =0x4D , +VSYS_REG =0xB1 , +TALRTTH2_REG =0xB2 , +VBYP_REG =0xB3 , +CONFIG2_REG =0xBB , + IIN_REG = 0xD0,
include/linux/mfd/max77705-private.h line 151
Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10
-0+OCV_REG =0xEE , +VFOCV_REG =0xFB , +VFSOC_REG =0xFF , + + MAX77705_FG_END, +}; + +enum max77705_led_reg { +MAX77705_RGBLED_REG_BASE =0x30 , + MAX77705_RGBLED_REG_LEDEN = 0,
Here too.
Quoted 33 lines
include/linux/mfd/max77705-private.h new file +29
-0+MAX77705_RGBLED_REG_LED0BRT , +MAX77705_RGBLED_REG_LED1BRT , +MAX77705_RGBLED_REG_LED2BRT , +MAX77705_RGBLED_REG_LED3BRT , +MAX77705_RGBLED_REG_LEDRMP , +MAX77705_RGBLED_REG_LEDBLNK , +MAX77705_LED_REG_END +}; + +enum max77705_charger_battery_state { +MAX77705_BATTERY_NOBAT , +MAX77705_BATTERY_PREQUALIFICATION , +MAX77705_BATTERY_DEAD , +MAX77705_BATTERY_GOOD , +MAX77705_BATTERY_LOWVOLTAGE , +MAX77705_BATTERY_OVERVOLTAGE , +MAX77705_BATTERY_RESERVED , +}; + +enum max77705_charger_charge_type { +MAX77705_CHARGER_CONSTANT_CURRENT =1 , +MAX77705_CHARGER_CONSTANT_VOLTAGE , +MAX77705_CHARGER_END_OF_CHARGE , +MAX77705_CHARGER_DONE , +}; + +extern const struct dev_pm_ops max77705_pm_ops; + +#endif /* __LINUX_MFD_MAX77705_PRIV_H */ Signature · 2 lines
-- 2.39.2
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v6 3/7] mfd: Add new driver for MAX77705 PMIC
Quoted 10 lines
Quoted 9 lines
drivers/mfd/max77705.c new file +3
-0@@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// max77705.c - mfd core driver for the MAX77705
(...)
Quoted 4 lines
Quoted 1 line
+// Copyright (C) 2024 Dzmitry Sankouski <[email protected]>
Only the SPDX in C++ comments please.
This conflicts with https://patchwork.kernel.org/comment/25898728/
Quoted 1 line
Quoted 1 line
+
(...)
Quoted 10 lines
drivers/mfd/max77705.c line 6
Quoted 8 lines
+++
b/include/linux/mfd/max77705-private.hdrivers/mfd/max77705.c new file +6
-0@@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// +// Maxim MAX77705 definitions. +// +// Copyright (C) 2015 Samsung Electronics, Inc. +// Copyright (C) 2024 Dzmitry Sankouski <[email protected]> No C++ please.
This conflicts with https://patchwork.kernel.org/comment/25898728/
Quoted 17 lines
Quoted 5 lines
drivers/mfd/max77705.c new file +4
-0+ +#ifndef __LINUX_MFD_MAX77705_PRIV_H +#define __LINUX_MFD_MAX77705_PRIV_H +drivers/mfd/max77705.c line 20
Quoted 10 lines
drivers/mfd/max77705.c new file +10
-0+#include <linux/pm.h> + +#define MAX77705_SRC_IRQ_CHG BIT(0) +#define MAX77705_SRC_IRQ_TOP BIT(1) +#define MAX77705_SRC_IRQ_FG BIT(2) +#define MAX77705_SRC_IRQ_USBC BIT(3) +#define MAX77705_SRC_IRQ_ALL (MAX77705_SRC_IRQ_CHG | MAX77705_SRC_IRQ_TOP | \ + MAX77705_SRC_IRQ_FG | MAX77705_SRC_IRQ_USBC) + +// MAX77705_PMIC_REG_PMICREV register No C++ please.
This conflicts with https://patchwork.kernel.org/comment/25898728/
Signature · 2 lines
Best regards, Dzmitry
Lee Jones
maintainerRe: [PATCH v6 3/7] mfd: Add new driver for MAX77705 PMIC
Quoted 10 lines · Dzmitry Sankouski
Quoted 10 lines
drivers/mfd/max77705.c line 3
Quoted 9 lines
drivers/mfd/max77705.c new file +3
-0@@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// max77705.c - mfd core driver for the MAX77705
Quoted 6 lines
(...)
Quoted 4 lines
Quoted 1 line
+// Copyright (C) 2024 Dzmitry Sankouski <[email protected]>
Only the SPDX in C++ comments please.
This conflicts with https://patchwork.kernel.org/comment/25898728/
a) Mark is only talking about the file header
Quoted 14 lines
Quoted 1 line
Quoted 1 line
+
(...)
Quoted 10 lines
drivers/mfd/max77705.c line 6
Quoted 8 lines
+++
b/include/linux/mfd/max77705-private.hdrivers/mfd/max77705.c new file +6
-0@@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// +// Maxim MAX77705 definitions. +// +// Copyright (C) 2015 Samsung Electronics, Inc. +// Copyright (C) 2024 Dzmitry Sankouski <[email protected]> No C++ please.
Quoted 1 line
This conflicts with https://patchwork.kernel.org/comment/25898728/
a) Mark is only talking about the file header
b) Different subsystem, different rules.
Quoted 19 lines
Quoted 18 lines
Quoted 6 lines
drivers/mfd/max77705.c new file +4
-0+ +#ifndef __LINUX_MFD_MAX77705_PRIV_H +#define __LINUX_MFD_MAX77705_PRIV_H +drivers/mfd/max77705.c line 20
Quoted 10 lines
drivers/mfd/max77705.c new file +10
-0+#include <linux/pm.h> + +#define MAX77705_SRC_IRQ_CHG BIT(0) +#define MAX77705_SRC_IRQ_TOP BIT(1) +#define MAX77705_SRC_IRQ_FG BIT(2) +#define MAX77705_SRC_IRQ_USBC BIT(3) +#define MAX77705_SRC_IRQ_ALL (MAX77705_SRC_IRQ_CHG | MAX77705_SRC_IRQ_TOP | \ + MAX77705_SRC_IRQ_FG | MAX77705_SRC_IRQ_USBC) + +// MAX77705_PMIC_REG_PMICREV register No C++ please.
Quoted 1 line
This conflicts with https://patchwork.kernel.org/comment/25898728/
a) Mark is only talking about the file header
b) Different subsystem, different rules.
Quoted 6 lines
Signature · 4 lines
-- Best regards, Dzmitry
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v6 3/7] mfd: Add new driver for MAX77705 PMIC
In reply to Lee JonesQuoted 7 lines
drivers/mfd/max77705.c line 184
Quoted 4 lines
drivers/mfd/max77705.c new file +4
-0+/* Unmask interrupts from all blocks in interrupt source register */ + ret =regmap_update_bits (max77705->regmap, +MAX77705_PMIC_REG_INTSRC_MASK , +MAX77705_SRC_IRQ_ALL , (unsigned int )~MAX77705_SRC_IRQ_ALL );Why the cast?
BIT macro creates a 64 bit constant value. When inverted, it overruns 32 bit value, causing compiler to warn on conversion like warning: conversion from ‘long unsigned int’ to ‘unsigned int’.
Signature · 2 lines
Best regards, Dzmitry
PATCH v6 4/7 input: max77693: add max77705 haptic support
In reply to Dzmitry SankouskiAdd support for haptic controller on MAX77705 Multifunction device.
This driver supports external pwm and LRA (Linear Resonant Actuator) motor. User can control the haptic device via force feedback framework.
---
Changes in v4:
- add max77705 haptic support to max77693 driver
- delete max77705-haptic
--- drivers/input/misc/Kconfig | 4 ++-- drivers/input/misc/Makefile | 1 + drivers/input/misc/max77693-haptic.c | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-)
drivers/input/misc/Kconfig +2 -2
@@ -241,11 +241,11 @@ config INPUT_MAX77650_ONKEY config INPUT_MAX77693_HAPTIC tristate "MAXIM MAX77693/MAX77843 haptic controller support" - depends on (MFD_MAX77693 || MFD_MAX77843) && PWM + depends on (MFD_MAX77693 || MFD_MAX77705 || MFD_MAX77843) && PWM select INPUT_FF_MEMLESS help This option enables support for the haptic controller on - MAXIM MAX77693 and MAX77843 chips. + MAXIM MAX77693, MAX77705 and MAX77843 chips. To compile this driver as module, choose M here: the module will be called max77693-haptic.
drivers/input/misc/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o +obj-$(CONFIG_INPUT_MAX77705_HAPTIC) += max77705-haptic.o obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o
drivers/input/misc/max77693-haptic.c +14 -1
@@ -23,6 +23,7 @@#include <linux/mfd/max77693.h> #include <linux/mfd/max77693-common.h> #include <linux/mfd/max77693-private.h> +#include <linux/mfd/max77705-private.h> #include <linux/mfd/max77843-private.h> #define MAX_MAGNITUDE_SHIFT 16
@@ -115,6 +116,13 @@ static int max77693_haptic_configure(struct max77693_haptic *haptic, MAX77693_HAPTIC_PWM_DIVISOR_128); config_reg =MAX77693_HAPTIC_REG_CONFIG2 ;break ; +case TYPE_MAX77705 : + value = ((haptic->type <<MAX77693_CONFIG2_MODE ) | + (enable <<MAX77693_CONFIG2_MEN ) | + (haptic->mode <<MAX77693_CONFIG2_HTYP ) | +MAX77693_HAPTIC_PWM_DIVISOR_128 ); + config_reg =MAX77705_PMIC_REG_MCONFIG ; +break ;case TYPE_MAX77843 : value = (haptic->type <<MCONFIG_MODE_SHIFT ) | (enable << MCONFIG_MEN_SHIFT) |
@@ -312,6 +320,9 @@ static int max77693_haptic_probe(struct platform_device *pdev)case TYPE_MAX77693 : haptic->regmap_haptic = max77693->regmap_haptic;break ; +case TYPE_MAX77705 : + haptic->regmap_haptic = max77693->regmap; +break ;case TYPE_MAX77843 : haptic->regmap_haptic = max77693->regmap;break ;
@@ -407,6 +418,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops,static const struct platform_device_id max77693_haptic_id[] = { {"max77693-haptic" , }, + {"max77705-haptic" , }, {"max77843-haptic" , }, {}, };
@@ -414,6 +426,7 @@ MODULE_DEVICE_TABLE(platform, max77693_haptic_id);static const struct of_device_id of_max77693_haptic_dt_match[] = { { .compatible ="maxim,max77693-haptic" , }, + { .compatible ="maxim,max77705-haptic" , }, { .compatible ="maxim,max77843-haptic" , }, {/* sentinel */ }, };
@@ -432,5 +445,5 @@ module_platform_driver(max77693_haptic_driver);MODULE_AUTHOR ("Jaewon Kim <[email protected]>" );MODULE_AUTHOR ("Krzysztof Kozlowski <[email protected]>" ); -MODULE_DESCRIPTION ("MAXIM 77693/77843 Haptic driver" ); +MODULE_DESCRIPTION ("MAXIM 77693/77705/77843 Haptic driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.39.2
PATCH v6 5/7 power: supply: max77705: Add charger driver for Maxim 77705
In reply to Dzmitry SankouskiAdd driver for Maxim 77705 switch-mode charger (part of max77705 MFD driver) providing power supply class information to userspace.
The driver is configured through DTS (battery and system related settings).
---
Changes for v5:
- remove const modifier from max77705_charger_irq_chip because it's modified with irq_drv_data in probe function
- fix license to GPL 2.0 only, where old vendor code used GPL 2.0 only
- move power header to power include dir
- use same hardware name in Kconfig and module descriptions
Changes for v4:
- start from scratch
- change word delimiters in filenames to '_'
- use GENMASK in header
- remove debugfs code
- migrate to regmap_add_irq_chip
- fix property getters to follow the same style
--- drivers/power/supply/Kconfig | 6 ++ drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_charger.c | 585 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 215 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 807 insertions(+)
drivers/power/supply/Kconfig +6 -0
@@ -573,6 +573,12 @@ config CHARGER_MAX77693 help Say Y to enable support for the Maxim MAX77693 battery charger. +config CHARGER_MAX77705 + tristate "Maxim MAX77705 battery charger driver" + depends on MFD_MAX77705 + help + Say Y to enable support for the Maxim MAX77705 battery charger. + config CHARGER_MAX77976 tristate "Maxim MAX77976 battery charger driver" depends on I2C
drivers/power/supply/Makefile +1 -0
@@ -79,6 +79,7 @@ obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o +obj-$(CONFIG_CHARGER_MAX77705) += max77705_charger.o obj-$(CONFIG_CHARGER_MAX77976) += max77976_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
drivers/power/supply/max77705_charger.c new file +585 -0
585 lines not on this page · raw message
include/linux/power/max77705_charger.h new file +215 -0
215 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v6 5/7] power: supply: max77705: Add charger driver for Maxim 77705
Hello,
drivers/power/supply/max77705_charger.c line 581
Quoted 9 lines · Dzmitry Sankouski
drivers/power/supply/max77705_charger.c new file +9
-0+static struct platform_driver max77705_charger_driver = { + .driver = { + .name ="max77705-charger" , + .of_match_table = max77705_charger_of_match, + }, + .probe = max77705_charger_probe, + .remove_new = max77705_charger_remove, +}; +module_platform_driver (max77705_charger_driver);
After commit 0edb555a65d1 ("platform: Make platform_driver::remove() return void") .remove() is (again) the right callback to implement for platform drivers. Please just drop "_new".
Best regards
Uwe
PATCH v6 6/7 power: supply: max77705: Add fuel gauge driver for Maxim 77705
In reply to Dzmitry SankouskiAdd driver for Maxim 77705 fuel gauge (part of max77705 MFD driver) providing power supply class information to userspace.
The driver is configured through DTS (battery and system related settings).
---
Changes for v5:
- fix license
- use same hardware name in Kconfig and module descriptions
- fix email, and module author
Changes for v4:
- rework driver from scratch
- change word delimiters in filenames to "_"
- remove debugfs code
- cleanup header
--- drivers/power/supply/Kconfig | 7 +++ drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_fuel_gauge.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_fuelgauge.h | 65 +++++++++++++++++++++++ 4 files changed, 421 insertions(+)
drivers/power/supply/Kconfig +7 -0
@@ -579,6 +579,13 @@ config CHARGER_MAX77705 help Say Y to enable support for the Maxim MAX77705 battery charger. +config FUEL_GAUGE_MAX77705 + tristate "Maxim MAX77705 fuel gauge driver" + depends on MFD_MAX77705 + default n + help + Say Y to enable support for MAXIM MAX77705 fuel gauge driver. + config CHARGER_MAX77976 tristate "Maxim MAX77976 battery charger driver" depends on I2C
drivers/power/supply/Makefile +1 -0
@@ -80,6 +80,7 @@ obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o obj-$(CONFIG_CHARGER_MAX77705) += max77705_charger.o +obj-$(CONFIG_FUEL_GAUGE_MAX77705) += max77705_fuel_gauge.o obj-$(CONFIG_CHARGER_MAX77976) += max77976_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
drivers/power/supply/max77705_fuel_gauge.c new file +348 -0
348 lines not on this page · raw message
include/linux/power/max77705_fuelgauge.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.39.2
kernel test robot
build botRe: [PATCH v6 6/7] power: supply: max77705: Add fuel gauge driver for Maxim 77705
kernel test robot noticed the following build warnings:
Hi Dzmitry,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 58ca61c1a866bfdaa5e19fb19a2416764f847d75]
url: https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20241008-000014 base: 58ca61c1a866bfdaa5e19fb19a2416764f847d75 patch link: https://lore.kernel.org/r/20241007-starqltechn_integration_upstream-v6-6-0d38b5090c57%40gmail.com patch subject: [PATCH v6 6/7] power: supply: max77705: Add fuel gauge driver for Maxim 77705 config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20241011/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241011/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/power/supply/max77705_fuel_gauge.c:220:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
220 | case POWER_SUPPLY_PROP_MANUFACTURER:
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/power/supply/max77705_fuel_gauge.c:227:6: note: uninitialized use occurs here
227 | if (ret)
| ^~~
drivers/power/supply/max77705_fuel_gauge.c:217:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
217 | case POWER_SUPPLY_PROP_MODEL_NAME:
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/power/supply/max77705_fuel_gauge.c:227:6: note: uninitialized use occurs here
227 | if (ret)
| ^~~
drivers/power/supply/max77705_fuel_gauge.c:169:9: note: initialize the variable 'ret' to silence this warning
169 | int ret;
| ^
| = 02 warnings generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]
vim +/ret +220 drivers/power/supply/max77705_fuel_gauge.c
162
163 static int max77705_fg_get_property(struct power_supply *psy,
164 enum power_supply_property psp,
165 union power_supply_propval *val)
166 {
167 struct max77705_fuelgauge_data *fuelgauge =
168 power_supply_get_drvdata(psy);
169 int ret;
170
171 switch (psp) {
172 case POWER_SUPPLY_PROP_STATUS:
173 ret = max77705_battery_get_status(fuelgauge, &val->intval);
174 break;
175 case POWER_SUPPLY_PROP_PRESENT:
176 ret = max77705_fg_check_battery_present(fuelgauge, &val->intval);
177 break;
178 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
179 ret = max77705_fg_read_reg(fuelgauge, VCELL_REG, &val->intval);
180 break;
181 case POWER_SUPPLY_PROP_VOLTAGE_OCV:
182 ret = max77705_fg_read_reg(fuelgauge, VFOCV_REG, &val->intval);
183 break;
184 case POWER_SUPPLY_PROP_VOLTAGE_AVG:
185 ret = max77705_fg_read_reg(fuelgauge, AVR_VCELL_REG, &val->intval);
186 break;
187 case POWER_SUPPLY_PROP_CURRENT_NOW:
188 ret = max77705_fg_read_reg(fuelgauge, CURRENT_REG, &val->intval);
189 break;
190 case POWER_SUPPLY_PROP_CURRENT_AVG:
191 ret = max77705_fg_read_reg(fuelgauge, AVG_CURRENT_REG, &val->intval);
192 break;
193 case POWER_SUPPLY_PROP_CHARGE_NOW:
194 ret = max77705_fg_read_reg(fuelgauge, REMCAP_REP_REG, &val->intval);
195 break;
196 case POWER_SUPPLY_PROP_CHARGE_FULL:
197 ret = max77705_fg_read_reg(fuelgauge, FULLCAP_REP_REG, &val->intval);
198 break;
199 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
200 ret = max77705_fg_read_reg(fuelgauge, DESIGNCAP_REG, &val->intval);
201 break;
202 case POWER_SUPPLY_PROP_CAPACITY:
203 ret = max77705_fg_read_reg(fuelgauge, SOCREP_REG, &val->intval);
204 break;
205 case POWER_SUPPLY_PROP_TEMP:
206 ret = max77705_fg_read_temp(fuelgauge, &val->intval);
207 break;
208 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
209 ret = max77705_fg_read_reg(fuelgauge, TIME_TO_EMPTY_REG, &val->intval);
210 break;
211 case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
212 ret = max77705_fg_read_reg(fuelgauge, TIME_TO_FULL_REG, &val->intval);
213 break;
214 case POWER_SUPPLY_PROP_CYCLE_COUNT:
215 ret = max77705_fg_read_reg(fuelgauge, CYCLES_REG, &val->intval);
216 break;
217 case POWER_SUPPLY_PROP_MODEL_NAME:
218 val->strval = max77705_fuelgauge_model;
219 break;
> 220 case POWER_SUPPLY_PROP_MANUFACTURER:
221 val->strval = max77705_fuelgauge_manufacturer;
222 break;
223 default:
224 return -EINVAL;
225 }
226
227 if (ret)
228 return ret;
229
230 max77705_unit_adjustment(fuelgauge, psp, val);
231
232 return 0;
233 }
234
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v6 6/7] power: supply: max77705: Add fuel gauge driver for Maxim 77705
In reply to Dzmitry Sankouskikernel test robot noticed the following build errors:
Hi Dzmitry,
kernel test robot noticed the following build errors:
[auto build test ERROR on 58ca61c1a866bfdaa5e19fb19a2416764f847d75]
url: https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20241008-000014 base: 58ca61c1a866bfdaa5e19fb19a2416764f847d75 patch link: https://lore.kernel.org/r/20241007-starqltechn_integration_upstream-v6-6-0d38b5090c57%40gmail.com patch subject: [PATCH v6 6/7] power: supply: max77705: Add fuel gauge driver for Maxim 77705 config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20241011/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241011/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: drivers/power/supply/max77705_fuel_gauge.o: in function `max77705_fg_get_property':
>> max77705_fuel_gauge.c:(.text+0x244): undefined reference to `__divdi3' >> ld: max77705_fuel_gauge.c:(.text+0x2b1): undefined reference to `__udivdi3' ld: drivers/power/supply/max77705_fuel_gauge.o: in function `max77705_fg_vs_convert': >> max77705_fuel_gauge.c:(.text+0x6c2): undefined reference to `__udivdi3'
ld: drivers/power/supply/max77705_fuel_gauge.o: in function `max77705_fg_cs_convert':
max77705_fuel_gauge.c:(.text+0x706): undefined reference to `__divdi3'
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=n] || GCC_PLUGINS [=y]) && MODULES [=y]
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [y]:
- RESOURCE_KUNIT_TEST [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v6 6/7] power: supply: max77705: Add fuel gauge driver for Maxim 77705
In reply to Dzmitry Sankouskikernel test robot noticed the following build errors:
Hi Dzmitry,
kernel test robot noticed the following build errors:
[auto build test ERROR on 58ca61c1a866bfdaa5e19fb19a2416764f847d75]
url: https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20241008-000014 base: 58ca61c1a866bfdaa5e19fb19a2416764f847d75 patch link: https://lore.kernel.org/r/20241007-starqltechn_integration_upstream-v6-6-0d38b5090c57%40gmail.com patch subject: [PATCH v6 6/7] power: supply: max77705: Add fuel gauge driver for Maxim 77705 config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20241012/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241012/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: missing MODULE_DESCRIPTION() in security/tomoyo/tomoyo.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/bridge/imx/imx-legacy-bridge.o
>> ERROR: modpost: "__udivdi3" [drivers/power/supply/max77705_fuel_gauge.ko] undefined! >> ERROR: modpost: "__divdi3" [drivers/power/supply/max77705_fuel_gauge.ko] undefined!
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=n] || GCC_PLUGINS [=y]) && MODULES [=y]
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v6 7/7 leds: max77705: Add LEDs support
In reply to Dzmitry SankouskiThis adds basic support for LEDs for the max77705 PMIC.
---
Changes for v5:
- use same hardware name in Kconfig and module descriptions
- remove copyrighter owner from module authors
Changes in v4:
- inline BLINK_(ON|OFF) macro
- remove camel case
- drop backwards compatibility(new driver)
- drop module alias
--- MAINTAINERS | 1 + drivers/leds/Kconfig | 6 ++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 165 insertions(+)
MAINTAINERS +1 -0
@@ -14079,6 +14079,7 @@ F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c F: drivers/*/max77705*.c +F: drivers/leds/leds-max77705.c F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.c
drivers/leds/Kconfig +6 -0
@@ -753,6 +753,12 @@ config LEDS_MAX77650 help LEDs driver for MAX77650 family of PMICs from Maxim Integrated. +config LEDS_MAX77705 + tristate "LED support for Maxim MAX77705 PMIC" + depends on MFD_MAX77705 && LEDS_CLASS && I2C + help + LED driver for MAX77705 MFD chip from Maxim Integrated. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997
drivers/leds/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o +obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
drivers/leds/leds-max77705.c new file +157 -0
157 lines not on this page · raw message
Signature · 1 line
2.39.2
Lee Jones
maintainerRe: [PATCH v6 7/7] leds: max77705: Add LEDs support
Quoted 14 lines · Dzmitry Sankouski
This adds basic support for LEDs for the max77705 PMIC.
Signed-off-by Dzmitry Sankouski <[email protected]>---
Changes for v5:
- use same hardware name inKconfigand module descriptions
- remove copyrighter owner from module authorsChanges in v4:
- inlineBLINK_(ON|OFF)macro
- remove camel case
- drop backwards compatibility(new driver)
- drop module alias
Quoted 5 lines
--- MAINTAINERS | 1 + drivers/leds/Kconfig | 6 ++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Lol! How big is your terminal? :)
MAINTAINERS F: drivers/*/max14577*.c · line 14082
Quoted 11 lines
4 files changed, 165 insertions(+)MAINTAINERS +1
-0@@ -14079,6 +14079,7 @@ F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c F: drivers/*/max77705*.c +F: drivers/leds/leds-max77705.c
Alphabetical?
Quoted 8 lines
MAINTAINERS +0
-0F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.cdrivers/leds/Kconfig +0
-0
drivers/leds/Kconfig config LEDS_MAX77650 · line 758
Quoted 6 lines
drivers/leds/Kconfig +3
-0@@ -753,6 +753,12 @@ config LEDS_MAX77650 help LEDs driver for MAX77650 family of PMICs from Maxim Integrated. +config LEDS_MAX77705 + tristate "LED support for Maxim MAX77705 PMIC" + depends on MFD_MAX77705 && LEDS_CLASS && I2C
If MFD_MAX77705 depends on I2C, you shouldn't need that here.
drivers/leds/Kconfig config LEDS_MAX77650 · line 760
Quoted 2 lines
drivers/leds/Kconfig +2
-0+ help + LED driver for MAX77705 MFD chip from Maxim Integrated.
No such thing as an "MFD chip".
Quoted 22 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -60,6 +60,7 @@ obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o +obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max77705.c new file +0
-0
drivers/leds/leds-max77705.c line 5
Quoted 5 lines
drivers/leds/leds-max77705.c new file +5
-0@@ -0,0 +1,157 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Based on leds-max77650 driver: +// Copyright (C) 2018 BayLibre SAS +// Author: Bartosz Golaszewski <[email protected]>
You don't need to do that.
drivers/leds/leds-max77705.c line 7
Quoted 2 lines
drivers/leds/leds-max77705.c new file +2
-0+// +// LED driver for MAXIM 77705 MFD.
Remove MFD from everywhere.
drivers/leds/leds-max77705.c line 8
Quoted 1 line
drivers/leds/leds-max77705.c new file +1
-0+// Copyright (C) 2024 Dzmitry Sankouski <[email protected]>
Only the SPDX in C++ please.
Quoted 28 lines
drivers/leds/leds-max77705.c new file +28
-0+#include <linux/i2c.h> +#include <linux/leds.h> +#include <linux/mfd/max77705-private.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#define MAX77705_LED_NUM_LEDS 4 +#define MAX77705_LED_EN_MASK GENMASK(1, 0) +#define MAX77705_LED_MAX_BRIGHTNESS 0xff + +struct max77705_led { +struct led_classdev cdev; +struct regmap *regmap; +unsigned int en_shift; +unsigned int reg_brightness; +}; + +static struct max77705_led *max77705_to_led (struct led_classdev *cdev) +{ + return container_of(cdev, struct max77705_led, cdev); +} + +static int max77705_rgb_blink (struct led_classdev *cdev, +unsigned long *delay_on, +unsigned long *delay_off) +{ +struct max77705_led *led =max77705_to_led (cdev);
drivers/leds/leds-max77705.c line 47
Quoted 10 lines
drivers/leds/leds-max77705.c new file +10
-0+int value, on_value, off_value; + + on_value = (((*delay_on <100 ) ?0 : + (*delay_on <500 ) ? *delay_on/100 -1 : + (*delay_on <3250 ) ? (*delay_on -500 ) /250 +4 :15 ) <<4 ); + off_value = ((*delay_off <1 ) ?0x00 : + (*delay_off <500 ) ?0x01 : + (*delay_off <5000 ) ? *delay_off /500 : + (*delay_off <8000 ) ? (*delay_off -5000 ) /1000 +10 : + (*delay_off <12000 ) ? (*delay_off -8000 ) /2000 +13 :15 );
These nested ternary are pretty miserable. Please break them out.
Also all of these magic numbers probably need defining so the maths becomes easier to follow for humans.
drivers/leds/leds-max77705.c line 56
Quoted 9 lines
drivers/leds/leds-max77705.c new file +9
-0+ value = on_value | off_value; +return regmap_write (led->regmap,MAX77705_RGBLED_REG_LEDBLNK , value); +} + +static int max77705_led_brightness_set (struct led_classdev *cdev, +enum led_brightness brightness) +{ +struct max77705_led *led =max77705_to_led (cdev); +int ret;
Pop the ret on the bottom, if no other reason than for my OCD!
drivers/leds/leds-max77705.c line 60
Quoted 4 lines
drivers/leds/leds-max77705.c new file +4
-0+unsigned long blink_default =0 ; + +if (brightness ==LED_OFF ) { +// Flash OFF
No C++ comments please.
drivers/leds/leds-max77705.c line 68
Quoted 8 lines
drivers/leds/leds-max77705.c new file +8
-0+ ret =regmap_update_bits (led->regmap, +MAX77705_RGBLED_REG_LEDEN , +MAX77705_LED_EN_MASK << led->en_shift,0 ); +max77705_rgb_blink (cdev, &blink_default, &blink_default); + }else { +// Set current + ret =regmap_write (led->regmap, + led->reg_brightness, brightness);
Line wrap at 100-chars.
Quoted 7 lines
drivers/leds/leds-max77705.c new file +7
-0+if (ret <0 ) +return ret; + + ret =regmap_update_bits (led->regmap, +MAX77705_RGBLED_REG_LEDEN ,LED_ON << led->en_shift, +MAX77705_LED_EN_MASK << led->en_shift); + }
drivers/leds/leds-max77705.c line 85
Quoted 10 lines
drivers/leds/leds-max77705.c new file +10
-0+ +return ret; +} + +static int max77705_led_probe (struct platform_device *pdev) +{ +struct fwnode_handle *child; +struct max77705_led *leds, *led; +struct device *dev; +struct regmap *map;
s/map/regmap/
drivers/leds/leds-max77705.c line 86
Quoted 1 line
drivers/leds/leds-max77705.c new file +1
-0+int rv, num_leds;
What's rv? If it's "return value", then please just use ret.
drivers/leds/leds-max77705.c line 89
Quoted 3 lines
drivers/leds/leds-max77705.c new file +3
-0+u32 reg; + + dev = &pdev->dev;
Do this during the declaration
drivers/leds/leds-max77705.c line 101
Quoted 11 lines
drivers/leds/leds-max77705.c new file +11
-0+ leds =devm_kcalloc (dev,sizeof (*leds), +MAX77705_LED_NUM_LEDS ,GFP_KERNEL ); +if (!leds) +return -ENOMEM ; + + map =dev_get_regmap (dev->parent,NULL ); +if (!map) +return -ENODEV ; + + num_leds =device_get_child_node_count (dev); +if (!num_leds || num_leds >MAX77705_LED_NUM_LEDS )
num_leds < 0
drivers/leds/leds-max77705.c line 104
Quoted 3 lines
drivers/leds/leds-max77705.c new file +3
-0+return -ENODEV ; + +device_for_each_child_node (dev, child) {
If you use the _scoped version, you can drop the gotos.
drivers/leds/leds-max77705.c line 116
Quoted 12 lines
drivers/leds/leds-max77705.c new file +12
-0+struct led_init_data init_data = {}; + + rv =fwnode_property_read_u32 (child,"reg" , ®); +if (rv || reg >=MAX77705_LED_NUM_LEDS ) { + rv = -EINVAL ; + goto err_node_put; + } + + led = &leds[reg]; + led->regmap = map; + led->reg_brightness =MAX77705_RGBLED_REG_LED0BRT + reg; + led->en_shift =2 * reg;
Why 2?
drivers/leds/leds-max77705.c line 122
Quoted 6 lines
drivers/leds/leds-max77705.c new file +6
-0+ led->cdev.brightness_set_blocking = max77705_led_brightness_set; + led->cdev.blink_set = max77705_rgb_blink; + led->cdev.max_brightness =MAX77705_LED_MAX_BRIGHTNESS ; + + init_data.fwnode = child; + init_data.devicename ="max77705" ;
You don't want to use the label as the devicename?
https://github.com/torvalds/linux/blob/master/drivers/leds/led-core.c#L526
drivers/leds/leds-max77705.c line 134
Quoted 12 lines
drivers/leds/leds-max77705.c new file +12
-0+ + rv =devm_led_classdev_register_ext (dev, &led->cdev, + &init_data); +if (rv) + goto err_node_put; + + rv =max77705_led_brightness_set (&led->cdev,LED_OFF ); +if (rv) + goto err_node_put; + } + +return 0 ;
'\n' here.
Quoted 27 lines
drivers/leds/leds-max77705.c new file +23
-0+err_node_put: +fwnode_handle_put (child); +return rv; +} + +static const struct of_device_id max77705_led_of_match[] = { + { .compatible ="maxim,max77705-led" }, + { } +}; +MODULE_DEVICE_TABLE (of, max77705_led_of_match); + +static struct platform_driver max77705_led_driver = { + .driver = { + .name ="max77705-led" , + .of_match_table = max77705_led_of_match, + }, + .probe = max77705_led_probe, +}; +module_platform_driver (max77705_led_driver); + +MODULE_DESCRIPTION ("Maxim MAX77705 LED driver" ); +MODULE_AUTHOR ("Dzmitry Sankouski <[email protected]>" ); +MODULE_LICENSE ("GPL" );Signature · 2 lines
-- 2.39.2
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v6 7/7] leds: max77705: Add LEDs support
(...)
Quoted 4 lines
Quoted 1 line
drivers/leds/leds-max77705.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Lol! How big is your terminal? :)
Dunno actually, this was generated by b4
(...)
Quoted 2 lines
No C++ comments please.
This conflicts with https://patchwork.kernel.org/comment/25898728/
Quoted 11 lines
drivers/leds/leds-max77705.c line 68
Quoted 8 lines
drivers/leds/leds-max77705.c new file +8
-0+ ret =regmap_update_bits (led->regmap, +MAX77705_RGBLED_REG_LEDEN , +MAX77705_LED_EN_MASK << led->en_shift,0 ); +max77705_rgb_blink (cdev, &blink_default, &blink_default); + }else { +// Set current + ret =regmap_write (led->regmap, + led->reg_brightness, brightness);Line wrap at 100-chars.
From coding-style.rst:The preferred limit on the length of a single line is 80 columns. I only exceed 80 chars, when there's no good wrapping.
Signature · 2 lines
Best regards, Dzmitry
Lee Jones
maintainerRe: [PATCH v6 7/7] leds: max77705: Add LEDs support
Quoted 8 lines · Dzmitry Sankouski
(...)
Quoted 4 lines
Quoted 1 line
drivers/leds/leds-max77705.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Lol! How big is your terminal? :)
Dunno actually, this was generated by b4
Quoted 7 lines
(...)
Quoted 2 lines
No C++ comments please.
This conflicts with https://patchwork.kernel.org/comment/25898728/
a) That's just for the header.
b) That's a different subsystem and Mark's choice.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/leds/leds-max77705.c new file +8
-0+ ret =regmap_update_bits (led->regmap, +MAX77705_RGBLED_REG_LEDEN , +MAX77705_LED_EN_MASK << led->en_shift,0 ); +max77705_rgb_blink (cdev, &blink_default, &blink_default); + }else { +// Set current + ret =regmap_write (led->regmap, + led->reg_brightness, brightness);
Quoted 6 lines
Quoted 2 lines
Line wrap at 100-chars.
From
coding-style.rst:The preferred limit on the length of a single line is 80 columns.I only exceed 80 chars, when there's no good wrapping.
a) This is old guidance
b) A lot of your lines already break the 80-char rule.
Signature · 1 line
Lee Jones [李琼斯]