Skip to content

Commit a763913

Browse files
author
Lee Jones
committed
Merge tag 'ib-mfd-watchdog-v5.13' into ibs-for-mfd-merged
Immutable branch between MFD and Watchdog due for the v5.13 merge window
2 parents 1658d62 + 42fc191 commit a763913

10 files changed

Lines changed: 775 additions & 0 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mfd/rohm,bd9576-pmic.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: ROHM BD9576MUF and BD9573MUF Power Management Integrated Circuit bindings
8+
9+
maintainers:
10+
- Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
11+
12+
description: |
13+
BD9576MUF and BD9573MUF are power management ICs primarily intended for
14+
powering the R-Car series processors.
15+
The IC provides 6 power outputs with configurable sequencing and safety
16+
monitoring. A watchdog logic with slow ping/windowed modes is also included.
17+
18+
properties:
19+
compatible:
20+
enum:
21+
- rohm,bd9576
22+
- rohm,bd9573
23+
24+
reg:
25+
description:
26+
I2C slave address.
27+
maxItems: 1
28+
29+
interrupts:
30+
maxItems: 1
31+
32+
rohm,vout1-en-low:
33+
description:
34+
BD9576 and BD9573 VOUT1 regulator enable state can be individually
35+
controlled by a GPIO. This is dictated by state of vout1-en pin during
36+
the PMIC startup. If vout1-en is LOW during PMIC startup then the VOUT1
37+
enable sate is controlled via this pin. Set this property if vout1-en
38+
is wired to be down at PMIC start-up.
39+
type: boolean
40+
41+
rohm,vout1-en-gpios:
42+
description:
43+
GPIO specifier to specify the GPIO connected to vout1-en for vout1 ON/OFF
44+
state control.
45+
maxItems: 1
46+
47+
rohm,ddr-sel-low:
48+
description:
49+
The BD9576 and BD9573 output voltage for DDR can be selected by setting
50+
the ddr-sel pin low or high. Set this property if ddr-sel is grounded.
51+
type: boolean
52+
53+
rohm,watchdog-enable-gpios:
54+
description: The GPIO line used to enable the watchdog.
55+
maxItems: 1
56+
57+
rohm,watchdog-ping-gpios:
58+
description: The GPIO line used to ping the watchdog.
59+
maxItems: 1
60+
61+
rohm,hw-timeout-ms:
62+
maxItems: 2
63+
description:
64+
Watchog timeout in milliseconds. If single value is given it is
65+
the maximum timeout. Eg. if pinging watchdog is not done within this time
66+
limit the watchdog will be triggered. If two values are given watchdog
67+
is configured in "window mode". Then first value is limit for short-ping
68+
Eg. if watchdog is pinged sooner than that the watchdog will trigger.
69+
When two values is given the second value is the maximum timeout.
70+
# (HW) minimum for short timeout is 2ms, maximum 220 ms.
71+
# (HW) minimum for max timeout is 4ms, maximum 4416 ms.
72+
73+
regulators:
74+
$ref: ../regulator/rohm,bd9576-regulator.yaml
75+
description:
76+
List of child nodes that specify the regulators.
77+
78+
required:
79+
- compatible
80+
- reg
81+
- regulators
82+
83+
additionalProperties: false
84+
85+
examples:
86+
- |
87+
#include <dt-bindings/gpio/gpio.h>
88+
#include <dt-bindings/leds/common.h>
89+
i2c {
90+
#address-cells = <1>;
91+
#size-cells = <0>;
92+
pmic: pmic@30 {
93+
compatible = "rohm,bd9576";
94+
reg = <0x30>;
95+
rohm,vout1-en-low;
96+
rohm,vout1-en-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
97+
rohm,ddr-sel-low;
98+
rohm,watchdog-enable-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
99+
rohm,watchdog-ping-gpios = <&gpio2 7 GPIO_ACTIVE_HIGH>;
100+
rohm,hw-timeout-ms = <150>, <2300>;
101+
102+
regulators {
103+
boost1: regulator-vd50 {
104+
regulator-name = "VD50";
105+
};
106+
buck1: regulator-vd18 {
107+
regulator-name = "VD18";
108+
};
109+
buck2: regulator-vdddr {
110+
regulator-name = "VDDDR";
111+
};
112+
buck3: regulator-vd10 {
113+
regulator-name = "VD10";
114+
};
115+
ldo: regulator-voutl1 {
116+
regulator-name = "VOUTL1";
117+
};
118+
sw: regulator-vouts1 {
119+
regulator-name = "VOUTS1";
120+
};
121+
};
122+
};
123+
};

