i2c: Drop use of CONFIG_I2C_HARD

This option is pretty old. It predates CONFIG_SYS_I2C which is itself
deprecated in favour of driver model. Disable it for all boards.

Also drop I2C options which depend on this.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2017-05-12 21:09:49 -06:00
committed by Heiko Schocher
parent 22f3368e71
commit eb5ba3aefd
81 changed files with 211 additions and 701 deletions

View File

@@ -156,17 +156,7 @@ int board_init(void)
int board_late_init(void)
{
u8 mac[6];
/* Read Mac Address and set*/
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
i2c_set_bus_num(CONFIG_SYS_I2C_MODULE);
/* Read MAC address */
i2c_read(0x50, 0x0, 0, mac, 6);
if (is_valid_ethaddr(mac))
eth_setenv_enetaddr("ethaddr", mac);
printf("Cannot use I2C to get MAC address\n");
return 0;
}

View File

@@ -161,14 +161,7 @@ int dram_init(void)
*/
static void read_hw_id(hw_id_t hw_id)
{
int i;
for (i = 0; i < HW_ID_ELEM_COUNT; ++i)
if (i2c_read(CONFIG_SYS_I2C_EEPROM,
hw_id_format[i].offset,
2,
(uchar *)&hw_id[i][0],
hw_id_format[i].length) != 0)
printf("ERROR: can't read HW ID from EEPROM\n");
printf("ERROR: can't read HW ID from EEPROM\n");
}
@@ -221,7 +214,7 @@ static void compose_module_name(hw_id_t hw_id, char *buf)
strcat(buf, tmp);
}
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
/*
* Compose string with hostname.
* buf is assumed to have enough space, and be null-terminated.
@@ -237,7 +230,7 @@ static void compose_hostname(hw_id_t hw_id, char *buf)
*p = tolower(*p);
}
#endif
#ifdef CONFIG_OF_BOARD_SETUP
/*
@@ -270,15 +263,6 @@ int checkboard(void)
hw_id_t hw_id_tmp;
char module_name_tmp[MODULE_NAME_MAXLEN] = "";
/*
* We need I2C to access HW ID data from EEPROM, so we call i2c_init()
* here despite the fact that it will be called again later on. We
* also use a little trick to silence I2C-related output.
*/
gd->flags |= GD_FLG_SILENT;
i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
gd->flags &= ~GD_FLG_SILENT;
read_hw_id(hw_id_tmp);
identify_module(hw_id_tmp); /* this sets gd->board_type */
compose_module_name(hw_id_tmp, module_name_tmp);
@@ -334,16 +318,16 @@ int misc_init_r(void)
" device at address %02X:%04X\n", CONFIG_SYS_I2C_EEPROM,
CONFIG_MAC_OFFSET);
}
hostname[0] = 0x00;
/* set the hostname appropriate to the module we're running on */
compose_hostname(hw_id, hostname);
setenv("hostname", hostname);
#endif /* defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT) */
if (!getenv("ethaddr"))
printf(LOG_PREFIX "MAC address not set, networking is not "
"operational\n");
/* set the hostname appropriate to the module we're running on */
hostname[0] = 0x00;
compose_hostname(hw_id, hostname);
setenv("hostname", hostname);
return 0;
}
#endif /* CONFIG_MISC_INIT_R */

View File

@@ -13,34 +13,6 @@
#ifdef CONFIG_CMD_BSP
static int do_i2c_test(char * const argv[])
{
unsigned char temp, temp1;
printf("Starting I2C Test\n"
"Please set Jumper:\nI2C SDA 2-3\nI2C SCL 2-3\n\n"
"Please press any key to start\n\n");
getc();
temp = 0xf0; /* set io 0-4 as output */
i2c_write(CONFIG_SYS_I2C_IO, 3, 1, (uchar *)&temp, 1);
printf("Press I2C4-7. LED I2C0-3 should have the same state\n\n"
"Press any key to stop\n\n");
while (!tstc()) {
i2c_read(CONFIG_SYS_I2C_IO, 0, 1, (uchar *)&temp, 1);
temp1 = (temp >> 4) & 0x03;
temp1 |= (temp >> 3) & 0x08; /* S302 -> LED303 */
temp1 |= (temp >> 5) & 0x04; /* S303 -> LED302 */
temp = temp1;
i2c_write(CONFIG_SYS_I2C_IO, 1, 1, (uchar *)&temp, 1);
}
getc();
return 0;
}
static int do_usb_test(char * const argv[])
{
int i;
@@ -387,9 +359,7 @@ static int cmd_fkt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
switch (argc) {
case 2:
if (strncmp(argv[1], "i2c", 3) == 0)
rcode = do_i2c_test(argv);
else if (strncmp(argv[1], "led", 3) == 0)
if (strncmp(argv[1], "led", 3) == 0)
rcode = do_led_test(argv);
else if (strncmp(argv[1], "usb", 3) == 0)
rcode = do_usb_test(argv);

View File

@@ -29,9 +29,6 @@ int misc_init_r(void)
{
u32 tmp;
/* we use I2C-2 for on-board eeprom */
i2c_set_bus_num(2);
tmp = in_be32((u32*)CONFIG_SYS_ARIA_FPGA_BASE);
printf("FPGA: %u-%u.%u.%u\n",
(tmp & 0xFF000000) >> 24,

View File

@@ -18,17 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
int eeprom_write_enable(unsigned dev_addr, int state)
{
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
if (dev_addr != CONFIG_SYS_I2C_EEPROM_ADDR)
return -1;
if (state == 0)
setbits_be32(&im->gpio.gpdat, 0x00100000);
else
clrbits_be32(&im->gpio.gpdat, 0x00100000);
return 0;
return -ENOSYS;
}
int board_early_init_f(void)

View File

@@ -174,27 +174,6 @@ int dram_init(void)
int misc_init_r(void)
{
u8 tmp_val;
/* Using this for DIU init before the driver in linux takes over
* Enable the TFP410 Encoder (I2C address 0x38)
*/
i2c_set_bus_num(2);
tmp_val = 0xBF;
i2c_write(0x38, 0x08, 1, &tmp_val, sizeof(tmp_val));
/* Verify if enabled */
tmp_val = 0;
i2c_read(0x38, 0x08, 1, &tmp_val, sizeof(tmp_val));
debug("DVI Encoder Read: 0x%02x\n", tmp_val);
tmp_val = 0x10;
i2c_write(0x38, 0x0A, 1, &tmp_val, sizeof(tmp_val));
/* Verify if enabled */
tmp_val = 0;
i2c_read(0x38, 0x0A, 1, &tmp_val, sizeof(tmp_val));
debug("DVI Encoder Read: 0x%02x\n", tmp_val);
return 0;
}

View File

@@ -17,7 +17,6 @@
#include <i2c.h>
#endif
static int eeprom_diag;
static int mac_diag;
static int gpio_diag;
@@ -136,7 +135,6 @@ struct __attribute__ ((__packed__)) eeprom_layout {
#define HW_COMP_MAINCPU 2
static struct eeprom_layout eeprom_content;
static int eeprom_was_read; /* has_been_read */
static int eeprom_is_valid;
static int eeprom_version;
@@ -153,53 +151,7 @@ static int eeprom_version;
static int read_eeprom(void)
{
int eeprom_datalen;
int ret;
if (eeprom_was_read)
return 0;
eeprom_is_valid = 0;
ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,
CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
(uchar *)&eeprom_content, sizeof(eeprom_content));
if (eeprom_diag) {
printf("DIAG: %s() read rc[%d], size[%d]\n",
__func__, ret, sizeof(eeprom_content));
}
if (ret != 0)
return -1;
eeprom_was_read = 1;
/*
* check validity of EEPROM content
* (check version, length, optionally checksum)
*/
eeprom_is_valid = 1;
eeprom_datalen = get_eeprom_field_int(eeprom_content.len);
eeprom_version = get_eeprom_field_int(eeprom_content.version);
if (eeprom_diag) {
printf("DIAG: %s() magic[%c%c%c] len[%d] ver[%d] type[%d]\n",
__func__, eeprom_content.magic[0],
eeprom_content.magic[1], eeprom_content.magic[2],
eeprom_datalen, eeprom_version, eeprom_content.type);
}
if (strncmp(eeprom_content.magic, "ifm", strlen("ifm")) != 0)
eeprom_is_valid = 0;
if (eeprom_datalen < sizeof(struct eeprom_layout) - 5)
eeprom_is_valid = 0;
if ((eeprom_version != 1) && (eeprom_version != 2))
eeprom_is_valid = 0;
if (eeprom_content.type != HW_COMP_MAINCPU)
eeprom_is_valid = 0;
if (eeprom_diag)
printf("DIAG: %s() valid[%d]\n", __func__, eeprom_is_valid);
return ret;
return -ENOSYS;
}
int mac_read_from_eeprom(void)
@@ -324,9 +276,6 @@ int misc_init_r(void)
char *s;
int want_recovery;
/* we use bus I2C-0 for the on-board eeprom */
i2c_set_bus_num(0);
/* setup GPIO directions and initial values */
gpio_configure();

View File

@@ -44,17 +44,7 @@ int board_init(void)
int board_late_init(void)
{
u8 mac[6];
/* Read Mac Address and set*/
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
i2c_set_bus_num(CONFIG_SYS_I2C_MODULE);
/* Read MAC address */
i2c_read(0x50, 0x10, 0, mac, 6);
if (is_valid_ethaddr(mac))
eth_setenv_enetaddr("ethaddr", mac);
printf("Cannot get MAC address from I2C\n");
return 0;
}

View File

@@ -486,20 +486,14 @@ int board_early_init_f (void)
static int tfp410_read_reg(int reg, uchar *buf)
{
if (i2c_read(CONFIG_SYS_TFP410_ADDR, reg, 1, buf, 1) != 0) {
puts ("Error reading the chip.\n");
return 1;
}
return 0;
puts("Error reading the chip.\n");
return -ENOSYS;
}
static int tfp410_write_reg(int reg, uchar buf)
{
if (i2c_write(CONFIG_SYS_TFP410_ADDR, reg, 1, &buf, 1) != 0) {
puts ("Error writing the chip.\n");
return 1;
}
return 0;
puts("Error writing the chip.\n");
return -ENOSYS;
}
typedef struct _tfp410_config {
@@ -525,12 +519,9 @@ static int charon_last_stage_init(void)
{
volatile struct mpc5xxx_lpb *lpb =
(struct mpc5xxx_lpb *) MPC5XXX_LPB;
int oldbus = i2c_get_bus_num();
uchar buf;
int i = 0;
i2c_set_bus_num(CONFIG_SYS_TFP410_BUS);
/* check version */
if (tfp410_read_reg(TFP410_REG_DEV_ID_H, &buf) != 0)
return -1;
@@ -551,7 +542,6 @@ static int charon_last_stage_init(void)
i++;
}
printf("TFP410 initialized.\n");
i2c_set_bus_num(oldbus);
/* set deadcycle for cs3 to 0 */
setbits_be32(&lpb->cs_deadcycle, 0xffffcfff);