From: Trevor Woerner <twoerner@gmail.com>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Subject: [PATCH v2 8/8] lpc32xx: ea-lpc3250devkitv2: enable i2c (DM)
Date: Thu, 10 Jun 2021 22:37:09 -0400 [thread overview]
Message-ID: <20210611023710.35203-8-twoerner@gmail.com> (raw)
In-Reply-To: <20210611023710.35203-1-twoerner@gmail.com>
Enable a DMed i2c driver for the ea-lpc3250devkitv2 board.
Include some sample commands/output for testing.
Signed-off-by: Trevor Woerner <twoerner@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@300
+ Bus 1: i2c@400a0000
+ Bus 2: i2c@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
next prev parent reply other threads:[~2021-06-11 2:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-11 2:37 [PATCH v2 1/8] lpc32xx: Kconfig: switch to CONFIG_CONS_INDEX Trevor Woerner
2021-06-11 2:37 ` [PATCH v2 2/8] lpc32xx: import device tree from Linux Trevor Woerner
2021-06-11 2:37 ` [PATCH v2 3/8] arm: lpc32xx: add EA LPC3250 DevKitv2 board support Trevor Woerner
2021-06-11 2:37 ` [PATCH v2 4/8] lpc32xx: i2c: remove unused define Trevor Woerner
2021-06-11 2:37 ` [PATCH v2 5/8] lpc32xx: i2c: fix base address Trevor Woerner
2021-06-11 2:37 ` [PATCH v2 6/8] lpc32xx: i2c: finish DM/OF code Trevor Woerner
2021-06-11 2:37 ` [PATCH v2 7/8] Kconfig: convert CONFIG_SYS_I2C_LPC32XX Trevor Woerner
2021-06-26 18:30 ` Simon Glass
2021-06-11 2:37 ` Trevor Woerner [this message]
2021-06-26 18:30 ` [PATCH v2 1/8] lpc32xx: Kconfig: switch to CONFIG_CONS_INDEX Simon Glass
2021-07-06 22:50 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210611023710.35203-8-twoerner@gmail.com \
--to=twoerner@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox