Re: [PATCH v2 1/3] cmd: pci: Add command to set MPS of all PCIe devices

2023-04-03 Thread Stephen Carlson

Thank you Tom!

Stephen Carlson

-Original Message-
From: Tom Rini 
Sent: Friday, March 31, 2023 7:17 AM
To: stcar...@linux.microsoft.com
Cc: u-boot@lists.denx.de
Subject: [EXTERNAL] Re: [PATCH v2 1/3] cmd: pci: Add command to set MPS of 
all PCIe devices


On Fri, Mar 10, 2023 at 11:07:13AM -0800, stcar...@linux.microsoft.com 
wrote:



From: Stephen Carlson 

Enable tuning of the PCI Express MPS (Maximum Payload Size) of each
device. The Maximum Read Request Size is not altered.

The SAFE method uses the largest MPS value supported by all devices in
the system for each device. This method is the same algorithm as used
by Linux pci=pcie_bus_safe.

The PEER2PEER method sets all devices to the minimal (128 byte) MPS,
which allows hot plug of devices later that might only support the
minimum size, and ensures compatibility of DMA between two devices on 

the bus.


Signed-off-by: Stephen Carlson 


Applied to u-boot/next, thanks!

--
Tom


Re: Re: [PATCH 2/2] drivers: mmc: Add wait_dat0 support for sdhci driver

2021-08-31 Thread Stephen Carlson

Jaehoon,

readx_poll_timeout expands to read_poll_timeout which accepts the signature:

read_poll_timeout(op, addr, val, cond, sleep_us, timeout_us)

sdhci_readl requires two arguments, host and SHCI_PRESENT_STATE, which 
cannot both be provided to that macro in the addr parameter. One potential 
workaround would be to declare a static helper function to call 
sdhci_readl with a constant second parameter, but this proposal would 
increase function call overhead and stack usage. Is it worth changing for 
the readability improvement?


Thanks,

Stephen Carlson

-Original Message-
From: Jaehoon Chung 
Sent: Friday, August 27, 2021 10:14 PM
To: stcar...@linux.microsoft.com; u-boot@lists.denx.de
Cc: Peng Fan 
Subject: Re: [PATCH 2/2] drivers: mmc: Add wait_dat0 support for sdhci 
driver


On 8/18/21 4:46 AM, stcar...@linux.microsoft.com wrote:

From: Stephen Carlson 

Adds an implementation of the wait_dat0 MMC operation for the DM SDHCI
driver, allowing the driver to continue when the card is ready rather
than waiting for the worst case time on each MMC switch operation.

Signed-off-by: Stephen Carlson 
---
 drivers/mmc/sdhci.c | 20 
 include/sdhci.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index
eea4701d8a..bb55e00ef5 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -775,6 +775,25 @@ static int sdhci_get_cd(struct udevice *dev)
return value;
 }

+static int sdhci_wait_dat0(struct udevice *dev, int state,
+  int timeout_us)
+{
+   int tmp;
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+   struct sdhci_host *host = mmc->priv;
+   unsigned long timeout = timer_get_us() + timeout_us;
+
+   // readx_poll_timeout is unsuitable because sdhci_readl accepts
+   // two arguments


Removed the comment or use "/* */" instead of "//"
And i didn't understand what's unsuitable?

Best Regards,
Jaehoon Chung


+   do {
+   tmp = sdhci_readl(host, SDHCI_PRESENT_STATE);
+   if (!!(tmp & SDHCI_DATA_0_LVL_MASK) == !!state)
+   return 0;
+   } while (!timeout_us || !time_after(timer_get_us(), timeout));
+
+   return -ETIMEDOUT;
+}
+
 const struct dm_mmc_ops sdhci_ops = {
.send_cmd   = sdhci_send_command,
.set_ios= sdhci_set_ios,
@@ -783,6 +802,7 @@ const struct dm_mmc_ops sdhci_ops = {  #ifdef
MMC_SUPPORTS_TUNING
.execute_tuning = sdhci_execute_tuning,
 #endif
+   .wait_dat0  = sdhci_wait_dat0,
 };
 #else
 static const struct mmc_ops sdhci_ops = { diff --git
a/include/sdhci.h b/include/sdhci.h index 0ae9471ad7..dd4eb41442
100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -65,6 +65,8 @@
 #define  SDHCI_CARD_STATE_STABLE   BIT(17)
 #define  SDHCI_CARD_DETECT_PIN_LEVEL   BIT(18)
 #define  SDHCI_WRITE_PROTECT   BIT(19)
+#define  SDHCI_DATA_LVL_MASK   0x00F0
+#define   SDHCI_DATA_0_LVL_MASK BIT(20)

 #define SDHCI_HOST_CONTROL 0x28
 #define  SDHCI_CTRL_LEDBIT(0)





[PATCH v3 9/9] board: freescale: ls2088a: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 configs/ls2088aqds_tfa_defconfig  | 1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls2088ardb_qspi_defconfig | 1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  | 1 +
 configs/ls2088ardb_tfa_defconfig  | 1 +
 5 files changed, 5 insertions(+)

diff --git a/configs/ls2088aqds_tfa_defconfig b/configs/ls2088aqds_tfa_defconfig
index 75986f90ab..6eb707206e 100644
--- a/configs/ls2088aqds_tfa_defconfig
+++ b/configs/ls2088aqds_tfa_defconfig
@@ -89,3 +89,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
index 51d114337d..2575345703 100644
--- a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
@@ -66,3 +66,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_qspi_defconfig 
b/configs/ls2088ardb_qspi_defconfig
index 3b9b53bc87..1cc382c811 100644
--- a/configs/ls2088ardb_qspi_defconfig
+++ b/configs/ls2088ardb_qspi_defconfig
@@ -71,3 +71,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
index ef7965fdbb..b05bfbce71 100644
--- a/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
@@ -82,3 +82,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_tfa_defconfig b/configs/ls2088ardb_tfa_defconfig
index 86254b0314..decf6a84d7 100644
--- a/configs/ls2088ardb_tfa_defconfig
+++ b/configs/ls2088ardb_tfa_defconfig
@@ -87,3 +87,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1



[PATCH v3 8/9] board: freescale: t2080qds: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/t208xqds/t208xqds.c   | 26 +--
 configs/T2080QDS_NAND_defconfig   |  1 +
 configs/T2080QDS_SDCARD_defconfig |  1 +
 configs/T2080QDS_SECURE_BOOT_defconfig|  1 +
 configs/T2080QDS_SPIFLASH_defconfig   |  1 +
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig |  1 +
 configs/T2080QDS_defconfig|  1 +
 7 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/board/freescale/t208xqds/t208xqds.c 
b/board/freescale/t208xqds/t208xqds.c
index fd3217f24d..715de106d6 100644
--- a/board/freescale/t208xqds/t208xqds.c
+++ b/board/freescale/t208xqds/t208xqds.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "../common/vsc3316_3308.h"
@@ -79,31 +80,6 @@ int checkboard(void)
return 0;
 }

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
return select_i2c_ch_pca9547(channel, 0);
diff --git a/configs/T2080QDS_NAND_defconfig b/configs/T2080QDS_NAND_defconfig
index b395bf17aa..b06117bda2 100644
--- a/configs/T2080QDS_NAND_defconfig
+++ b/configs/T2080QDS_NAND_defconfig
@@ -83,3 +83,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SDCARD_defconfig 
b/configs/T2080QDS_SDCARD_defconfig
index 53b82f789f..7c4ba2f53c 100644
--- a/configs/T2080QDS_SDCARD_defconfig
+++ b/configs/T2080QDS_SDCARD_defconfig
@@ -80,3 +80,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SECURE_BOOT_defconfig 
b/configs/T2080QDS_SECURE_BOOT_defconfig
index 4d33dc6a3a..f8f031f778 100644
--- a/configs/T2080QDS_SECURE_BOOT_defconfig
+++ b/configs/T2080QDS_SECURE_BOOT_defconfig
@@ -70,3 +70,4 @@ CONFIG_SYS_NUM_ADDR_MAP=64
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SPIFLASH_defconfig 
b/configs/T2080QDS_SPIFLASH_defconfig
index aa4f094cb5..2230e214d4 100644
--- a/configs/T2080QDS_SPIFLASH_defconfig
+++ b/configs/T2080QDS_SPIFLASH_defconfig
@@ -82,3 +82,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig 
b/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig
index 0677053e21..9ab1cdfe8c 100644
--- a/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig
+++ b/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig
@@ -60,3 +60,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_defconfig b/configs/T2080QDS_defconfig
index c9d1fec300..1cbc947454 100644
--- a/configs/T2080QDS_defconfig
+++ b/configs/T2080QDS_defconfig
@@ -68,3 +68,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1



[PATCH v3 7/9] board: freescale: lx2160a: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/lx2160a/lx2160a.c | 31 ---
 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2160aqds_tfa_defconfig  |  1 +
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2160ardb_tfa_defconfig  |  1 +
 configs/lx2160ardb_tfa_stmm_defconfig |  1 +
 configs/lx2162aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2162aqds_tfa_defconfig  |  1 +
 .../lx2162aqds_tfa_verified_boot_defconfig|  1 +
 9 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 47a7024f33..04a6296a36 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"
+
 #include "../common/qixis.h"
 #include "../common/vid.h"
 #include 
@@ -79,27 +81,6 @@ U_BOOT_DRVINFO(nxp_serial1) = {
.plat = ,
 };

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-
-#if !CONFIG_IS_ENABLED(DM_I2C)
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#else
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 static void uart_get_clock(void)
 {
serial0.clock = get_serial_clock();
@@ -115,10 +96,10 @@ int board_early_init_f(void)
uart_get_clock();

 #ifdef CONFIG_EMC2305
-   select_i2c_ch_pca9547(I2C_MUX_CH_EMC2305);
+   select_i2c_ch_pca9547(I2C_MUX_CH_EMC2305, 0);
emc2305_init(I2C_EMC2305_ADDR);
set_fan_speed(I2C_EMC2305_PWM, I2C_EMC2305_ADDR);
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
 #endif

fsl_lsch3_early_init_f();
@@ -275,7 +256,7 @@ int esdhc_status_fixup(void *blob, const char *compat)
 #if defined(CONFIG_VID)
 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
-   return select_i2c_ch_pca9547(channel);
+   return select_i2c_ch_pca9547(channel, 0);
 }

 int init_func_vid(void)
@@ -611,7 +592,7 @@ int board_init(void)
gd->env_addr = (ulong)_environment[0];
 #endif

-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);

 #if defined(CONFIG_FSL_MC_ENET) && defined(CONFIG_TARGET_LX2160ARDB)
/* invert AQR107 IRQ pins polarity */
diff --git a/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig 
b/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig
index 5cdf47221f..9c5d0067dc 100644
--- a/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig
@@ -85,3 +85,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160aqds_tfa_defconfig b/configs/lx2160aqds_tfa_defconfig
index d6fbfe0f9e..2a755e0574 100644
--- a/configs/lx2160aqds_tfa_defconfig
+++ b/configs/lx2160aqds_tfa_defconfig
@@ -91,3 +91,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_WDT=y
 CONFIG_WDT_SBSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig 
b/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig
index 8151ebdb2a..40fbaca4ed 100644
--- a/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig
@@ -76,3 +76,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160ardb_tfa_defconfig b/configs/lx2160ardb_tfa_defconfig
index 1dbf8f08c2..b75d217d67 100644
--- a/configs/lx2160ardb_tfa_defconfig
+++ b/configs/lx2160ardb_tfa_defconfig
@@ -86,3 +86,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_WDT=y
 CONFIG_WDT_SBSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160ardb_tfa_stmm_defconfig 
b/configs/lx2160ardb_tfa_stmm_defconfig
index 9b921e73e6..9d1e9dc5b7 100644
--- a/configs/lx2160ardb_tfa_stmm_defconfig
+++ b/configs/lx2160ardb_tfa_stmm_defconfig
@@ -85,3 +85,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_MM_COMM_TEE=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig 
b/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig
index 2840fd9bb5..f9fdee8a09 100644
--- a/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig
@@ -88,3 +88,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2162aqds_tfa_defconfig 

