Skip to contentSkip to conversation

armv8: lx2160a: The lx2160a platform supports the I2C driver model.

PATCH New Chuanhua Han 2 participants 17 messages May 23, 2019 – May 30, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 armv8: lx2160a: The lx2160a platform supports the I2C driver model.

DM_I2C_COMPAT is a compatibility layer that allows using the non-DM I2C API when DM_I2C is used.When DM_I2C_COMPAT is not enabled for compilation, a compilation error will be generated. This patch solves the problem that the i2c-related api of the lx2160a platform does not support dm.

---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  8 ---
 board/freescale/common/emc2305.c          | 21 ++++++
 board/freescale/common/qixis.c            | 17 +++++
 board/freescale/common/sys_eeprom.c       | 84 +++++++++++++++++++++--
 board/freescale/common/vid.c              | 84 +++++++++++++++++++++++
 board/freescale/lx2160a/lx2160a.c         |  8 +++
 drivers/ddr/fsl/main.c                    | 36 +++++++++-
 7 files changed, 245 insertions(+), 13 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/Kconfig +0 -8
index a843c1eb65..f3eaab960b 100644
@@ -234,14 +234,6 @@ config ARCH_LX2160A
 	select ARCH_EARLY_INIT_R
 	select BOARD_EARLY_INIT_F
 	select SYS_I2C_MXC
-	select SYS_I2C_MXC_I2C1
-	select SYS_I2C_MXC_I2C2
-	select SYS_I2C_MXC_I2C3
-	select SYS_I2C_MXC_I2C4
-	select SYS_I2C_MXC_I2C5
-	select SYS_I2C_MXC_I2C6
-	select SYS_I2C_MXC_I2C7
-	select SYS_I2C_MXC_I2C8
 	imply DISTRO_DEFAULTS
 	imply PANIC_HANG
 	imply SCSI
board/freescale/common/emc2305.c +21 -0
index 8523084da9..b1ca051db2 100644
@@ -24,10 +24,22 @@ void set_fan_speed(u8 data)
 			       I2C_EMC2305_FAN5};
 
 	for (index = 0; index < NUM_OF_FANS; index++) {
+#ifndef CONFIG_DM_I2C
 		if (i2c_write(I2C_EMC2305_ADDR, Fan[index], 1, &data, 1) != 0) {
 			printf("Error: failed to change fan speed @%x\n",
 			       Fan[index]);
 		}
+#else
+		struct udevice *dev;
+
+		if (i2c_get_chip_for_busnum(0, I2C_EMC2305_ADDR, 1, &dev))
+			continue;
+
+		if (dm_i2c_write(dev, Fan[index], &data, 1) != 0) {
+			printf("Error: failed to change fan speed @%x\n",
+			       Fan[index]);
+		}
+#endif
 	}
 }
 
@@ -36,6 +48,15 @@ void emc2305_init(void)
 	u8 data;
 
 	data = I2C_EMC2305_CMD;
+#ifndef CONFIG_DM_I2C
 	if (i2c_write(I2C_EMC2305_ADDR, I2C_EMC2305_CONF, 1, &data, 1) != 0)
 		printf("Error: failed to configure EMC2305\n");
+#else
+	struct udevice *dev;
+
+	if (!i2c_get_chip_for_busnum(0, I2C_EMC2305_ADDR, 1, &dev))
+		if (dm_i2c_write(dev, I2C_EMC2305_CONF, &data, 1))
+			printf("Error: failed to configure EMC2305\n");
+#endif
+
 }
board/freescale/common/qixis.c +17 -0
index f1b98bcd2a..2c4c4ae108 100644
@@ -24,13 +24,30 @@
 #ifdef CONFIG_SYS_I2C_FPGA_ADDR
 u8 qixis_read_i2c(unsigned int reg)
 {
+#ifndef CONFIG_DM_I2C
 	return i2c_reg_read(CONFIG_SYS_I2C_FPGA_ADDR, reg);
+#else
+	struct udevice *dev;
+
+	if (i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_FPGA_ADDR, 1, &dev))
+		return 0xff;
+
+	return dm_i2c_reg_read(dev, reg);
+#endif
 }
 
 void qixis_write_i2c(unsigned int reg, u8 value)
 {
 	u8 val = value;
+#ifndef CONFIG_DM_I2C
 	i2c_reg_write(CONFIG_SYS_I2C_FPGA_ADDR, reg, val);
+#else
+	struct udevice *dev;
+
+	if (!i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_FPGA_ADDR, 1, &dev))
+		dm_i2c_reg_write(dev, reg, val);
+#endif
+
 }
 #endif
 
