* [PATCH] board: beagle: convert to CONFIG_DM_I2C
@ 2024-07-19 21:51 Anatolij Gustschin
2024-07-20 12:36 ` Simon Glass
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Anatolij Gustschin @ 2024-07-19 21:51 UTC (permalink / raw)
To: u-boot; +Cc: Tom Rini
Rework to remove use of legacy I2C API.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Tom Rini <trini@konsulko.com>
---
board/beagle/beagle/beagle.c | 41 +++++++++++++++++++++-------------
configs/omap3_beagle_defconfig | 2 +-
include/configs/omap3_beagle.h | 3 ---
3 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/board/beagle/beagle/beagle.c b/board/beagle/beagle/beagle.c
index ac2f89cf21..ae258817e9 100644
--- a/board/beagle/beagle/beagle.c
+++ b/board/beagle/beagle/beagle.c
@@ -41,7 +41,6 @@
#include "beagle.h"
#include <command.h>
-#define TWL4030_I2C_BUS 0
#define EXPANSION_EEPROM_I2C_BUS 1
#define EXPANSION_EEPROM_I2C_ADDRESS 0x50
@@ -213,27 +212,37 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
*/
static unsigned int get_expansion_id(void)
{
- i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
+ struct udevice *eeprom = NULL;
+ int ret;
- /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
- if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
- i2c_set_bus_num(TWL4030_I2C_BUS);
+ ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
+ EXPANSION_EEPROM_I2C_ADDRESS, 1, &eeprom);
+ if (ret)
return BEAGLE_NO_EEPROM;
- }
/* read configuration data */
- i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
- sizeof(expansion_config));
+ ret = dm_i2c_read(eeprom, 0, (uint8_t *)&expansion_config,
+ sizeof(expansion_config));
+ if (ret != 0) {
+ /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
+ return BEAGLE_NO_EEPROM;
+ }
- /* retry reading configuration data with 16bit addressing */
if ((expansion_config.device_vendor == 0xFFFFFF00) ||
(expansion_config.device_vendor == 0xFFFFFFFF)) {
printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n");
- i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config,
- sizeof(expansion_config));
}
- i2c_set_bus_num(TWL4030_I2C_BUS);
+ /* retry reading configuration data with 16bit addressing */
+ ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
+ EXPANSION_EEPROM_I2C_ADDRESS, 2, &eeprom);
+ if (ret)
+ return BEAGLE_NO_EEPROM;
+
+ ret = dm_i2c_read(eeprom, 0, (uint8_t *)&expansion_config,
+ sizeof(expansion_config));
+ if (ret != 0)
+ return BEAGLE_NO_EEPROM;
return expansion_config.device_vendor;
}
@@ -281,13 +290,13 @@ static void beagle_dvi_pup(void)
#define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
#define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
- i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
+ twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, GPIODATADIR1, &val);
val |= 4;
- i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
+ twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, GPIODATADIR1, val);
- i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
+ twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, GPIODATAOUT1, &val);
val |= 4;
- i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
+ twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, GPIODATAOUT1, val);
break;
}
}
diff --git a/configs/omap3_beagle_defconfig b/configs/omap3_beagle_defconfig
index 8a709243a9..f76709389c 100644
--- a/configs/omap3_beagle_defconfig
+++ b/configs/omap3_beagle_defconfig
@@ -61,7 +61,7 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
CONFIG_SPL_OF_TRANSLATE=y
CONFIG_USB_FUNCTION_FASTBOOT=y
CONFIG_FASTBOOT_BUF_ADDR=0x82000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
CONFIG_SPL_SYS_I2C_LEGACY=y
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS0=y
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index af7cb3513f..b616dd2608 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -28,9 +28,6 @@
/* NAND: SPL falcon mode configs */
#endif /* CONFIG_MTD_RAW_NAND */
-/* Enable Multi Bus support for I2C */
-#define CFG_I2C_MULTI_BUS
-
/* DSS Support */
/* TWL4030 LED Support */
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] board: beagle: convert to CONFIG_DM_I2C
2024-07-19 21:51 [PATCH] board: beagle: convert to CONFIG_DM_I2C Anatolij Gustschin
@ 2024-07-20 12:36 ` Simon Glass
2024-07-20 13:09 ` Anatolij Gustschin
2024-07-20 17:11 ` Tom Rini
2024-07-23 21:04 ` Tom Rini
2 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2024-07-20 12:36 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: u-boot, Tom Rini
Hi Anatolij,
On Fri, 19 Jul 2024 at 22:51, Anatolij Gustschin <agust@denx.de> wrote:
>
> Rework to remove use of legacy I2C API.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> board/beagle/beagle/beagle.c | 41 +++++++++++++++++++++-------------
> configs/omap3_beagle_defconfig | 2 +-
> include/configs/omap3_beagle.h | 3 ---
> 3 files changed, 26 insertions(+), 20 deletions(-)
>
> diff --git a/board/beagle/beagle/beagle.c b/board/beagle/beagle/beagle.c
> index ac2f89cf21..ae258817e9 100644
> --- a/board/beagle/beagle/beagle.c
> +++ b/board/beagle/beagle/beagle.c
> @@ -41,7 +41,6 @@
> #include "beagle.h"
> #include <command.h>
>
> -#define TWL4030_I2C_BUS 0
> #define EXPANSION_EEPROM_I2C_BUS 1
> #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
>
> @@ -213,27 +212,37 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
> */
> static unsigned int get_expansion_id(void)
> {
> - i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
> + struct udevice *eeprom = NULL;
> + int ret;
>
> - /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
> - if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
> - i2c_set_bus_num(TWL4030_I2C_BUS);
> + ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
> + EXPANSION_EEPROM_I2C_ADDRESS, 1, &eeprom);
> + if (ret)
> return BEAGLE_NO_EEPROM;
Isn't this in the devicetree? It should be possible to use
i2c_eeprom_read(). See for example sysinfo_rcar_probe().
> - }
>
> /* read configuration data */
> - i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
> - sizeof(expansion_config));
> + ret = dm_i2c_read(eeprom, 0, (uint8_t *)&expansion_config,
> + sizeof(expansion_config));
> + if (ret != 0) {
> + /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
> + return BEAGLE_NO_EEPROM;
> + }
>
> - /* retry reading configuration data with 16bit addressing */
> if ((expansion_config.device_vendor == 0xFFFFFF00) ||
> (expansion_config.device_vendor == 0xFFFFFFFF)) {
> printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n");
> - i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config,
> - sizeof(expansion_config));
> }
>
> - i2c_set_bus_num(TWL4030_I2C_BUS);
> + /* retry reading configuration data with 16bit addressing */
> + ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
> + EXPANSION_EEPROM_I2C_ADDRESS, 2, &eeprom);
> + if (ret)
> + return BEAGLE_NO_EEPROM;
> +
> + ret = dm_i2c_read(eeprom, 0, (uint8_t *)&expansion_config,
> + sizeof(expansion_config));
> + if (ret != 0)
> + return BEAGLE_NO_EEPROM;
>
> return expansion_config.device_vendor;
> }
> @@ -281,13 +290,13 @@ static void beagle_dvi_pup(void)
> #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
> #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
>
> - i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
> + twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, GPIODATADIR1, &val);
> val |= 4;
> - i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
> + twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, GPIODATADIR1, val);
>
> - i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
> + twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, GPIODATAOUT1, &val);
> val |= 4;
> - i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
> + twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, GPIODATAOUT1, val);
> break;
> }
> }
> diff --git a/configs/omap3_beagle_defconfig b/configs/omap3_beagle_defconfig
> index 8a709243a9..f76709389c 100644
> --- a/configs/omap3_beagle_defconfig
> +++ b/configs/omap3_beagle_defconfig
> @@ -61,7 +61,7 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
> CONFIG_SPL_OF_TRANSLATE=y
> CONFIG_USB_FUNCTION_FASTBOOT=y
> CONFIG_FASTBOOT_BUF_ADDR=0x82000000
> -CONFIG_SYS_I2C_LEGACY=y
> +CONFIG_DM_I2C=y
> CONFIG_SPL_SYS_I2C_LEGACY=y
> CONFIG_LED_STATUS=y
> CONFIG_LED_STATUS0=y
> diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
> index af7cb3513f..b616dd2608 100644
> --- a/include/configs/omap3_beagle.h
> +++ b/include/configs/omap3_beagle.h
> @@ -28,9 +28,6 @@
> /* NAND: SPL falcon mode configs */
> #endif /* CONFIG_MTD_RAW_NAND */
>
> -/* Enable Multi Bus support for I2C */
> -#define CFG_I2C_MULTI_BUS
> -
> /* DSS Support */
>
> /* TWL4030 LED Support */
> --
> 2.25.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] board: beagle: convert to CONFIG_DM_I2C
2024-07-20 12:36 ` Simon Glass
@ 2024-07-20 13:09 ` Anatolij Gustschin
2024-07-20 18:08 ` Robert Nelson
0 siblings, 1 reply; 6+ messages in thread
From: Anatolij Gustschin @ 2024-07-20 13:09 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Tom Rini
Hi Simon,
On Sat, 20 Jul 2024 13:36:04 +0100
Simon Glass sjg@chromium.org wrote:
...
> > - /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
> > - if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
> > - i2c_set_bus_num(TWL4030_I2C_BUS);
> > + ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
> > + EXPANSION_EEPROM_I2C_ADDRESS, 1, &eeprom);
> > + if (ret)
> > return BEAGLE_NO_EEPROM;
>
> Isn't this in the devicetree? It should be possible to use
> i2c_eeprom_read(). See for example sysinfo_rcar_probe().
No, it isn't in the devicetree. This EEPROM is on an optional
expansion board.
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] board: beagle: convert to CONFIG_DM_I2C
2024-07-20 13:09 ` Anatolij Gustschin
@ 2024-07-20 18:08 ` Robert Nelson
0 siblings, 0 replies; 6+ messages in thread
From: Robert Nelson @ 2024-07-20 18:08 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: Simon Glass, u-boot, Tom Rini
Thank you Anatolij, I'm really glad someone was interested in making
this board work properly in mainline u-boot!
On Sat, Jul 20, 2024 at 8:09 AM Anatolij Gustschin <agust@denx.de> wrote:
>
> Hi Simon,
>
> On Sat, 20 Jul 2024 13:36:04 +0100
> Simon Glass sjg@chromium.org wrote:
> ...
> > > - /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
> > > - if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
> > > - i2c_set_bus_num(TWL4030_I2C_BUS);
> > > + ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
> > > + EXPANSION_EEPROM_I2C_ADDRESS, 1, &eeprom);
> > > + if (ret)
> > > return BEAGLE_NO_EEPROM;
> >
> > Isn't this in the devicetree? It should be possible to use
> > i2c_eeprom_read(). See for example sysinfo_rcar_probe().
>
> No, it isn't in the devicetree. This EEPROM is on an optional
> expansion board.
Oh this expansion eeprom never really supported that many devices:
https://elinux.org/Category:BeagleBoard_Expansion_Boards
With the older pre-device tree kernel days we would pass a boot arg to
the kernel to re-pinmux the proper device configuration..
We could either just drop this part, or convert to the u-boot
expansion framework, which would use u-boot overlays..
Regards,
--
Robert Nelson
https://rcn-ee.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] board: beagle: convert to CONFIG_DM_I2C
2024-07-19 21:51 [PATCH] board: beagle: convert to CONFIG_DM_I2C Anatolij Gustschin
2024-07-20 12:36 ` Simon Glass
@ 2024-07-20 17:11 ` Tom Rini
2024-07-23 21:04 ` Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2024-07-20 17:11 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: u-boot, Robert Nelson
[-- Attachment #1: Type: text/plain, Size: 732 bytes --]
On Fri, Jul 19, 2024 at 11:51:23PM +0200, Anatolij Gustschin wrote:
> Rework to remove use of legacy I2C API.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> board/beagle/beagle/beagle.c | 41 +++++++++++++++++++++-------------
> configs/omap3_beagle_defconfig | 2 +-
> include/configs/omap3_beagle.h | 3 ---
> 3 files changed, 26 insertions(+), 20 deletions(-)
Thanks for doing the conversion. That said, as the nominal maintainer of
the platform and also given that Robert of beagleboard.org would like to
drop this initial platform support, I'll merge this update, in case
someone in the future wishes to revive it, then continue to delete.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] board: beagle: convert to CONFIG_DM_I2C
2024-07-19 21:51 [PATCH] board: beagle: convert to CONFIG_DM_I2C Anatolij Gustschin
2024-07-20 12:36 ` Simon Glass
2024-07-20 17:11 ` Tom Rini
@ 2024-07-23 21:04 ` Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2024-07-23 21:04 UTC (permalink / raw)
To: u-boot, Anatolij Gustschin
On Fri, 19 Jul 2024 23:51:23 +0200, Anatolij Gustschin wrote:
> Rework to remove use of legacy I2C API.
>
>
Applied to u-boot/master, thanks!
--
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-23 21:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19 21:51 [PATCH] board: beagle: convert to CONFIG_DM_I2C Anatolij Gustschin
2024-07-20 12:36 ` Simon Glass
2024-07-20 13:09 ` Anatolij Gustschin
2024-07-20 18:08 ` Robert Nelson
2024-07-20 17:11 ` Tom Rini
2024-07-23 21:04 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.