[PATCH v3 6/9] board: freescale: ls2080: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls2080aqds/ls2080aqds.c  | 25 ++
 board/freescale/ls2080ardb/ls2080ardb.c  | 27 +++-
 configs/ls2080aqds_SECURE_BOOT_defconfig |  1 +
 configs/ls2080aqds_defconfig |  1 +
 configs/ls2080aqds_nand_defconfig|  1 +
 configs/ls2080aqds_qspi_defconfig|  1 +
 configs/ls2080aqds_sdcard_defconfig  |  1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig |  1 +
 configs/ls2080ardb_defconfig |  1 +
 configs/ls2080ardb_nand_defconfig|  1 +
 configs/ls2081ardb_defconfig |  1 +
 11 files changed, 14 insertions(+), 47 deletions(-)

diff --git a/board/freescale/ls2080aqds/ls2080aqds.c 
b/board/freescale/ls2080aqds/ls2080aqds.c
index 9572319234..c48b01f7d7 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "ls2080aqds_qixis.h"
@@ -161,27 +161,6 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int config_board_mux(int ctrl_type)
 {
u8 reg5;
@@ -235,7 +214,7 @@ int board_init(void)
 #ifdef CONFIG_ENV_IS_NOWHERE
gd->env_addr = (ulong)_environment[0];
 #endif
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);

 #ifdef CONFIG_RTC_ENABLE_32KHZ_OUTPUT
 #if CONFIG_IS_ENABLED(DM_I2C)
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c 
b/board/freescale/ls2080ardb/ls2080ardb.c
index 3a026b0827..6504cf768f 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #ifdef CONFIG_FSL_QIXIS
 #include "../common/qixis.h"
@@ -205,31 +206,9 @@ unsigned long get_board_sys_clk(void)
return 1;
 }

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-
-#if !CONFIG_IS_ENABLED(DM_I2C)
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#else
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-#endif
-
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
-   return select_i2c_ch_pca9547(channel);
+   return select_i2c_ch_pca9547(channel, 0);
 }

 int config_board_mux(int ctrl_type)
@@ -267,7 +246,7 @@ int board_init(void)
 #ifdef CONFIG_ENV_IS_NOWHERE
gd->env_addr = (ulong)_environment[0];
 #endif
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);

 #ifdef CONFIG_FSL_QIXIS
QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN);
diff --git a/configs/ls2080aqds_SECURE_BOOT_defconfig 
b/configs/ls2080aqds_SECURE_BOOT_defconfig
index f984149983..8fca07fc93 100644
--- a/configs/ls2080aqds_SECURE_BOOT_defconfig
+++ b/configs/ls2080aqds_SECURE_BOOT_defconfig
@@ -68,3 +68,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_defconfig b/configs/ls2080aqds_defconfig
index 9a69d143d1..681afc027d 100644
--- a/configs/ls2080aqds_defconfig
+++ b/configs/ls2080aqds_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_nand_defconfig 
b/configs/ls2080aqds_nand_defconfig
index bb36da157b..54cca1990d 100644
--- a/configs/ls2080aqds_nand_defconfig
+++ b/configs/ls2080aqds_nand_defconfig
@@ -76,3 +76,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_qspi_defconfig 
b/configs/ls2080aqds_qspi_defconfig
index cbdf733456..51ab47a583 100644
--- a/configs/ls2080aqds_qspi_defconfig
+++ b/configs/ls2080aqds_qspi_defconfig
@@ -68,3 +68,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_sdcard_defconfig 
b/configs/l

[PATCH v3 5/9] board: freescale: ls1088a: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1088a/ls1088a.c | 32 ---
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 13 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/board/freescale/ls1088a/ls1088a.c 
b/board/freescale/ls1088a/ls1088a.c
index f5dc449d89..2f422634d5 100644
--- a/board/freescale/ls1088a/ls1088a.c
+++ b/board/freescale/ls1088a/ls1088a.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "ls1088a_qixis.h"
@@ -415,34 +416,13 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-
-#if !CONFIG_IS_ENABLED(DM_I2C)
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#else
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 #if !defined(CONFIG_SPL_BUILD)
 void board_retimer_init(void)
 {
u8 reg;

/* Retimer is connected to I2C1_CH5 */
-   select_i2c_ch_pca9547(I2C_MUX_CH5);
+   select_i2c_ch_pca9547(I2C_MUX_CH5, 0);

/* Access to Control/Shared register */
reg = 0x0;
@@ -532,7 +512,7 @@ void board_retimer_init(void)

 #ifdef CONFIG_TARGET_LS1088AQDS
/* Retimer is connected to I2C1_CH5 */
-   select_i2c_ch_pca9547(I2C_MUX_CH5);
+   select_i2c_ch_pca9547(I2C_MUX_CH5, 0);

/* Access to Control/Shared register */
reg = 0x0;
@@ -620,7 +600,7 @@ void board_retimer_init(void)

 #endif
/*return the default channel*/
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
 }

 #ifdef CONFIG_MISC_INIT_R
@@ -669,7 +649,7 @@ int misc_init_r(void)

 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
-   return select_i2c_ch_pca9547(channel);
+   return select_i2c_ch_pca9547(channel, 0);
 }

 #ifdef CONFIG_TARGET_LS1088AQDS
@@ -827,7 +807,7 @@ int board_init(void)
u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
 #endif

-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
board_retimer_init();

 #ifdef CONFIG_ENV_IS_NOWHERE
diff --git a/configs/ls1088aqds_defconfig b/configs/ls1088aqds_defconfig
index 55e52c8770..c36f37d5d1 100644
--- a/configs/ls1088aqds_defconfig
+++ b/configs/ls1088aqds_defconfig
@@ -74,3 +74,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
index 9dc5f8dbb2..d401b91c40 100644
--- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
@@ -75,3 +75,4 @@ CONFIG_USB_GADGET=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_qspi_defconfig 
b/configs/ls1088aqds_qspi_defconfig
index 91903bd110..5711464e77 100644
--- a/configs/ls1088aqds_qspi_defconfig
+++ b/configs/ls1088aqds_qspi_defconfig
@@ -76,3 +76,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_sdcard_ifc_defconfig 
b/configs/ls1088aqds_sdcard_ifc_defconfig
index fcb48741e3..fdeddaef44 100644
--- a/configs/ls1088aqds_sdcard_ifc_defconfig
+++ b/configs/ls1088aqds_sdcard_ifc_defconfig
@@ -82,3 +82,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig 
b/configs/ls1088aqds_sdcard_qspi_defconfig
index 3e8c269add..6f30c6a284 100644
--- a/configs/ls1088aqds_sdcard_qspi_defconfig
+++ b/configs/ls1088aqds_sdcard_qspi_defconfig
@@ -85,3 +85,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_tfa_defconfig b/configs/ls1088aqds_tfa_defco

[PATCH v3 4/9] board: freescale: ls1046a: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1046afrwy/ls1046afrwy.c | 27 +--
 board/freescale/ls1046aqds/ls1046aqds.c   | 26 +-
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046afrwy_tfa_defconfig |  1 +
 configs/ls1046aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_defconfig  |  1 +
 configs/ls1046aqds_lpuart_defconfig   |  1 +
 configs/ls1046aqds_nand_defconfig |  1 +
 configs/ls1046aqds_qspi_defconfig |  1 +
 configs/ls1046aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1046aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_tfa_defconfig  |  1 +
 13 files changed, 13 insertions(+), 51 deletions(-)

diff --git a/board/freescale/ls1046afrwy/ls1046afrwy.c 
b/board/freescale/ls1046afrwy/ls1046afrwy.c
index f1709dcd1c..f1c08a13f7 100644
--- a/board/freescale/ls1046afrwy/ls1046afrwy.c
+++ b/board/freescale/ls1046afrwy/ls1046afrwy.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #define LS1046A_PORSR1_REG 0x1EE
 #define BOOT_SRC_SD0x2000
