Skip to contentSkip to conversation

Subject: [PATCH v7] spi: Add PPC4xx SPI driver

PATCH Steven A. Falco 2 participants 3 messages Jun 25, 2009 – Jun 26, 2009 SPI

lore
Share & tools
lore
#0 lore raw

This adds a SPI driver for the SPI controller found in the IBM/AMCC 4xx PowerPC's.

---
Note, I have not removed any of the prior sign-offs, but feel free to look this version over very closely, and let me know if you demand a "retraction". :-)

I've successfully used this driver on a custom PPC440EPx based board with three devices on the spi bus, one of which uses the "chip-select hole" feature.

Changes in v7:
- Additional comments as per David Brownell's review
- Corrected phase in mode 2 and 3
- Corrected speed and bits_per_word logic in spi_ppc4xx_setupxfer
- Removed extraneous tests as per David's review
- Added support for "holes" in the chip-select list
- Using dynamic bus allocation
- Corrected initialization logic

Changes in v6:
- Moved comment about high interrupt load to top of file and extended it by explaining that the 4xx SPI controller has no FIFOs.
- Added parameter checking to setup() routine.
- Removed comment about LSB
- Used of_gpio_count() instead creating own static implementation as suggested by Anton.

Changes in v5:
- Don't call setupxfer() from setup() so that the baudrate etc won't get changed while another transfer is active, as suggested by David Brownell.
- module_{init,exit} moved directly to the functions to which they apply.
- Use __func__ instead of __FUNCTION__.

Changes in v4:
- Added fixes suggested by Josh Boyer
- Changed compatible property from "ibm,spi" to "ibm,ppc4xx-spi"

Changes in v3:
- When the device is removed the GPIOs are released. The memory for the GPIO array is freed.

Changes in v2:
- Now the gpios property is correctly decoded and the resulting gpio numbers are used as the devices chip selects.

drivers/spi/Kconfig +7 -0
index 83a185d..2f0a3df 100644
@@ -171,6 +171,13 @@ config SPI_ORION
 	help
 	  This enables using the SPI master controller on the Orion chips.
 
+config SPI_PPC4xx
+	tristate "PPC4xx SPI Controller"
+	depends on 4xx && SPI_MASTER
+	select SPI_BITBANG
+	help
+	  This selects a driver for the PPC4xx SPI Controller.
+
 config SPI_PXA2XX
 	tristate "PXA2xx SSP SPI master"
 	depends on ARCH_PXA && EXPERIMENTAL
drivers/spi/Makefile +1 -0
index 5d04519..ed1d74f 100644
@@ -23,8 +23,9 @@ obj-$(CONFIG_SPI_PXA2XX)		+= pxa2xx_spi.o
 obj-$(CONFIG_SPI_OMAP_UWIRE)		+= omap_uwire.o
 obj-$(CONFIG_SPI_OMAP24XX)		+= omap2_mcspi.o
 obj-$(CONFIG_SPI_ORION)			+= orion_spi.o
 obj-$(CONFIG_SPI_MPC52xx_PSC)		+= mpc52xx_psc_spi.o
 obj-$(CONFIG_SPI_MPC83xx)		+= spi_mpc83xx.o
+obj-$(CONFIG_SPI_PPC4xx)		+= spi_ppc4xx.o
 obj-$(CONFIG_SPI_S3C24XX_GPIO)		+= spi_s3c24xx_gpio.o
 obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24xx.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
drivers/spi/spi_ppc4xx.c new file +623 -0

623 lines not on this page · raw message

#1 lore raw
Quoted 5 lines · Steven A. Falco

+       if (spi->mode & ~MODEBITS) {
+               dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", +                       spi->mode & ~MODEBITS);
+               return -EINVAL;
+       }

This wasn't tested against 2.6.30-rc1 was it?

See the recent fixup patch I sent. There's a spi_master->modebits mask that should have been initialized, and which eliminates the need for tests like that ...

drivers/spi/spi_ppc4xx.c line 288

Quoted 4 lines
drivers/spi/spi_ppc4xx.c new file +4 -0
+       dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n",
+               __func__, spi->mode, spi->bits_per_word,
+               spi->max_speed_hz);
+

... also the SPI core now provides a *standard* format debug message for that stuff. It also handles one more thing, which I expect to see fixed in a v8 of this patch ... :)

- Dave

#2 lore raw
Quoted 9 lines · David Brownell

drivers/spi/spi_ppc4xx.c line 252

Quoted 5 lines · Steven A. Falco
drivers/spi/spi_ppc4xx.c new file +5 -0
+       if (spi->mode & ~MODEBITS) {
+               dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
+                       spi->mode & ~MODEBITS);
+               return -EINVAL;
+       }

This wasn't tested against 2.6.30-rc1 was it?

I tested against Ben's "next" branch, plus your fix for bitbang_work. But the new version I'll post is tested against Linus' master branch (2.6.31-rc1) to take advantage of your mode_bits addition. If you need this driver to be based on something else, please say so.

Quoted 4 lines

See the recent fixup patch I sent. There's a spi_master->modebits mask that should have been initialized, and which eliminates the need for tests like that ...

Done.

Quoted 8 lines

drivers/spi/spi_ppc4xx.c line 288

Quoted 4 lines
drivers/spi/spi_ppc4xx.c new file +4 -0
+       dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n",
+               __func__, spi->mode, spi->bits_per_word,
+               spi->max_speed_hz);
+

... also the SPI core now provides a *standard* format debug message for that stuff. It also handles one more thing, which I expect to see fixed in a v8 of this patch ... :)

Ok - I removed that dev_dbg(). Also, I noticed that spi_setup sets bits_per_word to 8, so I've removed that as well. Did I pass your test? :-)

Version 8 will follow shortly. BTW, this driver is dependent on your bitbang_work fix. Not sure if that means it should be added via your tree. But since we are in an rc phase, I'm guessing this won't merge until 2.6.32, by which time your fix should be in the mainline.

Steve