[U-Boot] Enable I2C0 of NanoPiNeo2

Message ID 48205673-cd75-6f48-f85c-e924a7e38b38@metirionic.com
State New
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series
  • [U-Boot] Enable I2C0 of NanoPiNeo2
Related show

Commit Message

Ronny Lubke Dec. 7, 2018, 9:15 a.m.
For getting the I2C0 bus working in u-boot, the used PINS had to be 
enabled in the board.c.
In the nanopi_neo2_defconfig you have to set the CONFIG_I2C0_ENABLE=y.

Best regards

Ronny Lubke

  
-------------------------------------
Engineer

Metirionic GmbH
Strehlener Stra├če 12 - 14
01069 Dresden

phone: +49-351-873229-26

http://www.metirionic.com/

Geschaeftsfuehrung: Dr. Attila Roemer
Gesellschaftssitz: Dresden
Amtsgericht: Dresden
HRB 32209

Patch

diff --git a/arch/arm/dts/sun50i-h5-nanopi-neo2.dts b/arch/arm/dts/sun50i-h5-nanopi-neo2.dts
index cc268a6978..d25d38f742 100644
--- a/arch/arm/dts/sun50i-h5-nanopi-neo2.dts
+++ b/arch/arm/dts/sun50i-h5-nanopi-neo2.dts
@@ -52,6 +52,7 @@ 
 	aliases {
 		ethernet0 = &emac;
 		serial0 = &uart0;
+		i2c0 = &i2c0;
 	};
 
 	chosen {
@@ -125,6 +126,12 @@ 
 	};
 };
 
+&i2c0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c0_pins>;
+	status = "okay";
+};
+
 &mmc0 {
 	vmmc-supply = <&reg_vcc3v3>;
 	bus-width = <4>;
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index b196d48674..2a8391dc74 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -94,10 +94,15 @@  void i2c_init_board(void)
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(14), SUN6I_GPH_TWI0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(15), SUN6I_GPH_TWI0);
 	clock_twi_onoff(0, 1);
+#elif defined(CONFIG_MACH_SUNXI_H3_H5)
+	sunxi_gpio_set_cfgpin(SUNXI_GPA(11), SUN8I_GPH_TWI0);
+	sunxi_gpio_set_cfgpin(SUNXI_GPA(12), SUN8I_GPH_TWI0);
+	clock_twi_onoff(0, 1);
 #elif defined(CONFIG_MACH_SUN8I)
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(2), SUN8I_GPH_TWI0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(3), SUN8I_GPH_TWI0);
 	clock_twi_onoff(0, 1);
+
 #endif
 #endif
 
diff --git a/configs/nanopi_neo2_defconfig b/configs/nanopi_neo2_defconfig
index ee693be1a8..bbdac43b66 100644
--- a/configs/nanopi_neo2_defconfig
+++ b/configs/nanopi_neo2_defconfig
@@ -13,3 +13,8 @@  CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-nanopi-neo2"
 CONFIG_SUN8I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
+
+# enable I2C0
+CONFIG_I2C0_ENABLE=y
+# enable i2c u-boot command prompt for testing
+CONFIG_CMD_I2C=y