From: Marek Vasut <marek.vasut@gmail.com>
To: masonccyang@mxic.com.tw
Cc: boris.brezillon@bootlin.com, broonie@kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Simon Horman <horms@verge.net.au>,
juliensu@mxic.com.tw, linux-kernel@vger.kernel.org,
linux-renesas-soc@vger.kernel.org, linux-spi@vger.kernel.org,
tpiepho@impinj.com, zhengxunli@mxic.com.tw
Subject: Re: [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver
Date: Tue, 20 Nov 2018 14:09:05 +0100 [thread overview]
Message-ID: <6b024f18-d0bc-3e65-f07c-cef913f795ab@gmail.com> (raw)
In-Reply-To: <OF4FAD10C5.F4F6D29B-ON4825834B.001FAB40-4825834B.00289635@mxic.com.tw>
On 11/20/2018 08:23 AM, masonccyang@mxic.com.tw wrote:
> Hi Marek,
Hi,
>> Marek Vasut <marek.vasut@gmail.com>
>> 2018/11/19 下午 10:12
>>
>> To
>>
>> > +
>> > +static int rpc_spi_set_freq(struct rpc_spi *rpc, unsigned long freq)
>> > +{
>> > + int ret;
>> > +
>> > + if (rpc->cur_speed_hz == freq)
>> > + return 0;
>> > +
>> > + clk_disable_unprepare(rpc->clk_rpc);
>> > + ret = clk_set_rate(rpc->clk_rpc, freq);
>> > + if (ret)
>> > + return ret;
>> > +
>> > + ret = clk_prepare_enable(rpc->clk_rpc);
>> > + if (ret)
>> > + return ret;
>>
>> Is this clock disable/update/enable really needed ? I'd think that
>> clk_set_rate() would handle the rate update correctly.
>
> This is for run time PM mechanism in spi-mem layer and __spi_sync(),
> you may refer to another patch [1].
>
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/commit/?h=for-4.21&id=b942d80b0a394e8ea18fce3b032b4700439e8ca3
I think Geert commented on the clock topic, so let's move it there.
Disabling and enabling clock to change their rate looks real odd to me.
>> > + rpc->cur_speed_hz = freq;
>> > + return ret;
>> > +}
>> > +
>> > +static void rpc_spi_hw_init(struct rpc_spi *rpc)
>> > +{
>> > + /*
>> > + * NOTE: The 0x260 are undocumented bits, but they must be set.
>> > + */
>>
>> FYI:
>>
> http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/spi/renesas_rpc_spi.c#l207
>>
>> I think the STRTIM should be 6 .
>>
>
> In my D3 Draak board, the STRTIM is 0x3 for on board qspi flash and
> mx25uw51245g.
> And this is also refer to Renesas R-Car Gen3 bare-metal code,
> mini-monitor v4.01.
The copy of minimon I have says 6 , but maybe this is flash specific ?
[...]
>> > + writel(rpc->cmd, rpc->regs + RPC_SMCMR);
>> > + writel(rpc->dummy, rpc->regs + RPC_SMDMCR);
>> > + writel(rpc->addr + pos, rpc->regs + RPC_SMADR);
>> > + writel(rpc->smenr, rpc->regs + RPC_SMENR);
>> > + writel(rpc->smcr | RPC_SMCR_SPIE, rpc->regs + RPC_SMCR);
>> > + ret = wait_msg_xfer_end(rpc);
>> > + if (ret)
>> > + goto out;
>> > +
>> > + data = readl(rpc->regs + RPC_SMRDR0);
>> > + memcpy_fromio(rx_buf + pos, (void *)&data, nbytes);
>> > + pos += nbytes;
>> > + }
>> > + } else {
>> > + writel(rpc->cmd, rpc->regs + RPC_SMCMR);
>> > + writel(rpc->dummy, rpc->regs + RPC_SMDMCR);
>> > + writel(rpc->addr + pos, rpc->regs + RPC_SMADR);
>> > + writel(rpc->smenr, rpc->regs + RPC_SMENR);
>> > + writel(rpc->smcr | RPC_SMCR_SPIE, rpc->regs + RPC_SMCR);
>> > + ret = wait_msg_xfer_end(rpc);
>> > + }
>> > +out:
>>
>> Dont you need to stop the RPC somehow in case the transmission fails ?
>
> It seems there is no any RPC registers bit to monitor xfer fail !
What happens if wait_msg_xfer_end() returns non-zero ? I guess that
means the transfer timed out ?
[...]
>> > +static const struct of_device_id rpc_spi_of_ids[] = {
>> > + { .compatible = "renesas,rpc-r8a77995", },
>> > + { /* sentinel */ }
>> > +};
>> > +MODULE_DEVICE_TABLE(of, rpc_spi_of_ids);
>> > +
>> > +static struct platform_driver rpc_spi_driver = {
>> > + .probe = rpc_spi_probe,
>> > + .remove = rpc_spi_remove,
>> > + .driver = {
>> > + .name = "rpc-spi",
>> > + .of_match_table = rpc_spi_of_ids,
>> > + .pm = &rpc_spi_dev_pm_ops,
>> > + },
>> > +};
>> > +module_platform_driver(rpc_spi_driver);
>> > +
>> > +MODULE_AUTHOR("Mason Yang <masonccyang@mxic.com.tw>");
>> > +MODULE_DESCRIPTION("Renesas R-Car D3 RPC SPI controller driver");
>>
>> This is not D3 specific and not SPI-only controller btw.
>
> In R-Car Gen3, there are some registers(i.e,. RPC_PHYCNT) in different
> setting
> for R-Car H3, M3-W, V3M, V3H, D3, M3-N and E3 model.
>
> I test this patch is based on D3 Draak board, it works fine but I am not
> sure
> if these registers setting is ok for others R-Card model.
>
> I think this could be a reference when patch others Gen3 model is needed.
You can take a look into the U-Boot driver(s) I linked, that's used on
the other SoCs you listed (except for V3H).
--
Best regards,
Marek Vasut
next prev parent reply other threads:[~2018-11-20 13:09 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 10:01 [PATCH 0/2] spi: Add Renesas R-Car D3 RPC SPI driver Mason Yang
2018-11-19 10:01 ` [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver Mason Yang
2018-11-19 14:12 ` Marek Vasut
2018-11-19 15:27 ` Mark Brown
2018-11-19 22:10 ` Marek Vasut
2018-11-20 13:26 ` Mark Brown
2018-11-20 13:33 ` Marek Vasut
[not found] ` <OF4FAD10C5.F4F6D29B-ON4825834B.001FAB40-4825834B.00289635@mxic.com.tw>
2018-11-20 13:09 ` Marek Vasut [this message]
2018-11-20 13:32 ` Boris Brezillon
2018-11-20 13:35 ` Marek Vasut
[not found] ` <OF5B1A3AE4.2DEECF37-ON4825834E.00031E97-4825834E.00042D72@mxic.com.tw>
2018-11-23 13:34 ` Marek Vasut
2018-11-20 2:04 ` kbuild test robot
2018-11-20 5:49 ` kbuild test robot
2018-11-20 8:01 ` Geert Uytterhoeven
2018-11-20 8:10 ` Boris Brezillon
2018-11-19 10:01 ` [PATCH 2/2] dt-binding: spi: Document Renesas R-Car RPC controller bindings Mason Yang
2018-11-19 13:49 ` Marek Vasut
2018-11-19 14:10 ` Boris Brezillon
2018-11-19 14:14 ` Marek Vasut
2018-11-19 14:43 ` Boris Brezillon
2018-11-19 15:12 ` Marek Vasut
2018-11-19 15:21 ` Boris Brezillon
2018-11-19 22:11 ` Marek Vasut
2018-11-19 22:19 ` Boris Brezillon
2018-11-19 22:22 ` Marek Vasut
2018-11-19 22:25 ` Boris Brezillon
2018-11-19 22:29 ` Marek Vasut
2018-11-19 22:31 ` Boris Brezillon
[not found] ` <OFDD04CD59.10199EDD-ON4825834B.001E1390-4825834B.001F65DD@mxic.com.tw>
2018-11-20 12:57 ` Marek Vasut
[not found] ` <OF26D8352D.B4B02BBE-ON4825834C.00043726-4825834C.0004E2F7@mxic.com.tw>
2018-11-21 1:51 ` Marek Vasut
2018-11-20 8:07 ` Geert Uytterhoeven
2018-11-20 13:56 ` kbuild test robot
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=6b024f18-d0bc-3e65-f07c-cef913f795ab@gmail.com \
--to=marek.vasut@gmail.com \
--cc=boris.brezillon@bootlin.com \
--cc=broonie@kernel.org \
--cc=geert+renesas@glider.be \
--cc=horms@verge.net.au \
--cc=juliensu@mxic.com.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=masonccyang@mxic.com.tw \
--cc=tpiepho@impinj.com \
--cc=zhengxunli@mxic.com.tw \
/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
all inboxes | Powered by JetHome®