From: Daniel Schultz <d.schultz@phytec.de>
To: <u-boot@lists.denx.de>, <upstream@lists.phytec.de>
Cc: Daniel Schultz <d.schultz@phytec.de>
Subject: [PATCH 3/6] board: phytec: common: Move API v2 init to new function
Date: Tue, 21 May 2024 23:18:24 -0700 [thread overview]
Message-ID: <20240522061827.601699-4-d.schultz@phytec.de> (raw)
In-Reply-To: <20240522061827.601699-1-d.schultz@phytec.de>
Move the entire initialization code for API v2 into a dedicated
function. This rework will allow to easily integrate the API v3
as next step during init.
Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
---
board/phytec/common/phytec_som_detection.c | 38 +++++++++++++---------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index f0e35d8d2ec..ab2d5a7b726 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -72,11 +72,29 @@ int phytec_eeprom_read(u8 *data, int bus_num, int addr, int size, int offset)
return ret;
}
+int phytec_eeprom_data_init_v2(struct phytec_eeprom_data *data)
+{
+ unsigned int crc;
+
+ if (!data)
+ return -1;
+
+ crc = crc8(0, (const unsigned char *)&data->payload, PHYTEC_API2_DATA_LEN);
+ debug("%s: crc: %x\n", __func__, crc);
+
+ if (crc) {
+ pr_err("%s: CRC mismatch. EEPROM data is not usable.\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
int bus_num, int addr)
{
int ret, i;
- unsigned int crc;
u8 *ptr;
if (!data)
@@ -104,20 +122,10 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
goto err;
}
- /* We are done here for early revisions */
- if (data->payload.api_rev <= PHYTEC_API_REV1) {
- data->valid = true;
- return 0;
- }
-
- crc = crc8(0, (const unsigned char *)&data->payload, PHYTEC_API2_DATA_LEN);
- debug("%s: crc: %x\n", __func__, crc);
-
- if (crc) {
- pr_err("%s: CRC mismatch. EEPROM data is not usable.\n",
- __func__);
- ret = -EINVAL;
- goto err;
+ if (data->payload.api_rev >= PHYTEC_API_REV2) {
+ ret = phytec_eeprom_data_init_v2(data);
+ if (ret)
+ goto err;
}
data->valid = true;
--
2.25.1
next prev parent reply other threads:[~2024-05-22 14:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 6:18 [PATCH 0/6] PHYTEC SOM Detection API v3 Daniel Schultz
2024-05-22 6:18 ` [PATCH 1/6] board: phytec: common: Move eeprom read to new function Daniel Schultz
2024-05-22 6:18 ` [PATCH 2/6] board: phytec: common: Define PHYTEC_API2_DATA_LEN Daniel Schultz
2024-05-22 6:18 ` Daniel Schultz [this message]
2024-05-22 6:18 ` [PATCH 4/6] board: phytec: common: Add API v3 Daniel Schultz
2024-05-22 6:18 ` [PATCH 5/6] board: phytec: common: k3: Set MAC Daniel Schultz
2024-05-22 8:38 ` [Upstream] " Wadim Egorov
2024-05-22 6:18 ` [PATCH 6/6] configs: phycore_am62x_a53_defconfig: Enable CONFIG_ENV_OVERWRITE Daniel Schultz
2024-05-22 8:30 ` [Upstream] " Wadim Egorov
2024-05-22 8:46 ` Daniel Schultz
2024-05-22 8:28 ` [Upstream] [PATCH 0/6] PHYTEC SOM Detection API v3 Wadim Egorov
2024-06-07 22:03 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240522061827.601699-4-d.schultz@phytec.de \
--to=d.schultz@phytec.de \
--cc=u-boot@lists.denx.de \
--cc=upstream@lists.phytec.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox