[PATCH v1 4/9] soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms

Praveen Talari
2025-04-10T17:41:13Z

On the sa8255p platform, resources such as clocks,interconnects
and TLMM (GPIO) configurations are managed by firmware.

Introduce a platform data function callback to distinguish whether
resource control is performed by firmware or directly by the driver
in linux.

The refactor ensures clear differentiation of resource
management mechanisms, improving maintainability and flexibility
in handling platform-specific configurations.

Signed-off-by: Praveen Talari <quic_ptalari@quicinc.com>
---
drivers/soc/qcom/qcom-geni-se.c | 78 +++++++++++++++++++++------------
1 file changed, 50 insertions(+), 28 deletions(-)

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 4cb959106efa..5e2add1e04d3 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -105,6 +105,8 @@ struct geni_wrapper {
struct geni_se_desc {
unsigned int num_clks;
const char * const *clks;
+ int (*geni_se_rsc_init)(struct geni_wrapper *wrapper,
+ const struct geni_se_desc *desc);
};

static const char * const icc_path_names[] = {"qup-core", "qup-config",
@@ -891,10 +893,44 @@ int geni_icc_disable(struct geni_se *se)
}
EXPORT_SYMBOL_GPL(geni_icc_disable);

+static int geni_se_resource_init(struct geni_wrapper *wrapper,
+ const struct geni_se_desc *desc)
+{
+ struct device *dev = wrapper->dev;
+ int ret;
+ int i;
+
+ wrapper->num_clks = min_t(unsigned int, desc->num_clks, MAX_CLKS);
+
+ for (i = 0; i < wrapper->num_clks; ++i)
+ wrapper->clks[i].id = desc->clks[i];
+
+ ret = of_count_phandle_with_args(dev->of_node, "clocks", "#clock-cells");
+ if (ret < 0) {
+ dev_err(dev, "invalid clocks property at %pOF\n", dev->of_node);
+ return ret;
+ }
+
+ if (ret < wrapper->num_clks) {
+ dev_err(dev, "invalid clocks count at %pOF, expected %d entries\n",
+ dev->of_node, wrapper->num_clks);
+ return -EINVAL;
+ }
+
+ ret = devm_clk_bulk_get(dev, wrapper->num_clks, wrapper->clks);
+ if (ret) {
+ dev_err(dev, "Err getting clks %d\n", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
static int geni_se_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct geni_wrapper *wrapper;
+ const struct geni_se_desc *desc;
int ret;

wrapper = devm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL);
@@ -906,38 +942,15 @@ static int geni_se_probe(struct platform_device *pdev)
if (IS_ERR(wrapper->base))
return PTR_ERR(wrapper->base);

- if (!has_acpi_companion(&pdev->dev)) {
- const struct geni_se_desc *desc;
- int i;
-
- desc = device_get_match_data(&pdev->dev);
- if (!desc)
- return -EINVAL;
-
- wrapper->num_clks = min_t(unsigned int, desc->num_clks, MAX_CLKS);
-
- for (i = 0; i < wrapper->num_clks; ++i)
- wrapper->clks[i].id = desc->clks[i];
-
- ret = of_count_phandle_with_args(dev->of_node, "clocks", "#clock-cells");
- if (ret < 0) {
- dev_err(dev, "invalid clocks property at %pOF\n", dev->of_node);
- return ret;
- }
+ desc = device_get_match_data(&pdev->dev);

- if (ret < wrapper->num_clks) {
- dev_err(dev, "invalid clocks count at %pOF, expected %d entries\n",
- dev->of_node, wrapper->num_clks);
+ if (!has_acpi_companion(&pdev->dev) && desc->geni_se_rsc_init) {
+ ret = desc->geni_se_rsc_init(wrapper, desc);
+ if (ret)
return -EINVAL;
- }
-
- ret = devm_clk_bulk_get(dev, wrapper->num_clks, wrapper->clks);
- if (ret) {
- dev_err(dev, "Err getting clks %d\n", ret);
- return ret;
- }
}

+out:
dev_set_drvdata(dev, wrapper);
dev_dbg(dev, "GENI SE Driver probed\n");
return devm_of_platform_populate(dev);
@@ -951,6 +964,13 @@ static const char * const qup_clks[] = {
static const struct geni_se_desc qup_desc = {
.clks = qup_clks,
.num_clks = ARRAY_SIZE(qup_clks),
+ .geni_se_rsc_init = geni_se_resource_init,
+};
+
+static const struct geni_se_desc sa8255p_qup_desc = {
+ .clks = NULL,
+ .num_clks = 0,
+ .geni_se_rsc_init = NULL,
};

static const char * const i2c_master_hub_clks[] = {
@@ -960,11 +980,13 @@ static const char * const i2c_master_hub_clks[] = {
static const struct geni_se_desc i2c_master_hub_desc = {
.clks = i2c_master_hub_clks,
.num_clks = ARRAY_SIZE(i2c_master_hub_clks),
+ .geni_se_rsc_init = geni_se_resource_init,
};

static const struct of_device_id geni_se_dt_match[] = {
{ .compatible = "qcom,geni-se-qup", .data = &qup_desc },
{ .compatible = "qcom,geni-se-i2c-master-hub", .data = &i2c_master_hub_desc },
+ { .compatible = "qcom,sa8255p-geni-se-qup", .data = &sa8255p_qup_desc },
{}
};
MODULE_DEVICE_TABLE(of, geni_se_dt_match);
--
2.17.1