aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2006-04-05 16:52:13 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-05 16:52:13 -0700
commit688ad0ac7301d27e1d30e1e4e706bd8ac5c24258 (patch)
treecaf24fbb6717e87826667a211e95a3c61f275082 /driver
parentf6ada193524c8fcce65c87bb8a2834294dcd2007 (diff)
downloadpatches-688ad0ac7301d27e1d30e1e4e706bd8ac5c24258.tar.gz
spi patches added
Diffstat (limited to 'driver')
-rw-r--r--driver/spi-add-david-as-the-spi-subsystem-maintainer.patch33
-rw-r--r--driver/spi-busnum-0-needs-to-work.patch121
-rw-r--r--driver/spi-devices-can-require-lsb-first-encodings.patch79
-rw-r--r--driver/spi-renamed-bitbang_transfer_setup-to-spi_bitbang_setup_transfer-and-export-it.patch72
-rw-r--r--driver/spi-spi-bounce-buffer-has-a-minimum-length.patch30
-rw-r--r--driver/spi-spi-whitespace-fixes.patch86
6 files changed, 421 insertions, 0 deletions
diff --git a/driver/spi-add-david-as-the-spi-subsystem-maintainer.patch b/driver/spi-add-david-as-the-spi-subsystem-maintainer.patch
new file mode 100644
index 0000000000000..c7cfc46ec1175
--- /dev/null
+++ b/driver/spi-add-david-as-the-spi-subsystem-maintainer.patch
@@ -0,0 +1,33 @@
+From galak@kernel.crashing.org Sun Apr 2 14:07:08 2006
+Date: Sun, 2 Apr 2006 16:05:54 -0500 (CDT)
+From: Kumar Gala <galak@kernel.crashing.org>
+To: david-b@pacbell.net
+cc: <spi-devel-general@lists.sourceforge.net>, Greg KH <greg@kroah.com>, Andrew Morton <akpm@osdl.org>
+Subject: SPI: Add David as the SPI subsystem maintainer
+Message-ID: <Pine.LNX.4.44.0604021605160.9478-100000@gate.crashing.org>
+
+Add David as the SPI subsystem maintainer
+
+Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ MAINTAINERS | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- gregkh-2.6.orig/MAINTAINERS
++++ gregkh-2.6/MAINTAINERS
+@@ -2492,6 +2492,12 @@ M: perex@suse.cz
+ L: alsa-devel@alsa-project.org
+ S: Maintained
+
++SPI SUBSYSTEM
++P: David Brownell
++M: dbrownell@users.sourceforge.net
++L: spi-devel-general@lists.sourceforge.net
++S: Maintained
++
+ TPM DEVICE DRIVER
+ P: Kylene Hall
+ M: kjhall@us.ibm.com
diff --git a/driver/spi-busnum-0-needs-to-work.patch b/driver/spi-busnum-0-needs-to-work.patch
new file mode 100644
index 0000000000000..27e6c1d775336
--- /dev/null
+++ b/driver/spi-busnum-0-needs-to-work.patch
@@ -0,0 +1,121 @@
+From david-b@pacbell.net Mon Apr 3 15:55:59 2006
+From: David Brownell <david-b@pacbell.net>
+To: Greg KH <greg@kroah.com>
+Subject: SPI: busnum == 0 needs to work
+Date: Mon, 3 Apr 2006 15:49:04 -0700
+Message-Id: <200604031549.04064.david-b@pacbell.net>
+
+We need to be able to have a "SPI bus 0" matching chip numbering; but
+that number was wrongly used to flag dynamic allocation of a bus number.
+
+This patch resolves that issue; now negative numbers trigger dynamic alloc.
+
+It also updates the how-to-write-a-controller-driver overview to mention
+this stuff.
+
+Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ Documentation/spi/spi-summary | 34 +++++++++++++++++++++++++++++++++-
+ drivers/spi/spi.c | 4 ++--
+ include/linux/spi/spi.h | 6 +++---
+ 3 files changed, 38 insertions(+), 6 deletions(-)
+
+--- gregkh-2.6.orig/Documentation/spi/spi-summary
++++ gregkh-2.6/Documentation/spi/spi-summary
+@@ -414,7 +414,33 @@ to get the driver-private data allocated
+ The driver will initialize the fields of that spi_master, including the
+ bus number (maybe the same as the platform device ID) and three methods
+ used to interact with the SPI core and SPI protocol drivers. It will
+-also initialize its own internal state.
++also initialize its own internal state. (See below about bus numbering
++and those methods.)
++
++After you initialize the spi_master, then use spi_register_master() to
++publish it to the rest of the system. At that time, device nodes for
++the controller and any predeclared spi devices will be made available,
++and the driver model core will take care of binding them to drivers.
++
++If you need to remove your SPI controller driver, spi_unregister_master()
++will reverse the effect of spi_register_master().
++
++
++BUS NUMBERING
++
++Bus numbering is important, since that's how Linux identifies a given
++SPI bus (shared SCK, MOSI, MISO). Valid bus numbers start at zero. On
++SOC systems, the bus numbers should match the numbers defined by the chip
++manufacturer. For example, hardware controller SPI2 would be bus number 2,
++and spi_board_info for devices connected to it would use that number.
++
++If you don't have such hardware-assigned bus number, and for some reason
++you can't just assign them, then provide a negative bus number. That will
++then be replaced by a dynamically assigned number. You'd then need to treat
++this as a non-static configuration (see above).
++
++
++SPI MASTER METHODS
+
+ master->setup(struct spi_device *spi)
+ This sets up the device clock rate, SPI mode, and word sizes.
+@@ -431,6 +457,9 @@ also initialize its own internal state.
+ state it dynamically associates with that device. If you do that,
+ be sure to provide the cleanup() method to free that state.
+
++
++SPI MESSAGE QUEUE
++
+ The bulk of the driver will be managing the I/O queue fed by transfer().
+
+ That queue could be purely conceptual. For example, a driver used only
+@@ -440,6 +469,9 @@ But the queue will probably be very real
+ often DMA (especially if the root filesystem is in SPI flash), and
+ execution contexts like IRQ handlers, tasklets, or workqueues (such
+ as keventd). Your driver can be as fancy, or as simple, as you need.
++Such a transfer() method would normally just add the message to a
++queue, and then start some asynchronous transfer engine (unless it's
++already running).
+
+
+ THANKS TO
+--- gregkh-2.6.orig/drivers/spi/spi.c
++++ gregkh-2.6/drivers/spi/spi.c
+@@ -395,7 +395,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
+ int __init_or_module
+ spi_register_master(struct spi_master *master)
+ {
+- static atomic_t dyn_bus_id = ATOMIC_INIT(0);
++ static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
+ struct device *dev = master->cdev.dev;
+ int status = -ENODEV;
+ int dynamic = 0;
+@@ -404,7 +404,7 @@ spi_register_master(struct spi_master *m
+ return -ENODEV;
+
+ /* convention: dynamically assigned bus IDs count down from the max */
+- if (master->bus_num == 0) {
++ if (master->bus_num < 0) {
+ master->bus_num = atomic_dec_return(&dyn_bus_id);
+ dynamic = 1;
+ }
+--- gregkh-2.6.orig/include/linux/spi/spi.h
++++ gregkh-2.6/include/linux/spi/spi.h
+@@ -172,13 +172,13 @@ static inline void spi_unregister_driver
+ struct spi_master {
+ struct class_device cdev;
+
+- /* other than zero (== assign one dynamically), bus_num is fully
++ /* other than negative (== assign one dynamically), bus_num is fully
+ * board-specific. usually that simplifies to being SOC-specific.
+- * example: one SOC has three SPI controllers, numbered 1..3,
++ * example: one SOC has three SPI controllers, numbered 0..2,
+ * and one board's schematics might show it using SPI-2. software
+ * would normally use bus_num=2 for that controller.
+ */
+- u16 bus_num;
++ s16 bus_num;
+
+ /* chipselects will be integral to many controllers; some others
+ * might use board-specific GPIOs.
diff --git a/driver/spi-devices-can-require-lsb-first-encodings.patch b/driver/spi-devices-can-require-lsb-first-encodings.patch
new file mode 100644
index 0000000000000..55554af2869eb
--- /dev/null
+++ b/driver/spi-devices-can-require-lsb-first-encodings.patch
@@ -0,0 +1,79 @@
+From david-b@pacbell.net Mon Apr 3 15:55:59 2006
+From: David Brownell <david-b@pacbell.net>
+To: Greg KH <greg@kroah.com>
+Subject: SPI: devices can require LSB-first encodings
+Date: Mon, 3 Apr 2006 15:46:22 -0700
+Message-Id: <200604031546.22777.david-b@pacbell.net>
+
+Add spi_device hook for LSB-first word encoding, and update all the
+(in-tree) controller drivers to reject such devices. Eventually,
+some controller drivers will be updated to support lsb-first encodings
+on the wire; no current drivers need this.
+
+Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/spi/spi_bitbang.c | 11 ++++++++++-
+ include/linux/spi/spi.h | 7 +++++--
+ 2 files changed, 15 insertions(+), 3 deletions(-)
+
+--- gregkh-2.6.orig/drivers/spi/spi_bitbang.c
++++ gregkh-2.6/drivers/spi/spi_bitbang.c
+@@ -187,13 +187,22 @@ int spi_bitbang_setup(struct spi_device
+ if (!spi->max_speed_hz)
+ return -EINVAL;
+
++ bitbang = spi_master_get_devdata(spi->master);
++
++ /* REVISIT: some systems will want to support devices using lsb-first
++ * bit encodings on the wire. In pure software that would be trivial,
++ * just bitbang_txrx_le_cphaX() routines shifting the other way, and
++ * some hardware controllers also have this support.
++ */
++ if ((spi->mode & SPI_LSB_FIRST) != 0)
++ return -EINVAL;
++
+ if (!cs) {
+ cs = kzalloc(sizeof *cs, SLAB_KERNEL);
+ if (!cs)
+ return -ENOMEM;
+ spi->controller_state = cs;
+ }
+- bitbang = spi_master_get_devdata(spi->master);
+
+ if (!spi->bits_per_word)
+ spi->bits_per_word = 8;
+--- gregkh-2.6.orig/include/linux/spi/spi.h
++++ gregkh-2.6/include/linux/spi/spi.h
+@@ -35,10 +35,13 @@ extern struct bus_type spi_bus_type;
+ * @chip-select: Chipselect, distinguishing chips handled by "master".
+ * @mode: The spi mode defines how data is clocked out and in.
+ * This may be changed by the device's driver.
++ * The "active low" default for chipselect mode can be overridden,
++ * as can the "MSB first" default for each word in a transfer.
+ * @bits_per_word: Data transfers involve one or more words; word sizes
+ * like eight or 12 bits are common. In-memory wordsizes are
+ * powers of two bytes (e.g. 20 bit samples use 32 bits).
+- * This may be changed by the device's driver.
++ * This may be changed by the device's driver, or left at the
++ * default (0) indicating protocol words are eight bit bytes.
+ * The spi_transfer.bits_per_word can override this for each transfer.
+ * @irq: Negative, or the number passed to request_irq() to receive
+ * interrupts from this device.
+@@ -67,6 +70,7 @@ struct spi_device {
+ #define SPI_MODE_2 (SPI_CPOL|0)
+ #define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
+ #define SPI_CS_HIGH 0x04 /* chipselect active high? */
++#define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */
+ u8 bits_per_word;
+ int irq;
+ void *controller_state;
+@@ -75,7 +79,6 @@ struct spi_device {
+
+ // likely need more hooks for more protocol options affecting how
+ // the controller talks to each chip, like:
+- // - bit order (default is wordwise msb-first)
+ // - memory packing (12 bit samples into low bits, others zeroed)
+ // - priority
+ // - drop chipselect after each word
diff --git a/driver/spi-renamed-bitbang_transfer_setup-to-spi_bitbang_setup_transfer-and-export-it.patch b/driver/spi-renamed-bitbang_transfer_setup-to-spi_bitbang_setup_transfer-and-export-it.patch
new file mode 100644
index 0000000000000..b81b0adda8e48
--- /dev/null
+++ b/driver/spi-renamed-bitbang_transfer_setup-to-spi_bitbang_setup_transfer-and-export-it.patch
@@ -0,0 +1,72 @@
+From galak@kernel.crashing.org Sun Apr 2 14:07:51 2006
+Date: Sun, 2 Apr 2006 16:06:35 -0500 (CDT)
+From: Kumar Gala <galak@kernel.crashing.org>
+To: david-b@pacbell.net
+cc: <spi-devel-general@lists.sourceforge.net>, Greg KH <greg@kroah.com>, Andrew Morton <akpm@osdl.org>
+Subject: SPI: Renamed bitbang_transfer_setup to spi_bitbang_setup_transfer and export it
+Message-ID: <Pine.LNX.4.44.0604021605560.9478-100000@gate.crashing.org>
+
+Renamed bitbang_transfer_setup to follow convention of other exported symbols
+from spi-bitbang. Exported spi_bitbang_setup_transfer to allow users of
+spi-bitbang to use the function in their own setup_transfer.
+
+Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
+Cc: David Brownell <dbrownell@users.sourceforge.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/spi/spi_bitbang.c | 10 ++++++----
+ include/linux/spi/spi_bitbang.h | 2 ++
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+--- gregkh-2.6.orig/drivers/spi/spi_bitbang.c
++++ gregkh-2.6/drivers/spi/spi_bitbang.c
+@@ -138,8 +138,7 @@ static unsigned bitbang_txrx_32(
+ return t->len - count;
+ }
+
+-static int
+-bitbang_transfer_setup(struct spi_device *spi, struct spi_transfer *t)
++int spi_bitbang_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
+ {
+ struct spi_bitbang_cs *cs = spi->controller_state;
+ u8 bits_per_word;
+@@ -174,6 +173,7 @@ bitbang_transfer_setup(struct spi_device
+
+ return 0;
+ }
++EXPORT_SYMBOL_GPL(spi_bitbang_setup_transfer);
+
+ /**
+ * spi_bitbang_setup - default setup for per-word I/O loops
+@@ -203,7 +203,7 @@ int spi_bitbang_setup(struct spi_device
+ if (!cs->txrx_word)
+ return -EINVAL;
+
+- retval = bitbang_transfer_setup(spi, NULL);
++ retval = spi_bitbang_setup_transfer(spi, NULL);
+ if (retval < 0)
+ return retval;
+
+@@ -454,7 +454,9 @@ int spi_bitbang_start(struct spi_bitbang
+ bitbang->use_dma = 0;
+ bitbang->txrx_bufs = spi_bitbang_bufs;
+ if (!bitbang->master->setup) {
+- bitbang->setup_transfer = bitbang_transfer_setup;
++ if (!bitbang->setup_transfer)
++ bitbang->setup_transfer =
++ spi_bitbang_setup_transfer;
+ bitbang->master->setup = spi_bitbang_setup;
+ bitbang->master->cleanup = spi_bitbang_cleanup;
+ }
+--- gregkh-2.6.orig/include/linux/spi/spi_bitbang.h
++++ gregkh-2.6/include/linux/spi/spi_bitbang.h
+@@ -57,6 +57,8 @@ struct spi_bitbang {
+ extern int spi_bitbang_setup(struct spi_device *spi);
+ extern void spi_bitbang_cleanup(const struct spi_device *spi);
+ extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m);
++extern int spi_bitbang_setup_transfer(struct spi_device *spi,
++ struct spi_transfer *t);
+
+ /* start or stop queue processing */
+ extern int spi_bitbang_start(struct spi_bitbang *spi);
diff --git a/driver/spi-spi-bounce-buffer-has-a-minimum-length.patch b/driver/spi-spi-bounce-buffer-has-a-minimum-length.patch
new file mode 100644
index 0000000000000..c7acd0c539756
--- /dev/null
+++ b/driver/spi-spi-bounce-buffer-has-a-minimum-length.patch
@@ -0,0 +1,30 @@
+From david-b@pacbell.net Sun Apr 2 11:38:22 2006
+From: David Brownell <david-b@pacbell.net>
+To: Greg KH <greg@kroah.com>
+Subject: SPI: spi bounce buffer has a minimum length
+Date: Sun, 2 Apr 2006 10:37:40 -0800
+Cc: Andrew Morton <akpm@osdl.org>
+Message-Id: <200604021137.40719.david-b@pacbell.net>
+
+Make sure that spi_write_then_read() can always handle at least 32 bytes
+of transfer (total, both directions), minimizing one portability issue.
+
+Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/spi/spi.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- gregkh-2.6.orig/drivers/spi/spi.c
++++ gregkh-2.6/drivers/spi/spi.c
+@@ -522,7 +522,8 @@ int spi_sync(struct spi_device *spi, str
+ }
+ EXPORT_SYMBOL_GPL(spi_sync);
+
+-#define SPI_BUFSIZ (SMP_CACHE_BYTES)
++/* portable code must never pass more than 32 bytes */
++#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
+
+ static u8 *buf;
+
diff --git a/driver/spi-spi-whitespace-fixes.patch b/driver/spi-spi-whitespace-fixes.patch
new file mode 100644
index 0000000000000..f39df4354da85
--- /dev/null
+++ b/driver/spi-spi-whitespace-fixes.patch
@@ -0,0 +1,86 @@
+From david-b@pacbell.net Sun Apr 2 11:38:22 2006
+From: David Brownell <david-b@pacbell.net>
+To: Greg KH <greg@kroah.com>
+Subject: SPI: spi whitespace fixes
+Date: Sun, 2 Apr 2006 10:33:37 -0800
+Cc: Andrew Morton <akpm@osdl.org>
+Message-Id: <200604021133.38140.david-b@pacbell.net>
+
+This removes superfluous whitespace in the <linux/spi/spi.h> header.
+
+Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ include/linux/spi/spi.h | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+--- gregkh-2.6.orig/include/linux/spi/spi.h
++++ gregkh-2.6/include/linux/spi/spi.h
+@@ -36,15 +36,15 @@ extern struct bus_type spi_bus_type;
+ * @mode: The spi mode defines how data is clocked out and in.
+ * This may be changed by the device's driver.
+ * @bits_per_word: Data transfers involve one or more words; word sizes
+- * like eight or 12 bits are common. In-memory wordsizes are
++ * like eight or 12 bits are common. In-memory wordsizes are
+ * powers of two bytes (e.g. 20 bit samples use 32 bits).
+ * This may be changed by the device's driver.
+ * The spi_transfer.bits_per_word can override this for each transfer.
+ * @irq: Negative, or the number passed to request_irq() to receive
+- * interrupts from this device.
++ * interrupts from this device.
+ * @controller_state: Controller's runtime state
+ * @controller_data: Board-specific definitions for controller, such as
+- * FIFO initialization parameters; from board_info.controller_data
++ * FIFO initialization parameters; from board_info.controller_data
+ *
+ * An spi_device is used to interchange data between an SPI slave
+ * (usually a discrete chip) and CPU memory.
+@@ -145,13 +145,13 @@ static inline void spi_unregister_driver
+ * struct spi_master - interface to SPI master controller
+ * @cdev: class interface to this driver
+ * @bus_num: board-specific (and often SOC-specific) identifier for a
+- * given SPI controller.
++ * given SPI controller.
+ * @num_chipselect: chipselects are used to distinguish individual
+- * SPI slaves, and are numbered from zero to num_chipselects.
+- * each slave has a chipselect signal, but it's common that not
+- * every chipselect is connected to a slave.
++ * SPI slaves, and are numbered from zero to num_chipselects.
++ * each slave has a chipselect signal, but it's common that not
++ * every chipselect is connected to a slave.
+ * @setup: updates the device mode and clocking records used by a
+- * device's SPI controller; protocol code may call this.
++ * device's SPI controller; protocol code may call this.
+ * @transfer: adds a message to the controller's transfer queue.
+ * @cleanup: frees controller-specific state
+ *
+@@ -276,8 +276,8 @@ extern struct spi_master *spi_busnum_to_
+ * for this transfer. If 0 the default (from spi_device) is used.
+ * @cs_change: affects chipselect after this transfer completes
+ * @delay_usecs: microseconds to delay after this transfer before
+- * (optionally) changing the chipselect status, then starting
+- * the next transfer or completing this spi_message.
++ * (optionally) changing the chipselect status, then starting
++ * the next transfer or completing this spi_message.
+ * @transfer_list: transfers are sequenced through spi_message.transfers
+ *
+ * SPI transfers always write the same number of bytes as they read.
+@@ -364,7 +364,7 @@ struct spi_transfer {
+ * and its transfers, ignore them until its completion callback.
+ */
+ struct spi_message {
+- struct list_head transfers;
++ struct list_head transfers;
+
+ struct spi_device *spi;
+
+@@ -382,7 +382,7 @@ struct spi_message {
+ */
+
+ /* completion is reported through a callback */
+- void (*complete)(void *context);
++ void (*complete)(void *context);
+ void *context;
+ unsigned actual_length;
+ int status;