[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d56a32a5-ef74-45de-95ac-b38b137dda4f@samsung.com>
Date: Tue, 21 Jan 2025 22:32:17 +0100
From: Michal Wilczynski <m.wilczynski@...sung.com>
To: Krzysztof Kozlowski <krzk@...nel.org>
Cc: mturquette@...libre.com, sboyd@...nel.org, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, drew@...7.com, guoren@...nel.org,
wefu@...hat.com, jassisinghbrar@...il.com, paul.walmsley@...ive.com,
palmer@...belt.com, aou@...s.berkeley.edu, frank.binns@...tec.com,
matt.coster@...tec.com, maarten.lankhorst@...ux.intel.com,
mripard@...nel.org, tzimmermann@...e.de, airlied@...il.com, simona@...ll.ch,
ulf.hansson@...aro.org, jszhang@...nel.org, p.zabel@...gutronix.de,
m.szyprowski@...sung.com, linux-clk@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org, dri-devel@...ts.freedesktop.org,
linux-pm@...r.kernel.org
Subject: Re: [RFC v3 04/18] firmware: thead: Add AON firmware protocol
driver
On 1/21/25 10:56, Krzysztof Kozlowski wrote:
> On Mon, Jan 20, 2025 at 06:20:57PM +0100, Michal Wilczynski wrote:
>> +#include <linux/firmware/thead/thead,th1520-aon.h>
>> +#include <linux/mailbox_client.h>
>> +#include <linux/mailbox_controller.h>
>> +#include <linux/mod_devicetable.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/platform_device.h>
>> +
>> +#include <dt-bindings/firmware/thead,th1520-aon.h>
>
> How/where do you use this header?
Indeed, it's used by the power-domain driver, so it's not needed here.
>
>> +
>> +#define MAX_RX_TIMEOUT (msecs_to_jiffies(3000))
>> +#define MAX_TX_TIMEOUT 500
>> +
>> +struct th1520_aon_chan {
>> + struct platform_device *pd;
>> + struct mbox_chan *ch;
>> + struct th1520_aon_rpc_ack_common ack_msg;
>> + struct mbox_client cl;
>> + struct completion done;
>> +
>> + /* make sure only one RPC is perfomed at a time */
>> + struct mutex transaction_lock;
>> +};
>> +
>
> ...
>
>> +static int th1520_aon_probe(struct platform_device *pdev)
>> +{
>> + struct device *dev = &pdev->dev;
>> + struct th1520_aon_chan *aon_chan;
>> + struct mbox_client *cl;
>> + int ret;
>> + struct platform_device_info pdevinfo = {
>> + .name = "th1520-pd",
>> + .id = PLATFORM_DEVID_AUTO,
>> + .parent = dev,
>> + };
>> +
>> + aon_chan = devm_kzalloc(dev, sizeof(*aon_chan), GFP_KERNEL);
>> + if (!aon_chan)
>> + return -ENOMEM;
>> +
>> + cl = &aon_chan->cl;
>> + cl->dev = dev;
>> + cl->tx_block = true;
>> + cl->tx_tout = MAX_TX_TIMEOUT;
>> + cl->rx_callback = th1520_aon_rx_callback;
>> +
>> + aon_chan->ch = mbox_request_channel_byname(cl, "aon");
>> + if (IS_ERR(aon_chan->ch)) {
>> + ret = PTR_ERR(aon_chan->ch);
>
> Drop, pointless. The entire point of using dev_err_probe is to make it
> simple.
>
>> + return dev_err_probe(dev, ret, "Failed to request aon mbox chan\n");
>> + }
>> +
>> + mutex_init(&aon_chan->transaction_lock);
>> + init_completion(&aon_chan->done);
>> +
>> + platform_set_drvdata(pdev, aon_chan);
>> +
>> + aon_chan->pd = platform_device_register_full(&pdevinfo);
>> + ret = PTR_ERR_OR_ZERO(aon_chan->pd);
>> + if (ret) {
>> + dev_err(dev, "Failed to register child device 'th1520-pd': %d\n", ret);
>> + goto free_mbox_chan;
>> + }
>> +
>> + ret = devm_of_platform_populate(dev);
>> + if (ret)
>> + goto unregister_pd;
>> +
>> + return 0;
>> +
>> +unregister_pd:
>> + platform_device_unregister(aon_chan->pd);
>> +free_mbox_chan:
>> + mbox_free_channel(aon_chan->ch);
>> +
>> + return ret;
>> +}
>> +
>> +static void th1520_aon_remove(struct platform_device *pdev)
>> +{
>> + struct th1520_aon_chan *aon_chan = platform_get_drvdata(pdev);
>> +
>> + platform_device_unregister(aon_chan->pd);
>> + mbox_free_channel(aon_chan->ch);
>> +}
>> +
>> +static const struct of_device_id th1520_aon_match[] = {
>> + { .compatible = "thead,th1520-aon" },
>> + { /* Sentinel */ }
>> +};
>> +MODULE_DEVICE_TABLE(of, th1520_aon_match);
>> +
>> +static struct platform_driver th1520_aon_driver = {
>> + .driver = {
>> + .name = "th1520-aon",
>> + .of_match_table = th1520_aon_match,
>> + },
>> + .probe = th1520_aon_probe,
>> + .remove = th1520_aon_remove,
>> +};
>> +module_platform_driver(th1520_aon_driver);
>> +
>> +MODULE_AUTHOR("Michal Wilczynski <m.wilczynski@...sung.com>");
>> +MODULE_DESCRIPTION("T-HEAD TH1520 Always-On firmware driver");
>> +MODULE_LICENSE("GPL");
>> diff --git a/include/linux/firmware/thead/thead,th1520-aon.h b/include/linux/firmware/thead/thead,th1520-aon.h
>> new file mode 100644
>> index 000000000000..3daa17c01d17
>> --- /dev/null
>> +++ b/include/linux/firmware/thead/thead,th1520-aon.h
>> @@ -0,0 +1,186 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Copyright (C) 2021 Alibaba Group Holding Limited.
>> + */
>> +
>> +#ifndef _THEAD_AON_H
>> +#define _THEAD_AON_H
>> +
>> +#include <linux/device.h>
>> +#include <linux/types.h>
>> +
>> +#define AON_RPC_MSG_MAGIC (0xef)
>> +#define TH1520_AON_RPC_VERSION 2
>> +#define TH1520_AON_RPC_MSG_NUM 7
>> +
>> +extern struct th1520_aon_chan *aon_chan;
>
> Drop all externs.
>
>
> Best regards,
> Krzysztof
>
>
Powered by blists - more mailing lists