board/freescale/common/sys_eeprom.c +80 -4

149 lines not on this page · raw message

board/freescale/common/vid.c +84 -0

175 lines not on this page · raw message

board/freescale/lx2160a/lx2160a.c +8 -0
index 6109b280c6..ea28bfb621 100644
@@ -74,7 +74,15 @@ int select_i2c_ch_pca9547(u8 ch)
 {
 	int ret;
 
+#ifndef CONFIG_DM_I2C
 	ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
+#else
+	struct udevice *dev;
+
+	ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev);
+	if (!ret)
+		ret = dm_i2c_write(dev, 0, &ch, 1);
+#endif
 	if (ret) {
 		puts("PCA: failed to select proper channel\n");
 		return ret;
drivers/ddr/fsl/main.c +35 -1
index e1f69a1d25..ac0783b428 100644
@@ -92,7 +92,10 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
 	uint8_t dummy = 0;
 #endif
 
+#ifndef CONFIG_DM_I2C
 	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
+#endif
+
 
 #ifdef CONFIG_SYS_FSL_DDR4
 	/*
@@ -101,6 +104,7 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
 	 * To access the upper 256 bytes, we need to set EE page address to 1
 	 * See Jedec standar No. 21-C for detail
 	 */
+#ifndef CONFIG_DM_I2C
 	i2c_write(SPD_SPA0_ADDRESS, 0, 1, &dummy, 1);
 	ret = i2c_read(i2c_address, 0, 1, (uchar *)spd, 256);
 	if (!ret) {
@@ -111,8 +115,38 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
 				   (int)sizeof(generic_spd_eeprom_t) - 256));
 	}
 #else
+	struct udevice *dev;
+	int read_len = min(256, (int)sizeof(generic_spd_eeprom_t) - 256);
+
+	ret = i2c_get_chip_for_busnum(0, SPD_SPA0_ADDRESS, 1, &dev);
+	if (!ret)
+		dm_i2c_write(dev, 0, &dummy, 1);
+	ret = i2c_get_chip_for_busnum(0, i2c_address, 1, &dev);
+	if (!ret) {
+		if (!dm_i2c_read(dev, 0, (uchar *)spd, 256)) {
+			if (!i2c_get_chip_for_busnum(0, SPD_SPA1_ADDRESS,
+						     1, &dev))
+				dm_i2c_write(dev, 0, &dummy, 1);
+			if (!i2c_get_chip_for_busnum(0, i2c_address, 1, &dev))
+				ret = dm_i2c_read(dev, 0,
+						  (uchar *)((ulong)spd + 256),
+						  read_len);
+		}
+	}
+#endif
+
+#else
+
+#ifndef CONFIG_DM_I2C
 	ret = i2c_read(i2c_address, 0, 1, (uchar *)spd,
-				sizeof(generic_spd_eeprom_t));
+			sizeof(generic_spd_eeprom_t));
+#else
+	ret = i2c_get_chip_for_busnum(0, i2c_address, 1, &dev);
+	if (!ret)
+		ret = dm_i2c_read(dev, 0, (uchar *)spd,
+				  sizeof(generic_spd_eeprom_t));
+#endif
+
 #endif
 
 	if (ret) {
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/7 configs: lx2160a: enable DM support for pcf2127 rtc

Enable related configs to support pcf2127 rtc DM feature.

---
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig | 5 +++++
 configs/lx2160ardb_tfa_defconfig             | 5 +++++
 2 files changed, 10 insertions(+)
configs/lx2160ardb_tfa_SECURE_BOOT_defconfig +5 -0
index 5cb29fd9ca..d56aa6d333 100644
@@ -58,3 +58,8 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_DM_I2C=y
+CONFIG_DM_RTC=y
+CONFIG_DM_GPIO=y
+CONFIG_CMD_DATE=y
+CONFIG_RTC_PCF2127=y
configs/lx2160ardb_tfa_defconfig +5 -0
index 94f58a832f..059e877b21 100644
@@ -57,3 +57,8 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_DM_I2C=y
+CONFIG_DM_RTC=y
+CONFIG_DM_GPIO=y
+CONFIG_CMD_DATE=y
+CONFIG_RTC_PCF2127=y
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/7 armv8: dts: fsl-lx2160a: add i2c controller and gpio DT nodes

In reply to Chuanhua Han

In lx2160a soc, there are eight i2c controllers, this patch adds i2c nodes for lx2160a, and the gpio2 nodes on which the i2c4 controller depends.

---
 arch/arm/dts/fsl-lx2160a.dtsi | 101 ++++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)
