summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-rzv2m-csi.c
AgeCommit message (Collapse)AuthorFilesLines
2023-08-21spi: rzv2m-csi: switch to use devm_spi_alloc_host()Yang Yingliang1-1/+1
Switch to use modern name function devm_spi_alloc_host(). No functional changed. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20230818093154.1183529-16-yangyingliang@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-19spi: rzv2m-csi: Make use of device_set_nodeFabrizio Castro1-1/+3
Use device_set_node instead of assigning controller->dev.of_node directly because it also sets the firmware node. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230718192453.543549-5-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-19spi: rzv2m-csi: Get rid of the x_trg{_words} tablesFabrizio Castro1-18/+3
Table x_trg can be replaced with ilog2(), and table x_trg_words can be replaced with rounddown_pow_of_two(). Replace the tables usage with the corresponding macros. While at it, remove a couple of unnecessary empty lines. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20230718192453.543549-4-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-19spi: rzv2m-csi: Improve data types, casting and alignmentFabrizio Castro1-23/+23
"unsigned int" is more appropriate than "int" for the members of "struct rzv2m_csi_priv". Using void* rather than u8* for txbuf and rxbuf allows for the removal of some type casting. Remove the unnecessary casting of "data" to "struct rzv2m_csi_priv*" in function "rzv2m_csi_irq_handler". Also, members "bytes_per_word" and "errors" introduce gaps in the structure. Adjust "struct rzv2m_csi_priv" and its members usage accordingly. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20230718192453.543549-3-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-19spi: rzv2m-csi: Squash timing settings into one statementFabrizio Castro1-4/+3
Register CLKSEL hosts the configuration for both clock polarity and data phase, and both values can be set in one write operation. Squash the clock polarity and data phase register writes into one statement, for efficiency. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230718192453.543549-2-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17spi: rzv2m-csi: Replace unnecessary ternary operatorsFabrizio Castro1-2/+2
The ternary operators used to initialize tx_completed and rx_completed are not necessary, replace them with a better implementation. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230715010407.1751715-6-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17spi: rzv2m-csi: Leave readl_poll_timeout calls for lastFabrizio Castro1-11/+10
Both rzv2m_csi_sw_reset and rzv2m_csi_start_stop_operation call into readl_poll_timeout upon a certain condition, and return 0 otherwise. Flip the logic to improve readability. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230715010407.1751715-5-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17spi: rzv2m-csi: Rework CSI_CKS_MAX definitionFabrizio Castro1-1/+6
Clock "csiclk" gets divided by 2 * CSI_CLKSEL_CKS in order to generate the serial clock (output from master), with CSI_CLKSEL_CKS ranging from 0x1 (that means "csiclk" is divided by 2) to 0x3FFF ("csiclk" is divided by 32766). CSI_CKS_MAX is used for referring to the setting corresponding to the maximum frequency divider. Value 0x3FFF for CSI_CKS_MAX doesn't really means much to the reader without an explanation and a more readable definition. Add a comment with a meaningful description and also replace value 0x3FFF with the corresponding GENMASK, to make it very clear what the macro means. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230715010407.1751715-4-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17spi: rzv2m-csi: Adopt HZ_PER_MHZ for max spi clockFabrizio Castro1-1/+2
Make use of HZ_PER_MHZ for CSI_MAX_SPI_SCKO to make it clear what its value means. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230715010407.1751715-3-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17spi: rzv2m-csi: Add missing includeFabrizio Castro1-0/+1
Add missing include of bits.h file. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230715010407.1751715-2-fabrizio.castro.jz@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-10spi: rzv2m-csi: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() is renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230707071119.3394198-1-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-23spi: Add support for Renesas CSIFabrizio Castro1-0/+667
The RZ/V2M SoC comes with the Clocked Serial Interface (CSI) IP, which is a master/slave SPI controller. This commit adds a driver to support CSI master mode. Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Link: https://lore.kernel.org/r/Message-Id: <20230622113341.657842-4-fabrizio.castro.jz@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>