rockchip: backport poweroff support for rk806

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2024-01-26 15:54:24 +08:00
parent a87e404eb8
commit b4281bd4fb
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
14 changed files with 276 additions and 22 deletions

View File

@ -0,0 +1,31 @@
From 5d69b181cd0db10dc8327d28ce837b3623cd531a Mon Sep 17 00:00:00 2001
From: Tom Fitzhenry <tom@tom-fitzhenry.me.uk>
Date: Mon, 2 Jan 2023 22:11:47 +1100
Subject: [PATCH] mfd: rk808: Re-add rk808-clkout to RK818
Fixes RK818 (e.g. on Pinephone Pro) to register its clock, without which
dependent devices (e.g. wifi/BT, via sdio-wifi-pwrseq) fail to probe.
This line was removed in commit 3633daacea2e
("mfd: rk808: Permit having multiple PMIC instances"), but only from RK818.
Fixes: 3633daacea2e ("mfd: rk808: Permit having multiple PMIC instances")
Signed-off-by: Tom Fitzhenry <tom@tom-fitzhenry.me.uk>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230102111147.2580861-1-tom@tom-fitzhenry.me.uk
---
drivers/mfd/rk808.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -189,6 +189,7 @@ static const struct mfd_cell rk817s[] =
};
static const struct mfd_cell rk818s[] = {
+ { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
{ .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
{
.name = "rk808-rtc",

View File

@ -16,7 +16,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -547,13 +547,11 @@ static const struct regmap_irq_chip rk81
@@ -548,13 +548,11 @@ static const struct regmap_irq_chip rk81
.init_ack_masked = true,
};
@ -32,7 +32,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
switch (rk808->variant) {
case RK805_ID:
@@ -574,16 +572,18 @@ static void rk808_pm_power_off(void)
@@ -575,16 +573,18 @@ static void rk808_pm_power_off(void)
bit = DEV_OFF;
break;
default:
@ -55,7 +55,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
unsigned int reg, bit;
int ret;
@@ -599,16 +599,11 @@ static int rk808_restart_notify(struct n
@@ -600,16 +600,11 @@ static int rk808_restart_notify(struct n
}
ret = regmap_update_bits(rk808->regmap, reg, bit, bit);
if (ret)
@ -73,7 +73,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
static void rk8xx_shutdown(struct i2c_client *client)
{
struct rk808 *rk808 = i2c_get_clientdata(client);
@@ -744,9 +739,9 @@ static int rk808_probe(struct i2c_client
@@ -745,9 +740,9 @@ static int rk808_probe(struct i2c_client
return -EINVAL;
}
@ -86,7 +86,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
if (ret) {
dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
return ret;
@@ -770,17 +765,23 @@ static int rk808_probe(struct i2c_client
@@ -771,17 +766,23 @@ static int rk808_probe(struct i2c_client
regmap_irq_get_domain(rk808->irq_data));
if (ret) {
dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
@ -114,7 +114,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
if (ret)
dev_warn(&client->dev, "failed to register rst handler, %d\n", ret);
break;
@@ -791,26 +792,6 @@ static int rk808_probe(struct i2c_client
@@ -792,26 +793,6 @@ static int rk808_probe(struct i2c_client
}
return 0;
@ -141,7 +141,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
}
static int __maybe_unused rk8xx_suspend(struct device *dev)
@@ -867,7 +848,6 @@ static struct i2c_driver rk808_i2c_drive
@@ -868,7 +849,6 @@ static struct i2c_driver rk808_i2c_drive
.pm = &rk8xx_pm_ops,
},
.probe_new = rk808_probe,

View File

@ -21,7 +21,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -669,18 +669,12 @@ static int rk808_probe(struct i2c_client
@@ -670,18 +670,12 @@ static int rk808_probe(struct i2c_client
/* Read chip variant */
msb = i2c_smbus_read_byte_data(client, pmic_id_msb);
@ -44,7 +44,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
dev_info(&client->dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
@@ -729,44 +723,34 @@ static int rk808_probe(struct i2c_client
@@ -730,44 +724,34 @@ static int rk808_probe(struct i2c_client
i2c_set_clientdata(client, rk808);
rk808->regmap = devm_regmap_init_i2c(client, rk808->regmap_cfg);

View File

@ -19,7 +19,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -576,7 +576,7 @@ static int rk808_power_off(struct sys_of
@@ -577,7 +577,7 @@ static int rk808_power_off(struct sys_of
}
ret = regmap_update_bits(rk808->regmap, reg, bit, bit);
if (ret)
@ -28,7 +28,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
return NOTIFY_DONE;
}
@@ -599,7 +599,7 @@ static int rk808_restart(struct sys_off_
@@ -600,7 +600,7 @@ static int rk808_restart(struct sys_off_
}
ret = regmap_update_bits(rk808->regmap, reg, bit, bit);
if (ret)
@ -37,7 +37,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
return NOTIFY_DONE;
}
@@ -719,7 +719,7 @@ static int rk808_probe(struct i2c_client
@@ -720,7 +720,7 @@ static int rk808_probe(struct i2c_client
return -EINVAL;
}

View File

@ -86,7 +86,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
obj-$(CONFIG_MFD_SYSCON) += syscon.o
--- a/drivers/mfd/rk808.c
+++ /dev/null
@@ -1,844 +0,0 @@
@@ -1,845 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * MFD core driver for Rockchip RK808/RK818
@ -278,6 +278,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
-};
-
-static const struct mfd_cell rk818s[] = {
- { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
- { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
- {
- .name = "rk808-rtc",
@ -933,7 +934,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
-MODULE_DESCRIPTION("RK808/RK818 PMIC driver");
--- /dev/null
+++ b/drivers/mfd/rk8xx-core.c
@@ -0,0 +1,705 @@
@@ -0,0 +1,706 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * MFD core driver for Rockchip RK8XX
@ -1036,6 +1037,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
+};
+
+static const struct mfd_cell rk818s[] = {
+ { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
+ { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
+ {
+ .name = "rk808-rtc",

View File

@ -22,7 +22,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
--- a/drivers/mfd/rk8xx-core.c
+++ b/drivers/mfd/rk8xx-core.c
@@ -596,8 +596,6 @@ int rk8xx_probe(struct device *dev, int
@@ -597,8 +597,6 @@ int rk8xx_probe(struct device *dev, int
return -EINVAL;
}

View File

@ -87,7 +87,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
{ .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
@@ -122,6 +138,12 @@ static const struct rk808_reg_data rk805
@@ -123,6 +139,12 @@ static const struct rk808_reg_data rk805
{RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
};
@ -100,7 +100,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_200MA },
@@ -272,6 +294,27 @@ static const struct regmap_irq rk805_irq
@@ -273,6 +295,27 @@ static const struct regmap_irq rk805_irq
},
};
@ -128,7 +128,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
static const struct regmap_irq rk808_irqs[] = {
/* INT_STS */
[RK808_IRQ_VOUT_LO] = {
@@ -422,6 +465,18 @@ static struct regmap_irq_chip rk805_irq_
@@ -423,6 +466,18 @@ static struct regmap_irq_chip rk805_irq_
.init_ack_masked = true,
};
@ -147,7 +147,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
static const struct regmap_irq_chip rk808_irq_chip = {
.name = "rk808",
.irqs = rk808_irqs,
@@ -548,6 +603,7 @@ int rk8xx_probe(struct device *dev, int
@@ -549,6 +604,7 @@ int rk8xx_probe(struct device *dev, int
struct rk808 *rk808;
const struct rk808_reg_data *pre_init_reg;
const struct mfd_cell *cells;
@ -155,7 +155,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
int nr_pre_init_regs;
int nr_cells;
int ret;
@@ -569,6 +625,14 @@ int rk8xx_probe(struct device *dev, int
@@ -570,6 +626,14 @@ int rk8xx_probe(struct device *dev, int
cells = rk805s;
nr_cells = ARRAY_SIZE(rk805s);
break;
@ -170,7 +170,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
case RK808_ID:
rk808->regmap_irq_chip = &rk808_irq_chip;
pre_init_reg = rk808_pre_init_reg;
@@ -600,7 +664,7 @@ int rk8xx_probe(struct device *dev, int
@@ -601,7 +665,7 @@ int rk8xx_probe(struct device *dev, int
return dev_err_probe(dev, -EINVAL, "No interrupt support, no core IRQ\n");
ret = devm_regmap_add_irq_chip(dev, rk808->regmap, irq,
@ -179,7 +179,7 @@ Signed-off-by: Lee Jones <lee@kernel.org>
rk808->regmap_irq_chip, &rk808->irq_data);
if (ret)
return dev_err_probe(dev, ret, "Failed to add irq_chip\n");
@@ -615,8 +679,7 @@ int rk8xx_probe(struct device *dev, int
@@ -616,8 +680,7 @@ int rk8xx_probe(struct device *dev, int
pre_init_reg[i].addr);
}

View File

@ -0,0 +1,28 @@
From 2a46cd97f401a669d71b3d36b78bd6653f8424ee Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Thu, 19 Oct 2023 18:57:25 +0200
Subject: [PATCH] mfd: rk8xx: Add support for standard system-power-controller
property
DT property rockchip,system-power-controller is now deprecated.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20231019165732.3818789-4-megi@xff.cz
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mfd/rk8xx-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/mfd/rk8xx-core.c
+++ b/drivers/mfd/rk8xx-core.c
@@ -685,7 +685,8 @@ int rk8xx_probe(struct device *dev, int
if (ret)
return dev_err_probe(dev, ret, "failed to add MFD devices\n");
- if (device_property_read_bool(dev, "rockchip,system-power-controller")) {
+ if (device_property_read_bool(dev, "rockchip,system-power-controller") ||
+ device_property_read_bool(dev, "system-power-controller")) {
ret = devm_register_sys_off_handler(dev,
SYS_OFF_MODE_POWER_OFF_PREPARE, SYS_OFF_PRIO_HIGH,
&rk808_power_off, rk808);

View File

@ -0,0 +1,29 @@
From b0227e7081404448a0059b8698fdffd2dec280d2 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Thu, 19 Oct 2023 18:57:26 +0200
Subject: [PATCH] mfd: rk8xx: Add support for RK806 power off
Use DEV_OFF bit to power off the RK806 PMIC, when system-power-controller
is used in DTS.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20231019165732.3818789-5-megi@xff.cz
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mfd/rk8xx-core.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/drivers/mfd/rk8xx-core.c
+++ b/drivers/mfd/rk8xx-core.c
@@ -525,6 +525,10 @@ static int rk808_power_off(struct sys_of
reg = RK805_DEV_CTRL_REG;
bit = DEV_OFF;
break;
+ case RK806_ID:
+ reg = RK806_SYS_CFG3;
+ bit = DEV_OFF;
+ break;
case RK808_ID:
reg = RK808_DEVCTRL_REG,
bit = DEV_OFF_RST;

View File

@ -0,0 +1,164 @@
From 4aedcd4aa61d536ca17e67ecd5bc5d42529164f4 Mon Sep 17 00:00:00 2001
From: Neil Armstrong <neil.armstrong@linaro.org>
Date: Thu, 16 Nov 2023 15:05:13 +0100
Subject: [PATCH] mfd: rk8xx: fixup devices registration with
PLATFORM_DEVID_AUTO
Since commit 210f418f8ace ("mfd: rk8xx: Add rk806 support"), devices are
registered with "0" as id, causing devices to not have an automatic device id
and prevents having multiple RK8xx PMICs on the same system.
Properly pass PLATFORM_DEVID_AUTO to devm_mfd_add_devices() and since
it will ignore the cells .id with this special value, also cleanup
by removing all now ignored cells .id values.
Now we have the same behaviour as before rk806 introduction and rk806
retains the intended behavior.
This fixes a regression while booting the Odroid Go Ultra on v6.6.1:
sysfs: cannot create duplicate filename '/bus/platform/devices/rk808-clkout'
CPU: 3 PID: 97 Comm: kworker/u12:2 Not tainted 6.6.1 #1
Hardware name: Hardkernel ODROID-GO-Ultra (DT)
Workqueue: events_unbound deferred_probe_work_func
Call trace:
dump_backtrace+0x9c/0x11c
show_stack+0x18/0x24
dump_stack_lvl+0x78/0xc4
dump_stack+0x18/0x24
sysfs_warn_dup+0x64/0x80
sysfs_do_create_link_sd+0xf0/0xf8
sysfs_create_link+0x20/0x40
bus_add_device+0x114/0x160
device_add+0x3f0/0x7cc
platform_device_add+0x180/0x270
mfd_add_device+0x390/0x4a8
devm_mfd_add_devices+0xb0/0x150
rk8xx_probe+0x26c/0x410
rk8xx_i2c_probe+0x64/0x98
i2c_device_probe+0x104/0x2e8
really_probe+0x184/0x3c8
__driver_probe_device+0x7c/0x16c
driver_probe_device+0x3c/0x10c
__device_attach_driver+0xbc/0x158
bus_for_each_drv+0x80/0xdc
__device_attach+0x9c/0x1ac
device_initial_probe+0x14/0x20
bus_probe_device+0xac/0xb0
deferred_probe_work_func+0xa0/0xf4
process_one_work+0x1bc/0x378
worker_thread+0x1dc/0x3d4
kthread+0x104/0x118
ret_from_fork+0x10/0x20
rk8xx-i2c 0-001c: error -EEXIST: failed to add MFD devices
rk8xx-i2c: probe of 0-001c failed with error -17
Fixes: 210f418f8ace ("mfd: rk8xx: Add rk806 support")
Reported-by: Adam Green <greena88@gmail.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20231116-topic-amlogic-upstream-fix-rk8xx-devid-auto-v2-1-3f1bad68ab9d@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mfd/rk8xx-core.c | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
--- a/drivers/mfd/rk8xx-core.c
+++ b/drivers/mfd/rk8xx-core.c
@@ -53,76 +53,68 @@ static const struct resource rk817_charg
};
static const struct mfd_cell rk805s[] = {
- { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
- { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
- { .name = "rk805-pinctrl", .id = PLATFORM_DEVID_NONE, },
+ { .name = "rk808-clkout", },
+ { .name = "rk808-regulator", },
+ { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = &rtc_resources[0],
- .id = PLATFORM_DEVID_NONE,
},
{ .name = "rk805-pwrkey",
.num_resources = ARRAY_SIZE(rk805_key_resources),
.resources = &rk805_key_resources[0],
- .id = PLATFORM_DEVID_NONE,
},
};
static const struct mfd_cell rk806s[] = {
- { .name = "rk805-pinctrl", .id = PLATFORM_DEVID_AUTO, },
- { .name = "rk808-regulator", .id = PLATFORM_DEVID_AUTO, },
+ { .name = "rk805-pinctrl", },
+ { .name = "rk808-regulator", },
{
.name = "rk805-pwrkey",
.resources = rk806_pwrkey_resources,
.num_resources = ARRAY_SIZE(rk806_pwrkey_resources),
- .id = PLATFORM_DEVID_AUTO,
},
};
static const struct mfd_cell rk808s[] = {
- { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
- { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
+ { .name = "rk808-clkout", },
+ { .name = "rk808-regulator", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = rtc_resources,
- .id = PLATFORM_DEVID_NONE,
},
};
static const struct mfd_cell rk817s[] = {
- { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
- { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
+ { .name = "rk808-clkout", },
+ { .name = "rk808-regulator", },
{
.name = "rk805-pwrkey",
.num_resources = ARRAY_SIZE(rk817_pwrkey_resources),
.resources = &rk817_pwrkey_resources[0],
- .id = PLATFORM_DEVID_NONE,
},
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rk817_rtc_resources),
.resources = &rk817_rtc_resources[0],
- .id = PLATFORM_DEVID_NONE,
},
- { .name = "rk817-codec", .id = PLATFORM_DEVID_NONE, },
+ { .name = "rk817-codec", },
{
.name = "rk817-charger",
.num_resources = ARRAY_SIZE(rk817_charger_resources),
.resources = &rk817_charger_resources[0],
- .id = PLATFORM_DEVID_NONE,
},
};
static const struct mfd_cell rk818s[] = {
- { .name = "rk808-clkout", .id = PLATFORM_DEVID_NONE, },
- { .name = "rk808-regulator", .id = PLATFORM_DEVID_NONE, },
+ { .name = "rk808-clkout", },
+ { .name = "rk808-regulator", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = rtc_resources,
- .id = PLATFORM_DEVID_NONE,
},
};
@@ -684,7 +676,7 @@ int rk8xx_probe(struct device *dev, int
pre_init_reg[i].addr);
}
- ret = devm_mfd_add_devices(dev, 0, cells, nr_cells, NULL, 0,
+ ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cells, nr_cells, NULL, 0,
regmap_irq_get_domain(rk808->irq_data));
if (ret)
return dev_err_probe(dev, ret, "failed to add MFD devices\n");