armv8: lx2160a: The lx2160a platform supports the I2C driver model.
Subsystems (3)
PATCH v2 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.
---
Changes in v2:
- No change.
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 2/7 configs: lx2160a: enable DM support for pcf2127 rtc
Enable related configs to support pcf2127 rtc DM feature.
---
Changes in v2:
- No change.
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
@@ -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
@@ -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
PATCH v2 3/7 drivers: i2c: mxc: Solve the compiler error when using i2c dm mode
In reply to Chuanhua HanThis 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---
Changes in v2:
- No change.
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
@@ -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
@@ -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
PATCH v2 4/7 gpio: do not include <asm/arch/gpio.h> on ARCH_LX2160A
In reply to Chuanhua HanAs no gpio.h is defined for this architecture, to avoid compilation failure, do not include <asm/arch/gpio.h> for arch ls2160a.
---
Changes in v2:
- No change.
arch/arm/include/asm/gpio.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/gpio.h +2 -1
@@ -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
PATCH v2 5/7 armv8: dts: fsl-lx2160a: add i2c controller and gpio DT nodes
In reply to Chuanhua HanIn lx2160a soc, there are eight i2c controllers, this patch adds i2c nodes for lx2160a, and the gpio2 nodes on which the i2c4 controller depends.
---
Changes in v2:
- Delete unnecessary clockgen related attributes in the i2c
controller node
arch/arm/dts/fsl-lx2160a.dtsi | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
arch/arm/dts/fsl-lx2160a.dtsi +85 -0
@@ -49,6 +49,80 @@ <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>; + 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>; + 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>; + 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>; + 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>; + 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>; + 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>; + 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>; + status = "disabled"; + }; + uart0: serial at 21c0000 { compatible = "arm,pl011"; reg = <0x0 0x21c0000 0x0 0x1000>;
@@ -102,6 +176,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
PATCH v2 6/7 armv8: lx2160ardb : Add pcf2127 node
In reply to Chuanhua HanThis patch adds the pcf2127-rtc node under the i2c4 node.
---
Changes in v2:
- Delete unnecessary aliases about i2c.
arch/arm/dts/fsl-lx2160a-rdb.dts | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/dts/fsl-lx2160a-rdb.dts +9 -0
@@ -27,6 +27,15 @@ status = "okay"; }; +&i2c4 { + status = "okay"; + + rtc at 51 { + compatible = "pcf2127-rtc"; + reg = <0x51>; + }; +}; + &sata0 { status = "okay"; };
Signature · 1 line
2.17.1
PATCH v2 7/7 armv8: lx2160ardb : Add slave nodes under the i2c0 controller
In reply to Chuanhua HanThis patch adds some slave nodes to support the i2c dm on the device side under the i2c0 controller.
---
Changes in v2:
- Add "u-boot,dm-pre-reloc" attribute to i2c0 node.
arch/arm/dts/fsl-lx2160a-rdb.dts | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/arm/dts/fsl-lx2160a-rdb.dts +50 -0
@@ -17,6 +17,14 @@ model = "NXP Layerscape LX2160ARDB Board"; compatible = "fsl,lx2160ardb", "fsl,lx2160a"; + 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 {
@@ -27,6 +35,48 @@ status = "okay"; }; +&i2c0 { + status = "okay"; + u-boot,dm-pre-reloc; + + 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