* [PATCH v2 2/6] board: phytec: common: Add imx8m specific EEPROM detection support
2023-08-17 8:57 [PATCH v2 0/6] PHYTEC SoM detection for phyCORE-i.MX8MP Teresa Remmet
@ 2023-08-17 8:57 ` Teresa Remmet
2023-08-28 12:32 ` Yannic Moog
0 siblings, 1 reply; 3+ messages in thread
From: Teresa Remmet @ 2023-08-17 8:57 UTC (permalink / raw)
To: Stefano Babic, Fabio Estevam, NXP i . MX U-Boot Team
Cc: u-boot, upstream, Yannic Moog, Daniel Schultz, Wadim Egorov
Add imx8m specific detection part. Which includes checking the
EEPROM data for article number options.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
Changes in v2:
- remove blank line at EOF
- fix string conversion to integer
- fix typo s/revsions/revisions
---
board/phytec/common/Kconfig | 8 ++
board/phytec/common/Makefile | 1 +
board/phytec/common/imx8m_som_detection.c | 168 ++++++++++++++++++++++
board/phytec/common/imx8m_som_detection.h | 54 +++++++
4 files changed, 231 insertions(+)
create mode 100644 board/phytec/common/imx8m_som_detection.c
create mode 100644 board/phytec/common/imx8m_som_detection.h
diff --git a/board/phytec/common/Kconfig b/board/phytec/common/Kconfig
index d614d45b1d60..3b1c5aa0d02b 100644
--- a/board/phytec/common/Kconfig
+++ b/board/phytec/common/Kconfig
@@ -3,3 +3,11 @@ config PHYTEC_SOM_DETECTION
select SPL_CRC8 if SPL
help
Support of I2C EEPROM based SoM detection.
+
+config PHYTEC_IMX8M_SOM_DETECTION
+ bool "Support SoM detection for i.MX8M PHYTEC platforms"
+ depends on ARCH_IMX8M && PHYTEC_SOM_DETECTION
+ default y
+ help
+ Support of I2C EEPROM based SoM detection. Supported
+ for PHYTEC i.MX8MM/i.MX8MP boards
diff --git a/board/phytec/common/Makefile b/board/phytec/common/Makefile
index 5fe8725ef684..fe28964ce21c 100644
--- a/board/phytec/common/Makefile
+++ b/board/phytec/common/Makefile
@@ -8,3 +8,4 @@ obj- := __dummy__.o
endif
obj-$(CONFIG_PHYTEC_SOM_DETECTION) += phytec_som_detection.o
+obj-$(CONFIG_PHYTEC_IMX8M_SOM_DETECTION) += imx8m_som_detection.o
diff --git a/board/phytec/common/imx8m_som_detection.c b/board/phytec/common/imx8m_som_detection.c
new file mode 100644
index 000000000000..c6c96ed19cb3
--- /dev/null
+++ b/board/phytec/common/imx8m_som_detection.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2023 PHYTEC Messtechnik GmbH
+ * Author: Teresa Remmet <t.remmet@phytec.de>
+ */
+
+#include <common.h>
+#include <asm/arch/sys_proto.h>
+#include <dm/device.h>
+#include <dm/uclass.h>
+#include <i2c.h>
+#include <u-boot/crc.h>
+
+#include "imx8m_som_detection.h"
+
+extern struct phytec_eeprom_data eeprom_data;
+
+/* Check if the SoM is actually one of the following products:
+ * - i.MX8MM
+ * - i.MX8MN
+ * - i.MX8MP
+ * - i.MX8MQ
+ *
+ * Returns 0 in case it's a known SoM. Otherwise, returns -1.
+ */
+u8 __maybe_unused phytec_imx8m_detect(struct phytec_eeprom_data *data)
+{
+ char *opt;
+ u8 som;
+
+ /* We can not do the check for early API revisions */
+ if (data->api_rev < PHYTEC_API_REV2)
+ return -1;
+
+ if (!data)
+ data = &eeprom_data;
+
+ som = data->data.data_api2.som_no;
+ debug("%s: som id: %u\n", __func__, som);
+
+ opt = phytec_get_opt(data);
+ if (!opt)
+ return -1;
+
+ if (som == PHYTEC_IMX8MP_SOM && is_imx8mp())
+ return 0;
+
+ if (som == PHYTEC_IMX8MM_SOM) {
+ if ((PHYTEC_GET_OPTION(opt[0]) != 0) &&
+ (PHYTEC_GET_OPTION(opt[1]) == 0) && is_imx8mm())
+ return 0;
+ else if ((PHYTEC_GET_OPTION(opt[0]) == 0) &&
+ (PHYTEC_GET_OPTION(opt[1]) != 0) && is_imx8mn())
+ return 0;
+ }
+
+ if (som == PHYTEC_IMX8MQ_SOM && is_imx8mq())
+ return 0;
+
+ pr_err("%s: SoM ID does not match. Wrong EEPROM data?\n", __func__);
+ return -1;
+}
+
+/*
+ * All PHYTEC i.MX8M boards have RAM size definition at the
+ * same location.
+ */
+u8 __maybe_unused phytec_get_imx8m_ddr_size(struct phytec_eeprom_data *data)
+{
+ char *opt;
+ u8 ddr_id;
+
+ if (!data)
+ data = &eeprom_data;
+
+ opt = phytec_get_opt(data);
+ if (opt)
+ ddr_id = PHYTEC_GET_OPTION(opt[2]);
+ else
+ ddr_id = PHYTEC_EEPROM_INVAL;
+
+ debug("%s: ddr id: %u\n", __func__, ddr_id);
+ return ddr_id;
+}
+
+/*
+ * Filter SPI-NOR flash information. All i.MX8M boards have this at
+ * the same location.
+ * returns: 0x0 if no SPI is populated. Otherwise a board depended
+ * code for the size. PHYTEC_EEPROM_INVAL when the data is invalid.
+ */
+u8 __maybe_unused phytec_get_imx8m_spi(struct phytec_eeprom_data *data)
+{
+ char *opt;
+ u8 spi;
+
+ if (!data)
+ data = &eeprom_data;
+
+ if (data->api_rev < PHYTEC_API_REV2)
+ return PHYTEC_EEPROM_INVAL;
+
+ opt = phytec_get_opt(data);
+ if (opt)
+ spi = PHYTEC_GET_OPTION(opt[4]);
+ else
+ spi = PHYTEC_EEPROM_INVAL;
+
+ debug("%s: spi: %u\n", __func__, spi);
+ return spi;
+}
+
+/*
+ * Filter ethernet phy information. All i.MX8M boards have this at
+ * the same location.
+ * returns: 0x0 if no ethernet phy is populated. 0x1 if it is populated.
+ * PHYTEC_EEPROM_INVAL when the data is invalid.
+ */
+u8 __maybe_unused phytec_get_imx8m_eth(struct phytec_eeprom_data *data)
+{
+ char *opt;
+ u8 eth;
+
+ if (!data)
+ data = &eeprom_data;
+
+ if (data->api_rev < PHYTEC_API_REV2)
+ return PHYTEC_EEPROM_INVAL;
+
+ opt = phytec_get_opt(data);
+ if (opt) {
+ eth = PHYTEC_GET_OPTION(opt[5]);
+ eth &= 0x1;
+ } else {
+ eth = PHYTEC_EEPROM_INVAL;
+ }
+
+ debug("%s: eth: %u\n", __func__, eth);
+ return eth;
+}
+
+/*
+ * Filter RTC information for phyCORE-i.MX8MP.
+ * returns: 0 if no RTC is populated. 1 if it is populated.
+ * PHYTEC_EEPROM_INVAL when the data is invalid.
+ */
+u8 __maybe_unused phytec_get_imx8mp_rtc(struct phytec_eeprom_data *data)
+{
+ char *opt;
+ u8 rtc;
+
+ if (!data)
+ data = &eeprom_data;
+
+ if (data->api_rev < PHYTEC_API_REV2)
+ return PHYTEC_EEPROM_INVAL;
+
+ opt = phytec_get_opt(data);
+ if (opt) {
+ rtc = PHYTEC_GET_OPTION(opt[5]);
+ rtc &= 0x4;
+ rtc = !(rtc >> 2);
+ } else {
+ rtc = PHYTEC_EEPROM_INVAL;
+ }
+ debug("%s: rtc: %u\n", __func__, rtc);
+ return rtc;
+}
diff --git a/board/phytec/common/imx8m_som_detection.h b/board/phytec/common/imx8m_som_detection.h
new file mode 100644
index 000000000000..88d3037bf363
--- /dev/null
+++ b/board/phytec/common/imx8m_som_detection.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2023 PHYTEC Messtechnik GmbH
+ * Author: Teresa Remmet <t.remmet@phytec.de>
+ */
+
+#ifndef _PHYTEC_IMX8M_SOM_DETECTION_H
+#define _PHYTEC_IMX8M_SOM_DETECTION_H
+
+#include "phytec_som_detection.h"
+
+#define PHYTEC_IMX8MQ_SOM 66
+#define PHYTEC_IMX8MM_SOM 69
+#define PHYTEC_IMX8MP_SOM 70
+
+#if IS_ENABLED(CONFIG_PHYTEC_IMX8M_SOM_DETECTION)
+
+u8 __maybe_unused phytec_imx8m_detect(struct phytec_eeprom_data *data);
+u8 __maybe_unused phytec_get_imx8m_ddr_size(struct phytec_eeprom_data *data);
+u8 __maybe_unused phytec_get_imx8mp_rtc(struct phytec_eeprom_data *data);
+u8 __maybe_unused phytec_get_imx8m_spi(struct phytec_eeprom_data *data);
+u8 __maybe_unused phytec_get_imx8m_eth(struct phytec_eeprom_data *data);
+
+#else
+
+inline u8 __maybe_unused phytec_imx8m_detect(struct phytec_eeprom_data *data)
+{
+ return -1;
+}
+
+inline u8 __maybe_unused
+phytec_get_imx8m_ddr_size(struct phytec_eeprom_data *data)
+{
+ return PHYTEC_EEPROM_INVAL;
+}
+
+inline u8 __maybe_unused phytec_get_imx8mp_rtc(struct phytec_eeprom_data *data)
+{
+ return PHYTEC_EEPROM_INVAL;
+}
+
+inline u8 __maybe_unused phytec_get_imx8m_spi(struct phytec_eeprom_data *data)
+{
+ return PHYTEC_EEPROM_INVAL;
+}
+
+inline u8 __maybe_unused phytec_get_imx8m_eth(struct phytec_eeprom_data *data)
+{
+ return PHYTEC_EEPROM_INVAL;
+}
+
+#endif /* IS_ENABLED(CONFIG_PHYTEC_IMX8M_SOM_DETECTION) */
+
+#endif /* _PHYTEC_IMX8M_SOM_DETECTION_H */
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/6] board: phytec: common: Add imx8m specific EEPROM detection support
2023-08-17 8:57 ` [PATCH v2 2/6] board: phytec: common: Add imx8m specific EEPROM detection support Teresa Remmet
@ 2023-08-28 12:32 ` Yannic Moog
0 siblings, 0 replies; 3+ messages in thread
From: Yannic Moog @ 2023-08-28 12:32 UTC (permalink / raw)
To: festevam@gmail.com, uboot-imx@nxp.com, sbabic@denx.de,
Teresa Remmet
Cc: upstream@lists.phytec.de, u-boot@lists.denx.de, Daniel Schultz,
Wadim Egorov
On Thu, 2023-08-17 at 10:57 +0200, Teresa Remmet wrote:
> Add imx8m specific detection part. Which includes checking the
> EEPROM data for article number options.
>
> Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Reviewed-by: Yannic Moog <y.moog@phytec.de>
Tested-by: Yannic Moog <y.moog@phytec.de>
> ---
> Changes in v2:
> - remove blank line at EOF
> - fix string conversion to integer
> - fix typo s/revsions/revisions
> ---
> board/phytec/common/Kconfig | 8 ++
> board/phytec/common/Makefile | 1 +
> board/phytec/common/imx8m_som_detection.c | 168
> ++++++++++++++++++++++
> board/phytec/common/imx8m_som_detection.h | 54 +++++++
> 4 files changed, 231 insertions(+)
> create mode 100644 board/phytec/common/imx8m_som_detection.c
> create mode 100644 board/phytec/common/imx8m_som_detection.h
>
> diff --git a/board/phytec/common/Kconfig b/board/phytec/common/Kconfig
> index d614d45b1d60..3b1c5aa0d02b 100644
> --- a/board/phytec/common/Kconfig
> +++ b/board/phytec/common/Kconfig
> @@ -3,3 +3,11 @@ config PHYTEC_SOM_DETECTION
> select SPL_CRC8 if SPL
> help
> Support of I2C EEPROM based SoM detection.
> +
> +config PHYTEC_IMX8M_SOM_DETECTION
> + bool "Support SoM detection for i.MX8M PHYTEC platforms"
> + depends on ARCH_IMX8M && PHYTEC_SOM_DETECTION
> + default y
> + help
> + Support of I2C EEPROM based SoM detection. Supported
> + for PHYTEC i.MX8MM/i.MX8MP boards
> diff --git a/board/phytec/common/Makefile
> b/board/phytec/common/Makefile
> index 5fe8725ef684..fe28964ce21c 100644
> --- a/board/phytec/common/Makefile
> +++ b/board/phytec/common/Makefile
> @@ -8,3 +8,4 @@ obj- := __dummy__.o
> endif
>
> obj-$(CONFIG_PHYTEC_SOM_DETECTION) += phytec_som_detection.o
> +obj-$(CONFIG_PHYTEC_IMX8M_SOM_DETECTION) += imx8m_som_detection.o
> diff --git a/board/phytec/common/imx8m_som_detection.c
> b/board/phytec/common/imx8m_som_detection.c
> new file mode 100644
> index 000000000000..c6c96ed19cb3
> --- /dev/null
> +++ b/board/phytec/common/imx8m_som_detection.c
> @@ -0,0 +1,168 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2023 PHYTEC Messtechnik GmbH
> + * Author: Teresa Remmet <t.remmet@phytec.de>
> + */
> +
> +#include <common.h>
> +#include <asm/arch/sys_proto.h>
> +#include <dm/device.h>
> +#include <dm/uclass.h>
> +#include <i2c.h>
> +#include <u-boot/crc.h>
> +
> +#include "imx8m_som_detection.h"
> +
> +extern struct phytec_eeprom_data eeprom_data;
> +
> +/* Check if the SoM is actually one of the following products:
> + * - i.MX8MM
> + * - i.MX8MN
> + * - i.MX8MP
> + * - i.MX8MQ
> + *
> + * Returns 0 in case it's a known SoM. Otherwise, returns -1.
> + */
> +u8 __maybe_unused phytec_imx8m_detect(struct phytec_eeprom_data
> *data)
> +{
> + char *opt;
> + u8 som;
> +
> + /* We can not do the check for early API revisions */
> + if (data->api_rev < PHYTEC_API_REV2)
> + return -1;
> +
> + if (!data)
> + data = &eeprom_data;
> +
> + som = data->data.data_api2.som_no;
> + debug("%s: som id: %u\n", __func__, som);
> +
> + opt = phytec_get_opt(data);
> + if (!opt)
> + return -1;
> +
> + if (som == PHYTEC_IMX8MP_SOM && is_imx8mp())
> + return 0;
> +
> + if (som == PHYTEC_IMX8MM_SOM) {
> + if ((PHYTEC_GET_OPTION(opt[0]) != 0) &&
> + (PHYTEC_GET_OPTION(opt[1]) == 0) && is_imx8mm())
> + return 0;
> + else if ((PHYTEC_GET_OPTION(opt[0]) == 0) &&
> + (PHYTEC_GET_OPTION(opt[1]) != 0) &&
> is_imx8mn())
> + return 0;
> + }
> +
> + if (som == PHYTEC_IMX8MQ_SOM && is_imx8mq())
> + return 0;
> +
> + pr_err("%s: SoM ID does not match. Wrong EEPROM data?\n",
> __func__);
> + return -1;
> +}
> +
> +/*
> + * All PHYTEC i.MX8M boards have RAM size definition at the
> + * same location.
> + */
> +u8 __maybe_unused phytec_get_imx8m_ddr_size(struct phytec_eeprom_data
> *data)
> +{
> + char *opt;
> + u8 ddr_id;
> +
> + if (!data)
> + data = &eeprom_data;
> +
> + opt = phytec_get_opt(data);
> + if (opt)
> + ddr_id = PHYTEC_GET_OPTION(opt[2]);
> + else
> + ddr_id = PHYTEC_EEPROM_INVAL;
> +
> + debug("%s: ddr id: %u\n", __func__, ddr_id);
> + return ddr_id;
> +}
> +
> +/*
> + * Filter SPI-NOR flash information. All i.MX8M boards have this at
> + * the same location.
> + * returns: 0x0 if no SPI is populated. Otherwise a board depended
> + * code for the size. PHYTEC_EEPROM_INVAL when the data is invalid.
> + */
> +u8 __maybe_unused phytec_get_imx8m_spi(struct phytec_eeprom_data
> *data)
> +{
> + char *opt;
> + u8 spi;
> +
> + if (!data)
> + data = &eeprom_data;
> +
> + if (data->api_rev < PHYTEC_API_REV2)
> + return PHYTEC_EEPROM_INVAL;
> +
> + opt = phytec_get_opt(data);
> + if (opt)
> + spi = PHYTEC_GET_OPTION(opt[4]);
> + else
> + spi = PHYTEC_EEPROM_INVAL;
> +
> + debug("%s: spi: %u\n", __func__, spi);
> + return spi;
> +}
> +
> +/*
> + * Filter ethernet phy information. All i.MX8M boards have this at
> + * the same location.
> + * returns: 0x0 if no ethernet phy is populated. 0x1 if it is
> populated.
> + * PHYTEC_EEPROM_INVAL when the data is invalid.
> + */
> +u8 __maybe_unused phytec_get_imx8m_eth(struct phytec_eeprom_data
> *data)
> +{
> + char *opt;
> + u8 eth;
> +
> + if (!data)
> + data = &eeprom_data;
> +
> + if (data->api_rev < PHYTEC_API_REV2)
> + return PHYTEC_EEPROM_INVAL;
> +
> + opt = phytec_get_opt(data);
> + if (opt) {
> + eth = PHYTEC_GET_OPTION(opt[5]);
> + eth &= 0x1;
> + } else {
> + eth = PHYTEC_EEPROM_INVAL;
> + }
> +
> + debug("%s: eth: %u\n", __func__, eth);
> + return eth;
> +}
> +
> +/*
> + * Filter RTC information for phyCORE-i.MX8MP.
> + * returns: 0 if no RTC is populated. 1 if it is populated.
> + * PHYTEC_EEPROM_INVAL when the data is invalid.
> + */
> +u8 __maybe_unused phytec_get_imx8mp_rtc(struct phytec_eeprom_data
> *data)
> +{
> + char *opt;
> + u8 rtc;
> +
> + if (!data)
> + data = &eeprom_data;
> +
> + if (data->api_rev < PHYTEC_API_REV2)
> + return PHYTEC_EEPROM_INVAL;
> +
> + opt = phytec_get_opt(data);
> + if (opt) {
> + rtc = PHYTEC_GET_OPTION(opt[5]);
> + rtc &= 0x4;
> + rtc = !(rtc >> 2);
> + } else {
> + rtc = PHYTEC_EEPROM_INVAL;
> + }
> + debug("%s: rtc: %u\n", __func__, rtc);
> + return rtc;
> +}
> diff --git a/board/phytec/common/imx8m_som_detection.h
> b/board/phytec/common/imx8m_som_detection.h
> new file mode 100644
> index 000000000000..88d3037bf363
> --- /dev/null
> +++ b/board/phytec/common/imx8m_som_detection.h
> @@ -0,0 +1,54 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2023 PHYTEC Messtechnik GmbH
> + * Author: Teresa Remmet <t.remmet@phytec.de>
> + */
> +
> +#ifndef _PHYTEC_IMX8M_SOM_DETECTION_H
> +#define _PHYTEC_IMX8M_SOM_DETECTION_H
> +
> +#include "phytec_som_detection.h"
> +
> +#define PHYTEC_IMX8MQ_SOM 66
> +#define PHYTEC_IMX8MM_SOM 69
> +#define PHYTEC_IMX8MP_SOM 70
> +
> +#if IS_ENABLED(CONFIG_PHYTEC_IMX8M_SOM_DETECTION)
> +
> +u8 __maybe_unused phytec_imx8m_detect(struct phytec_eeprom_data
> *data);
> +u8 __maybe_unused phytec_get_imx8m_ddr_size(struct phytec_eeprom_data
> *data);
> +u8 __maybe_unused phytec_get_imx8mp_rtc(struct phytec_eeprom_data
> *data);
> +u8 __maybe_unused phytec_get_imx8m_spi(struct phytec_eeprom_data
> *data);
> +u8 __maybe_unused phytec_get_imx8m_eth(struct phytec_eeprom_data
> *data);
> +
> +#else
> +
> +inline u8 __maybe_unused phytec_imx8m_detect(struct
> phytec_eeprom_data *data)
> +{
> + return -1;
> +}
> +
> +inline u8 __maybe_unused
> +phytec_get_imx8m_ddr_size(struct phytec_eeprom_data *data)
> +{
> + return PHYTEC_EEPROM_INVAL;
> +}
> +
> +inline u8 __maybe_unused phytec_get_imx8mp_rtc(struct
> phytec_eeprom_data *data)
> +{
> + return PHYTEC_EEPROM_INVAL;
> +}
> +
> +inline u8 __maybe_unused phytec_get_imx8m_spi(struct
> phytec_eeprom_data *data)
> +{
> + return PHYTEC_EEPROM_INVAL;
> +}
> +
> +inline u8 __maybe_unused phytec_get_imx8m_eth(struct
> phytec_eeprom_data *data)
> +{
> + return PHYTEC_EEPROM_INVAL;
> +}
> +
> +#endif /* IS_ENABLED(CONFIG_PHYTEC_IMX8M_SOM_DETECTION) */
> +
> +#endif /* _PHYTEC_IMX8M_SOM_DETECTION_H */
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/6] board: phytec: common: Add imx8m specific EEPROM detection support
@ 2023-10-16 11:50 sbabic
0 siblings, 0 replies; 3+ messages in thread
From: sbabic @ 2023-10-16 11:50 UTC (permalink / raw)
To: Teresa Remmet, u-boot
> Add imx8m specific detection part. Which includes checking the
> EEPROM data for article number options.
> Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
> Reviewed-by: Yannic Moog <y.moog@phytec.de>
> Tested-by: Yannic Moog <y.moog@phytec.de>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-16 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-16 11:50 [PATCH v2 2/6] board: phytec: common: Add imx8m specific EEPROM detection support sbabic
-- strict thread matches above, loose matches on Subject: below --
2023-08-17 8:57 [PATCH v2 0/6] PHYTEC SoM detection for phyCORE-i.MX8MP Teresa Remmet
2023-08-17 8:57 ` [PATCH v2 2/6] board: phytec: common: Add imx8m specific EEPROM detection support Teresa Remmet
2023-08-28 12:32 ` Yannic Moog
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox