[PATCH v4] i2c: add support for the MT7621 I2C controller
Heiko Schocher
hs at nabladev.com
Thu Oct 30 13:05:53 CET 2025
Hello Justin,
On 27.10.25 14:09, Justin Swartz wrote:
> This commit introduces a port of the Linux kernel's driver for the
> Mediatek's MT7621 I2C controller.
>
> The port was undertaken as the existing driver intended for Mediatek
> I2C controllers (mtk_i2c.c) is not compatible with the MT7621.
>
> To use the driver:
>
> 1. Ensure that the mode of the i2c pin group is
> configured for "i2c" rather than "gpio".
>
> 2. Delete the existing (bitbanged) i2c node from
> arch/mips/dts/mt7621.dtsi, or specify:
>
> /delete-node/ &i2c;
>
> 3. Declare:
>
> i2c: i2c at 1e000900 {
> compatible = "mediatek,mt7621-i2c";
> reg = <0x1e000900 0x100>;
>
> clocks = <&clk50m>;
> clock-names = "sys_clock";
>
> resets = <&rstctrl RST_I2C>;
> reset-names = "i2c_reset";
>
> pinctrl-names = "default";
> pinctrl-0 = <&i2c_pins>;
>
> #address-cells = <1>;
> #size-cells = <0>;
> status = "okay";
> };
>
> Signed-off-by: Justin Swartz <justin.swartz at risingedge.co.za>
> ---
>
> Notes:
> [PATCH v4]
>
> - Fix style and whitespace issues to appease checkpatch.pl
> - Include time.h (instead of common.h) for get_timer()
> - Replace mt7621_i2c_check_ack()'s MMIO register access,
> via a volatile pointer, with readl() macro expansion.
>
> [PATCH v3]
>
> - Add an empty line between variable declaration and code to
> functions that did not have this separation.
>
> - Condense multi-line closing brace / else / opening brace
> sequences into single lines consisting of "} else {" instead.
>
> - Relocate mt7621_i2c_check_ack()'s I2C_M_IGNORE_NAK flag check
> to just after the last variable declaration.
>
> [PATCH v2]
>
> - Add "REG_" prefix to I2C (Serial Master 0) register definitions.
> - Remove unused "PINT" (Peripheral Interrupt) register definitions.
> - Adjust function definition style.
>
> - Refactor mt7621_i2c_check_ack() to accept the number of bytes
> expected to have been acknowledged, instead of accepting a
> literal value (which represents the acknowledgement status of
> (up to) 8 bytes, encoded as 8 independent bit values) expected
> in the SM0_ACK field (bits 23:16) of the SM0CTL1 register.
>
> drivers/i2c/Kconfig | 7 +
> drivers/i2c/Makefile | 1 +
> drivers/i2c/mt7621_i2c.c | 374 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 382 insertions(+)
> create mode 100644 drivers/i2c/mt7621_i2c.c
applied to u-boot-i2c.git
Thanks!
bye,
Heiko
--
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: office at nabladev.com
Geschäftsführer : Stefano Babic
More information about the U-Boot
mailing list