* [PATCH v4 0/3] spacemit: fix P1 sub-device Kconfig defaults and dependencies
From: Troy Mitchell @ 2025-12-25 7:46 UTC (permalink / raw)
To: Lee Jones, Yixun Lan, Alex Elder, Andi Shyti, Alexandre Belloni,
Liam Girdwood, Mark Brown
Cc: linux-kernel, linux-riscv, spacemit, linux-i2c, linux-rtc,
Troy Mitchell
This series fixes Kconfig default value and dependency handling for
the SpacemiT P1 PMIC and its sub-devices.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
Troy Mitchell (3):
regulator: spacemit: MFD_SPACEMIT_P1 as dependencies
mfd: simple-mfd-i2c: add default value
rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
drivers/mfd/Kconfig | 1 +
drivers/regulator/Kconfig | 5 ++---
drivers/rtc/Kconfig | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
---
base-commit: b87881a3c93345252ce8559ad763369febfdb75d
change-id: 20251021-p1-kconfig-fix-6d2b59d03b8f
Best regards,
--
Troy Mitchell <troy.mitchell@linux.spacemit.com>
^ permalink raw reply
* RE: [PATCH 1/4] dt-bindings: rtc: ds1307: Add epson,rx8901
From: nobuhiro.iwamatsu.x90 @ 2025-12-24 5:04 UTC (permalink / raw)
To: fredrik.m.olsson, alexandre.belloni, robh, krzk+dt, conor+dt
Cc: linux-rtc, devicetree, linux-kernel, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-1-b13f346ebe93@axis.com>
Hi Fredrik,
> -----Original Message-----
> From: Fredrik M Olsson <fredrik.m.olsson@axis.com>
> Sent: Friday, December 19, 2025 9:11 PM
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Rob Herring
> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro.iwamatsu.x90@mail.toshiba>
> Cc: linux-rtc@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; Fredrik M Olsson <fredrik.m.olsson@axis.com>;
> kernel@axis.com
> Subject: [PATCH 1/4] dt-bindings: rtc: ds1307: Add epson,rx8901
>
> Add compatible string epson,rx8901 for the Epson RX8901CE RTC.
>
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@mail.toshiba>
Best regards,
Nobuhiro
> ---
> Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
> b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
> index 98d10e680144..9b2796804f07 100644
> --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
> +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
> @@ -31,6 +31,7 @@ properties:
> - epson,rx8025
> - isil,isl12057
> - epson,rx8130
> + - epson,rx8901
>
> - items:
> - enum:
>
> --
> 2.43.0
^ permalink raw reply
* RE: [PATCH 2/4] rtc: ds1307: Fix off-by-one issue with wday for rx8130
From: nobuhiro.iwamatsu.x90 @ 2025-12-24 5:06 UTC (permalink / raw)
To: fredrik.m.olsson, alexandre.belloni, robh, krzk+dt, conor+dt
Cc: linux-rtc, devicetree, linux-kernel, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-2-b13f346ebe93@axis.com>
Hi Fredrik,
> -----Original Message-----
> From: Fredrik M Olsson <fredrik.m.olsson@axis.com>
> Sent: Friday, December 19, 2025 9:11 PM
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Rob Herring
> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro.iwamatsu.x90@mail.toshiba>
> Cc: linux-rtc@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; Fredrik M Olsson <fredrik.m.olsson@axis.com>;
> kernel@axis.com
> Subject: [PATCH 2/4] rtc: ds1307: Fix off-by-one issue with wday for rx8130
>
> The RTC represent each weekday with a individual bit set in the WDAY register,
> where the 0th bit represent the first day of the week and the 6th bit represents
> the last day of the week. For each passed day the chip performs a
> rotary-left-shift by one to advance the weekday by one.
>
> The tm_wday field represent weekdays by a value in the range of 0-6.
>
> The fls() function return the bit index of the last bit set. To handle when there
> are no bits set it will return 0, and if the 0th bit is set it will return 1, and if the
> 1st bit is set it will return 2, and so on.
>
> In order to make the result of the fls() function fall into the expected range of
> 0-6 (instead of 1-7) this patch subtracts one from the result (which matches
> how the value is written in ds1307_set_time()).
>
> Fixes: 204756f016726 ("rtc: ds1307: Fix wday settings for rx8130")
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
Thanks for fixing.
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>
Best regards,
Nobuhiro
> ---
> drivers/rtc/rtc-ds1307.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index
> 7205c59ff729..bf42c250ea7d 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -308,7 +308,7 @@ static int ds1307_get_time(struct device *dev, struct
> rtc_time *t)
> t->tm_hour = bcd2bin(tmp);
> /* rx8130 is bit position, not BCD */
> if (ds1307->type == rx_8130)
> - t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f);
> + t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f) - 1;
> else
> t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1;
> t->tm_mday = bcd2bin(regs[DS1307_REG_MDAY] & 0x3f);
>
> --
> 2.43.0
^ permalink raw reply
* RE: [PATCH 4/4] rtc: ds1307: Add support for reading RX8901CE battery VL status
From: nobuhiro.iwamatsu.x90 @ 2025-12-24 5:07 UTC (permalink / raw)
To: fredrik.m.olsson, alexandre.belloni, robh, krzk+dt, conor+dt
Cc: linux-rtc, devicetree, linux-kernel, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-4-b13f346ebe93@axis.com>
Hi Fredrik,
> -----Original Message-----
> From: Fredrik M Olsson <fredrik.m.olsson@axis.com>
> Sent: Friday, December 19, 2025 9:11 PM
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Rob Herring
> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro.iwamatsu.x90@mail.toshiba>
> Cc: linux-rtc@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; Fredrik M Olsson <fredrik.m.olsson@axis.com>;
> kernel@axis.com
> Subject: [PATCH 4/4] rtc: ds1307: Add support for reading RX8901CE battery
> VL status
>
> Adds support for:
> - Reading the battery voltage low status using the RTC_VL_READ ioctl,
> which also reports invalid time information if the VLF flag is set.
>
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>
Best regards,
Nobuhiro
> ---
> drivers/rtc/rtc-ds1307.c | 46
> +++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index
> 99d95e520108..ca062ed0c867 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -133,8 +133,11 @@ enum ds_type {
> #define RX8901_REG_INTF 0x0e
> #define RX8901_REG_INTF_VLF BIT(1)
> #define RX8901_REG_PWSW_CFG 0x37
> +#define RX8901_REG_PWSW_CFG_VBATLDETEN BIT(4)
> #define RX8901_REG_PWSW_CFG_INIEN BIT(6)
> #define RX8901_REG_PWSW_CFG_CHGEN BIT(7)
> +#define RX8901_REG_BUF_INTF 0x46
> +#define RX8901_REG_BUF_INTF_VBATLF BIT(3)
>
> #define MCP794XX_REG_CONTROL 0x07
> # define MCP794XX_BIT_ALM0_EN 0x10
> @@ -458,6 +461,39 @@ static int ds1307_set_time(struct device *dev, struct
> rtc_time *t)
> return 0;
> }
>
> +#ifdef CONFIG_RTC_INTF_DEV
> +static int rx8901_ioctl(struct device *dev, unsigned int cmd, unsigned
> +long arg) {
> + struct ds1307 *ds1307 = dev_get_drvdata(dev);
> + unsigned int regflag, tmp = 0;
> + int ret = 0;
> +
> + switch (cmd) {
> + case RTC_VL_READ:
> + ret = regmap_read(ds1307->regmap, RX8901_REG_INTF,
> ®flag);
> + if (ret)
> + return ret;
> +
> + if (regflag & RX8901_REG_INTF_VLF)
> + tmp |= RTC_VL_DATA_INVALID;
> +
> + ret = regmap_read(ds1307->regmap, RX8901_REG_BUF_INTF,
> ®flag);
> + if (ret)
> + return ret;
> +
> + if (regflag & RX8901_REG_BUF_INTF_VBATLF)
> + tmp |= RTC_VL_BACKUP_LOW;
> +
> + return put_user(tmp, (unsigned int __user *)arg);
> + default:
> + return -ENOIOCTLCMD;
> + }
> + return ret;
> +}
> +#else
> +#define rx8901_ioctl NULL
> +#endif
> +
> static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t) {
> struct ds1307 *ds1307 = dev_get_drvdata(dev);
> @@ -599,10 +635,13 @@ static u8 do_trickle_setup_rx8130(struct ds1307
> *ds1307, u32 ohms, bool diode)
> return setup;
> }
>
> -static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms, bool
> diode)
> +static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms
> +__always_unused, bool diode)
> {
> - /* make sure that the backup battery is enabled */
> - u8 setup = RX8901_REG_PWSW_CFG_INIEN;
> + /*
> + * make sure that the backup battery is enabled and that battery
> + * voltage detection is performed
> + */
> + u8 setup = RX8901_REG_PWSW_CFG_INIEN |
> RX8901_REG_PWSW_CFG_VBATLDETEN;
>
> if (diode)
> setup |= RX8901_REG_PWSW_CFG_CHGEN;
> @@ -1005,6 +1044,7 @@ static const struct rtc_class_ops rx8130_rtc_ops =
> { static const struct rtc_class_ops rx8901_rtc_ops = {
> .read_time = ds1307_get_time,
> .set_time = ds1307_set_time,
> + .ioctl = rx8901_ioctl,
> };
>
> static const struct rtc_class_ops mcp794xx_rtc_ops = {
>
> --
> 2.43.0
^ permalink raw reply
* RE: [PATCH 3/4] rtc: ds1307: Add Driver for Epson RX8901CE
From: nobuhiro.iwamatsu.x90 @ 2025-12-24 5:05 UTC (permalink / raw)
To: fredrik.m.olsson, alexandre.belloni, robh, krzk+dt, conor+dt
Cc: linux-rtc, devicetree, linux-kernel, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-3-b13f346ebe93@axis.com>
Hi Fredrik,
> -----Original Message-----
> From: Fredrik M Olsson <fredrik.m.olsson@axis.com>
> Sent: Friday, December 19, 2025 9:11 PM
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Rob Herring
> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro.iwamatsu.x90@mail.toshiba>
> Cc: linux-rtc@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; Fredrik M Olsson <fredrik.m.olsson@axis.com>;
> kernel@axis.com
> Subject: [PATCH 3/4] rtc: ds1307: Add Driver for Epson RX8901CE
>
> Adds Support for:
> - Reading and writing time to/from the RTC.
> - Switching to backup battery supply when primary supply disappears.
> - Optionally enabling battery charging.
>
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>
Best regards,
Nobuhiro
> ---
> drivers/rtc/rtc-ds1307.c | 62
> ++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 60 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index
> bf42c250ea7d..99d95e520108 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -48,6 +48,7 @@ enum ds_type {
> mcp794xx,
> rx_8025,
> rx_8130,
> + rx_8901,
> last_ds_type /* always last */
> /* rs5c372 too? different address... */ }; @@ -129,6 +130,12 @@
> enum ds_type {
> #define RX8130_REG_CONTROL1_INIEN BIT(4)
> #define RX8130_REG_CONTROL1_CHGEN BIT(5)
>
> +#define RX8901_REG_INTF 0x0e
> +#define RX8901_REG_INTF_VLF BIT(1)
> +#define RX8901_REG_PWSW_CFG 0x37
> +#define RX8901_REG_PWSW_CFG_INIEN BIT(6)
> +#define RX8901_REG_PWSW_CFG_CHGEN BIT(7)
> +
> #define MCP794XX_REG_CONTROL 0x07
> # define MCP794XX_BIT_ALM0_EN 0x10
> # define MCP794XX_BIT_ALM1_EN 0x20
> @@ -226,6 +233,19 @@ static int ds1307_get_time(struct device *dev, struct
> rtc_time *t)
> dev_warn_once(dev, "oscillator failed, set time!\n");
> return -EINVAL;
> }
> + } else if (ds1307->type == rx_8901) {
> + unsigned int regflag;
> +
> + ret = regmap_read(ds1307->regmap, RX8901_REG_INTF,
> ®flag);
> + if (ret) {
> + dev_err(dev, "%s error %d\n", "read", ret);
> + return ret;
> + }
> +
> + if (regflag & RX8901_REG_INTF_VLF) {
> + dev_warn_once(dev, "oscillator failed, set time!\n");
> + return -EINVAL;
> + }
> }
>
> /* read the RTC date and time registers all at once */ @@ -307,7
> +327,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
> tmp = regs[DS1307_REG_HOUR] & 0x3f;
> t->tm_hour = bcd2bin(tmp);
> /* rx8130 is bit position, not BCD */
> - if (ds1307->type == rx_8130)
> + if (ds1307->type == rx_8130 || ds1307->type == rx_8901)
> t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f) - 1;
> else
> t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1;
> @@ -358,7 +378,7 @@ static int ds1307_set_time(struct device *dev, struct
> rtc_time *t)
> regs[DS1307_REG_MIN] = bin2bcd(t->tm_min);
> regs[DS1307_REG_HOUR] = bin2bcd(t->tm_hour);
> /* rx8130 is bit position, not BCD */
> - if (ds1307->type == rx_8130)
> + if (ds1307->type == rx_8130 || ds1307->type == rx_8901)
> regs[DS1307_REG_WDAY] = 1 << t->tm_wday;
> else
> regs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1); @@
> -422,6 +442,17 @@ static int ds1307_set_time(struct device *dev, struct
> rtc_time *t)
> dev_err(dev, "%s error %d\n", "write", result);
> return result;
> }
> + } else if (ds1307->type == rx_8901) {
> + /*
> + * clear Voltage Loss Flag as data is available now (writing 1
> + * to the other bits in the INTF register has no effect)
> + */
> + result = regmap_write(ds1307->regmap, RX8901_REG_INTF,
> + 0xff ^ RX8901_REG_INTF_VLF);
> + if (result) {
> + dev_err(dev, "%s error %d\n", "write", result);
> + return result;
> + }
> }
>
> return 0;
> @@ -568,6 +599,17 @@ static u8 do_trickle_setup_rx8130(struct ds1307
> *ds1307, u32 ohms, bool diode)
> return setup;
> }
>
> +static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms, bool
> +diode) {
> + /* make sure that the backup battery is enabled */
> + u8 setup = RX8901_REG_PWSW_CFG_INIEN;
> +
> + if (diode)
> + setup |= RX8901_REG_PWSW_CFG_CHGEN;
> +
> + return setup;
> +}
> +
> static irqreturn_t rx8130_irq(int irq, void *dev_id) {
> struct ds1307 *ds1307 = dev_id;
> @@ -960,6 +1002,11 @@ static const struct rtc_class_ops rx8130_rtc_ops = {
> .alarm_irq_enable = rx8130_alarm_irq_enable, };
>
> +static const struct rtc_class_ops rx8901_rtc_ops = {
> + .read_time = ds1307_get_time,
> + .set_time = ds1307_set_time,
> +};
> +
> static const struct rtc_class_ops mcp794xx_rtc_ops = {
> .read_time = ds1307_get_time,
> .set_time = ds1307_set_time,
> @@ -1040,6 +1087,12 @@ static const struct chip_desc chips[last_ds_type] = {
> .trickle_charger_reg = RX8130_REG_CONTROL1,
> .do_trickle_setup = &do_trickle_setup_rx8130,
> },
> + [rx_8901] = {
> + .offset = 0x0,
> + .rtc_ops = &rx8901_rtc_ops,
> + .trickle_charger_reg = RX8901_REG_PWSW_CFG,
> + .do_trickle_setup = &do_trickle_setup_rx8901,
> + },
> [m41t0] = {
> .rtc_ops = &m41txx_rtc_ops,
> },
> @@ -1081,6 +1134,7 @@ static const struct i2c_device_id ds1307_id[] = {
> { "rx8025", rx_8025 },
> { "isl12057", ds_1337 },
> { "rx8130", rx_8130 },
> + { "rx8901", rx_8901 },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, ds1307_id);
> @@ -1158,6 +1212,10 @@ static const struct of_device_id ds1307_of_match[]
> = {
> .compatible = "epson,rx8130",
> .data = (void *)rx_8130
> },
> + {
> + .compatible = "epson,rx8901",
> + .data = (void *)rx_8901
> + },
> { }
> };
> MODULE_DEVICE_TABLE(of, ds1307_of_match);
>
> --
> 2.43.0
^ permalink raw reply
* [PATCH] rtc: s35390a: implement nvmem support
From: Lorenz Brun @ 2025-12-23 12:57 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
This RTC has one "free" register which can be used to store arbitrary
data. Expose it as a nvmem resource in Linux.
Signed-off-by: Lorenz Brun <lorenz@monogon.tech>
---
drivers/rtc/rtc-s35390a.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 3408d2ab2741..2ed39d1c8142 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -18,6 +18,7 @@
#define S35390A_CMD_TIME1 2
#define S35390A_CMD_TIME2 3
#define S35390A_CMD_INT2_REG1 5
+#define S35390A_CMD_FREE_REG 7
#define S35390A_BYTE_YEAR 0
#define S35390A_BYTE_MONTH 1
@@ -416,6 +417,23 @@ static const struct rtc_class_ops s35390a_rtc_ops = {
.ioctl = s35390a_rtc_ioctl,
};
+static int s35390a_nvmem_read(void *priv, unsigned int offset, void *val,
+ size_t bytes)
+{
+ struct s35390a *s35390a = priv;
+
+ /* The offset is ignored because the NVMEM region is only 1 byte */
+ return s35390a_get_reg(s35390a, S35390A_CMD_FREE_REG, val, bytes);
+}
+
+static int s35390a_nvmem_write(void *priv, unsigned int offset, void *val,
+ size_t bytes)
+{
+ struct s35390a *s35390a = priv;
+
+ return s35390a_set_reg(s35390a, S35390A_CMD_FREE_REG, val, bytes);
+}
+
static int s35390a_probe(struct i2c_client *client)
{
int err, err_read;
@@ -424,6 +442,15 @@ static int s35390a_probe(struct i2c_client *client)
struct rtc_device *rtc;
char buf, status1;
struct device *dev = &client->dev;
+ struct nvmem_config nvmem_cfg = {
+ .name = "s35390a_nvram",
+ .type = NVMEM_TYPE_BATTERY_BACKED,
+ .word_size = 1,
+ .stride = 1,
+ .size = 1,
+ .reg_read = s35390a_nvmem_read,
+ .reg_write = s35390a_nvmem_write,
+ };
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
@@ -490,6 +517,11 @@ static int s35390a_probe(struct i2c_client *client)
if (status1 & S35390A_FLAG_INT2)
rtc_update_irq(rtc, 1, RTC_AF);
+ nvmem_cfg.priv = s35390a;
+ err = devm_rtc_nvmem_register(rtc, &nvmem_cfg);
+ if (err)
+ return err;
+
return devm_rtc_register_device(rtc);
}
--
2.49.0
^ permalink raw reply related
* Re: [PATCH v1 2/2] rtc: loongson: Add Loongson-2K0300 support
From: Huacai Chen @ 2025-12-23 9:09 UTC (permalink / raw)
To: Binbin Zhou
Cc: Binbin Zhou, Huacai Chen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, linux-rtc, Xiaochuang Mao,
Xuerui Wang, loongarch, devicetree, linux-mips, Keguang Zhang
In-Reply-To: <CAMpQs4LMkq6BpsrnS+e+cvh2hJshO4=41vX4ETq+tkJEMZ7zdA@mail.gmail.com>
On Tue, Dec 23, 2025 at 5:06 PM Binbin Zhou <zhoubb.aaron@gmail.com> wrote:
>
> Hi:
>
>
> On Tue, Dec 23, 2025 at 4:40 PM Huacai Chen <chenhuacai@kernel.org> wrote:
> >
> > Hi, Binbin,
> >
> > On Tue, Dec 23, 2025 at 2:42 PM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
> > >
> > > The Loongson-2K0300's rtc hardware design is similar to that of the
> > > Loongson-1B, but it does not support the alarm feature.
> > >
> > > Introduce `LOONGSON_RTC_ALARM_WORKAROUND`, which indicates a chip that
> > > does not support the alarm function, and rewritethe related logic in
> > > `loongson_rtc_alarm_setting()`
> > >
> > > Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> > > ---
> > > drivers/rtc/rtc-loongson.c | 65 ++++++++++++++++++++++++++------------
> > > 1 file changed, 44 insertions(+), 21 deletions(-)
> > >
> > > diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c
> > > index 2ca7ffd5d7a9..6b076bd4e24e 100644
> > > --- a/drivers/rtc/rtc-loongson.c
> > > +++ b/drivers/rtc/rtc-loongson.c
> > > @@ -67,6 +67,7 @@
> > > * Accessing the relevant registers will cause the system to hang.
> > > */
> > > #define LS1C_RTC_CTRL_WORKAROUND BIT(0)
> > > +#define LOONGSON_RTC_ALARM_WORKAROUND BIT(1)
> > Can we reuse existing logic, which means "alarm_irq =
> > platform_get_irq(pdev, 0)" return 0 for LS2K0300?
>
> First of all, as I understand it, platform_get_irq() doesn't normally
> return 0 unless interrupt 0 is configured in the DTS, which doesn't
> seem appropriate.
>
> Also, the return value of platform_get_irq() was previously used to
> determine if the alarm feature was supported, which is not
> particularly accurate. It should be an inherent feature of the chip,
> and I think it would be more appropriate to define it in
> loongson_rtc_config.
OK, then I think it is better to rename LS1C_RTC_CTRL_WORKAROUND to
LOONGSON_RTC_CTRL_WORKAROUND for consistency.
Huacai
> >
> > Huacai
> >
> > >
> > > struct loongson_rtc_config {
> > > u32 pm_offset; /* Offset of PM domain, for RTC alarm wakeup */
> > > @@ -89,7 +90,7 @@ static const struct loongson_rtc_config ls1b_rtc_config = {
> > >
> > > static const struct loongson_rtc_config ls1c_rtc_config = {
> > > .pm_offset = 0,
> > > - .flags = LS1C_RTC_CTRL_WORKAROUND,
> > > + .flags = LS1C_RTC_CTRL_WORKAROUND | LOONGSON_RTC_ALARM_WORKAROUND,
> > > };
> > >
> > > static const struct loongson_rtc_config generic_rtc_config = {
> > > @@ -97,6 +98,11 @@ static const struct loongson_rtc_config generic_rtc_config = {
> > > .flags = 0,
> > > };
> > >
> > > +static const struct loongson_rtc_config ls2k0300_rtc_config = {
> > > + .pm_offset = 0x0,
> > > + .flags = LOONGSON_RTC_ALARM_WORKAROUND,
> > > +};
> > > +
> > > static const struct loongson_rtc_config ls2k1000_rtc_config = {
> > > .pm_offset = 0x800,
> > > .flags = 0,
> > > @@ -299,9 +305,41 @@ static const struct rtc_class_ops loongson_rtc_ops = {
> > > .alarm_irq_enable = loongson_rtc_alarm_irq_enable,
> > > };
> > >
> > > +static int loongson_rtc_alarm_setting(struct platform_device *pdev, void __iomem *regs)
> > > +{
> > > + int ret = 0, alarm_irq;
> > > + struct device *dev = &pdev->dev;
> > > + struct loongson_rtc_priv *priv = dev_get_drvdata(dev);
> > > +
> > > + if (priv->config->flags & LOONGSON_RTC_ALARM_WORKAROUND) {
> > > + /* Loongson-1C/Loongson-2K0300 RTC does not support alarm */
> > > + clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
> > > + return 0;
> > > + }
> > > +
> > > + /* Get RTC alarm irq */
> > > + alarm_irq = platform_get_irq(pdev, 0);
> > > + if (alarm_irq < 0)
> > > + return alarm_irq;
> > > +
> > > + ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr, 0, "loongson-alarm",
> > > + priv);
> > > + if (ret < 0)
> > > + return ret;
> > > +
> > > + priv->pm_base = regs - priv->config->pm_offset;
> > > + device_init_wakeup(dev, true);
> > > +
> > > + if (has_acpi_companion(dev))
> > > + acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
> > > + loongson_rtc_handler, priv);
> > > +
> > > + return ret;
> > > +}
> > > +
> > > static int loongson_rtc_probe(struct platform_device *pdev)
> > > {
> > > - int ret, alarm_irq;
> > > + int ret;
> > > void __iomem *regs;
> > > struct loongson_rtc_priv *priv;
> > > struct device *dev = &pdev->dev;
> > > @@ -330,25 +368,9 @@ static int loongson_rtc_probe(struct platform_device *pdev)
> > > return dev_err_probe(dev, PTR_ERR(priv->rtcdev),
> > > "devm_rtc_allocate_device failed\n");
> > >
> > > - /* Get RTC alarm irq */
> > > - alarm_irq = platform_get_irq(pdev, 0);
> > > - if (alarm_irq > 0) {
> > > - ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr,
> > > - 0, "loongson-alarm", priv);
> > > - if (ret < 0)
> > > - return dev_err_probe(dev, ret, "Unable to request irq %d\n",
> > > - alarm_irq);
> > > -
> > > - priv->pm_base = regs - priv->config->pm_offset;
> > > - device_init_wakeup(dev, true);
> > > -
> > > - if (has_acpi_companion(dev))
> > > - acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
> > > - loongson_rtc_handler, priv);
> > > - } else {
> > > - /* Loongson-1C RTC does not support alarm */
> > > - clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
> > > - }
> > > + ret = loongson_rtc_alarm_setting(pdev, regs);
> > > + if (ret)
> > > + return ret;
> > >
> > > /* Loongson RTC does not support UIE */
> > > clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, priv->rtcdev->features);
> > > @@ -379,6 +401,7 @@ static const struct of_device_id loongson_rtc_of_match[] = {
> > > { .compatible = "loongson,ls1b-rtc", .data = &ls1b_rtc_config },
> > > { .compatible = "loongson,ls1c-rtc", .data = &ls1c_rtc_config },
> > > { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config },
> > > + { .compatible = "loongson,ls2k0300-rtc", .data = &ls2k0300_rtc_config },
> > > { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config },
> > > { /* sentinel */ }
> > > };
> > > --
> > > 2.47.3
> > >
> > >
>
> --
> Thanks.
> Binbin
^ permalink raw reply
* Re: [PATCH v1 2/2] rtc: loongson: Add Loongson-2K0300 support
From: Binbin Zhou @ 2025-12-23 9:06 UTC (permalink / raw)
To: Huacai Chen
Cc: Binbin Zhou, Huacai Chen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, linux-rtc, Xiaochuang Mao,
Xuerui Wang, loongarch, devicetree, linux-mips, Keguang Zhang
In-Reply-To: <CAAhV-H5WfEhsV4fEzThR-C95cg0nPpJ+OfQ10NXEsFKneJQQ5A@mail.gmail.com>
Hi:
On Tue, Dec 23, 2025 at 4:40 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Binbin,
>
> On Tue, Dec 23, 2025 at 2:42 PM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
> >
> > The Loongson-2K0300's rtc hardware design is similar to that of the
> > Loongson-1B, but it does not support the alarm feature.
> >
> > Introduce `LOONGSON_RTC_ALARM_WORKAROUND`, which indicates a chip that
> > does not support the alarm function, and rewritethe related logic in
> > `loongson_rtc_alarm_setting()`
> >
> > Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> > ---
> > drivers/rtc/rtc-loongson.c | 65 ++++++++++++++++++++++++++------------
> > 1 file changed, 44 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c
> > index 2ca7ffd5d7a9..6b076bd4e24e 100644
> > --- a/drivers/rtc/rtc-loongson.c
> > +++ b/drivers/rtc/rtc-loongson.c
> > @@ -67,6 +67,7 @@
> > * Accessing the relevant registers will cause the system to hang.
> > */
> > #define LS1C_RTC_CTRL_WORKAROUND BIT(0)
> > +#define LOONGSON_RTC_ALARM_WORKAROUND BIT(1)
> Can we reuse existing logic, which means "alarm_irq =
> platform_get_irq(pdev, 0)" return 0 for LS2K0300?
First of all, as I understand it, platform_get_irq() doesn't normally
return 0 unless interrupt 0 is configured in the DTS, which doesn't
seem appropriate.
Also, the return value of platform_get_irq() was previously used to
determine if the alarm feature was supported, which is not
particularly accurate. It should be an inherent feature of the chip,
and I think it would be more appropriate to define it in
loongson_rtc_config.
>
> Huacai
>
> >
> > struct loongson_rtc_config {
> > u32 pm_offset; /* Offset of PM domain, for RTC alarm wakeup */
> > @@ -89,7 +90,7 @@ static const struct loongson_rtc_config ls1b_rtc_config = {
> >
> > static const struct loongson_rtc_config ls1c_rtc_config = {
> > .pm_offset = 0,
> > - .flags = LS1C_RTC_CTRL_WORKAROUND,
> > + .flags = LS1C_RTC_CTRL_WORKAROUND | LOONGSON_RTC_ALARM_WORKAROUND,
> > };
> >
> > static const struct loongson_rtc_config generic_rtc_config = {
> > @@ -97,6 +98,11 @@ static const struct loongson_rtc_config generic_rtc_config = {
> > .flags = 0,
> > };
> >
> > +static const struct loongson_rtc_config ls2k0300_rtc_config = {
> > + .pm_offset = 0x0,
> > + .flags = LOONGSON_RTC_ALARM_WORKAROUND,
> > +};
> > +
> > static const struct loongson_rtc_config ls2k1000_rtc_config = {
> > .pm_offset = 0x800,
> > .flags = 0,
> > @@ -299,9 +305,41 @@ static const struct rtc_class_ops loongson_rtc_ops = {
> > .alarm_irq_enable = loongson_rtc_alarm_irq_enable,
> > };
> >
> > +static int loongson_rtc_alarm_setting(struct platform_device *pdev, void __iomem *regs)
> > +{
> > + int ret = 0, alarm_irq;
> > + struct device *dev = &pdev->dev;
> > + struct loongson_rtc_priv *priv = dev_get_drvdata(dev);
> > +
> > + if (priv->config->flags & LOONGSON_RTC_ALARM_WORKAROUND) {
> > + /* Loongson-1C/Loongson-2K0300 RTC does not support alarm */
> > + clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
> > + return 0;
> > + }
> > +
> > + /* Get RTC alarm irq */
> > + alarm_irq = platform_get_irq(pdev, 0);
> > + if (alarm_irq < 0)
> > + return alarm_irq;
> > +
> > + ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr, 0, "loongson-alarm",
> > + priv);
> > + if (ret < 0)
> > + return ret;
> > +
> > + priv->pm_base = regs - priv->config->pm_offset;
> > + device_init_wakeup(dev, true);
> > +
> > + if (has_acpi_companion(dev))
> > + acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
> > + loongson_rtc_handler, priv);
> > +
> > + return ret;
> > +}
> > +
> > static int loongson_rtc_probe(struct platform_device *pdev)
> > {
> > - int ret, alarm_irq;
> > + int ret;
> > void __iomem *regs;
> > struct loongson_rtc_priv *priv;
> > struct device *dev = &pdev->dev;
> > @@ -330,25 +368,9 @@ static int loongson_rtc_probe(struct platform_device *pdev)
> > return dev_err_probe(dev, PTR_ERR(priv->rtcdev),
> > "devm_rtc_allocate_device failed\n");
> >
> > - /* Get RTC alarm irq */
> > - alarm_irq = platform_get_irq(pdev, 0);
> > - if (alarm_irq > 0) {
> > - ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr,
> > - 0, "loongson-alarm", priv);
> > - if (ret < 0)
> > - return dev_err_probe(dev, ret, "Unable to request irq %d\n",
> > - alarm_irq);
> > -
> > - priv->pm_base = regs - priv->config->pm_offset;
> > - device_init_wakeup(dev, true);
> > -
> > - if (has_acpi_companion(dev))
> > - acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
> > - loongson_rtc_handler, priv);
> > - } else {
> > - /* Loongson-1C RTC does not support alarm */
> > - clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
> > - }
> > + ret = loongson_rtc_alarm_setting(pdev, regs);
> > + if (ret)
> > + return ret;
> >
> > /* Loongson RTC does not support UIE */
> > clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, priv->rtcdev->features);
> > @@ -379,6 +401,7 @@ static const struct of_device_id loongson_rtc_of_match[] = {
> > { .compatible = "loongson,ls1b-rtc", .data = &ls1b_rtc_config },
> > { .compatible = "loongson,ls1c-rtc", .data = &ls1c_rtc_config },
> > { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config },
> > + { .compatible = "loongson,ls2k0300-rtc", .data = &ls2k0300_rtc_config },
> > { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config },
> > { /* sentinel */ }
> > };
> > --
> > 2.47.3
> >
> >
--
Thanks.
Binbin
^ permalink raw reply
* Re: [PATCH v1 2/2] rtc: loongson: Add Loongson-2K0300 support
From: Huacai Chen @ 2025-12-23 8:40 UTC (permalink / raw)
To: Binbin Zhou
Cc: Binbin Zhou, Huacai Chen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, linux-rtc, Xiaochuang Mao,
Xuerui Wang, loongarch, devicetree, linux-mips, Keguang Zhang
In-Reply-To: <6e10c70653b32f1f79e3f98116924e1aad7154bf.1766471839.git.zhoubinbin@loongson.cn>
Hi, Binbin,
On Tue, Dec 23, 2025 at 2:42 PM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
>
> The Loongson-2K0300's rtc hardware design is similar to that of the
> Loongson-1B, but it does not support the alarm feature.
>
> Introduce `LOONGSON_RTC_ALARM_WORKAROUND`, which indicates a chip that
> does not support the alarm function, and rewritethe related logic in
> `loongson_rtc_alarm_setting()`
>
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> ---
> drivers/rtc/rtc-loongson.c | 65 ++++++++++++++++++++++++++------------
> 1 file changed, 44 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c
> index 2ca7ffd5d7a9..6b076bd4e24e 100644
> --- a/drivers/rtc/rtc-loongson.c
> +++ b/drivers/rtc/rtc-loongson.c
> @@ -67,6 +67,7 @@
> * Accessing the relevant registers will cause the system to hang.
> */
> #define LS1C_RTC_CTRL_WORKAROUND BIT(0)
> +#define LOONGSON_RTC_ALARM_WORKAROUND BIT(1)
Can we reuse existing logic, which means "alarm_irq =
platform_get_irq(pdev, 0)" return 0 for LS2K0300?
Huacai
>
> struct loongson_rtc_config {
> u32 pm_offset; /* Offset of PM domain, for RTC alarm wakeup */
> @@ -89,7 +90,7 @@ static const struct loongson_rtc_config ls1b_rtc_config = {
>
> static const struct loongson_rtc_config ls1c_rtc_config = {
> .pm_offset = 0,
> - .flags = LS1C_RTC_CTRL_WORKAROUND,
> + .flags = LS1C_RTC_CTRL_WORKAROUND | LOONGSON_RTC_ALARM_WORKAROUND,
> };
>
> static const struct loongson_rtc_config generic_rtc_config = {
> @@ -97,6 +98,11 @@ static const struct loongson_rtc_config generic_rtc_config = {
> .flags = 0,
> };
>
> +static const struct loongson_rtc_config ls2k0300_rtc_config = {
> + .pm_offset = 0x0,
> + .flags = LOONGSON_RTC_ALARM_WORKAROUND,
> +};
> +
> static const struct loongson_rtc_config ls2k1000_rtc_config = {
> .pm_offset = 0x800,
> .flags = 0,
> @@ -299,9 +305,41 @@ static const struct rtc_class_ops loongson_rtc_ops = {
> .alarm_irq_enable = loongson_rtc_alarm_irq_enable,
> };
>
> +static int loongson_rtc_alarm_setting(struct platform_device *pdev, void __iomem *regs)
> +{
> + int ret = 0, alarm_irq;
> + struct device *dev = &pdev->dev;
> + struct loongson_rtc_priv *priv = dev_get_drvdata(dev);
> +
> + if (priv->config->flags & LOONGSON_RTC_ALARM_WORKAROUND) {
> + /* Loongson-1C/Loongson-2K0300 RTC does not support alarm */
> + clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
> + return 0;
> + }
> +
> + /* Get RTC alarm irq */
> + alarm_irq = platform_get_irq(pdev, 0);
> + if (alarm_irq < 0)
> + return alarm_irq;
> +
> + ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr, 0, "loongson-alarm",
> + priv);
> + if (ret < 0)
> + return ret;
> +
> + priv->pm_base = regs - priv->config->pm_offset;
> + device_init_wakeup(dev, true);
> +
> + if (has_acpi_companion(dev))
> + acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
> + loongson_rtc_handler, priv);
> +
> + return ret;
> +}
> +
> static int loongson_rtc_probe(struct platform_device *pdev)
> {
> - int ret, alarm_irq;
> + int ret;
> void __iomem *regs;
> struct loongson_rtc_priv *priv;
> struct device *dev = &pdev->dev;
> @@ -330,25 +368,9 @@ static int loongson_rtc_probe(struct platform_device *pdev)
> return dev_err_probe(dev, PTR_ERR(priv->rtcdev),
> "devm_rtc_allocate_device failed\n");
>
> - /* Get RTC alarm irq */
> - alarm_irq = platform_get_irq(pdev, 0);
> - if (alarm_irq > 0) {
> - ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr,
> - 0, "loongson-alarm", priv);
> - if (ret < 0)
> - return dev_err_probe(dev, ret, "Unable to request irq %d\n",
> - alarm_irq);
> -
> - priv->pm_base = regs - priv->config->pm_offset;
> - device_init_wakeup(dev, true);
> -
> - if (has_acpi_companion(dev))
> - acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
> - loongson_rtc_handler, priv);
> - } else {
> - /* Loongson-1C RTC does not support alarm */
> - clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
> - }
> + ret = loongson_rtc_alarm_setting(pdev, regs);
> + if (ret)
> + return ret;
>
> /* Loongson RTC does not support UIE */
> clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, priv->rtcdev->features);
> @@ -379,6 +401,7 @@ static const struct of_device_id loongson_rtc_of_match[] = {
> { .compatible = "loongson,ls1b-rtc", .data = &ls1b_rtc_config },
> { .compatible = "loongson,ls1c-rtc", .data = &ls1c_rtc_config },
> { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config },
> + { .compatible = "loongson,ls2k0300-rtc", .data = &ls2k0300_rtc_config },
> { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config },
> { /* sentinel */ }
> };
> --
> 2.47.3
>
>
^ permalink raw reply
* [PATCH v1 2/2] rtc: loongson: Add Loongson-2K0300 support
From: Binbin Zhou @ 2025-12-23 6:42 UTC (permalink / raw)
To: Binbin Zhou, Huacai Chen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, linux-rtc
Cc: Xiaochuang Mao, Huacai Chen, Xuerui Wang, loongarch, devicetree,
linux-mips, Keguang Zhang, Binbin Zhou
In-Reply-To: <cover.1766471839.git.zhoubinbin@loongson.cn>
The Loongson-2K0300's rtc hardware design is similar to that of the
Loongson-1B, but it does not support the alarm feature.
Introduce `LOONGSON_RTC_ALARM_WORKAROUND`, which indicates a chip that
does not support the alarm function, and rewritethe related logic in
`loongson_rtc_alarm_setting()`
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
drivers/rtc/rtc-loongson.c | 65 ++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 21 deletions(-)
diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c
index 2ca7ffd5d7a9..6b076bd4e24e 100644
--- a/drivers/rtc/rtc-loongson.c
+++ b/drivers/rtc/rtc-loongson.c
@@ -67,6 +67,7 @@
* Accessing the relevant registers will cause the system to hang.
*/
#define LS1C_RTC_CTRL_WORKAROUND BIT(0)
+#define LOONGSON_RTC_ALARM_WORKAROUND BIT(1)
struct loongson_rtc_config {
u32 pm_offset; /* Offset of PM domain, for RTC alarm wakeup */
@@ -89,7 +90,7 @@ static const struct loongson_rtc_config ls1b_rtc_config = {
static const struct loongson_rtc_config ls1c_rtc_config = {
.pm_offset = 0,
- .flags = LS1C_RTC_CTRL_WORKAROUND,
+ .flags = LS1C_RTC_CTRL_WORKAROUND | LOONGSON_RTC_ALARM_WORKAROUND,
};
static const struct loongson_rtc_config generic_rtc_config = {
@@ -97,6 +98,11 @@ static const struct loongson_rtc_config generic_rtc_config = {
.flags = 0,
};
+static const struct loongson_rtc_config ls2k0300_rtc_config = {
+ .pm_offset = 0x0,
+ .flags = LOONGSON_RTC_ALARM_WORKAROUND,
+};
+
static const struct loongson_rtc_config ls2k1000_rtc_config = {
.pm_offset = 0x800,
.flags = 0,
@@ -299,9 +305,41 @@ static const struct rtc_class_ops loongson_rtc_ops = {
.alarm_irq_enable = loongson_rtc_alarm_irq_enable,
};
+static int loongson_rtc_alarm_setting(struct platform_device *pdev, void __iomem *regs)
+{
+ int ret = 0, alarm_irq;
+ struct device *dev = &pdev->dev;
+ struct loongson_rtc_priv *priv = dev_get_drvdata(dev);
+
+ if (priv->config->flags & LOONGSON_RTC_ALARM_WORKAROUND) {
+ /* Loongson-1C/Loongson-2K0300 RTC does not support alarm */
+ clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
+ return 0;
+ }
+
+ /* Get RTC alarm irq */
+ alarm_irq = platform_get_irq(pdev, 0);
+ if (alarm_irq < 0)
+ return alarm_irq;
+
+ ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr, 0, "loongson-alarm",
+ priv);
+ if (ret < 0)
+ return ret;
+
+ priv->pm_base = regs - priv->config->pm_offset;
+ device_init_wakeup(dev, true);
+
+ if (has_acpi_companion(dev))
+ acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
+ loongson_rtc_handler, priv);
+
+ return ret;
+}
+
static int loongson_rtc_probe(struct platform_device *pdev)
{
- int ret, alarm_irq;
+ int ret;
void __iomem *regs;
struct loongson_rtc_priv *priv;
struct device *dev = &pdev->dev;
@@ -330,25 +368,9 @@ static int loongson_rtc_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(priv->rtcdev),
"devm_rtc_allocate_device failed\n");
- /* Get RTC alarm irq */
- alarm_irq = platform_get_irq(pdev, 0);
- if (alarm_irq > 0) {
- ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr,
- 0, "loongson-alarm", priv);
- if (ret < 0)
- return dev_err_probe(dev, ret, "Unable to request irq %d\n",
- alarm_irq);
-
- priv->pm_base = regs - priv->config->pm_offset;
- device_init_wakeup(dev, true);
-
- if (has_acpi_companion(dev))
- acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
- loongson_rtc_handler, priv);
- } else {
- /* Loongson-1C RTC does not support alarm */
- clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
- }
+ ret = loongson_rtc_alarm_setting(pdev, regs);
+ if (ret)
+ return ret;
/* Loongson RTC does not support UIE */
clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, priv->rtcdev->features);
@@ -379,6 +401,7 @@ static const struct of_device_id loongson_rtc_of_match[] = {
{ .compatible = "loongson,ls1b-rtc", .data = &ls1b_rtc_config },
{ .compatible = "loongson,ls1c-rtc", .data = &ls1c_rtc_config },
{ .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config },
+ { .compatible = "loongson,ls2k0300-rtc", .data = &ls2k0300_rtc_config },
{ .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config },
{ /* sentinel */ }
};
--
2.47.3
^ permalink raw reply related
* [PATCH v1 1/2] dt-binding: rtc: loongson: Document Loongson-2K0300 compatible
From: Binbin Zhou @ 2025-12-23 6:42 UTC (permalink / raw)
To: Binbin Zhou, Huacai Chen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, linux-rtc
Cc: Xiaochuang Mao, Huacai Chen, Xuerui Wang, loongarch, devicetree,
linux-mips, Keguang Zhang, Binbin Zhou
In-Reply-To: <cover.1766471839.git.zhoubinbin@loongson.cn>
Add "loongson,ls2k0300-rtc" dedicated compatible to represent the RTC
interface of the Loongson-2K0300 chip.
Its hardware design is similar to that of the Loongson-1B, but it does
not support the alarm feature.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
.../devicetree/bindings/rtc/loongson,rtc.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/Documentation/devicetree/bindings/rtc/loongson,rtc.yaml b/Documentation/devicetree/bindings/rtc/loongson,rtc.yaml
index f89c1f660aee..aac91c79ffdb 100644
--- a/Documentation/devicetree/bindings/rtc/loongson,rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/loongson,rtc.yaml
@@ -23,6 +23,7 @@ properties:
- loongson,ls1b-rtc
- loongson,ls1c-rtc
- loongson,ls7a-rtc
+ - loongson,ls2k0300-rtc
- loongson,ls2k1000-rtc
- items:
- enum:
@@ -42,6 +43,18 @@ required:
unevaluatedProperties: false
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - loongson,ls1c-rtc
+ - loongson,ls2k0300-rtc
+
+then:
+ properties:
+ interrupts: false
+
examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
--
2.47.3
^ permalink raw reply related
* [PATCH v1 0/2] RTC: Add Loongson-2K0300 support
From: Binbin Zhou @ 2025-12-23 6:42 UTC (permalink / raw)
To: Binbin Zhou, Huacai Chen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, linux-rtc
Cc: Xiaochuang Mao, Huacai Chen, Xuerui Wang, loongarch, devicetree,
linux-mips, Keguang Zhang, Binbin Zhou
Hi all:
This patch set introduces the Loongson-2K0300 RTC, which has a similar
hardware design to the Loongson-1B, but without the alarm feature.
To Keguang:
Would you have time to test the driver on a Loongson-1?
Thanks.
Binbin
Binbin Zhou (2):
dt-binding: rtc: loongson: Document Loongson-2K0300 compatible
rtc: loongson: Add Loongson-2K0300 support
.../devicetree/bindings/rtc/loongson,rtc.yaml | 13 ++++
drivers/rtc/rtc-loongson.c | 65 +++++++++++++------
2 files changed, 57 insertions(+), 21 deletions(-)
base-commit: 16bd954c93360145bc77cc601e350913fc28182d
--
2.47.3
^ permalink raw reply
* Re: [PATCH v5 08/11] input: macsmc-input: New driver to handle the Apple Mac SMC buttons/lid
From: Nick Chan @ 2025-12-22 13:50 UTC (permalink / raw)
To: James Calligeros, Sven Peter, Janne Grunau, Alyssa Rosenzweig,
Neal Gompa, Lee Jones, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Alexandre Belloni, Jean Delvare, Guenter Roeck,
Dmitry Torokhov, Jonathan Corbet
Cc: asahi, linux-arm-kernel, devicetree, linux-kernel, linux-rtc,
linux-hwmon, linux-input, linux-doc, Hector Martin
In-Reply-To: <20251112-macsmc-subdevs-v5-8-728e4b91fe81@gmail.com>
Hi,
On 12/11/2025 19:16, James Calligeros wrote:
> From: Hector Martin <marcan@marcan.st>
>
> This driver implements power button and lid switch support for Apple Mac
> devices using SMC controllers driven by the macsmc driver.
>
> In addition to basic input support, this also responds to the final
> shutdown warning (when the power button is held down long enough) by
> doing an emergency kernel poweroff. This allows the NVMe controller to
> be cleanly shut down, which prevents data loss for in-cache data.
>
> Reviewed-by: Neal Gompa <neal@gompa.dev>
> Signed-off-by: Hector Martin <marcan@marcan.st>
> Co-developed-by: Sven Peter <sven@kernel.org>
> Signed-off-by: Sven Peter <sven@kernel.org>
> Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
> ---
> MAINTAINERS | 1 +
> drivers/input/misc/Kconfig | 11 ++
> drivers/input/misc/Makefile | 1 +
> drivers/input/misc/macsmc-input.c | 207 +++++++++++++++++++++++++
> 4 files changed, 220 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fb55a167699e..48bdca6943f3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2455,6 +2455,7 @@ F: drivers/hwmon/macsmc-hwmon.c
> F: drivers/pmdomain/apple/
> F: drivers/i2c/busses/i2c-pasemi-core.c
> F: drivers/i2c/busses/i2c-pasemi-platform.c
> +F: drivers/input/misc/macsmc-input.c
> F: drivers/input/touchscreen/apple_z2.c
> F: drivers/iommu/apple-dart.c
> F: drivers/iommu/io-pgtable-dart.c
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index cc2558630797..1144ba151dbf 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -992,4 +992,15 @@ config INPUT_STPMIC1_ONKEY
> To compile this driver as a module, choose M here: the
> module will be called stpmic1_onkey.
>
> +config INPUT_MACSMC
> + tristate "Apple Mac SMC lid/buttons"
> + depends on MFD_MACSMC
> + help
> + Say Y here if you want to use the input events delivered via the
> + SMC controller on Apple Mac machines using the macsmc driver.
> + This includes lid open/close and the power button.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called macsmc-input.
> +
> endif
> diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
> index f5ebfa9d9983..c6394105252f 100644
> --- a/drivers/input/misc/Makefile
> +++ b/drivers/input/misc/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_INPUT_IQS7222) += iqs7222.o
> obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
> obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o
> obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
> +obj-$(CONFIG_INPUT_MACSMC_INPUT) += macsmc-input.o
should be CONFIG_INPUT_MACSMC (alternatively change Kconfig instead)
> obj-$(CONFIG_INPUT_MAX7360_ROTARY) += max7360-rotary.o
> obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o
> obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o
> diff --git a/drivers/input/misc/macsmc-input.c b/drivers/input/misc/macsmc-input.c
> new file mode 100644
> index 000000000000..f4598e65fc80
> --- /dev/null
> +++ b/drivers/input/misc/macsmc-input.c
> @@ -0,0 +1,207 @@
> +// SPDX-License-Identifier: GPL-2.0-only OR MIT
> +/*
> + * Apple SMC input event driver
> + * Copyright The Asahi Linux Contributors
> + *
> + * This driver exposes certain events from the SMC as an input device.
> + * This includes the lid open/close and power button notifications.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/input.h>
> +#include <linux/mfd/macsmc.h>
Missing #include <linux/mfd/core.h>
> +#include <linux/module.h>
> +#include <linux/reboot.h>
> +
> +/**
> + * struct macsmc_input
> + * @dev: Underlying struct device for the input sub-device
> + * @smc: Pointer to apple_smc struct of the mfd parent
> + * @input: Allocated input_dev; devres managed
> + * @nb: Notifier block used for incoming events from SMC (e.g. button pressed down)
> + * @wakeup_mode: Set to true when system is suspended and power button events should wake it
> + */
> +struct macsmc_input {
> + struct device *dev;
> + struct apple_smc *smc;
> + struct input_dev *input;
> + struct notifier_block nb;
> + bool wakeup_mode;
> +};
> +
> +#define SMC_EV_BTN 0x7201
> +#define SMC_EV_LID 0x7203
> +
> +#define BTN_POWER 0x01 /* power button on e.g. Mac Mini chasis pressed */
> +#define BTN_TOUCHID 0x06 /* combined TouchID / power button on MacBooks pressed */
> +#define BTN_POWER_HELD_SHORT 0xfe /* power button briefly held down */
> +#define BTN_POWER_HELD_LONG 0x00 /* power button held down; sent just before forced poweroff */
> +
> +static void macsmc_input_event_button(struct macsmc_input *smcin, unsigned long event)
> +{
> + u8 button = (event >> 8) & 0xff;
> + u8 state = !!(event & 0xff);
> +
> + switch (button) {
> + case BTN_POWER:
> + case BTN_TOUCHID:
> + pm_wakeup_dev_event(smcin->dev, 0, (smcin->wakeup_mode && state));
> +
> + /* Suppress KEY_POWER event to prevent immediate shutdown on wake */
> + if (smcin->wakeup_mode)
> + return;
> +
> + input_report_key(smcin->input, KEY_POWER, state);
> + input_sync(smcin->input);
> + break;
> + case BTN_POWER_HELD_SHORT: /* power button held down; ignore */
> + break;
> + case BTN_POWER_HELD_LONG:
> + /*
> + * If we get here the power button has been held down for a while and
> + * we have about 4 seconds before forced power-off is triggered by SMC.
> + * Try to do an emergency shutdown to make sure the NVMe cache is
> + * flushed. macOS actually does this by panicing (!)...
> + */
> + if (state) {
> + dev_crit(smcin->dev, "Triggering forced shutdown!\n");
> + if (kernel_can_power_off())
> + kernel_power_off();
> + else /* Missing macsmc-reboot driver? */
> + kernel_restart("SMC power button triggered restart");
> + }
> + break;
> + default:
> + dev_warn(smcin->dev, "Unknown SMC button event: %04lx\n", event & 0xffff);
> + }
> +}
> +
> +static void macsmc_input_event_lid(struct macsmc_input *smcin, unsigned long event)
> +{
> + u8 lid_state = !!((event >> 8) & 0xff);
> +
> + pm_wakeup_dev_event(smcin->dev, 0, (smcin->wakeup_mode && !lid_state));
> + input_report_switch(smcin->input, SW_LID, lid_state);
> + input_sync(smcin->input);
> +}
> +
> +static int macsmc_input_event(struct notifier_block *nb, unsigned long event, void *data)
> +{
> + struct macsmc_input *smcin = container_of(nb, struct macsmc_input, nb);
> + u16 type = event >> 16;
> +
> + switch (type) {
> + case SMC_EV_BTN:
> + macsmc_input_event_button(smcin, event);
> + return NOTIFY_OK;
> + case SMC_EV_LID:
> + macsmc_input_event_lid(smcin, event);
> + return NOTIFY_OK;
> + default:
> + /* SMC event meant for another driver */
> + return NOTIFY_DONE;
> + }
> +}
> +
> +static int macsmc_input_probe(struct platform_device *pdev)
> +{
> + struct apple_smc *smc = dev_get_drvdata(pdev->dev.parent);
> + struct macsmc_input *smcin;
> + bool have_lid, have_power;
> + int error;
> +
> + /* Bail early if this SMC neither supports power button nor lid events */
> + have_lid = apple_smc_key_exists(smc, SMC_KEY(MSLD));
> + have_power = apple_smc_key_exists(smc, SMC_KEY(bHLD));
> + if (!have_lid && !have_power)
> + return -ENODEV;
> +
> + smcin = devm_kzalloc(&pdev->dev, sizeof(*smcin), GFP_KERNEL);
> + if (!smcin)
> + return -ENOMEM;
> +
> + smcin->dev = &pdev->dev;
> + smcin->smc = smc;
> + platform_set_drvdata(pdev, smcin);
> +
> + smcin->input = devm_input_allocate_device(&pdev->dev);
> + if (!smcin->input)
> + return -ENOMEM;
> +
> + smcin->input->phys = "macsmc-input (0)";
> + smcin->input->name = "Apple SMC power/lid events";
> +
> + if (have_lid)
> + input_set_capability(smcin->input, EV_SW, SW_LID);
> + if (have_power)
> + input_set_capability(smcin->input, EV_KEY, KEY_POWER);
> +
> + if (have_lid) {
> + u8 val;
> +
> + error = apple_smc_read_u8(smc, SMC_KEY(MSLD), &val);
> + if (error < 0)
> + dev_warn(&pdev->dev, "Failed to read initial lid state\n");
> + else
> + input_report_switch(smcin->input, SW_LID, val);
> + }
> +
> + if (have_power) {
> + u32 val;
> +
> + error = apple_smc_read_u32(smc, SMC_KEY(bHLD), &val);
> + if (error < 0)
> + dev_warn(&pdev->dev, "Failed to read initial power button state\n");
> + else
> + input_report_key(smcin->input, KEY_POWER, val & 1);
> + }
> +
> + error = input_register_device(smcin->input);
> + if (error) {
> + dev_err(&pdev->dev, "Failed to register input device: %d\n", error);
> + return error;
> + }
> +
> + input_sync(smcin->input);
> +
> + smcin->nb.notifier_call = macsmc_input_event;
> + blocking_notifier_chain_register(&smc->event_handlers, &smcin->nb);
> +
> + device_init_wakeup(&pdev->dev, true);
> +
> + return 0;
> +}
> +
> +static int macsmc_input_pm_prepare(struct device *dev)
> +{
> + struct macsmc_input *smcin = dev_get_drvdata(dev);
> +
> + smcin->wakeup_mode = true;
> + return 0;
> +}
> +
> +static void macsmc_input_pm_complete(struct device *dev)
> +{
> + struct macsmc_input *smcin = dev_get_drvdata(dev);
> +
> + smcin->wakeup_mode = false;
> +}
> +
> +static const struct dev_pm_ops macsmc_input_pm_ops = {
> + .prepare = macsmc_input_pm_prepare,
> + .complete = macsmc_input_pm_complete,
> +};
> +
> +static struct platform_driver macsmc_input_driver = {
> + .driver = {
> + .name = "macsmc-input",
> + .pm = &macsmc_input_pm_ops,
> + },
> + .probe = macsmc_input_probe,
> +};
> +module_platform_driver(macsmc_input_driver);
> +
> +MODULE_AUTHOR("Hector Martin <marcan@marcan.st>");
> +MODULE_LICENSE("Dual MIT/GPL");
> +MODULE_DESCRIPTION("Apple SMC input driver");
> +MODULE_ALIAS("platform:macsmc-input");
>
Best regards,
Nick Chan
^ permalink raw reply
* Re: [PATCH v3 0/4] fix the SpacemiT P1 Kconfig and resend the K1 I2C ILCR patch.
From: Troy Mitchell @ 2025-12-22 9:36 UTC (permalink / raw)
To: Lee Jones, patchwork-bot+linux-riscv, Konstantin Ryabitsev, tools
Cc: Troy Mitchell, linux-riscv, dlan, elder, andi.shyti,
alexandre.belloni, lgirdwood, broonie, linux-kernel, spacemit,
linux-i2c, linux-rtc
In-Reply-To: <20251219112634.GJ9275@google.com>
On Fri, Dec 19, 2025 at 11:26:34AM +0000, Lee Jones wrote:
> Hi Konstantin,
>
> > This series was applied to riscv/linux.git (fixes)
> > by Alexandre Belloni <alexandre.belloni@bootlin.com>:
> >
> > On Tue, 18 Nov 2025 14:08:04 +0800 you wrote:
> > > Since P1 Kconfig directly selects K1_I2C, after the I2C ILCR patch was
> > > merged, the driver would fail [1] when COMMON_CLK was not selected.
> > >
> > > This series fixes the P1 Kconfig and resends the I2C ILCR patch(This
> > > patch has reverted by maintainer [2]).
> > >
> > > Now, P1 Kconfig patch has been merged[3], so I2C ILCR patch can be
> > > merged as well.
> > >
> > > [...]
> >
> > Here is the summary with links:
> > - [v3,1/4] i2c: spacemit: configure ILCR for accurate SCL frequency
> > (no matching commit)
> > - [v3,2/4] rtc: spacemit: MFD_SPACEMIT_P1 as dependencies
> > https://git.kernel.org/riscv/c/16bd954c9336
> > - [v3,3/4] regulator: spacemit: MFD_SPACEMIT_P1 as dependencies
> > (no matching commit)
>
> > - [v3,4/4] mfd: simple-mfd-i2c: add default value
> > (no matching commit)
>
> I was just about to send another snot-o-gram about people picking up
> patches without the correct Acks, but I just realised this is the same
> Patchwork issue we spoke about a couple of weeks ago.
>
> This formatting is very confusing, since at first blush it looks as
> though the whole patch-set was applied.
>
> Please can we only list patches that were merged?
I agree. At first glance, I also thought the entire series was applied.
- Troy
>
> --
> Lee Jones [李琼斯]
>
^ permalink raw reply
* [PATCH] rtc: nvvrs: Add ARCH_TEGRA to the NV VRS RTC driver
From: Peter Robinson @ 2025-12-22 3:56 UTC (permalink / raw)
To: Alexandre Belloni, linux-rtc; +Cc: Peter Robinson, Shubhi Garg, Jon Hunter
The NV VRS RTC driver currently is only supported on the
Tegra platform so add a dep for ARCH_TEGRA and compile test
so it doesn't show up universally across all arches/platforms.
Fixes: 9d6d6b06933c8 ("rtc: nvvrs: add NVIDIA VRS RTC device driver")
Cc: Shubhi Garg <shgarg@nvidia.com>
Cc: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---
drivers/rtc/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 50dc779f7f983..50ba48609d74e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -418,6 +418,7 @@ config RTC_DRV_SPACEMIT_P1
config RTC_DRV_NVIDIA_VRS10
tristate "NVIDIA VRS10 RTC device"
+ depends on ARCH_TEGRA || COMPILE_TEST
help
If you say yes here you will get support for the battery backed RTC device
of NVIDIA VRS (Voltage Regulator Specification). The RTC is connected via
--
2.52.0
^ permalink raw reply related
* Re: [PATCH 1/4] dt-bindings: rtc: ds1307: Add epson,rx8901
From: Krzysztof Kozlowski @ 2025-12-20 8:59 UTC (permalink / raw)
To: Fredrik M Olsson
Cc: Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nobuhiro Iwamatsu, linux-rtc, devicetree, linux-kernel, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-1-b13f346ebe93@axis.com>
On Fri, Dec 19, 2025 at 01:10:35PM +0100, Fredrik M Olsson wrote:
> Add compatible string epson,rx8901 for the Epson RX8901CE RTC.
>
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
> ---
> Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 +
> 1 file changed, 1 insertion(+)
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply
* [PATCH 0/4] rtc: ds1307: Add support for Epson RX8901CE
From: Fredrik M Olsson @ 2025-12-19 12:10 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nobuhiro Iwamatsu
Cc: linux-rtc, devicetree, linux-kernel, Fredrik M Olsson, kernel
Add basic support for the Epson RX8901CE RTC.
Datasheet: https://download.epsondevice.com/td/pdf/app/RX8901CE_en.pdf
Also includes a bug fix for an issue with reading the weekday from the
RTC which affects both the existing rx8130 and this rx8901 driver.
Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
---
Fredrik M Olsson (4):
dt-bindings: rtc: ds1307: Add epson,rx8901
rtc: ds1307: Fix off-by-one issue with wday for rx8130
rtc: ds1307: Add Driver for Epson RX8901CE
rtc: ds1307: Add support for reading RX8901CE battery VL status
.../devicetree/bindings/rtc/rtc-ds1307.yaml | 1 +
drivers/rtc/rtc-ds1307.c | 104 ++++++++++++++++++++-
2 files changed, 102 insertions(+), 3 deletions(-)
---
base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
change-id: 20251126-ds1307-rx8901-add-a0fe173093e3
Best regards,
--
Fredrik M Olsson <fredrik.m.olsson@axis.com>
^ permalink raw reply
* [PATCH 1/4] dt-bindings: rtc: ds1307: Add epson,rx8901
From: Fredrik M Olsson @ 2025-12-19 12:10 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nobuhiro Iwamatsu
Cc: linux-rtc, devicetree, linux-kernel, Fredrik M Olsson, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-0-b13f346ebe93@axis.com>
Add compatible string epson,rx8901 for the Epson RX8901CE RTC.
Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
---
Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
index 98d10e680144..9b2796804f07 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
+++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml
@@ -31,6 +31,7 @@ properties:
- epson,rx8025
- isil,isl12057
- epson,rx8130
+ - epson,rx8901
- items:
- enum:
--
2.43.0
^ permalink raw reply related
* [PATCH 2/4] rtc: ds1307: Fix off-by-one issue with wday for rx8130
From: Fredrik M Olsson @ 2025-12-19 12:10 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nobuhiro Iwamatsu
Cc: linux-rtc, devicetree, linux-kernel, Fredrik M Olsson, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-0-b13f346ebe93@axis.com>
The RTC represent each weekday with a individual bit set in the WDAY
register, where the 0th bit represent the first day of the week and the
6th bit represents the last day of the week. For each passed day the
chip performs a rotary-left-shift by one to advance the weekday by one.
The tm_wday field represent weekdays by a value in the range of 0-6.
The fls() function return the bit index of the last bit set. To handle
when there are no bits set it will return 0, and if the 0th bit is set
it will return 1, and if the 1st bit is set it will return 2, and so on.
In order to make the result of the fls() function fall into the expected
range of 0-6 (instead of 1-7) this patch subtracts one from the result
(which matches how the value is written in ds1307_set_time()).
Fixes: 204756f016726 ("rtc: ds1307: Fix wday settings for rx8130")
Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
---
drivers/rtc/rtc-ds1307.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 7205c59ff729..bf42c250ea7d 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -308,7 +308,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
t->tm_hour = bcd2bin(tmp);
/* rx8130 is bit position, not BCD */
if (ds1307->type == rx_8130)
- t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f);
+ t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f) - 1;
else
t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1;
t->tm_mday = bcd2bin(regs[DS1307_REG_MDAY] & 0x3f);
--
2.43.0
^ permalink raw reply related
* [PATCH 3/4] rtc: ds1307: Add Driver for Epson RX8901CE
From: Fredrik M Olsson @ 2025-12-19 12:10 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nobuhiro Iwamatsu
Cc: linux-rtc, devicetree, linux-kernel, Fredrik M Olsson, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-0-b13f346ebe93@axis.com>
Adds Support for:
- Reading and writing time to/from the RTC.
- Switching to backup battery supply when primary supply disappears.
- Optionally enabling battery charging.
Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
---
drivers/rtc/rtc-ds1307.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 60 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bf42c250ea7d..99d95e520108 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -48,6 +48,7 @@ enum ds_type {
mcp794xx,
rx_8025,
rx_8130,
+ rx_8901,
last_ds_type /* always last */
/* rs5c372 too? different address... */
};
@@ -129,6 +130,12 @@ enum ds_type {
#define RX8130_REG_CONTROL1_INIEN BIT(4)
#define RX8130_REG_CONTROL1_CHGEN BIT(5)
+#define RX8901_REG_INTF 0x0e
+#define RX8901_REG_INTF_VLF BIT(1)
+#define RX8901_REG_PWSW_CFG 0x37
+#define RX8901_REG_PWSW_CFG_INIEN BIT(6)
+#define RX8901_REG_PWSW_CFG_CHGEN BIT(7)
+
#define MCP794XX_REG_CONTROL 0x07
# define MCP794XX_BIT_ALM0_EN 0x10
# define MCP794XX_BIT_ALM1_EN 0x20
@@ -226,6 +233,19 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
dev_warn_once(dev, "oscillator failed, set time!\n");
return -EINVAL;
}
+ } else if (ds1307->type == rx_8901) {
+ unsigned int regflag;
+
+ ret = regmap_read(ds1307->regmap, RX8901_REG_INTF, ®flag);
+ if (ret) {
+ dev_err(dev, "%s error %d\n", "read", ret);
+ return ret;
+ }
+
+ if (regflag & RX8901_REG_INTF_VLF) {
+ dev_warn_once(dev, "oscillator failed, set time!\n");
+ return -EINVAL;
+ }
}
/* read the RTC date and time registers all at once */
@@ -307,7 +327,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
tmp = regs[DS1307_REG_HOUR] & 0x3f;
t->tm_hour = bcd2bin(tmp);
/* rx8130 is bit position, not BCD */
- if (ds1307->type == rx_8130)
+ if (ds1307->type == rx_8130 || ds1307->type == rx_8901)
t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f) - 1;
else
t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1;
@@ -358,7 +378,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
regs[DS1307_REG_MIN] = bin2bcd(t->tm_min);
regs[DS1307_REG_HOUR] = bin2bcd(t->tm_hour);
/* rx8130 is bit position, not BCD */
- if (ds1307->type == rx_8130)
+ if (ds1307->type == rx_8130 || ds1307->type == rx_8901)
regs[DS1307_REG_WDAY] = 1 << t->tm_wday;
else
regs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1);
@@ -422,6 +442,17 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
dev_err(dev, "%s error %d\n", "write", result);
return result;
}
+ } else if (ds1307->type == rx_8901) {
+ /*
+ * clear Voltage Loss Flag as data is available now (writing 1
+ * to the other bits in the INTF register has no effect)
+ */
+ result = regmap_write(ds1307->regmap, RX8901_REG_INTF,
+ 0xff ^ RX8901_REG_INTF_VLF);
+ if (result) {
+ dev_err(dev, "%s error %d\n", "write", result);
+ return result;
+ }
}
return 0;
@@ -568,6 +599,17 @@ static u8 do_trickle_setup_rx8130(struct ds1307 *ds1307, u32 ohms, bool diode)
return setup;
}
+static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms, bool diode)
+{
+ /* make sure that the backup battery is enabled */
+ u8 setup = RX8901_REG_PWSW_CFG_INIEN;
+
+ if (diode)
+ setup |= RX8901_REG_PWSW_CFG_CHGEN;
+
+ return setup;
+}
+
static irqreturn_t rx8130_irq(int irq, void *dev_id)
{
struct ds1307 *ds1307 = dev_id;
@@ -960,6 +1002,11 @@ static const struct rtc_class_ops rx8130_rtc_ops = {
.alarm_irq_enable = rx8130_alarm_irq_enable,
};
+static const struct rtc_class_ops rx8901_rtc_ops = {
+ .read_time = ds1307_get_time,
+ .set_time = ds1307_set_time,
+};
+
static const struct rtc_class_ops mcp794xx_rtc_ops = {
.read_time = ds1307_get_time,
.set_time = ds1307_set_time,
@@ -1040,6 +1087,12 @@ static const struct chip_desc chips[last_ds_type] = {
.trickle_charger_reg = RX8130_REG_CONTROL1,
.do_trickle_setup = &do_trickle_setup_rx8130,
},
+ [rx_8901] = {
+ .offset = 0x0,
+ .rtc_ops = &rx8901_rtc_ops,
+ .trickle_charger_reg = RX8901_REG_PWSW_CFG,
+ .do_trickle_setup = &do_trickle_setup_rx8901,
+ },
[m41t0] = {
.rtc_ops = &m41txx_rtc_ops,
},
@@ -1081,6 +1134,7 @@ static const struct i2c_device_id ds1307_id[] = {
{ "rx8025", rx_8025 },
{ "isl12057", ds_1337 },
{ "rx8130", rx_8130 },
+ { "rx8901", rx_8901 },
{ }
};
MODULE_DEVICE_TABLE(i2c, ds1307_id);
@@ -1158,6 +1212,10 @@ static const struct of_device_id ds1307_of_match[] = {
.compatible = "epson,rx8130",
.data = (void *)rx_8130
},
+ {
+ .compatible = "epson,rx8901",
+ .data = (void *)rx_8901
+ },
{ }
};
MODULE_DEVICE_TABLE(of, ds1307_of_match);
--
2.43.0
^ permalink raw reply related
* [PATCH 4/4] rtc: ds1307: Add support for reading RX8901CE battery VL status
From: Fredrik M Olsson @ 2025-12-19 12:10 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Nobuhiro Iwamatsu
Cc: linux-rtc, devicetree, linux-kernel, Fredrik M Olsson, kernel
In-Reply-To: <20251219-ds1307-rx8901-add-v1-0-b13f346ebe93@axis.com>
Adds support for:
- Reading the battery voltage low status using the RTC_VL_READ ioctl,
which also reports invalid time information if the VLF flag is set.
Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
---
drivers/rtc/rtc-ds1307.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 99d95e520108..ca062ed0c867 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -133,8 +133,11 @@ enum ds_type {
#define RX8901_REG_INTF 0x0e
#define RX8901_REG_INTF_VLF BIT(1)
#define RX8901_REG_PWSW_CFG 0x37
+#define RX8901_REG_PWSW_CFG_VBATLDETEN BIT(4)
#define RX8901_REG_PWSW_CFG_INIEN BIT(6)
#define RX8901_REG_PWSW_CFG_CHGEN BIT(7)
+#define RX8901_REG_BUF_INTF 0x46
+#define RX8901_REG_BUF_INTF_VBATLF BIT(3)
#define MCP794XX_REG_CONTROL 0x07
# define MCP794XX_BIT_ALM0_EN 0x10
@@ -458,6 +461,39 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
return 0;
}
+#ifdef CONFIG_RTC_INTF_DEV
+static int rx8901_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+ struct ds1307 *ds1307 = dev_get_drvdata(dev);
+ unsigned int regflag, tmp = 0;
+ int ret = 0;
+
+ switch (cmd) {
+ case RTC_VL_READ:
+ ret = regmap_read(ds1307->regmap, RX8901_REG_INTF, ®flag);
+ if (ret)
+ return ret;
+
+ if (regflag & RX8901_REG_INTF_VLF)
+ tmp |= RTC_VL_DATA_INVALID;
+
+ ret = regmap_read(ds1307->regmap, RX8901_REG_BUF_INTF, ®flag);
+ if (ret)
+ return ret;
+
+ if (regflag & RX8901_REG_BUF_INTF_VBATLF)
+ tmp |= RTC_VL_BACKUP_LOW;
+
+ return put_user(tmp, (unsigned int __user *)arg);
+ default:
+ return -ENOIOCTLCMD;
+ }
+ return ret;
+}
+#else
+#define rx8901_ioctl NULL
+#endif
+
static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
{
struct ds1307 *ds1307 = dev_get_drvdata(dev);
@@ -599,10 +635,13 @@ static u8 do_trickle_setup_rx8130(struct ds1307 *ds1307, u32 ohms, bool diode)
return setup;
}
-static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms, bool diode)
+static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms __always_unused, bool diode)
{
- /* make sure that the backup battery is enabled */
- u8 setup = RX8901_REG_PWSW_CFG_INIEN;
+ /*
+ * make sure that the backup battery is enabled and that battery
+ * voltage detection is performed
+ */
+ u8 setup = RX8901_REG_PWSW_CFG_INIEN | RX8901_REG_PWSW_CFG_VBATLDETEN;
if (diode)
setup |= RX8901_REG_PWSW_CFG_CHGEN;
@@ -1005,6 +1044,7 @@ static const struct rtc_class_ops rx8130_rtc_ops = {
static const struct rtc_class_ops rx8901_rtc_ops = {
.read_time = ds1307_get_time,
.set_time = ds1307_set_time,
+ .ioctl = rx8901_ioctl,
};
static const struct rtc_class_ops mcp794xx_rtc_ops = {
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v3 0/4] fix the SpacemiT P1 Kconfig and resend the K1 I2C ILCR patch.
From: Lee Jones @ 2025-12-19 11:26 UTC (permalink / raw)
To: patchwork-bot+linux-riscv, Konstantin Ryabitsev, tools
Cc: Troy Mitchell, linux-riscv, dlan, elder, andi.shyti,
alexandre.belloni, lgirdwood, broonie, linux-kernel, spacemit,
linux-i2c, linux-rtc
In-Reply-To: <176613181654.3684357.18070317581817603415.git-patchwork-notify@kernel.org>
Hi Konstantin,
> This series was applied to riscv/linux.git (fixes)
> by Alexandre Belloni <alexandre.belloni@bootlin.com>:
>
> On Tue, 18 Nov 2025 14:08:04 +0800 you wrote:
> > Since P1 Kconfig directly selects K1_I2C, after the I2C ILCR patch was
> > merged, the driver would fail [1] when COMMON_CLK was not selected.
> >
> > This series fixes the P1 Kconfig and resends the I2C ILCR patch(This
> > patch has reverted by maintainer [2]).
> >
> > Now, P1 Kconfig patch has been merged[3], so I2C ILCR patch can be
> > merged as well.
> >
> > [...]
>
> Here is the summary with links:
> - [v3,1/4] i2c: spacemit: configure ILCR for accurate SCL frequency
> (no matching commit)
> - [v3,2/4] rtc: spacemit: MFD_SPACEMIT_P1 as dependencies
> https://git.kernel.org/riscv/c/16bd954c9336
> - [v3,3/4] regulator: spacemit: MFD_SPACEMIT_P1 as dependencies
> (no matching commit)
> - [v3,4/4] mfd: simple-mfd-i2c: add default value
> (no matching commit)
I was just about to send another snot-o-gram about people picking up
patches without the correct Acks, but I just realised this is the same
Patchwork issue we spoke about a couple of weeks ago.
This formatting is very confusing, since at first blush it looks as
though the whole patch-set was applied.
Please can we only list patches that were merged?
--
Lee Jones [李琼斯]
^ permalink raw reply
* Re: [PATCH v3 0/4] fix the SpacemiT P1 Kconfig and resend the K1 I2C ILCR patch.
From: patchwork-bot+linux-riscv @ 2025-12-19 8:10 UTC (permalink / raw)
To: Troy Mitchell
Cc: linux-riscv, lee, dlan, elder, andi.shyti, alexandre.belloni,
lgirdwood, broonie, linux-kernel, spacemit, linux-i2c, linux-rtc
In-Reply-To: <20251118-p1-kconfig-fix-v3-0-8839c5ac5db3@linux.spacemit.com>
Hello:
This series was applied to riscv/linux.git (fixes)
by Alexandre Belloni <alexandre.belloni@bootlin.com>:
On Tue, 18 Nov 2025 14:08:04 +0800 you wrote:
> Since P1 Kconfig directly selects K1_I2C, after the I2C ILCR patch was
> merged, the driver would fail [1] when COMMON_CLK was not selected.
>
> This series fixes the P1 Kconfig and resends the I2C ILCR patch(This
> patch has reverted by maintainer [2]).
>
> Now, P1 Kconfig patch has been merged[3], so I2C ILCR patch can be
> merged as well.
>
> [...]
Here is the summary with links:
- [v3,1/4] i2c: spacemit: configure ILCR for accurate SCL frequency
(no matching commit)
- [v3,2/4] rtc: spacemit: MFD_SPACEMIT_P1 as dependencies
https://git.kernel.org/riscv/c/16bd954c9336
- [v3,3/4] regulator: spacemit: MFD_SPACEMIT_P1 as dependencies
(no matching commit)
- [v3,4/4] mfd: simple-mfd-i2c: add default value
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply
* Re: [PATCH v2 00/17] tee: Use bus callbacks instead of driver callbacks
From: Jens Wiklander @ 2025-12-18 16:29 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Uwe Kleine-König, Jonathan Corbet, Sumit Garg,
Olivia Mackall, Herbert Xu, Clément Léger,
Ard Biesheuvel, Maxime Coquelin, Alexandre Torgue, Sumit Garg,
Ilias Apalodimas, Jan Kiszka, Sudeep Holla, Christophe JAILLET,
Rafał Miłecki, Michael Chan, Pavan Chebbi,
James Bottomley, Jarkko Sakkinen, Mimi Zohar, David Howells,
Paul Moore, James Morris, Serge E. Hallyn, Peter Huewe, op-tee,
linux-kernel, linux-doc, linux-crypto, linux-rtc, linux-efi,
linux-stm32, linux-arm-kernel, Cristian Marussi, arm-scmi,
linux-mips, netdev, linux-integrity, keyrings,
linux-security-module, Jason Gunthorpe
In-Reply-To: <20251218135332f323fa91@mail.local>
On Thu, Dec 18, 2025 at 2:53 PM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> On 18/12/2025 08:21:27+0100, Jens Wiklander wrote:
> > Hi,
> >
> > On Mon, Dec 15, 2025 at 3:17 PM Uwe Kleine-König
> > <u.kleine-koenig@baylibre.com> wrote:
> > >
> > > Hello,
> > >
> > > the objective of this series is to make tee driver stop using callbacks
> > > in struct device_driver. These were superseded by bus methods in 2006
> > > (commit 594c8281f905 ("[PATCH] Add bus_type probe, remove, shutdown
> > > methods.")) but nobody cared to convert all subsystems accordingly.
> > >
> > > Here the tee drivers are converted. The first commit is somewhat
> > > unrelated, but simplifies the conversion (and the drivers). It
> > > introduces driver registration helpers that care about setting the bus
> > > and owner. (The latter is missing in all drivers, so by using these
> > > helpers the drivers become more correct.)
> > >
> > > v1 of this series is available at
> > > https://lore.kernel.org/all/cover.1765472125.git.u.kleine-koenig@baylibre.com
> > >
> > > Changes since v1:
> > >
> > > - rebase to v6.19-rc1 (no conflicts)
> > > - add tags received so far
> > > - fix whitespace issues pointed out by Sumit Garg
> > > - fix shutdown callback to shutdown and not remove
> > >
> > > As already noted in v1's cover letter, this series should go in during a
> > > single merge window as there are runtime warnings when the series is
> > > only applied partially. Sumit Garg suggested to apply the whole series
> > > via Jens Wiklander's tree.
> > > If this is done the dependencies in this series are honored, in case the
> > > plan changes: Patches #4 - #17 depend on the first two.
> > >
> > > Note this series is only build tested.
> > >
> > > Uwe Kleine-König (17):
> > > tee: Add some helpers to reduce boilerplate for tee client drivers
> > > tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
> > > tee: Adapt documentation to cover recent additions
> > > hwrng: optee - Make use of module_tee_client_driver()
> > > hwrng: optee - Make use of tee bus methods
> > > rtc: optee: Migrate to use tee specific driver registration function
> > > rtc: optee: Make use of tee bus methods
> > > efi: stmm: Make use of module_tee_client_driver()
> > > efi: stmm: Make use of tee bus methods
> > > firmware: arm_scmi: optee: Make use of module_tee_client_driver()
> > > firmware: arm_scmi: Make use of tee bus methods
> > > firmware: tee_bnxt: Make use of module_tee_client_driver()
> > > firmware: tee_bnxt: Make use of tee bus methods
> > > KEYS: trusted: Migrate to use tee specific driver registration
> > > function
> > > KEYS: trusted: Make use of tee bus methods
> > > tpm/tpm_ftpm_tee: Make use of tee specific driver registration
> > > tpm/tpm_ftpm_tee: Make use of tee bus methods
> > >
> > > Documentation/driver-api/tee.rst | 18 +----
> > > drivers/char/hw_random/optee-rng.c | 26 ++----
> > > drivers/char/tpm/tpm_ftpm_tee.c | 31 +++++---
> > > drivers/firmware/arm_scmi/transports/optee.c | 32 +++-----
> > > drivers/firmware/broadcom/tee_bnxt_fw.c | 30 ++-----
> > > drivers/firmware/efi/stmm/tee_stmm_efi.c | 25 ++----
> > > drivers/rtc/rtc-optee.c | 27 ++-----
> > > drivers/tee/tee_core.c | 84 ++++++++++++++++++++
> > > include/linux/tee_drv.h | 12 +++
> > > security/keys/trusted-keys/trusted_tee.c | 17 ++--
> > > 10 files changed, 164 insertions(+), 138 deletions(-)
> > >
> > > base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> > > --
> > > 2.47.3
> > >
> >
> > Thank you for the nice cleanup, Uwe.
> >
> > I've applied patch 1-3 to the branch tee_bus_callback_for_6.20 in my
> > tree at https://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee.git/
> >
> > The branch is based on v6.19-rc1, and I'll try to keep it stable for
> > others to depend on, if needed. Let's see if we can agree on taking
> > the remaining patches via that branch.
>
> 6 and 7 can go through your branch.
Good, I've added them to my branch now.
Thanks,
Jens
^ permalink raw reply
* Re: [PATCH v2 00/17] tee: Use bus callbacks instead of driver callbacks
From: Alexandre Belloni @ 2025-12-18 13:53 UTC (permalink / raw)
To: Jens Wiklander
Cc: Uwe Kleine-König, Jonathan Corbet, Sumit Garg,
Olivia Mackall, Herbert Xu, Clément Léger,
Ard Biesheuvel, Maxime Coquelin, Alexandre Torgue, Sumit Garg,
Ilias Apalodimas, Jan Kiszka, Sudeep Holla, Christophe JAILLET,
Rafał Miłecki, Michael Chan, Pavan Chebbi,
James Bottomley, Jarkko Sakkinen, Mimi Zohar, David Howells,
Paul Moore, James Morris, Serge E. Hallyn, Peter Huewe, op-tee,
linux-kernel, linux-doc, linux-crypto, linux-rtc, linux-efi,
linux-stm32, linux-arm-kernel, Cristian Marussi, arm-scmi,
linux-mips, netdev, linux-integrity, keyrings,
linux-security-module, Jason Gunthorpe
In-Reply-To: <CAHUa44FrDZbvRvfN8obf80_k=Eqxe9YxHpjaE5jU7nkxPUwfag@mail.gmail.com>
On 18/12/2025 08:21:27+0100, Jens Wiklander wrote:
> Hi,
>
> On Mon, Dec 15, 2025 at 3:17 PM Uwe Kleine-König
> <u.kleine-koenig@baylibre.com> wrote:
> >
> > Hello,
> >
> > the objective of this series is to make tee driver stop using callbacks
> > in struct device_driver. These were superseded by bus methods in 2006
> > (commit 594c8281f905 ("[PATCH] Add bus_type probe, remove, shutdown
> > methods.")) but nobody cared to convert all subsystems accordingly.
> >
> > Here the tee drivers are converted. The first commit is somewhat
> > unrelated, but simplifies the conversion (and the drivers). It
> > introduces driver registration helpers that care about setting the bus
> > and owner. (The latter is missing in all drivers, so by using these
> > helpers the drivers become more correct.)
> >
> > v1 of this series is available at
> > https://lore.kernel.org/all/cover.1765472125.git.u.kleine-koenig@baylibre.com
> >
> > Changes since v1:
> >
> > - rebase to v6.19-rc1 (no conflicts)
> > - add tags received so far
> > - fix whitespace issues pointed out by Sumit Garg
> > - fix shutdown callback to shutdown and not remove
> >
> > As already noted in v1's cover letter, this series should go in during a
> > single merge window as there are runtime warnings when the series is
> > only applied partially. Sumit Garg suggested to apply the whole series
> > via Jens Wiklander's tree.
> > If this is done the dependencies in this series are honored, in case the
> > plan changes: Patches #4 - #17 depend on the first two.
> >
> > Note this series is only build tested.
> >
> > Uwe Kleine-König (17):
> > tee: Add some helpers to reduce boilerplate for tee client drivers
> > tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
> > tee: Adapt documentation to cover recent additions
> > hwrng: optee - Make use of module_tee_client_driver()
> > hwrng: optee - Make use of tee bus methods
> > rtc: optee: Migrate to use tee specific driver registration function
> > rtc: optee: Make use of tee bus methods
> > efi: stmm: Make use of module_tee_client_driver()
> > efi: stmm: Make use of tee bus methods
> > firmware: arm_scmi: optee: Make use of module_tee_client_driver()
> > firmware: arm_scmi: Make use of tee bus methods
> > firmware: tee_bnxt: Make use of module_tee_client_driver()
> > firmware: tee_bnxt: Make use of tee bus methods
> > KEYS: trusted: Migrate to use tee specific driver registration
> > function
> > KEYS: trusted: Make use of tee bus methods
> > tpm/tpm_ftpm_tee: Make use of tee specific driver registration
> > tpm/tpm_ftpm_tee: Make use of tee bus methods
> >
> > Documentation/driver-api/tee.rst | 18 +----
> > drivers/char/hw_random/optee-rng.c | 26 ++----
> > drivers/char/tpm/tpm_ftpm_tee.c | 31 +++++---
> > drivers/firmware/arm_scmi/transports/optee.c | 32 +++-----
> > drivers/firmware/broadcom/tee_bnxt_fw.c | 30 ++-----
> > drivers/firmware/efi/stmm/tee_stmm_efi.c | 25 ++----
> > drivers/rtc/rtc-optee.c | 27 ++-----
> > drivers/tee/tee_core.c | 84 ++++++++++++++++++++
> > include/linux/tee_drv.h | 12 +++
> > security/keys/trusted-keys/trusted_tee.c | 17 ++--
> > 10 files changed, 164 insertions(+), 138 deletions(-)
> >
> > base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> > --
> > 2.47.3
> >
>
> Thank you for the nice cleanup, Uwe.
>
> I've applied patch 1-3 to the branch tee_bus_callback_for_6.20 in my
> tree at https://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee.git/
>
> The branch is based on v6.19-rc1, and I'll try to keep it stable for
> others to depend on, if needed. Let's see if we can agree on taking
> the remaining patches via that branch.
6 and 7 can go through your branch.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox