From: Caleb Ethridge <[email protected]>

somcrr_common.c calls adi_somcrr_enable_ethernet() and
adi_somcrr_disable_ethernet(), which are only provided by the
carrier-specific files. It is built unconditionally, so a SOM built
without a carrier board would be left with undefined references.

Add an ADI_CARRIER_SOMCRR_COMMON symbol, selected by each carrier
board option, and only build somcrr_common.o when it is enabled.

Signed-off-by: Caleb Ethridge <[email protected]>
---
 arch/arm/mach-sc5xx/Kconfig            | 8 ++++++++
 board/adi/carriers/Makefile            | 2 +-
 board/adi/common-sc594-som/sc594-som.c | 4 +---
 board/adi/common-sc598-som/sc598-som.c | 4 +---
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-sc5xx/Kconfig b/arch/arm/mach-sc5xx/Kconfig
index 0f4e63a355e..cf154c221eb 100644
--- a/arch/arm/mach-sc5xx/Kconfig
+++ b/arch/arm/mach-sc5xx/Kconfig
@@ -210,6 +210,12 @@ config ADI_BUG_EZKHW21
          This workaround affects the SC584 EZKIT and addresses bug EZKHW21.
          It disables gigabit ethernet mode and limits the board to 100 Mbps
 
+config ADI_CARRIER_SOMCRR_COMMON
+       bool
+       help
+         Common code shared by the EV-SOMCRR carrier board support.
+         Selected by the carrier board options.
+
 choice
        prompt "Analog Devices SOM Carrier Board Variant"
        depends on (SC59X || SC59X_64)
@@ -220,12 +226,14 @@ choice
 
 config ADI_CARRIER_SOMCRR_EZKIT
        bool "Support the EV-SOMCRR-EZKIT"
+       select ADI_CARRIER_SOMCRR_COMMON
        help
          Say y to include support for the EV-SOMCRR-EZKIT carrier board,
          which is compatible with the SC594 and SC598 SOMs.
 
 config ADI_CARRIER_SOMCRR_EZLITE
        bool "Support the EV-SOMCRR-EZLITE"
+       select ADI_CARRIER_SOMCRR_COMMON
        help
          Say y to include support for the EV-SOMCRR-EZLITE carrier board,
          which is compatible with the SC594 and SC598 SOMs.
diff --git a/board/adi/carriers/Makefile b/board/adi/carriers/Makefile
index cefd2cc837f..ccb44e262fe 100644
--- a/board/adi/carriers/Makefile
+++ b/board/adi/carriers/Makefile
@@ -3,6 +3,6 @@
 # (C) Copyright 2024 - Analog Devices, Inc.
 #
 
-obj-y += somcrr_common.o
+obj-$(CONFIG_ADI_CARRIER_SOMCRR_COMMON) += somcrr_common.o
 obj-$(CONFIG_ADI_CARRIER_SOMCRR_EZKIT) += somcrr_ezkit.o
 obj-$(CONFIG_ADI_CARRIER_SOMCRR_EZLITE) += somcrr_ezlite.o
diff --git a/board/adi/common-sc594-som/sc594-som.c 
b/board/adi/common-sc594-som/sc594-som.c
index 37817c4b062..136548b4f35 100644
--- a/board/adi/common-sc594-som/sc594-som.c
+++ b/board/adi/common-sc594-som/sc594-som.c
@@ -23,10 +23,8 @@ int board_init(void)
 {
        sc59x_remap_ospi();
 
-       if (IS_ENABLED(CONFIG_ADI_CARRIER_SOMCRR_EZKIT) ||
-           IS_ENABLED(CONFIG_ADI_CARRIER_SOMCRR_EZLITE)) {
+       if (IS_ENABLED(CONFIG_ADI_CARRIER_SOMCRR_COMMON))
                adi_somcrr_init_ethernet();
-       }
 
        sc5xx_enable_rgmii();
 
diff --git a/board/adi/common-sc598-som/sc598-som.c 
b/board/adi/common-sc598-som/sc598-som.c
index 0e1ee828956..51c96fd69c8 100644
--- a/board/adi/common-sc598-som/sc598-som.c
+++ b/board/adi/common-sc598-som/sc598-som.c
@@ -23,10 +23,8 @@ int board_init(void)
 {
        sc59x_remap_ospi();
 
-       if (IS_ENABLED(CONFIG_ADI_CARRIER_SOMCRR_EZKIT) ||
-           IS_ENABLED(CONFIG_ADI_CARRIER_SOMCRR_EZLITE)) {
+       if (IS_ENABLED(CONFIG_ADI_CARRIER_SOMCRR_COMMON))
                adi_somcrr_init_ethernet();
-       }
 
        sc5xx_enable_rgmii();
 
-- 
2.43.0

Reply via email to