#include <environment.h>
#include <watchdog.h>
#include <environment.h>
+#include "../common/board_detect.h"
#include "board.h"
DECLARE_GLOBAL_DATA_PTR;
/*
* Read header information from EEPROM into global structure.
*/
-static int read_eeprom(struct am335x_baseboard_id *header)
+static inline int __maybe_unused read_eeprom(void)
{
- /* Check if baseboard eeprom is available */
- if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
- puts("Could not probe the EEPROM; something fundamentally "
- "wrong on the I2C bus.\n");
- return -ENODEV;
- }
-
- /* read the eeprom using i2c */
- if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header,
- sizeof(struct am335x_baseboard_id))) {
- puts("Could not read the EEPROM; something fundamentally"
- " wrong on the I2C bus.\n");
- return -EIO;
- }
-
- if (header->magic != 0xEE3355AA) {
- /*
- * read the eeprom using i2c again,
- * but use only a 1 byte address
- */
- if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header,
- sizeof(struct am335x_baseboard_id))) {
- puts("Could not read the EEPROM; something "
- "fundamentally wrong on the I2C bus.\n");
- return -EIO;
- }
-
- if (header->magic != 0xEE3355AA) {
- printf("Incorrect magic number (0x%x) in EEPROM\n",
- header->magic);
- return -EINVAL;
- }
- }
-
- return 0;
+ return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR);
}
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
void am33xx_spl_board_init(void)
{
- struct am335x_baseboard_id header;
int mpu_vdd;
- if (read_eeprom(&header) < 0)
+ if (read_eeprom() < 0)
puts("Could not get board ID.\n");
/* Get the frequency */
dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
- if (board_is_bone(&header) || board_is_bone_lt(&header)) {
+ if (board_is_bone() || board_is_bone_lt()) {
/* BeagleBone PMIC Code */
int usb_cur_lim;
* Only perform PMIC configurations if board rev > A1
* on Beaglebone White
*/
- if (board_is_bone(&header) && !strncmp(header.version,
- "00A1", 4))
+ if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4))
return;
if (i2c_probe(TPS65217_CHIP_PM))
* On Beaglebone White we need to ensure we have AC power
* before increasing the frequency.
*/
- if (board_is_bone(&header)) {
+ if (board_is_bone()) {
uchar pmic_status_reg;
if (tps65217_reg_read(TPS65217_STATUS,
&pmic_status_reg))
* Override what we have detected since we know if we have
* a Beaglebone Black it supports 1GHz.
*/
- if (board_is_bone_lt(&header))
+ if (board_is_bone_lt())
dpll_mpu_opp100.m = MPUPLL_M_1000;
/*
* Set LDO3, LDO4 output voltage to 3.3V for Beaglebone.
* Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black.
*/
- if (board_is_bone(&header)) {
+ if (board_is_bone()) {
if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
TPS65217_DEFLS1,
TPS65217_LDO_VOLTAGE_OUT_3_3,
const struct dpll_params *get_dpll_ddr_params(void)
{
- struct am335x_baseboard_id header;
-
enable_i2c0_pin_mux();
i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
- if (read_eeprom(&header) < 0)
+ if (read_eeprom() < 0)
puts("Could not get board ID.\n");
- if (board_is_evm_sk(&header))
+ if (board_is_evm_sk())
return &dpll_ddr_evm_sk;
- else if (board_is_bone_lt(&header))
+ else if (board_is_bone_lt())
return &dpll_ddr_bone_black;
- else if (board_is_evm_15_or_later(&header))
+ else if (board_is_evm_15_or_later())
return &dpll_ddr_evm_sk;
else
return &dpll_ddr;
void set_mux_conf_regs(void)
{
- __maybe_unused struct am335x_baseboard_id header;
-
- if (read_eeprom(&header) < 0)
+ if (read_eeprom() < 0)
puts("Could not get board ID.\n");
- enable_board_pin_mux(&header);
+ enable_board_pin_mux();
}
const struct ctrl_ioregs ioregs_evmsk = {
void sdram_init(void)
{
- __maybe_unused struct am335x_baseboard_id header;
-
- if (read_eeprom(&header) < 0)
+ if (read_eeprom() < 0)
puts("Could not get board ID.\n");
- if (board_is_evm_sk(&header)) {
+ if (board_is_evm_sk()) {
/*
* EVM SK 1.2A and later use gpio0_7 to enable DDR3.
* This is safe enough to do on older revs.
gpio_direction_output(GPIO_DDR_VTT_EN, 1);
}
- if (board_is_evm_sk(&header))
+ if (board_is_evm_sk())
config_ddr(303, &ioregs_evmsk, &ddr3_data,
&ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
- else if (board_is_bone_lt(&header))
+ else if (board_is_bone_lt())
config_ddr(400, &ioregs_bonelt,
&ddr3_beagleblack_data,
&ddr3_beagleblack_cmd_ctrl_data,
&ddr3_beagleblack_emif_reg_data, 0);
- else if (board_is_evm_15_or_later(&header))
+ else if (board_is_evm_15_or_later())
config_ddr(303, &ioregs_evm15, &ddr3_evm_data,
&ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);
else
int board_late_init(void)
{
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
- char safe_string[HDR_NAME_LEN + 1];
- struct am335x_baseboard_id header;
+ int rc;
+ char *name = NULL;
- if (read_eeprom(&header) < 0)
+ rc = read_eeprom();
+ if (rc)
puts("Could not get board ID.\n");
- /* Now set variables based on the header. */
- strncpy(safe_string, (char *)header.name, sizeof(header.name));
- safe_string[sizeof(header.name)] = 0;
- setenv("board_name", safe_string);
-
- /* BeagleBone Green eeprom, board_rev: 0x1a 0x00 0x00 0x00 */
- if ( (header.version[0] == 0x1a) && (header.version[1] == 0x00) &&
- (header.version[2] == 0x00) && (header.version[3] == 0x00) ) {
- setenv("board_rev", "BBG1");
- } else {
- strncpy(safe_string, (char *)header.version, sizeof(header.version));
- safe_string[sizeof(header.version)] = 0;
- setenv("board_rev", safe_string);
- }
+ if (board_is_bbg1())
+ name = "BBG1";
+ set_board_info_env(name);
#endif
return 0;
int rv, n = 0;
uint8_t mac_addr[6];
uint32_t mac_hi, mac_lo;
- __maybe_unused struct am335x_baseboard_id header;
+ __maybe_unused struct ti_am_eeprom *header;
/* try reading mac address from efuse */
mac_lo = readl(&cdev->macid0l);
eth_setenv_enetaddr("eth1addr", mac_addr);
}
- if (read_eeprom(&header) < 0)
+ if (read_eeprom() < 0)
puts("Could not get board ID.\n");
- if (board_is_bone(&header) || board_is_bone_lt(&header) ||
- board_is_idk(&header)) {
+ if (board_is_bone() || board_is_bone_lt() ||
+ board_is_idk()) {
writel(MII_MODE_ENABLE, &cdev->miisel);
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_MII;
#define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5
#define AR8051_RGMII_TX_CLK_DLY 0x100
- if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) {
+ if (board_is_evm_sk() || board_is_gp_evm()) {
const char *devname;
devname = miiphy_get_current_dev();
#ifndef _BOARD_H_
#define _BOARD_H_
-/*
- * TI AM335x parts define a system EEPROM that defines certain sub-fields.
- * We use these fields to in turn see what board we are on, and what
- * that might require us to set or not set.
- */
-#define HDR_NO_OF_MAC_ADDR 3
-#define HDR_ETH_ALEN 6
-#define HDR_NAME_LEN 8
-
-struct am335x_baseboard_id {
- unsigned int magic;
- char name[HDR_NAME_LEN];
- char version[4];
- char serial[12];
- char config[32];
- char mac_addr[HDR_NO_OF_MAC_ADDR][HDR_ETH_ALEN];
-};
+static inline int board_is_bone(void)
+{
+ return board_ti_is("A335BONE");
+}
-static inline int board_is_bone(struct am335x_baseboard_id *header)
+static inline int board_is_bone_lt(void)
{
- return !strncmp(header->name, "A335BONE", HDR_NAME_LEN);
+ return board_ti_is("A335BNLT");
}
-static inline int board_is_bone_lt(struct am335x_baseboard_id *header)
+static inline int board_is_bbg1(void)
{
- return !strncmp(header->name, "A335BNLT", HDR_NAME_LEN);
+ return board_is_bone_lt() && !strncmp(board_ti_get_rev(), "BBG1", 4);
}
-static inline int board_is_evm_sk(struct am335x_baseboard_id *header)
+static inline int board_is_evm_sk(void)
{
- return !strncmp("A335X_SK", header->name, HDR_NAME_LEN);
+ return board_ti_is("A335X_SK");
}
-static inline int board_is_idk(struct am335x_baseboard_id *header)
+static inline int board_is_idk(void)
{
- return !strncmp(header->config, "SKU#02", 6);
+ return !strncmp(board_ti_get_config(), "SKU#02", 6);
}
-static inline int board_is_gp_evm(struct am335x_baseboard_id *header)
+static inline int board_is_gp_evm(void)
{
- return !strncmp("A33515BB", header->name, HDR_NAME_LEN);
+ return board_ti_is("A33515BB");
}
-static inline int board_is_evm_15_or_later(struct am335x_baseboard_id *header)
+static inline int board_is_evm_15_or_later(void)
{
- return (board_is_gp_evm(header) &&
- strncmp("1.5", header->version, 3) <= 0);
+ return (board_is_gp_evm() &&
+ strncmp("1.5", board_ti_get_rev(), 3) <= 0);
}
/*
void enable_uart4_pin_mux(void);
void enable_uart5_pin_mux(void);
void enable_i2c0_pin_mux(void);
-void enable_board_pin_mux(struct am335x_baseboard_id *header);
+void enable_board_pin_mux(void);
#endif
#include <asm/arch/mux.h>
#include <asm/io.h>
#include <i2c.h>
+#include "../common/board_detect.h"
#include "board.h"
static struct module_pin_mux uart0_pin_mux[] = {
return (1 << (val & PROFILE_MASK));
}
-void enable_board_pin_mux(struct am335x_baseboard_id *header)
+void enable_board_pin_mux(void)
{
/* Do board-specific muxes. */
- if (board_is_bone(header)) {
+ if (board_is_bone()) {
/* Beaglebone pinmux */
configure_module_pin_mux(mii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux);
#else
configure_module_pin_mux(mmc1_pin_mux);
#endif
- } else if (board_is_gp_evm(header)) {
+ } else if (board_is_gp_evm()) {
/* General Purpose EVM */
unsigned short profile = detect_daughter_board_profile();
configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(mmc1_pin_mux);
configure_module_pin_mux(spi0_pin_mux);
}
- } else if (board_is_idk(header)) {
+ } else if (board_is_idk()) {
/* Industrial Motor Control (IDK) */
configure_module_pin_mux(mii1_pin_mux);
configure_module_pin_mux(mmc0_no_cd_pin_mux);
- } else if (board_is_evm_sk(header)) {
+ } else if (board_is_evm_sk()) {
/* Starter Kit EVM */
configure_module_pin_mux(i2c1_pin_mux);
configure_module_pin_mux(gpio0_7_pin_mux);
configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux_sk_evm);
- } else if (board_is_bone_lt(header)) {
+ } else if (board_is_bone_lt()) {
/* Beaglebone LT pinmux */
configure_module_pin_mux(mii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux);