Driver for Apple SPMI controller
Subsystems (3)
cover Driver for Apple SPMI controller
Hi.
This patch series adds support for the SPMI controller persent in most Apple SoCs. The drivers for the attached PMU and subdevices will be in further patch series.
---
Jean-Francois Bortolotti (1):
spmi: add a spmi driver for Apple SoC
Sasha Finkelstein (2):
dt-bindings: spmi: Add Apple SPMI controller
arm64: dts: apple: Add SPMI controller nodes
.../devicetree/bindings/spmi/apple,spmi.yaml | 56 +++++++ MAINTAINERS | 2 + arch/arm64/boot/dts/apple/t600x-die0.dtsi | 7 + arch/arm64/boot/dts/apple/t8103.dtsi | 8 + arch/arm64/boot/dts/apple/t8112.dtsi | 8 + drivers/spmi/Kconfig | 8 + drivers/spmi/Makefile | 1 + drivers/spmi/spmi-apple-controller.c | 176 +++++++++++++++++++++ 8 files changed, 266 insertions(+)
---
base-commit: 48a5eed9ad584315c30ed35204510536235ce402
change-id: 20250304-spmi-6d3c24b9027a
PATCH 1/3 dt-bindings: spmi: Add Apple SPMI controller
From: Sasha Finkelstein <[email protected]>
Add bindings for the SPMI controller present on most Apple SoCs
--- .../devicetree/bindings/spmi/apple,spmi.yaml | 56 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 57 insertions(+)
Documentation/devicetree/bindings/spmi/apple,spmi.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# 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 <[email protected]> + +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 + +patternProperties: + "pmu@[0-9a-f]$": + type: object + + description: + PMIC properties, which are specific to the used SPMI PMIC device(s). + +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>; + + pmu@f { + reg = <0xf SPMI_USID>; + /* PMIC-specific properties */ + }; + };
MAINTAINERS +1 -0
@@ -2236,6 +2236,7 @@ F: Documentation/devicetree/bindings/pci/apple,pcie.yaml 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/spmi/apple,spmi.yaml F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml F: arch/arm64/boot/dts/apple/ F: drivers/bluetooth/hci_bcm4377.c
Signature · 1 line
2.48.1
PATCH 2/3 spmi: add a spmi driver for Apple SoC
In reply to Sasha FinkelsteinFrom: Jean-Francois Bortolotti <[email protected]>
--- MAINTAINERS | 1 + drivers/spmi/Kconfig | 8 ++ drivers/spmi/Makefile | 1 + drivers/spmi/spmi-apple-controller.c | 176 +++++++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+)
MAINTAINERS +1 -0
@@ -2254,6 +2254,7 @@ F: drivers/nvmem/apple-efuses.c F: drivers/pinctrl/pinctrl-apple-gpio.c F: drivers/pwm/pwm-apple.c F: drivers/soc/apple/* +F: drivers/spmi/spmi-apple-controller.c F: drivers/watchdog/apple_wdt.c F: include/dt-bindings/interrupt-controller/apple-aic.h F: include/dt-bindings/pinctrl/apple.h
drivers/spmi/Kconfig +8 -0
@@ -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
drivers/spmi/Makefile +1 -0
@@ -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
drivers/spmi/spmi-apple-controller.c new file +176 -0
176 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 3/3 arm64: dts: apple: Add SPMI controller nodes
In reply to Sasha FinkelsteinFrom: Sasha Finkelstein <[email protected]>
Add device tree entries for the SPMI controller
--- arch/arm64/boot/dts/apple/t600x-die0.dtsi | 7 +++++++ arch/arm64/boot/dts/apple/t8103.dtsi | 8 ++++++++ arch/arm64/boot/dts/apple/t8112.dtsi | 8 ++++++++ 3 files changed, 23 insertions(+)
arch/arm64/boot/dts/apple/t600x-die0.dtsi +7 -0
@@ -53,6 +53,13 @@ wdt: watchdog@2922b0000 { interrupts = <AIC_IRQ 0 631 IRQ_TYPE_LEVEL_HIGH>; }; + nub_spmi0: spmi@2920a1300 { + compatible = "apple,t6000-spmi", "apple,spmi"; + reg = <0x2 0x920a1300 0x0 0x100>; + #address-cells = <2>; + #size-cells = <0>; + }; + sio_dart_0: iommu@39b004000 { compatible = "apple,t6000-dart"; reg = <0x3 0x9b004000 0x0 0x4000>;
arch/arm64/boot/dts/apple/t8103.dtsi +8 -0
@@ -11,6 +11,7 @@ #include <dt-bindings/interrupt-controller/apple-aic.h> #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/pinctrl/apple.h> +#include <dt-bindings/spmi/spmi.h> / { compatible = "apple,t8103", "apple,arm-platform";
@@ -604,6 +605,13 @@ pcie_pins: pcie-pins { }; }; + nub_spmi: spmi@23d0d9300 { + compatible = "apple,t8103-spmi", "apple,spmi"; + reg = <0x2 0x3d0d9300 0x0 0x100>; + #address-cells = <2>; + #size-cells = <0>; + }; + pinctrl_nub: pinctrl@23d1f0000 { compatible = "apple,t8103-pinctrl", "apple,pinctrl"; reg = <0x2 0x3d1f0000 0x0 0x4000>;
arch/arm64/boot/dts/apple/t8112.dtsi +8 -0
@@ -641,6 +641,14 @@ pcie_pins: pcie-pins { }; }; + + nub_spmi: spmi@23d714000 { + compatible = "apple,t8112-spmi", "apple,spmi"; + reg = <0x2 0x3d714000 0x0 0x100>; + #address-cells = <2>; + #size-cells = <0>; + }; + pinctrl_nub: pinctrl@23d1f0000 { compatible = "apple,t8112-pinctrl", "apple,pinctrl"; reg = <0x2 0x3d1f0000 0x0 0x4000>;
Signature · 1 line
2.48.1
Re: [PATCH 1/3] dt-bindings: spmi: Add Apple SPMI controller
In reply to Sasha FinkelsteinQuoted 41 lines · On Wed, Mar 5, 2025 at 2:26 PM Sasha Finkelstein via B4 Relay…
From: Sasha Finkelstein <[email protected]>
Add bindings for the SPMI controller present on most Apple SoCs
Signed-off-by Sasha Finkelstein <[email protected]>--- .../devicetree/bindings/spmi/apple,spmi.yaml | 56 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 57 insertions(+)Documentation/devicetree/bindings/spmi/apple,spmi.yaml new file +24
-0@@ -0,0 +1,56 @@ +# 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 <[email protected]> + +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
Documentation/devicetree/bindings/spmi/apple,spmi.yaml line 34
Quoted 10 lines
Documentation/devicetree/bindings/spmi/apple,spmi.yaml new file +10
-0+ + reg: + maxItems: 1 + +required: + - compatible + - reg + +patternProperties: + "pmu@[0-9a-f]$":
Typically 'pmic' is the name used here. However, you should just drop this because spmi.yaml already defines child node structure.
With that,
Quoted 39 lines
Documentation/devicetree/bindings/spmi/apple,spmi.yaml new file +22
-0+ type: object + + description: + PMIC properties, which are specific to the used SPMI PMIC device(s). + +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>; + + pmu@f { + reg = <0xf SPMI_USID>; + /* PMIC-specific properties */ + }; + };MAINTAINERS +1
-1@@ -2236,6 +2236,7 @@ F: Documentation/devicetree/bindings/pci/apple,pcie.yaml 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/spmi/apple,spmi.yaml F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml F: arch/arm64/boot/dts/apple/ F: drivers/bluetooth/hci_bcm4377.c --2.48.1
Stephen Boyd
maintainerRe: [PATCH 2/3] spmi: add a spmi driver for Apple SoC
In reply to Sasha FinkelsteinQuoting Sasha Finkelstein via B4 Relay (2025-03-05 12:26:40)
Quoted 2 lines
From: Jean-Francois Bortolotti <[email protected]>
Please write some commit text explaining why this driver is important to review. Maybe it's necessary for something to work?
Quoted 7 lines
drivers/spmi/spmi-apple-controller.c new file +1
-0@@ -0,0 +1,176 @@ +// SPDX-License-Identifier: GPL-2.0
drivers/spmi/spmi-apple-controller.c line 11
Quoted 10 lines
drivers/spmi/spmi-apple-controller.c new file +10
-0+/* +* Apple SoC SPMI device driver +* +* Copyright The Asahi Linux Contributors +* +* Inspired by: +* OpenBSD support Copyright (c) 2021 Mark Kettenis <[email protected]> +* Correllium support Copyright (C) 2021 Corellium LLC +* hisi-spmi-controller.c +* spmi-pmic-ard.c Copyright (c) 2021, The Linux Foundation.
spmi-pmic-arb?
drivers/spmi/spmi-apple-controller.c line 18
Quoted 7 lines
drivers/spmi/spmi-apple-controller.c new file +7
-0+*/ + +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_platform.h>
Are these includes used? I think you need mod_devicetable.h
Quoted 20 lines
drivers/spmi/spmi-apple-controller.c new file +20
-0+#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 10000 +#define REG_POLL_TIMEOUT (REG_POLL_INTERVAL * 5) + +struct apple_spmi { +void __iomem *regs; +}; + +#define poll_reg (spmi, reg, val, cond) \ + readl_relaxed_poll_timeout((spmi)->regs + (reg), (val), (cond), \ + REG_POLL_INTERVAL, REG_POLL_TIMEOUT)
drivers/spmi/spmi-apple-controller.c line 48
Quoted 10 lines
drivers/spmi/spmi-apple-controller.c new file +10
-0+ +static inline u32 read_reg (struct apple_spmi *spmi,int offset) +{ +return readl_relaxed (spmi->regs + offset); +} + +static inline void write_reg (u32 value,struct apple_spmi *spmi,int offset) +{ +writel_relaxed (value, spmi->regs + offset); +}
I'm not a huge fan of these wrappers but OK. Why relaxed accessors?
drivers/spmi/spmi-apple-controller.c line 51
Quoted 3 lines
drivers/spmi/spmi-apple-controller.c new file +3
-0+ +static int spmi_read_cmd (struct spmi_controller *ctrl,u8 opc,u8 sid, +u16 saddr,u8 *__buf,size_t bc)
Drop the underscore because the variable 'buf' is never used.
drivers/spmi/spmi-apple-controller.c line 54
Quoted 3 lines
drivers/spmi/spmi-apple-controller.c new file +3
-0+{ +struct apple_spmi *spmi =spmi_controller_get_drvdata (ctrl); +u32 spmi_cmd = opc | sid <<8 | saddr <<16 | (bc -1 ) | (1 <<15 );
Can this be some function like apple_spmi_pack_cmd()? I suspect 'bc' is byte_count? Usually we just call that 'len'.
drivers/spmi/spmi-apple-controller.c line 57
Quoted 3 lines
drivers/spmi/spmi-apple-controller.c new file +3
-0+u32 rsp; +u32 status; +size_t len_to_read =0 ;
len_to_read would imply that it is non-zero to start. Maybe 'len_read' past tense, or decrement 'bc'.
drivers/spmi/spmi-apple-controller.c line 69
Quoted 12 lines
drivers/spmi/spmi-apple-controller.c new file +12
-0+u8 i; +int ret; + +write_reg (spmi_cmd, spmi,SPMI_CMD_REG ); + +/* Wait for Rx FIFO to have something */ + ret =poll_reg (spmi,SPMI_STATUS_REG , status, !(status &SPMI_RX_FIFO_EMPTY )); +if (ret) { +dev_err (&ctrl->dev, +"%s:Failed to wait for RX FIFO not empty\n" , __func__); +return ret; + }
This chunk is the same. Maybe have apple_spmi_wait_for_rx_fifo() that does everything including the error message?
drivers/spmi/spmi-apple-controller.c line 82
Quoted 13 lines
drivers/spmi/spmi-apple-controller.c new file +13
-0+ +/* Discard SPMI reply status */ +read_reg (spmi,SPMI_RSP_REG ); + +/* Read SPMI data reply */ +while (len_to_read < bc) { + rsp =read_reg (spmi,SPMI_RSP_REG ); + i =0 ; +while ((len_to_read < bc) && (i <4 )) { + __buf[len_to_read++] = ((0xff << (8 * i)) & rsp) >> + (8 * i); + i +=1 ; + }
Is this ioread32_rep()?
Quoted 11 lines
drivers/spmi/spmi-apple-controller.c new file +11
-0+ } + +return 0 ; +} + +static int spmi_write_cmd (struct spmi_controller *ctrl,u8 opc,u8 sid, +u16 saddr,const u8 *__buf,size_t bc) +{ +struct apple_spmi *spmi =spmi_controller_get_drvdata (ctrl); +u32 spmi_cmd = opc | sid <<8 | saddr <<16 | (bc -1 ) | (1 <<15 ); +u32 status;
drivers/spmi/spmi-apple-controller.c line 103
Quoted 10 lines
drivers/spmi/spmi-apple-controller.c new file +10
-0+size_t i =0 , j; +int ret; + +write_reg (spmi_cmd, spmi,SPMI_CMD_REG ); + +while (i < bc) { + j =0 ; + spmi_cmd =0 ; +while ((j <4 ) & (i < bc)) + spmi_cmd |= __buf[i++] << (j++ *8 );
Is this iowrite32_rep()? Perhaps unaligned sizes have to be dealt with, but otherwise I suspect it would be more efficient to use iowrite32_rep() until the number of bytes is less than 4 and then do the one extra pack.
drivers/spmi/spmi-apple-controller.c line 112
Quoted 9 lines
drivers/spmi/spmi-apple-controller.c new file +9
-0+ +write_reg (spmi_cmd, spmi,SPMI_CMD_REG ); + } + +/* Wait for Rx FIFO to have something */ + ret =poll_reg (spmi,SPMI_STATUS_REG , status, !(status &SPMI_RX_FIFO_EMPTY )); +if (ret) { +dev_err (&ctrl->dev, +"%s:Failed to wait for RX FIFO not empty\n" , __func__);
^
Please put a space after ---|
Quoted 9 lines
drivers/spmi/spmi-apple-controller.c new file +9
-0+return ret; + } + +/* Discard */ +read_reg (spmi,SPMI_RSP_REG ); + +return 0 ; +} +
drivers/spmi/spmi-apple-controller.c line 131
Quoted 10 lines
drivers/spmi/spmi-apple-controller.c new file +10
-0+static int spmi_controller_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)) { +dev_err_probe (&pdev->dev,PTR_ERR (ctrl), +"Can't allocate spmi_controller data\n" );
This is likely redundant given that the spmi core API prints errors. I could see a patch that moves to dev_err_probe() there.
drivers/spmi/spmi-apple-controller.c line 137
Quoted 6 lines
drivers/spmi/spmi-apple-controller.c new file +6
-0+return -ENOMEM ; + } + + spmi =spmi_controller_get_drvdata (ctrl); + + spmi->regs =devm_platform_ioremap_resource (pdev,0 );
This already prints an error message so the dev_err_probe() later is redundant. Please remove.
drivers/spmi/spmi-apple-controller.c line 144
Quoted 7 lines
drivers/spmi/spmi-apple-controller.c new file +7
-0+if (IS_ERR (spmi->regs)) { +dev_err_probe (&pdev->dev,PTR_ERR (spmi->regs), +"Can't get ioremap regs\n" ); +return PTR_ERR (spmi->regs); + } + + ctrl->dev.of_node =of_node_get (pdev->dev.of_node);
Drop the of_node_get(), especially because it never gets put.
drivers/spmi/spmi-apple-controller.c line 152
Quoted 8 lines
drivers/spmi/spmi-apple-controller.c new file +8
-0+ + ctrl->read_cmd = spmi_read_cmd; + ctrl->write_cmd = spmi_write_cmd; + + ret =devm_spmi_controller_add (&pdev->dev, ctrl); +if (ret) { +dev_err (&pdev->dev, +"spmi_controller_add failed with error %d!\n" , ret);
Use 'return dev_err_probe()'?
drivers/spmi/spmi-apple-controller.c line 165
Quoted 13 lines
drivers/spmi/spmi-apple-controller.c new file +13
-0+return ret; + } + +return 0 ; +} + +static const struct of_device_id spmi_controller_match_table[] = { + { .compatible ="apple,spmi" , }, + {} +}; +MODULE_DEVICE_TABLE (of, spmi_controller_match_table); + +static struct platform_driver spmi_controller_driver = {
How about apple_spmi_driver?
drivers/spmi/spmi-apple-controller.c line 166
Quoted 1 line
drivers/spmi/spmi-apple-controller.c new file +1
-0+ .probe = spmi_controller_probe,
And apple_spmi_probe?
drivers/spmi/spmi-apple-controller.c line 169
Quoted 3 lines
drivers/spmi/spmi-apple-controller.c new file +3
-0+ .driver = { + .name = "apple-spmi", + .of_match_table = spmi_controller_match_table,
And apple_spmi_match_table?
Quoted 3 lines
drivers/spmi/spmi-apple-controller.c new file +3
-0+ }, +}; +module_platform_driver (spmi_controller_driver);
Re: [PATCH 3/3] arm64: dts: apple: Add SPMI controller nodes
In reply to Sasha FinkelsteinSasha Finkelstein via B4 Relay 於 2025/3/6 凌晨4:26 寫道:
Quoted 65 lines
From: Sasha Finkelstein <[email protected]>
Add device tree entries for the SPMI controller
Signed-off-by Sasha Finkelstein <[email protected]>--- arch/arm64/boot/dts/apple/t600x-die0.dtsi | 7 +++++++ arch/arm64/boot/dts/apple/t8103.dtsi | 8 ++++++++ arch/arm64/boot/dts/apple/t8112.dtsi | 8 ++++++++ 3 files changed, 23 insertions(+)arch/arm64/boot/dts/apple/t600x-die0.dtsi +7
-0@@ -53,6 +53,13 @@ wdt: watchdog@2922b0000 { interrupts = <AIC_IRQ 0 631 IRQ_TYPE_LEVEL_HIGH>; }; + nub_spmi0: spmi@2920a1300 { + compatible = "apple,t6000-spmi", "apple,spmi"; + reg = <0x2 0x920a1300 0x0 0x100>; + #address-cells = <2>; + #size-cells = <0>; + }; + sio_dart_0: iommu@39b004000 { compatible = "apple,t6000-dart"; reg = <0x3 0x9b004000 0x0 0x4000>;arch/arm64/boot/dts/apple/t8103.dtsi +8
-0@@ -11,6 +11,7 @@ #include <dt-bindings/interrupt-controller/apple-aic.h> #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/pinctrl/apple.h> +#include <dt-bindings/spmi/spmi.h> / { compatible = "apple,t8103", "apple,arm-platform";@@ -604,6 +605,13 @@ pcie_pins: pcie-pins { }; }; + nub_spmi: spmi@23d0d9300 { + compatible = "apple,t8103-spmi", "apple,spmi"; + reg = <0x2 0x3d0d9300 0x0 0x100>; + #address-cells = <2>; + #size-cells = <0>; + }; + pinctrl_nub: pinctrl@23d1f0000 { compatible = "apple,t8103-pinctrl", "apple,pinctrl"; reg = <0x2 0x3d1f0000 0x0 0x4000>;arch/arm64/boot/dts/apple/t8112.dtsi +1
-0@@ -641,6 +641,14 @@ pcie_pins: pcie-pins { }; }; +
arch/arm64/boot/dts/apple/t8112.dtsi pcie_pins: pcie-pins { · line 654
Quoted 10 lines
arch/arm64/boot/dts/apple/t8112.dtsi +7
-0+ nub_spmi: spmi@23d714000 { + compatible = "apple,t8112-spmi", "apple,spmi"; + reg = <0x2 0x3d714000 0x0 0x100>; + #address-cells = <2>; + #size-cells = <0>; + }; + pinctrl_nub: pinctrl@23d1f0000 { compatible = "apple,t8112-pinctrl", "apple,pinctrl"; reg = <0x2 0x3d1f0000 0x0 0x4000>;
Re: [PATCH 2/3] spmi: add a spmi driver for Apple SoC
In reply to Stephen BoydQuoted 13 lines · Stephen Boyd
Quoting Sasha Finkelstein via B4 Relay (2025-03-05 12:26:40)
drivers/spmi/spmi-apple-controller.c line 82
Quoted 8 lines
drivers/spmi/spmi-apple-controller.c new file +8
-0+while (len_to_read < bc) { + rsp =read_reg (spmi,SPMI_RSP_REG ); + i =0 ; +while ((len_to_read < bc) && (i <4 )) { + __buf[len_to_read++] = ((0xff << (8 * i)) & rsp) >> + (8 * i); + i +=1 ; + }Is this
ioread32_rep()?
[...]
Quoted 10 lines
drivers/spmi/spmi-apple-controller.c line 103
Quoted 5 lines
drivers/spmi/spmi-apple-controller.c new file +5
-0+while (i < bc) { + j =0 ; + spmi_cmd =0 ; +while ((j <4 ) & (i < bc)) + spmi_cmd |= __buf[i++] << (j++ *8 );Is this
iowrite32_rep()? Perhaps unaligned sizes have to be dealt with, but otherwise I suspect it would be more efficient to useiowrite32_rep()until the number of bytes is less than 4 and then do the one extra pack.
I think it would be better to leave them open-coded, io{read,write}32_rep casts the buffer to u32 and accesses it that way, probably resulting in unaligned accesses, and we are on arm64.