‎MAINTAINERS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15478,18 +15478,22 @@ F: drivers/gpio/gpio-bd71828.c
1547815478
F: drivers/mfd/rohm-bd70528.c
1547915479
F: drivers/mfd/rohm-bd71828.c
1548015480
F: drivers/mfd/rohm-bd718x7.c
15481+
F: drivers/mfd/rohm-bd9576.c
1548115482
F: drivers/power/supply/bd70528-charger.c
1548215483
F: drivers/regulator/bd70528-regulator.c
1548315484
F: drivers/regulator/bd71815-regulator.c
1548415485
F: drivers/regulator/bd71828-regulator.c
1548515486
F: drivers/regulator/bd718x7-regulator.c
15487+
F: drivers/regulator/bd9576-regulator.c
1548615488
F: drivers/regulator/rohm-regulator.c
1548715489
F: drivers/rtc/rtc-bd70528.c
1548815490
F: drivers/watchdog/bd70528_wdt.c
15491+
F: drivers/watchdog/bd9576_wdt.c
1548915492
F: include/linux/mfd/rohm-bd70528.h
1549015493
F: include/linux/mfd/rohm-bd71815.h
1549115494
F: include/linux/mfd/rohm-bd71828.h
1549215495
F: include/linux/mfd/rohm-bd718x7.h
15496+
F: include/linux/mfd/rohm-bd957x.h
1549315497
F: include/linux/mfd/rohm-generic.h
1549415498
F: include/linux/mfd/rohm-shared.h
1549515499

‎drivers/mfd/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,17 @@ config MFD_ROHM_BD71828
20012001
also a single-cell linear charger, a Coulomb counter, a real-time
20022002
clock (RTC), GPIOs and a 32.768 kHz clock gate.
20032003

2004+
config MFD_ROHM_BD957XMUF
2005+
tristate "ROHM BD9576MUF and BD9573MUF Power Management ICs"
2006+
depends on I2C=y
2007+
depends on OF
2008+
select REGMAP_I2C
2009+
select MFD_CORE
2010+
help
2011+
Select this option to get support for the ROHM BD9576MUF and
2012+
BD9573MUF Power Management ICs. BD9576 and BD9573 are primarily
2013+
designed to be used to power R-Car series processors.
2014+
20042015
config MFD_STM32_LPTIMER
20052016
tristate "Support for STM32 Low-Power Timer"
20062017
depends on (ARCH_STM32 && OF) || COMPILE_TEST

‎drivers/mfd/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o
262262
obj-$(CONFIG_MFD_ROHM_BD70528) += rohm-bd70528.o
263263
obj-$(CONFIG_MFD_ROHM_BD71828) += rohm-bd71828.o
264264
obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o
265+
obj-$(CONFIG_MFD_ROHM_BD957XMUF) += rohm-bd9576.o
265266
obj-$(CONFIG_MFD_STMFX) += stmfx.o
266267
obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o
267268
obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o

