spi: add new driver for OpenCores tiny_spi
PATCH 1/1 spi: add new driver for OpenCores tiny_spi
This patch adds support for OpenCores tiny_spi.
http://opencores.org/project,tiny_spi
--- drivers/spi/Makefile | 1 + drivers/spi/oc_tiny_spi.c | 241 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/oc_tiny_spi.c
drivers/spi/Makefile +1 -0
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o +COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/oc_tiny_spi.c new file +241 -0
241 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH 1/1 spi: add new driver for OpenCores tiny_spi
Quoted 2 lines · On Saturday, January 08, 2011 18:56:03 Thomas Chou wrote:
+ */
+#include <common.h>
space between comment and includes
drivers/spi/oc_tiny_spi.c line 17
Quoted 2 lines
drivers/spi/oc_tiny_spi.c new file +2
-0+#include <asm/gpio.h> +#define TINY_SPI_RXDATA 0
space between includes and defines
Quoted 1 line
+static struct
tiny_spi_hosttiny_spi_host_list[] =
CONFIG_SYS_TINY_SPI_LIST;
i think you only read this, so you'll want to add "const"
drivers/spi/oc_tiny_spi.c line 58
Quoted 8 lines
drivers/spi/oc_tiny_spi.c new file +8
-0+__attribute__((weak)) +int spi_cs_is_valid(unsigned int bus, unsigned int cs) + +__attribute__((weak)) +void spi_cs_activate(struct spi_slave *slave) + +__attribute__((weak)) +void spi_cs_deactivate(struct spi_slave *slave)
only reason i had these marked weak in the Blackfin SPI driver was because i didn't support GPIO CS's. now that that's fixed, i dropped the weak markings. either way is fine of course; just giving some background info.
drivers/spi/oc_tiny_spi.c line 72
Quoted 3 lines
drivers/spi/oc_tiny_spi.c new file +3
-0+ tiny_spi->baud =DIV_ROUND_UP (host->freq, hz *2 ) -1 ; +if (tiny_spi->baud > (1 << host->baudwidth) -1 ) + tiny_spi->baud = (1 << host->baudwidth) -1 ;
might be simpler to use:
tiny_spi->baud = max(DIV_ROUND_UP(host->freq, hz * 2),
(1 << host->baudwidth)) - 1;
otherwise code looks fine
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110108/25ee407c/attachment.pgp
PATCH v2 1/1 spi: add new driver for OpenCores tiny_spi
This patch adds support for OpenCores tiny_spi.
http://opencores.org/project,tiny_spi
---
for u-boot
v2, use const and clean up as Mike suggested.
drivers/spi/Makefile | 1 + drivers/spi/oc_tiny_spi.c | 240 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/oc_tiny_spi.c
drivers/spi/Makefile +1 -0
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o +COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/oc_tiny_spi.c new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH v2 1/1 spi: add new driver for OpenCores tiny_spi
Dear Thomas Chou,
Quoted 8 lines · In message <[email protected]> you wrote:
This patch adds support for OpenCores
tiny_spi.http://opencores.org/project,tiny_spi
Signed-off-by Thomas Chou <[email protected]>---
for u-boot
v2, use const and clean up as Mike suggested.
...
drivers/spi/oc_tiny_spi.c line 56
Quoted 7 lines
drivers/spi/oc_tiny_spi.c new file +7
-0+void spi_cs_activate (struct spi_slave *slave) +{ +struct tiny_spi_slave *tiny_spi =to_tiny_spi_slave (slave); +unsigned int cs = slave->cs; +gpio_set_value (cs, tiny_spi->flg); +debug ("%s: SPI_CS_GPIO:%x\n" , __func__,gpio_get_value (cs)); +}
Please separate declartations and code with a blank line. Please fix globally.
...
drivers/spi/oc_tiny_spi.c line 119
Quoted 8 lines
drivers/spi/oc_tiny_spi.c new file +8
-0+int spi_claim_bus (struct spi_slave *slave) +{ +struct tiny_spi_slave *tiny_spi =to_tiny_spi_slave (slave); +const struct tiny_spi_host *host = tiny_spi->host; +debug ("%s: bus:%i cs:%i\n" , __func__, slave->bus, slave->cs); +gpio_direction_output (slave->cs, !tiny_spi->flg); +writel (tiny_spi->mode, host->base +TINY_SPI_CONTROL ); +writel (tiny_spi->baud, host->base +TINY_SPI_BAUD );
Please do not use base + offset notation. Use a proper C struct instead. Please fix globally.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A conservative is a man who believes that nothing should be done for the first time. - Alfred E. Wiggam
PATCH v2 1/1 spi: add new driver for OpenCores tiny_spi
Dear Wolfgang,
Quoted 5 lines · Wolfgang Denk
Please separate declartations and code with a blank line. Please fix globally.
Please do not use base + offset notation. Use a proper C struct instead. Please fix globally.
Thank you very much for the coding style correction. I will follow them.
Best regards,
Thomas
PATCH v3 1/1 spi: add new driver for OpenCores tiny_spi
In reply to Wolfgang DenkThis patch adds support for OpenCores tiny_spi.
http://opencores.org/project,tiny_spi
---
for u-boot
v2, use const and clean up as Mike suggested.
v3, use struct instead of base+offset as Wolfgang suggested.
drivers/spi/Makefile | 1 + drivers/spi/oc_tiny_spi.c | 248 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/oc_tiny_spi.c
drivers/spi/Makefile +1 -0
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o +COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/oc_tiny_spi.c new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH v3 1/1 spi: add new driver for OpenCores tiny_spi
Dear Thomas Chou,
Quoted 10 lines · In message <[email protected]> you wrote:
This patch adds support for OpenCores
tiny_spi.http://opencores.org/project,tiny_spi
Signed-off-by Thomas Chou <[email protected]>---
for u-boot
v2, use const and clean up as Mike suggested.
v3, use struct instead of base+offset as Wolfgang suggested.
Quoted 4 lines
drivers/spi/Makefile | 1 + drivers/spi/oc_tiny_spi.c | 248 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/oc_tiny_spi.c
Sorry, but I see only now trhat there is an issue left:
drivers/spi/oc_tiny_spi.c line 28
Quoted 7 lines
drivers/spi/oc_tiny_spi.c new file +7
-0+struct tiny_spi_regs { +volatile unsigned rxdata;/* Rx data reg */ +volatile unsigned txdata;/* Tx data reg */ +volatile unsigned status;/* Status reg */ +volatile unsigned control;/* Control reg */ +volatile unsigned baud;/* Baud reg */ +};
Please drop all these volatiles; see Documentation/volatile-considered-harmful.txt in the Linux source tree.
Thanks.
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Accident: A condition in which presence of mind is good, but absence of body is better.
PATCH v4 1/1 spi: add new driver for OpenCores tiny_spi
This patch adds support for OpenCores tiny_spi.
http://opencores.org/project,tiny_spi
---
for u-boot
v2, use const and clean up as Mike suggested.
v3, use struct instead of base+offset as Wolfgang suggested. v4, remove volatile in regs def.
drivers/spi/Makefile | 1 + drivers/spi/oc_tiny_spi.c | 248 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/oc_tiny_spi.c
drivers/spi/Makefile +1 -0
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o +COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o COBJS-$(CONFIG_SH_SPI) += sh_spi.o
drivers/spi/oc_tiny_spi.c new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
1.7.4.2
Wolfgang Denk
AppliedPATCH v4 1/1 spi: add new driver for OpenCores tiny_spi
Dear Thomas Chou,
Quoted 11 lines · In message <[email protected]> you wrote:
This patch adds support for OpenCores
tiny_spi.http://opencores.org/project,tiny_spi
Signed-off-by Thomas Chou <[email protected]>---
for u-boot
v2, use const and clean up as Mike suggested.
v3, use struct instead of base+offset as Wolfgang suggested. v4, remove volatile in regs def.
Quoted 4 lines
drivers/spi/Makefile | 1 + drivers/spi/oc_tiny_spi.c | 248 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/oc_tiny_spi.c
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "A complex system that works is invariably found to have evolved from a simple system that worked." - John Gall, _Systemantics_