arm: socfpga: arria10: Enable and fix I2C support
Subsystems (2)
cover arm: socfpga: arria10: Enable and fix I2C support
From: Dinesh Maniyam <[email protected]>
This series enables I2C support on the Intel Arria 10 SoCDK and fixes two related issues observed when the I2C controller is actually used:
1. The Linux DTS sets i2c-scl-falling-time-ns to a value that the U-Boot designware_i2c driver cannot consume on Arria 10. Override it in the U-Boot SoC dtsi to the maximum value allowed by the HW spec so the driver computes correct timings.
2. The designware_i2c remove() callback disables l4_sp_clk, which is shared with several other peripherals on Arria 10/Cyclone V/etc. Disabling it on i2c removal corrupts those peripherals. Drop the clk_disable() call.
3. Enable CONFIG_SYS_I2C_DW (which selects DM_I2C) and CONFIG_CMD_I2C in socfpga_arria10_defconfig so the driver is actually built and exercised by U-Boot's CI.
The patches originate from the Altera SoCFPGA downstream tree and have been carried internally for several years. Tested on Arria 10 SoCDK (sdmmc boot variant); SPL/U-Boot build clean. 'make savedefconfig' shows no diff introduced by these patches.
Dinesh Maniyam (3):
arm: dts: a10: Correct i2c scl falling time
i2c: designware_i2c: Remove clk disabled codes
configs: socfpga_arria10_defconfig: Enable I2C as default
arch/arm/dts/socfpga_arria10_socdk-u-boot.dtsi | 5 +++++ configs/socfpga_arria10_defconfig | 2 ++ drivers/i2c/designware_i2c.c | 4 ---- 3 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.7
PATCH 1/3 arm: dts: a10: Correct i2c scl falling time
From: Dinesh Maniyam <[email protected]>
The value set for i2c-scl-falling-time-ns in Linux DTS is not compatible for the i2c driver in U-Boot. The value is updated to the max value specified in the HW spec.
--- arch/arm/dts/socfpga_arria10_socdk-u-boot.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/dts/socfpga_arria10_socdk-u-boot.dtsi +5 -0
@@ -12,6 +12,11 @@ }; }; +&i2c1 { + /* Max value set according to HW spec */ + i2c-scl-falling-time-ns = <300>; +}; + &uart1 { bootph-all; };
Signature · 1 line
2.43.7
PATCH 2/3 i2c: designware_i2c: Remove clk disabled codes
In reply to [email protected]From: Dinesh Maniyam <[email protected]>
l4_sp_clk is disabled when i2c device is removed, this would causing unexpected failing behavior for other peripherals which are still running with l4_sp_clk. The patch removes the codes implementation for disabling the lp_spl_clk.
--- drivers/i2c/designware_i2c.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/i2c/designware_i2c.c +0 -4
@@ -807,10 +807,6 @@ int designware_i2c_remove(struct udevice *dev) {struct dw_i2c *priv =dev_get_priv (dev); -#if CONFIG_IS_ENABLED (CLK ) -clk_disable (&priv->clk); -#endif -return reset_release_bulk (&priv->resets); }
Signature · 1 line
2.43.7
PATCH 3/3 configs: socfpga_arria10_defconfig: Enable I2C as default
In reply to [email protected]From: Dinesh Maniyam <[email protected]>
Enable I2C as default for Arria 10 defconfig so that this driver can be covered by U-Boot's regtest.
--- configs/socfpga_arria10_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/socfpga_arria10_defconfig +2 -0
@@ -41,6 +41,7 @@ CONFIG_SYS_MAXARGS=32 CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y CONFIG_CMD_CACHE=y
@@ -52,6 +53,7 @@ CONFIG_ENV_RELOC_GD_ENV_ADDR=y CONFIG_VERSION_VARIABLE=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_DWAPB_GPIO=y +CONFIG_SYS_I2C_DW=y CONFIG_FS_LOADER=y CONFIG_SPL_FS_LOADER=y CONFIG_SYS_MMC_MAX_BLK_COUNT=256
Signature · 1 line
2.43.7
Re: [PATCH 1/3] arm: dts: a10: Correct i2c scl falling time
In reply to [email protected]Hello Dinesh,
Quoted 11 lines · On 29.04.26 07:11, [email protected] wrote:
From: Dinesh Maniyam <[email protected]>
The value set for i2c-scl-falling-time-ns in Linux DTS is not compatible for the i2c driver in U-Boot. The value is updated to the max value specified in the HW spec.
Signed-off-by Tien Fong Chee <[email protected]>Signed-off-by Dinesh Maniyam <[email protected]>--- arch/arm/dts/socfpga_arria10_socdk-u-boot.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
Thanks!
bye,
Heiko
Quoted 18 lines
arch/arm/dts/socfpga_arria10_socdk-u-boot.dtsi +5
-0@@ -12,6 +12,11 @@ }; }; +&i2c1 { + /* Max value set according to HW spec */ + i2c-scl-falling-time-ns = <300>; +}; + &uart1 { bootph-all; };
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic
Re: [PATCH 2/3] i2c: designware_i2c: Remove clk disabled codes
In reply to [email protected]Hello Dinesh,
Quoted 18 lines · On 29.04.26 07:11, [email protected] wrote:
From: Dinesh Maniyam <[email protected]>
l4_sp_clkis disabled when i2c device is removed, this would causing unexpected failing behavior for other peripherals which are still running withl4_sp_clk. The patch removes the codes implementation for disabling thelp_spl_clk.Signed-off-by Tien Fong Chee <[email protected]>Signed-off-by Dinesh Maniyam <[email protected]>--- drivers/i2c/designware_i2c.c | 4 ---- 1 file changed, 4 deletions(-)drivers/i2c/designware_i2c.c +0
-0
drivers/i2c/designware_i2c.c int designware_i2c_remove(struct udevice *dev) · line 812
Quoted 6 lines
drivers/i2c/designware_i2c.c +0
-3@@ -807,10 +807,6 @@ int designware_i2c_remove(struct udevice *dev) {struct dw_i2c *priv =dev_get_priv (dev); -#if CONFIG_IS_ENABLED (CLK ) -clk_disable (&priv->clk); -#endif
Hmm... clock framework should have a counter how many times clock is enabled... with your patch, clock never gets disabled...
bye,
Heiko
Quoted 5 lines
drivers/i2c/designware_i2c.c +0
-1-return reset_release_bulk (&priv->resets); }
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic
Re: [PATCH 3/3] configs: socfpga_arria10_defconfig: Enable I2C as default
In reply to [email protected]Hello Dinesh,
Quoted 10 lines · On 29.04.26 07:11, [email protected] wrote:
From: Dinesh Maniyam <[email protected]>
Enable I2C as default for Arria 10 defconfig so that this driver can be covered by U-Boot's regtest.
Signed-off-by Tien Fong Chee <[email protected]>Signed-off-by Dinesh Maniyam <[email protected]>--- configs/socfpga_arria10_defconfig | 2 ++ 1 file changed, 2 insertions(+)
Thanks!
bye,
Heiko
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic
Re: [PATCH 2/3] i2c: designware_i2c: Remove clk disabled codes
In reply to Heiko SchocherHi Heiko,
Thanks for the review.
Quoted 33 lines · Heiko Schocher
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Hello Dinesh,
Quoted 18 lines · On 29.04.26 07:11, [email protected] wrote:
From: Dinesh Maniyam <[email protected]>
l4_sp_clkis disabled when i2c device is removed, this would causing unexpected failing behavior for other peripherals which are still running withl4_sp_clk. The patch removes the codes implementation for disabling thelp_spl_clk.Signed-off-by Tien Fong Chee <[email protected]>Signed-off-by Dinesh Maniyam <[email protected]>--- drivers/i2c/designware_i2c.c | 4 ---- 1 file changed, 4 deletions(-)drivers/i2c/designware_i2c.c +0
-0drivers/i2c/designware_i2c.c int designware_i2c_remove(struct udevice *dev) · line 812
Quoted 6 lines
drivers/i2c/designware_i2c.c +0
-3@@ -807,10 +807,6 @@ int designware_i2c_remove(struct udevice *dev) {struct dw_i2c *priv =dev_get_priv (dev); -#if CONFIG_IS_ENABLED (CLK ) -clk_disable (&priv->clk); -#endif Hmm... clock framework should have a counter how many times clock is enabled... with your patch, clock never gets disabled...
Quoted 2 lines
bye,
Heiko
You're right -- this patch is at the wrong layer. designware_i2c is a generic driver and disabling clk_disable() globally affects every SoCFPGA / x86 / RISC-V user of it. The asymmetry vs. clk_enable() in designware_i2c_of_to_plat() is also a refcount leak by construction.
I'll send v2 for this patch series with the fix.
Regards,
Dinesh
Quoted 12 lines
drivers/i2c/designware_i2c.c int designware_i2c_remove(struct udevice *dev) · line 812
Quoted 5 lines
drivers/i2c/designware_i2c.c +0
-1-return reset_release_bulk (&priv->resets); }--
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschäftsführer : Stefano Babic