‎drivers/mfd/rohm-bd9576.c‎

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Copyright (C) 2021 ROHM Semiconductors
4+
*
5+
* ROHM BD9576MUF and BD9573MUF PMIC driver
6+
*/
7+
8+
#include <linux/i2c.h>
9+
#include <linux/interrupt.h>
10+
#include <linux/ioport.h>
11+
#include <linux/irq.h>
12+
#include <linux/mfd/core.h>
13+
#include <linux/mfd/rohm-bd957x.h>
14+
#include <linux/mfd/rohm-generic.h>
15+
#include <linux/module.h>
16+
#include <linux/of_device.h>
17+
#include <linux/regmap.h>
18+
#include <linux/types.h>
19+
20+
enum {
21+
BD957X_REGULATOR_CELL,
22+
BD957X_WDT_CELL,
23+
};
24+
25+
/*
26+
* Due to the BD9576MUF nasty IRQ behaiour we don't always populate IRQs.
27+
* These will be added to regulator resources only if IRQ information for the
28+
* PMIC is populated in device-tree.
29+
*/
30+
static const struct resource bd9576_regulator_irqs[] = {
31+
DEFINE_RES_IRQ_NAMED(BD9576_INT_THERM, "bd9576-temp"),
32+
DEFINE_RES_IRQ_NAMED(BD9576_INT_OVD, "bd9576-ovd"),
33+
DEFINE_RES_IRQ_NAMED(BD9576_INT_UVD, "bd9576-uvd"),
34+
};
35+
36+
static struct mfd_cell bd9573_mfd_cells[] = {
37+
[BD957X_REGULATOR_CELL] = { .name = "bd9573-regulator", },
38+
[BD957X_WDT_CELL] = { .name = "bd9576-wdt", },
39+
};
40+
41+
static struct mfd_cell bd9576_mfd_cells[] = {
42+
[BD957X_REGULATOR_CELL] = { .name = "bd9576-regulator", },
43+
[BD957X_WDT_CELL] = { .name = "bd9576-wdt", },
44+
};
45+
46+
static const struct regmap_range volatile_ranges[] = {
47+
regmap_reg_range(BD957X_REG_SMRB_ASSERT, BD957X_REG_SMRB_ASSERT),
48+
regmap_reg_range(BD957X_REG_PMIC_INTERNAL_STAT,
49+
BD957X_REG_PMIC_INTERNAL_STAT),
50+
regmap_reg_range(BD957X_REG_INT_THERM_STAT, BD957X_REG_INT_THERM_STAT),
51+
regmap_reg_range(BD957X_REG_INT_OVP_STAT, BD957X_REG_INT_SYS_STAT),
52+
regmap_reg_range(BD957X_REG_INT_MAIN_STAT, BD957X_REG_INT_MAIN_STAT),
53+
};
54+
55+
static const struct regmap_access_table volatile_regs = {
56+
.yes_ranges = &volatile_ranges[0],
57+
.n_yes_ranges = ARRAY_SIZE(volatile_ranges),
58+
};
59+
60+
static struct regmap_config bd957x_regmap = {
61+
.reg_bits = 8,
62+
.val_bits = 8,
63+
.volatile_table = &volatile_regs,
64+
.max_register = BD957X_MAX_REGISTER,
65+
.cache_type = REGCACHE_RBTREE,
66+
};
67+
68+
static struct regmap_irq bd9576_irqs[] = {
69+
REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM),
70+
REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP),
71+
REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP),
72+
REGMAP_IRQ_REG(BD9576_INT_OCP, 0, BD957X_MASK_INT_MAIN_OCP),
73+
REGMAP_IRQ_REG(BD9576_INT_OVD, 0, BD957X_MASK_INT_MAIN_OVD),
74+
REGMAP_IRQ_REG(BD9576_INT_UVD, 0, BD957X_MASK_INT_MAIN_UVD),
75+
REGMAP_IRQ_REG(BD9576_INT_UVP, 0, BD957X_MASK_INT_MAIN_UVP),
76+
REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS),
77+
};
78+
79+
static struct regmap_irq_chip bd9576_irq_chip = {
80+
.name = "bd9576_irq",
81+
.irqs = &bd9576_irqs[0],
82+
.num_irqs = ARRAY_SIZE(bd9576_irqs),
83+
.status_base = BD957X_REG_INT_MAIN_STAT,
84+
.mask_base = BD957X_REG_INT_MAIN_MASK,
85+
.ack_base = BD957X_REG_INT_MAIN_STAT,
86+
.init_ack_masked = true,
87+
.num_regs = 1,
88+
.irq_reg_stride = 1,
89+
};
90+
91+
static int bd957x_i2c_probe(struct i2c_client *i2c,
92+
const struct i2c_device_id *id)
93+
{
94+
int ret;
95+
struct regmap *regmap;
96+
struct mfd_cell *cells;
97+
int num_cells;
98+
unsigned long chip_type;
99+
struct irq_domain *domain;
100+
bool usable_irqs;
101+
102+
chip_type = (unsigned long)of_device_get_match_data(&i2c->dev);
103+
104+
switch (chip_type) {
105+
case ROHM_CHIP_TYPE_BD9576:
106+
cells = bd9576_mfd_cells;
107+
num_cells = ARRAY_SIZE(bd9576_mfd_cells);
108+
usable_irqs = !!i2c->irq;
109+
break;
110+
case ROHM_CHIP_TYPE_BD9573:
111+
cells = bd9573_mfd_cells;
112+
num_cells = ARRAY_SIZE(bd9573_mfd_cells);
113+
/*
114+
* BD9573 only supports fatal IRQs which we can not handle
115+
* because SoC is going to lose the power.
116+
*/
117+
usable_irqs = false;
118+
break;
119+
default:
120+
dev_err(&i2c->dev, "Unknown device type");
121+
return -EINVAL;
122+
}
123+
124+
regmap = devm_regmap_init_i2c(i2c, &bd957x_regmap);
125+
if (IS_ERR(regmap)) {
126+
dev_err(&i2c->dev, "Failed to initialize Regmap\n");
127+
return PTR_ERR(regmap);
128+
}
129+
130+
/*
131+
* BD9576 behaves badly. It kepts IRQ line asserted for the whole
132+
* duration of detected HW condition (like over temperature). So we
133+
* don't require IRQ to be populated.
134+
* If IRQ information is not given, then we mask all IRQs and do not
135+
* provide IRQ resources to regulator driver - which then just omits
136+
* the notifiers.
137+
*/
138+
if (usable_irqs) {
139+
struct regmap_irq_chip_data *irq_data;
140+
struct mfd_cell *regulators;
141+
142+
regulators = &bd9576_mfd_cells[BD957X_REGULATOR_CELL];
143+
regulators->resources = bd9576_regulator_irqs;
144+
regulators->num_resources = ARRAY_SIZE(bd9576_regulator_irqs);
145+
146+
ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq,
147+
IRQF_ONESHOT, 0,
148+
&bd9576_irq_chip, &irq_data);
149+
if (ret) {
150+
dev_err(&i2c->dev, "Failed to add IRQ chip\n");
151+
return ret;
152+
}
153+
domain = regmap_irq_get_domain(irq_data);
154+
} else {
155+
ret = regmap_update_bits(regmap, BD957X_REG_INT_MAIN_MASK,
156+
BD957X_MASK_INT_ALL,
157+
BD957X_MASK_INT_ALL);
158+
if (ret)
159+
return ret;
160+
domain = NULL;
161+
}
162+
163+
ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, cells,
164+
num_cells, NULL, 0, domain);
165+
if (ret)
166+
dev_err(&i2c->dev, "Failed to create subdevices\n");
167+
168+
return ret;
169+
}
170+
171+
static const struct of_device_id bd957x_of_match[] = {
172+
{ .compatible = "rohm,bd9576", .data = (void *)ROHM_CHIP_TYPE_BD9576, },
173+
{ .compatible = "rohm,bd9573", .data = (void *)ROHM_CHIP_TYPE_BD9573, },
174+
{ },
175+
};
176+
MODULE_DEVICE_TABLE(of, bd957x_of_match);
177+
178+
static struct i2c_driver bd957x_drv = {
179+
.driver = {
180+
.name = "rohm-bd957x",
181+
.of_match_table = bd957x_of_match,
182+
},
183+
.probe = &bd957x_i2c_probe,
184+
};
185+
module_i2c_driver(bd957x_drv);
186+
187+
MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
188+
MODULE_DESCRIPTION("ROHM BD9576MUF and BD9573MUF Power Management IC driver");
189+
MODULE_LICENSE("GPL");

