spi: Add Renesas R-Car Gen3 RPC-IF SPI driver
Subsystems (2)
v5 cover spi: Add Renesas R-Car Gen3 RPC-IF SPI driver
Hi Mark,
This Renesas R-Car Gen3 RPC-IF SPI driver is based on Boris's new spi-mem direct mapping read/write mode [1][2].
v5 patch is accroding to Sergei's comments:
1) Read 6 bytes ID from Sergei's patch.
2) regmap_update_bits()
3) C++ style comment
v4 patch is according to Sergei's comments including:
1) Drop soc_device_match()
2) Drop unused RPC registers
3) Use ilog2() instead of fls()
4) Patch read 6 bytes ID w/ one command.
5) Coding style and so on.
v3 patch is according to Marek and Geert's comments including:
1) soc_device_mach() to set up RPC_PHYCNT_STRTIM.
2) get_unaligned()
3) rpc-mode for rpi-spi-flash or rpc-hyperflash.
4) coding style and so on.
v2 patch including:
1) remove RPC clock enable/dis-able control,
2) patch run time PM,
3) add RPC module software reset,
4) add regmap,
5) other coding style and so on.
thanks for your review.
best regards,
Mason
[1] https://patchwork.kernel.org/patch/10670753
[2] https://patchwork.kernel.org/patch/10670747
Mason Yang (2):
spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
dt-bindings: spi: Document Renesas R-Car RPC-IF controller bindings
.../devicetree/bindings/spi/spi-renesas-rpc.txt | 37 + drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/spi-renesas-rpc.c | 787 +++++++++++++++++++++ 4 files changed, 831 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt create mode 100644 drivers/spi/spi-renesas-rpc.c
Signature · 1 line
1.9.1
PATCH v5 1/2 spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
--- drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/spi-renesas-rpc.c | 787 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 794 insertions(+) create mode 100644 drivers/spi/spi-renesas-rpc.c
drivers/spi/Kconfig +6 -0
@@ -544,6 +544,12 @@ config SPI_RSPI help SPI driver for Renesas RSPI and QSPI blocks. +config SPI_RENESAS_RPC_IF + tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TEST + help + SPI driver for Renesas R-Car Gen3 RPC-IF. + config SPI_QCOM_QSPI tristate "QTI QSPI controller" depends on ARCH_QCOM
drivers/spi/Makefile +1 -0
@@ -84,6 +84,7 @@ obj-$(CONFIG_SPI_QUP) += spi-qup.o obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o obj-$(CONFIG_SPI_RB4XX) += spi-rb4xx.o obj-$(CONFIG_SPI_RSPI) += spi-rspi.o +obj-$(CONFIG_SPI_RENESAS_RPC_IF) += spi-renesas-rpc.o obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o spi-s3c24xx-hw-y := spi-s3c24xx.o spi-s3c24xx-hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi-s3c24xx-fiq.o
drivers/spi/spi-renesas-rpc.c new file +787 -0
787 lines not on this page · raw message
Signature · 1 line
1.9.1
kbuild test robot
build botRe: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Thank you for the patch! Yet something to improve:
Hi Mason,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on spi/for-next]
[also build test ERROR on v5.0-rc1 next-20190108]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Mason-Yang/spi-Add-Renesas-R-Car-Gen3-RPC-IF-SPI-controller-driver/20190108-165354 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next config: nds32-allyesconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 6.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=6.4.0 make.cross ARCH=nds32
All errors (new ones prefixed by >>):
drivers/spi/spi-renesas-rpc.c: In function 'rpc_spi_io_xfer':
>> drivers/spi/spi-renesas-rpc.c:285:10: error: implicit declaration of function 'readq' [-Werror=implicit-function-declaration]
tmp = readq(rpc->dirmap);
^~~~~cc1: some warnings being treated as errors
vim +/readq +285 drivers/spi/spi-renesas-rpc.c
222
223 static int rpc_spi_io_xfer(struct rpc_spi *rpc,
224 const void *tx_buf, void *rx_buf)
225 {
226 u32 smenr, smcr, data, pos = 0;
227 int ret = 0;
228
229 regmap_update_bits(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD, RPC_CMNCR_MD);
230 regmap_write(rpc->regmap, RPC_SMDRENR, 0);
231 regmap_write(rpc->regmap, RPC_SMCMR, rpc->cmd);
232 regmap_write(rpc->regmap, RPC_SMDMCR, rpc->dummy);
233 regmap_write(rpc->regmap, RPC_SMADR, rpc->addr);
234 smenr = rpc->smenr;
235
236 if (tx_buf) {
237 while (pos < rpc->xferlen) {
238 u32 nbytes = rpc->xferlen - pos;
239
240 regmap_write(rpc->regmap, RPC_SMWDR0,
241 get_unaligned((u32 *)(tx_buf + pos)));
242
243 smcr = rpc->smcr | RPC_SMCR_SPIE;
244
245 if (nbytes > 4) {
246 nbytes = 4;
247 smcr |= RPC_SMCR_SSLKP;
248 }
249
250 regmap_write(rpc->regmap, RPC_SMENR, smenr);
251 regmap_write(rpc->regmap, RPC_SMCR, smcr);
252 ret = wait_msg_xfer_end(rpc);
253 if (ret)
254 goto out;
255
256 pos += nbytes;
257 smenr = rpc->smenr & ~RPC_SMENR_CDE &
258 ~RPC_SMENR_ADE(0xf);
259 }
260 } else if (rx_buf) {
261 //
262 // RPC-IF spoils the data for the commands without an address
263 // phase (like RDID) in the manual mode, so we'll have to work
264 // around this issue by using the external address space read
265 // mode instead; we seem to be able to read 8 bytes at most in
266 // this mode though...
267 //
268 if (!(smenr & RPC_SMENR_ADE(0xf))) {
269 u32 nbytes = rpc->xferlen - pos;
270 u64 tmp;
271
272 if (nbytes > 8)
273 nbytes = 8;
274
275 regmap_update_bits(rpc->regmap, RPC_CMNCR,
276 RPC_CMNCR_MD, 0);
277 regmap_write(rpc->regmap, RPC_DRCR, 0);
278 regmap_write(rpc->regmap, RPC_DREAR, RPC_DREAR_EAC(1));
279 regmap_write(rpc->regmap, RPC_DRCMR, rpc->cmd);
280 regmap_write(rpc->regmap, RPC_DRDMCR, rpc->dummy);
281 regmap_write(rpc->regmap, RPC_DROPR, 0);
282 regmap_write(rpc->regmap, RPC_DRENR, rpc->smenr &
283 ~RPC_SMENR_SPIDE(0xf));
284
> 285 tmp = readq(rpc->dirmap);
286 memcpy(rx_buf, &tmp, nbytes);
287 } else {
288 while (pos < rpc->xferlen) {
289 u32 nbytes = rpc->xferlen - pos;
290
291 if (nbytes > 4)
292 nbytes = 4;
293
294 regmap_write(rpc->regmap, RPC_SMENR, smenr);
295 regmap_write(rpc->regmap, RPC_SMCR, rpc->smcr |
296 RPC_SMCR_SPIE);
297 ret = wait_msg_xfer_end(rpc);
298 if (ret)
299 goto out;
300
301 regmap_read(rpc->regmap, RPC_SMRDR0, &data);
302 memcpy(rx_buf + pos, &data, nbytes);
303 pos += nbytes;
304
305 regmap_write(rpc->regmap, RPC_SMADR,
306 rpc->addr + pos);
307 }
308 }
309 } else {
310 regmap_write(rpc->regmap, RPC_SMENR, rpc->smenr);
311 regmap_write(rpc->regmap, RPC_SMCR, rpc->smcr | RPC_SMCR_SPIE);
312 ret = wait_msg_xfer_end(rpc);
313 if (ret)
314 goto out;
315 }
316
317 return ret;
318
319 out:
320 return reset_control_reset(rpc->rstc);
321 }
322
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
In reply to Mason YangHi Mason,
Quoted 3 lines · Mason Yang
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>
Thanks for your patch!
drivers/spi/spi-renesas-rpc.c line 327
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +5
-0+static void rpc_spi_mem_set_prep_op_cfg (struct spi_device *spi, +const struct spi_mem_op *op, +u64 *offs,size_t *len) +{ +struct rpc_spi *rpc =spi_master_get_devdata (spi->master);
spi_controller_get_devdata(), for new code.
drivers/spi/spi-renesas-rpc.c line 399
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +8
-0+static ssize_t rpc_spi_mem_dirmap_read (struct spi_mem_dirmap_desc *desc, +u64 offs,size_t len,void *buf) +{ +struct rpc_spi *rpc =spi_master_get_devdata (desc->mem->spi->master); +int ret; + +if (WARN_ON (offs + desc->info.offset + len >U32_MAX )) +return -EINVAL ;
Why do you need a WARN_ON()?
drivers/spi/spi-renesas-rpc.c line 402
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+ +if (WARN_ON (len >0x4000000 )) + len =0x4000000 ;
Please drop the WARN_ON(), as this is normal behavior, cfr.:
* @dirmap_write: write data to the memory device using the direct mapping
* created by ->dirmap_create(). The function can return less * data than requested (for example when the request is crossing * the currently mapped area), and the caller of * spi_mem_dirmap_write() is responsible for calling it again in * this case.
drivers/spi/spi-renesas-rpc.c line 433
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +8
-0+static ssize_t rpc_spi_mem_dirmap_write (struct spi_mem_dirmap_desc *desc, +u64 offs,size_t len,const void *buf) +{ +struct rpc_spi *rpc =spi_master_get_devdata (desc->mem->spi->master); +int ret; + +if (WARN_ON (offs + desc->info.offset + len >U32_MAX )) +return -EINVAL ;
Why do you need a WARN_ON()?
drivers/spi/spi-renesas-rpc.c line 436
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+ +if (WARN_ON (len >RPC_WBUF_SIZE )) + len =RPC_WBUF_SIZE ;
Please drop the WARN_ON().
drivers/spi/spi-renesas-rpc.c line 624
Quoted 12 lines
drivers/spi/spi-renesas-rpc.c new file +12
-0+static int rpc_spi_transfer_one_message (struct spi_master *master, +struct spi_message *msg) +{ +struct rpc_spi *rpc =spi_master_get_devdata (master); +struct spi_transfer *t; +int ret; + +rpc_spi_transfer_setup (rpc, msg); + +list_for_each_entry (t, &msg->transfers, transfer_list) { +if (!list_is_last (&t->transfer_list, &msg->transfers)) +continue ;
Can't you use list_last_entry(), to avoid having to loop over the whole list?
Quoted 5 lines
drivers/spi/spi-renesas-rpc.c new file +5
-0+ ret =rpc_spi_xfer_message (rpc, t); +if (ret) + goto out; + } +
drivers/spi/spi-renesas-rpc.c line 659
Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +9
-0+ msg->status =0 ; + msg->actual_length = rpc->totalxferlen; +out: +spi_finalize_current_message (master); +return 0 ; +} +static int rpc_spi_probe (struct platform_device *pdev) +{ +struct spi_master *master;
struct spi_controller, for new code.
Quoted 62 lines
drivers/spi/spi-renesas-rpc.c new file +62
-0+struct resource *res; +struct rpc_spi *rpc; +const struct regmap_config *regmap_config; +const char *mode; +int ret; + + ret =of_property_read_string (pdev->dev.of_node, +"renesas,rpc-mode" , &mode); +if (ret <0 ) +return ret; + +if (strcasecmp (mode,"spi" )) +return -ENODEV ; + + master =spi_alloc_master (&pdev->dev,sizeof (*rpc)); +if (!master) +return -ENOMEM ; + +platform_set_drvdata (pdev, master); + + rpc =spi_master_get_devdata (master); + + master->dev.of_node = pdev->dev.of_node; + + rpc->clk_rpc =devm_clk_get (&pdev->dev,"rpc" ); +if (IS_ERR (rpc->clk_rpc)) +return PTR_ERR (rpc->clk_rpc); + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"regs" ); + rpc->base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (rpc->base)) +return PTR_ERR (rpc->base); + + regmap_config = &rpc_spi_regmap_config; + rpc->regmap =devm_regmap_init_mmio (&pdev->dev, rpc->base, + regmap_config); +if (IS_ERR (rpc->regmap)) { +dev_err (&pdev->dev,"failed to init regmap %ld for rpc-spi\n" , +PTR_ERR (rpc->regmap)); +return PTR_ERR (rpc->regmap); + } + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dirmap" ); + rpc->dirmap =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (rpc->dirmap)) + rpc->dirmap =NULL ; + + rpc->rstc =devm_reset_control_get_exclusive (&pdev->dev,NULL ); +if (IS_ERR (rpc->rstc)) +return PTR_ERR (rpc->rstc); + +pm_runtime_enable (&pdev->dev); + master->auto_runtime_pm = true; + + master->num_chipselect =1 ; + master->mem_ops = &rpc_spi_mem_ops; + master->transfer_one_message = rpc_spi_transfer_one_message; + + master->bits_per_word_mask =SPI_BPW_MASK (8 ); + master->mode_bits =SPI_CPOL |SPI_CPHA |SPI_TX_QUAD |SPI_RX_QUAD ; + +rpc_spi_hw_init (rpc);
drivers/spi/spi-renesas-rpc.c line 731
Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10
-0+ + ret =spi_register_master (master); +if (ret) { +dev_err (&pdev->dev,"spi_register_master failed\n" ); + goto err_put_master; + } +return 0 ; + +err_put_master: +spi_master_put (master);
spi_controller_put(), for new code
drivers/spi/spi-renesas-rpc.c line 739
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +8
-0+pm_runtime_disable (&pdev->dev); + +return ret; +} + +static int rpc_spi_remove (struct platform_device *pdev) +{ +struct spi_master *master =platform_get_drvdata (pdev);
struct spi_controller
drivers/spi/spi-renesas-rpc.c line 742
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+ +pm_runtime_disable (&pdev->dev); +spi_unregister_master (master);
spi_unregister_controller()
Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +6
-0+ +return 0 ; +} + +static const struct of_device_id rpc_spi_of_ids[] = { + { .compatible ="renesas,r8a77995-rpc" , },
drivers/spi/spi-renesas-rpc.c line 758
Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10
-0+ {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, rpc_spi_of_ids); + +#ifdef CONFIG_PM_SLEEP +static int rpc_spi_suspend (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); + +return spi_master_suspend (master);
spi_controller_suspend()
drivers/spi/spi-renesas-rpc.c line 765
Quoted 7 lines
drivers/spi/spi-renesas-rpc.c new file +7
-0+} + +static int rpc_spi_resume (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); + +return spi_master_resume (master);
spi_controller_resume()
Quoted 1 line
+}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
In reply to Mason YangHello!
Quoted 3 lines · Mason Yang
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>
You now need to add:
Quoted 12 lines
--- drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/spi-renesas-rpc.c | 787 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 794 insertions(+) create mode 100644 drivers/spi/spi-renesas-rpc.cdrivers/spi/Kconfig +0
-0
drivers/spi/Kconfig config SPI_RSPI · line 547
Quoted 4 lines
drivers/spi/Kconfig +1
-0@@ -544,6 +544,12 @@ config SPI_RSPI help SPI driver for Renesas RSPI and QSPI blocks. +config SPI_RENESAS_RPC_IF
Since the driver is called without -IF suffix, I wouldn't use it in theKconfig name either, the following is enough:
drivers/spi/Kconfig config SPI_RSPI · line 549
Quoted 2 lines
drivers/spi/Kconfig +2
-0+ tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TEST
Judging on the compilation error reported by the 0-day bot about readq(),
we now need to depend on 64BIT or something...
[...]
Quoted 4 lines
drivers/spi/Makefile +0
-0
[...]
Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +0
-0@@ -0,0 +1,787 @@
[...]
drivers/spi/spi-renesas-rpc.c line 37
Quoted 11 lines
drivers/spi/spi-renesas-rpc.c new file +11
-0+#define RPC_CMNCR 0x0000 // R/W +#define RPC_CMNCR_MD BIT(31) +#define RPC_CMNCR_SFDE BIT(24) // undocumented bit but must be set +#define RPC_CMNCR_MOIIO3 (val) (((val) & 0x3) << 22) +#define RPC_CMNCR_MOIIO2 (val) (((val) & 0x3) << 20) +#define RPC_CMNCR_MOIIO1 (val) (((val) & 0x3) << 18) +#define RPC_CMNCR_MOIIO0 (val) (((val) & 0x3) << 16) +#define RPC_CMNCR_MOIIO_HIZ (RPC_CMNCR_MOIIO0(3) | RPC_CMNCR_MOIIO1(3) | \ + RPC_CMNCR_MOIIO2(3) | RPC_CMNCR_MOIIO3(3)) +#define RPC_CMNCR_IO3FV (val) (((val) & 0x3) << 14) // undocumented bit +#define RPC_CMNCR_IO2FV (val) (((val) & 0x3) << 12) // undocumented bit
Those are not exactly bits. I'd be happy with just // undocumented...
[...]
drivers/spi/spi-renesas-rpc.c line 144
Quoted 2 lines
drivers/spi/spi-renesas-rpc.c new file +2
-0+#define RPC_WBUF 0x8000 // Write Buffer +#define RPC_WBUF_SIZE 256 // Write Buffer size
I wonder if the write buffer should be in a separate "reg" prop tuple...
Have you considered that?
[...]
Quoted 13 lines
drivers/spi/spi-renesas-rpc.c new file +13
-0+static void rpc_spi_hw_init (struct rpc_spi *rpc) +{ +// +// NOTE: The 0x260 are undocumented bits, but they must be set. +// RPC_PHYCNT_STRTIM is strobe timing adjustment bit, +// 0x0 : the delay is biggest, +// 0x1 : the delay is 2nd biggest, +// On H3 ES1.x, the value should be 0, while on others, +// the value should be 6. +// +regmap_write (rpc->regmap,RPC_PHYCNT ,RPC_PHYCNT_CAL | +RPC_PHYCNT_STRTIM (6 ) |0x260 ); +
drivers/spi/spi-renesas-rpc.c line 200
Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10
-0+// +// NOTE: The 0x1511144 are undocumented bits, but they must be set +// for RPC_PHYOFFSET1. +// The 0x31 are undocumented bits, but they must be set +// for RPC_PHYOFFSET2. +// +regmap_write (rpc->regmap,RPC_PHYOFFSET1 , +RPC_PHYOFFSET1_DDRTMG (3 ) |0x1511144 ); +regmap_write (rpc->regmap,RPC_PHYOFFSET2 ,0x31 | +RPC_PHYOFFSET2_OCTTMG (4 ));
I still would have preferred using regmap_update_bits() here...
[...]
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+static int rpc_spi_io_xfer (struct rpc_spi *rpc, +const void *tx_buf,void *rx_buf) +{
[...]
Quoted 14 lines
drivers/spi/spi-renesas-rpc.c new file +14
-0+ }else if (rx_buf) { +// +// RPC-IF spoils the data for the commands without an address +// phase (like RDID) in the manual mode, so we'll have to work +// around this issue by using the external address space read +// mode instead; we seem to be able to read 8 bytes at most in +// this mode though... +// +if (!(smenr &RPC_SMENR_ADE (0xf ))) { +u32 nbytes = rpc->xferlen - pos; +u64 tmp; + +if (nbytes >8 ) + nbytes =8 ;
drivers/spi/spi-renesas-rpc.c line 283
Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10
-0+ +regmap_update_bits (rpc->regmap,RPC_CMNCR , +RPC_CMNCR_MD ,0 ); +regmap_write (rpc->regmap,RPC_DRCR ,0 ); +regmap_write (rpc->regmap,RPC_DREAR ,RPC_DREAR_EAC (1 )); +regmap_write (rpc->regmap,RPC_DRCMR , rpc->cmd); +regmap_write (rpc->regmap,RPC_DRDMCR , rpc->dummy); +regmap_write (rpc->regmap,RPC_DROPR ,0 ); +regmap_write (rpc->regmap,RPC_DRENR , rpc->smenr & + ~RPC_SMENR_SPIDE (0xf ));
The 'smenr' filed needs a more universal name -- it's written to both SMENR and DRENR?
drivers/spi/spi-renesas-rpc.c line 317
Quoted 9 lines
drivers/spi/spi-renesas-rpc.c new file +9
-0+ }else { +regmap_write (rpc->regmap,RPC_SMENR , rpc->smenr); +regmap_write (rpc->regmap,RPC_SMCR , rpc->smcr |RPC_SMCR_SPIE ); + ret =wait_msg_xfer_end (rpc); +if (ret) + goto out; + } + +return ret;
We always return 0 here...
drivers/spi/spi-renesas-rpc.c
Quoted 2 lines
drivers/spi/spi-renesas-rpc.c new file +2
-0+ +out:
I'd call this label error, since this is our error path...
Quoted 7 lines
drivers/spi/spi-renesas-rpc.c new file +7
-0+return reset_control_reset (rpc->rstc); +} + +static void rpc_spi_mem_set_prep_op_cfg (struct spi_device *spi, +const struct spi_mem_op *op, +u64 *offs,size_t *len) +{
[...]
drivers/spi/spi-renesas-rpc.c line 364
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +8
-0+if (op->data.nbytes || (offs && len)) { +if (op->data.dir ==SPI_MEM_DATA_IN ) { + rpc->smcr =RPC_SMCR_SPIRE ; + rpc->xfer_dir =SPI_MEM_DATA_IN ; + }else if (op->data.dir ==SPI_MEM_DATA_OUT ) { + rpc->smcr =RPC_SMCR_SPIWE ; + rpc->xfer_dir =SPI_MEM_DATA_OUT ; + }
I asked for *switch* above...
[...]
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+static ssize_t rpc_spi_mem_dirmap_write (struct spi_mem_dirmap_desc *desc, +u64 offs,size_t len,const void *buf) +{
[...]
drivers/spi/spi-renesas-rpc.c line 449
Quoted 5 lines
drivers/spi/spi-renesas-rpc.c new file +5
-0+regmap_update_bits (rpc->regmap,RPC_CMNCR ,RPC_CMNCR_MD ,RPC_CMNCR_MD ); + +regmap_write (rpc->regmap,RPC_SMDRENR ,0 ); +regmap_write (rpc->regmap,RPC_PHYCNT ,RPC_PHYCNT_CAL |0x260 | +RPC_PHYCNT_WBUF2 |RPC_PHYCNT_WBUF );
regmap_update_bits()?
Quoted 4 lines
drivers/spi/spi-renesas-rpc.c new file +4
-0+ +memcpy_toio (rpc->base +RPC_WBUF , buf, len); + +regmap_write (rpc->regmap,RPC_SMCMR , rpc->cmd);
drivers/spi/spi-renesas-rpc.c line 463
Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10
-0+regmap_write (rpc->regmap,RPC_SMADR , offs); +regmap_write (rpc->regmap,RPC_SMENR , rpc->smenr); +regmap_write (rpc->regmap,RPC_SMCR , rpc->smcr |RPC_SMCR_SPIE ); + ret =wait_msg_xfer_end (rpc); +if (ret) + goto out; + +regmap_write (rpc->regmap,RPC_DRCR ,RPC_DRCR_RCF ); +regmap_write (rpc->regmap,RPC_PHYCNT ,RPC_PHYCNT_CAL | +RPC_PHYCNT_STRTIM (6 ) |0x260 );
Same here...
drivers/spi/spi-renesas-rpc.c line 467
Quoted 4 lines
drivers/spi/spi-renesas-rpc.c new file +4
-0+ +return len; + +out:
error:
drivers/spi/spi-renesas-rpc.c
Quoted 2 lines
drivers/spi/spi-renesas-rpc.c new file +2
-0+return reset_control_reset (rpc->rstc); +}
[...]
MBR, Sergei
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Hi Sergei,
Quoted 20 lines · Sergei Shtylyov
Quoted 3 lines · Mason Yang
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>You now need to add:
Signed-off-by Sergei Shtylyov <[email protected]>drivers/spi/Kconfig config SPI_RSPI · line 547
Quoted 7 lines
drivers/spi/Kconfig +1
-0@@ -544,6 +544,12 @@ config SPI_RSPI help SPI driver for Renesas RSPI and QSPI blocks. +config SPI_RENESAS_RPC_IFSince the driver is called without -IF suffix, I wouldn't use it in the
Kconfigname either, the following is enough:
Quoted 5 lines
drivers/spi/Kconfig config SPI_RSPI · line 549
Quoted 2 lines
drivers/spi/Kconfig +2
-0+ tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TESTJudging on the compilation error reported by the 0-day bot about
readq(),
we now need to depend on 64BIT or something...
IIRC, this hardware block is also used on RZ/A, which is 32-bit.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Quoted 19 lines · Geert Uytterhoeven
Quoted 19 lines
Quoted 3 lines
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>You now need to add:
Signed-off-by Sergei Shtylyov <[email protected]>drivers/spi/Kconfig config SPI_RSPI · line 547
Quoted 7 lines
drivers/spi/Kconfig +1
-0@@ -544,6 +544,12 @@ config SPI_RSPI help SPI driver for Renesas RSPI and QSPI blocks. +config SPI_RENESAS_RPC_IFSince the driver is called without -IF suffix, I wouldn't use it in the
Kconfigname either, the following is enough:
Quoted 7 lines
Quoted 5 lines
drivers/spi/Kconfig config SPI_RSPI · line 549
Quoted 2 lines
drivers/spi/Kconfig +2
-0+ tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TESTJudging on the compilation error reported by the 0-day bot about
readq(),
we now need to depend on 64BIT or something...IIRC, this hardware block is also used on RZ/A, which is 32-bit.
I'm not seeing it in the "RZ/A1H Group, RZ/A1M Group User’s Manual: Hardware"
Rev 3.00. What SoC did you have in mind?
Quoted 3 lines
Gr{oetje,eeting}s,
Geert
MBR, Sergei
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Quoted 24 lines · Sergei Shtylyov
Quoted 22 lines · Geert Uytterhoeven
Quoted 22 lines
Quoted 3 lines
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>You now need to add:
Signed-off-by Sergei Shtylyov <[email protected]>drivers/spi/Kconfig config SPI_RSPI · line 547
Quoted 7 lines
drivers/spi/Kconfig +1
-0@@ -544,6 +544,12 @@ config SPI_RSPI help SPI driver for Renesas RSPI and QSPI blocks. +config SPI_RENESAS_RPC_IFSince the driver is called without -IF suffix, I wouldn't use it in the
Kconfigname either, the following is enough:Quoted 2 lines
drivers/spi/Kconfig +2
-0+ tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TEST
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Judging on the compilation error reported by the 0-day bot about
readq(),
we now need to depend on 64BIT or something...IIRC, this hardware block is also used on RZ/A, which is 32-bit.
I'm not seeing it in the "RZ/A1H Group, RZ/A1M Group User’s Manual: Hardware"
Rev 3.00. What SoC did you have in mind?
At least the GR Peach boots from this block, so that one :)
Signature · 2 lines
Best regards, Marek Vasut
RE: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
In reply to Sergei ShtylyovQuoted 5 lines · Sergei Shtylyov
Quoted 1 line
IIRC, this hardware block is also used on RZ/A, which is 32-bit.
I'm not seeing it in the "RZ/A1H Group, RZ/A1M Group User’s Manual:
Hardware"
Rev 3.00. What SoC did you have in mind?
For the RZ/A series (and RZ/T series), it is called the "SPI Multi I/O Bus Controller" (Chapter 17)
I have no idea why it has a different name for the same hardware (and the same pages in the manual).
The HW version in RZ/A1 does not have HyperRAM.
But the HW version in RZ/A2 is the same as what is in R-Car Gen3.
Chris
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
In reply to Sergei ShtylyovQuoted 9 lines · On Wed, 9 Jan 2019 21:47:48 +0300 Sergei Shtylyov…
Quoted 3 lines · Mason Yang
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>You now need to add:
Signed-off-by Sergei Shtylyov <[email protected]>
May I ask why?
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Quoted 9 lines · Boris Brezillon
Quoted 7 lines
Quoted 3 lines
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.
Signed-off-by Mason Yang <[email protected]>You now need to add:
Signed-off-by Sergei Shtylyov <[email protected]>May I ask why?
v5 includes my signed read mode workaround patch.
MBR, Sergei
A message that is not in the archive (sent off-list or not yet received): OFBBA60D64.FFD34553-ON48258384.00315BB0-48258384.0034A5C7@mxic.com.tw
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
On 01/16/2019 12:35 PM, [email protected] wrote:
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/Kconfig +0
-0
[...]
Quoted 9 lines
Quoted 6 lines
drivers/spi/Kconfig config SPI_RSPI · line 549
Quoted 3 lines
drivers/spi/Kconfig +2
-0+ tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TESTJudging on the compilation error reported by the 0-day bot about
readq(),
we now need to depend on 64BIT or something...I have patched RPC external address space read mode and driver don't need
readq()now!
Good work, thank you!
Quoted 29 lines
Quoted 29 lines
[...]
Quoted 4 lines
drivers/spi/Makefile +0
-0[...]
Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +0
-0@@ -0,0 +1,787 @@[...]
drivers/spi/spi-renesas-rpc.c
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +8
-0+#define RPC_CMNCR 0x0000 // R/W +#define RPC_CMNCR_MD BIT(31) +#define RPC_CMNCR_SFDE BIT(24) // undocumented bit but must be set +#define RPC_CMNCR_MOIIO3 (val) (((val) & 0x3) << 22) +#define RPC_CMNCR_MOIIO2 (val) (((val) & 0x3) << 20) +#define RPC_CMNCR_MOIIO1 (val) (((val) & 0x3) << 18) +#define RPC_CMNCR_MOIIO0 (val) (((val) & 0x3) << 16) +#define RPC_CMNCR_MOIIO_HIZ (RPC_CMNCR_MOIIO0(3) |
RPC_CMNCR_MOIIO1(3)| \drivers/spi/spi-renesas-rpc.c line 37
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+ RPC_CMNCR_MOIIO2(3) | RPC_CMNCR_MOIIO3(3)) +#define RPC_CMNCR_IO3FV (val) (((val) & 0x3) << 14) // undocumented bit +#define RPC_CMNCR_IO2FV (val) (((val) & 0x3) << 12) // undocumented bitThose are not exactly bits. I'd be happy with just // undocumented...
[...]
Quoted 8 lines
Quoted 6 lines
drivers/spi/spi-renesas-rpc.c line 144
Quoted 2 lines
drivers/spi/spi-renesas-rpc.c new file +2
-0+#define RPC_WBUF 0x8000 // Write Buffer +#define RPC_WBUF_SIZE 256 // Write Buffer sizeI wonder if the write buffer should be in a separate "reg" prop tuple...
Have you considered that?I don't get your point!
I mean that the write buffer should be a separate "reg" property address/size tuple,
so that the RPC device has 3 memory resources. Our SPI driver used this scheme, and I like it.
Quoted 28 lines
Quoted 18 lines
[...]
Quoted 17 lines
drivers/spi/spi-renesas-rpc.c new file +17
-0+static void rpc_spi_hw_init (struct rpc_spi *rpc) +{ +// +// NOTE: The 0x260 are undocumented bits, but they must be set. +// RPC_PHYCNT_STRTIM is strobe timing adjustment bit, +// 0x0 : the delay is biggest, +// 0x1 : the delay is 2nd biggest, +// On H3 ES1.x, the value should be 0, while on others, +// the value should be 6. +// +regmap_write (rpc->regmap,RPC_PHYCNT ,RPC_PHYCNT_CAL | +RPC_PHYCNT_STRTIM (6 ) |0x260 ); + +// +// NOTE: The 0x1511144 are undocumented bits, but they must be set +// for RPC_PHYOFFSET1. +// The 0x31 are undocumented bits, but they must be set Quoted 9 lines
drivers/spi/spi-renesas-rpc.c line 200
Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +6
-0+// for RPC_PHYOFFSET2. +// +regmap_write (rpc->regmap,RPC_PHYOFFSET1 , +RPC_PHYOFFSET1_DDRTMG (3 ) |0x1511144 ); +regmap_write (rpc->regmap,RPC_PHYOFFSET2 ,0x31 | +RPC_PHYOFFSET2_OCTTMG (4 ));I still would have preferred using
regmap_update_bits()here...
Quoted 1 line
This is a
init()function to set up an initial value to registers.
Note that 0x31 is read only register value.
Quoted 33 lines
[...]
Quoted 23 lines
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+static int rpc_spi_io_xfer (struct rpc_spi *rpc, +const void *tx_buf,void *rx_buf) +{[...]
Quoted 19 lines
drivers/spi/spi-renesas-rpc.c new file +19
-0+ }else if (rx_buf) { +// +// RPC-IF spoils the data for the commands without an address +// phase (like RDID) in the manual mode, so we'll have to work +// around this issue by using the external address space read +// mode instead; we seem to be able to read 8 bytes at most in +// this mode though... +// +if (!(smenr &RPC_SMENR_ADE (0xf ))) { +u32 nbytes = rpc->xferlen - pos; +u64 tmp; + +if (nbytes >8 ) + nbytes =8 ; + +regmap_update_bits (rpc->regmap,RPC_CMNCR , +RPC_CMNCR_MD ,0 ); +regmap_write (rpc->regmap,RPC_DRCR ,0 ); +regmap_write (rpc->regmap,RPC_DREAR ,RPC_DREAR_EAC (1 ));Quoted 8 lines
drivers/spi/spi-renesas-rpc.c line 283
Quoted 5 lines
drivers/spi/spi-renesas-rpc.c new file +5
-0+regmap_write (rpc->regmap,RPC_DRCMR , rpc->cmd); +regmap_write (rpc->regmap,RPC_DRDMCR , rpc->dummy); +regmap_write (rpc->regmap,RPC_DROPR ,0 ); +regmap_write (rpc->regmap,RPC_DRENR , rpc->smenr & + ~RPC_SMENR_SPIDE (0xf ));The 'smenr' filed needs a more universal name -- it's written to
both SMENR and DRENR?
Quoted 1 line
I think it's ok because their bits are compatible.
Not quite, the LSBs are not compatible, as you can see from the code above.
I'd suggest smth like 'enr' or 'enable'...
Quoted 9 lines
I patch external address space read mode as follows and don't need u64,
readq().
----------------------------------------------------------------
//
// RPC-IF spoils the data for the commands without an address // phase (like RDID) in the manual mode, so we'll have to work // around this issue by using the external address space read // mode instead.
//
Quoted 5 lines
if (!(smenr & RPC_SMENR_ADE(0xf))) {
regmap_update_bits(rpc->regmap, RPC_CMNCR,
RPC_CMNCR_MD, 0);
regmap_write(rpc->regmap, RPC_DRCR,
RPC_DRCR_RBURST(32) | RPC_DRCR_RBE);So the burst mode was the key?
Quoted 11 lines
regmap_write(rpc->regmap, RPC_DREAR, RPC_DREAR_EAC(1)); regmap_write(rpc->regmap, RPC_DRCMR, rpc->cmd); regmap_write(rpc->regmap, RPC_DRDMCR, rpc->dummy); regmap_write(rpc->regmap, RPC_DROPR, 0); regmap_write(rpc->regmap, RPC_DRENR, smenr); memcpy_fromio(rx_buf, rpc->dirmap, rpc->xferlen); regmap_write(rpc->regmap, RPC_DRCR, RPC_DRCR_RCF); } else {---------------------------------------------------------------
you may test it on your side.
It works!
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
drivers/spi/spi-renesas-rpc.c new file +9
-0+ }else { +regmap_write (rpc->regmap,RPC_SMENR , rpc->smenr); +regmap_write (rpc->regmap,RPC_SMCR , rpc->smcr |RPC_SMCR_SPIE ); + ret =wait_msg_xfer_end (rpc); +if (ret) + goto out; + } + +return ret;
Quoted 6 lines
Quoted 1 line
We always return 0 here...
you mean driver just
return 0;
rather than
return ret;
Yep.
[...]
Quoted 34 lines
Quoted 17 lines
Quoted 7 lines
drivers/spi/spi-renesas-rpc.c new file +7
-0+return reset_control_reset (rpc->rstc); +} + +static void rpc_spi_mem_set_prep_op_cfg (struct spi_device *spi, +const struct spi_mem_op *op, +u64 *offs,size_t *len) +{[...]
drivers/spi/spi-renesas-rpc.c line 364
Quoted 8 lines
drivers/spi/spi-renesas-rpc.c new file +8
-0+if (op->data.nbytes || (offs && len)) { +if (op->data.dir ==SPI_MEM_DATA_IN ) { + rpc->smcr =RPC_SMCR_SPIRE ; + rpc->xfer_dir =SPI_MEM_DATA_IN ; + }else if (op->data.dir ==SPI_MEM_DATA_OUT ) { + rpc->smcr =RPC_SMCR_SPIWE ; + rpc->xfer_dir =SPI_MEM_DATA_OUT ; + }Quoted 2 lines
I asked for *switch* above...
okay, patch it to:
------------------------------
switch (op->data.dir) {
caseSPI_MEM_DATA_IN:rpc->smcr = RPC_SMCR_SPIRE; rpc->xfer_dir = SPI_MEM_DATA_IN; break; case SPI_MEM_DATA_OUT: rpc->smcr = RPC_SMCR_SPIWE; rpc->xfer_dir = SPI_MEM_DATA_OUT; break; default: break; }
Quoted 1 line
-------------------------------
Thanks.
Quoted 12 lines
Quoted 12 lines
[...]
Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3
-0+static ssize_t rpc_spi_mem_dirmap_write (struct spi_mem_dirmap_desc *desc, +u64 offs,size_t len,const void *buf) +{[...]
Quoted 5 lines
drivers/spi/spi-renesas-rpc.c new file +5
-0+regmap_update_bits (rpc->regmap,RPC_CMNCR ,RPC_CMNCR_MD ,RPC_CMNCR_MD ); + +regmap_write (rpc->regmap,RPC_SMDRENR ,0 ); +regmap_write (rpc->regmap,RPC_PHYCNT ,RPC_PHYCNT_CAL |0x260 | +RPC_PHYCNT_WBUF2 |RPC_PHYCNT_WBUF );
Quoted 8 lines
Quoted 1 line
regmap_update_bits()?if so, call
regmap_update_bots()twice!!
regmap_update_bits(rpc->regmap, RPC_PHYCNT, RPC_PHYCNT_STRTIM(7), 0); regmap_update_bits(rpc->regmap,RPC_PHYCNT,
RPC_PHYCNT_WBUF2|RPC_PHYCNT_WBUF,RPC_PHYCNT_WBUF2|RPC_PHYCNT_WBUF);
Duplicate line here? And you can do both in 1 go, I think.
Quoted 6 lines
performance and code size!
is it better ?best regards,
Mason
MBR, Sergei
A message that is not in the archive (sent off-list or not yet received): OFFCBB6F75.77BB80DE-ON48258385.0020045C-48258385.0023EF3B@mxic.com.tw
Re: [PATCH v5 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Hi Mason,
Quoted 20 lines · On Thu, Jan 17, 2019 at 7:32 AM <[email protected]> wrote:
Quoted 11 lines
"Sergei Shtylyov" <[email protected]> 2019/01/17 上午 03:36
Quoted 9 lines
Quoted 8 lines
[...]
drivers/spi/spi-renesas-rpc.c line 144
Quoted 2 lines
drivers/spi/spi-renesas-rpc.c new file +2
-0+#define RPC_WBUF 0x8000 // Write Buffer +#define RPC_WBUF_SIZE 256 // Write Buffer sizeI wonder if the write buffer should be in a separate "reg" prop tuple...
Have you considered that?Quoted 8 lines
Quoted 1 line
I don't get your point!
I mean that the write buffer should be a separate "reg" property
address/size tuple,
so that the RPC device has 3 memory resources. Our SPI driver used this scheme, and I
like it.
Quoted 5 lines
I got your point but I think this RPC_WBUF@0xEE20_8000 is in the same group and it's size only 256 bytes, not like external address space read mode @0x0800_0000 w/ 64K bytes.
Maybe Geert or Marek could comment on it, thanks.
Given the writer buffer is separate from the other registers (it's in a different
4 KiB page, and thus may be at a different offset on future SoCs), and not present on RZ/A1, I think it's a good idea to use a separate reg entry for it.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH v5 2/2 dt-bindings: spi: Document Renesas R-Car RPC-IF controller bindings
In reply to Mason YangDocument the bindings used by the Renesas R-Car Gen3 RPC-IF controller.
--- .../devicetree/bindings/spi/spi-renesas-rpc.txt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +37 -0
@@ -0,0 +1,37 @@ +Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings +---------------------------------------------------------- + +Required properties: +- compatible: should be "renesas,r8a77995-rpc" +- #address-cells: should be 1 +- #size-cells: should be 0 +- reg: should contain 2 entries, one for the registers and one for the direct + mapping area +- reg-names: should contain "regs" and "dirmap" +- clock-names: should contain "rpc" +- clocks: should contain 1 entries for the module's clock +- renesas,rpc-mode: should contain "spi" for rpc spi mode or + "hyperflash" for rpc hyperflash mode. + +Example: + + rpc: rpc@ee200000 { + compatible = "renesas,r8a77995-rpc"; + reg = <0 0xee200000 0 0x8100>, <0 0x08000000 0 0x4000000>; + reg-names = "regs", "dirmap"; + clocks = <&cpg CPG_MOD 917>; + power-domains = <&sysc R8A77995_PD_ALWAYS_ON>; + resets = <&cpg 917>; + clock-names = "rpc"; + renesas,rpc-mode = "spi"; + #address-cells = <1>; + #size-cells = <0>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + spi-tx-bus-width = <1>; + spi-rx-bus-width = <1>; + }; + };
Signature · 1 line
1.9.1
Re: [PATCH v5 2/2] dt-bindings: spi: Document Renesas R-Car RPC-IF controller bindings
Quoted 18 lines · Mason Yang
Document the bindings used by the Renesas R-Car Gen3 RPC-IF controller.
Signed-off-by Mason Yang <[email protected]>--- .../devicetree/bindings/spi/spi-renesas-rpc.txt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txtDocumentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +4
-0@@ -0,0 +1,37 @@ +Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings +---------------------------------------------------------- + +Required properties:
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt line 14
Quoted 10 lines
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +10
-0+- compatible: should be "renesas,r8a77995-rpc" +- #address-cells: should be 1 +- #size-cells: should be 0 +- reg: should contain 2 entries, one for the registers and one for the direct + mapping area +- reg-names: should contain "regs" and "dirmap" +- clock-names: should contain "rpc" +- clocks: should contain 1 entries for the module's clock +- renesas,rpc-mode: should contain "spi" for rpc spi mode or + "hyperflash" for rpc hyperflash mode.
Why do we need this property ? I believe it is possible to detect the configuration based on the type of child of the RPC node. If the driver was properly designed, it could well behave as either CFI NOR driver or SPI flash driver and all would be good, but it seems this is written with it being SPI flash driver only and once the HF mode would need to be added, it'd mean a tremendous undertaking to rework the entire driver.
Signature · 2 lines
Best regards, Marek Vasut
A message that is not in the archive (sent off-list or not yet received): OFD1D4749F.04B5A6A1-ON4825837E.00331D68-4825837E.00344CA0@mxic.com.tw
Re: [PATCH v5 2/2] dt-bindings: spi: Document Renesas R-Car RPC-IF controller bindings
Quoted 1 line · On 1/10/19 10:31 AM, [email protected] wrote:
Hi Marek,
Hi,
Quoted 33 lines
Quoted 25 lines
"Marek Vasut" <[email protected]>
2019/01/08 下午 08:06Review
Quoted 1 line
(quoted diff) +0
-0rpc.txt
b/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txtDocumentation/devicetree/bindings/spi/spi-renesas-rpc.txt line 8
Quoted 13 lines
new file mode 100644
index 0000000..5f96532Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +8
-0@@ -0,0 +1,37 @@ +Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings +---------------------------------------------------------- + +Required properties: +- compatible: should be "renesas,r8a77995-rpc" +- #address-cells: should be 1 +- #size-cells: should be 0 +- reg: should contain 2 entries, one for the registers and onefor the direct
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt line 14
Quoted 6 lines
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +6
-0+ mapping area +- reg-names: should contain "regs" and "dirmap" +- clock-names: should contain "rpc" +- clocks: should contain 1 entries for the module's clock +- renesas,rpc-mode: should contain "spi" for rpc spi mode or + "hyperflash" for rpc hyperflash mode.Quoted 7 lines
Why do we need this property ? I believe it is possible to detect the configuration based on the type of child of the RPC node. If the driver was properly designed, it could well behave as either CFI NOR driver or SPI flash driver and all would be good, but it seems this is written with it being SPI flash driver only and once the HF mode would need to be added, it'd mean a tremendous undertaking to rework the entire driver.
Quoted 4 lines
Except to check if there are any SPI NOR child nodes by "jedec,spi-nor" compatible, is any other way better ?
any suggestion is welcome.
That's the one. A MFD RPC driver can sanitize it's child nodes, verify that the config is valid and configure the RPC accordingly. All of the devices that can be connected to the RPC are either valid jedec-nor or CFI NOR (HF), so this should work fine.
Signature · 2 lines
Best regards, Marek Vasut
Re: [PATCH v5 2/2] dt-bindings: spi: Document Renesas R-Car RPC-IF controller bindings
In reply to Mason YangHi Mason,
Quoted 3 lines · Mason Yang
Document the bindings used by the Renesas R-Car Gen3 RPC-IF controller.
Signed-off-by Mason Yang <[email protected]>
Thanks for your patch!
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt line 5
Quoted 8 lines
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +5
-0@@ -0,0 +1,37 @@ +Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings +---------------------------------------------------------- + +Required properties: +- compatible: should be "renesas,r8a77995-rpc"
Would it make sense to have a family-specific fallback "renesas,rcar-gen3-rpc", bseides the SoC-specific compatible value? </[email protected]></[email protected]>
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt line 12
Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +7
-0+- #address-cells: should be 1 +- #size-cells: should be 0 +- reg: should contain 2 entries, one for the registers and one for the direct + mapping area +- reg-names: should contain "regs" and "dirmap" +- clock-names: should contain "rpc" +- clocks: should contain 1 entries for the module's clock
Doesn't the driver have a need to access the RPCD2 clock? At least on R-Car V3M, it needs to program the Divider Clock Register (DIVREG).
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt line 14
Quoted 2 lines
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +2
-0+- renesas,rpc-mode: should contain "spi" for rpc spi mode or + "hyperflash" for rpc hyperflash mode.
Can't this be derived from the flash subnode?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds