drivers/wifi,soc/intel/adl: Move CnviDdrRfim property to drivers

Some non-SoC code might want to know whether or not the CNVi DDR RFIM
feature is enabled. Also note that future SoCs may also support this
feature. To make the CnviDdrRfim property generic, move it from
soc/intel/alderlake to drivers/wifi/generic instead.

Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: Idf9fba0a79d1f431269be5851b026ed966600160
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61638
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Rizwan Qureshi <rizwan.qureshi@intel.com>
Reviewed-by: Varshit B Pandya <varshit.b.pandya@intel.com>
diff --git a/src/drivers/wifi/generic/generic.c b/src/drivers/wifi/generic/generic.c
index de93741..a6936f1 100644
--- a/src/drivers/wifi/generic/generic.c
+++ b/src/drivers/wifi/generic/generic.c
@@ -7,6 +7,7 @@
 #include <elog.h>
 #include "chip.h"
 #include "wifi_private.h"
+#include "wifi.h"
 
 static void wifi_pci_dev_init(struct device *dev)
 {
@@ -40,17 +41,39 @@
 #endif
 };
 
+static bool is_cnvi(const struct device *dev)
+{
+#if !DEVTREE_EARLY
+	return dev && dev->ops == &wifi_cnvi_ops;
+#else
+	return dev && dev->path.type != DEVICE_PATH_PCI;
+#endif
+}
+
+bool wifi_generic_cnvi_ddr_rfim_enabled(const struct device *dev)
+{
+	const struct drivers_wifi_generic_config *config;
+
+	if (!dev || !is_cnvi(dev) || !dev->chip_info)
+		return false;
+
+	config = dev->chip_info;
+	return config->enable_cnvi_ddr_rfim;
+}
+
 static void wifi_generic_enable(struct device *dev)
 {
-	struct drivers_wifi_generic_config *config = dev ? dev->chip_info : NULL;
+	DEVTREE_CONST struct drivers_wifi_generic_config *config = dev ? dev->chip_info : NULL;
 
 	if (!config)
 		return;
 
-	if (dev->path.type == DEVICE_PATH_PCI)
-		dev->ops = &wifi_pcie_ops;
-	else
+#if !DEVTREE_EARLY
+	if (is_cnvi(dev))
 		dev->ops = &wifi_cnvi_ops;
+	else
+		dev->ops = &wifi_pcie_ops;
+#endif
 }
 
 struct chip_operations drivers_wifi_generic_ops = {