- Add DM model for P1010RDB
- Add I2C DM Model support for P1010RDB, T1042RDB, T2080, T4240RDB,
  MPC8548CDS, T1024RDB, P4080, P3041DS, P2041RDB, P2020RDB, P1020RDB,
  P5040DS
- Fix reference to READM.qe_firmware
This commit is contained in:
Tom Rini
2020-05-05 09:08:53 -04:00
128 changed files with 1580 additions and 83 deletions

View File

@@ -595,6 +595,7 @@ unsigned int get_cpu_board_revision(void)
(void *)&be, sizeof(be));
#else
struct udevice *dev;
int ret;
#ifdef CONFIG_SYS_EEPROM_BUS_NUM
ret = i2c_get_chip_for_busnum(CONFIG_SYS_EEPROM_BUS_NUM,
CONFIG_SYS_I2C_EEPROM_ADDR,
@@ -603,7 +604,7 @@ unsigned int get_cpu_board_revision(void)
#else
ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_EEPROM_ADDR,
CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
&dev)
&dev);
#endif
if (!ret)
dm_i2c_read(dev, 0, (void *)&be, sizeof(be));

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2012 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include "vsc3316_3308.h"
@@ -32,7 +33,22 @@ int vsc_if_enable(unsigned int vsc_addr)
/* enable 2-wire Serial InterFace (I2C) */
data = 0x02;
#ifdef CONFIG_DM_I2C
int ret, bus_num = 0;
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, vsc_addr,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
return dm_i2c_write(dev, INTERFACE_MODE_REG, &data, 1);
#else
return i2c_write(vsc_addr, INTERFACE_MODE_REG, 1, &data, 1);
#endif
}
int vsc3316_config(unsigned int vsc_addr, int8_t con_arr[][2],
@@ -45,6 +61,66 @@ int vsc3316_config(unsigned int vsc_addr, int8_t con_arr[][2],
debug("VSC:Initializing VSC3316 at I2C address 0x%2x"
" for Tx\n", vsc_addr);
#ifdef CONFIG_DM_I2C
int bus_num = 0;
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, vsc_addr,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_read(dev, REVISION_ID_REG, &rev_id, 1);
if (ret < 0) {
printf("VSC:0x%x could not read REV_ID from device.\n",
vsc_addr);
return ret;
}
if (rev_id != 0xab) {
printf("VSC: device at address 0x%x is not VSC3316/3308.\n",
vsc_addr);
return -ENODEV;
}
ret = vsc_if_enable(vsc_addr);
if (ret) {
printf("VSC:0x%x could not configured for 2-wire I/F.\n",
vsc_addr);
return ret;
}
/* config connections - page 0x00 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, CONNECTION_CONFIG_PAGE);
/* Making crosspoint connections, by connecting required
* input to output
*/
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][1], con_arr[i][0]);
/* input state - page 0x13 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, INPUT_STATE_REG);
/* Configuring the required input of the switch */
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][0], 0x80);
/* Setting Global Input LOS threshold value */
dm_i2c_reg_write(dev, GLOBAL_INPUT_LOS, 0x60);
/* config output mode - page 0x23 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, OUTPUT_MODE_PAGE);
/* Turn ON the Output driver correspond to required output*/
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][1], 0);
/* configure global core control register, Turn on Global core power */
dm_i2c_reg_write(dev, GLOBAL_CORE_CNTRL, 0);
#else
ret = i2c_read(vsc_addr, REVISION_ID_REG, 1, &rev_id, 1);
if (ret < 0) {
printf("VSC:0x%x could not read REV_ID from device.\n",
@@ -90,6 +166,7 @@ int vsc3316_config(unsigned int vsc_addr, int8_t con_arr[][2],
/* configure global core control register, Turn on Global core power */
i2c_reg_write(vsc_addr, GLOBAL_CORE_CNTRL, 0);
#endif
vsc_wp_config(vsc_addr);
@@ -107,6 +184,105 @@ int vsc3308_config_adjust(unsigned int vsc_addr, const int8_t con_arr[][2],
debug("VSC:Initializing VSC3308 at I2C address 0x%x for Tx\n",
vsc_addr);
#ifdef CONFIG_DM_I2C
int bus_num = 0;
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, vsc_addr,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_read(dev, REVISION_ID_REG, &rev_id, 1);
if (ret < 0) {
printf("VSC:0x%x could not read REV_ID from device.\n",
vsc_addr);
return ret;
}
if (rev_id != 0xab) {
printf("VSC: device at address 0x%x is not VSC3316/3308.\n",
vsc_addr);
return -ENODEV;
}
ret = vsc_if_enable(vsc_addr);
if (ret) {
printf("VSC:0x%x could not configured for 2-wire I/F.\n",
vsc_addr);
return ret;
}
/* config connections - page 0x00 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, CONNECTION_CONFIG_PAGE);
/* Configure Global Input ISE */
dm_i2c_reg_write(dev, GLOBAL_INPUT_ISE1, 0);
dm_i2c_reg_write(dev, GLOBAL_INPUT_ISE2, 0);
/* Configure Tx/Rx Global Output PE1 */
dm_i2c_reg_write(dev, GLOBAL_OUTPUT_PE1, 0);
/* Configure Tx/Rx Global Output PE2 */
dm_i2c_reg_write(dev, GLOBAL_OUTPUT_PE2, 0);
/* Configure Tx/Rx Global Input GAIN */
dm_i2c_reg_write(dev, GLOBAL_INPUT_GAIN, 0x3F);
/* Setting Global Input LOS threshold value */
dm_i2c_reg_write(dev, GLOBAL_INPUT_LOS, 0xE0);
/* Setting Global output termination */
dm_i2c_reg_write(dev, GLOBAL_OUTPUT_TERMINATION, 0);
/* Configure Tx/Rx Global Output level */
if (vsc_addr == VSC3308_TX_ADDRESS)
dm_i2c_reg_write(dev, GLOBAL_OUTPUT_LEVEL, 4);
else
dm_i2c_reg_write(dev, GLOBAL_OUTPUT_LEVEL, 2);
/* Making crosspoint connections, by connecting required
* input to output
*/
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][1], con_arr[i][0]);
/* input state - page 0x13 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, INPUT_STATE_REG);
/* Turning off all the required input of the switch */
for (i = 0; i < num_con; i++)
dm_i2c_reg_write(dev, con_arr[i][0], 1);
/* only turn on specific Tx/Rx requested by the XFI erratum */
if (vsc_addr == VSC3308_TX_ADDRESS) {
dm_i2c_reg_write(dev, 2, 0);
dm_i2c_reg_write(dev, 3, 0);
} else {
dm_i2c_reg_write(dev, 0, 0);
dm_i2c_reg_write(dev, 1, 0);
}
/* config output mode - page 0x23 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, OUTPUT_MODE_PAGE);
/* Turn off the Output driver correspond to required output*/
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][1], 1);
/* only turn on specific Tx/Rx requested by the XFI erratum */
if (vsc_addr == VSC3308_TX_ADDRESS) {
dm_i2c_reg_write(dev, 0, 0);
dm_i2c_reg_write(dev, 1, 0);
} else {
dm_i2c_reg_write(dev, 3, 0);
dm_i2c_reg_write(dev, 4, 0);
}
/* configure global core control register, Turn on Global core power */
dm_i2c_reg_write(dev, GLOBAL_CORE_CNTRL, 0);
#else
ret = i2c_read(vsc_addr, REVISION_ID_REG, 1, &rev_id, 1);
if (ret < 0) {
printf("VSC:0x%x could not read REV_ID from device.\n",
@@ -192,7 +368,7 @@ int vsc3308_config_adjust(unsigned int vsc_addr, const int8_t con_arr[][2],
/* configure global core control register, Turn on Global core power */
i2c_reg_write(vsc_addr, GLOBAL_CORE_CNTRL, 0);
#endif
vsc_wp_config(vsc_addr);
return 0;
@@ -208,7 +384,69 @@ int vsc3308_config(unsigned int vsc_addr, const int8_t con_arr[][2],
debug("VSC:Initializing VSC3308 at I2C address 0x%x"
" for Tx\n", vsc_addr);
#ifdef CONFIG_DM_I2C
int bus_num = 0;
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, vsc_addr,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_read(dev, REVISION_ID_REG, &rev_id, 1);
if (ret < 0) {
printf("VSC:0x%x could not read REV_ID from device.\n",
vsc_addr);
return ret;
}
if (rev_id != 0xab) {
printf("VSC: device at address 0x%x is not VSC3316/3308.\n",
vsc_addr);
return -ENODEV;
}
ret = vsc_if_enable(vsc_addr);
if (ret) {
printf("VSC:0x%x could not configured for 2-wire I/F.\n",
vsc_addr);
return ret;
}
/* config connections - page 0x00 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, CONNECTION_CONFIG_PAGE);
/* Making crosspoint connections, by connecting required
* input to output
*/
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][1], con_arr[i][0]);
/*Configure Global Input ISE and gain */
dm_i2c_reg_write(dev, GLOBAL_INPUT_ISE1, 0x12);
dm_i2c_reg_write(dev, GLOBAL_INPUT_ISE2, 0x12);
/* input state - page 0x13 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, INPUT_STATE_REG);
/* Turning ON the required input of the switch */
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][0], 0);
/* Setting Global Input LOS threshold value */
dm_i2c_reg_write(dev, GLOBAL_INPUT_LOS, 0x60);
/* config output mode - page 0x23 */
dm_i2c_reg_write(dev, CURRENT_PAGE_REGISTER, OUTPUT_MODE_PAGE);
/* Turn ON the Output driver correspond to required output*/
for (i = 0; i < num_con ; i++)
dm_i2c_reg_write(dev, con_arr[i][1], 0);
/* configure global core control register, Turn on Global core power */
dm_i2c_reg_write(dev, GLOBAL_CORE_CNTRL, 0);
#else
ret = i2c_read(vsc_addr, REVISION_ID_REG, 1, &rev_id, 1);
if (ret < 0) {
printf("VSC:0x%x could not read REV_ID from device.\n",
@@ -258,7 +496,7 @@ int vsc3308_config(unsigned int vsc_addr, const int8_t con_arr[][2],
/* configure global core control register, Turn on Global core power */
i2c_reg_write(vsc_addr, GLOBAL_CORE_CNTRL, 0);
#endif
vsc_wp_config(vsc_addr);
return 0;
@@ -270,6 +508,22 @@ void vsc_wp_config(unsigned int vsc_addr)
/* For new crosspoint configuration to occur, WP bit of
* CORE_CONFIG_REG should be set 1 and then reset to 0 */
#ifdef CONFIG_DM_I2C
int ret, bus_num = 0;
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, vsc_addr,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return;
}
dm_i2c_reg_write(dev, CORE_CONFIG_REG, 0x01);
dm_i2c_reg_write(dev, CORE_CONFIG_REG, 0x0);
#else
i2c_reg_write(vsc_addr, CORE_CONFIG_REG, 0x01);
i2c_reg_write(vsc_addr, CORE_CONFIG_REG, 0x0);
#endif
}

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2010-2011 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -124,7 +125,7 @@ int board_early_init_r(void)
return 0;
}
#ifdef CONFIG_PCI
#if defined(CONFIG_PCI) && !defined(CONFIG_DM_PCI)
void pci_init_board(void)
{
fsl_pcie_init_board(0);
@@ -136,6 +137,125 @@ int config_board_mux(int ctrl_type)
ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
u8 tmp;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
int ret;
#if defined(CONFIG_TARGET_P1010RDB_PA)
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
ret = i2c_get_chip_for_busnum(I2C_PCA9557_BUS_NUM,
I2C_PCA9557_ADDR1, 1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n",
__func__, I2C_PCA9557_BUS_NUM);
return ret;
}
switch (ctrl_type) {
case MUX_TYPE_IFC:
tmp = 0xf0;
dm_i2c_write(dev, 3, &tmp, 1);
tmp = 0x01;
dm_i2c_write(dev, 1, &tmp, 1);
sd_ifc_mux = MUX_TYPE_IFC;
clrbits_be32(&gur->pmuxcr, PMUXCR1_IFC_MASK);
break;
case MUX_TYPE_SDHC:
tmp = 0xf0;
dm_i2c_write(dev, 3, &tmp, 1);
tmp = 0x05;
dm_i2c_write(dev, 1, &tmp, 1);
sd_ifc_mux = MUX_TYPE_SDHC;
clrsetbits_be32(&gur->pmuxcr, PMUXCR1_SDHC_MASK,
PMUXCR1_SDHC_ENABLE);
break;
case MUX_TYPE_SPIFLASH:
out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_FLASH);
break;
case MUX_TYPE_TDM:
out_8(&cpld_data->tdm_can_sel, MUX_CPLD_TDM);
out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_SLIC);
break;
case MUX_TYPE_CAN:
out_8(&cpld_data->tdm_can_sel, MUX_CPLD_CAN_UART);
break;
default:
break;
}
#elif defined(CONFIG_TARGET_P1010RDB_PB)
ret = i2c_get_chip_for_busnum(I2C_PCA9557_BUS_NUM,
I2C_PCA9557_ADDR2, 1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n",
__func__, I2C_PCA9557_BUS_NUM);
return ret;
}
switch (ctrl_type) {
case MUX_TYPE_IFC:
dm_i2c_read(dev, 0, &tmp, 1);
clrbits_8(&tmp, 0x04);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x04);
dm_i2c_write(dev, 3, &tmp, 1);
sd_ifc_mux = MUX_TYPE_IFC;
clrbits_be32(&gur->pmuxcr, PMUXCR1_IFC_MASK);
break;
case MUX_TYPE_SDHC:
dm_i2c_read(dev, 0, &tmp, 1);
setbits_8(&tmp, 0x04);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x04);
dm_i2c_write(dev, 3, &tmp, 1);
sd_ifc_mux = MUX_TYPE_SDHC;
clrsetbits_be32(&gur->pmuxcr, PMUXCR1_SDHC_MASK,
PMUXCR1_SDHC_ENABLE);
break;
case MUX_TYPE_SPIFLASH:
dm_i2c_read(dev, 0, &tmp, 1);
clrbits_8(&tmp, 0x80);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x80);
dm_i2c_write(dev, 3, &tmp, 1);
break;
case MUX_TYPE_TDM:
dm_i2c_read(dev, 0, &tmp, 1);
setbits_8(&tmp, 0x82);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x82);
dm_i2c_write(dev, 3, &tmp, 1);
break;
case MUX_TYPE_CAN:
dm_i2c_read(dev, 0, &tmp, 1);
clrbits_8(&tmp, 0x02);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x02);
dm_i2c_write(dev, 3, &tmp, 1);
break;
case MUX_TYPE_CS0_NOR:
dm_i2c_read(dev, 0, &tmp, 1);
clrbits_8(&tmp, 0x08);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x08);
dm_i2c_write(dev, 3, &tmp, 1);
break;
case MUX_TYPE_CS0_NAND:
dm_i2c_read(dev, 0, &tmp, 1);
setbits_8(&tmp, 0x08);
dm_i2c_write(dev, 1, &tmp, 1);
dm_i2c_read(dev, 3, &tmp, 1);
clrbits_8(&tmp, 0x08);
dm_i2c_write(dev, 3, &tmp, 1);
break;
default:
break;
}
#endif
#else
#if defined(CONFIG_TARGET_P1010RDB_PA)
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
@@ -242,6 +362,7 @@ int config_board_mux(int ctrl_type)
break;
}
i2c_set_bus_num(orig_bus);
#endif
#endif
return 0;
}
@@ -250,9 +371,23 @@ int config_board_mux(int ctrl_type)
int i2c_pca9557_read(int type)
{
u8 val;
int bus_num = I2C_PCA9557_BUS_NUM;
i2c_set_bus_num(I2C_PCA9557_BUS_NUM);
#ifdef CONFIG_DM_I2C
struct udevice *dev;
int ret;
ret = i2c_get_chip_for_busnum(bus_num, I2C_PCA9557_ADDR2, 1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n",
__func__, bus_num);
return ret;
}
dm_i2c_read(dev, 0, &val, 1);
#else
i2c_set_bus_num(bus_num);
i2c_read(I2C_PCA9557_ADDR2, 0, 1, &val, 1);
#endif
switch (type) {
case I2C_READ_BANK:
@@ -280,11 +415,26 @@ int checkboard(void)
printf("Board: %sRDB-PA, ", cpu->name);
#elif defined(CONFIG_TARGET_P1010RDB_PB)
printf("Board: %sRDB-PB, ", cpu->name);
#ifdef CONFIG_DM_I2C
struct udevice *dev;
int ret;
ret = i2c_get_chip_for_busnum(I2C_PCA9557_BUS_NUM, I2C_PCA9557_ADDR2,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
I2C_PCA9557_BUS_NUM);
return ret;
}
val = 0x0; /* no polarity inversion */
dm_i2c_write(dev, 2, &val, 1);
#else
i2c_set_bus_num(I2C_PCA9557_BUS_NUM);
i2c_init(CONFIG_SYS_FSL_I2C_SPEED, CONFIG_SYS_FSL_I2C_SLAVE);
val = 0x0; /* no polarity inversion */
i2c_write(I2C_PCA9557_ADDR2, 2, 1, &val, 1);
#endif
#endif
#ifdef CONFIG_SDCARD
/* switch to IFC to read info from CPLD */
@@ -308,7 +458,11 @@ int checkboard(void)
case 0xe:
puts("SDHC\n");
val = 0x60; /* set pca9557 pin input/output */
#ifdef CONFIG_DM_I2C
dm_i2c_write(dev, 3, &val, 1);
#else
i2c_write(I2C_PCA9557_ADDR2, 3, 1, &val, 1);
#endif
break;
case 0x5:
config_board_mux(MUX_TYPE_IFC);
@@ -457,7 +611,7 @@ int ft_board_setup(void *blob, bd_t *bd)
base = env_get_bootm_low();
size = env_get_bootm_size();
#if defined(CONFIG_PCI)
#if defined(CONFIG_PCI) && !defined(CONFIG_DM_PCI)
FT_FSL_PCI_SETUP;
#endif

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2010-2011, 2013 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -227,6 +228,7 @@ int checkboard(void)
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
u8 in, out, io_config, val;
int bus_num = CONFIG_SYS_SPD_BUS_NUM;
printf("Board: %s CPLD: V%d.%d PCBA: V%d.0\n", CONFIG_BOARDNAME,
in_8(&cpld_data->cpld_rev_major) & 0x0F,
@@ -234,7 +236,26 @@ int checkboard(void)
in_8(&cpld_data->pcba_rev) & 0x0F);
/* Initialize i2c early for rom_loc and flash bank information */
i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
#if defined(CONFIG_DM_I2C)
struct udevice *dev;
int ret;
ret = i2c_get_chip_for_busnum(bus_num, CONFIG_SYS_I2C_PCA9557_ADDR,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return -ENXIO;
}
if (dm_i2c_read(dev, 0, &in, 1) < 0 ||
dm_i2c_read(dev, 1, &out, 1) < 0 ||
dm_i2c_read(dev, 3, &io_config, 1) < 0) {
printf("Error reading i2c boot information!\n");
return 0; /* Don't want to hang() on this error */
}
#else /* Non DM I2C support - will be removed */
i2c_set_bus_num(bus_num);
if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0, 1, &in, 1) < 0 ||
i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 1, 1, &out, 1) < 0 ||
@@ -242,6 +263,7 @@ int checkboard(void)
printf("Error reading i2c boot information!\n");
return 0; /* Don't want to hang() on this error */
}
#endif
val = (in & io_config) | (out & (~io_config));

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2014 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -75,11 +76,24 @@ int checkboard(void)
return 0;
}
int select_i2c_ch_pca9547(u8 ch)
int select_i2c_ch_pca9547(u8 ch, int bus_num)
{
int ret;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_write(dev, 0, &ch, 1);
#else
ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
#endif
if (ret) {
puts("PCA: failed to select proper channel\n");
return ret;
@@ -191,6 +205,82 @@ void board_retimer_ds125df111_init(void)
{
u8 reg;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
int ret, bus_num = 0;
ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
1, &dev);
if (ret)
goto failed;
/* Retimer DS125DF111 is connected to I2C1_CH7_CH5 */
reg = I2C_MUX_CH7;
dm_i2c_write(dev, 0, &reg, 1);
ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_SEC,
1, &dev);
if (ret)
goto failed;
reg = I2C_MUX_CH5;
dm_i2c_write(dev, 0, &reg, 1);
/* Access to Control/Shared register */
ret = i2c_get_chip_for_busnum(bus_num, I2C_RETIMER_ADDR,
1, &dev);
if (ret)
goto failed;
reg = 0x0;
dm_i2c_write(dev, 0xff, &reg, 1);
/* Read device revision and ID */
dm_i2c_read(dev, 1, &reg, 1);
debug("Retimer version id = 0x%x\n", reg);
/* Enable Broadcast */
reg = 0x0c;
dm_i2c_write(dev, 0xff, &reg, 1);
/* Reset Channel Registers */
dm_i2c_read(dev, 0, &reg, 1);
reg |= 0x4;
dm_i2c_write(dev, 0, &reg, 1);
/* Enable override divider select and Enable Override Output Mux */
dm_i2c_read(dev, 9, &reg, 1);
reg |= 0x24;
dm_i2c_write(dev, 9, &reg, 1);
/* Select VCO Divider to full rate (000) */
dm_i2c_read(dev, 0x18, &reg, 1);
reg &= 0x8f;
dm_i2c_write(dev, 0x18, &reg, 1);
/* Select active PFD MUX input as re-timed data (001) */
dm_i2c_read(dev, 0x1e, &reg, 1);
reg &= 0x3f;
reg |= 0x20;
dm_i2c_write(dev, 0x1e, &reg, 1);
/* Set data rate as 10.3125 Gbps */
reg = 0x0;
dm_i2c_write(dev, 0x60, &reg, 1);
reg = 0xb2;
dm_i2c_write(dev, 0x61, &reg, 1);
reg = 0x90;
dm_i2c_write(dev, 0x62, &reg, 1);
reg = 0xb3;
dm_i2c_write(dev, 0x63, &reg, 1);
reg = 0xcd;
dm_i2c_write(dev, 0x64, &reg, 1);
return;
failed:
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return;
#else
/* Retimer DS125DF111 is connected to I2C1_CH7_CH5 */
reg = I2C_MUX_CH7;
i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &reg, 1);
@@ -241,6 +331,7 @@ void board_retimer_ds125df111_init(void)
i2c_write(I2C_RETIMER_ADDR, 0x63, 1, &reg, 1);
reg = 0xcd;
i2c_write(I2C_RETIMER_ADDR, 0x64, 1, &reg, 1);
#endif
}
int board_early_init_f(void)
@@ -281,7 +372,7 @@ int board_early_init_r(void)
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
0, flash_esel, BOOKE_PAGESZ_256M, 1);
#endif
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
board_mux_lane_to_slot();
board_retimer_ds125df111_init();

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2014 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#ifndef __T102x_QDS_H__
@@ -8,6 +9,6 @@
void fdt_fixup_board_enet(void *blob);
void pci_of_setup(void *blob, bd_t *bd);
int select_i2c_ch_pca9547(u8 ch);
int select_i2c_ch_pca9547(u8 ch, int bus_num);
#endif

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2014 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -250,8 +251,69 @@ static u32 t1023rdb_ctrl(u32 ctrl_type)
{
ccsr_gpio_t __iomem *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
u32 val, orig_bus = i2c_get_bus_num();
u32 val;
u8 tmp;
int bus_num = I2C_PCA6408_BUS_NUM;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
int ret;
ret = i2c_get_chip_for_busnum(bus_num, I2C_PCA6408_ADDR,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
switch (ctrl_type) {
case GPIO1_SD_SEL:
val = in_be32(&pgpio->gpdat);
val |= GPIO1_SD_SEL;
out_be32(&pgpio->gpdat, val);
setbits_be32(&pgpio->gpdir, GPIO1_SD_SEL);
break;
case GPIO1_EMMC_SEL:
val = in_be32(&pgpio->gpdat);
val &= ~GPIO1_SD_SEL;
out_be32(&pgpio->gpdat, val);
setbits_be32(&pgpio->gpdir, GPIO1_SD_SEL);
break;
case GPIO3_GET_VERSION:
pgpio = (ccsr_gpio_t *)(CONFIG_SYS_MPC85xx_GPIO_ADDR
+ GPIO3_OFFSET);
val = in_be32(&pgpio->gpdat);
val = ((val & GPIO3_BRD_VER_MASK) >> 26) & 0x3;
if (val == 0x3) /* GPIO3_4/5 not used on RevB */
val = 0;
return val;
case I2C_GET_BANK:
dm_i2c_read(dev, 0, &tmp, 1);
tmp &= 0x7;
tmp = ((tmp & 1) << 2) | (tmp & 2) | ((tmp & 4) >> 2);
return tmp;
case I2C_SET_BANK0:
tmp = 0x0;
dm_i2c_write(dev, 1, &tmp, 1);
tmp = 0xf8;
dm_i2c_write(dev, 3, &tmp, 1);
/* asserting HRESET_REQ */
out_be32(&gur->rstcr, 0x2);
break;
case I2C_SET_BANK4:
tmp = 0x1;
dm_i2c_write(dev, 1, &tmp, 1);
tmp = 0xf8;
dm_i2c_write(dev, 3, &tmp, 1);
out_be32(&gur->rstcr, 0x2);
break;
default:
break;
}
#else
u32 orig_bus;
orig_bus = i2c_get_bus_num();
switch (ctrl_type) {
case GPIO1_SD_SEL:
@@ -275,14 +337,14 @@ static u32 t1023rdb_ctrl(u32 ctrl_type)
val = 0;
return val;
case I2C_GET_BANK:
i2c_set_bus_num(I2C_PCA6408_BUS_NUM);
i2c_set_bus_num(bus_num);
i2c_read(I2C_PCA6408_ADDR, 0, 1, &tmp, 1);
tmp &= 0x7;
tmp = ((tmp & 1) << 2) | (tmp & 2) | ((tmp & 4) >> 2);
i2c_set_bus_num(orig_bus);
return tmp;
case I2C_SET_BANK0:
i2c_set_bus_num(I2C_PCA6408_BUS_NUM);
i2c_set_bus_num(bus_num);
tmp = 0x0;
i2c_write(I2C_PCA6408_ADDR, 1, 1, &tmp, 1);
tmp = 0xf8;
@@ -291,7 +353,7 @@ static u32 t1023rdb_ctrl(u32 ctrl_type)
out_be32(&gur->rstcr, 0x2);
break;
case I2C_SET_BANK4:
i2c_set_bus_num(I2C_PCA6408_BUS_NUM);
i2c_set_bus_num(bus_num);
tmp = 0x1;
i2c_write(I2C_PCA6408_ADDR, 1, 1, &tmp, 1);
tmp = 0xf8;
@@ -301,6 +363,7 @@ static u32 t1023rdb_ctrl(u32 ctrl_type)
default:
break;
}
#endif
return 0;
}

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2014 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
* Author: Priyanka Jain <Priyanka.Jain@freescale.com>
*/
@@ -48,7 +49,7 @@ void diu_set_pixel_clock(unsigned int pixclock)
/* Program HDMI encoder */
/* Switch channel to DIU */
select_i2c_ch_pca9547(I2C_MUX_CH_DIU);
select_i2c_ch_pca9547(I2C_MUX_CH_DIU, 0);
/* Set dispaly encoder */
ret = diu_set_dvi_encoder(temp);
@@ -58,7 +59,7 @@ void diu_set_pixel_clock(unsigned int pixclock)
}
/* Switch channel to default */
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
/* Program pixel clock */
out_be32((unsigned *)CONFIG_SYS_FSL_SCFG_PIXCLK_ADDR,

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2013 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -79,11 +80,24 @@ int checkboard(void)
return 0;
}
int select_i2c_ch_pca9547(u8 ch)
int select_i2c_ch_pca9547(u8 ch, int bus_num)
{
int ret;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, 1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_write(dev, 0, &ch, 1);
#else
ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
#endif
if (ret) {
puts("PCA: failed to select proper channel\n");
return ret;
@@ -154,7 +168,7 @@ int board_early_init_r(void)
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
0, flash_esel, BOOKE_PAGESZ_256M, 1);
#endif
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
return 0;
}

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2013 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#ifndef __T1040_QDS_H__
@@ -8,6 +9,6 @@
void fdt_fixup_board_enet(void *blob);
void pci_of_setup(void *blob, bd_t *bd);
int select_i2c_ch_pca9547(u8 ch);
int select_i2c_ch_pca9547(u8 ch, int bus_bum);
#endif

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2009-2013 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -75,11 +76,23 @@ int checkboard(void)
return 0;
}
int select_i2c_ch_pca9547(u8 ch)
int select_i2c_ch_pca9547(u8 ch, int bus_num)
{
int ret;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, 1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_write(dev, 0, &ch, 1);
#else
ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
#endif
if (ret) {
puts("PCA: failed to select proper channel\n");
return ret;
@@ -90,7 +103,7 @@ int select_i2c_ch_pca9547(u8 ch)
int i2c_multiplexer_select_vid_channel(u8 channel)
{
return select_i2c_ch_pca9547(channel);
return select_i2c_ch_pca9547(channel, 0);
}
int brd_mux_lane_to_slot(void)
@@ -368,7 +381,7 @@ int board_early_init_r(void)
printf("Warning: Adjusting core voltage failed.\n");
brd_mux_lane_to_slot();
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
return 0;
}

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2009-2012 Freescale Semiconductor, Inc.
* Copyright 2020 NXP
*/
#include <common.h>
@@ -91,11 +92,25 @@ int checkboard(void)
return 0;
}
int select_i2c_ch_pca9547(u8 ch)
int select_i2c_ch_pca9547(u8 ch, int bus_num)
{
int ret;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_write(dev, 0, &ch, 1);
#else
ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
#endif
if (ret) {
puts("PCA: failed to select proper channel\n");
return ret;
@@ -115,10 +130,28 @@ static inline int read_voltage(void)
{
int i, ret, voltage_read = 0;
u16 vol_mon;
#ifdef CONFIG_DM_I2C
struct udevice *dev;
int bus_num = 0;
#endif
for (i = 0; i < NUM_READINGS; i++) {
#ifdef CONFIG_DM_I2C
ret = i2c_get_chip_for_busnum(bus_num, I2C_VOL_MONITOR_ADDR,
1, &dev);
if (ret) {
printf("%s: Cannot find udev for a bus %d\n", __func__,
bus_num);
return ret;
}
ret = dm_i2c_read(dev,
I2C_VOL_MONITOR_BUS_V_OFFSET,
(void *)&vol_mon, 2);
#else
ret = i2c_read(I2C_VOL_MONITOR_ADDR,
I2C_VOL_MONITOR_BUS_V_OFFSET, 1, (void *)&vol_mon, 2);
#endif
if (ret) {
printf("VID: failed to read core voltage\n");
return ret;
@@ -250,7 +283,7 @@ static int adjust_vdd(ulong vdd_override)
unsigned voltage;
};
ret = select_i2c_ch_pca9547(I2C_MUX_CH_VOL_MONITOR);
ret = select_i2c_ch_pca9547(I2C_MUX_CH_VOL_MONITOR, 0);
if (ret) {
debug("VID: I2c failed to switch channel\n");
ret = -1;
@@ -348,7 +381,7 @@ int config_frontside_crossbar_vsc3316(void)
u32 srds_prtcl_s1, srds_prtcl_s2;
int ret;
ret = select_i2c_ch_pca9547(I2C_MUX_CH_VSC3316_FS);
ret = select_i2c_ch_pca9547(I2C_MUX_CH_VSC3316_FS, 0);
if (ret)
return ret;
@@ -567,7 +600,7 @@ int board_early_init_r(void)
/* Configure board SERDES ports crossbar */
config_frontside_crossbar_vsc3316();
config_backside_crossbar_mux();
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
return 0;
}
@@ -732,11 +765,11 @@ void board_detail(void)
}
/* Voltage secion */
if (!select_i2c_ch_pca9547(I2C_MUX_CH_VOL_MONITOR)) {
if (!select_i2c_ch_pca9547(I2C_MUX_CH_VOL_MONITOR, 0)) {
vdd = read_voltage();
if (vdd > 0)
printf("Core voltage= %d mV\n", vdd);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
}
printf("XVDD = 1.%d V\n", ((brdcfg[8] & 0xf) - 4) * 5 + 25);