@@ -38,32 +39,6 @@

 DECLARE_GLOBAL_DATA_PTR;

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 static inline void demux_select_usb2(void)
 {
u32 val;
diff --git a/board/freescale/ls1046aqds/ls1046aqds.c 
b/board/freescale/ls1046aqds/ls1046aqds.c
index 20694426af..2b0786ac30 100644
--- a/board/freescale/ls1046aqds/ls1046aqds.c
+++ b/board/freescale/ls1046aqds/ls1046aqds.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/vid.h"
 #include "../common/qixis.h"
@@ -276,31 +277,6 @@ u32 get_lpuart_clk(void)
 }
 #endif

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int dram_init(void)
 {
/*
diff --git a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig 
b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
index 45f28527e5..f094ee7053 100644
--- a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
@@ -60,3 +60,4 @@ CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_USB_ETHER_RTL8152=y
 CONFIG_RSA=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046afrwy_tfa_defconfig 
b/configs/ls1046afrwy_tfa_defconfig
index 27e4409d76..38d7df923f 100644
--- a/configs/ls1046afrwy_tfa_defconfig
+++ b/configs/ls1046afrwy_tfa_defconfig
@@ -68,3 +68,4 @@ CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_USB_ETHER_RTL8152=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_SECURE_BOOT_defconfig 
b/configs/ls1046aqds_SECURE_BOOT_defconfig
index 3177a03a79..7b68ef1f9a 100644
--- a/configs/ls1046aqds_SECURE_BOOT_defconfig
+++ b/configs/ls1046aqds_SECURE_BOOT_defconfig
@@ -70,3 +70,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_defconfig b/configs/ls1046aqds_defconfig
index 9fd216ba54..3a00325dc9 100644
--- a/configs/ls1046aqds_defconfig
+++ b/configs/ls1046aqds_defconfig
@@ -72,3 +72,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_lpuart_defconfig 
b/configs/ls1046aqds_lpuart_defconfig
index eab291a22f..41c9e6c8f1 100644
--- a/configs/ls1046aqds_lpuart_defconfig
+++ b/configs/ls1046aqds_lpuart_defconfig
@@ -74,3 +74,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_X

[PATCH v3 3/9] board: freescale: ls1043aqds: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1043aqds/ls1043aqds.c  | 27 +---
 configs/ls1043aqds_defconfig |  1 +
 configs/ls1043aqds_lpuart_defconfig  |  1 +
 configs/ls1043aqds_nand_defconfig|  1 +
 configs/ls1043aqds_nor_ddr3_defconfig|  1 +
 configs/ls1043aqds_qspi_defconfig|  1 +
 configs/ls1043aqds_sdcard_ifc_defconfig  |  1 +
 configs/ls1043aqds_sdcard_qspi_defconfig |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1043aqds_tfa_defconfig |  1 +
 10 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/board/freescale/ls1043aqds/ls1043aqds.c 
b/board/freescale/ls1043aqds/ls1043aqds.c
index 5b131d1d67..76bbb6087a 100644
--- a/board/freescale/ls1043aqds/ls1043aqds.c
+++ b/board/freescale/ls1043aqds/ls1043aqds.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "ls1043aqds_qixis.h"
@@ -279,32 +280,6 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int dram_init(void)
 {
/*
diff --git a/configs/ls1043aqds_defconfig b/configs/ls1043aqds_defconfig
index 5e04dca25c..6fc6c327ba 100644
--- a/configs/ls1043aqds_defconfig
+++ b/configs/ls1043aqds_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_lpuart_defconfig 
b/configs/ls1043aqds_lpuart_defconfig
index 8f479b7cb2..b2223b8d4e 100644
--- a/configs/ls1043aqds_lpuart_defconfig
+++ b/configs/ls1043aqds_lpuart_defconfig
@@ -71,3 +71,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_nand_defconfig 
b/configs/ls1043aqds_nand_defconfig
index f0951cdf3e..42830d3228 100644
--- a/configs/ls1043aqds_nand_defconfig
+++ b/configs/ls1043aqds_nand_defconfig
@@ -85,3 +85,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_nor_ddr3_defconfig 
b/configs/ls1043aqds_nor_ddr3_defconfig
index 1de948f48c..481f6eaa6f 100644
--- a/configs/ls1043aqds_nor_ddr3_defconfig
+++ b/configs/ls1043aqds_nor_ddr3_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_qspi_defconfig 
b/configs/ls1043aqds_qspi_defconfig
index 8a98ce9977..fb105f3cd0 100644
--- a/configs/ls1043aqds_qspi_defconfig
+++ b/configs/ls1043aqds_qspi_defconfig
@@ -66,3 +66,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_sdcard_ifc_defconfig 
b/configs/ls1043aqds_sdcard_ifc_defconfig
index 11b46211dc..f518517309 100644
--- a/configs/ls1043aqds_sdcard_ifc_defconfig
+++ b/configs/ls1043aqds_sdcard_ifc_defconfig
@@ -86,3 +86,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_sdcard_qspi_defconfig 
b/configs/ls1043aqds_sdcard_qspi_defconfig
index 1fe1dee7a9..10e87b7df9 100644
--- a/configs/ls1043aqds_sdcard_qspi_defconfig
+++ b/configs/ls1043aqds_sdcard_qspi_defconfig
@@ -80,3 +80,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig 
b/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
index 29e47cd55a..03effc67c9 100644
--- a/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
@@ -72,3 +72,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_tfa_defconfig b/configs/ls1043aqds_tfa_defconfig
index 4d6a644a02..00afe589a1 100644
--- a/configs/ls1043aqds_tfa_defconfig
+++ b/configs/ls1043aqds_tfa_defconfig
@@ -79

[PATCH v3 2/9] board: freescale: ls1021aqds: Update I2C mux config

2021-07-14 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1021aqds/dcu.c | 26 +---
 board/freescale/ls1021aqds/ls1021aqds.c  | 26 +---
 configs/ls1021aqds_ddr4_nor_defconfig|  1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig |  1 +
 configs/ls1021aqds_nand_defconfig|  1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig |  1 +
 configs/ls1021aqds_nor_defconfig |  1 +
 configs/ls1021aqds_nor_lpuart_defconfig  |  1 +
 configs/ls1021aqds_qspi_defconfig|  1 +
 configs/ls1021aqds_sdcard_ifc_defconfig  |  1 +
 configs/ls1021aqds_sdcard_qspi_defconfig |  1 +
 11 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/board/freescale/ls1021aqds/dcu.c b/board/freescale/ls1021aqds/dcu.c
index 7532f7c0b2..b5fee06b5b 100644
--- a/board/freescale/ls1021aqds/dcu.c
+++ b/board/freescale/ls1021aqds/dcu.c
@@ -11,37 +11,13 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"
 #include "div64.h"
 #include "../common/diu_ch7301.h"
 #include "ls1021aqds_qixis.h"

 DECLARE_GLOBAL_DATA_PTR;

-static int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 unsigned int dcu_set_pixel_clock(unsigned int pixclock)
 {
unsigned long long div;
diff --git a/board/freescale/ls1021aqds/ls1021aqds.c 
b/board/freescale/ls1021aqds/ls1021aqds.c
index aa1f6025c1..fcbde2ceb7 100644
--- a/board/freescale/ls1021aqds/ls1021aqds.c
+++ b/board/freescale/ls1021aqds/ls1021aqds.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"
 #include "../common/sleep.h"
 #include "../common/qixis.h"
 #include "ls1021aqds_qixis.h"
@@ -141,31 +142,6 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int dram_init(void)
 {
/*
diff --git a/configs/ls1021aqds_ddr4_nor_defconfig 
b/configs/ls1021aqds_ddr4_nor_defconfig
index a02a9fd955..04ad866731 100644
--- a/configs/ls1021aqds_ddr4_nor_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig 
b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
index d42e351754..700768294d 100644
--- a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_nand_defconfig 
b/configs/ls1021aqds_nand_defconfig
index 1aac0bf408..f969fdc4e0 100644
--- a/configs/ls1021aqds_nand_defconfig
+++ b/configs/ls1021aqds_nand_defconfig
@@ -84,3 +84,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_nor_SECURE_BOOT_defconfig 
b/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
index d3b68b9f95..43e77c95bc 100644
--- a/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
@@ -68,3 +68,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_nor_defconfig b/configs/ls1021aqds_nor_defconfig
index a67d040443..26d2e5e567 100644
--- a/configs/ls1021aqds_nor_defconfig
+++ b/configs/ls1021aqds_nor_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA954

[PATCH v3 1/9] board: freescale: Refactor NXP common mux code

2021-07-14 Thread Stephen Carlson

Refactors similar mux code from multiple NXP boards into a common location,
and allows it to be disabled in config.

New config: CONFIG_FSL_USE_PCA9547_MUX to enable PCA9547 mux functionality.

Signed-off-by: Stephen Carlson 
---
 board/freescale/common/Kconfig  |  6 +++
 board/freescale/common/Makefile | 11 ++
 board/freescale/common/i2c_common.c | 34 +
 board/freescale/common/i2c_common.h | 30 +++
 board/freescale/common/i2c_mux.c| 40 
 board/freescale/common/i2c_mux.h| 15 
 board/freescale/common/vid.c| 58 ++---
 7 files changed, 148 insertions(+), 46 deletions(-)
 create mode 100644 board/freescale/common/i2c_common.c
 create mode 100644 board/freescale/common/i2c_common.h
 create mode 100644 board/freescale/common/i2c_mux.c
 create mode 100644 board/freescale/common/i2c_mux.h

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 17db755951..ab9c14ae88 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,6 +21,12 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config FSL_USE_PCA9547_MUX
+   bool "Enable PCA9547 I2C Mux on Freescale boards"
+   default n
+   help
+This option enables the PCA9547 I2C mux on Freescale boards.
+
 config VID
depends on DM_I2C
bool "Enable Freescale VID"
diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile
index 7862a791ac..116c1e71cc 100644
--- a/board/freescale/common/Makefile
+++ b/board/freescale/common/Makefile
@@ -15,6 +15,15 @@ ifdef MINIMAL
 # necessary to create built-in.o
 obj- := __dummy__.o
 else
+# include i2c_common.o once if either VID or FSL_USE_PCA9547_MUX
+I2C_COMMON=
+ifdef CONFIG_VID
+I2C_COMMON=y
+endif
+ifdef CONFIG_FSL_USE_PCA9547_MUX
+I2C_COMMON=y
+endif
+
 obj-$(CONFIG_FSL_CADMUS)   += cadmus.o
 obj-$(CONFIG_FSL_VIA)  += cds_via.o
 obj-$(CONFIG_FMAN_ENET)+= fman.o
@@ -22,6 +31,8 @@ obj-$(CONFIG_FSL_PIXIS)   += pixis.o
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_FSL_NGPIXIS)  += ngpixis.o
 endif
+obj-$(I2C_COMMON)  += i2c_common.o
+obj-$(CONFIG_FSL_USE_PCA9547_MUX)  += i2c_mux.o
 obj-$(CONFIG_VID)  += vid.o
 obj-$(CONFIG_FSL_QIXIS)+= qixis.o
 obj-$(CONFIG_PQ_MDS_PIB)   += pq-mds-pib.o
diff --git a/board/freescale/common/i2c_common.c 
b/board/freescale/common/i2c_common.c
new file mode 100644
index 00..0f09ed7d34
--- /dev/null
+++ b/board/freescale/common/i2c_common.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020-21 NXP
+ * Copyright 2021 Microsoft Corporation
+ */
+
+#include 
+#include 
+#include "i2c_common.h"
+
+#ifdef CONFIG_DM_I2C
+
+/* If DM is in use, retrieve the chip for the specified bus number */
+int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev)
+{
+   int ret = i2c_get_chip_for_busnum(bus, address, 1, dev);
+
+   if (ret)
+   printf("I2C: Bus %d has no device with address 0x%02X\n",
+  bus, address);
+   return ret;
+}
+
+#else
+
+/* Handle is passed directly */
+int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev)
+{
+   *dev = address;
+   return 0;
+}
+
+#endif
diff --git a/board/freescale/common/i2c_common.h 
b/board/freescale/common/i2c_common.h
new file mode 100644
index 00..840ad66183
--- /dev/null
+++ b/board/freescale/common/i2c_common.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020-21 NXP
+ * Copyright 2021 Microsoft Corporation
+ */
+
+#ifndef __NXP_I2C_COMMON_H__
+#define __NXP_I2C_COMMON_H__
+
+/* Common functionality shared by the I2C drivers for VID and the mux. */
+#ifdef CONFIG_DM_I2C
+#define DEVICE_HANDLE_T struct udevice *
+
+#define I2C_READ(dev, register, data, length) \
+   dm_i2c_read(dev, register, data, length)
+#define I2C_WRITE(dev, register, data, length) \
+   dm_i2c_write(dev, register, data, length)
+#else
+#define DEVICE_HANDLE_T int
+
+#define I2C_READ(dev, register, data, length) \
+   i2c_read(dev, register, 1, data, length)
+#define I2C_WRITE(dev, register, data, length) \
+   i2c_write(dev, register, 1, data, length)
+#endif
+
+int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev);
+
+#endif
diff --git a/board/freescale/common/i2c_mux.c b/board/freescale/common/i2c_mux.c
new file mode 100644
index 00..54f89e2576
--- /dev/null
+++ b/board/freescale/common/i2c_mux.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020-21 NXP
+ * Copyright 2021 Microsoft Corporatio

[PATCH v3 0/9] board: freescale: common: Refactor I2C mux driver

2021-07-14 Thread Stephen Carlson

This patch set unifies code from multiple Freescale boards for the PCA9547
I2C mux into one location, and adds a Kconfig to disable the mux for new
Freescale boards which do not include it.

This patch set has been tested on the following boards:

LX2160ARDB
LX2160AQDS
LX2162AQDS
LS1046AFRWY
LS1046ARDB
LS2088ARDB
LS1043ARDB
LS1043AQDS
LS1088ARDB
LS1088AQDS

Signed-off-by: Stephen Carlson 
Signed-off-by: Wasim Khan 
Tested-by: Zhao Zheng 

Stephen Carlson (9):
  board: freescale: Refactor NXP common mux code
  board: freescale: ls1021aqds: Update I2C mux config
  board: freescale: ls1043aqds: Update I2C mux config
  board: freescale: ls1046a: Update I2C mux config
  board: freescale: ls1088a: Update I2C mux config
  board: freescale: ls2080: Update I2C mux config
  board: freescale: lx2160a: Update I2C mux config
  board: freescale: t2080qds: Update I2C mux config
  board: freescale: ls2088a: Update I2C mux config

 board/freescale/common/Kconfig|  6 ++
 board/freescale/common/Makefile   | 11 
 board/freescale/common/i2c_common.c   | 34 +++
 board/freescale/common/i2c_common.h   | 30 ++
 board/freescale/common/i2c_mux.c  | 40 +
 board/freescale/common/i2c_mux.h  | 15 +
 board/freescale/common/vid.c  | 58 ---
 board/freescale/ls1021aqds/dcu.c  | 26 +
 board/freescale/ls1021aqds/ls1021aqds.c   | 26 +
 board/freescale/ls1043aqds/ls1043aqds.c   | 27 +
 board/freescale/ls1046afrwy/ls1046afrwy.c | 27 +
 board/freescale/ls1046aqds/ls1046aqds.c   | 26 +
 board/freescale/ls1088a/ls1088a.c | 32 ++
 board/freescale/ls2080aqds/ls2080aqds.c   | 25 +---
 board/freescale/ls2080ardb/ls2080ardb.c   | 27 +
 board/freescale/lx2160a/lx2160a.c | 31 ++
 board/freescale/t208xqds/t208xqds.c   | 26 +
 configs/T2080QDS_NAND_defconfig   |  1 +
 configs/T2080QDS_SDCARD_defconfig |  1 +
 configs/T2080QDS_SECURE_BOOT_defconfig|  1 +
 configs/T2080QDS_SPIFLASH_defconfig   |  1 +
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig |  1 +
 configs/T2080QDS_defconfig|  1 +
 configs/ls1021aqds_ddr4_nor_defconfig |  1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig  |  1 +
 configs/ls1021aqds_nand_defconfig |  1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig  |  1 +
 configs/ls1021aqds_nor_defconfig  |  1 +
 configs/ls1021aqds_nor_lpuart_defconfig   |  1 +
 configs/ls1021aqds_qspi_defconfig |  1 +
 configs/ls1021aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1021aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_defconfig  |  1 +
 configs/ls1043aqds_lpuart_defconfig   |  1 +
 configs/ls1043aqds_nand_defconfig |  1 +
 configs/ls1043aqds_nor_ddr3_defconfig |  1 +
 configs/ls1043aqds_qspi_defconfig |  1 +
 configs/ls1043aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1043aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043aqds_tfa_defconfig  |  1 +
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046afrwy_tfa_defconfig |  1 +
 configs/ls1046aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_defconfig  |  1 +
 configs/ls1046aqds_lpuart_defconfig   |  1 +
 configs/ls1046aqds_nand_defconfig |  1 +
 configs/ls1046aqds_qspi_defconfig |  1 +
 configs/ls1046aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1046aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_tfa_defconfig  |  1 +
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 configs/ls2080aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080aqds_defconfig  |  1 +
 configs/ls2080aqds_nand_defconfig |  1 +
 configs/ls2080aqds_qspi_defconfig |  1 +
 configs/ls2080aqds_sdcard_defconfig   |  1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080ardb_defconfig  |  1 +
 configs/ls2080ardb_nand_defconfig |  1 +
 configs/ls2081ardb_defconfig

[PATCH v2 14/14] board: freescale: ls2088ardb: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls2088ardb_qspi_defconfig | 1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  | 1 +
 configs/ls2088ardb_tfa_defconfig  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
index 10c139c98e..fb77c8942e 100644
--- a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
@@ -67,3 +67,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_qspi_defconfig 
b/configs/ls2088ardb_qspi_defconfig
index 58fc6b2384..c09568b52a 100644
--- a/configs/ls2088ardb_qspi_defconfig
+++ b/configs/ls2088ardb_qspi_defconfig
@@ -72,3 +72,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
index eed26fa898..032d6125f2 100644
--- a/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
@@ -83,3 +83,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2088ardb_tfa_defconfig b/configs/ls2088ardb_tfa_defconfig
index 56cd02418c..522b381bb7 100644
--- a/configs/ls2088ardb_tfa_defconfig
+++ b/configs/ls2088ardb_tfa_defconfig
@@ -88,3 +88,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 13/14] board: freescale: ls2088aqds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 configs/ls2088aqds_tfa_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/ls2088aqds_tfa_defconfig b/configs/ls2088aqds_tfa_defconfig
index 5d14b55e6b..41a58359e6 100644
--- a/configs/ls2088aqds_tfa_defconfig
+++ b/configs/ls2088aqds_tfa_defconfig
@@ -90,3 +90,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 12/14] board: freescale: lx2162aqds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 configs/lx2162aqds_tfa_SECURE_BOOT_defconfig   | 1 +
 configs/lx2162aqds_tfa_defconfig   | 1 +
 configs/lx2162aqds_tfa_verified_boot_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig 
b/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig
index fcc78c6fe5..8dc601ff2c 100644
--- a/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/lx2162aqds_tfa_SECURE_BOOT_defconfig
@@ -89,3 +89,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2162aqds_tfa_defconfig b/configs/lx2162aqds_tfa_defconfig
index 42a3a3af44..d493bc1e7f 100644
--- a/configs/lx2162aqds_tfa_defconfig
+++ b/configs/lx2162aqds_tfa_defconfig
@@ -96,3 +96,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_WDT=y
 CONFIG_WDT_SBSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2162aqds_tfa_verified_boot_defconfig 
b/configs/lx2162aqds_tfa_verified_boot_defconfig
index bf0ac38ff2..8ff6f8113e 100644
--- a/configs/lx2162aqds_tfa_verified_boot_defconfig
+++ b/configs/lx2162aqds_tfa_verified_boot_defconfig
@@ -97,3 +97,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_WDT=y
 CONFIG_WDT_SBSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 11/14] board: freescale: ls2081ardb: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 configs/ls2081ardb_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/ls2081ardb_defconfig b/configs/ls2081ardb_defconfig
index ab1a9e22e0..d9134d6a01 100644
--- a/configs/ls2081ardb_defconfig
+++ b/configs/ls2081ardb_defconfig
@@ -65,3 +65,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 10/14] board: freescale: t2080qds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/t208xqds/t208xqds.c   | 26 +--
 configs/T2080QDS_NAND_defconfig   |  1 +
 configs/T2080QDS_SDCARD_defconfig |  1 +
 configs/T2080QDS_SECURE_BOOT_defconfig|  1 +
 configs/T2080QDS_SPIFLASH_defconfig   |  1 +
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig |  1 +
 configs/T2080QDS_defconfig|  1 +
 7 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/board/freescale/t208xqds/t208xqds.c 
b/board/freescale/t208xqds/t208xqds.c
index fd3217f24d..715de106d6 100644
--- a/board/freescale/t208xqds/t208xqds.c
+++ b/board/freescale/t208xqds/t208xqds.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "../common/vsc3316_3308.h"
@@ -79,31 +80,6 @@ int checkboard(void)
return 0;
 }

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
return select_i2c_ch_pca9547(channel, 0);
diff --git a/configs/T2080QDS_NAND_defconfig b/configs/T2080QDS_NAND_defconfig
index ffd23fab6b..62ce9eeecd 100644
--- a/configs/T2080QDS_NAND_defconfig
+++ b/configs/T2080QDS_NAND_defconfig
@@ -83,3 +83,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SDCARD_defconfig 
b/configs/T2080QDS_SDCARD_defconfig
index cb5d7ff233..c7987fa3bf 100644
--- a/configs/T2080QDS_SDCARD_defconfig
+++ b/configs/T2080QDS_SDCARD_defconfig
@@ -80,3 +80,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SECURE_BOOT_defconfig 
b/configs/T2080QDS_SECURE_BOOT_defconfig
index 4d33dc6a3a..f8f031f778 100644
--- a/configs/T2080QDS_SECURE_BOOT_defconfig
+++ b/configs/T2080QDS_SECURE_BOOT_defconfig
@@ -70,3 +70,4 @@ CONFIG_SYS_NUM_ADDR_MAP=64
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SPIFLASH_defconfig 
b/configs/T2080QDS_SPIFLASH_defconfig
index 1029a8ec34..cdcbf37edc 100644
--- a/configs/T2080QDS_SPIFLASH_defconfig
+++ b/configs/T2080QDS_SPIFLASH_defconfig
@@ -82,3 +82,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig 
b/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig
index 0677053e21..9ab1cdfe8c 100644
--- a/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig
+++ b/configs/T2080QDS_SRIO_PCIE_BOOT_defconfig
@@ -60,3 +60,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/T2080QDS_defconfig b/configs/T2080QDS_defconfig
index c9d1fec300..1cbc947454 100644
--- a/configs/T2080QDS_defconfig
+++ b/configs/T2080QDS_defconfig
@@ -68,3 +68,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_ADDR_MAP=y
 CONFIG_SYS_NUM_ADDR_MAP=64
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 09/14] board: freescale: lx2160a: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/lx2160a/lx2160a.c| 31 
 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig |  1 +
 configs/lx2160aqds_tfa_defconfig |  1 +
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig |  1 +
 configs/lx2160ardb_tfa_defconfig |  1 +
 configs/lx2160ardb_tfa_stmm_defconfig|  1 +
 6 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 47a7024f33..04a6296a36 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"
+
 #include "../common/qixis.h"
 #include "../common/vid.h"
 #include 
@@ -79,27 +81,6 @@ U_BOOT_DRVINFO(nxp_serial1) = {
.plat = ,
 };

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-
-#if !CONFIG_IS_ENABLED(DM_I2C)
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#else
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 static void uart_get_clock(void)
 {
serial0.clock = get_serial_clock();
@@ -115,10 +96,10 @@ int board_early_init_f(void)
uart_get_clock();

 #ifdef CONFIG_EMC2305
-   select_i2c_ch_pca9547(I2C_MUX_CH_EMC2305);
+   select_i2c_ch_pca9547(I2C_MUX_CH_EMC2305, 0);
emc2305_init(I2C_EMC2305_ADDR);
set_fan_speed(I2C_EMC2305_PWM, I2C_EMC2305_ADDR);
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
 #endif

fsl_lsch3_early_init_f();
@@ -275,7 +256,7 @@ int esdhc_status_fixup(void *blob, const char *compat)
 #if defined(CONFIG_VID)
 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
-   return select_i2c_ch_pca9547(channel);
+   return select_i2c_ch_pca9547(channel, 0);
 }

 int init_func_vid(void)
@@ -611,7 +592,7 @@ int board_init(void)
gd->env_addr = (ulong)_environment[0];
 #endif

-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);

 #if defined(CONFIG_FSL_MC_ENET) && defined(CONFIG_TARGET_LX2160ARDB)
/* invert AQR107 IRQ pins polarity */
diff --git a/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig 
b/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig
index 54d88c88d5..75a6bdd19a 100644
--- a/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/lx2160aqds_tfa_SECURE_BOOT_defconfig
@@ -86,3 +86,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160aqds_tfa_defconfig b/configs/lx2160aqds_tfa_defconfig
index d25d3e8b98..fafe42c559 100644
--- a/configs/lx2160aqds_tfa_defconfig
+++ b/configs/lx2160aqds_tfa_defconfig
@@ -92,3 +92,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_WDT=y
 CONFIG_WDT_SBSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig 
b/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig
index 1d61807c11..501e9ae44a 100644
--- a/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/lx2160ardb_tfa_SECURE_BOOT_defconfig
@@ -77,3 +77,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160ardb_tfa_defconfig b/configs/lx2160ardb_tfa_defconfig
index a160cfe21e..4b8e7edf94 100644
--- a/configs/lx2160ardb_tfa_defconfig
+++ b/configs/lx2160ardb_tfa_defconfig
@@ -87,3 +87,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_WDT=y
 CONFIG_WDT_SBSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/lx2160ardb_tfa_stmm_defconfig 
b/configs/lx2160ardb_tfa_stmm_defconfig
index 8b69a36dd9..06cfacab6d 100644
--- a/configs/lx2160ardb_tfa_stmm_defconfig
+++ b/configs/lx2160ardb_tfa_stmm_defconfig
@@ -86,3 +86,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_MM_COMM_TEE=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 08/14] board: freescale: ls2080ardb: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls2080ardb/ls2080ardb.c  | 27 +++-
 configs/ls2080ardb_SECURE_BOOT_defconfig |  1 +
 configs/ls2080ardb_defconfig |  1 +
 configs/ls2080ardb_nand_defconfig|  1 +
 4 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/board/freescale/ls2080ardb/ls2080ardb.c 
b/board/freescale/ls2080ardb/ls2080ardb.c
index 3a026b0827..6504cf768f 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #ifdef CONFIG_FSL_QIXIS
 #include "../common/qixis.h"
@@ -205,31 +206,9 @@ unsigned long get_board_sys_clk(void)
return 1;
 }

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-
-#if !CONFIG_IS_ENABLED(DM_I2C)
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#else
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-#endif
-
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
-   return select_i2c_ch_pca9547(channel);
+   return select_i2c_ch_pca9547(channel, 0);
 }

 int config_board_mux(int ctrl_type)
@@ -267,7 +246,7 @@ int board_init(void)
 #ifdef CONFIG_ENV_IS_NOWHERE
gd->env_addr = (ulong)_environment[0];
 #endif
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);

 #ifdef CONFIG_FSL_QIXIS
QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN);
diff --git a/configs/ls2080ardb_SECURE_BOOT_defconfig 
b/configs/ls2080ardb_SECURE_BOOT_defconfig
index 1175aafadb..b3cc52ba03 100644
--- a/configs/ls2080ardb_SECURE_BOOT_defconfig
+++ b/configs/ls2080ardb_SECURE_BOOT_defconfig
@@ -66,3 +66,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080ardb_defconfig b/configs/ls2080ardb_defconfig
index 53abd06ec6..b3c5001c50 100644
--- a/configs/ls2080ardb_defconfig
+++ b/configs/ls2080ardb_defconfig
@@ -67,3 +67,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080ardb_nand_defconfig 
b/configs/ls2080ardb_nand_defconfig
index 93032edc0c..63fadc5255 100644
--- a/configs/ls2080ardb_nand_defconfig
+++ b/configs/ls2080ardb_nand_defconfig
@@ -72,3 +72,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 07/14] board: freescale: ls2080aqds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls2080aqds/ls2080aqds.c  | 25 ++--
 configs/ls2080aqds_SECURE_BOOT_defconfig |  1 +
 configs/ls2080aqds_defconfig |  1 +
 configs/ls2080aqds_nand_defconfig|  1 +
 configs/ls2080aqds_qspi_defconfig|  1 +
 configs/ls2080aqds_sdcard_defconfig  |  1 +
 6 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/board/freescale/ls2080aqds/ls2080aqds.c 
