diff options
author | Caleb Robey | 2019-12-13 12:50:04 -0600 |
---|---|---|
committer | Jacob Stiffler | 2019-12-16 11:48:31 -0600 |
commit | a2ab3d87a8259005dc508313697609c8bae8016d (patch) | |
tree | 1e9c02b5e87048fb1cc92ad53c00c784972d66d4 | |
parent | 3d47908c16f4930796b08779bb19dec0480bd85d (diff) | |
download | processor-sdk-u-boot-a2ab3d87a8259005dc508313697609c8bae8016d.tar.gz processor-sdk-u-boot-a2ab3d87a8259005dc508313697609c8bae8016d.tar.xz processor-sdk-u-boot-a2ab3d87a8259005dc508313697609c8bae8016d.zip |
board: ti: beagleboneai: emmc read changes
BeagleBoard.org BeagleBone AI rev A1 does not include a board
identifier I2C EEPROM due to a design oversight. These boards have
been put into production and are generally available now.
The board identifier information, however, has been included in the
second eMMC linear boot partition (/dev/mmcblk1boot1).
This patch works by:
* First, looking for a board identifier I2C EEPROM and if not found,
* Then seeing if the boot mode matches BeagleBone AI with eMMC in the
boot chain to make sure we don't enable eMMC pinmuxes on boards
that don't support it, and
* Finally, initializes the eMMC pins and reading the header.
Signed-off-by: Jason Kridner <jdk@ti.com>
Signed-off-by: Caleb Robey <c-robey@ti.com>
Cc: Robert Nelson <robertcnelson@gmail.com>
Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
-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 302b69ecf7..e883c93cdf 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <palmas.h> | 11 | #include <palmas.h> |
12 | #include <sata.h> | 12 | #include <sata.h> |
13 | #include <usb.h> | 13 | #include <usb.h> |
14 | #include <errno.h> | ||
14 | #include <asm/omap_common.h> | 15 | #include <asm/omap_common.h> |
15 | #include <asm/omap_sec_common.h> | 16 | #include <asm/omap_sec_common.h> |
16 | #include <asm/emif.h> | 17 | #include <asm/emif.h> |
@@ -35,6 +36,10 @@ | |||
35 | #include "../common/board_detect.h" | 36 | #include "../common/board_detect.h" |
36 | #include "mux_data.h" | 37 | #include "mux_data.h" |
37 | 38 | ||
39 | #ifdef CONFIG_SUPPORT_EMMC_BOOT | ||
40 | static int board_bootmode_has_emmc(void); | ||
41 | #endif | ||
42 | |||
38 | #define board_is_x15() board_ti_is("BBRDX15_") | 43 | #define board_is_x15() board_ti_is("BBRDX15_") |
39 | #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \ | 44 | #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \ |
40 | !strncmp("B.10", board_ti_get_rev(), 3)) | 45 | !strncmp("B.10", board_ti_get_rev(), 3)) |
@@ -505,6 +510,14 @@ void do_board_detect(void) | |||
505 | CONFIG_EEPROM_CHIP_ADDRESS); | 510 | CONFIG_EEPROM_CHIP_ADDRESS); |
506 | if (rc) | 511 | if (rc) |
507 | printf("ti_i2c_eeprom_init failed %d\n", rc); | 512 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
513 | |||
514 | #ifdef CONFIG_SUPPORT_EMMC_BOOT | ||
515 | rc = board_bootmode_has_emmc(); | ||
516 | if (!rc) | ||
517 | rc = ti_emmc_boardid_get(); | ||
518 | if (rc) | ||
519 | printf("ti_emmc_boardid_get failed %d\n", rc); | ||
520 | #endif | ||
508 | } | 521 | } |
509 | 522 | ||
510 | #else /* CONFIG_SPL_BUILD */ | 523 | #else /* CONFIG_SPL_BUILD */ |
@@ -520,6 +533,14 @@ void do_board_detect(void) | |||
520 | if (rc) | 533 | if (rc) |
521 | printf("ti_i2c_eeprom_init failed %d\n", rc); | 534 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
522 | 535 | ||
536 | #ifdef CONFIG_SUPPORT_EMMC_BOOT | ||
537 | rc = board_bootmode_has_emmc(); | ||
538 | if (!rc) | ||
539 | rc = ti_emmc_boardid_get(); | ||
540 | if (rc) | ||
541 | printf("ti_emmc_boardid_get failed %d\n", rc); | ||
542 | #endif | ||
543 | |||
523 | if (board_is_x15()) | 544 | if (board_is_x15()) |
524 | bname = "BeagleBoard X15"; | 545 | bname = "BeagleBoard X15"; |
525 | else if (board_is_am572x_evm()) | 546 | else if (board_is_am572x_evm()) |
@@ -754,6 +775,11 @@ void set_muxconf_regs(void) | |||
754 | { | 775 | { |
755 | do_set_mux32((*ctrl)->control_padconf_core_base, | 776 | do_set_mux32((*ctrl)->control_padconf_core_base, |
756 | early_padconf, ARRAY_SIZE(early_padconf)); | 777 | early_padconf, ARRAY_SIZE(early_padconf)); |
778 | |||
779 | #ifdef CONFIG_SUPPORT_EMMC_BOOT | ||
780 | do_set_mux32((*ctrl)->control_padconf_core_base, | ||
781 | emmc_padconf, ARRAY_SIZE(emmc_padconf)); | ||
782 | #endif | ||
757 | } | 783 | } |
758 | 784 | ||
759 | #ifdef CONFIG_IODELAY_RECALIBRATION | 785 | #ifdef CONFIG_IODELAY_RECALIBRATION |
@@ -1113,6 +1139,17 @@ int board_fit_config_name_match(const char *name) | |||
1113 | } | 1139 | } |
1114 | #endif | 1140 | #endif |
1115 | 1141 | ||
1142 | #ifdef CONFIG_SUPPORT_EMMC_BOOT | ||
1143 | static int board_bootmode_has_emmc(void) | ||
1144 | { | ||
1145 | /* Check that boot mode is same as BBAI */ | ||
1146 | if (gd->arch.omap_boot_mode != 2) | ||
1147 | return -EIO; | ||
1148 | |||
1149 | return 0; | ||
1150 | } | ||
1151 | #endif | ||
1152 | |||
1116 | #ifdef CONFIG_TI_SECURE_DEVICE | 1153 | #ifdef CONFIG_TI_SECURE_DEVICE |
1117 | void board_fit_image_post_process(void **p_image, size_t *p_size) | 1154 | void board_fit_image_post_process(void **p_image, size_t *p_size) |
1118 | { | 1155 | { |
diff --git a/board/ti/am57xx/mux_data.h b/board/ti/am57xx/mux_data.h index d4a15ae93d..2e739dec1c 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[] = { | |||
1000 | {I2C1_SCL, (PIN_INPUT_PULLUP | M0)}, /* I2C1_SCL */ | 1000 | {I2C1_SCL, (PIN_INPUT_PULLUP | M0)}, /* I2C1_SCL */ |
1001 | }; | 1001 | }; |
1002 | 1002 | ||
1003 | #ifdef CONFIG_SUPPORT_EMMC_BOOT | ||
1004 | const struct pad_conf_entry emmc_padconf[] = { | ||
1005 | {GPMC_A19, (M1 | PIN_INPUT_PULLUP)}, /* K7: gpmc_a19.mmc2_dat4 */ | ||
1006 | {GPMC_A20, (M1 | PIN_INPUT_PULLUP)}, /* M7: gpmc_a20.mmc2_dat5 */ | ||
1007 | {GPMC_A21, (M1 | PIN_INPUT_PULLUP)}, /* J5: gpmc_a21.mmc2_dat6 */ | ||
1008 | {GPMC_A22, (M1 | PIN_INPUT_PULLUP)}, /* K6: gpmc_a22.mmc2_dat7 */ | ||
1009 | {GPMC_A23, (M1 | PIN_INPUT_PULLUP)}, /* J7: gpmc_a23.mmc2_clk */ | ||
1010 | {GPMC_A24, (M1 | PIN_INPUT_PULLUP)}, /* J4: gpmc_a24.mmc2_dat0 */ | ||
1011 | {GPMC_A25, (M1 | PIN_INPUT_PULLUP)}, /* J6: gpmc_a25.mmc2_dat1 */ | ||
1012 | {GPMC_A26, (M1 | PIN_INPUT_PULLUP)}, /* H4: gpmc_a26.mmc2_dat2 */ | ||
1013 | {GPMC_A27, (M1 | PIN_INPUT_PULLUP)}, /* H5: gpmc_a27.mmc2_dat3 */ | ||
1014 | {GPMC_CS1, (M1 | PIN_INPUT_PULLUP)}, /* H6: gpmc_cs1.mmc2_cmd */ | ||
1015 | {MCASP1_AXR5, (M14 | PIN_OUTPUT_PULLUP)}, /* F13: eMMC_RSTn (missing on schematic): mcasp1_axr5.gpio5_7 */ | ||
1016 | }; | ||
1017 | #endif | ||
1018 | |||
1003 | #ifdef CONFIG_IODELAY_RECALIBRATION | 1019 | #ifdef CONFIG_IODELAY_RECALIBRATION |
1004 | const struct iodelay_cfg_entry iodelay_cfg_array_x15_sr1_1[] = { | 1020 | const struct iodelay_cfg_entry iodelay_cfg_array_x15_sr1_1[] = { |
1005 | {0x0114, 2980, 0}, /* CFG_GPMC_A0_IN */ | 1021 | {0x0114, 2980, 0}, /* CFG_GPMC_A0_IN */ |
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c index 87aae76d6b..e150d231c8 100644 --- a/board/ti/common/board_detect.c +++ b/board/ti/common/board_detect.c | |||
@@ -12,6 +12,9 @@ | |||
12 | #include <asm/omap_common.h> | 12 | #include <asm/omap_common.h> |
13 | #include <dm/uclass.h> | 13 | #include <dm/uclass.h> |
14 | #include <i2c.h> | 14 | #include <i2c.h> |
15 | #include <mmc.h> | ||
16 | #include <errno.h> | ||
17 | #include <malloc.h> | ||
15 | 18 | ||
16 | #include "board_detect.h" | 19 | #include "board_detect.h" |
17 | 20 | ||
@@ -239,6 +242,79 @@ int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr) | |||
239 | return 0; | 242 | return 0; |
240 | } | 243 | } |
241 | 244 | ||
245 | int __maybe_unused ti_emmc_boardid_get(void) | ||
246 | { | ||
247 | int rc; | ||
248 | struct udevice *dev; | ||
249 | struct mmc *mmc; | ||
250 | struct ti_common_eeprom *ep; | ||
251 | struct ti_am_eeprom brdid; | ||
252 | struct blk_desc *bdesc; | ||
253 | uchar *buffer; | ||
254 | |||
255 | ep = TI_EEPROM_DATA; | ||
256 | if (ep->header == TI_EEPROM_HEADER_MAGIC) | ||
257 | return 0; /* EEPROM has already been read */ | ||
258 | |||
259 | /* Initialize with a known bad marker for emmc fails.. */ | ||
260 | ep->header = TI_DEAD_EEPROM_MAGIC; | ||
261 | ep->name[0] = 0x0; | ||
262 | ep->version[0] = 0x0; | ||
263 | ep->serial[0] = 0x0; | ||
264 | ep->config[0] = 0x0; | ||
265 | |||
266 | /* uclass object initialization */ | ||
267 | rc = mmc_initialize(NULL); | ||
268 | if (rc) | ||
269 | return rc; | ||
270 | |||
271 | /* Set device to /dev/mmcblk1 */ | ||
272 | rc = uclass_get_device(UCLASS_MMC, 1, &dev); | ||
273 | if (rc) | ||
274 | return rc; | ||
275 | |||
276 | /* Grab the mmc device */ | ||
277 | mmc = mmc_get_mmc_dev(dev); | ||
278 | if (!mmc) | ||
279 | return -ENODEV; | ||
280 | |||
281 | /* mmc hardware initialization routine */ | ||
282 | mmc_init(mmc); | ||
283 | |||
284 | /* Set partition to /dev/mmcblk1boot1 */ | ||
285 | rc = mmc_switch_part(mmc, 2); | ||
286 | if (rc) | ||
287 | return rc; | ||
288 | |||
289 | buffer = malloc(mmc->read_bl_len); | ||
290 | if (!buffer) | ||
291 | return -ENOMEM; | ||
292 | |||
293 | bdesc = mmc_get_blk_desc(mmc); | ||
294 | |||
295 | /* blk_dread returns the number of blocks read*/ | ||
296 | if (blk_dread(bdesc, 0L, 1, buffer) != 1) { | ||
297 | rc = -EIO; | ||
298 | goto cleanup; | ||
299 | } | ||
300 | |||
301 | memcpy(&brdid, buffer, sizeof(brdid)); | ||
302 | |||
303 | /* Write out the ep struct values */ | ||
304 | ep->header = brdid.header; | ||
305 | strlcpy(ep->name, brdid.name, TI_EEPROM_HDR_NAME_LEN + 1); | ||
306 | ti_eeprom_string_cleanup(ep->name); | ||
307 | strlcpy(ep->version, brdid.version, TI_EEPROM_HDR_REV_LEN + 1); | ||
308 | ti_eeprom_string_cleanup(ep->version); | ||
309 | strlcpy(ep->serial, brdid.serial, TI_EEPROM_HDR_SERIAL_LEN + 1); | ||
310 | ti_eeprom_string_cleanup(ep->serial); | ||
311 | |||
312 | cleanup: | ||
313 | free(buffer); | ||
314 | |||
315 | return rc; | ||
316 | } | ||
317 | |||
242 | int __maybe_unused ti_i2c_eeprom_dra7_get(int bus_addr, int dev_addr) | 318 | int __maybe_unused ti_i2c_eeprom_dra7_get(int bus_addr, int dev_addr) |
243 | { | 319 | { |
244 | int rc, offset = 0; | 320 | int rc, offset = 0; |
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h index 52f0eb2070..5835af5344 100644 --- a/board/ti/common/board_detect.h +++ b/board/ti/common/board_detect.h | |||
@@ -268,6 +268,15 @@ struct ti_am6_eeprom { | |||
268 | int ti_i2c_eeprom_am_get(int bus_addr, int dev_addr); | 268 | int ti_i2c_eeprom_am_get(int bus_addr, int dev_addr); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | * ti_emmc_boardid_get() - Fetch board ID information from eMMC | ||
272 | * | ||
273 | * ep in SRAM is populated by the this function that is currently | ||
274 | * based on BeagleBone AI, but could be made more general across AM* | ||
275 | * platforms. | ||
276 | */ | ||
277 | int __maybe_unused ti_emmc_boardid_get(void); | ||
278 | |||
279 | /** | ||
271 | * ti_i2c_eeprom_dra7_get() - Consolidated eeprom data for DRA7 TI EVMs | 280 | * ti_i2c_eeprom_dra7_get() - Consolidated eeprom data for DRA7 TI EVMs |
272 | * @bus_addr: I2C bus address | 281 | * @bus_addr: I2C bus address |
273 | * @dev_addr: I2C slave address | 282 | * @dev_addr: I2C slave address |