Skip to contentSkip to conversation

Add MAX77714 PMIC minimal driver (RTC and watchdog only)

PATCH In review Luca Ceresoli 2 participants 10 messages Feb 23, 2022 – Mar 7, 2022

Subsystems (6)
lore
Share & tools
lore

Luca Ceresoli

author maintainer
#0 lore raw

v6 cover Add MAX77714 PMIC minimal driver (RTC and watchdog only)

Hi,

this series adds minimal drivers for the Maxim Semiconductor MAX77714
(https://www.maximintegrated.com/en/products/power/power-management-ics/MAX77714.html).
Only RTC and watchdog are implemented by these patches.

This is almost a bare resend of v5. Changes are minimal, trivial and only in comments (see list below).

All implemented functionality is tested and working: RTC read/write, watchdog start/stop/ping/set_timeout.

Patches 1-3 are trivial cleanups to the max77686 drivers.

Patches 4-8 add dt bindings, mfd driver, watchdog driver and rtc driver.

Changes in v6:
- patch 6: removed, now in mainline
- patch 5: describe as "Core driver", not "MFD driver" in comment (Lee Jones)
- update copyright years
- add review tags

Changes in v5:
- patch 7: fix (and simplify) watchdog_info code
- patch 8: remove amibguity in comment

Changes in v4:
- do not add a new wdog driver for MAX77714, extend the MAX77620 wdog driver; this means removing v3 patch 7, now replaced by patches 7+8
- added review tags

Changes in v3:
- fixed all issues reported on v1 patches
- removed patch 1 of v2, already applied
("mfd: max77686: Correct tab-based alignment of register addresses")

Changes in v2:
- fixed all issues reported on v1 patches
- added patch 7 ("watchdog: Kconfig: fix help text indentation")
- additional minor improvements

Luca

Luca Ceresoli (8):
rtc: max77686: convert comments to kernel-doc format
rtc: max77686: rename day-of-month defines
rtc: max77686: remove unused code to read in 12-hour mode
dt-bindings: mfd: add Maxim MAX77714 PMIC
mfd: max77714: Add driver for Maxim MAX77714 PMIC
watchdog: max77620: add support for the max77714 variant
watchdog: max77620: add comment to clarify set_timeout procedure
rtc: max77686: add MAX77714 support

 .../bindings/mfd/maxim,max77714.yaml          |  68 ++++++++
 MAINTAINERS                                   |   7 +
 drivers/mfd/Kconfig                           |  14 ++
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/max77686.c                        |   2 +-
 drivers/mfd/max77714.c                        | 152 ++++++++++++++++++
 drivers/rtc/Kconfig                           |   2 +-
 drivers/rtc/rtc-max77686.c                    |  75 +++++----
 drivers/watchdog/Kconfig                      |   2 +-
 drivers/watchdog/max77620_wdt.c               |  85 ++++++++--
 include/linux/mfd/max77686-private.h          |   4 +-
 include/linux/mfd/max77714.h                  |  60 +++++++
 12 files changed, 421 insertions(+), 51 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
 create mode 100644 drivers/mfd/max77714.c
 create mode 100644 include/linux/mfd/max77714.h
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH v6 1/8 rtc: max77686: convert comments to kernel-doc format

Convert the comments documenting this struct to kernel-doc format for standardization and readability.

---
Changes in v6: none

Changes in v5: none

Changes in v4: none

Changes in v3: none

Changes in v2: none

---
 drivers/rtc/rtc-max77686.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/rtc/rtc-max77686.c +12 -9
index eae7cb9faf1e..bac52cdea97d 100644
@@ -61,24 +61,27 @@ enum {
 	RTC_NR_TIME
 };
 
+/**
+ * struct max77686_rtc_driver_data - model-specific configuration
+ * @delay: Minimum usecs needed for a RTC update
+ * @mask: Mask used to read RTC registers value
+ * @map: Registers offset to I2C addresses map
+ * @alarm_enable_reg: Has a separate alarm enable register?
+ * @rtc_i2c_addr: I2C address for RTC block
+ * @rtc_irq_from_platform: RTC interrupt via platform resource
+ * @alarm_pending_status_reg: Pending alarm status register
+ * @rtc_irq_chip: RTC IRQ CHIP for regmap
+ * @regmap_config: regmap configuration for the chip
+ */
 struct max77686_rtc_driver_data {
-	/* Minimum usecs needed for a RTC update */
 	unsigned long		delay;
-	/* Mask used to read RTC registers value */
 	u8			mask;
-	/* Registers offset to I2C addresses map */
 	const unsigned int	*map;
-	/* Has a separate alarm enable register? */
 	bool			alarm_enable_reg;
-	/* I2C address for RTC block */
 	int			rtc_i2c_addr;
-	/* RTC interrupt via platform resource */
 	bool			rtc_irq_from_platform;
-	/* Pending alarm status register */
 	int			alarm_pending_status_reg;
-	/* RTC IRQ CHIP for regmap */
 	const struct regmap_irq_chip *rtc_irq_chip;
-	/* regmap configuration for the chip */
 	const struct regmap_config *regmap_config;
 };
 
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH v6 2/8 rtc: max77686: rename day-of-month defines

In reply to Luca Ceresoli

RTC_DATE and REG_RTC_DATE are used for the registers holding the day of month. Rename these constants to mean what they mean.

---

Changes in v6: none

Changes in v5: none

Changes in v4: none

Changes in v3: none

Changes in v2:
- fix drivers/mfd/max77686.c build failure due to missing rename (Reported-by: kernel test robot <[email protected]>)

---
 drivers/mfd/max77686.c               |  2 +-
 drivers/rtc/rtc-max77686.c           | 16 ++++++++--------
 include/linux/mfd/max77686-private.h |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/mfd/max77686.c +1 -1
index f9e12ab2bc75..2ac64277fb84 100644
@@ -87,7 +87,7 @@ static bool max77802_rtc_is_volatile_reg(struct device *dev, unsigned int reg)
 		reg == MAX77802_RTC_WEEKDAY ||
 		reg == MAX77802_RTC_MONTH ||
 		reg == MAX77802_RTC_YEAR ||
-		reg == MAX77802_RTC_DATE);
+		reg == MAX77802_RTC_MONTHDAY);
 }
 
 static bool max77802_is_volatile_reg(struct device *dev, unsigned int reg)
drivers/rtc/rtc-max77686.c +8 -8
index bac52cdea97d..7e765207f28e 100644
@@ -57,7 +57,7 @@ enum {
 	RTC_WEEKDAY,
 	RTC_MONTH,
 	RTC_YEAR,
-	RTC_DATE,
+	RTC_MONTHDAY,
 	RTC_NR_TIME
 };
 
@@ -119,7 +119,7 @@ enum max77686_rtc_reg_offset {
 	REG_RTC_WEEKDAY,
 	REG_RTC_MONTH,
 	REG_RTC_YEAR,
-	REG_RTC_DATE,
+	REG_RTC_MONTHDAY,
 	REG_ALARM1_SEC,
 	REG_ALARM1_MIN,
 	REG_ALARM1_HOUR,
@@ -150,7 +150,7 @@ static const unsigned int max77686_map[REG_RTC_END] = {
 	[REG_RTC_WEEKDAY]    = MAX77686_RTC_WEEKDAY,
 	[REG_RTC_MONTH]      = MAX77686_RTC_MONTH,
 	[REG_RTC_YEAR]       = MAX77686_RTC_YEAR,
-	[REG_RTC_DATE]       = MAX77686_RTC_DATE,
+	[REG_RTC_MONTHDAY]   = MAX77686_RTC_MONTHDAY,
 	[REG_ALARM1_SEC]     = MAX77686_ALARM1_SEC,
 	[REG_ALARM1_MIN]     = MAX77686_ALARM1_MIN,
 	[REG_ALARM1_HOUR]    = MAX77686_ALARM1_HOUR,
@@ -233,7 +233,7 @@ static const unsigned int max77802_map[REG_RTC_END] = {
 	[REG_RTC_WEEKDAY]    = MAX77802_RTC_WEEKDAY,
 	[REG_RTC_MONTH]      = MAX77802_RTC_MONTH,
 	[REG_RTC_YEAR]       = MAX77802_RTC_YEAR,
-	[REG_RTC_DATE]       = MAX77802_RTC_DATE,
+	[REG_RTC_MONTHDAY]   = MAX77802_RTC_MONTHDAY,
 	[REG_ALARM1_SEC]     = MAX77802_ALARM1_SEC,
 	[REG_ALARM1_MIN]     = MAX77802_ALARM1_MIN,
 	[REG_ALARM1_HOUR]    = MAX77802_ALARM1_HOUR,
@@ -288,7 +288,7 @@ static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
 
 	/* Only a single bit is set in data[], so fls() would be equivalent */
 	tm->tm_wday = ffs(data[RTC_WEEKDAY] & mask) - 1;
-	tm->tm_mday = data[RTC_DATE] & 0x1f;
+	tm->tm_mday = data[RTC_MONTHDAY] & 0x1f;
 	tm->tm_mon = (data[RTC_MONTH] & 0x0f) - 1;
 	tm->tm_year = data[RTC_YEAR] & mask;
 	tm->tm_yday = 0;
@@ -309,7 +309,7 @@ static int max77686_rtc_tm_to_data(struct rtc_time *tm, u8 *data,
 	data[RTC_MIN] = tm->tm_min;
 	data[RTC_HOUR] = tm->tm_hour;
 	data[RTC_WEEKDAY] = 1 << tm->tm_wday;
-	data[RTC_DATE] = tm->tm_mday;
+	data[RTC_MONTHDAY] = tm->tm_mday;
 	data[RTC_MONTH] = tm->tm_mon + 1;
 
 	if (info->drv_data->alarm_enable_reg) {
@@ -565,8 +565,8 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 			data[RTC_MONTH] |= (1 << ALARM_ENABLE_SHIFT);
 		if (data[RTC_YEAR] & info->drv_data->mask)
 			data[RTC_YEAR] |= (1 << ALARM_ENABLE_SHIFT);
-		if (data[RTC_DATE] & 0x1f)
-			data[RTC_DATE] |= (1 << ALARM_ENABLE_SHIFT);
+		if (data[RTC_MONTHDAY] & 0x1f)
+			data[RTC_MONTHDAY] |= (1 << ALARM_ENABLE_SHIFT);
 
 		ret = regmap_bulk_write(info->rtc_regmap, map[REG_ALARM1_SEC],
 					data, ARRAY_SIZE(data));
include/linux/mfd/max77686-private.h +2 -2
index b1482b3cf353..3acceeedbaba 100644
@@ -152,7 +152,7 @@ enum max77686_rtc_reg {
 	MAX77686_RTC_WEEKDAY		= 0x0A,
 	MAX77686_RTC_MONTH		= 0x0B,
 	MAX77686_RTC_YEAR		= 0x0C,
-	MAX77686_RTC_DATE		= 0x0D,
+	MAX77686_RTC_MONTHDAY		= 0x0D,
 	MAX77686_ALARM1_SEC		= 0x0E,
 	MAX77686_ALARM1_MIN		= 0x0F,
 	MAX77686_ALARM1_HOUR		= 0x10,
@@ -352,7 +352,7 @@ enum max77802_rtc_reg {
 	MAX77802_RTC_WEEKDAY		= 0xCA,
 	MAX77802_RTC_MONTH		= 0xCB,
 	MAX77802_RTC_YEAR		= 0xCC,
-	MAX77802_RTC_DATE		= 0xCD,
+	MAX77802_RTC_MONTHDAY		= 0xCD,
 	MAX77802_RTC_AE1		= 0xCE,
 	MAX77802_ALARM1_SEC		= 0xCF,
 	MAX77802_ALARM1_MIN		= 0xD0,
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH v6 3/8 rtc: max77686: remove unused code to read in 12-hour mode

In reply to Luca Ceresoli

The MAX77714 RTC chip is explicitly set to 24-hour mode in max77686_rtc_probe() -> max77686_rtc_init_reg() and never changed back to 12-hour mode. Accordingly info->rtc_24hr_mode is set to 1 in the same place and never modified later, so it is de facto a constant. Yet there is code to read 12-hour time, which is unreachable.

Remove the unused variable, the unreachable code to manage 12-hour mode and the defines that become unused due to the above changes.

---

Changes in v6: none

Changes in v5: none

Changes in v4: none

Changes in v3: none

Changes in v2:
- remove the now-unused defines too (Alexandre Belloni)
- improve the commit message

---
 drivers/rtc/rtc-max77686.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/rtc/rtc-max77686.c +1 -13
index 7e765207f28e..5c64d08c0732 100644
@@ -34,9 +34,6 @@
 #define RTC_UDR_MASK			BIT(RTC_UDR_SHIFT)
 #define RTC_RBUDR_SHIFT			4
 #define RTC_RBUDR_MASK			BIT(RTC_RBUDR_SHIFT)
-/* RTC Hour register */
-#define HOUR_PM_SHIFT			6
-#define HOUR_PM_MASK			BIT(HOUR_PM_SHIFT)
 /* RTC Alarm Enable */
 #define ALARM_ENABLE_SHIFT		7
 #define ALARM_ENABLE_MASK		BIT(ALARM_ENABLE_SHIFT)
@@ -99,7 +96,6 @@ struct max77686_rtc_info {
 
 	int rtc_irq;
 	int virq;
-	int rtc_24hr_mode;
 };
 
 enum MAX77686_RTC_OP {
@@ -278,13 +274,7 @@ static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
 
 	tm->tm_sec = data[RTC_SEC] & mask;
 	tm->tm_min = data[RTC_MIN] & mask;
-	if (info->rtc_24hr_mode) {
-		tm->tm_hour = data[RTC_HOUR] & 0x1f;
-	} else {
-		tm->tm_hour = data[RTC_HOUR] & 0x0f;
-		if (data[RTC_HOUR] & HOUR_PM_MASK)
-			tm->tm_hour += 12;
-	}
+	tm->tm_hour = data[RTC_HOUR] & 0x1f;
 
 	/* Only a single bit is set in data[], so fls() would be equivalent */
 	tm->tm_wday = ffs(data[RTC_WEEKDAY] & mask) - 1;
@@ -662,8 +652,6 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	data[0] = (1 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
 	data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
 
-	info->rtc_24hr_mode = 1;
-
 	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_RTC_CONTROLM],
 				data, ARRAY_SIZE(data));
Signature · 1 line
2.25.1
author maintainer
#4 lore raw

PATCH v6 4/8 dt-bindings: mfd: add Maxim MAX77714 PMIC

In reply to Luca Ceresoli

Add bindings for the MAX77714 PMIC with GPIO, RTC and watchdog.

---

Changes in v6: none

Changes in v5: none

Changes in v4: none

Changes in v3:
- add 'regulators' node (Krzysztof Kozlowski, Rob Herring)

Changes in v2: none

---
 .../bindings/mfd/maxim,max77714.yaml          | 68 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
Documentation/devicetree/bindings/mfd/maxim,max77714.yaml new file +68 -0
new file mode 100644
index 000000000000..74a6867d3c82
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/maxim,max77714.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MAX77714 PMIC with GPIO, RTC and watchdog from Maxim Integrated.
+
+maintainers:
+  - Luca Ceresoli <[email protected]>
+
+description: |
+  MAX77714 is a Power Management IC with 4 buck regulators, 9
+  low-dropout regulators, 8 GPIOs, RTC and watchdog.
+
+properties:
+  compatible:
+    const: maxim,max77714
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+    description:
+      The first cell is the IRQ number, the second cell is the trigger type.
+
+  regulators:
+    type: object
+    additionalProperties: false
+
+    patternProperties:
+      '^(buck[0-3]|ldo[0-8])$':
+        type: object
+        unevaluatedProperties: false
+        $ref: /schemas/regulator/regulator.yaml#
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@1c {
+            compatible = "maxim,max77714";
+            reg = <0x1c>;
+            interrupt-parent = <&gpio2>;
+            interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+        };
+    };
MAINTAINERS +5 -0
index 777cd6fa2b3d..e112ca549c5d 100644
@@ -11720,6 +11720,11 @@ F:	drivers/power/supply/max77650-charger.c
 F:	drivers/regulator/max77650-regulator.c
 F:	include/linux/mfd/max77650.h
 
+MAXIM MAX77714 PMIC MFD DRIVER
+M:	Luca Ceresoli <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
+
 MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER
 M:	Javier Martinez Canillas <[email protected]>
 L:	[email protected]
Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH v6 5/8 mfd: max77714: Add driver for Maxim MAX77714 PMIC

In reply to Luca Ceresoli

Add a simple driver for the Maxim MAX77714 PMIC, supporting RTC and watchdog only.

---

Changes in v6:
- describe as "Core driver", not "MFD driver" (Lee Jones)
- Update copyright year

Changes in v5: none

Changes in v4: none

Changes in v3:
- Suggested by Lee Jones:
- move struct mfd_cell to top of file
- remove struct max77714 and its kmalloc, not used after probe
- reword error messages
- add "/* pF */" onto the end of the load_cap line

Changes in v2:
- fix "watchdog" word in heading comment (Guenter Roeck)
- move struct max77714 to .c file (Krzysztof Kozlowski)
- change include guard format (Krzysztof Kozlowski)
- allow building as a module (Krzysztof Kozlowski)
- remove of_match_ptr usage (Krzysztof Kozlowski / lkp) (Reported-by: kernel test robot <[email protected]>)

---
 MAINTAINERS                  |   2 +
 drivers/mfd/Kconfig          |  14 ++++
 drivers/mfd/Makefile         |   1 +
 drivers/mfd/max77714.c       | 152 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/max77714.h |  60 ++++++++++++++
 5 files changed, 229 insertions(+)
 create mode 100644 drivers/mfd/max77714.c
 create mode 100644 include/linux/mfd/max77714.h
MAINTAINERS +2 -0
index e112ca549c5d..7c3abb2778cb 100644
@@ -11724,6 +11724,8 @@ MAXIM MAX77714 PMIC MFD DRIVER
 M:	Luca Ceresoli <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
+F:	drivers/mfd/max77714.c
+F:	include/linux/mfd/max77714.h
 
 MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER
 M:	Javier Martinez Canillas <[email protected]>
drivers/mfd/Kconfig +14 -0
index ba0b3eb131f1..036ddf68c814 100644
@@ -849,6 +849,20 @@ config MFD_MAX77693
 	  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
+	depends on OF || COMPILE_TEST
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  Say yes here to add support for Maxim Semiconductor MAX77714.
+	  This is a Power Management IC with 4 buck regulators, 9
+	  low-dropout regulators, 8 GPIOs, RTC, watchdog etc. This driver
+	  provides common support for accessing the device; additional
+	  drivers must be enabled in order to use each functionality of the
+	  device.
+
 config MFD_MAX77843
 	bool "Maxim Semiconductor MAX77843 PMIC Support"
 	depends on I2C=y
drivers/mfd/Makefile +1 -0
index df1ecc4a4c95..eea70cb9f9b9 100644
@@ -162,6 +162,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_MAX77714)	+= max77714.o
 obj-$(CONFIG_MFD_MAX77843)	+= max77843.o
 obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
 max8925-objs			:= max8925-core.o max8925-i2c.o
drivers/mfd/max77714.c new file +152 -0

152 lines not on this page · raw message

include/linux/mfd/max77714.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#6 lore raw

PATCH v6 6/8 watchdog: max77620: add support for the max77714 variant

In reply to Luca Ceresoli

The MAX77714 is a MFD chip whose watchdog has the same programming procedures as the MAX77620 watchdog, but most register offsets and bit masks are different, as well as some features.

Support the MAX77714 watchdog by adding a variant description table holding the differences.

All the features implemented by this driver are available on the MAX77714 except for the lack of a WDTOFFC bit. Instead of using a "HAS_*" flag we handle this by holding in the cnfg_glbl2_cfg_bits struct field the bits (i.e. the features) to enable in the CNFG_GLBL2 register. These bits differ among the two models. This implementation allows to avoid any conditional code, keeping the execution flow unchanged.

---

Changes in v6:
- Update copyright year

Changes in v5:
- keep a unique watchdog_info for both models (Guenter Roeck)

This patch is new in v4. It replaces v3 patch 7 ("watchdog: max77714: add driver for the watchdog in the MAX77714 PMIC") by adding MAX77714 wdog support to the existing MAX77620 wdog driver instead of adding a new driver. Suggested by Guenter Roeck and Krzysztof Kozlowski.

---
 drivers/watchdog/Kconfig        |  2 +-
 drivers/watchdog/max77620_wdt.c | 80 ++++++++++++++++++++++++++-------
 2 files changed, 65 insertions(+), 17 deletions(-)
drivers/watchdog/Kconfig +1 -1
index c8fa79da23b3..5373ecdec58e 100644
@@ -678,7 +678,7 @@ config MAX63XX_WATCHDOG
 
 config MAX77620_WATCHDOG
 	tristate "Maxim Max77620 Watchdog Timer"
-	depends on MFD_MAX77620 || COMPILE_TEST
+	depends on MFD_MAX77620 || MFD_MAX77714 || COMPILE_TEST
 	select WATCHDOG_CORE
 	help
 	  This is the driver for the Max77620 watchdog timer.
drivers/watchdog/max77620_wdt.c +64 -16

170 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#7 lore raw

PATCH v6 7/8 watchdog: max77620: add comment to clarify set_timeout procedure

In reply to Luca Ceresoli

Clarify why we need to ping the watchdog before changing the timeout by quoting the MAX77714 datasheet.

---

Changes in v6: none

Changes in v5:
- improve comment to remove misleading ambiguous interpretation (Guenter Roeck)

This patch is new in v4. It adds a clarification comment to the max77620 driver taken from v3 patch 7.

---
 drivers/watchdog/max77620_wdt.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/watchdog/max77620_wdt.c +5 -0
index cd321c7e0d59..b76ad6ba0915 100644
@@ -123,6 +123,11 @@ static int max77620_wdt_set_timeout(struct watchdog_device *wdt_dev,
 		break;
 	}
 
+	/*
+	 * "If the value of TWD needs to be changed, clear the system
+	 * watchdog timer first [...], then change the value of TWD."
+	 * (MAX77714 datasheet but applies to MAX77620 too)
+	 */
 	ret = regmap_update_bits(wdt->rmap, wdt->drv_data->reg_cnfg_glbl3,
 				 wdt->drv_data->wdtc_mask, 0x1);
 	if (ret < 0)
Signature · 1 line
2.25.1
author maintainer
#8 lore raw

PATCH v6 8/8 rtc: max77686: add MAX77714 support

In reply to Luca Ceresoli

The RTC included in the MAX77714 PMIC is very similar to the one in the MAX77686. Reuse the rtc-max77686.c driver with the minimum required changes for the MAX77714 RTC.

---

Changes in v6: none

Changes in v5: none

Changes in v4: none

Changes in v3: none

Changes in v2: none

---
 drivers/rtc/Kconfig        |  2 +-
 drivers/rtc/rtc-max77686.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
drivers/rtc/Kconfig +1 -1
index d85a3c31347c..f6d6d4c26361 100644
@@ -375,7 +375,7 @@ config RTC_DRV_MAX8997
 
 config RTC_DRV_MAX77686
 	tristate "Maxim MAX77686"
-	depends on MFD_MAX77686 || MFD_MAX77620 || COMPILE_TEST
+	depends on MFD_MAX77686 || MFD_MAX77620 || MFD_MAX77714 || COMPILE_TEST
 	help
 	  If you say yes here you will get support for the
 	  RTC of Maxim MAX77686/MAX77620/MAX77802 PMIC.
drivers/rtc/rtc-max77686.c +24 -0
index 5c64d08c0732..b0250d91fb00 100644
@@ -19,6 +19,7 @@
 
 #define MAX77686_I2C_ADDR_RTC		(0x0C >> 1)
 #define MAX77620_I2C_ADDR_RTC		0x68
+#define MAX77714_I2C_ADDR_RTC		0x48
 #define MAX77686_INVALID_I2C_ADDR	(-1)
 
 /* Define non existing register */
@@ -200,6 +201,28 @@ static const struct max77686_rtc_driver_data max77686_drv_data = {
 	.regmap_config = &max77686_rtc_regmap_config,
 };
 
+static const struct regmap_irq_chip max77714_rtc_irq_chip = {
+	.name		= "max77714-rtc",
+	.status_base	= MAX77686_RTC_INT,
+	.mask_base	= MAX77686_RTC_INTM,
+	.num_regs	= 1,
+	.irqs		= max77686_rtc_irqs,
+	.num_irqs	= ARRAY_SIZE(max77686_rtc_irqs) - 1, /* no WTSR on 77714 */
+};
+
+static const struct max77686_rtc_driver_data max77714_drv_data = {
+	.delay = 16000,
+	.mask  = 0x7f,
+	.map   = max77686_map,
+	.alarm_enable_reg = false,
+	.rtc_irq_from_platform = false,
+	/* On MAX77714 RTCA1 is BIT 1 of RTCINT (0x00). Not supported by this driver. */
+	.alarm_pending_status_reg = MAX77686_INVALID_REG,
+	.rtc_i2c_addr = MAX77714_I2C_ADDR_RTC,
+	.rtc_irq_chip = &max77714_rtc_irq_chip,
+	.regmap_config = &max77686_rtc_regmap_config,
+};
+
 static const struct regmap_config max77620_rtc_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -843,6 +866,7 @@ static const struct platform_device_id rtc_id[] = {
 	{ "max77686-rtc", .driver_data = (kernel_ulong_t)&max77686_drv_data, },
 	{ "max77802-rtc", .driver_data = (kernel_ulong_t)&max77802_drv_data, },
 	{ "max77620-rtc", .driver_data = (kernel_ulong_t)&max77620_drv_data, },
+	{ "max77714-rtc", .driver_data = (kernel_ulong_t)&max77714_drv_data, },
 	{},
 };
 MODULE_DEVICE_TABLE(platform, rtc_id);
Signature · 1 line
2.25.1
#9 lore raw

[GIT PULL] Immutable branch between MFD, RTC and Watchdog due for the v5.18 merge window

In reply to Luca Ceresoli

Enjoy!

The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07:

Linux 5.17-rc1 (2022-01-23 10:12:53 +0200)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-rtc-watchdog-v5.18

for you to fetch changes up to c58e496311a50c087eeeaaae81083cd643fe5128:

rtc: max77686: Add MAX77714 support (2022-03-07 13:55:04 +0000)

----------------------------------------------------------------
Immutable branch between MFD, RTC and Watchdog due for the v5.18 merge window

----------------------------------------------------------------
Luca Ceresoli (8):
rtc: max77686: Convert comments to kernel-doc format
rtc: max77686: Rename day-of-month defines
rtc: max77686: Remove unused code to read in 12-hour mode
dt-bindings: mfd: Add Maxim MAX77714 PMIC
mfd: max77714: Add driver for Maxim MAX77714 PMIC
watchdog: max77620: Add support for the max77714 variant
watchdog: max77620: Add comment to clarify set_timeout procedure
rtc: max77686: Add MAX77714 support

 .../devicetree/bindings/mfd/maxim,max77714.yaml    |  68 +++++++++
 MAINTAINERS                                        |   7 +
 drivers/mfd/Kconfig                                |  14 ++
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/max77686.c                             |   2 +-
 drivers/mfd/max77714.c                             | 152 +++++++++++++++++++++
 drivers/rtc/Kconfig                                |   2 +-
 drivers/rtc/rtc-max77686.c                         |  75 ++++++----
 drivers/watchdog/Kconfig                           |   2 +-
 drivers/watchdog/max77620_wdt.c                    |  85 +++++++++---
 include/linux/mfd/max77686-private.h               |   4 +-
 include/linux/mfd/max77714.h                       |  60 ++++++++
 12 files changed, 421 insertions(+), 51 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
 create mode 100644 drivers/mfd/max77714.c
 create mode 100644 include/linux/mfd/max77714.h
Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog