diff options
| -rw-r--r-- | board/ti/am57xx/board.c | 37 | ||||
| -rw-r--r-- | board/ti/am57xx/mux_data.h | 16 | ||||
| -rw-r--r-- | board/ti/common/board_detect.c | 76 | ||||
| -rw-r--r-- | board/ti/common/board_detect.h | 9 | 
4 files changed, 138 insertions, 0 deletions
| diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index c755821b74f..52f5e954e69 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -14,6 +14,7 @@  #include <sata.h>  #include <serial.h>  #include <usb.h> +#include <errno.h>  #include <asm/omap_common.h>  #include <asm/omap_sec_common.h>  #include <asm/emif.h> @@ -37,6 +38,10 @@  #include "../common/board_detect.h"  #include "mux_data.h" +#ifdef CONFIG_SUPPORT_EMMC_BOOT +static int board_bootmode_has_emmc(void); +#endif +  #define board_is_x15()		board_ti_is("BBRDX15_")  #define board_is_x15_revb1()	(board_ti_is("BBRDX15_") && \  				 !strncmp("B.10", board_ti_get_rev(), 3)) @@ -507,6 +512,14 @@ void do_board_detect(void)  				  CONFIG_EEPROM_CHIP_ADDRESS);  	if (rc)  		printf("ti_i2c_eeprom_init failed %d\n", rc); + +#ifdef CONFIG_SUPPORT_EMMC_BOOT +	rc = board_bootmode_has_emmc(); +	if (!rc) +		rc = ti_emmc_boardid_get(); +	if (rc) +		printf("ti_emmc_boardid_get failed %d\n", rc); +#endif  }  #else	/* CONFIG_SPL_BUILD */ @@ -522,6 +535,14 @@ void do_board_detect(void)  	if (rc)  		printf("ti_i2c_eeprom_init failed %d\n", rc); +#ifdef CONFIG_SUPPORT_EMMC_BOOT +	rc = board_bootmode_has_emmc(); +	if (!rc) +		rc = ti_emmc_boardid_get(); +	if (rc) +		printf("ti_emmc_boardid_get failed %d\n", rc); +#endif +  	if (board_is_x15())  		bname = "BeagleBoard X15";  	else if (board_is_am572x_evm()) @@ -744,6 +765,11 @@ void set_muxconf_regs(void)  {  	do_set_mux32((*ctrl)->control_padconf_core_base,  		     early_padconf, ARRAY_SIZE(early_padconf)); + +#ifdef CONFIG_SUPPORT_EMMC_BOOT +	do_set_mux32((*ctrl)->control_padconf_core_base, +		     emmc_padconf, ARRAY_SIZE(emmc_padconf)); +#endif  }  #ifdef CONFIG_IODELAY_RECALIBRATION @@ -1113,6 +1139,17 @@ int fastboot_set_reboot_flag(void)  }  #endif +#ifdef CONFIG_SUPPORT_EMMC_BOOT +static int board_bootmode_has_emmc(void) +{ +	/* Check that boot mode is same as BBAI */ +	if (gd->arch.omap_boot_mode != 2) +		return -EIO; + +	return 0; +} +#endif +  #ifdef CONFIG_TI_SECURE_DEVICE  void board_fit_image_post_process(void **p_image, size_t *p_size)  { diff --git a/board/ti/am57xx/mux_data.h b/board/ti/am57xx/mux_data.h index d4a15ae93d7..51df977817e 100644 --- a/board/ti/am57xx/mux_data.h +++ b/board/ti/am57xx/mux_data.h @@ -1000,6 +1000,22 @@ const struct pad_conf_entry early_padconf[] = {  	{I2C1_SCL, (PIN_INPUT_PULLUP | M0)},	/* I2C1_SCL */  }; +#ifdef CONFIG_SUPPORT_EMMC_BOOT +const struct pad_conf_entry emmc_padconf[] = { +	{GPMC_A19, (M1 | PIN_INPUT_PULLUP)},		    /*  K7: gpmc_a19.mmc2_dat4 */ +	{GPMC_A20, (M1 | PIN_INPUT_PULLUP)},		    /*  M7: gpmc_a20.mmc2_dat5 */ +	{GPMC_A21, (M1 | PIN_INPUT_PULLUP)},		    /*  J5: gpmc_a21.mmc2_dat6 */ +	{GPMC_A22, (M1 | PIN_INPUT_PULLUP)},		    /*  K6: gpmc_a22.mmc2_dat7 */ +	{GPMC_A23, (M1 | PIN_INPUT_PULLUP)},		    /*  J7: gpmc_a23.mmc2_clk */ +	{GPMC_A24, (M1 | PIN_INPUT_PULLUP)},		    /*  J4: gpmc_a24.mmc2_dat0 */ +	{GPMC_A25, (M1 | PIN_INPUT_PULLUP)},		    /*  J6: gpmc_a25.mmc2_dat1 */ +	{GPMC_A26, (M1 | PIN_INPUT_PULLUP)},		    /*  H4: gpmc_a26.mmc2_dat2 */ +	{GPMC_A27, (M1 | PIN_INPUT_PULLUP)},		    /*  H5: gpmc_a27.mmc2_dat3 */ +	{GPMC_CS1, (M1 | PIN_INPUT_PULLUP)},		    /*  H6: gpmc_cs1.mmc2_cmd */ +	{MCASP1_AXR5, (M14 | PIN_OUTPUT_PULLUP)},	       /* F13: eMMC_RSTn (missing on schematic): mcasp1_axr5.gpio5_7 */ +}; +#endif +  #ifdef CONFIG_IODELAY_RECALIBRATION  const struct iodelay_cfg_entry iodelay_cfg_array_x15_sr1_1[] = {  	{0x0114, 2980, 0},	/* CFG_GPMC_A0_IN */ diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c index 564d2f70460..59ec57062d7 100644 --- a/board/ti/common/board_detect.c +++ b/board/ti/common/board_detect.c @@ -14,6 +14,9 @@  #include <dm/uclass.h>  #include <env.h>  #include <i2c.h> +#include <mmc.h> +#include <errno.h> +#include <malloc.h>  #include "board_detect.h" @@ -171,6 +174,79 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,  	return 0;  } +int __maybe_unused ti_emmc_boardid_get(void) +{ +	int rc; +	struct udevice *dev; +	struct mmc *mmc; +	struct ti_common_eeprom *ep; +	struct ti_am_eeprom brdid; +	struct blk_desc *bdesc; +	uchar *buffer; + +	ep = TI_EEPROM_DATA; +	if (ep->header == TI_EEPROM_HEADER_MAGIC) +		return 0;       /* EEPROM has already been read */ + +	/* Initialize with a known bad marker for emmc fails.. */ +	ep->header = TI_DEAD_EEPROM_MAGIC; +	ep->name[0] = 0x0; +	ep->version[0] = 0x0; +	ep->serial[0] = 0x0; +	ep->config[0] = 0x0; + +	/* uclass object initialization */ +	rc = mmc_initialize(NULL); +	if (rc) +		return rc; + +	/* Set device to /dev/mmcblk1 */ +	rc = uclass_get_device(UCLASS_MMC, 1, &dev); +	if (rc) +		return rc; + +	/* Grab the mmc device */ +	mmc = mmc_get_mmc_dev(dev); +	if (!mmc) +		return -ENODEV; + +	/* mmc hardware initialization routine */ +	mmc_init(mmc); + +	/* Set partition to /dev/mmcblk1boot1 */ +	rc = mmc_switch_part(mmc, 2); +	if (rc) +		return rc; + +	buffer = malloc(mmc->read_bl_len); +	if (!buffer) +		return -ENOMEM; + +	bdesc = mmc_get_blk_desc(mmc); + +	/* blk_dread returns the number of blocks read*/ +	if (blk_dread(bdesc, 0L, 1, buffer) != 1) { +		rc = -EIO; +		goto cleanup; +	} + +	memcpy(&brdid, buffer, sizeof(brdid)); + +	/* Write out the ep struct values */ +	ep->header = brdid.header; +	strlcpy(ep->name, brdid.name, TI_EEPROM_HDR_NAME_LEN + 1); +	ti_eeprom_string_cleanup(ep->name); +	strlcpy(ep->version, brdid.version, TI_EEPROM_HDR_REV_LEN + 1); +	ti_eeprom_string_cleanup(ep->version); +	strlcpy(ep->serial, brdid.serial, TI_EEPROM_HDR_SERIAL_LEN + 1); +	ti_eeprom_string_cleanup(ep->serial); + +cleanup: +	free(buffer); + +	return rc; +} +  int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev)  {  	struct ti_common_eeprom *ep; diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h index a45d8961b9a..1a85b7fda96 100644 --- a/board/ti/common/board_detect.h +++ b/board/ti/common/board_detect.h @@ -268,6 +268,15 @@ struct ti_am6_eeprom {  int ti_i2c_eeprom_am_get(int bus_addr, int dev_addr);  /** + * ti_emmc_boardid_get() - Fetch board ID information from eMMC + * + * ep in SRAM is populated by the this function that is currently + * based on BeagleBone AI, but could be made more general across AM* + * platforms. + */ +int __maybe_unused ti_emmc_boardid_get(void); + +/**   * ti_i2c_eeprom_dra7_get() - Consolidated eeprom data for DRA7 TI EVMs   * @bus_addr:	I2C bus address   * @dev_addr:	I2C slave address | 
