diff mbox series

[v2,5/6] board: phytec: common: phytec_som_detection: Add helper for PCB revision

Message ID 20230817085711.45339-6-t.remmet@phytec.de
State Accepted
Commit 44c82e7c90be700719a4b105ec97ff328a40d675
Delegated to: Stefano Babic
Headers show
Series PHYTEC SoM detection for phyCORE-i.MX8MP | expand

Commit Message

Teresa Remmet Aug. 17, 2023, 8:57 a.m. UTC
Add helper function to read out the PCB revision of a PHYTEC SoM.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
Changes in v2:
- none
---
 board/phytec/common/phytec_som_detection.c | 15 +++++++++++++++
 board/phytec/common/phytec_som_detection.h |  5 +++++
 2 files changed, 20 insertions(+)

Comments

Yannic Moog Aug. 28, 2023, 12:33 p.m. UTC | #1
On Thu, 2023-08-17 at 10:57 +0200, Teresa Remmet wrote:
> 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>

> ---
> Changes in v2:
> - none
> ---
>  board/phytec/common/phytec_som_detection.c | 15 +++++++++++++++
>  board/phytec/common/phytec_som_detection.h |  5 +++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/board/phytec/common/phytec_som_detection.c
> b/board/phytec/common/phytec_som_detection.c
> index 366bdd4ace4b..55562731270b 100644
> --- a/board/phytec/common/phytec_som_detection.c
> +++ b/board/phytec/common/phytec_som_detection.c
> @@ -186,3 +186,18 @@ char * __maybe_unused phytec_get_opt(struct
> phytec_eeprom_data *data)
>  
>         return opt;
>  }
> +
> +u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data)
> +{
> +       struct phytec_api2_data *api2;
> +
> +       if (!data)
> +               data = &eeprom_data;
> +
> +       if (data->api_rev < PHYTEC_API_REV2)
> +               return PHYTEC_EEPROM_INVAL;
> +
> +       api2 = &data->data.data_api2;
> +
> +       return api2->pcb_rev;
> +}
> diff --git a/board/phytec/common/phytec_som_detection.h
> b/board/phytec/common/phytec_som_detection.h
> index 01f7e4652ddb..c68e2302cc42 100644
> --- a/board/phytec/common/phytec_som_detection.h
> +++ b/board/phytec/common/phytec_som_detection.h
> @@ -68,6 +68,7 @@ int phytec_eeprom_data_init(struct
> phytec_eeprom_data *data,
>  void __maybe_unused phytec_print_som_info(struct phytec_eeprom_data
> *data);
>  
>  char * __maybe_unused phytec_get_opt(struct phytec_eeprom_data
> *data);
> +u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data);
>  
>  #else
>  
> @@ -99,6 +100,10 @@ inline char *__maybe_unused phytec_get_opt(struct
> phytec_eeprom_data *data)
>         return NULL;
>  }
>  
> +u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data)
> +{
> +       return PHYTEC_EEPROM_INVAL;
> +}
>  #endif /* IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION) */
>  
>  #endif /* _PHYTEC_SOM_DETECTION_H */
diff mbox series

Patch

diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index 366bdd4ace4b..55562731270b 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -186,3 +186,18 @@  char * __maybe_unused phytec_get_opt(struct phytec_eeprom_data *data)
 
 	return opt;
 }
+
+u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data)
+{
+	struct phytec_api2_data *api2;
+
+	if (!data)
+		data = &eeprom_data;
+
+	if (data->api_rev < PHYTEC_API_REV2)
+		return PHYTEC_EEPROM_INVAL;
+
+	api2 = &data->data.data_api2;
+
+	return api2->pcb_rev;
+}
diff --git a/board/phytec/common/phytec_som_detection.h b/board/phytec/common/phytec_som_detection.h
index 01f7e4652ddb..c68e2302cc42 100644
--- a/board/phytec/common/phytec_som_detection.h
+++ b/board/phytec/common/phytec_som_detection.h
@@ -68,6 +68,7 @@  int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
 void __maybe_unused phytec_print_som_info(struct phytec_eeprom_data *data);
 
 char * __maybe_unused phytec_get_opt(struct phytec_eeprom_data *data);
+u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data);
 
 #else
 
@@ -99,6 +100,10 @@  inline char *__maybe_unused phytec_get_opt(struct phytec_eeprom_data *data)
 	return NULL;
 }
 
+u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data)
+{
+	return PHYTEC_EEPROM_INVAL;
+}
 #endif /* IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION) */
 
 #endif /* _PHYTEC_SOM_DETECTION_H */