public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model
@ 2024-08-09 17:58 Fabio Estevam
  2024-08-09 17:58 ` [PATCH 2/2] tqma6: Do not print the board name twice Fabio Estevam
  2024-08-13 16:28 ` [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model Fabio Estevam
  0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2024-08-09 17:58 UTC (permalink / raw)
  To: Markus.Niebel; +Cc: u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Currently, the power_init_board() function is not executed because
CONFIG_POWER_LEGACY is not selected.

Convert to PMIC driver model, which allows removing board I2C code in
favor of the I2C driver model.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 board/tq/tqma6/tqma6.c  | 61 +++++++----------------------------------
 include/configs/tqma6.h |  8 ------
 2 files changed, 10 insertions(+), 59 deletions(-)

diff --git a/board/tq/tqma6/tqma6.c b/board/tq/tqma6/tqma6.c
index 92142c10ae5a..02a2022c3c84 100644
--- a/board/tq/tqma6/tqma6.c
+++ b/board/tq/tqma6/tqma6.c
@@ -19,11 +19,9 @@
 #include <linux/errno.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
-#include <asm/mach-imx/mxc_i2c.h>
 #include <asm/mach-imx/spi.h>
 #include <fsl_esdhc_imx.h>
 #include <linux/libfdt.h>
-#include <i2c.h>
 #include <mmc.h>
 #include <power/pfuze100_pmic.h>
 #include <power/pmic.h>
@@ -48,10 +46,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
 	PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
 
-#define I2C_PAD_CTRL	(PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
-	PAD_CTL_DSE_80ohm | PAD_CTL_HYS |			\
-	PAD_CTL_ODE | PAD_CTL_SRE_FAST)
-
 int dram_init(void)
 {
 	gd->ram_size = imx_ddr_size();
@@ -170,38 +164,6 @@ int board_spi_cs_gpio(unsigned bus, unsigned cs)
 #endif
 #endif
 
-#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
-static struct i2c_pads_info tqma6_i2c3_pads = {
-	/* I2C3: on board LM75, M24C64,  */
-	.scl = {
-		.i2c_mode = NEW_PAD_CTRL(MX6_PAD_GPIO_5__I2C3_SCL,
-					 I2C_PAD_CTRL),
-		.gpio_mode = NEW_PAD_CTRL(MX6_PAD_GPIO_5__GPIO1_IO05,
-					  I2C_PAD_CTRL),
-		.gp = IMX_GPIO_NR(1, 5)
-	},
-	.sda = {
-		.i2c_mode = NEW_PAD_CTRL(MX6_PAD_GPIO_6__I2C3_SDA,
-					 I2C_PAD_CTRL),
-		.gpio_mode = NEW_PAD_CTRL(MX6_PAD_GPIO_6__GPIO1_IO06,
-					  I2C_PAD_CTRL),
-		.gp = IMX_GPIO_NR(1, 6)
-	}
-};
-
-static void tqma6_setup_i2c(void)
-{
-	int ret;
-	/*
-	 * use logical index for bus, e.g. I2C1 -> 0
-	 * warn on error
-	 */
-	ret = setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &tqma6_i2c3_pads);
-	if (ret)
-		printf("setup I2C3 failed: %d\n", ret);
-}
-#endif
-
 int board_early_init_f(void)
 {
 	return tqma6_bb_board_early_init_f();
@@ -215,10 +177,6 @@ int board_init(void)
 #ifndef CONFIG_DM_SPI
 	tqma6_iomuxc_spi();
 #endif
-#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
-	tqma6_setup_i2c();
-#endif
-
 	tqma6_bb_board_init();
 
 	return 0;
@@ -246,21 +204,22 @@ static const char *tqma6_get_boardname(void)
 	};
 }
 
