Skip to content
Snippets Groups Projects
Commit e936f997 authored by Nishanth Menon's avatar Nishanth Menon Committed by Tom Rini
Browse files

ti: common: board_detect: Allow settings board detection variables manually


In some situations the EEPROM used for board detection may not be
programmed or simply programmed incorrectly. Therefore, it may be
necessary to "simulate" reading the contents of the EEPROM to set
appropriate variables used in the board detection code.

This may also be helpful in certain boot modes where doing i2c reads
may be costly and the config supports running only a specific board.

Signed-off-by: default avatarNishanth Menon <nm@ti.com>
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Signed-off-by: default avatarKeerthy <j-keerthy@ti.com>
Signed-off-by: default avatarFranklin S Cooper Jr. <fcooper@ti.com>
Reviewed-by: default avatarTom Rini <trini@konsulko.com>
parent a75df9ae
No related branches found
No related tags found
No related merge requests found
...@@ -173,6 +173,30 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, ...@@ -173,6 +173,30 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
return 0; return 0;
} }
int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev)
{
struct ti_common_eeprom *ep;
if (!name || !rev)
return -1;
ep = TI_EEPROM_DATA;
if (ep->header == TI_EEPROM_HEADER_MAGIC)
goto already_set;
/* Set to 0 all fields */
memset(ep, 0, sizeof(*ep));
strncpy(ep->name, name, TI_EEPROM_HDR_NAME_LEN);
strncpy(ep->version, rev, TI_EEPROM_HDR_REV_LEN);
/* Some dummy serial number to identify the platform */
strncpy(ep->serial, "0000", TI_EEPROM_HDR_SERIAL_LEN);
/* Mark it with a valid header */
ep->header = TI_EEPROM_HEADER_MAGIC;
already_set:
return 0;
}
int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr) int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr)
{ {
int rc; int rc;
......
...@@ -205,4 +205,21 @@ void set_board_info_env(char *name); ...@@ -205,4 +205,21 @@ void set_board_info_env(char *name);
*/ */
void board_ti_set_ethaddr(int index); void board_ti_set_ethaddr(int index);
/**
* ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
* @name: Name of the board
* @rev: Revision of the board
*
* In some cases such as in RTC-only mode, we are able to skip reading eeprom
* and wasting i2c based initialization time by using predefined flags for
* detecting what platform we are booting on. For those platforms, provide
* a handy function to pre-program information.
*
* NOTE: many eeprom information such as serial number, mac address etc is not
* available.
*
* Return: 0 if all went fine, else return error.
*/
int ti_i2c_eeprom_am_set(const char *name, const char *rev);
#endif /* __BOARD_DETECT_H */ #endif /* __BOARD_DETECT_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment