* [PATCH 1/2] arm: dart6ul: change compatible string for eeprom @ 2020-12-22 19:24 ferlandm at amotus.ca 2020-12-22 19:24 ` [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup ferlandm at amotus.ca ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: ferlandm at amotus.ca @ 2020-12-22 19:24 UTC (permalink / raw) To: u-boot From: Marc Ferland <ferlandm@amotus.ca> The eeprom at address 0x50 is a BR24G04NUX-3TTR. It has a 4Kbit (512x8) capacity, change the compatible string to reflect this fact. Also, add an alias to easily refer to this eeprom with fdt_path_offset() which will be in another commit. Signed-off-by: Marc Ferland <ferlandm@amotus.ca> --- arch/arm/dts/imx6ull-dart-6ul.dtsi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/imx6ull-dart-6ul.dtsi b/arch/arm/dts/imx6ull-dart-6ul.dtsi index e96669f493..fed40b0109 100644 --- a/arch/arm/dts/imx6ull-dart-6ul.dtsi +++ b/arch/arm/dts/imx6ull-dart-6ul.dtsi @@ -14,6 +14,10 @@ chosen { stdout-path = &uart1; }; + + aliases { + eeprom0 = &eeprom_som; + }; }; &fec1 { @@ -97,9 +101,10 @@ sda-gpios = <&gpio1 31 GPIO_ACTIVE_HIGH>; status = "okay"; - eeprom at 50 { - compatible = "cat,24c32"; + eeprom_som: eeprom at 50 { + compatible = "atmel,24c04"; reg = <0x50>; + status = "okay"; }; }; -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup 2020-12-22 19:24 [PATCH 1/2] arm: dart6ul: change compatible string for eeprom ferlandm at amotus.ca @ 2020-12-22 19:24 ` ferlandm at amotus.ca 2020-12-26 3:10 ` Fabio Estevam 2020-12-26 15:53 ` sbabic at denx.de 2020-12-26 3:10 ` [PATCH 1/2] arm: dart6ul: change compatible string for eeprom Fabio Estevam 2020-12-26 15:53 ` sbabic at denx.de 2 siblings, 2 replies; 6+ messages in thread From: ferlandm at amotus.ca @ 2020-12-22 19:24 UTC (permalink / raw) To: u-boot From: Marc Ferland <ferlandm@amotus.ca> The dart6ul has an i2c eeprom at 0x50 which contains, among other things, the manufacturing/revision/options info of the SoM. This patch replaces the current checkboard() implementation with a more exhaustive one based on the content of the eeprom. Since this code uses the new driver model, some changes were also required in the DTS to make the nodes related to i2c available before relocation. This code was inspired from the supported u-boot code from Variscite which can be found here: https://github.com/varigit/uboot-imx/tree/imx_v2018.03_4.14.78_1.0.0_ga_var02 New output example: Board: PN: VSM-6UL-705B, Assy: AS1812142257, Date: 2019 Feb 17 Storage: eMMC, Wifi: yes, DDR: 1024 MiB, Rev: 2.4G Signed-off-by: Marc Ferland <ferlandm@amotus.ca> --- arch/arm/dts/imx6ull-dart-6ul.dtsi | 8 +++ board/variscite/dart_6ul/dart_6ul.c | 104 +++++++++++++++++++++++++++- configs/variscite_dart6ul_defconfig | 2 + 3 files changed, 113 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/imx6ull-dart-6ul.dtsi b/arch/arm/dts/imx6ull-dart-6ul.dtsi index fed40b0109..805a382da9 100644 --- a/arch/arm/dts/imx6ull-dart-6ul.dtsi +++ b/arch/arm/dts/imx6ull-dart-6ul.dtsi @@ -56,6 +56,10 @@ }; }; +&gpio1 { + u-boot,dm-pre-reloc; +}; + &gpmi { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_gpmi_nand>; @@ -100,8 +104,10 @@ scl-gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>; sda-gpios = <&gpio1 31 GPIO_ACTIVE_HIGH>; status = "okay"; + u-boot,dm-pre-reloc; eeprom_som: eeprom at 50 { + u-boot,dm-pre-reloc; compatible = "atmel,24c04"; reg = <0x50>; status = "okay"; @@ -210,6 +216,7 @@ }; pinctrl_i2c2: i2cgrp { + u-boot,dm-pre-reloc; fsl,pins = < MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0 MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0 @@ -217,6 +224,7 @@ }; pinctrl_i2c2_gpio: i2c2grp_gpio { + u-boot,dm-pre-reloc; fsl,pins = < MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 0x1b8b0 MX6UL_PAD_UART5_RX_DATA__GPIO1_IO31 0x1b8b0 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; } diff --git a/configs/variscite_dart6ul_defconfig b/configs/variscite_dart6ul_defconfig index 5f94cea5dd..721882567d 100644 --- a/configs/variscite_dart6ul_defconfig +++ b/configs/variscite_dart6ul_defconfig @@ -36,6 +36,8 @@ CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM_I2C_GPIO=y CONFIG_SYS_I2C_MXC=y +CONFIG_MISC=y +CONFIG_I2C_EEPROM=y CONFIG_FSL_USDHC=y CONFIG_MTD=y CONFIG_PHYLIB=y -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup 2020-12-22 19:24 ` [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup ferlandm at amotus.ca @ 2020-12-26 3:10 ` Fabio Estevam 2020-12-26 15:53 ` sbabic at denx.de 1 sibling, 0 replies; 6+ messages in thread From: Fabio Estevam @ 2020-12-26 3:10 UTC (permalink / raw) To: u-boot On Tue, Dec 22, 2020 at 4:58 PM <ferlandm@amotus.ca> wrote: > > From: Marc Ferland <ferlandm@amotus.ca> > > The dart6ul has an i2c eeprom at 0x50 which contains, among other > things, the manufacturing/revision/options info of the SoM. This patch > replaces the current checkboard() implementation with a more > exhaustive one based on the content of the eeprom. > > Since this code uses the new driver model, some changes were also > required in the DTS to make the nodes related to i2c available before > relocation. > > This code was inspired from the supported u-boot code from Variscite > which can be found here: > > https://github.com/varigit/uboot-imx/tree/imx_v2018.03_4.14.78_1.0.0_ga_var02 > > New output example: > > Board: PN: VSM-6UL-705B, Assy: AS1812142257, Date: 2019 Feb 17 > Storage: eMMC, Wifi: yes, DDR: 1024 MiB, Rev: 2.4G > > Signed-off-by: Marc Ferland <ferlandm@amotus.ca> Reviewed-by: Fabio Estevam <festevam@gmail.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup 2020-12-22 19:24 ` [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup ferlandm at amotus.ca 2020-12-26 3:10 ` Fabio Estevam @ 2020-12-26 15:53 ` sbabic at denx.de 1 sibling, 0 replies; 6+ messages in thread From: sbabic at denx.de @ 2020-12-26 15:53 UTC (permalink / raw) To: u-boot > From: Marc Ferland <ferlandm@amotus.ca> > The dart6ul has an i2c eeprom at 0x50 which contains, among other > things, the manufacturing/revision/options info of the SoM. This patch > replaces the current checkboard() implementation with a more > exhaustive one based on the content of the eeprom. > Since this code uses the new driver model, some changes were also > required in the DTS to make the nodes related to i2c available before > relocation. > This code was inspired from the supported u-boot code from Variscite > which can be found here: > https://github.com/varigit/uboot-imx/tree/imx_v2018.03_4.14.78_1.0.0_ga_var02 > New output example: > Board: PN: VSM-6UL-705B, Assy: AS1812142257, Date: 2019 Feb 17 > Storage: eMMC, Wifi: yes, DDR: 1024 MiB, Rev: 2.4G > Signed-off-by: Marc Ferland <ferlandm@amotus.ca> > Reviewed-by: Fabio Estevam <festevam@gmail.com> Applied to u-boot-imx, master, thanks ! Best regards, Stefano Babic -- ===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de ===================================================================== ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] arm: dart6ul: change compatible string for eeprom 2020-12-22 19:24 [PATCH 1/2] arm: dart6ul: change compatible string for eeprom ferlandm at amotus.ca 2020-12-22 19:24 ` [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup ferlandm at amotus.ca @ 2020-12-26 3:10 ` Fabio Estevam 2020-12-26 15:53 ` sbabic at denx.de 2 siblings, 0 replies; 6+ messages in thread From: Fabio Estevam @ 2020-12-26 3:10 UTC (permalink / raw) To: u-boot On Tue, Dec 22, 2020 at 4:58 PM <ferlandm@amotus.ca> wrote: > > From: Marc Ferland <ferlandm@amotus.ca> > > The eeprom at address 0x50 is a BR24G04NUX-3TTR. It has a > 4Kbit (512x8) capacity, change the compatible string to reflect this > fact. > > Also, add an alias to easily refer to this eeprom with > fdt_path_offset() which will be in another commit. > > Signed-off-by: Marc Ferland <ferlandm@amotus.ca> Reviewed-by: Fabio Estevam <festevam@gmail.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] arm: dart6ul: change compatible string for eeprom 2020-12-22 19:24 [PATCH 1/2] arm: dart6ul: change compatible string for eeprom ferlandm at amotus.ca 2020-12-22 19:24 ` [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup ferlandm at amotus.ca 2020-12-26 3:10 ` [PATCH 1/2] arm: dart6ul: change compatible string for eeprom Fabio Estevam @ 2020-12-26 15:53 ` sbabic at denx.de 2 siblings, 0 replies; 6+ messages in thread From: sbabic at denx.de @ 2020-12-26 15:53 UTC (permalink / raw) To: u-boot > From: Marc Ferland <ferlandm@amotus.ca> > The eeprom at address 0x50 is a BR24G04NUX-3TTR. It has a > 4Kbit (512x8) capacity, change the compatible string to reflect this > fact. > Also, add an alias to easily refer to this eeprom with > fdt_path_offset() which will be in another commit. > Signed-off-by: Marc Ferland <ferlandm@amotus.ca> > Reviewed-by: Fabio Estevam <festevam@gmail.com> Applied to u-boot-imx, master, thanks ! Best regards, Stefano Babic -- ===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de ===================================================================== ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-26 15:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-22 19:24 [PATCH 1/2] arm: dart6ul: change compatible string for eeprom ferlandm at amotus.ca 2020-12-22 19:24 ` [PATCH 2/2] arm: dart6ul: read and print SoM info from eeprom on startup ferlandm at amotus.ca 2020-12-26 3:10 ` Fabio Estevam 2020-12-26 15:53 ` sbabic at denx.de 2020-12-26 3:10 ` [PATCH 1/2] arm: dart6ul: change compatible string for eeprom Fabio Estevam 2020-12-26 15:53 ` sbabic at denx.de
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.