‎drivers/watchdog/Kconfig‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ config BD70528_WATCHDOG
172172
Alternatively say M to compile the driver as a module,
173173
which will be called bd70528_wdt.
174174

175+
config BD957XMUF_WATCHDOG
176+
tristate "ROHM BD9576MUF and BD9573MUF PMIC Watchdog"
177+
depends on MFD_ROHM_BD957XMUF
178+
select WATCHDOG_CORE
179+
help
180+
Support for the watchdog in the ROHM BD9576 and BD9573 PMICs.
181+
These PMIC ICs contain watchdog block which can be configured
182+
to toggle reset line if SoC fails to ping watchdog via GPIO.
183+
184+
Say Y here to include support for the ROHM BD9576 or BD9573
185+
watchdog. Alternatively say M to compile the driver as a module,
186+
which will be called bd9576_wdt.
187+
175188
config DA9052_WATCHDOG
176189
tristate "Dialog DA9052 Watchdog"
177190
depends on PMIC_DA9052 || COMPILE_TEST

‎drivers/watchdog/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o
204204

205205
# Architecture Independent
206206
obj-$(CONFIG_BD70528_WATCHDOG) += bd70528_wdt.o
207+
obj-$(CONFIG_BD957XMUF_WATCHDOG) += bd9576_wdt.o
207208
obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o
208209
obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o
209210
obj-$(CONFIG_DA9062_WATCHDOG) += da9062_wdt.o

0 commit comments

Comments
 (0)