-#if CONFIG_IS_ENABLED(POWER_LEGACY)
+#if CONFIG_IS_ENABLED(DM_PMIC)
 /* setup board specific PMIC */
 int power_init_board(void)
 {
-	struct pmic *p;
+	struct udevice *dev;
 	u32 reg, rev;
+	int ret;
 
-	power_pfuze100_init(TQMA6_PFUZE100_I2C_BUS);
-	p = pmic_get("PFUZE100");
-	if (p && !pmic_probe(p)) {
-		pmic_reg_read(p, PFUZE100_DEVICEID, &reg);
-		pmic_reg_read(p, PFUZE100_REVID, &rev);
-		printf("PMIC: PFUZE100 ID=0x%02x REV=0x%02x\n", reg, rev);
-	}
+	ret = pmic_get("pmic@8", &dev);
+	if (ret < 0)
+		return 0;
+
+	reg = pmic_reg_read(dev, PFUZE100_DEVICEID);
+	rev = pmic_reg_read(dev, PFUZE100_REVID);
 
+	printf("PMIC:  PFUZE100 ID=0x%02x REV=0x%02x\n", reg, rev);
 	return 0;
 }
 #endif
diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h
index 2da76f154313..b4a06a75c538 100644
--- a/include/configs/tqma6.h
+++ b/include/configs/tqma6.h
@@ -26,14 +26,6 @@
 
 #define TQMA6_SPI_FLASH_SECTOR_SIZE	SZ_64K
 
-/* I2C Configs */
-#define CFG_I2C_MULTI_BUS
-
-#if !defined(CONFIG_DM_PMIC)
-#define CFG_POWER_PFUZE100_I2C_ADDR	0x08
-#define TQMA6_PFUZE100_I2C_BUS		2
-#endif
-
 /* MMC Configs */
 #define CFG_SYS_FSL_ESDHC_ADDR	0
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tqma6: Do not print the board name twice
  2024-08-09 17:58 [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model Fabio Estevam
@ 2024-08-09 17:58 ` Fabio Estevam
  2024-08-13 16:28 ` [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model Fabio Estevam
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2024-08-09 17:58 UTC (permalink / raw)
  To: Markus.Niebel; +Cc: u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Currently, the devicetree model as well as the board variant name
are shown:
...    
Model: TQ TQMa6S/DL on MBa6x
Board: TQMa6DL on a MBa6x
...
    
Unselect the CONFIG_DISPLAY_BOARDINFO option so that the
board name is printed only once in board_late_init() instead.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 board/tq/tqma6/tqma6.c             | 5 -----
 configs/tqma6dl_mba6_mmc_defconfig | 1 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/board/tq/tqma6/tqma6.c b/board/tq/tqma6/tqma6.c
index 02a2022c3c84..445ce987b683 100644
--- a/board/tq/tqma6/tqma6.c
+++ b/board/tq/tqma6/tqma6.c
@@ -230,11 +230,6 @@ int board_late_init(void)
 
 	tqma6_bb_board_late_init();
 
-	return 0;
-}
-
-int checkboard(void)
-{
 	printf("Board: %s on a %s\n", tqma6_get_boardname(),
 	       tqma6_bb_get_boardname());
 	return 0;
diff --git a/configs/tqma6dl_mba6_mmc_defconfig b/configs/tqma6dl_mba6_mmc_defconfig
index be891d24537f..d0c5db65177c 100644
--- a/configs/tqma6dl_mba6_mmc_defconfig
+++ b/configs/tqma6dl_mba6_mmc_defconfig
@@ -17,6 +17,7 @@ CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run mmcboot; run netboot; run panicboot"
 CONFIG_DEFAULT_FDT_FILE="imx6dl-mba6x.dtb"
 CONFIG_SYS_PBSIZE=532
+# CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_BOOTZ=y
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model
  2024-08-09 17:58 [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model Fabio Estevam
  2024-08-09 17:58 ` [PATCH 2/2] tqma6: Do not print the board name twice Fabio Estevam
@ 2024-08-13 16:28 ` Fabio Estevam
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2024-08-13 16:28 UTC (permalink / raw)
  To: Markus.Niebel; +Cc: u-boot, Fabio Estevam

On Fri, Aug 9, 2024 at 2:58 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> From: Fabio Estevam <festevam@denx.de>
>
> Currently, the power_init_board() function is not executed because
> CONFIG_POWER_LEGACY is not selected.
>
> Convert to PMIC driver model, which allows removing board I2C code in
> favor of the I2C driver model.
>
> Signed-off-by: Fabio Estevam <festevam@denx.de>

Applied both, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-13 16:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09 17:58 [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model Fabio Estevam
2024-08-09 17:58 ` [PATCH 2/2] tqma6: Do not print the board name twice Fabio Estevam
2024-08-13 16:28 ` [PATCH 1/2] tqma6: Convert to PMIC and I2C driver model Fabio Estevam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox