summaryrefslogtreecommitdiff
path: root/board/phytec/common/phytec_som_detection.c
AgeCommit message (Collapse)Author
2025-04-15board: phytec: common: Fix phytec_get_product_name()Primoz Fiser
Currently, phytec_get_product_name() function only takes care of PCM SoM type, however in case of PCL, KSM or KSP SoM type it will return error: phytec_get_product_name: Invalid SOM type Add support for other SoM types as defined in phytec_som_type_str enum (see phytec_som_detection.h) to get rid of the error. While at it, also simplify switch case statements by grouping them together. This makes it more concise and readable. Signed-off-by: Primoz Fiser <primoz.fiser@norik.com> Reviewed-by: Daniel Schultz <d.schultz@phytec.de>
2025-01-31board: phytec: common: Add product information to FTDDaniel Schultz
ft_board_setup inside the board code allows to alter device-tree during the boot process. Introduce a new function for the PHYTEC SOM detection to read the product name and part number from the EEPROM content and include both into the device-tree as * phytec,som-part-number * phytec,som-product-name This function can be called from the board code when those values should be exposed to Linux. This patch also updates the phytec_print_som_info function and changes the output. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Reviewed-by: Wadim Egorov <w.egorov@phytec.de> Tested-by: Wadim Egorov <w.egorov@phytec.de>
2024-06-07board: phytec: common: Add API v3Daniel Schultz
This API is based on a block structure with a 8 Byte large API v3 header and various of different blocks following. It extends our current API v2, which is always 32 Byte large, and is located directly after v2. Add the MAC block as first block type. It contains the physical Ehternet interface number, a MAC address and a CRC checksum over the MAC payload. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Tested-by: Wadim Egorov <w.egorov@phytec.de>
2024-06-07board: phytec: common: Move API v2 init to new functionDaniel Schultz
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> Tested-by: Wadim Egorov <w.egorov@phytec.de>
2024-06-07board: phytec: common: Define PHYTEC_API2_DATA_LENDaniel Schultz
The EEPROM image length for API v2 is fixed to 32 bytes. No need to use sizeof while this value won't change. This value is also be required for API v3 to know where the API v3 header starts. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Tested-by: Wadim Egorov <w.egorov@phytec.de>
2024-06-07board: phytec: common: Move eeprom read to new functionDaniel Schultz
We need to read multiple times from different offsets in API v3. Move the EEPROM read logic into a dedicated function to make it usable multiple times. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Tested-by: Wadim Egorov <w.egorov@phytec.de>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-07board: phytec: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from this board vendor directory and when needed add missing include files directly. Acked-by: Wadim Egorov <w.egorov@phytec.de> Acked-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-04-29board: phytec: common: Fix eepom is empty checkDaniel Schultz
The ptr variable is currently defined as int and sizeof returns the size of the eeprom data struct as Byte (32 in total). In case the eeprom is empty, the check, if the eeprom is empty, will most likely stop after 8 iterations because it will continue with the stack which should contain some data. Therefore, the init function will detect an empty EEPROM as API0 and return with the valid flag set to True. Fixes: dc22188cdc8 ("board: phytec: Add common PHYTEC SoM detection") Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Reviewed-by: Teresa Remmet <t.remmet@phytec.de>
2024-04-29board: phytec: check eeprom_data validityYannic Moog
For all of the functions that access the eeprom_data, make sure these data are valid. Use the valid member of the phytec_eeprom_data struct. This fixes a bug where only the API revision check guarded against accessing rubbish. But if API revision was e.g. 6, eeprom setup failed before, but phytec_get_imx8m_eth would still happily access the data. Fixes: dc22188cdc8 ("board: phytec: Add common PHYTEC SoM detection") Signed-off-by: Yannic Moog <y.moog@phytec.de> Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Reviewed-by: Teresa Remmet <t.remmet@phytec.de>
2024-04-29board: phytec: introduce eeprom struct member 'valid'Yannic Moog
Add a new nember to the eeprom_data that indicates whether the associated data is valid or not. Make use of this new member in the phytec_eeprom_data_init function by setting the valid value appropriately. Move the eeprom data to a new struct payload that holds the payload of the eeprom. Signed-off-by: Yannic Moog <y.moog@phytec.de> Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Reviewed-by: Teresa Remmet <t.remmet@phytec.de>
2024-04-29board: phytec: common: Generic "add extension" functionDaniel Schultz
Add a generic function to apply overlays in our board code to not implement the same logic in different PHYTEC products. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Reviewed-by: Teresa Remmet <t.remmet@phytec.de>
2024-03-17board: phytec: define get_som_type also when SoM detection is disabledBenjamin Hahn
define the phytec_get_som_type function also when the SoM detection is disabled. Fixes: commit 110d321a56c3 ("board: phytec: common: phytec_som_detection: Add phytec_get_som_type") Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
2024-03-11board: phytec: common: phytec_som_detection: Add phytec_get_som_typeBenjamin Hahn
Add a function that gets the som_type from the EEPROM. Add an enum for the som_type. Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
2024-01-15board: phytec: fix link error when disabling PHYTEC_SOM_DETECTIONYannic Moog
Commit aa7858fe5e2e ("board: phytec: som_detection: move definitions to source file") moved function definitions from header to source file. Makefile however was not updated to unconditionally (from [..]_SOM_DETECTION) build the imx8 and phytec som detection units. Also remove unused includes that cause build failures on arm 32bit boards. SoM detection shall support 32bit boards as well, but arch specific code should not be included in the generic module. Fixes: aa7858fe5e2e ("board: phytec: som_detection: move definitions to source file") Signed-off-by: Yannic Moog <y.moog@phytec.de>
2023-12-20board: phytec: phytec_som_detection: fix uninitialized bugYannic Moog
When som_type does not match any case, it is uninitialized and the function still tries to print the SoM info. Rather, this is an error condition and the function should abort prematurely. Highlight this by printing an error message and returning early. Signed-off-by: Yannic Moog <y.moog@phytec.de>
2023-12-20board: phytec: som_detection: move definitions to source fileYannic Moog
Move all function definitions in {phytec|imx8m}_som_detection from the header to the source file to prevent potential linker error regarding multiple definitions. Also move the #if blocks with the definitions. Signed-off-by: Yannic Moog <y.moog@phytec.de>
2023-12-20board: phytec: phytec_som_detection: fix eeprom_data zero checkYannic Moog
In phytec_eeprom_data_init, after reading eeprom data into buffer, it is checked whether all bytes are 0x0 by iterating over chunks of the buffer. The offset, or index of the chunk, was never changed, leading to repeated comparison of only the first chunk. Use array notation and access chunk via array index to compare all chunks of the buffer. Signed-off-by: Yannic Moog <y.moog@phytec.de>
2023-10-16board: phytec: common: phytec_som_detection: Add helper for PCB revisionTeresa Remmet
Add helper function to read out the PCB revision of a PHYTEC SoM. 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>
2023-10-16board: phytec: Add common PHYTEC SoM detectionTeresa Remmet
Recent shipped PHYTEC SoMs come with an i2c EEPROM containing information about the hardware such as board revision and variant. This can be used for RAM detection and loading device tree overlays during kernel start. 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> Reviewed-by: Fabio Estevam <festevam@gmail.com>