b/board/freescale/ls2080aqds/ls2080aqds.c
index 9572319234..c48b01f7d7 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "ls2080aqds_qixis.h"
@@ -161,27 +161,6 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int config_board_mux(int ctrl_type)
 {
u8 reg5;
@@ -235,7 +214,7 @@ int board_init(void)
 #ifdef CONFIG_ENV_IS_NOWHERE
gd->env_addr = (ulong)_environment[0];
 #endif
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);

 #ifdef CONFIG_RTC_ENABLE_32KHZ_OUTPUT
 #if CONFIG_IS_ENABLED(DM_I2C)
diff --git a/configs/ls2080aqds_SECURE_BOOT_defconfig 
b/configs/ls2080aqds_SECURE_BOOT_defconfig
index bfa697c9ef..9e687f8066 100644
--- a/configs/ls2080aqds_SECURE_BOOT_defconfig
+++ b/configs/ls2080aqds_SECURE_BOOT_defconfig
@@ -68,3 +68,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_defconfig b/configs/ls2080aqds_defconfig
index 6f9cce5b25..a13e471a68 100644
--- a/configs/ls2080aqds_defconfig
+++ b/configs/ls2080aqds_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_nand_defconfig 
b/configs/ls2080aqds_nand_defconfig
index cc0f2b16aa..808140f10b 100644
--- a/configs/ls2080aqds_nand_defconfig
+++ b/configs/ls2080aqds_nand_defconfig
@@ -76,3 +76,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_qspi_defconfig 
b/configs/ls2080aqds_qspi_defconfig
index cbdf733456..51ab47a583 100644
--- a/configs/ls2080aqds_qspi_defconfig
+++ b/configs/ls2080aqds_qspi_defconfig
@@ -68,3 +68,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls2080aqds_sdcard_defconfig 
b/configs/ls2080aqds_sdcard_defconfig
index 71174de458..79fa0e179f 100644
--- a/configs/ls2080aqds_sdcard_defconfig
+++ b/configs/ls2080aqds_sdcard_defconfig
@@ -75,3 +75,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 06/14] board: freescale: ls1088a: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1088a/ls1088a.c | 32 ---
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 13 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/board/freescale/ls1088a/ls1088a.c 
b/board/freescale/ls1088a/ls1088a.c
index f5dc449d89..2f422634d5 100644
--- a/board/freescale/ls1088a/ls1088a.c
+++ b/board/freescale/ls1088a/ls1088a.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "ls1088a_qixis.h"
@@ -415,34 +416,13 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch)
-{
-   int ret;
-
-#if !CONFIG_IS_ENABLED(DM_I2C)
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#else
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, );
-   if (!ret)
-   ret = dm_i2c_write(dev, 0, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 #if !defined(CONFIG_SPL_BUILD)
 void board_retimer_init(void)
 {
u8 reg;

/* Retimer is connected to I2C1_CH5 */
-   select_i2c_ch_pca9547(I2C_MUX_CH5);
+   select_i2c_ch_pca9547(I2C_MUX_CH5, 0);

/* Access to Control/Shared register */
reg = 0x0;
@@ -532,7 +512,7 @@ void board_retimer_init(void)

 #ifdef CONFIG_TARGET_LS1088AQDS
/* Retimer is connected to I2C1_CH5 */
-   select_i2c_ch_pca9547(I2C_MUX_CH5);
+   select_i2c_ch_pca9547(I2C_MUX_CH5, 0);

/* Access to Control/Shared register */
reg = 0x0;
@@ -620,7 +600,7 @@ void board_retimer_init(void)

 #endif
/*return the default channel*/
-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
 }

 #ifdef CONFIG_MISC_INIT_R
@@ -669,7 +649,7 @@ int misc_init_r(void)

 int i2c_multiplexer_select_vid_channel(u8 channel)
 {
-   return select_i2c_ch_pca9547(channel);
+   return select_i2c_ch_pca9547(channel, 0);
 }

 #ifdef CONFIG_TARGET_LS1088AQDS
@@ -827,7 +807,7 @@ int board_init(void)
u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
 #endif

-   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+   select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
board_retimer_init();

 #ifdef CONFIG_ENV_IS_NOWHERE
diff --git a/configs/ls1088aqds_defconfig b/configs/ls1088aqds_defconfig
index c0fb4c9872..d9b8c9a18d 100644
--- a/configs/ls1088aqds_defconfig
+++ b/configs/ls1088aqds_defconfig
@@ -74,3 +74,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
index 57c91c1ad8..518a3ce6b9 100644
--- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
@@ -75,3 +75,4 @@ CONFIG_USB_GADGET=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_qspi_defconfig 
b/configs/ls1088aqds_qspi_defconfig
index 9abaead1c8..641efd982e 100644
--- a/configs/ls1088aqds_qspi_defconfig
+++ b/configs/ls1088aqds_qspi_defconfig
@@ -76,3 +76,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_sdcard_ifc_defconfig 
b/configs/ls1088aqds_sdcard_ifc_defconfig
index 44d4c13632..b70720c1d7 100644
--- a/configs/ls1088aqds_sdcard_ifc_defconfig
+++ b/configs/ls1088aqds_sdcard_ifc_defconfig
@@ -82,3 +82,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig 
b/configs/ls1088aqds_sdcard_qspi_defconfig
index dadea57078..764df3b698 100644
--- a/configs/ls1088aqds_sdcard_qspi_defconfig
+++ b/configs/ls1088aqds_sdcard_qspi_defconfig
@@ -85,3 +85,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1088aqds_tfa_defconfig b/configs/ls1088aqds_tfa_defco

[PATCH v2 05/14] board: freescale: ls1046aqds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1046aqds/ls1046aqds.c  | 26 +---
 configs/ls1046aqds_SECURE_BOOT_defconfig |  1 +
 configs/ls1046aqds_defconfig |  1 +
 configs/ls1046aqds_lpuart_defconfig  |  1 +
 configs/ls1046aqds_nand_defconfig|  1 +
 configs/ls1046aqds_qspi_defconfig|  1 +
 configs/ls1046aqds_sdcard_ifc_defconfig  |  1 +
 configs/ls1046aqds_sdcard_qspi_defconfig |  1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046aqds_tfa_defconfig |  1 +
 10 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/board/freescale/ls1046aqds/ls1046aqds.c 
b/board/freescale/ls1046aqds/ls1046aqds.c
index 20694426af..2b0786ac30 100644
--- a/board/freescale/ls1046aqds/ls1046aqds.c
+++ b/board/freescale/ls1046aqds/ls1046aqds.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/vid.h"
 #include "../common/qixis.h"
@@ -276,31 +277,6 @@ u32 get_lpuart_clk(void)
 }
 #endif

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int dram_init(void)
 {
/*
diff --git a/configs/ls1046aqds_SECURE_BOOT_defconfig 
b/configs/ls1046aqds_SECURE_BOOT_defconfig
index 7e7ae34226..5d58cc40a2 100644
--- a/configs/ls1046aqds_SECURE_BOOT_defconfig
+++ b/configs/ls1046aqds_SECURE_BOOT_defconfig
@@ -70,3 +70,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_defconfig b/configs/ls1046aqds_defconfig
index 8905d450da..205a129bce 100644
--- a/configs/ls1046aqds_defconfig
+++ b/configs/ls1046aqds_defconfig
@@ -72,3 +72,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_lpuart_defconfig 
b/configs/ls1046aqds_lpuart_defconfig
index 6627ac2bb0..0001b55aee 100644
--- a/configs/ls1046aqds_lpuart_defconfig
+++ b/configs/ls1046aqds_lpuart_defconfig
@@ -74,3 +74,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_nand_defconfig 
b/configs/ls1046aqds_nand_defconfig
index 9da564a788..d71e13df99 100644
--- a/configs/ls1046aqds_nand_defconfig
+++ b/configs/ls1046aqds_nand_defconfig
@@ -80,3 +80,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_qspi_defconfig 
b/configs/ls1046aqds_qspi_defconfig
index 6cf46ff2c9..3eb204fd07 100644
--- a/configs/ls1046aqds_qspi_defconfig
+++ b/configs/ls1046aqds_qspi_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_sdcard_ifc_defconfig 
b/configs/ls1046aqds_sdcard_ifc_defconfig
index 165c272c41..91fde75c9e 100644
--- a/configs/ls1046aqds_sdcard_ifc_defconfig
+++ b/configs/ls1046aqds_sdcard_ifc_defconfig
@@ -90,3 +90,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_sdcard_qspi_defconfig 
b/configs/ls1046aqds_sdcard_qspi_defconfig
index 8e60a35858..e81096fc2b 100644
--- a/configs/ls1046aqds_sdcard_qspi_defconfig
+++ b/configs/ls1046aqds_sdcard_qspi_defconfig
@@ -85,3 +85,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig 
b/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig
index 7e57b53a1f..f78bbcf695 100644
--- a/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig
@@ -72,3 +72,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046aqds_tfa_defconfig b/configs/ls1046aqds_tfa_defconfig
index 9366bc1d32..919c407618 100644
--- a/configs/ls1046aqds_tfa_defconfig
+++ b/configs/ls1046aqds_tfa_defconfig
@@ -82,3 +82,4 @@ CONFIG_DM_US

[PATCH v2 04/14] board: freescale: ls1046afrwy: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1046afrwy/ls1046afrwy.c | 27 +--
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046afrwy_tfa_defconfig |  1 +
 3 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/board/freescale/ls1046afrwy/ls1046afrwy.c 
b/board/freescale/ls1046afrwy/ls1046afrwy.c
index f1709dcd1c..f1c08a13f7 100644
--- a/board/freescale/ls1046afrwy/ls1046afrwy.c
+++ b/board/freescale/ls1046afrwy/ls1046afrwy.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #define LS1046A_PORSR1_REG 0x1EE
 #define BOOT_SRC_SD0x2000
@@ -38,32 +39,6 @@

 DECLARE_GLOBAL_DATA_PTR;

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 static inline void demux_select_usb2(void)
 {
u32 val;
diff --git a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig 
b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
index 33308aa0e3..4fb54f161a 100644
--- a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
@@ -61,3 +61,4 @@ CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_USB_ETHER_RTL8152=y
 CONFIG_RSA=y
 CONFIG_NXP_ESBC=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1046afrwy_tfa_defconfig 
b/configs/ls1046afrwy_tfa_defconfig
index ea62d7fa7e..6861d22193 100644
--- a/configs/ls1046afrwy_tfa_defconfig
+++ b/configs/ls1046afrwy_tfa_defconfig
@@ -68,3 +68,4 @@ CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_USB_ETHER_RTL8152=y
+CONFIG_FSL_USE_PCA9547_MUX=y
--
2.17.1


[PATCH v2 03/14] board: freescale: ls1043aqds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1043aqds/ls1043aqds.c  | 27 +---
 configs/ls1043aqds_defconfig |  1 +
 configs/ls1043aqds_lpuart_defconfig  |  1 +
 configs/ls1043aqds_nand_defconfig|  1 +
 configs/ls1043aqds_nor_ddr3_defconfig|  1 +
 configs/ls1043aqds_qspi_defconfig|  1 +
 configs/ls1043aqds_sdcard_ifc_defconfig  |  1 +
 configs/ls1043aqds_sdcard_qspi_defconfig |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1043aqds_tfa_defconfig |  1 +
 10 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/board/freescale/ls1043aqds/ls1043aqds.c 
b/board/freescale/ls1043aqds/ls1043aqds.c
index 5b131d1d67..76bbb6087a 100644
--- a/board/freescale/ls1043aqds/ls1043aqds.c
+++ b/board/freescale/ls1043aqds/ls1043aqds.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"

 #include "../common/qixis.h"
 #include "ls1043aqds_qixis.h"
@@ -279,32 +280,6 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int dram_init(void)
 {
/*
diff --git a/configs/ls1043aqds_defconfig b/configs/ls1043aqds_defconfig
index 42fd350075..2f1da44884 100644
--- a/configs/ls1043aqds_defconfig
+++ b/configs/ls1043aqds_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_lpuart_defconfig 
b/configs/ls1043aqds_lpuart_defconfig
index 1bafc2bb03..41b304cee8 100644
--- a/configs/ls1043aqds_lpuart_defconfig
+++ b/configs/ls1043aqds_lpuart_defconfig
@@ -71,3 +71,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_nand_defconfig 
b/configs/ls1043aqds_nand_defconfig
index 8fb23acd88..25c5d93fcb 100644
--- a/configs/ls1043aqds_nand_defconfig
+++ b/configs/ls1043aqds_nand_defconfig
@@ -85,3 +85,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_nor_ddr3_defconfig 
b/configs/ls1043aqds_nor_ddr3_defconfig
index f87c9a7cbf..a324291824 100644
--- a/configs/ls1043aqds_nor_ddr3_defconfig
+++ b/configs/ls1043aqds_nor_ddr3_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_qspi_defconfig 
b/configs/ls1043aqds_qspi_defconfig
index 5de4e07457..3724d392bc 100644
--- a/configs/ls1043aqds_qspi_defconfig
+++ b/configs/ls1043aqds_qspi_defconfig
@@ -66,3 +66,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_sdcard_ifc_defconfig 
b/configs/ls1043aqds_sdcard_ifc_defconfig
index 6e3318b1ed..eedabdbc6b 100644
--- a/configs/ls1043aqds_sdcard_ifc_defconfig
+++ b/configs/ls1043aqds_sdcard_ifc_defconfig
@@ -86,3 +86,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_sdcard_qspi_defconfig 
b/configs/ls1043aqds_sdcard_qspi_defconfig
index cd20980c98..3058442cdd 100644
--- a/configs/ls1043aqds_sdcard_qspi_defconfig
+++ b/configs/ls1043aqds_sdcard_qspi_defconfig
@@ -80,3 +80,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig 
b/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
index 4caabcadb8..ee92209d63 100644
--- a/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
@@ -72,3 +72,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1043aqds_tfa_defconfig b/configs/ls1043aqds_tfa_defconfig
index fb28072638..c15f956b0a 100644
--- a/configs/ls1043aqds_tfa_defconfig
+++ b/configs/ls1043aqds_tfa_defconfig
@@ -79

[PATCH v2 02/14] board: freescale: ls1021aqds: Update I2C mux config

2021-06-24 Thread Stephen Carlson

Updates the board configuration to enable use of the PCA9547 I2C mux.

Signed-off-by: Stephen Carlson 
---
 board/freescale/ls1021aqds/dcu.c | 26 +---
 board/freescale/ls1021aqds/ls1021aqds.c  | 26 +---
 configs/ls1021aqds_ddr4_nor_defconfig|  1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig |  1 +
 configs/ls1021aqds_nand_defconfig|  1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig |  1 +
 configs/ls1021aqds_nor_defconfig |  1 +
 configs/ls1021aqds_nor_lpuart_defconfig  |  1 +
 configs/ls1021aqds_qspi_defconfig|  1 +
 configs/ls1021aqds_sdcard_ifc_defconfig  |  1 +
 configs/ls1021aqds_sdcard_qspi_defconfig |  1 +
 11 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/board/freescale/ls1021aqds/dcu.c b/board/freescale/ls1021aqds/dcu.c
index 7532f7c0b2..b5fee06b5b 100644
--- a/board/freescale/ls1021aqds/dcu.c
+++ b/board/freescale/ls1021aqds/dcu.c
@@ -11,37 +11,13 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"
 #include "div64.h"
 #include "../common/diu_ch7301.h"
 #include "ls1021aqds_qixis.h"

 DECLARE_GLOBAL_DATA_PTR;

-static int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 unsigned int dcu_set_pixel_clock(unsigned int pixclock)
 {
unsigned long long div;
diff --git a/board/freescale/ls1021aqds/ls1021aqds.c 
b/board/freescale/ls1021aqds/ls1021aqds.c
index aa1f6025c1..fcbde2ceb7 100644
--- a/board/freescale/ls1021aqds/ls1021aqds.c
+++ b/board/freescale/ls1021aqds/ls1021aqds.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "../common/i2c_mux.h"
 #include "../common/sleep.h"
 #include "../common/qixis.h"
 #include "ls1021aqds_qixis.h"
@@ -141,31 +142,6 @@ unsigned long get_board_ddr_clk(void)
return ;
 }

-int select_i2c_ch_pca9547(u8 ch, int bus_num)
-{
-   int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
-   struct udevice *dev;
-
-   ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
- 1, );
-   if (ret) {
-   printf("%s: Cannot find udev for a bus %d\n", __func__,
-  bus_num);
-   return ret;
-   }
-   ret = dm_i2c_write(dev, 0, , 1);
-#else
-   ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, , 1);
-#endif
-   if (ret) {
-   puts("PCA: failed to select proper channel\n");
-   return ret;
-   }
-
-   return 0;
-}
-
 int dram_init(void)
 {
/*
diff --git a/configs/ls1021aqds_ddr4_nor_defconfig 
b/configs/ls1021aqds_ddr4_nor_defconfig
index a02a9fd955..04ad866731 100644
--- a/configs/ls1021aqds_ddr4_nor_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig 
b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
index d42e351754..700768294d 100644
--- a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_nand_defconfig 
b/configs/ls1021aqds_nand_defconfig
index 93cb6bfbf2..d36d957995 100644
--- a/configs/ls1021aqds_nand_defconfig
+++ b/configs/ls1021aqds_nand_defconfig
@@ -84,3 +84,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_nor_SECURE_BOOT_defconfig 
b/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
index d3b68b9f95..43e77c95bc 100644
--- a/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
@@ -68,3 +68,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
+CONFIG_FSL_USE_PCA9547_MUX=y
diff --git a/configs/ls1021aqds_nor_defconfig b/configs/ls1021aqds_nor_defconfig
index a67d040443..26d2e5e567 100644
--- a/configs/ls1021aqds_nor_defconfig
+++ b/configs/ls1021aqds_nor_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_FSL_USE_PCA954

[PATCH v2 01/14] board: freescale: Refactor NXP common mux code

2021-06-24 Thread Stephen Carlson

Refactors similar mux code from multiple NXP boards into a common location,
and allows it to be disabled in config.

New config: CONFIG_FSL_USE_PCA9547_MUX to enable PCA9547 mux functionality.

Signed-off-by: Stephen Carlson 
---
 board/freescale/common/Kconfig  |  6 +++
 board/freescale/common/Makefile | 11 ++
 board/freescale/common/i2c_common.c | 34 +
 board/freescale/common/i2c_common.h | 30 +++
 board/freescale/common/i2c_mux.c| 40 
 board/freescale/common/i2c_mux.h| 15 
 board/freescale/common/vid.c| 58 ++---
 7 files changed, 148 insertions(+), 46 deletions(-)
 create mode 100644 board/freescale/common/i2c_common.c
 create mode 100644 board/freescale/common/i2c_common.h
 create mode 100644 board/freescale/common/i2c_mux.c
 create mode 100644 board/freescale/common/i2c_mux.h

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 17db755951..ab9c14ae88 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,6 +21,12 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config FSL_USE_PCA9547_MUX
+   bool "Enable PCA9547 I2C Mux on Freescale boards"
+   default n
+   help
+This option enables the PCA9547 I2C mux on Freescale boards.
+
 config VID
depends on DM_I2C
bool "Enable Freescale VID"
diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile
index 114b7ba8f9..45aaa16ca4 100644
--- a/board/freescale/common/Makefile
+++ b/board/freescale/common/Makefile
@@ -15,6 +15,15 @@ ifdef MINIMAL
 # necessary to create built-in.o
 obj- := __dummy__.o
 else
+# include i2c_common.o once if either VID or FSL_USE_PCA9547_MUX
+I2C_COMMON=
+ifdef CONFIG_VID
+I2C_COMMON=y
+endif
+ifdef CONFIG_FSL_USE_PCA9547_MUX
+I2C_COMMON=y
+endif
+
 obj-$(CONFIG_FSL_CADMUS)   += cadmus.o
 obj-$(CONFIG_FSL_VIA)  += cds_via.o
 obj-$(CONFIG_FMAN_ENET)+= fman.o
@@ -22,6 +31,8 @@ obj-$(CONFIG_FSL_PIXIS)   += pixis.o
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_FSL_NGPIXIS)  += ngpixis.o
 endif
+obj-$(I2C_COMMON)  += i2c_common.o
+obj-$(CONFIG_FSL_USE_PCA9547_MUX)  += i2c_mux.o
 obj-$(CONFIG_VID)  += vid.o
 obj-$(CONFIG_FSL_QIXIS)+= qixis.o
 obj-$(CONFIG_PQ_MDS_PIB)   += pq-mds-pib.o
diff --git a/board/freescale/common/i2c_common.c 
b/board/freescale/common/i2c_common.c
new file mode 100644
index 00..0f09ed7d34
--- /dev/null
+++ b/board/freescale/common/i2c_common.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020-21 NXP
+ * Copyright 2021 Microsoft Corporation
+ */
+
+#include 
+#include 
+#include "i2c_common.h"
+
+#ifdef CONFIG_DM_I2C
+
+/* If DM is in use, retrieve the chip for the specified bus number */
+int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev)
+{
+   int ret = i2c_get_chip_for_busnum(bus, address, 1, dev);
+
+   if (ret)
+   printf("I2C: Bus %d has no device with address 0x%02X\n",
+  bus, address);
+   return ret;
+}
+
+#else
+
+/* Handle is passed directly */
+int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev)
+{
+   *dev = address;
+   return 0;
+}
+
+#endif
diff --git a/board/freescale/common/i2c_common.h 
b/board/freescale/common/i2c_common.h
new file mode 100644
index 00..840ad66183
--- /dev/null
+++ b/board/freescale/common/i2c_common.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020-21 NXP
+ * Copyright 2021 Microsoft Corporation
+ */
+
+#ifndef __NXP_I2C_COMMON_H__
+#define __NXP_I2C_COMMON_H__
+
+/* Common functionality shared by the I2C drivers for VID and the mux. */
+#ifdef CONFIG_DM_I2C
+#define DEVICE_HANDLE_T struct udevice *
+
+#define I2C_READ(dev, register, data, length) \
+   dm_i2c_read(dev, register, data, length)
+#define I2C_WRITE(dev, register, data, length) \
+   dm_i2c_write(dev, register, data, length)
+#else
+#define DEVICE_HANDLE_T int
+
+#define I2C_READ(dev, register, data, length) \
+   i2c_read(dev, register, 1, data, length)
+#define I2C_WRITE(dev, register, data, length) \
+   i2c_write(dev, register, 1, data, length)
+#endif
+
+int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev);
+
+#endif
diff --git a/board/freescale/common/i2c_mux.c b/board/freescale/common/i2c_mux.c
new file mode 100644
index 00..54f89e2576
--- /dev/null
+++ b/board/freescale/common/i2c_mux.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020-21 NXP
+ * Copyright 2021 Microsoft Corporatio

