[qca-ssdk] Support API to get dev_id by chip type

Change-Id: I15a525cd9fd1c9a05a722743a8368054f261972e
Signed-off-by: linchen <linchen@codeaurora.org>
diff --git a/include/fal/fal_init.h b/include/fal/fal_init.h
index c09741a..254fdea 100755
--- a/include/fal/fal_init.h
+++ b/include/fal/fal_init.h
@@ -70,6 +70,8 @@
 sw_error_t fal_module_func_ctrl_get(a_uint32_t dev_id,
 		a_uint32_t module, fal_func_ctrl_t *func_ctrl);
 sw_error_t fal_module_func_init(a_uint32_t dev_id, ssdk_init_cfg *cfg);
+sw_error_t fal_switch_devid_get(ssdk_chip_type chip_type, a_uint32_t *pdev_id);
+
 /*qca808x_start*/
 #ifdef __cplusplus
 }
diff --git a/src/fal/fal_init.c b/src/fal/fal_init.c
index cbff342..c57809b 100755
--- a/src/fal/fal_init.c
+++ b/src/fal/fal_init.c
@@ -153,6 +153,23 @@
 }
 
 sw_error_t
+fal_switch_devid_get(ssdk_chip_type chip_type, a_uint32_t *pdev_id)
+{
+	sw_error_t rv = SW_OK;
+	ssdk_cfg_t cfg = {0};
+	a_uint32_t dev_id = 0;
+
+	for(dev_id = 0; dev_id < SW_MAX_NR_DEV; dev_id++) {
+		rv = _fal_ssdk_cfg(dev_id, &cfg);
+		if(rv == SW_OK && cfg.init_cfg.chip_type == chip_type) {
+			*pdev_id = dev_id;
+			return rv;
+		}
+	}
+	return SW_FAIL;
+}
+
+sw_error_t
 fal_module_func_ctrl_set(a_uint32_t dev_id, a_uint32_t module, fal_func_ctrl_t *func_ctrl)
 {
     sw_error_t rv;
@@ -186,6 +203,8 @@
     return rv;
 }
 
+EXPORT_SYMBOL(fal_switch_devid_get);
+
 /**
  * @}
  */