arch/arm/dts/fsl-lx2160a.dtsi +101 -0
index 28220781d3..8a91cdb7dc 100644
@@ -49,6 +49,96 @@
 			     <1 10 0x8>; /* Hypervisor PPI, active-low */
 	};
 
+	i2c0: i2c at 2000000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2000000 0x0 0x10000>;
+		interrupts = <0 34 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		scl-gpio = <&gpio2 15 0>;
+		status = "disabled";
+	};
+
+	i2c1: i2c at 2010000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2010000 0x0 0x10000>;
+		interrupts = <0 34 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		status = "disabled";
+	};
+
+	i2c2: i2c at 2020000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2020000 0x0 0x10000>;
+		interrupts = <0 35 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		status = "disabled";
+	};
+
+	i2c3: i2c at 2030000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2030000 0x0 0x10000>;
+		interrupts = <0 35 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		status = "disabled";
+	};
+
+	i2c4: i2c at 2040000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2040000 0x0 0x10000>;
+		interrupts = <0 74 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		scl-gpio = <&gpio2 16 0>;
+		status = "disabled";
+	};
+
+	i2c5: i2c at 2050000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2050000 0x0 0x10000>;
+		interrupts = <0 74 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		status = "disabled";
+	};
+
+	i2c6: i2c at 2060000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2060000 0x0 0x10000>;
+		interrupts = <0 75 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		status = "disabled";
+	};
+
+	i2c7: i2c at 2070000 {
+		compatible = "fsl,vf610-i2c";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x0 0x2070000 0x0 0x10000>;
+		interrupts = <0 75 4>;
+		clock-names = "i2c";
+		clocks = <&clockgen 4 7>;
+		status = "disabled";
+	};
+
 	uart0: serial at 21c0000 {
 		compatible = "arm,pl011";
 		reg = <0x0 0x21c0000 0x0 0x1000>;
@@ -102,6 +192,17 @@
 		num-cs = <6>;
 	};
 
