* [PATCH 0/4] SPMI patches for the merge window
@ 2025-05-18 3:23 Stephen Boyd
2025-05-18 3:23 ` [PATCH 1/4] spmi: Only use Hikey 970 SPMI controller driver when ARM64 Stephen Boyd
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Stephen Boyd @ 2025-05-18 3:23 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, patches
Hi Greg,
These are the SPMI patches for the next merge window.
- A new SPMI driver for Apple SoCs
- Limit Hikey 970 SPMI Kconfig to arm64
- Use irq_domain_create_tree() where appropriate
Jean-Francois Bortolotti (1):
spmi: add a spmi driver for Apple SoC
Jiri Slaby (SUSE) (1):
irqdomain: spmi: Switch to irq_domain_create_tree()
Sasha Finkelstein (1):
dt-bindings: spmi: Add Apple SPMI controller
WangYuli (1):
spmi: Only use Hikey 970 SPMI controller driver when ARM64
.../devicetree/bindings/spmi/apple,spmi.yaml | 49 +++++
MAINTAINERS | 2 +
drivers/spmi/Kconfig | 9 +
drivers/spmi/Makefile | 1 +
drivers/spmi/spmi-apple-controller.c | 168 ++++++++++++++++++
drivers/spmi/spmi-pmic-arb.c | 2 +-
6 files changed, 230 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/spmi/apple,spmi.yaml
create mode 100644 drivers/spmi/spmi-apple-controller.c
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] spmi: Only use Hikey 970 SPMI controller driver when ARM64
2025-05-18 3:23 [PATCH 0/4] SPMI patches for the merge window Stephen Boyd
@ 2025-05-18 3:23 ` Stephen Boyd
2025-05-18 3:23 ` [PATCH 2/4] dt-bindings: spmi: Add Apple SPMI controller Stephen Boyd
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2025-05-18 3:23 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: WangYuli, linux-kernel, patches, Wentao Guan
From: WangYuli <wangyuli@uniontech.com>
SPMI_HISI3670, the Hikey 970 SPMI controller driver, is only
required to use the Kirin 970 SPMI bus.
And the Kirin 970 is an ARM64-based SoC, it cannot be used on
platforms of other architectures.
Link: https://lore.kernel.org/all/b4810f476e41e7de4efdf28b42472ae4ffe7defe.1597647359.git.mchehab+huawei@kernel.org/
Reported-by: Wentao Guan <guanwentao@uniontech.com>
Closes: https://github.com/deepin-community/kernel/pull/604
Signed-off-by: WangYuli <wangyuli@uniontech.com>
Link: https://lore.kernel.org/r/23BAA675A75EF4F5+20250218050552.57711-1-wangyuli@uniontech.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
drivers/spmi/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/spmi/Kconfig b/drivers/spmi/Kconfig
index 737802046314..4ee496491c74 100644
--- a/drivers/spmi/Kconfig
+++ b/drivers/spmi/Kconfig
@@ -14,6 +14,7 @@ if SPMI
config SPMI_HISI3670
tristate "Hisilicon 3670 SPMI Controller"
select IRQ_DOMAIN_HIERARCHY
+ depends on ARM64 || COMPILE_TEST
depends on HAS_IOMEM
help
If you say yes to this option, support will be included for the
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] dt-bindings: spmi: Add Apple SPMI controller
2025-05-18 3:23 [PATCH 0/4] SPMI patches for the merge window Stephen Boyd
2025-05-18 3:23 ` [PATCH 1/4] spmi: Only use Hikey 970 SPMI controller driver when ARM64 Stephen Boyd
@ 2025-05-18 3:23 ` Stephen Boyd
2025-05-18 3:23 ` [PATCH 3/4] spmi: add a spmi driver for Apple SoC Stephen Boyd
2025-05-18 3:23 ` [PATCH 4/4] irqdomain: spmi: Switch to irq_domain_create_tree() Stephen Boyd
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2025-05-18 3:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Sasha Finkelstein, linux-kernel, patches, Rob Herring (Arm),
Sven Peter, Neal Gompa
From: Sasha Finkelstein <fnkl.kernel@gmail.com>
Add bindings for the SPMI controller present on most Apple SoCs
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Link: https://lore.kernel.org/r/20250409-spmi-v4-1-eb81ecfd1f64@gmail.com
Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
.../devicetree/bindings/spmi/apple,spmi.yaml | 49 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 50 insertions(+)
create mode 100644 Documentation/devicetree/bindings/spmi/apple,spmi.yaml
diff --git a/Documentation/devicetree/bindings/spmi/apple,spmi.yaml b/Documentation/devicetree/bindings/spmi/apple,spmi.yaml
new file mode 100644
index 000000000000..16bd7eb2b7af
--- /dev/null
+++ b/Documentation/devicetree/bindings/spmi/apple,spmi.yaml
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spmi/apple,spmi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple SPMI controller
+
+maintainers:
+ - Sasha Finkelstein <fnkl.kernel@gmail.com>
+
+description: A SPMI controller present on most Apple SoCs
+
+allOf:
+ - $ref: spmi.yaml#
+
+properties:
+ compatible:
+ items:
+ - enum:
+ - apple,t8103-spmi
+ - apple,t6000-spmi
+ - apple,t8112-spmi
+ - const: apple,spmi
+
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/spmi/spmi.h>
+
+ spmi@920a1300 {
+ compatible = "apple,t6000-spmi", "apple,spmi";
+ reg = <0x920a1300 0x100>;
+ #address-cells = <2>;
+ #size-cells = <0>;
+
+ pmic@f {
+ reg = <0xf SPMI_USID>;
+ /* PMIC-specific properties */
+ };
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 96b827049501..5f348736ea0b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2282,6 +2282,7 @@ F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml
F: Documentation/devicetree/bindings/power/apple*
F: Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml
F: Documentation/devicetree/bindings/spi/apple,spi.yaml
+F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml
F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml
F: arch/arm64/boot/dts/apple/
F: drivers/bluetooth/hci_bcm4377.c
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] spmi: add a spmi driver for Apple SoC
2025-05-18 3:23 [PATCH 0/4] SPMI patches for the merge window Stephen Boyd
2025-05-18 3:23 ` [PATCH 1/4] spmi: Only use Hikey 970 SPMI controller driver when ARM64 Stephen Boyd
2025-05-18 3:23 ` [PATCH 2/4] dt-bindings: spmi: Add Apple SPMI controller Stephen Boyd
@ 2025-05-18 3:23 ` Stephen Boyd
2025-05-18 3:23 ` [PATCH 4/4] irqdomain: spmi: Switch to irq_domain_create_tree() Stephen Boyd
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2025-05-18 3:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jean-Francois Bortolotti, linux-kernel, patches, Sven Peter,
Alyssa Rosenzweig, Sasha Finkelstein, Neal Gompa
From: Jean-Francois Bortolotti <jeff@borto.fr>
The connected PMU contains several useful nvmem cells such as RTC offset,
boot failure counters, reboot/shutdown selector, and a few others.
In addition M3+ machines have their USB-PD controller connected via SPMI.
Signed-off-by: Jean-Francois Bortolotti <jeff@borto.fr>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Co-developed-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Link: https://lore.kernel.org/r/20250409-spmi-v4-2-eb81ecfd1f64@gmail.com
Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
MAINTAINERS | 1 +
drivers/spmi/Kconfig | 8 ++
drivers/spmi/Makefile | 1 +
drivers/spmi/spmi-apple-controller.c | 168 +++++++++++++++++++++++++++
4 files changed, 178 insertions(+)
create mode 100644 drivers/spmi/spmi-apple-controller.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 5f348736ea0b..2bf1c547bd0a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2302,6 +2302,7 @@ F: drivers/pinctrl/pinctrl-apple-gpio.c
F: drivers/pwm/pwm-apple.c
F: drivers/soc/apple/*
F: drivers/spi/spi-apple.c
+F: drivers/spmi/spmi-apple-controller.c
F: drivers/video/backlight/apple_dwi_bl.c
F: drivers/watchdog/apple_wdt.c
F: include/dt-bindings/interrupt-controller/apple-aic.h
diff --git a/drivers/spmi/Kconfig b/drivers/spmi/Kconfig
index 4ee496491c74..a80cf4047b86 100644
--- a/drivers/spmi/Kconfig
+++ b/drivers/spmi/Kconfig
@@ -11,6 +11,14 @@ menuconfig SPMI
if SPMI
+config SPMI_APPLE
+ tristate "Apple SoC SPMI Controller platform driver"
+ depends on ARCH_APPLE || COMPILE_TEST
+ help
+ If you say yes to this option, support will be included for the
+ SPMI controller present on many Apple SoCs, including the
+ t8103 (M1) and t600x (M1 Pro/Max).
+
config SPMI_HISI3670
tristate "Hisilicon 3670 SPMI Controller"
select IRQ_DOMAIN_HIERARCHY
diff --git a/drivers/spmi/Makefile b/drivers/spmi/Makefile
index 7f152167bb05..38ac635645ba 100644
--- a/drivers/spmi/Makefile
+++ b/drivers/spmi/Makefile
@@ -4,6 +4,7 @@
#
obj-$(CONFIG_SPMI) += spmi.o spmi-devres.o
+obj-$(CONFIG_SPMI_APPLE) += spmi-apple-controller.o
obj-$(CONFIG_SPMI_HISI3670) += hisi-spmi-controller.o
obj-$(CONFIG_SPMI_MSM_PMIC_ARB) += spmi-pmic-arb.o
obj-$(CONFIG_SPMI_MTK_PMIF) += spmi-mtk-pmif.o
diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c
new file mode 100644
index 000000000000..697b3e8bb023
--- /dev/null
+++ b/drivers/spmi/spmi-apple-controller.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Apple SoC SPMI device driver
+ *
+ * Copyright The Asahi Linux Contributors
+ *
+ * Inspired by:
+ * OpenBSD support Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
+ * Correllium support Copyright (C) 2021 Corellium LLC
+ * hisi-spmi-controller.c
+ * spmi-pmic-arb.c Copyright (c) 2021, The Linux Foundation.
+ */
+
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/spmi.h>
+
+/* SPMI Controller Registers */
+#define SPMI_STATUS_REG 0
+#define SPMI_CMD_REG 0x4
+#define SPMI_RSP_REG 0x8
+
+#define SPMI_RX_FIFO_EMPTY BIT(24)
+
+#define REG_POLL_INTERVAL_US 10000
+#define REG_POLL_TIMEOUT_US (REG_POLL_INTERVAL_US * 5)
+
+struct apple_spmi {
+ void __iomem *regs;
+};
+
+#define poll_reg(spmi, reg, val, cond) \
+ readl_poll_timeout((spmi)->regs + (reg), (val), (cond), \
+ REG_POLL_INTERVAL_US, REG_POLL_TIMEOUT_US)
+
+static inline u32 apple_spmi_pack_cmd(u8 opc, u8 sid, u16 saddr, size_t len)
+{
+ return opc | sid << 8 | saddr << 16 | (len - 1) | (1 << 15);
+}
+
+/* Wait for Rx FIFO to have something */
+static int apple_spmi_wait_rx_not_empty(struct spmi_controller *ctrl)
+{
+ struct apple_spmi *spmi = spmi_controller_get_drvdata(ctrl);
+ int ret;
+ u32 status;
+
+ ret = poll_reg(spmi, SPMI_STATUS_REG, status, !(status & SPMI_RX_FIFO_EMPTY));
+ if (ret) {
+ dev_err(&ctrl->dev,
+ "failed to wait for RX FIFO not empty\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int spmi_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
+ u16 saddr, u8 *buf, size_t len)
+{
+ struct apple_spmi *spmi = spmi_controller_get_drvdata(ctrl);
+ u32 spmi_cmd = apple_spmi_pack_cmd(opc, sid, saddr, len);
+ u32 rsp;
+ size_t len_read = 0;
+ u8 i;
+ int ret;
+
+ writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
+
+ ret = apple_spmi_wait_rx_not_empty(ctrl);
+ if (ret)
+ return ret;
+
+ /* Discard SPMI reply status */
+ readl(spmi->regs + SPMI_RSP_REG);
+
+ /* Read SPMI data reply */
+ while (len_read < len) {
+ rsp = readl(spmi->regs + SPMI_RSP_REG);
+ i = 0;
+ while ((len_read < len) && (i < 4)) {
+ buf[len_read++] = ((0xff << (8 * i)) & rsp) >> (8 * i);
+ i += 1;
+ }
+ }
+
+ return 0;
+}
+
+static int spmi_write_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
+ u16 saddr, const u8 *buf, size_t len)
+{
+ struct apple_spmi *spmi = spmi_controller_get_drvdata(ctrl);
+ u32 spmi_cmd = apple_spmi_pack_cmd(opc, sid, saddr, len);
+ size_t i = 0, j;
+ int ret;
+
+ writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
+
+ while (i < len) {
+ j = 0;
+ spmi_cmd = 0;
+ while ((j < 4) & (i < len))
+ spmi_cmd |= buf[i++] << (j++ * 8);
+
+ writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
+ }
+
+ ret = apple_spmi_wait_rx_not_empty(ctrl);
+ if (ret)
+ return ret;
+
+ /* Discard */
+ readl(spmi->regs + SPMI_RSP_REG);
+
+ return 0;
+}
+
+static int apple_spmi_probe(struct platform_device *pdev)
+{
+ struct apple_spmi *spmi;
+ struct spmi_controller *ctrl;
+ int ret;
+
+ ctrl = devm_spmi_controller_alloc(&pdev->dev, sizeof(*spmi));
+ if (IS_ERR(ctrl))
+ return -ENOMEM;
+
+ spmi = spmi_controller_get_drvdata(ctrl);
+
+ spmi->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(spmi->regs))
+ return PTR_ERR(spmi->regs);
+
+ ctrl->dev.of_node = pdev->dev.of_node;
+
+ ctrl->read_cmd = spmi_read_cmd;
+ ctrl->write_cmd = spmi_write_cmd;
+
+ ret = devm_spmi_controller_add(&pdev->dev, ctrl);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "spmi_controller_add failed\n");
+
+ return 0;
+}
+
+static const struct of_device_id apple_spmi_match_table[] = {
+ { .compatible = "apple,spmi", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, apple_spmi_match_table);
+
+static struct platform_driver apple_spmi_driver = {
+ .probe = apple_spmi_probe,
+ .driver = {
+ .name = "apple-spmi",
+ .of_match_table = apple_spmi_match_table,
+ },
+};
+module_platform_driver(apple_spmi_driver);
+
+MODULE_AUTHOR("Jean-Francois Bortolotti <jeff@borto.fr>");
+MODULE_DESCRIPTION("Apple SoC SPMI driver");
+MODULE_LICENSE("GPL");
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] irqdomain: spmi: Switch to irq_domain_create_tree()
2025-05-18 3:23 [PATCH 0/4] SPMI patches for the merge window Stephen Boyd
` (2 preceding siblings ...)
2025-05-18 3:23 ` [PATCH 3/4] spmi: add a spmi driver for Apple SoC Stephen Boyd
@ 2025-05-18 3:23 ` Stephen Boyd
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2025-05-18 3:23 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby (SUSE), linux-kernel, patches
From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
irq_domain_add_tree() is going away as being obsolete now. Switch to
the preferred irq_domain_create_tree(). That differs in the first
parameter: It takes more generic struct fwnode_handle instead of struct
device_node. Therefore, of_fwnode_handle() is added around the
parameter.
Note some of the users can likely use dev->fwnode directly instead of
indirect of_fwnode_handle(dev->of_node). But dev->fwnode is not
guaranteed to be set for all, so this has to be investigated on case to
case basis (by people who can actually test with the HW).
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250319092951.37667-37-jirislaby@kernel.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
drivers/spmi/spmi-pmic-arb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 5c058db21821..91581974ef84 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -1737,7 +1737,7 @@ static int spmi_pmic_arb_bus_init(struct platform_device *pdev,
dev_dbg(&pdev->dev, "adding irq domain for bus %d\n", bus_index);
- bus->domain = irq_domain_add_tree(node, &pmic_arb_irq_domain_ops, bus);
+ bus->domain = irq_domain_create_tree(of_fwnode_handle(node), &pmic_arb_irq_domain_ops, bus);
if (!bus->domain) {
dev_err(&pdev->dev, "unable to create irq_domain\n");
return -ENOMEM;
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-18 3:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-18 3:23 [PATCH 0/4] SPMI patches for the merge window Stephen Boyd
2025-05-18 3:23 ` [PATCH 1/4] spmi: Only use Hikey 970 SPMI controller driver when ARM64 Stephen Boyd
2025-05-18 3:23 ` [PATCH 2/4] dt-bindings: spmi: Add Apple SPMI controller Stephen Boyd
2025-05-18 3:23 ` [PATCH 3/4] spmi: add a spmi driver for Apple SoC Stephen Boyd
2025-05-18 3:23 ` [PATCH 4/4] irqdomain: spmi: Switch to irq_domain_create_tree() Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).