Skip to content

Commit a3bac0f

Browse files
alifermoraesnatashaKoval
authored andcommitted
imx8mp_var_dart: set PMIC SW_EN bit for DART-MX8M-PLUS v2.0
In the DART-MX8M-PLUS v2.0 module, the PMIC does not enable the SW_EN bit by hardware. This issue prevents the PMIC from supplying the voltage necessary to power the Ethernet PHY. Read the value in the LOADSW_CTRL register and sets the SW_EN bit via software, if necessary, to ensure that the PMIC correctly powers the Ethernet PHY. Signed-off-by: Alifer Moraes <alifer.m@variscite.com> (cherry picked from commit ca1dfc1)
1 parent 8b286c5 commit a3bac0f

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

board/variscite/imx8mp_var_dart/imx8mp_var_dart.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,58 @@ int var_detect_board_id(void)
103103
return board_id;
104104
}
105105

106+
#ifdef CONFIG_POWER_PCA9450
107+
#define PCA9450_I2C_BUS 0
108+
#define PCA9450_I2C_ADDR 0x25
109+
#define PCA9450_LSW_CTRL_ADDR 0x2A
110+
#define REG_DATA_SIZE 1
111+
112+
int setup_sw_en_pmic(void)
113+
{
114+
struct udevice *bus;
115+
struct udevice *dev;
116+
u8 reg_data[REG_DATA_SIZE];
117+
int ret;
118+
119+
struct var_eeprom *ep = VAR_EEPROM_DATA;
120+
int som_rev = SOMREV_MAJOR(ep->somrev);
121+
122+
/* On DART-MX8M-PLUS v2.0, SW_EN must be set by software to ensure
123+
* that the ethernet PHY is powered up. Set bit 0 of LOADSW_CTRL.
124+
*/
125+
if ((var_detect_board_id() == BOARD_ID_DART) && (som_rev >= 2)) {
126+
ret = uclass_get_device_by_seq(UCLASS_I2C, PCA9450_I2C_BUS, &bus);
127+
if (ret) {
128+
printf("Can't find I2C bus %d\n", PCA9450_I2C_BUS);
129+
return ret;
130+
}
131+
132+
ret = dm_i2c_probe(bus, PCA9450_I2C_ADDR, 0, &dev);
133+
if (ret) {
134+
printf("Can't find device at address 0x%x\n", PCA9450_I2C_ADDR);
135+
return ret;
136+
}
137+
138+
ret = dm_i2c_read(dev, PCA9450_LSW_CTRL_ADDR, reg_data, REG_DATA_SIZE);
139+
if (ret) {
140+
printf("Failed to read address 0x%x\n", PCA9450_I2C_ADDR);
141+
return ret;
142+
}
143+
144+
/* Enable SW_EN by setting LOADSW_CTRL bit 0 */
145+
reg_data[0] |= 0x01;
146+
147+
ret = dm_i2c_write(dev, PCA9450_LSW_CTRL_ADDR, reg_data, REG_DATA_SIZE);
148+
if (ret) {
149+
printf("Failed to write at address 0x%x\n", PCA9450_I2C_ADDR);
150+
return ret;
151+
}
152+
}
153+
154+
return 0;
155+
}
156+
#endif
157+
106158
#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
107159
struct efi_fw_image fw_images[] = {
108160
{
@@ -359,6 +411,14 @@ int board_init(void)
359411
extcon_ptn5150_setup(&usb_ptn5150);
360412
}
361413

414+
#ifdef CONFIG_POWER_PCA9450
415+
int ret;
416+
417+
ret = setup_sw_en_pmic();
418+
if (ret)
419+
return ret;
420+
#endif
421+
362422
if (CONFIG_IS_ENABLED(FEC_MXC)) {
363423
setup_fec();
364424
}

0 commit comments

Comments
 (0)