[PATCH v2 00/14] board: freescale: common: Refactor I2C mux driver

2021-06-24 Thread Stephen Carlson

This patch set unifies code from multiple Freescale boards for the PCA9547
I2C mux into one location, and adds a Kconfig to disable the mux for new
Freescale boards which do not include it.

This patch set has been tested on the following boards:

LX2160ARDB
LX2160AQDS
LX2162AQDS
LS1046AFRWY
LS1046ARDB
LS2088ARDB
LS1043ARDB
LS1043AQDS
LS1088ARDB
LS1088AQDS

Signed-off-by: Stephen Carlson 
Signed-off-by: Wasim Khan 
Tested-by: Zhao Zheng 
---
 board/freescale/common/Kconfig|  6 ++
 board/freescale/common/Makefile   | 11 
 board/freescale/common/i2c_common.c   | 32 ++
 board/freescale/common/i2c_common.h   | 28 +
 board/freescale/common/i2c_mux.c  | 38 
 board/freescale/common/i2c_mux.h  | 13 +
 board/freescale/common/vid.c  | 58 ---
 board/freescale/ls1021aqds/dcu.c  | 26 +
 board/freescale/ls1021aqds/ls1021aqds.c   | 26 +
 board/freescale/ls1043aqds/ls1043aqds.c   | 27 +
 board/freescale/ls1046afrwy/ls1046afrwy.c | 27 +
 board/freescale/ls1046aqds/ls1046aqds.c   | 26 +
 board/freescale/ls1088a/ls1088a.c | 32 ++
 board/freescale/ls2080aqds/ls2080aqds.c   | 25 +---
 board/freescale/ls2080ardb/ls2080ardb.c   | 27 +
 board/freescale/lx2160a/lx2160a.c | 31 ++
 board/freescale/t208xqds/t208xqds.c   | 26 +
 configs/T2080QDS_NAND_defconfig   |  1 +
 configs/T2080QDS_SDCARD_defconfig |  1 +
 configs/T2080QDS_SECURE_BOOT_defconfig|  1 +
 configs/T2080QDS_SPIFLASH_defconfig   |  1 +
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig |  1 +
 configs/T2080QDS_defconfig|  1 +
 configs/ls1021aqds_ddr4_nor_defconfig |  1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig  |  1 +
 configs/ls1021aqds_nand_defconfig |  1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig  |  1 +
 configs/ls1021aqds_nor_defconfig  |  1 +
 configs/ls1021aqds_nor_lpuart_defconfig   |  1 +
 configs/ls1021aqds_qspi_defconfig |  1 +
 configs/ls1021aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1021aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_defconfig  |  1 +
 configs/ls1043aqds_lpuart_defconfig   |  1 +
 configs/ls1043aqds_nand_defconfig |  1 +
 configs/ls1043aqds_nor_ddr3_defconfig |  1 +
 configs/ls1043aqds_qspi_defconfig |  1 +
 configs/ls1043aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1043aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043aqds_tfa_defconfig  |  1 +
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046afrwy_tfa_defconfig |  1 +
 configs/ls1046aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_defconfig  |  1 +
 configs/ls1046aqds_lpuart_defconfig   |  1 +
 configs/ls1046aqds_nand_defconfig |  1 +
 configs/ls1046aqds_qspi_defconfig |  1 +
 configs/ls1046aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1046aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_tfa_defconfig  |  1 +
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 configs/ls2080aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080aqds_defconfig  |  1 +
 configs/ls2080aqds_nand_defconfig |  1 +
 configs/ls2080aqds_qspi_defconfig |  1 +
 configs/ls2080aqds_sdcard_defconfig   |  1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080ardb_defconfig  |  1 +
 configs/ls2080ardb_nand_defconfig |  1 +
 configs/ls2081ardb_defconfig  |  1 +
 configs/ls2088aqds_tfa_defconfig  |  1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls2088ardb_qspi_defconfig |  1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls2088ardb_tfa_defconfig  |  1 +
 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2160aqds_tfa_defconfig  |  1 +
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2160ardb_tfa_defconfig

[PATCH] board: freescale: common: Refactor I2C mux driver

2021-06-09 Thread Stephen Carlson

Refactors the NXP I2C mux driver to clean up duplicate code and allow it to
be disabled with a config.

New config: CONFIG_FSL_USE_PCA9547_MUX. Defaults to Y since this 
multiplexer was always enabled before on these targets. When enabled, adds
functions for selecting the current I2C channel on the PCA9547 mux, which 
can be used when accessing I2C peripherals on the board.


Signed-off-by: Stephen Carlson 
Signed-off-by: Wasim Khan 
Tested-by: Zhao Zheng 
---
 board/freescale/common/Kconfig|  6 ++
 board/freescale/common/Makefile   | 11 
 board/freescale/common/i2c_common.c   | 32 ++
 board/freescale/common/i2c_common.h   | 28 +
 board/freescale/common/i2c_mux.c  | 38 
 board/freescale/common/i2c_mux.h  | 13 +
 board/freescale/common/vid.c  | 58 ---
 board/freescale/ls1021aqds/dcu.c  | 26 +
 board/freescale/ls1021aqds/ls1021aqds.c   | 26 +
 board/freescale/ls1043aqds/ls1043aqds.c   | 27 +
 board/freescale/ls1046afrwy/ls1046afrwy.c | 27 +
 board/freescale/ls1046aqds/ls1046aqds.c   | 26 +
 board/freescale/ls1088a/ls1088a.c | 32 ++
 board/freescale/ls2080aqds/ls2080aqds.c   | 25 +---
 board/freescale/ls2080ardb/ls2080ardb.c   | 27 +
 board/freescale/lx2160a/lx2160a.c | 31 ++
 board/freescale/t208xqds/t208xqds.c   | 26 +
 configs/T2080QDS_NAND_defconfig   |  1 +
 configs/T2080QDS_SDCARD_defconfig |  1 +
 configs/T2080QDS_SECURE_BOOT_defconfig|  1 +
 configs/T2080QDS_SPIFLASH_defconfig   |  1 +
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig |  1 +
 configs/T2080QDS_defconfig|  1 +
 configs/ls1021aqds_ddr4_nor_defconfig |  1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig  |  1 +
 configs/ls1021aqds_nand_defconfig |  1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig  |  1 +
 configs/ls1021aqds_nor_defconfig  |  1 +
 configs/ls1021aqds_nor_lpuart_defconfig   |  1 +
 configs/ls1021aqds_qspi_defconfig |  1 +
 configs/ls1021aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1021aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_defconfig  |  1 +
 configs/ls1043aqds_lpuart_defconfig   |  1 +
 configs/ls1043aqds_nand_defconfig |  1 +
 configs/ls1043aqds_nor_ddr3_defconfig |  1 +
 configs/ls1043aqds_qspi_defconfig |  1 +
 configs/ls1043aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1043aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043aqds_tfa_defconfig  |  1 +
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046afrwy_tfa_defconfig |  1 +
 configs/ls1046aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_defconfig  |  1 +
 configs/ls1046aqds_lpuart_defconfig   |  1 +
 configs/ls1046aqds_nand_defconfig |  1 +
 configs/ls1046aqds_qspi_defconfig |  1 +
 configs/ls1046aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1046aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_tfa_defconfig  |  1 +
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 configs/ls2080aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080aqds_defconfig  |  1 +
 configs/ls2080aqds_nand_defconfig |  1 +
 configs/ls2080aqds_qspi_defconfig |  1 +
 configs/ls2080aqds_sdcard_defconfig   |  1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080ardb_defconfig  |  1 +
 configs/ls2080ardb_nand_defconfig |  1 +
 configs/ls2081ardb_defconfig  |  1 +
 configs/ls2088aqds_tfa_defconfig  |  1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls2088ardb_qspi_defconfig |  1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls2088ardb_tfa_defconfig  |  1 +
 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2160aqds_tfa_defconfig  |  1 +
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs

[PATCH v3] arm: fsl: common: Improve NXP VID driver PMBus support

2021-01-28 Thread Stephen Carlson

This patch adds support for more PMBus compatible devices to the NXP
drivers for its QorIQ family devices. At runtime, the voltage regulator is
queried over I2C, and the required voltage multiplier determined. This
change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the
IR36021 and LTC3882, so this change allows the QorIQ series to be used
with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain
consistency with the existing code.

Signed-off-by: Stephen Carlson 
---
 board/freescale/common/Kconfig|  27 +-
 board/freescale/common/vid.c  | 814 --
 board/freescale/common/vid.h  |   7 +-
 board/freescale/ls1028a/ls1028a.c |  42 ++
 board/freescale/ls1088a/ls1088a.c |  40 ++
 board/freescale/ls2080a/ls2080a.c |  49 ++
 board/freescale/lx2160a/lx2160a.c |  42 ++
 include/configs/ls1088aqds.h  |   6 -
 include/configs/ls1088ardb.h  |   8 +-
 9 files changed, 519 insertions(+), 516 deletions(-)

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 1b1fd69cb2..17db755951 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,18 +21,37 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config VID
+   depends on DM_I2C
+   bool "Enable Freescale VID"
+   help
+This option enables setting core voltage based on individual
+values saved in SoC fuses.
+
 config VOL_MONITOR_LTC3882_READ
depends on VID
bool "Enable the LTC3882 voltage monitor read"
-   default n
help
 This option enables LTC3882 voltage monitor read
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.

 config VOL_MONITOR_LTC3882_SET
depends on VID
bool "Enable the LTC3882 voltage monitor set"
-   default n
help
 This option enables LTC3882 voltage monitor set
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_READ
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor read"
+   help
+This option enables ISL68233 voltage monitor read
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_SET
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor set"
+   help
+This option enables ISL68233 voltage monitor set
+functionality. It is used by the common VID driver.
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index 2617f61520..d155582006 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -2,6 +2,7 @@
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
  * Copyright 2020 NXP
+ * Copyright 2020 Stephen Carlson 
  */

 #include 
@@ -21,14 +22,22 @@
 #include 
 #include "vid.h"

+/* Voltages are generally handled in mV to keep them as integers */
+#define MV_PER_V 1000
+
+/*
+ * Select the channel on the I2C mux (on some NXP boards) that contains
+ * the voltage regulator to use for VID. Return 0 for success or nonzero
+ * for failure.
+ */
 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
 {
return 0;
 }

 /*
- * Compensate for a board specific voltage drop between regulator and SoC
- * return a value in mV
+ * Compensate for a board specific voltage drop between regulator and SoC.
+ * Returns the voltage offset in mV.
  */
 int __weak board_vdd_drop_compensation(void)
 {
@@ -36,13 +45,90 @@ int __weak board_vdd_drop_compensation(void)
 }

 /*
- * Board specific settings for specific voltage value
+ * Performs any board specific adjustments after the VID voltage has been
+ * set. Return 0 for success or nonzero for failure.
  */
 int __weak board_adjust_vdd(int vdd)
 {
return 0;
 }

