From: Leilk Liu <leilk.liu@mediatek.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
"Mark Brown" <broonie@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-spi@vger.kernel.org>, <linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH V4 4/6] spi: mediatek: add spi memory support for ipm design
Date: Thu, 17 Mar 2022 17:27:20 +0800 [thread overview]
Message-ID: <602f93f020967789eff49e2fd821d1b03f5b009f.camel@mediatek.com> (raw)
In-Reply-To: <b237c1fe-9ddd-0a2e-ecf2-05bfb984c5dd@collabora.com>
On Tue, 2022-03-15 at 10:31 +0100, AngeloGioacchino Del Regno wrote:
> Il 15/03/22 04:24, Leilk Liu ha scritto:
> > this patch add the support of spi-mem for ipm design.
> >
> > Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
> > ---
> > drivers/spi/spi-mt65xx.c | 349
> > ++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 348 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
> > index 1a0b3208dfca..8958c3fa4fea 100644
> > --- a/drivers/spi/spi-mt65xx.c
> > +++ b/drivers/spi/spi-mt65xx.c
>
> ...snip...
>
> > +
> > +static void of_mtk_spi_parse_dt(struct spi_master *master, struct
> > device_node *nc)
> > +{
> > + struct mtk_spi *mdata = spi_master_get_devdata(master);
> > + u32 value;
> > +
> > + if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
>
> Hello Leilk,
>
> thanks for considering my advice about "spi-{tx,rx}-bus-width", but
> there's
> something that you have misunderstood about it.
>
> Simply, you don't need this function at all. Whatever you are doing
> here is
> already being performed in the Linux SPI framework: at the end of the
> probe
> function, this driver is calling the (legacy)
> devm_spi_register_master(),
> which calls devm_spi_register_controller().
>
> In drivers/spi/spi.c, function spi_register_controller(), will in
> turn call
> of_register_spi_devices(ctlr) -> of_register_spi_device(ctlr, nc)...
> that
> will end up finally calling function of_spi_parse_dt(ctlr, spi, nc).
>
> The last mentioned function already contains the logic and setup to
> check
> devicetree properties "spi-tx-bus-width" and "spi-rx-bus-width" (and
> some
> others, as well).
>
> This means that spi-mt65xx.c already probed these even before your
> IPM
> implementation, hence ***function of_mtk_spi_parse_dt() is not
> needed***.
>
> Simply drop it and don't check for these properties: that's already
> done.
>
>
> Regards,
> Angelo
>
Hi Angelo,
Thanks for your advice.
There are two spi controllor on MT7986. One supports single/dual mode,
the other supports quad mode. Both of them can support spi memory
framework(one's tx/rx bus width is 1/2, the other one's tx/rx bus width
is 1/2/4).
Can I use of_mtk_spi_parse_dt() to parse the information? What's your
suggestion?
Thanks!
> > + switch (value) {
> > + case 1:
> > + break;
> > + case 2:
> > + master->mode_bits |= SPI_TX_DUAL;
> > + break;
> > + case 4:
> > + master->mode_bits |= SPI_TX_QUAD;
> > + break;
> > + default:
> > + dev_warn(mdata->dev,
> > + "spi-tx-bus-width %d not supported\n",
> > + value);
> > + break;
> > + }
> > + }
> > +
> > + if (!of_property_read_u32(nc, "spi-rx-bus-width", &value)) {
> > + switch (value) {
> > + case 1:
> > + break;
> > + case 2:
> > + master->mode_bits |= SPI_RX_DUAL;
> > + break;
> > + case 4:
> > + master->mode_bits |= SPI_RX_QUAD;
> > + break;
> > + case 8:
> > + master->mode_bits |= SPI_RX_OCTAL;
> > + break;
> > + default:
> > + dev_warn(mdata->dev,
> > + "spi-rx-bus-width %d not supported\n",
> > + value);
> > + break;
> > + }
> > + }
> > +}
> > +
> > static int mtk_spi_probe(struct platform_device *pdev)
> > {
> > struct spi_master *master;
> > @@ -830,6 +1170,13 @@ static int mtk_spi_probe(struct
> > platform_device *pdev)
> > if (mdata->dev_comp->ipm_design)
> > master->mode_bits |= SPI_LOOP;
> >
> > + if (mdata->dev_comp->ipm_design) {
> > + mdata->dev = &pdev->dev;
> > + master->mem_ops = &mtk_spi_mem_ops;
> > + of_mtk_spi_parse_dt(master, pdev->dev.of_node);
> > + init_completion(&mdata->spimem_done);
> > + }
> > +
> > if (mdata->dev_comp->need_pad_sel) {
> > mdata->pad_num = of_property_count_u32_elems(
> > pdev->dev.of_node,
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2022-03-17 9:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 3:24 [PATCH V4 0/6] spi: mediatek: add single/quad mode support Leilk Liu
2022-03-15 3:24 ` [PATCH V4 1/6] spi: mediatek: support tick_delay without enhance_timing Leilk Liu
2022-03-15 3:24 ` [PATCH V4 2/6] dt-bindings: spi: Add compatible for MT7986 Leilk Liu
2022-03-15 9:38 ` AngeloGioacchino Del Regno
2022-03-15 3:24 ` [PATCH V4 3/6] spi: mediatek: add ipm design support " Leilk Liu
2022-03-15 9:38 ` AngeloGioacchino Del Regno
2022-03-15 9:39 ` AngeloGioacchino Del Regno
2022-03-15 3:24 ` [PATCH V4 4/6] spi: mediatek: add spi memory support for ipm design Leilk Liu
2022-03-15 9:31 ` AngeloGioacchino Del Regno
2022-03-17 9:27 ` Leilk Liu [this message]
2022-03-17 9:33 ` AngeloGioacchino Del Regno
2022-03-17 9:44 ` Leilk Liu
2022-03-15 3:24 ` [PATCH V4 5/6] dt-bindings: spi: support hclk Leilk Liu
2022-03-15 3:24 ` [PATCH V4 6/6] spi: mediatek: " Leilk Liu
2022-03-15 9:37 ` AngeloGioacchino Del Regno
2022-03-17 9:14 ` Leilk Liu
2022-03-15 13:41 ` (subset) [PATCH V4 0/6] spi: mediatek: add single/quad mode support Mark Brown
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=602f93f020967789eff49e2fd821d1b03f5b009f.camel@mediatek.com \
--to=leilk.liu@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@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