[PATCH v2 8/8] lpc32xx: ea-lpc3250devkitv2: enable i2c (DM)

Trevor Woerner twoerner at gmail.com
Fri Jun 11 04:37:09 CEST 2021


Enable a DMed i2c driver for the ea-lpc3250devkitv2 board.
Include some sample commands/output for testing.

Signed-off-by: Trevor Woerner <twoerner at gmail.com>

---

Changes in v2:
- added

 board/ea/ea-lpc3250devkitv2/README.rst        | 54 +++++++++++++++++++
 .../ea-lpc3250devkitv2/ea-lpc3250devkitv2.c   |  4 ++
 configs/ea-lpc3250devkitv2_defconfig          |  3 ++
 3 files changed, 61 insertions(+)

diff --git a/board/ea/ea-lpc3250devkitv2/README.rst b/board/ea/ea-lpc3250devkitv2/README.rst
index 56b5d0dbb1..1b78000331 100644
--- a/board/ea/ea-lpc3250devkitv2/README.rst
+++ b/board/ea/ea-lpc3250devkitv2/README.rst
@@ -4,6 +4,7 @@ ToC:
 - Introduction
 - Booting
 - Debugging
+- i2c
 
 
 Introduction
@@ -130,3 +131,56 @@ dongle from Olimex successfully as follows:
 	# openocd \
 		-f interface/ftdi/olimex-arm-usb-ocd-h.cfg \
 		-f board/phytec_lpc3250.cfg
+
+
+i2c
+===
+Some of the LEDs on the board are connected via an I/O Expander (PCA9532) that
+is attached to the i2c1 bus. Here is a sample session of toggling some of
+these LEDs via i2c in U-Boot:
+
+show the existing i2c busses:
+	EA-LPC3250v2=> i2c bus
+	Bus 0:  i2c at 300
+	Bus 1:  i2c at 400a0000
+	Bus 2:  i2c at 400a8000
+
+set i2c1 as the current bus:
+	EA-LPC3250v2=> i2c dev 1
+	Setting bus to 1
+
+see what potential devices are found with rudimentary probing on i2c1:
+	EA-LPC3250v2=> i2c probe
+	Valid chip addresses: 1A 1D 48 50 57 60 66 6E
+
+According to the schematics the i2c slave address of the PCA9532 is 0x60.
+
+dump all of the 10 registers from the I/O Expander; NOTE that the 0x10 in the
+command specifies the self-incrementing mode of the PCA9532; also NOTE that
+the values repeat themseves to fill out a full 16 bytes:
+	EA-LPC3250v2=> i2c md 0x60 0x10 10
+	0010: 00 ff 00 80 00 80 00 00 00 00 4f ff 00 80 00 80    ..........O.....
+
+turn on LEDs 23, 25, 27, and 29 (green):
+	EA-LPC3250v2=> i2c mw 0x60 9 0x55
+
+turn on LEDs 22, 24, 26, and 28 (red):
+	EA-LPC3250v2=> i2c mw 0x60 8 0x55
+
+dim the green LEDs (23, 25, 27, 29):
+	EA-LPC3250v2=> i2c mw 0x60 3 0x20
+	EA-LPC3250v2=> i2c mw 0x60 9 0xaa
+
+turn off all LEDs (23-29):
+	EA-LPC3250v2=> i2c mw 0x60 8 0
+	EA-LPC3250v2=> i2c mw 0x60 9 0
+
+read value of switches (input):
+	EA-LPC3250v2=> i2c md 0x60 0 1
+	0000: 4f    O
+[none are pressed]
+
+press and hold SW2 while running the following:
+	EA-LPC3250v2=> i2c md 0x60 0 1
+	0000: 4e    N
+[SW2 is pressed]
diff --git a/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c b/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c
index 7a19400041..72cf46c749 100644
--- a/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c
+++ b/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c
@@ -19,6 +19,10 @@ int
 board_early_init_f(void)
 {
 	lpc32xx_uart_init(CONFIG_CONS_INDEX);
+	if (IS_ENABLED(CONFIG_SYS_I2C_LPC32XX)) {
+		lpc32xx_i2c_init(1);
+		lpc32xx_i2c_init(2);
+	}
 	return 0;
 }
 
diff --git a/configs/ea-lpc3250devkitv2_defconfig b/configs/ea-lpc3250devkitv2_defconfig
index dc90e16475..e8d60b573e 100644
--- a/configs/ea-lpc3250devkitv2_defconfig
+++ b/configs/ea-lpc3250devkitv2_defconfig
@@ -14,9 +14,12 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SYS_PROMPT="EA-LPC3250v2=> "
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
 CONFIG_OF_CONTROL=y
 # CONFIG_NET is not set
 CONFIG_LPC32XX_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_LPC32XX=y
 CONFIG_SPECIFY_CONSOLE_INDEX=y
 CONFIG_CONS_INDEX=5
 CONFIG_SYS_NS16550=y
-- 
2.30.0.rc0



More information about the U-Boot mailing list