+/*
+ * Processor specific method of converting the fuse value read from VID
+ * registers into the core voltage to supply. Return the voltage in mV.
+ */
+u16 __weak soc_get_fuse_vid(int vid_index)
+{
+   /* Default VDD for Layerscape Chassis 1 devices */
+   static const u16 vdd[32] = {
+   0,  /* unused */
+   9875,   /* 0.9875V */
+   9750,
+   9625,
+   9500,
+   9375,
+   9250,
+   9125,
+   9000,
+   8875,
+   8750,
+   8625,
+   8500,
+   8375,
+   8250,
+   8125,
+   1,  /* 1.V */
+   10125,
+   10250,
+   1037

[PATCH v3] arm: fsl: common: Improve NXP VID driver PMBus support

2020-12-09 Thread Stephen Carlson

This patch adds support for more PMBus compatible devices to the NXP
drivers for its QorIQ family devices. At runtime, the voltage regulator is
queried over I2C, and the required voltage multiplier determined. This
change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the
IR36021 and LTC3882, so this change allows the QorIQ series to be used
with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain
consistency with the existing code.

Signed-off-by: Stephen Carlson 
Cc: Priyanka Jain 
---
 board/freescale/common/Kconfig|  27 +-
 board/freescale/common/vid.c  | 815 --
 board/freescale/common/vid.h  |  13 +-
 board/freescale/ls1028a/ls1028a.c |  42 ++
 board/freescale/ls1088a/ls1088a.c |  40 ++
 board/freescale/ls2080a/ls2080a.c |  49 ++
 board/freescale/lx2160a/lx2160a.c |  42 ++
 include/configs/ls1088aqds.h  |   6 -
 include/configs/ls1088ardb.h  |   8 +-
 9 files changed, 526 insertions(+), 516 deletions(-)

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 1b1fd69cb2..17db755951 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,18 +21,37 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config VID
+   depends on DM_I2C
+   bool "Enable Freescale VID"
+   help
+This option enables setting core voltage based on individual
+values saved in SoC fuses.
+
 config VOL_MONITOR_LTC3882_READ
depends on VID
bool "Enable the LTC3882 voltage monitor read"
-   default n
help
 This option enables LTC3882 voltage monitor read
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.

 config VOL_MONITOR_LTC3882_SET
depends on VID
bool "Enable the LTC3882 voltage monitor set"
-   default n
help
 This option enables LTC3882 voltage monitor set
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_READ
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor read"
+   help
+This option enables ISL68233 voltage monitor read
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_SET
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor set"
+   help
+This option enables ISL68233 voltage monitor set
+functionality. It is used by the common VID driver.
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index 9c51f50260..2df3adf3bc 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * Copyright 2020 Stephen Carlson 
  */

 #include 
@@ -20,14 +22,22 @@
 #include 
 #include "vid.h"

+/* Voltages are generally handled in mV to keep them as integers */
+#define MV_PER_V 1000
+
+/*
+ * Select the channel on the I2C mux (on some NXP boards) that contains
+ * the voltage regulator to use for VID. Return 0 for success or nonzero
+ * for failure.
+ */
 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
 {
return 0;
 }

 /*
- * Compensate for a board specific voltage drop between regulator and SoC
- * return a value in mV
+ * Compensate for a board specific voltage drop between regulator and SoC.
+ * Returns the voltage offset in mV.
  */
 int __weak board_vdd_drop_compensation(void)
 {
@@ -35,13 +45,90 @@ int __weak board_vdd_drop_compensation(void)
 }

 /*
- * Board specific settings for specific voltage value
+ * Performs any board specific adjustments after the VID voltage has been
+ * set. Return 0 for success or nonzero for failure.
  */
 int __weak board_adjust_vdd(int vdd)
 {
return 0;
 }

+/*
+ * Processor specific method of converting the fuse value read from VID
+ * registers into the core voltage to supply. Return the voltage in mV.
+ */
+u16 __weak soc_get_fuse_vid(int vid_index)
+{
+   /* Default VDD for Layerscape Chassis 1 devices */
+   static const u16 vdd[32] = {
+   0,  /* unused */
+   9875,   /* 0.9875V */
+   9750,
+   9625,
+   9500,
+   9375,
+   9250,
+   9125,
+   9000,
+   8875,
+   8750,
+   8625,
+   8500,
+   8375,
+   8250,
+   8125,
+   1,  /* 1.V */
+   1012

[PATCH v2] arm: fsl: common: Improve NXP VID driver PMBus support

2020-11-02 Thread Stephen Carlson

This patch adds support for more PMBus compatible devices to the NXP
drivers for its QorIQ family devices. At runtime, the voltage regulator is
queried over I2C, and the required voltage multiplier determined. This
change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the
IR36021 and LTC3882, so this change allows the QorIQ series to be used
with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain
consistency with the existing code.

Signed-off-by: Stephen Carlson 
Cc: Priyanka Jain 
---
 board/freescale/common/Kconfig|  27 +-
 board/freescale/common/vid.c  | 815 --
 board/freescale/common/vid.h  |  13 +-
 board/freescale/ls1028a/ls1028a.c |  42 ++
 board/freescale/ls1088a/ls1088a.c |  40 ++
 board/freescale/ls2080a/ls2080a.c |  49 ++
 board/freescale/lx2160a/lx2160a.c |  42 ++
 include/configs/ls1088aqds.h  |   6 -
 include/configs/ls1088ardb.h  |   8 +-
 9 files changed, 526 insertions(+), 516 deletions(-)

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 1b1fd69cb2..17db755951 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,18 +21,37 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config VID
+   depends on DM_I2C
+   bool "Enable Freescale VID"
+   help
+This option enables setting core voltage based on individual
+values saved in SoC fuses.
+
 config VOL_MONITOR_LTC3882_READ
depends on VID
bool "Enable the LTC3882 voltage monitor read"
-   default n
help
 This option enables LTC3882 voltage monitor read
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.

 config VOL_MONITOR_LTC3882_SET
depends on VID
bool "Enable the LTC3882 voltage monitor set"
-   default n
help
 This option enables LTC3882 voltage monitor set
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_READ
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor read"
+   help
+This option enables ISL68233 voltage monitor read
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_SET
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor set"
+   help
+This option enables ISL68233 voltage monitor set
+functionality. It is used by the common VID driver.
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index 9c51f50260..2df3adf3bc 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * Copyright 2020 Stephen Carlson 
  */

 #include 
@@ -20,14 +22,22 @@
 #include 
 #include "vid.h"

+/* Voltages are generally handled in mV to keep them as integers */
+#define MV_PER_V 1000
+
+/*
+ * Select the channel on the I2C mux (on some NXP boards) that contains
+ * the voltage regulator to use for VID. Return 0 for success or nonzero
+ * for failure.
+ */
 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
 {
return 0;
 }

 /*
- * Compensate for a board specific voltage drop between regulator and SoC
- * return a value in mV
+ * Compensate for a board specific voltage drop between regulator and SoC.
+ * Returns the voltage offset in mV.
  */
 int __weak board_vdd_drop_compensation(void)
 {
@@ -35,13 +45,90 @@ int __weak board_vdd_drop_compensation(void)
 }

 /*
- * Board specific settings for specific voltage value
+ * Performs any board specific adjustments after the VID voltage has been
+ * set. Return 0 for success or nonzero for failure.
  */
 int __weak board_adjust_vdd(int vdd)
 {
return 0;
 }

+/*
+ * Processor specific method of converting the fuse value read from VID
+ * registers into the core voltage to supply. Return the voltage in mV.
+ */
+u16 __weak soc_get_fuse_vid(int vid_index)
+{
+   /* Default VDD for Layerscape Chassis 1 devices */
+   static const u16 vdd[32] = {
+   0,  /* unused */
+   9875,   /* 0.9875V */
+   9750,
+   9625,
+   9500,
+   9375,
+   9250,
+   9125,
+   9000,
+   8875,
+   8750,
+   8625,
+   8500,
+   8375,
+   8250,
+   8125,
+   1,  /* 1.V */
+   1012

[PATCH] arm: fsl: common: Improve NXP VID driver PMBus support

2020-08-18 Thread Stephen Carlson

[Resending as mailer dropped the Cc recipients]

This patch adds support for more PMBus compatible devices to the NXP
drivers for its QorIQ family devices. At runtime, the voltage regulator is
queried over I2C, and the required voltage multiplier determined. This
change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the
IR36021 and LTC3882, so this change allows the QorIQ series to be used
with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain
consistency with the existing code.

Signed-off-by: Stephen Carlson 
---
 board/freescale/common/Kconfig|  27 +-
 board/freescale/common/vid.c  | 784 --
 board/freescale/common/vid.h  |  14 +-
 board/freescale/ls1028a/ls1028a.c |  42 ++
 board/freescale/ls1088a/ls1088a.c |  40 ++
 board/freescale/ls2080a/ls2080a.c |  49 ++
 board/freescale/lx2160a/lx2160a.c |  42 ++
 include/configs/ls1088aqds.h  |   6 -
 include/configs/ls1088ardb.h  |   8 +-
 9 files changed, 521 insertions(+), 491 deletions(-)

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 1b1fd69cb2..17db755951 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,18 +21,37 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config VID
+   depends on DM_I2C
+   bool "Enable Freescale VID"
+   help
+This option enables setting core voltage based on individual
+values saved in SoC fuses.
+
 config VOL_MONITOR_LTC3882_READ
depends on VID
bool "Enable the LTC3882 voltage monitor read"
-   default n
help
 This option enables LTC3882 voltage monitor read
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.

 config VOL_MONITOR_LTC3882_SET
depends on VID
bool "Enable the LTC3882 voltage monitor set"
-   default n
help
 This option enables LTC3882 voltage monitor set
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_READ
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor read"
+   help
+This option enables ISL68233 voltage monitor read
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_SET
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor set"
+   help
+This option enables ISL68233 voltage monitor set
+functionality. It is used by the common VID driver.
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index ed0d9b471c..24f4d7c7b1 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * Copyright 2020 Stephen Carlson 
  */

 #include 
@@ -20,14 +22,22 @@
 #include 
 #include "vid.h"

+/* Voltages are generally handled in mV to keep them as integers */
+#define MV_PER_V 1000
+
+/*
+ * Select the channel on the I2C mux (on some NXP boards) that contains
+ * the voltage regulator to use for VID. Return 0 for success or nonzero
+ * for failure.
+ */
 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
 {
return 0;
 }

 /*
- * Compensate for a board specific voltage drop between regulator and SoC
- * return a value in mV
+ * Compensate for a board specific voltage drop between regulator and SoC.
+ * Returns the voltage offset in mV.
  */
 int __weak board_vdd_drop_compensation(void)
 {
@@ -35,13 +45,90 @@ int __weak board_vdd_drop_compensation(void)
 }

 /*
- * Board specific settings for specific voltage value
+ * Performs any board specific adjustments after the VID voltage has been
+ * set. Return 0 for success or nonzero for failure.
  */
 int __weak board_adjust_vdd(int vdd)
 {
return 0;
 }

+/*
+ * Processor specific method of converting the fuse value read from VID
+ * registers into the core voltage to supply. Return the voltage in mV.
+ */
+u16 __weak soc_get_fuse_vid(int vid_index)
+{
+   /* Default VDD for Layerscape Chassis 1 devices */
+   static const u16 vdd[32] = {
+   0,  /* unused */
+   9875,   /* 0.9875V */
+   9750,
+   9625,
+   9500,
+   9375,
+   9250,
+   9125,
+   9000,
+   8875,
+   8750,
+   8625,
+   8500,
+   8375,
+   8250,
+   8125,
+   1,  /* 1.V 

[PATCH] arm: fsl: common: Improve NXP VID driver PMBus support

2020-08-17 Thread Stephen Carlson

This patch adds support for more PMBus compatible devices to the NXP
drivers for its QorIQ family devices. At runtime, the voltage regulator is
queried over I2C, and the required voltage multiplier determined. This
change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the
IR36021 and LTC3882, so this change allows the QorIQ series to be used
with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain
consistency with the existing code.

Signed-off-by: Stephen Carlson 
Cc: Prabhakar Kushwaha 
---
 board/freescale/common/Kconfig|  27 +-
 board/freescale/common/vid.c  | 784 --
 board/freescale/common/vid.h  |  14 +-
 board/freescale/ls1028a/ls1028a.c |  42 ++
 board/freescale/ls1088a/ls1088a.c |  40 ++
 board/freescale/ls2080a/ls2080a.c |  49 ++
 board/freescale/lx2160a/lx2160a.c |  42 ++
 include/configs/ls1088aqds.h  |   6 -
 include/configs/ls1088ardb.h  |   8 +-
 9 files changed, 521 insertions(+), 491 deletions(-)

diff --git a/board/freescale/common/Kconfig b/board/freescale/common/Kconfig
index 1b1fd69cb2..17db755951 100644
--- a/board/freescale/common/Kconfig
+++ b/board/freescale/common/Kconfig
@@ -21,18 +21,37 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)

+config VID
+   depends on DM_I2C
+   bool "Enable Freescale VID"
+   help
+This option enables setting core voltage based on individual
+values saved in SoC fuses.
+
 config VOL_MONITOR_LTC3882_READ
depends on VID
bool "Enable the LTC3882 voltage monitor read"
-   default n
help
 This option enables LTC3882 voltage monitor read
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.

 config VOL_MONITOR_LTC3882_SET
depends on VID
bool "Enable the LTC3882 voltage monitor set"
-   default n
help
 This option enables LTC3882 voltage monitor set
-functionality. It is used by common VID driver.
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_READ
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor read"
+   help
+This option enables ISL68233 voltage monitor read
+functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_SET
+   depends on VID
+   bool "Enable the ISL68233 voltage monitor set"
+   help
+This option enables ISL68233 voltage monitor set
+functionality. It is used by the common VID driver.
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index ed0d9b471c..24f4d7c7b1 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * Copyright 2020 Stephen Carlson 
  */

 #include 
@@ -20,14 +22,22 @@
 #include 
 #include "vid.h"

+/* Voltages are generally handled in mV to keep them as integers */
+#define MV_PER_V 1000
+
+/*
+ * Select the channel on the I2C mux (on some NXP boards) that contains
+ * the voltage regulator to use for VID. Return 0 for success or nonzero
+ * for failure.
+ */
 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
 {
return 0;
 }

 /*
- * Compensate for a board specific voltage drop between regulator and SoC
- * return a value in mV
+ * Compensate for a board specific voltage drop between regulator and SoC.
+ * Returns the voltage offset in mV.
 */
 int __weak board_vdd_drop_compensation(void)
 {
@@ -35,13 +45,90 @@ int __weak board_vdd_drop_compensation(void)
 }

 /*
- * Board specific settings for specific voltage value
+ * Performs any board specific adjustments after the VID voltage has been
+ * set. Return 0 for success or nonzero for failure.
 */
 int __weak board_adjust_vdd(int vdd)
 {
return 0;
 }

+/*
+ * Processor specific method of converting the fuse value read from VID
+ * registers into the core voltage to supply. Return the voltage in mV.
+ */
+u16 __weak soc_get_fuse_vid(int vid_index)
+{
+   /* Default VDD for Layerscape Chassis 1 devices */
+   static const u16 vdd[32] = {
+   0,  /* unused */
+   9875,   /* 0.9875V */
+   9750,
+   9625,
+   9500,
+   9375,
+   9250,
+   9125,
+   9000,
+   8875,
+   8750,
+   8625,
+   8500,
+   8375,
+   8250,
+   8125,
+   1,  /* 1.V */
+   1012