|
@@ -1,7 +1,7 @@
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
/*
|
|
|
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
|
|
|
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
|
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
|
*/
|
|
|
|
|
|
#include <linux/slab.h>
|
|
@@ -16,6 +16,7 @@
|
|
|
#include "cam_cpas_api.h"
|
|
|
|
|
|
static struct cam_isp_hw_intf_data cam_tfe_hw_list[CAM_TFE_HW_NUM_MAX];
|
|
|
+static uint32_t g_num_tfe_hws, g_num_tfe_lite_hws;
|
|
|
|
|
|
static int cam_tfe_component_bind(struct device *dev,
|
|
|
struct device *master_dev, void *data)
|
|
@@ -33,11 +34,15 @@ static int cam_tfe_component_bind(struct device *dev,
|
|
|
|
|
|
CAM_DBG(CAM_ISP, "probe called");
|
|
|
|
|
|
- of_property_read_u32(pdev->dev.of_node,
|
|
|
- "cell-index", &tfe_hw_idx);
|
|
|
+ rc = of_property_read_u32(pdev->dev.of_node, "cell-index", &tfe_hw_idx);
|
|
|
+ if (rc) {
|
|
|
+ CAM_ERR(CAM_ISP, "Failed to read cell-index of TFE HW, rc: %d", rc);
|
|
|
+ goto end;
|
|
|
+ }
|
|
|
|
|
|
- if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_LITE_FUSE, BIT(tfe_hw_idx), NULL)) {
|
|
|
- CAM_DBG(CAM_ISP, "TFE:%d is not supported", tfe_hw_idx);
|
|
|
+ if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE, BIT(tfe_hw_idx), NULL) ||
|
|
|
+ !cam_cpas_is_feature_supported(CAM_CPAS_ISP_LITE_FUSE, BIT(tfe_hw_idx), NULL)) {
|
|
|
+ CAM_DBG(CAM_ISP, "TFE[%d] not supported based on fuse", tfe_hw_idx);
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
@@ -207,11 +212,44 @@ const static struct component_ops cam_tfe_component_ops = {
|
|
|
.unbind = cam_tfe_component_unbind,
|
|
|
};
|
|
|
|
|
|
+void cam_tfe_get_num_tfe_hws(uint32_t *num_tfes)
|
|
|
+{
|
|
|
+ if (num_tfes)
|
|
|
+ *num_tfes = g_num_tfe_hws;
|
|
|
+ else
|
|
|
+ CAM_ERR(CAM_ISP, "Invalid argument, g_num_tfe_hws: %u", g_num_tfe_hws);
|
|
|
+}
|
|
|
+
|
|
|
+void cam_tfe_get_num_tfe_lite_hws(uint32_t *num_tfe_lites)
|
|
|
+{
|
|
|
+ if (num_tfe_lites)
|
|
|
+ *num_tfe_lites = g_num_tfe_lite_hws;
|
|
|
+ else
|
|
|
+ CAM_ERR(CAM_ISP, "Invalid argument, g_num_tfe_lite_hws: %u", g_num_tfe_lite_hws);
|
|
|
+}
|
|
|
+
|
|
|
int cam_tfe_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
int rc = 0;
|
|
|
+ const char *compatible_name;
|
|
|
+ struct device_node *of_node = NULL;
|
|
|
|
|
|
CAM_DBG(CAM_ISP, "Adding TFE component");
|
|
|
+
|
|
|
+ of_node = pdev->dev.of_node;
|
|
|
+
|
|
|
+ rc = of_property_read_string_index(of_node, "compatible", 0,
|
|
|
+ (const char **)&compatible_name);
|
|
|
+ if (rc)
|
|
|
+ CAM_ERR(CAM_ISP, "No compatible string present for: %s, rc: %d", pdev->name, rc);
|
|
|
+
|
|
|
+ if (strnstr(compatible_name, "lite", strlen(compatible_name)) != NULL)
|
|
|
+ g_num_tfe_lite_hws++;
|
|
|
+ else if (strnstr(compatible_name, "tfe", strlen(compatible_name)) != NULL)
|
|
|
+ g_num_tfe_hws++;
|
|
|
+ else
|
|
|
+ CAM_ERR(CAM_ISP, "Failed to increement number of TFEs/TFE-LITEs");
|
|
|
+
|
|
|
rc = component_add(&pdev->dev, &cam_tfe_component_ops);
|
|
|
if (rc)
|
|
|
CAM_ERR(CAM_ISP, "failed to add component rc: %d", rc);
|