2021-04-20 17:03:02

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 0/9] mfd/rtc/regulator: Drop board file support for Samsung PMIC

Hi,

The Samsung PMIC drivers since long time are used only on devicetree
platforms (Samsung Exynos) and there are no users with board files.

Drop the support for board files entirely and depend on OF for matching.

This makes the code smaller and simpler.

Dependencies
============
The MFD pieces are rebased on my previous sec-core dirver changes:
mfd: sec: Simplify getting of_device_id match data
https://lore.kernel.org/linux-samsung-soc/[email protected]/T/#t

Applying - can be independent
=============================
The last RTC and regulator patches can be picked up independently via
regulator and rtc trees. There are no board files currently, so the
code in these drivers is basically dead code and feature-bisection is
preserved.

Best regards,
Krzysztof


Krzysztof Kozlowski (9):
mfd: sec: Drop support for board files and require devicetree
mfd: sec: Remove unused cfg_pmic_irq in platform data
mfd: sec: Remove unused device_type in platform data
mfd: sec: Remove unused irq_base in platform data
mfd: sec: Enable wakeup from suspend via devicetree property
mfd: sec: Remove unused platform data members
rtc: s5m: Remove reference to parent's device pdata
regulator: s2mpa01: Drop initialization via platform data
regulator: s2mps11: Drop initialization via platform data

drivers/mfd/Kconfig | 1 +
drivers/mfd/sec-core.c | 64 +++++---------------------------
drivers/mfd/sec-irq.c | 4 +-
drivers/regulator/s2mpa01.c | 4 --
drivers/regulator/s2mps11.c | 22 +----------
drivers/rtc/rtc-s5m.c | 6 ---
include/linux/mfd/samsung/core.h | 33 ----------------
7 files changed, 14 insertions(+), 120 deletions(-)

--
2.25.1


2021-04-20 17:03:34

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 4/9] mfd: sec: Remove unused irq_base in platform data

The 'irq_base' field of platform data structure is not assigned,
therefore its default value of 0 has no impact and can be safely
dropped.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/mfd/sec-core.c | 1 -
drivers/mfd/sec-irq.c | 4 +---
include/linux/mfd/samsung/core.h | 3 ---
3 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 4c4db3171ce6..a9d4fbc51997 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -337,7 +337,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
}

sec_pmic->device_type = (unsigned long)of_device_get_match_data(sec_pmic->dev);
- sec_pmic->irq_base = pdata->irq_base;
sec_pmic->wakeup = pdata->wakeup;
sec_pmic->pdata = pdata;

diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index a98c5d165039..e473c2fb42d5 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -444,7 +444,6 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
if (!sec_pmic->irq) {
dev_warn(sec_pmic->dev,
"No interrupt specified, no interrupts\n");
- sec_pmic->irq_base = 0;
return 0;
}

@@ -482,8 +481,7 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic,
sec_pmic->irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- sec_pmic->irq_base, sec_irq_chip,
- &sec_pmic->irq_data);
+ 0, sec_irq_chip, &sec_pmic->irq_data);
if (ret != 0) {
dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret);
return ret;
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index bfde1b7c6303..9864f13b7814 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -67,7 +67,6 @@ struct sec_pmic_dev {
struct i2c_client *i2c;

unsigned long device_type;
- int irq_base;
int irq;
struct regmap_irq_chip_data *irq_data;

@@ -83,8 +82,6 @@ struct sec_platform_data {
struct sec_opmode_data *opmode;
int num_regulators;

- int irq_base;
-
bool wakeup;
bool buck_voltage_lock;

--
2.25.1

2021-04-20 17:04:17

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 5/9] mfd: sec: Enable wakeup from suspend via devicetree property

Set device wakeup capability from devicetree property (done by drivers
core), instead of always setting it to 0 (because value in platform data
is not assigned).

This should not have visible effect on actual resuming from suspend
because the child device - S5M RTC driver - is responsible for waking
up and sets device wakeup unconditionally.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/mfd/sec-core.c | 8 --------
include/linux/mfd/samsung/core.h | 3 ---
2 files changed, 11 deletions(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index a9d4fbc51997..1fb29c45f5cf 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -298,12 +298,6 @@ sec_pmic_i2c_parse_dt_pdata(struct device *dev)
if (!pd)
return ERR_PTR(-ENOMEM);

- /*
- * ToDo: the 'wakeup' member in the platform data is more of a linux
- * specfic information. Hence, there is no binding for that yet and
- * not parsed here.
- */
-
pd->manual_poweroff = of_property_read_bool(dev->of_node,
"samsung,s2mps11-acokb-ground");
pd->disable_wrstbi = of_property_read_bool(dev->of_node,
@@ -337,7 +331,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
}

sec_pmic->device_type = (unsigned long)of_device_get_match_data(sec_pmic->dev);
- sec_pmic->wakeup = pdata->wakeup;
sec_pmic->pdata = pdata;

switch (sec_pmic->device_type) {
@@ -429,7 +422,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
if (ret)
return ret;

- device_init_wakeup(sec_pmic->dev, sec_pmic->wakeup);
sec_pmic_configure(sec_pmic);
sec_pmic_dump_rev(sec_pmic);

diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index 9864f13b7814..b0d049a56d16 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -69,8 +69,6 @@ struct sec_pmic_dev {
unsigned long device_type;
int irq;
struct regmap_irq_chip_data *irq_data;
-
- bool wakeup;
};

int sec_irq_init(struct sec_pmic_dev *sec_pmic);
@@ -82,7 +80,6 @@ struct sec_platform_data {
struct sec_opmode_data *opmode;
int num_regulators;

- bool wakeup;
bool buck_voltage_lock;

int buck_gpios[3];
--
2.25.1

2021-04-20 17:04:44

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 7/9] rtc: s5m: Remove reference to parent's device pdata

The S5M RTC driver does not use parent's device (sec-core PMIC driver)
platform data so there is no need to check for it.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/rtc/rtc-s5m.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index 80b66f16db89..038269a6b08c 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -713,16 +713,10 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
static int s5m_rtc_probe(struct platform_device *pdev)
{
struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent);
- struct sec_platform_data *pdata = s5m87xx->pdata;
struct s5m_rtc_info *info;
const struct regmap_config *regmap_cfg;
int ret, alarm_irq;

- if (!pdata) {
- dev_err(pdev->dev.parent, "Platform data not supplied\n");
- return -ENODEV;
- }
-
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
--
2.25.1

2021-04-20 17:05:04

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 8/9] regulator: s2mpa01: Drop initialization via platform data

None of the platforms with S2MPA01 use board files, so any
initialization via platform data can be safely removed.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/regulator/s2mpa01.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
index 115f59530852..28b424fe7bea 100644
--- a/drivers/regulator/s2mpa01.c
+++ b/drivers/regulator/s2mpa01.c
@@ -340,7 +340,6 @@ static const struct regulator_desc regulators[] = {
static int s2mpa01_pmic_probe(struct platform_device *pdev)
{
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
- struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
struct regulator_config config = { };
struct s2mpa01_info *s2mpa01;
int i;
@@ -356,9 +355,6 @@ static int s2mpa01_pmic_probe(struct platform_device *pdev)
for (i = 0; i < S2MPA01_REGULATOR_MAX; i++) {
struct regulator_dev *rdev;

- if (pdata)
- config.init_data = pdata->regulators[i].initdata;
-
rdev = devm_regulator_register(&pdev->dev,
&regulators[i], &config);
if (IS_ERR(rdev)) {
--
2.25.1

2021-04-20 17:05:08

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 2/9] mfd: sec: Remove unused cfg_pmic_irq in platform data

The 'cfg_pmic_irq' field of platform data structure is not used and can
be safely dropped.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/mfd/sec-core.c | 3 ---
include/linux/mfd/samsung/core.h | 1 -
2 files changed, 4 deletions(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index c61c1fc62165..653d02b98d53 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -382,9 +382,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
return ret;
}

- if (pdata->cfg_pmic_irq)
- pdata->cfg_pmic_irq();
-
sec_irq_init(sec_pmic);

pm_runtime_set_active(sec_pmic->dev);
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index f1631a39acfc..68afc2b97a41 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -85,7 +85,6 @@ struct sec_platform_data {
int num_regulators;

int irq_base;
- int (*cfg_pmic_irq)(void);

bool wakeup;
bool buck_voltage_lock;
--
2.25.1

2021-04-20 17:05:50

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 3/9] mfd: sec: Remove unused device_type in platform data

The 'device_type' field of platform data structure is not used and can
be safely dropped.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/mfd/sec-core.c | 5 +----
include/linux/mfd/samsung/core.h | 1 -
2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 653d02b98d53..4c4db3171ce6 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -318,7 +318,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
struct sec_platform_data *pdata;
const struct mfd_cell *sec_devs;
struct sec_pmic_dev *sec_pmic;
- unsigned long device_type;
int ret, num_sec_devs;

sec_pmic = devm_kzalloc(&i2c->dev, sizeof(struct sec_pmic_dev),
@@ -330,16 +329,14 @@ static int sec_pmic_probe(struct i2c_client *i2c,
sec_pmic->dev = &i2c->dev;
sec_pmic->i2c = i2c;
sec_pmic->irq = i2c->irq;
- device_type = (unsigned long)of_device_get_match_data(sec_pmic->dev);

pdata = sec_pmic_i2c_parse_dt_pdata(sec_pmic->dev);
if (IS_ERR(pdata)) {
ret = PTR_ERR(pdata);
return ret;
}
- pdata->device_type = device_type;

- sec_pmic->device_type = pdata->device_type;
+ sec_pmic->device_type = (unsigned long)of_device_get_match_data(sec_pmic->dev);
sec_pmic->irq_base = pdata->irq_base;
sec_pmic->wakeup = pdata->wakeup;
sec_pmic->pdata = pdata;
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index 68afc2b97a41..bfde1b7c6303 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -81,7 +81,6 @@ int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
struct sec_platform_data {
struct sec_regulator_data *regulators;
struct sec_opmode_data *opmode;
- int device_type;
int num_regulators;

int irq_base;
--
2.25.1

2021-04-20 17:06:17

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 6/9] mfd: sec: Remove unused platform data members

The Samsung PMIC drivers for early chipsets like S5M8767 stored quite a
lot in platform data (struct sec_platform_data). The s5m8767 regulator
driver currently references only some of its fields. Newer regulator
drivers (e.g. s2mps11) use even less platform data fields.

Clean up the structure to reduce memory footprint and source code size.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
include/linux/mfd/samsung/core.h | 25 -------------------------
1 file changed, 25 deletions(-)

diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index b0d049a56d16..f92fe090473d 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -80,8 +80,6 @@ struct sec_platform_data {
struct sec_opmode_data *opmode;
int num_regulators;

- bool buck_voltage_lock;
-
int buck_gpios[3];
int buck_ds[3];
unsigned int buck2_voltage[8];
@@ -91,35 +89,12 @@ struct sec_platform_data {
unsigned int buck4_voltage[8];
bool buck4_gpiodvs;

- int buck_set1;
- int buck_set2;
- int buck_set3;
- int buck2_enable;
- int buck3_enable;
- int buck4_enable;
int buck_default_idx;
- int buck2_default_idx;
- int buck3_default_idx;
- int buck4_default_idx;
-
int buck_ramp_delay;

- int buck2_ramp_delay;
- int buck34_ramp_delay;
- int buck5_ramp_delay;
- int buck16_ramp_delay;
- int buck7810_ramp_delay;
- int buck9_ramp_delay;
- int buck24_ramp_delay;
- int buck3_ramp_delay;
- int buck7_ramp_delay;
- int buck8910_ramp_delay;
-
- bool buck1_ramp_enable;
bool buck2_ramp_enable;
bool buck3_ramp_enable;
bool buck4_ramp_enable;
- bool buck6_ramp_enable;

int buck2_init;
int buck3_init;
--
2.25.1

2021-04-20 17:07:11

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 9/9] regulator: s2mps11: Drop initialization via platform data

None of the platforms with S2MPS11 use board files, so any
initialization via platform data can be safely removed.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/regulator/s2mps11.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 33cf84bce05a..ebc67e3ddd4f 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -1120,7 +1120,6 @@ static const struct regulator_desc s2mpu02_regulators[] = {
static int s2mps11_pmic_probe(struct platform_device *pdev)
{
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
- struct sec_platform_data *pdata = NULL;
struct of_regulator_match *rdata = NULL;
struct regulator_config config = { };
struct s2mps11_info *s2mps11;
@@ -1171,17 +1170,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
if (!s2mps11->ext_control_gpiod)
return -ENOMEM;

- if (!iodev->dev->of_node) {
- if (iodev->pdata) {
- pdata = iodev->pdata;
- goto common_reg;
- } else {
- dev_err(pdev->dev.parent,
- "Platform data or DT node not supplied\n");
- return -ENODEV;
- }
- }
-
rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
if (!rdata)
return -ENOMEM;
@@ -1193,7 +1181,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
if (ret)
goto out;

-common_reg:
platform_set_drvdata(pdev, s2mps11);

config.dev = &pdev->dev;
@@ -1202,13 +1189,8 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
for (i = 0; i < rdev_num; i++) {
struct regulator_dev *regulator;

- if (pdata) {
- config.init_data = pdata->regulators[i].initdata;
- config.of_node = pdata->regulators[i].reg_node;
- } else {
- config.init_data = rdata[i].init_data;
- config.of_node = rdata[i].of_node;
- }
+ config.init_data = rdata[i].init_data;
+ config.of_node = rdata[i].of_node;
config.ena_gpiod = s2mps11->ext_control_gpiod[i];
/*
* Hand the GPIO descriptor management over to the regulator
--
2.25.1

2021-04-22 01:20:25

by Mark Brown

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/9] mfd/rtc/regulator: Drop board file support for Samsung PMIC

On Tue, 20 Apr 2021 19:01:09 +0200, Krzysztof Kozlowski wrote:
> The Samsung PMIC drivers since long time are used only on devicetree
> platforms (Samsung Exynos) and there are no users with board files.
>
> Drop the support for board files entirely and depend on OF for matching.
>
> This makes the code smaller and simpler.
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[8/9] regulator: s2mpa01: Drop initialization via platform data
commit: 378b40ae1a8639f03192711573e478a367ccb6e1
[9/9] regulator: s2mps11: Drop initialization via platform data
commit: beeab9bc8e85de6cacbbb2124a464166f2f5043d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

2021-04-29 21:31:23

by Alexandre Belloni

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/9] mfd/rtc/regulator: Drop board file support for Samsung PMIC

On Tue, 20 Apr 2021 19:01:09 +0200, Krzysztof Kozlowski wrote:
> The Samsung PMIC drivers since long time are used only on devicetree
> platforms (Samsung Exynos) and there are no users with board files.
>
> Drop the support for board files entirely and depend on OF for matching.
>
> This makes the code smaller and simpler.
>
> [...]

Applied, thanks!

[7/9] rtc: s5m: Remove reference to parent's device pdata
commit: aa364b12fd7404374a8a6c55ec2e4a70aba9a574

Best regards,
--
Alexandre Belloni <[email protected]>