[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPDyKFp6OTa07Lv+jsMy=Rn7U_NYFb_0MfNUXT3cjN_Gkwqs9g@mail.gmail.com>
Date: Fri, 14 Feb 2025 12:01:47 +0100
From: Ulf Hansson <ulf.hansson@...aro.org>
To: Michal Wilczynski <m.wilczynski@...sung.com>
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, 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: [PATCH v4 04/18] firmware: thead: Add AON firmware protocol driver
On Tue, 28 Jan 2025 at 20:48, Michal Wilczynski
<m.wilczynski@...sung.com> wrote:
>
> The T-Head TH1520 SoC uses an E902 co-processor running Always-On (AON)
> firmware to manage power, clock, and other system resources [1]. This
> patch introduces a driver implementing the AON firmware protocol,
> allowing the Linux kernel to communicate with the firmware via mailbox
> channels. Through an RPC-based interface, the kernel can initiate power
> state transitions, update resource configurations, and perform other
> AON-related tasks.
>
> Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1]
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@...sung.com>
> ---
[...]
> +
> +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))
> + return dev_err_probe(dev, PTR_ERR(aon_chan->ch),
> + "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;
> +}
Rather than implementing this as a driver, I suggest limiting this to
a set of exported library functions.
In this way, you don't need to register a platform device, but can
instead let the power-domain provider driver in patch6, to be the one
that matches on the "thead,th1520-aon" compatible to probe.
> +
> +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");
[...]
Kind regards
Uffe
Powered by blists - more mailing lists