diff options
author | Tom Rini <trini@konsulko.com> | 2020-12-28 07:44:03 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-12-28 07:44:03 -0500 |
commit | ab865a8ee5c1a069f72a171270c02c99ccda7bfa (patch) | |
tree | b4ac4a8519bc0128f12de2a13a8311c0f845f5b5 /board/variscite/dart_6ul/dart_6ul.c | |
parent | 1c3d1aa00617dbbdd92f0d5a2df40d7784dfcc13 (diff) | |
parent | 26c7048dd9d04158a23e9dbfe3f0dccc4febcaed (diff) |
Merge tag 'u-boot-imx-20201227' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
Fixes for 2021.1
----------------
CI: https://gitlab.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/5680
- fixes for Variscite dart6ul
- imx8mp : increase malloc area
- fixes for bx50v3
- imx8m: HS400ES and UHS for EVK
- imx8qm-rom7720: fix phy bind
Diffstat (limited to 'board/variscite/dart_6ul/dart_6ul.c')
-rw-r--r-- | board/variscite/dart_6ul/dart_6ul.c | 104 |
1 files changed, 103 insertions, 1 deletions
diff --git a/board/variscite/dart_6ul/dart_6ul.c b/board/variscite/dart_6ul/dart_6ul.c index d8e383d323..360be758bb 100644 --- a/board/variscite/dart_6ul/dart_6ul.c +++ b/board/variscite/dart_6ul/dart_6ul.c @@ -12,8 +12,11 @@ #include <asm/arch/sys_proto.h> #include <asm/mach-imx/iomux-v3.h> #include <asm/mach-imx/mxc_i2c.h> +#include <dm.h> #include <fsl_esdhc_imx.h> +#include <i2c_eeprom.h> #include <linux/bitops.h> +#include <malloc.h> #include <miiphy.h> #include <netdev.h> #include <usb.h> @@ -222,9 +225,108 @@ int board_init(void) return 0; } +/* length of strings stored in the eeprom */ +#define DART6UL_PN_LEN 16 +#define DART6UL_ASSY_LEN 16 +#define DART6UL_DATE_LEN 12 + +/* eeprom content, 512 bytes */ +struct dart6ul_info { + u32 magic; + u8 partnumber[DART6UL_PN_LEN]; + u8 assy[DART6UL_ASSY_LEN]; + u8 date[DART6UL_DATE_LEN]; + u32 custom_addr_val[32]; + struct cmd { + u8 addr; + u8 index; + } custom_cmd[150]; + u8 res[33]; + u8 som_info; + u8 ddr_size; + u8 crc; +} __attribute__ ((__packed__)); + +#define DART6UL_INFO_STORAGE_GET(n) ((n) & 0x3) +#define DART6UL_INFO_WIFI_GET(n) ((n) >> 2 & 0x1) +#define DART6UL_INFO_REV_GET(n) ((n) >> 3 & 0x3) +#define DART6UL_DDRSIZE_IN_MIB(n) ((n) << 8) +#define DART6UL_INFO_MAGIC 0x32524156 + +static const char *som_info_storage_to_str(u8 som_info) +{ + switch (DART6UL_INFO_STORAGE_GET(som_info)) { + case 0x0: return "none (SD only)"; + case 0x1: return "NAND"; + case 0x2: return "eMMC"; + default: return "unknown"; + } +} + +static const char *som_info_rev_to_str(u8 som_info) +{ + switch (DART6UL_INFO_REV_GET(som_info)) { + case 0x0: return "2.4G"; + case 0x1: return "5G"; + default: return "unknown"; + } +} + int checkboard(void) { - puts("Board: Variscite DART-6UL Evaluation Kit\n"); + const char *path = "eeprom0"; + struct dart6ul_info *info; + struct udevice *dev; + int ret, off; + + off = fdt_path_offset(gd->fdt_blob, path); + if (off < 0) { + printf("%s: fdt_path_offset() failed: %d\n", __func__, off); + return off; + } + + ret = uclass_get_device_by_of_offset(UCLASS_I2C_EEPROM, off, &dev); + if (ret) { + printf("%s: uclass_get_device_by_of_offset() failed: %d\n", __func__, ret); + return ret; + } + + info = malloc(sizeof(struct dart6ul_info)); + if (!info) + return -ENOMEM; + + ret = i2c_eeprom_read(dev, 0, (uint8_t *)info, + sizeof(struct dart6ul_info)); + if (ret) { + printf("%s: i2c_eeprom_read() failed: %d\n", __func__, ret); + free(info); + return ret; + } + + if (info->magic != DART6UL_INFO_MAGIC) { + printf("Board: Invalid board info magic: 0x%08x, expected 0x%08x\n", + info->magic, DART6UL_INFO_MAGIC); + /* do not fail if the content is invalid */ + free(info); + return 0; + } + + /* make sure strings are null terminated */ + info->partnumber[DART6UL_PN_LEN - 1] = '\0'; + info->assy[DART6UL_ASSY_LEN - 1] = '\0'; + info->date[DART6UL_DATE_LEN - 1] = '\0'; + + printf("Board: PN: %s, Assy: %s, Date: %s\n" + " Storage: %s, Wifi: %s, DDR: %d MiB, Rev: %s\n", + info->partnumber, + info->assy, + info->date, + som_info_storage_to_str(info->som_info), + DART6UL_INFO_WIFI_GET(info->som_info) ? "yes" : "no", + DART6UL_DDRSIZE_IN_MIB(info->ddr_size), + som_info_rev_to_str(info->som_info)); + + free(info); return 0; } |