Add i2c support for MediaTek mt8512
Subsystems (3)
cover Add i2c support for MediaTek mt8512
From: Mingming Lee <[email protected]>
This patch series adds basic i2c support for MediaTek MT8512 EMMC boards.
Mingming Lee (3):
i2c: mediatek: add basic driver support
ARM: dts: Mediatek: add i2c node support for mt8512
configs: mt8512: Enable I2C related configs
arch/arm/dts/mt8512-bm1-emmc.dts | 12 + arch/arm/dts/mt8512.dtsi | 38 ++- configs/mt8512_bm1_emmc_defconfig | 3 + drivers/i2c/Kconfig | 9 + drivers/i2c/Makefile | 1 + drivers/i2c/mt_i2c.c | 619 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 681 insertions(+), 1 deletion(-) create mode 100644 drivers/i2c/mt_i2c.c
Signature · 1 line
1.9.1
PATCH 1/3 i2c: mediatek: add basic driver support
From: Mingming Lee <[email protected]>
Add MediaTek I2C basic driver
--- drivers/i2c/Kconfig | 9 + drivers/i2c/Makefile | 1 + drivers/i2c/mt_i2c.c | 619 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 629 insertions(+) create mode 100644 drivers/i2c/mt_i2c.c
drivers/i2c/Kconfig +9 -0
@@ -159,6 +159,15 @@ config SYS_I2C_MESON internal buffer holding up to 8 bytes for transfers and supports both 7-bit and 10-bit addresses. +config SYS_I2C_MTK + bool "MediaTek I2C driver" + default n + help + This selects the MediaTek Integrated Inter Circuit bus driver. + The I2C bus adapter is the base for some other I2C client, eg: touch, sensors. + If you want to use MediaTek I2C interface, say Y here. + If unsure, say N. + config SYS_I2C_MXC bool "NXP MXC I2C driver" help
drivers/i2c/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_SYS_I2C_LPC32XX) += lpc32xx_i2c.o obj-$(CONFIG_SYS_I2C_MESON) += meson_i2c.o obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o +obj-$(CONFIG_SYS_I2C_MTK) += mt_i2c.o obj-$(CONFIG_SYS_I2C_NEXELL) += nx_i2c.o obj-$(CONFIG_SYS_I2C_OCTEON) += octeon_i2c.o obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
drivers/i2c/mt_i2c.c new file +619 -0
619 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 2/3 ARM: dts: Mediatek: add i2c node support for mt8512
In reply to mingming leeFrom: Mingming Lee <[email protected]>
add i2c dts node support for mt8512
--- arch/arm/dts/mt8512-bm1-emmc.dts | 12 ++++++++++++ arch/arm/dts/mt8512.dtsi | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-)
arch/arm/dts/mt8512-bm1-emmc.dts +12 -0
@@ -45,6 +45,18 @@ }; }; +&i2c0 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; +}; + +&i2c2 { + status = "okay"; +}; + &mmc0 { pinctrl-names = "default"; pinctrl-0 = <&mmc0_pins_default>;
arch/arm/dts/mt8512.dtsi +37 -1
@@ -90,6 +90,42 @@ reg = <0x10200a80 0x50>; }; + i2c0: i2c at 11007000 { + compatible = "mediatek,mt8512-i2c"; + reg = <0x11007000 0x1000>, + <0x11000080 0x80>; + clocks = <&infracfg CLK_INFRA_I2C0_AXI>, + <&infracfg CLK_INFRA_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c at 10019000 { + compatible = "mediatek,mt8512-i2c"; + reg = <0x10019000 0x1000>, + <0x11000100 0x80>; + clocks = <&infracfg CLK_INFRA_I2C1_AXI>, + <&infracfg CLK_INFRA_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c at 1001e000 { + compatible = "mediatek,mt8512-i2c"; + reg = <0x1001e000 0x1000>, + <0x11000180 0x80>; + clocks = <&infracfg CLK_INFRA_I2C1_AXI>, + <&infracfg CLK_INFRA_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + uart0: serial at 11002000 { compatible = "mediatek,hsuart"; reg = <0x11002000 0x1000>;
@@ -112,4 +148,4 @@ status = "disabled"; }; -}; +};
Signature · 1 line
1.9.1
PATCH 3/3 configs: mt8512: Enable I2C related configs
In reply to mingming leeFrom: Mingming Lee <[email protected]>
Enable MTK I2C
Enable I2C basic command
--- configs/mt8512_bm1_emmc_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/mt8512_bm1_emmc_defconfig +3 -0
@@ -33,3 +33,6 @@ CONFIG_MTK_TIMER=y CONFIG_WDT=y CONFIG_WDT_MTK=y CONFIG_LZO=y +CONFIG_CMD_I2C=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_MTK=y
Signature · 1 line
1.9.1
PATCH 1/3 i2c: mediatek: add basic driver support
In reply to mingming leeHello mingming,
Am 09.09.2020 um 08:07 schrieb mingming lee:
Quoted 11 lines
From: Mingming Lee <[email protected]>
Add MediaTek I2C basic driver
Signed-off-by Mingming Lee <[email protected]>--- drivers/i2c/Kconfig | 9 + drivers/i2c/Makefile | 1 + drivers/i2c/mt_i2c.c | 619 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 629 insertions(+)create mode 100644
drivers/i2c/mt_i2c.c
Nitpicks only:
As you introduce here new DTS bindings, can you please document them in u-boot:/doc/device-tree-bindings/
Thanks!
[snip]
Quoted 16 lines
drivers/i2c/mt_i2c.c new file +10
-0@@ -0,0 +1,619 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* MediaTek I2C Interface driver +* +* Copyright (C) 2020 MediaTek Inc. +* Author: Mingming Lee <[email protected]> +*/ + +#include <asm/cache.h> +#include <asm/io.h>
drivers/i2c/mt_i2c.c line 20
Quoted 10 lines
drivers/i2c/mt_i2c.c new file +10
-0+#include <common.h> +#include <clk.h> +#include <dm.h> +#include <i2c.h> +#include <linux/delay.h> + +#define I2C_OK 0 +#define EINVAL_I2C 22/* invalid argument */ +#define ETIMEDOUT_I2C 110/* connection timed out */ +#define EACK_I2C 6/* remote I/O error */
You could use defines from include/linux/errno.h ?
[snip]
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 2/3 ARM: dts: Mediatek: add i2c node support for mt8512
In reply to mingming leeHello mingming,
Am 09.09.2020 um 08:07 schrieb mingming lee:
Quoted 9 lines
From: Mingming Lee <[email protected]>
add i2c dts node support for mt8512
Signed-off-by Mingming Lee <[email protected]>--- arch/arm/dts/mt8512-bm1-emmc.dts | 12 ++++++++++++ arch/arm/dts/mt8512.dtsi | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-)
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 3/3 configs: mt8512: Enable I2C related configs
In reply to mingming leeHello mingming,
Am 09.09.2020 um 08:07 schrieb mingming lee:
Quoted 9 lines
From: Mingming Lee <[email protected]>
Enable MTK I2C
Enable I2C basic commandSigned-off-by Mingming Lee <[email protected]>--- configs/mt8512_bm1_emmc_defconfig | 3 +++ 1 file changed, 3 insertions(+)
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/3 i2c: mediatek: add basic driver support
In reply to Heiko SchocherQuoted 15 lines · Heiko Schocher
Hello mingming,
Am 09.09.2020 um 08:07 schrieb mingming lee:
Quoted 11 lines
From: Mingming Lee <[email protected]>
Add MediaTek I2C basic driver
Signed-off-by Mingming Lee <[email protected]>--- drivers/i2c/Kconfig | 9 + drivers/i2c/Makefile | 1 + drivers/i2c/mt_i2c.c | 619 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 629 insertions(+)create mode 100644
drivers/i2c/mt_i2c.c
Quoted 5 lines
Nitpicks only:
As you introduce here new DTS bindings, can you please document them in u-boot:/doc/device-tree-bindings/
----->thank you for for advice, I would add the new DTS bingding in next version.
Quoted 24 lines
Thanks!
[snip]
Quoted 20 lines
drivers/i2c/mt_i2c.c new file +14
-0@@ -0,0 +1,619 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* MediaTek I2C Interface driver +* +* Copyright (C) 2020 MediaTek Inc. +* Author: Mingming Lee <[email protected]> +*/ + +#include <asm/cache.h> +#include <asm/io.h> +#include <common.h> +#include <clk.h> +#include <dm.h> +#include <i2c.h>
Quoted 9 lines
drivers/i2c/mt_i2c.c line 20
Quoted 6 lines
drivers/i2c/mt_i2c.c new file +6
-0+#include <linux/delay.h> + +#define I2C_OK 0 +#define EINVAL_I2C 22/* invalid argument */ +#define ETIMEDOUT_I2C 110/* connection timed out */ +#define EACK_I2C 6/* remote I/O error */ You could use defines from
include/linux/errno.h?
------->I think it is better to use the define from include/linux/errno.h, and I would modify it in next version today.
Quoted 9 lines
[snip]
Reviewed-by Heiko Schocher <[email protected]>Thanks!
bye,
Heiko