+	gpio2: gpio at 2320000 {
+		compatible = "fsl,qoriq-gpio";
+		reg = <0x0 0x2320000 0x0 0x10000>;
+		interrupts = <0 37 4>;
+		gpio-controller;
+		little-endian;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+
 	usb0: usb3 at 3100000 {
 		compatible = "fsl,layerscape-dwc3";
 		reg = <0x0 0x3100000 0x0 0x10000>;
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/7 armv8: dts: fsl-lx2160a: add i2c controller and gpio DT nodes

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 8 lines

In lx2160a soc, there are eight i2c controllers, this patch adds i2c nodes for lx2160a, and the gpio2 nodes on which the i2c4 controller depends.

---
  arch/arm/dts/fsl-lx2160a.dtsi | 101 ++++++++++++++++++++++++++++++++++
  1 file changed, 101 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
#4 lore raw

PATCH 4/7 armv8: lx2160ardb : Add pcf2127 node

In reply to Chuanhua Han

This patch adds the pcf2127-rtc node under the i2c4 node.

---
 arch/arm/dts/fsl-lx2160a-rdb.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/dts/fsl-lx2160a-rdb.dts +19 -0
index 4b526449a1..ca71fbea42 100644
@@ -17,6 +17,16 @@
 	model = "NXP Layerscape LX2160ARDB Board";
 	compatible = "fsl,lx2160ardb", "fsl,lx2160a";
 
+	aliases {
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
+		i2c3 = &i2c3;
+		i2c4 = &i2c4;
+		i2c5 = &i2c5;
+		i2c6 = &i2c6;
+		i2c7 = &i2c7;
+	};
 };
 
 &esdhc0 {
@@ -27,6 +37,15 @@
 	status = "okay";
 };
 
+&i2c4 {
+	status = "okay";
+
+	rtc at 51 {
+		compatible = "pcf2127-rtc";
+		reg = <0x51>;
+	};
+};
+
 &sata0 {
 	status = "okay";
 };
Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/7 armv8: lx2160ardb : Add pcf2127 node

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 6 lines

This patch adds the pcf2127-rtc node under the i2c4 node.

---
  arch/arm/dts/fsl-lx2160a-rdb.dts | 19 +++++++++++++++++++
  1 file changed, 19 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
#6 lore raw

PATCH 5/7 drivers: i2c: mxc: Solve the compiler error when using i2c dm mode

In reply to Chuanhua Han

This patch solved the following compilation error:

1.Remove the definition of CONFIG_SYS_I2C to solve the following compilation issue:
In file included from include/config.h:8:0,
from include/common.h:20:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
# error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"

    ^~~~~

In file included from include/config.h:8:0,
from include/common.h:20:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
# error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"

    ^~~~~

2.Remove the definition of CONFIG_SYS_I2C_EARLY_INIT to solve the following compilation issue:
board/freescale/lx2160a/lx2160a.c: In function 'board_early_init_f':
board/freescale/lx2160a/lx2160a.c:108:2: warning: implicit declaration of function 'i2c_early_init_f'; did you mean 'arch_early_init_r'? [-Wimplicit-function-declaration]
i2c_early_init_f();
^~~~~~~~~~~~~~~~
arch_early_init_r

3.Move the enable_i2c_clk function definition to resolve the following compilation issues:
drivers/i2c/mxc_i2c.c: In function 'mxc_i2c_probe':
drivers/i2c/mxc_i2c.c:824:8: warning: implicit declaration of function
'enable_i2c_clk';
did you mean 'enable_irq_wake'? [-Wimplicit-function-declaration]

  ret = enable_i2c_clk(1, bus->seq);
        ^~~~~~~~~~~~~~
        enable_irq_wake
---
 arch/arm/include/asm/arch-fsl-layerscape/config.h |  2 --
 drivers/i2c/mxc_i2c.c                             | 15 ++++++++-------
 2 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/include/asm/arch-fsl-layerscape/config.h +0 -2
index eb21c09e01..5f87499980 100644
@@ -178,8 +178,6 @@
 #elif defined(CONFIG_ARCH_LX2160A)
 #define TZPC_BASE				0x02200000
 #define TZPCDECPROT_0_SET_BASE			(TZPC_BASE + 0x804)
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_EARLY_INIT
 #define SRDS_MAX_LANES  8
 #ifndef L1_CACHE_BYTES
 #define L1_CACHE_SHIFT		6
drivers/i2c/mxc_i2c.c +8 -7
index f3811eb0c5..241367bac8 100644
@@ -558,6 +558,14 @@ static int i2c_read_data(struct mxc_i2c_bus *i2c_bus, uchar chip, uchar *buf,
 	return 0;
 }
 
+int __enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
+{
+	return 1;
+}
+
+int enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
+	__attribute__((weak, alias("__enable_i2c_clk")));
+
 #ifndef CONFIG_DM_I2C
 /*
  * Read data from I2C device
@@ -723,13 +731,6 @@ static int mxc_i2c_probe(struct i2c_adapter *adap, uint8_t chip)
 	return bus_i2c_write(i2c_get_base(adap), chip, 0, 0, NULL, 0);
 }
 
-int __enable_i2c_clk(unsigned char enable, unsigned i2c_num)
-{
-	return 1;
-}
-int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
-	__attribute__((weak, alias("__enable_i2c_clk")));
-
 void bus_i2c_init(int index, int speed, int unused,
 		  int (*idle_bus_fn)(void *p), void *idle_bus_data)
 {
Signature · 1 line
2.17.1
#7 lore raw

PATCH 5/7 drivers: i2c: mxc: Solve the compiler error when using i2c dm mode

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 9 lines

This patch solved the following compilation error:

1.Remove the definition of CONFIG_SYS_I2C to solve the following compilation issue:
In file included from include/config.h:8:0,
from include/common.h:20:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
# error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"

Quoted 7 lines
     ^~~~~

In file included from include/config.h:8:0,
from include/common.h:20:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
# error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"

     ^~~~~

Shouldn't this patch merged with the patch, which introduces DM_I2C?

Else you break git bisect..

Quoted 20 lines

2.Remove the definition of CONFIG_SYS_I2C_EARLY_INIT to solve the following compilation issue:
board/freescale/lx2160a/lx2160a.c: In function 'board_early_init_f':
board/freescale/lx2160a/lx2160a.c:108:2: warning: implicit declaration of function 'i2c_early_init_f'; did you mean 'arch_early_init_r'? [-Wimplicit-function-declaration]

   i2c_early_init_f();
   ^~~~~~~~~~~~~~~~
   arch_early_init_r

3.Move the enable_i2c_clk function definition to resolve the following compilation issues:
drivers/i2c/mxc_i2c.c: In function 'mxc_i2c_probe':
drivers/i2c/mxc_i2c.c:824:8: warning: implicit declaration of function

'enable_i2c_clk';
   did you mean 'enable_irq_wake'? [-Wimplicit-function-declaration]
   ret = enable_i2c_clk(1, bus->seq);
         ^~~~~~~~~~~~~~
         enable_irq_wake
Quoted 3 lines
---
  arch/arm/include/asm/arch-fsl-layerscape/config.h |  2 --

Hmm... this is a "common" file ... have you checked, if this change does not break other boards?

Quoted 1 line
  drivers/i2c/mxc_i2c.c                             | 15 ++++++++-------

please in a seperate patch, thanks!

Quoted 49 lines
  2 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/include/asm/arch-fsl-layerscape/config.h +0 -2
index eb21c09e01..5f87499980 100644
@@ -178,8 +178,6 @@
  #elif defined(CONFIG_ARCH_LX2160A)
  #define TZPC_BASE				0x02200000
  #define TZPCDECPROT_0_SET_BASE			(TZPC_BASE + 0x804)
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_EARLY_INIT
  #define SRDS_MAX_LANES  8
  #ifndef L1_CACHE_BYTES
  #define L1_CACHE_SHIFT		6
drivers/i2c/mxc_i2c.c +8 -7
index f3811eb0c5..241367bac8 100644
@@ -558,6 +558,14 @@ static int i2c_read_data(struct mxc_i2c_bus *i2c_bus, uchar chip, uchar *buf,
  	return 0;
  }
 
+int __enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
+{
+	return 1;
+}
+
+int enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
+	__attribute__((weak, alias("__enable_i2c_clk")));
+
  #ifndef CONFIG_DM_I2C
  /*
   * Read data from I2C device
@@ -723,13 +731,6 @@ static int mxc_i2c_probe(struct i2c_adapter *adap, uint8_t chip)
  	return bus_i2c_write(i2c_get_base(adap), chip, 0, 0, NULL, 0);
  }
 
-int __enable_i2c_clk(unsigned char enable, unsigned i2c_num)
-{
-	return 1;
-}
-int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
-	__attribute__((weak, alias("__enable_i2c_clk")));
-
  void bus_i2c_init(int index, int speed, int unused,
  		  int (*idle_bus_fn)(void *p), void *idle_bus_data)
  {
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
#8 lore raw

[U-Boot] [EXT] Re: [PATCH 5/7] drivers: i2c: mxc: Solve the compiler error when using i2c dm mode

Quoted 33 lines

-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2019年5月24日 12:58
To: Chuanhua Han <[email protected]>
Cc: albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; Udit Agarwal <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 5/7] drivers: i2c: mxc: Solve the compiler error when using i2c dm mode

Caution: EXT Email

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 9 lines

This patch solved the following compilation error:

1.Remove the definition of CONFIG_SYS_I2C to solve the following compilation issue:
In file included from include/config.h:8:0,
from include/common.h:20:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
# error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"

Quoted 7 lines
     ^~~~~

In file included from include/config.h:8:0,
from include/common.h:20:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
# error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"

     ^~~~~
Quoted 3 lines

Shouldn't this patch merged with the patch, which introduces DM_I2C?

Else you break git bisect..

OK.You are right

Quoted 21 lines
Quoted 21 lines

2.Remove the definition of CONFIG_SYS_I2C_EARLY_INIT to solve the following compilation issue:
board/freescale/lx2160a/lx2160a.c: In function 'board_early_init_f':
board/freescale/lx2160a/lx2160a.c:108:2: warning: implicit declaration of function 'i2c_early_init_f'; did you mean 'arch_early_init_r'? [-Wimplicit-function-declaration]

   i2c_early_init_f();
   ^~~~~~~~~~~~~~~~
   arch_early_init_r

3.Move the enable_i2c_clk function definition to resolve the following compilation issues:
drivers/i2c/mxc_i2c.c: In function 'mxc_i2c_probe':
drivers/i2c/mxc_i2c.c:824:8: warning: implicit declaration of

function 'enable_i2c_clk';
   did you mean 'enable_irq_wake'? [-Wimplicit-function-declaration]
   ret = enable_i2c_clk(1, bus->seq);
         ^~~~~~~~~~~~~~
         enable_irq_wake
Quoted 6 lines
Quoted 3 lines
---
  arch/arm/include/asm/arch-fsl-layerscape/config.h |  2 --

Hmm... this is a "common" file ... have you checked, if this change does not break other boards?

Yes, there will be no impact

Quoted 5 lines
Quoted 2 lines
  drivers/i2c/mxc_i2c.c                             | 15

++++++++-------

please in a seperate patch, thanks!

OK

Quoted 57 lines

arch/arm/include/asm/arch-fsl-layerscape/config.h line 180

Quoted 12 lines
  2 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/include/asm/arch-fsl-layerscape/config.h +0 -0
index eb21c09e01..5f87499980 100644
@@ -178,8 +178,6 @@
  #elif defined(CONFIG_ARCH_LX2160A)
  #define TZPC_BASE                           0x02200000
  #define TZPCDECPROT_0_SET_BASE                      (TZPC_BASE

+ 0x804)

drivers/i2c/mxc_i2c.c static int i2c_read_data(struct mxc_i2c_bus

Quoted 10 lines
arch/arm/include/asm/arch-fsl-layerscape/config.h +0 -2
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_EARLY_INIT
  #define SRDS_MAX_LANES  8
  #ifndef L1_CACHE_BYTES
  #define L1_CACHE_SHIFT              6
drivers/i2c/mxc_i2c.c index renamed from drivers/i2c/mxc_i2c.c +0 -0

f3811eb0c5..241367bac8 100644

drivers/i2c/mxc_i2c.c +0 -0
@@ -558,6 +558,14 @@ static int i2c_read_data(struct mxc_i2c_bus

*i2c_bus, uchar chip, uchar *buf,

drivers/i2c/mxc_i2c.c static int mxc_i2c_probe(struct i2c_adapter *adap,

Quoted 14 lines
drivers/i2c/mxc_i2c.c +7 -0
      return 0;
  }
 
+int __enable_i2c_clk(unsigned char enable, unsigned int i2c_num) {
+     return 1;
+}
+
+int enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
+     __attribute__((weak, alias("__enable_i2c_clk")));
+
  #ifndef CONFIG_DM_I2C
  /*
   * Read data from I2C device
@@ -723,13 +731,6 @@ static int mxc_i2c_probe(struct i2c_adapter *adap,

uint8_t chip)

drivers/i2c/mxc_i2c.c static int mxc_i2c_probe(struct i2c_adapter *adap, uint8_t chip) · line 736

Quoted 13 lines
drivers/i2c/mxc_i2c.c +0 -6
      return bus_i2c_write(i2c_get_base(adap), chip, 0, 0, NULL, 0);
  }
 
-int __enable_i2c_clk(unsigned char enable, unsigned i2c_num) -{
-     return 1;
-}
-int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
-     __attribute__((weak, alias("__enable_i2c_clk")));
-
  void bus_i2c_init(int index, int speed, int unused,
                int (*idle_bus_fn)(void *p), void *idle_bus_data)
  {

--
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

#9 lore raw

PATCH 6/7 gpio: do not include <asm/arch/gpio.h> on ARCH_LX2160A

In reply to Chuanhua Han

As no gpio.h is defined for this architecture, to avoid compilation failure, do not include <asm/arch/gpio.h> for arch ls2160a.

---
 arch/arm/include/asm/gpio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/gpio.h +2 -1
index 370031f2ac..f78b976e10 100644
@@ -1,6 +1,7 @@
 #if !defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARCH_STI) && \
 	!defined(CONFIG_ARCH_K3) && !defined(CONFIG_ARCH_BCM6858) && \
-	!defined(CONFIG_ARCH_BCM63158) && !defined(CONFIG_ARCH_ROCKCHIP)
+	!defined(CONFIG_ARCH_BCM63158) && !defined(CONFIG_ARCH_ROCKCHIP) && \
+	!defined(CONFIG_ARCH_LX2160A)
 #include <asm/arch/gpio.h>
 #endif
 #include <asm-generic/gpio.h>
Signature · 1 line
2.17.1
#10 lore raw

PATCH 6/7 gpio: do not include <asm/arch/gpio.h> on ARCH_LX2160A

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 8 lines

As no gpio.h is defined for this architecture, to avoid compilation failure, do not include <asm/arch/gpio.h> for arch ls2160a.

---
  arch/arm/include/asm/gpio.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Hmm... I wonder, why this does not popup with current source?

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
#11 lore raw

[U-Boot] [EXT] Re: [PATCH 6/7] gpio: do not include <asm/arch/gpio.h> on ARCH_LX2160A

Quoted 19 lines

-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2019年5月24日 13:01
To: Chuanhua Han <[email protected]>
Cc: albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; Udit Agarwal <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 6/7] gpio: do not include <asm/arch/gpio.h> on ARCH_LX2160A

Caution: EXT Email

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 3 lines

As no gpio.h is defined for this architecture, to avoid compilation failure, do not include <asm/arch/gpio.h> for arch ls2160a.

Quoted 8 lines
Quoted 4 lines
---
  arch/arm/include/asm/gpio.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Hmm... I wonder, why this does not popup with current source?

Ls2160a platform does not include <asm/arch/gpio.h>

Quoted 7 lines

bye,
Heiko
--
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

#12 lore raw

PATCH 7/7 armv8: lx2160ardb : Add slave nodes under the i2c0 controller

In reply to Chuanhua Han

This patch adds some slave nodes to support the i2c dm on the device side under the i2c0 controller.

---
 arch/arm/dts/fsl-lx2160a-rdb.dts | 51 ++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm/dts/fsl-lx2160a-rdb.dts +51 -0
index ca71fbea42..c6b4131338 100644
@@ -27,6 +27,16 @@
 		i2c6 = &i2c6;
 		i2c7 = &i2c7;
 	};
+
+	sb_3v3: regulator-sb3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "MC34717-3.3VSB";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
 };
 
 &esdhc0 {
@@ -37,6 +47,47 @@
 	status = "okay";
 };
 
+&i2c0 {
+	status = "okay";
+
+	i2c-mux at 77 {
+		compatible = "nxp,pca9547";
+		reg = <0x77>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		i2c at 2 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x2>;
+
+			power-monitor at 40 {
+				compatible = "ti,ina220";
+				reg = <0x40>;
+				shunt-resistor = <1000>;
+			};
+		};
+
+		i2c at 3 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x3>;
+
+			temperature-sensor at 4c {
+				compatible = "nxp,sa56004";
+				reg = <0x4c>;
+				vcc-supply = <&sb_3v3>;
+			};
+
+			temperature-sensor at 4d {
+				compatible = "nxp,sa56004";
+				reg = <0x4d>;
+				vcc-supply = <&sb_3v3>;
+			};
+		};
+	};
+};
+
 &i2c4 {
 	status = "okay";
 
Signature · 1 line
2.17.1
#13 lore raw

PATCH 7/7 armv8: lx2160ardb : Add slave nodes under the i2c0 controller

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 7 lines

This patch adds some slave nodes to support the i2c dm on the device side under the i2c0 controller.

---
  arch/arm/dts/fsl-lx2160a-rdb.dts | 51 ++++++++++++++++++++++++++++++++
  1 file changed, 51 insertions(+)

Is this board in linux mainline? If so, may a sync with linux makes sense, and add u-boot specific changes into an "fsl-lx2160a-rdb-u-boot.dts" ?

Beside of this:

bye,
Heiko

Signature · 4 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
#14 lore raw

[U-Boot] [EXT] Re: [PATCH 7/7] armv8: lx2160ardb : Add slave nodes under the i2c0 controller

Quoted 19 lines

-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2019年5月24日 13:03
To: Chuanhua Han <[email protected]>
Cc: albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; Udit Agarwal <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 7/7] armv8: lx2160ardb : Add slave nodes under the i2c0 controller

Caution: EXT Email

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 3 lines

This patch adds some slave nodes to support the i2c dm on the device side under the i2c0 controller.

Quoted 8 lines
Quoted 3 lines
---
  arch/arm/dts/fsl-lx2160a-rdb.dts | 51

++++++++++++++++++++++++++++++++

Quoted 1 line
  1 file changed, 51 insertions(+)

Is this board in linux mainline? If so, may a sync with linux makes sense, and add u-boot specific changes into an "fsl-lx2160a-rdb-u-boot.dts" ?

Yes, these nodes are already in the linux mainline, need uboot device tree synchronization

Quoted 11 lines

Beside of this:

bye,
Heiko
--
--
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

#15 lore raw

PATCH 1/7 armv8: lx2160a: The lx2160a platform supports the I2C driver model.

In reply to Chuanhua Han

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 41 lines

DM_I2C_COMPAT is a compatibility layer that allows using the non-DM I2C API when DM_I2C is used.When DM_I2C_COMPAT is not enabled for compilation, a compilation error will be generated. This patch solves the problem that the i2c-related api of the lx2160a platform does not support dm.

---
  arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  8 ---
  board/freescale/common/emc2305.c          | 21 ++++++
  board/freescale/common/qixis.c            | 17 +++++
  board/freescale/common/sys_eeprom.c       | 84 +++++++++++++++++++++--
  board/freescale/common/vid.c              | 84 +++++++++++++++++++++++
  board/freescale/lx2160a/lx2160a.c         |  8 +++
  drivers/ddr/fsl/main.c                    | 36 +++++++++-
  7 files changed, 245 insertions(+), 13 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/Kconfig +0 -8
index a843c1eb65..f3eaab960b 100644
@@ -234,14 +234,6 @@ config ARCH_LX2160A
  	select ARCH_EARLY_INIT_R
  	select BOARD_EARLY_INIT_F
  	select SYS_I2C_MXC
-	select SYS_I2C_MXC_I2C1
-	select SYS_I2C_MXC_I2C2
-	select SYS_I2C_MXC_I2C3
-	select SYS_I2C_MXC_I2C4
-	select SYS_I2C_MXC_I2C5
-	select SYS_I2C_MXC_I2C6
-	select SYS_I2C_MXC_I2C7
-	select SYS_I2C_MXC_I2C8
  	imply DISTRO_DEFAULTS
  	imply PANIC_HANG
  	imply SCSI
board/freescale/common/emc2305.c +0 -0
index 8523084da9..b1ca051db2 100644

board/freescale/common/emc2305.c void set_fan_speed(u8 data) · line 31

Quoted 8 lines
board/freescale/common/emc2305.c +1 -0
@@ -24,10 +24,22 @@ void set_fan_speed(u8 data)
  			       I2C_EMC2305_FAN5};
 
  	for (index = 0; index < NUM_OF_FANS; index++) {
+#ifndef CONFIG_DM_I2C
  		if (i2c_write(I2C_EMC2305_ADDR, Fan[index], 1, &data, 1) != 0) {
  			printf("Error: failed to change fan speed @%x\n",
  			       Fan[index]);
  		}

As you switch to DM_I2C, please remove the none DM_I2C case.

Or is there a reason to support the none DM_I2C case?

bye,
Heiko

Signature · 4 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
#16 lore raw
Quoted 67 lines

-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2019年5月24日 12:49
To: Chuanhua Han <[email protected]>
Cc: albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; Udit Agarwal <[email protected]>; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/7] armv8: lx2160a: The lx2160a platform supports the I2C driver model.

Caution: EXT Email

Hello Chuanhua Han,

Am 23.05.2019 um 11:22 schrieb Chuanhua Han:

Quoted 6 lines

DM_I2C_COMPAT is a compatibility layer that allows using the non-DM I2C API when DM_I2C is used.When DM_I2C_COMPAT is not enabled for compilation, a compilation error will be generated. This patch solves the problem that the i2c-related api of the lx2160a platform does not support dm.

Quoted 6 lines
---
  arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  8 ---
  board/freescale/common/emc2305.c          | 21 ++++++
  board/freescale/common/qixis.c            | 17 +++++
  board/freescale/common/sys_eeprom.c       | 84

+++++++++++++++++++++--

Quoted 1 line
  board/freescale/common/vid.c              | 84

+++++++++++++++++++++++

Quoted 30 lines
  board/freescale/lx2160a/lx2160a.c         |  8 +++
  drivers/ddr/fsl/main.c                    | 36 +++++++++-
  7 files changed, 245 insertions(+), 13 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/Kconfig +0 -8
index a843c1eb65..f3eaab960b 100644
@@ -234,14 +234,6 @@ config ARCH_LX2160A
      select ARCH_EARLY_INIT_R
      select BOARD_EARLY_INIT_F
      select SYS_I2C_MXC
-     select SYS_I2C_MXC_I2C1
-     select SYS_I2C_MXC_I2C2
-     select SYS_I2C_MXC_I2C3
-     select SYS_I2C_MXC_I2C4
-     select SYS_I2C_MXC_I2C5
-     select SYS_I2C_MXC_I2C6
-     select SYS_I2C_MXC_I2C7
-     select SYS_I2C_MXC_I2C8
      imply DISTRO_DEFAULTS
      imply PANIC_HANG
      imply SCSI
board/freescale/common/emc2305.c +0 -0
index 8523084da9..b1ca051db2 100644

board/freescale/common/emc2305.c void set_fan_speed(u8 data) · line 28

Quoted 5 lines
board/freescale/common/emc2305.c +1 -0
@@ -24,10 +24,22 @@ void set_fan_speed(u8 data)
                             I2C_EMC2305_FAN5};
 
      for (index = 0; index < NUM_OF_FANS; index++) {
+#ifndef CONFIG_DM_I2C
              if (i2c_write(I2C_EMC2305_ADDR, Fan[index], 1, &data,

1) != 0) {

Quoted 7 lines

board/freescale/common/emc2305.c void set_fan_speed(u8 data) · line 31

Quoted 3 lines
board/freescale/common/emc2305.c +0 -0
                      printf("Error: failed to change fan speed @%x\n",
                             Fan[index]);
              }

As you switch to DM_I2C, please remove the none DM_I2C case.

Or is there a reason to support the none DM_I2C case?

There are two types of compatibility here, both DM_I2C and none DM_I2C

Quoted 8 lines

bye,
Heiko
--
--
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