Subject: [PATCH v8] spi: Add PPC4xx SPI driver
This adds a SPI driver for the SPI controller found in the IBM/AMCC 4xx PowerPC's.
---
Changes in v8:
- Removed redundant dbg messages
- Using new master->mode_line variable
- Removed redundant test and assignment of bits_per_word
- Some white-space fixes from checkpatch
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 + drivers/spi/Makefile | 1 + drivers/spi/spi_ppc4xx.c | 612 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 620 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/spi_ppc4xx.c
drivers/spi/Kconfig +7 -0
@@ -178,6 +178,13 @@ config SPI_PL022 controller. If you have an embedded system with an AMBA(R) bus and a PL022 controller, say Y or M here. +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
@@ -26,6 +26,7 @@ obj-$(CONFIG_SPI_ORION) += orion_spi.o obj-$(CONFIG_SPI_PL022) += amba-pl022.o obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o obj-$(CONFIG_SPI_MPC8xxx) += spi_mpc8xxx.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 +612 -0
612 lines not on this page · raw message
Signature · 1 line
1.6.0.2
drivers/spi/spi_ppc4xx.c line 290
Quoted 9 lines · Steven A. Falco
drivers/spi/spi_ppc4xx.c new file +9
-0+ + /* + * If there are no chip selects at all, or if this is the special + * case of a non-existent (dummy) chip select, do nothing. + */ + + if (!hw->master->num_chipselect || hw->gpios[cs] == -EEXIST) + return; +
I'm going to send this in, but please send a followup patch making all this "non-existent (dummy) chip select" stuff use the SPI_NO_CS flag.
Quoted 5 lines
drivers/spi/spi_ppc4xx.c new file +5
-0+/* +* A count of zero implies a single SPI device without any chip-select. +* Note that of_gpio_count counts all gpios assigned to this spi master. +* This includes both "null" gpio's and real ones. +*/
Quoted 15 lines · David Brownell
drivers/spi/spi_ppc4xx.c line 290
Quoted 9 lines · Steven A. Falco
drivers/spi/spi_ppc4xx.c new file +9
-0+ +/* +* If there are no chip selects at all, or if this is the special +* case of a non-existent (dummy) chip select, do nothing. +*/ + +if (!hw->master->num_chipselect || hw->gpios[cs] == -EEXIST ) +return ; +I'm going to send this in, but please send a followup patch making all this "non-existent (dummy) chip select" stuff use the
SPI_NO_CSflag.
Not sure yet how this will work. GPIOs are detected during probe. of_get_gpio_flags() will return EEXIST for devices without a CS, and will return the gpio number for devices with a CS, but probe doesn't (currently) know anything about "struct spi_device".
In fact, the devices don't exist until spi_bitbang_start is called, near the end of the probe. So, I've not figured out how the probe routine will set the new SPI_NO_CS flag on a per-device basis.
There is one example of a ppc board calling spi_register_board_info, but even that board doesn't really use it, if a device tree exists.
Quoted 9 lines
Quoted 6 lines
drivers/spi/spi_ppc4xx.c new file +5
-0+/* +* A count of zero implies a single SPI device without any chip-select. +* Note that of_gpio_count counts all gpios assigned to this spi master. +* This includes both "null" gpio's and real ones. +*/