Add ACPI binding to Rockchip RK3xxx I2C bus
Subsystems (3)
v2 cover Add ACPI binding to Rockchip RK3xxx I2C bus
Hi,
This is a second version of the patch that I submitted a few weeks ago for adding an ACPI binding for I2C bringup on the Rockchip RK3xxx (specifically, RK3588) platforms for compatibility with the newfangled TianoCore EDK2 firmwares. This was previously discussed here:
https://lore.kernel.org/linux-kernel/[email protected]/
After some convo with the maintainer of the firmware, it was suggested I should have a kernel patch ready and approvable here before he can amend the ACPI tables in it. The following patch accepts an ACPI table entry for the I2C busses that looks like this:
Device (I2Cx) {
Name (_HID, "RKCP3001")
Name (_CID, "PRP0001")
Name (_UID, x)
Name (_CCA, 0) Method (_CRS, 0x0, Serialized) {
Name (RBUF, ResourceTemplate() {
Memory32Fixed (ReadWrite, 0xfea90000, 0x1000)
Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 350 }
ClockInput (198000000, 1, Hz, Fixed, "\\_SB_.CRU_", PCLK_I2Cx)
ClockInput (198000000, 1, Hz, Fixed, "\\_SB_.CRU_", BCLK_I2Cx)
})
Return (RBUF)
}
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package (2) { "compatible", Package (2) { "rockchip,rk3588-i2c", "rockchip,rk3399-i2c" } },
Package (2) { "i2c,clk-rate", 198000000 },
Package (2) { "rockchip,bclk", 198000000 },
Package (2) { "#address-cells", 1 },
Package (2) { "#size-cells", 0 },
}
})}
where "x" above in the name, _UID, and bindings should be replaced with the bus number (0..8). There was some debate about how to specify the clock rates in the first proposed version of this patch - in particular, regarding the inclusion of the "i2c,clk-rate" and "rockchip,bclk" settings in the _DSD section above. It was determined through correspondence with the firmware team that the reason for the inclusion of these settings was for compatibility with Microsoft Windows, but the kernel team here suggested it would be better to use ClockInput bindings, introduced as of ACPI 6.5. Hence, this patch is based on the assumption such bindings are available and is designed to fetch the clock rates from them. Note how the above example maintains both methods of specifying rates in parallel; this is also documented in the patch and it is noted that the _DSD settings should NOT be used in the kernel. The code to use ClockInput bindings is based off a base patch suggested by Niyas Sait, as in the linked thread.
---
Documentation/firmware-guide/acpi/dsd/soc/general.rst | 32 +++++++++ Documentation/firmware-guide/acpi/dsd/soc/soc-i2c.rst | 59 +++++++++++++++++ drivers/acpi/Makefile | 1 + drivers/acpi/acpi_clk.c | 93 +++++++++++++++++++++++++++ drivers/i2c/busses/i2c-rk3x.c | 79 ++++++++++++++++++++--- include/linux/acpi.h | 8 +++ 6 files changed, 262 insertions(+), 10 deletions(-)
Documentation/firmware-guide/acpi/dsd/soc/general.rst new file +32 -0
@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================================== +System-on-Chip (SoC) facility descriptions +========================================== + +These documents describe how to create ACPI profiles for devices composed into +system-on-chip (SoC) architectures. Currently, we only describe the options +availed in the _DSD block for select platforms; other considerations are not +yet applied. The inspiration for these documents are based around the advent +(as of March 2024) of hefty, non-Apple ARM SoC systems such as the Rockchip +RK3588 and newer chips that have desktop-like performance and thus are prime +candidates for a UEFI-based desktop-like boot system with the goal being to +deliver the same user-friendly ease of loading operating systems as on the +Intel x86 sphere. Open-source UEFI-based firmware engines, such as TianoCore +[1], mean it is possible on such platforms for the open-source developer to +control both firmware and kernel simultaneously, which is not the case for +the situation with Intel-based PC boards where boards are provided with pre- +baked, vendor-selected and opaque firmwares. + +The description of ACPI usage here is not meant to suggest that ACPI replace +Device Tree altogether for such SoCs; rather, we recognize that given they +often will have a variety of applications that may include embedded usage where +that more hard-wired boot loader setups such as U-Boot still shine, the +maintenance of ACPI and DTB-based configuration options should be in parallel, +and it may be possible for the same firmware to deploy both options. + +References +========== + +[1] EDK2-RK3588 port of TianoCore EDK2 firmware. + https://github.com/edk2-porting/edk2-rk3588
Documentation/firmware-guide/acpi/dsd/soc/soc-i2c.rst new file +59 -0
59 lines not on this page · raw message
drivers/acpi/Makefile +1 -0
@@ -48,6 +48,7 @@ acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o acpi-$(CONFIG_PCI) += acpi_lpss.o acpi-y += acpi_apd.o +acpi-y += acpi_clk.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o acpi-y += power.o
drivers/acpi/acpi_clk.c new file +93 -0
93 lines not on this page · raw message
drivers/i2c/busses/i2c-rk3x.c +69 -10
122 lines not on this page · raw message
include/linux/acpi.h +8 -0
@@ -32,6 +32,7 @@ struct irq_domain_ops;#include <linux/module.h> #include <linux/mutex.h> #include <linux/fw_table.h> +#include <linux/clk-provider.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -1569,4 +1570,11 @@ static inline bool acpi_node_backed_by_real_pxm(int nid) }#endif +/* Clock support */ + +#ifdef CONFIG_ACPI +struct clk *acpi_clk_register (struct acpi_device *adev,int index, +const char *name); +#endif +#endif /*_LINUX_ACPI_H*/