From: Anatolij Gustschin <agust@denx.de>
To: u-boot@lists.denx.de
Cc: Nikita Kiryanov <nikita@compulab.co.il>,
Fabio Estevam <festevam@denx.de>, Heiko Schocher <hs@denx.de>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 10/11] board: cm_fx6: convert to DM_I2C
Date: Wed, 7 Aug 2024 15:09:33 +0200 [thread overview]
Message-ID: <20240807130933.846385-1-agust@denx.de> (raw)
In-Reply-To: <20240803161513.486062-10-agust@denx.de>
Conversion to DM_I2C is mandatory, enable DM_I2C to fix board
removal warning. Convert EEPROM access to use DM_I2C API.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
Cc: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Tom Rini <trini@konsulko.com>
---
Changes in v2: fix trimslice build errors
board/compulab/cm_fx6/cm_fx6.c | 3 ++-
board/compulab/common/Makefile | 8 +++++++-
board/compulab/common/eeprom.c | 14 +++++---------
board/compulab/common/eeprom.h | 2 +-
configs/cm_fx6_defconfig | 2 +-
5 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index c6d33c32cc..40047cf678 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -14,6 +14,7 @@
#include <env.h>
#include <fsl_esdhc_imx.h>
#include <init.h>
+#include <i2c.h>
#include <miiphy.h>
#include <mtd_node.h>
#include <net.h>
@@ -256,7 +257,7 @@ static int cm_fx6_setup_one_i2c(int busnum, struct i2c_pads_info *pads)
{
int ret;
- ret = setup_i2c(busnum, CONFIG_SYS_I2C_SPEED, 0x7f, pads);
+ ret = setup_i2c(busnum, I2C_SPEED_STANDARD_RATE, 0x7f, pads);
if (ret)
printf("Warning: I2C%d setup failed: %d\n", busnum, ret);
diff --git a/board/compulab/common/Makefile b/board/compulab/common/Makefile
index 7c8226e6e1..c7b2237e5c 100644
--- a/board/compulab/common/Makefile
+++ b/board/compulab/common/Makefile
@@ -4,6 +4,12 @@
#
# Author: Igor Grinberg <grinberg@compulab.co.il>
+CL_EEPROM=y
+
+ifdef CONFIG_TARGET_TRIMSLICE
+CL_EEPROM=
+endif
+
obj-y += common.o
-obj-$(CONFIG_$(SPL_)SYS_I2C_LEGACY) += eeprom.o
+obj-$(CL_EEPROM) += eeprom.o
obj-$(CONFIG_SMC911X) += omap3_smc911x.o
diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index efdaf342d5..1b12d09604 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -34,19 +34,15 @@ static int cl_eeprom_layout; /* Implicitly LAYOUT_INVALID */
static int cl_eeprom_read(uint offset, uchar *buf, int len)
{
+ struct udevice *eeprom;
int res;
- unsigned int current_i2c_bus = i2c_get_bus_num();
- res = i2c_set_bus_num(cl_eeprom_bus);
- if (res < 0)
+ res = i2c_get_chip_for_busnum(cl_eeprom_bus, CONFIG_SYS_I2C_EEPROM_ADDR,
+ CONFIG_SYS_I2C_EEPROM_ADDR_LEN, &eeprom);
+ if (res)
return res;
- res = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, offset,
- CONFIG_SYS_I2C_EEPROM_ADDR_LEN, buf, len);
-
- i2c_set_bus_num(current_i2c_bus);
-
- return res;
+ return dm_i2c_read(eeprom, offset, (uint8_t *)buf, len);
}
static int cl_eeprom_setup(uint eeprom_bus)
diff --git a/board/compulab/common/eeprom.h b/board/compulab/common/eeprom.h
index 9bd7604a99..0a44926ebd 100644
--- a/board/compulab/common/eeprom.h
+++ b/board/compulab/common/eeprom.h
@@ -10,7 +10,7 @@
#define _EEPROM_
#include <errno.h>
-#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
+#if !CONFIG_IS_ENABLED(TARGET_TRIMSLICE)
int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus);
u32 cl_eeprom_get_board_rev(uint eeprom_bus);
int cl_eeprom_get_product_name(uchar *buf, uint eeprom_bus);
diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index 386616cc42..81a39f7073 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -80,7 +80,7 @@ CONFIG_BOUNCE_BUFFER=y
CONFIG_DWC_AHSATA=y
# CONFIG_DWC_AHSATA_AHCI is not set
CONFIG_LBA48=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
CONFIG_SPL_SYS_I2C_LEGACY=y
CONFIG_SYS_I2C_MXC=y
CONFIG_SYS_MXC_I2C3_SPEED=400000
--
2.25.1
next prev parent reply other threads:[~2024-08-07 13:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-03 16:15 [PATCH 01/11] board: shc: convert to DM_I2C Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 02/11] board: chiliboard: " Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 03/11] board: cm-t43: " Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 04/11] board: igep003x: " Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 05/11] board: sl50: " Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 06/11] board: rut: " Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 07/11] board: novena: " Anatolij Gustschin
2024-08-04 0:21 ` Marek Vasut
2024-08-03 16:15 ` [PATCH 08/11] board: vining_2000: " Anatolij Gustschin
2024-08-07 22:34 ` [PATCH v2 " Anatolij Gustschin
2024-08-03 16:15 ` [PATCH 09/11] board: sniper: " Anatolij Gustschin
2024-08-04 10:05 ` Paul Kocialkowski
2024-08-03 16:15 ` [PATCH 10/11] board: cm_fx6: " Anatolij Gustschin
2024-08-07 11:16 ` Heiko Schocher
2024-08-07 13:11 ` Anatolij Gustschin
2024-08-07 13:47 ` Heiko Schocher
2024-08-07 13:09 ` Anatolij Gustschin [this message]
2024-08-07 13:44 ` [PATCH v2 " Fabio Estevam
2024-08-03 16:15 ` [PATCH 11/11] board: vf610twr: " Anatolij Gustschin
2024-08-05 4:54 ` [PATCH 01/11] board: shc: " Heiko Schocher
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=20240807130933.846385-1-agust@denx.de \
--to=agust@denx.de \
--cc=festevam@denx.de \
--cc=hs@denx.de \
--cc=nikita@compulab.co.il \
--cc=trini@konsulko.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