From: neil.armstrong@linaro.org
To: Praveen Talari <quic_ptalari@quicinc.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
Stephen Boyd <sboyd@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, devicetree@vger.kernel.org,
linux-pm@vger.kernel.org
Cc: psodagud@quicinc.com, djaggi@quicinc.com,
quic_msavaliy@quicinc.com, quic_vtanuku@quicinc.com,
quic_arandive@quicinc.com, quic_mnaresh@quicinc.com,
quic_shazhuss@quicinc.com
Subject: Re: [PATCH v3 4/9] soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms
Date: Fri, 2 May 2025 11:28:53 +0200 [thread overview]
Message-ID: <9bf9b71f-e7d6-40ac-9fe8-a8396db0870e@linaro.org> (raw)
In-Reply-To: <20250502031018.1292-5-quic_ptalari@quicinc.com>
On 02/05/2025 05:10, Praveen Talari wrote:
> 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>
>
> v1 -> v2
> - changed datatype of i from int to unsigned int as per comment.
> ---
> drivers/soc/qcom/qcom-geni-se.c | 77 +++++++++++++++++++++------------
> 1 file changed, 49 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> index 4cb959106efa..0e3658b09603 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;
> + unsigned 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,36 +942,12 @@ 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;
> - }
> }
>
> dev_set_drvdata(dev, wrapper);
> @@ -951,6 +963,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,
Just don't specify it, it will be NULL by default, same for the other fields aswell.
Just declare an empty struct instead, maybe add a comment if you want the reader
to understand there's no clocks for this instance type.
Another much simpler way to implement this would be to just check for num_clks
along !has_acpi_companion(&pdev->dev) like:
if (!has_acpi_companion(&pdev->dev) && desc->num_clks) {
}
And you're done.
Neil
> };
>
> static const char * const i2c_master_hub_clks[] = {
> @@ -960,11 +979,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);
next prev parent reply other threads:[~2025-05-02 9:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 3:10 [PATCH v3 0/9] Enable QUPs and Serial on SA8255p Qualcomm platforms Praveen Talari
2025-05-02 3:10 ` [PATCH v3 1/9] opp: add new helper API dev_pm_opp_set_level() Praveen Talari
2025-05-02 3:49 ` Trilok Soni
2025-05-02 5:37 ` Viresh Kumar
2025-05-02 7:37 ` Praveen Talari
2025-05-02 7:45 ` Viresh Kumar
2025-05-02 8:01 ` Praveen Talari
2025-05-02 8:14 ` Viresh Kumar
2025-05-02 14:01 ` Praveen Talari
2025-05-02 14:11 ` Viresh Kumar
2025-05-02 14:39 ` Praveen Talari
2025-05-02 3:10 ` [PATCH v3 2/9] dt-bindings: serial: describe SA8255p Praveen Talari
2025-05-02 3:49 ` Trilok Soni
2025-05-02 6:36 ` Krzysztof Kozlowski
2025-05-02 3:10 ` [PATCH v3 3/9] dt-bindings: qcom: geni-se: " Praveen Talari
2025-05-02 6:37 ` Krzysztof Kozlowski
2025-05-02 8:07 ` Praveen Talari
2025-05-02 3:10 ` [PATCH v3 4/9] soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms Praveen Talari
2025-05-02 9:28 ` neil.armstrong [this message]
2025-05-07 5:49 ` kernel test robot
2025-05-02 3:10 ` [PATCH v3 5/9] serial: qcom-geni: move resource initialization to separate function Praveen Talari
2025-05-02 3:10 ` [PATCH v3 6/9] serial: qcom-geni: move resource control logic to separate functions Praveen Talari
2025-05-02 3:10 ` [PATCH v3 7/9] serial: qcom-geni: move clock-rate logic to separate function Praveen Talari
2025-05-02 3:10 ` [PATCH v3 8/9] serial: qcom-geni: Enable PM runtime for serial driver Praveen Talari
2025-05-07 7:58 ` kernel test robot
2025-05-02 3:10 ` [PATCH v3 9/9] serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms Praveen Talari
2025-05-02 9:24 ` neil.armstrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9bf9b71f-e7d6-40ac-9fe8-a8396db0870e@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djaggi@quicinc.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=nm@ti.com \
--cc=psodagud@quicinc.com \
--cc=quic_arandive@quicinc.com \
--cc=quic_mnaresh@quicinc.com \
--cc=quic_msavaliy@quicinc.com \
--cc=quic_ptalari@quicinc.com \
--cc=quic_shazhuss@quicinc.com \
--cc=quic_vtanuku@quicinc.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=vireshk@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox