aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-05-16 18:18:26 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-16 18:18:26 -0400
commit0c056c50a6218e0e577817c16ba8851af593d742 (patch)
treefeabddbd93b49ce94103c6054336078f240848ee /include
parent4fbca5320eb102d2e15bdeffe79e125c11cf925e (diff)
parent1e316d7566b63767aa18902235c719e9e95465d0 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/spi-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/spi-2.6: [PATCH] SPI: spi_bitbang: clocking fixes [PATCH] spi: Update to PXA2xx SPI Driver [PATCH] SPI: busnum == 0 needs to work [PATCH] SPI: devices can require LSB-first encodings [PATCH] SPI: Renamed bitbang_transfer_setup to spi_bitbang_setup_transfer and export it [PATCH] SPI: Add David as the SPI subsystem maintainer [PATCH] SPI: spi bounce buffer has a minimum length [PATCH] SPI: spi whitespace fixes [PATCH] SPI: add PXA2xx SSP SPI Driver [PATCH] SPI: per-transfer overrides for wordsize and clocking
Diffstat (limited to 'include')
-rw-r--r--include/asm-arm/arch-pxa/pxa2xx_spi.h68
-rw-r--r--include/linux/spi/spi.h45
-rw-r--r--include/linux/spi/spi_bitbang.h8
3 files changed, 104 insertions, 17 deletions
diff --git a/include/asm-arm/arch-pxa/pxa2xx_spi.h b/include/asm-arm/arch-pxa/pxa2xx_spi.h
new file mode 100644
index 000000000000..1e70908b816f
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pxa2xx_spi.h
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef PXA2XX_SPI_H_
20#define PXA2XX_SPI_H_
21
22#define PXA2XX_CS_ASSERT (0x01)
23#define PXA2XX_CS_DEASSERT (0x02)
24
25#if defined(CONFIG_PXA25x)
26#define CLOCK_SPEED_HZ 3686400
27#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/2/(x+1))<<8)&0x0000ff00)
28#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
29#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
30#elif defined(CONFIG_PXA27x)
31#define CLOCK_SPEED_HZ 13000000
32#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
33#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
34#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
35#endif
36
37#define SSP1_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(1)))))
38#define SSP2_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(2)))))
39#define SSP3_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(3)))))
40
41enum pxa_ssp_type {
42 SSP_UNDEFINED = 0,
43 PXA25x_SSP, /* pxa 210, 250, 255, 26x */
44 PXA25x_NSSP, /* pxa 255, 26x (including ASSP) */
45 PXA27x_SSP,
46};
47
48/* device.platform_data for SSP controller devices */
49struct pxa2xx_spi_master {
50 enum pxa_ssp_type ssp_type;
51 u32 clock_enable;
52 u16 num_chipselect;
53 u8 enable_dma;
54};
55
56/* spi_board_info.controller_data for SPI slave devices,
57 * copied to spi_device.platform_data ... mostly for dma tuning
58 */
59struct pxa2xx_spi_chip {
60 u8 tx_threshold;
61 u8 rx_threshold;
62 u8 dma_burst_size;
63 u32 timeout_microsecs;
64 u8 enable_loopback;
65 void (*cs_control)(u32 command);
66};
67
68#endif /*PXA2XX_SPI_H_*/
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index b05f1463a267..e928c0dcc297 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -31,18 +31,23 @@ extern struct bus_type spi_bus_type;
31 * @master: SPI controller used with the device. 31 * @master: SPI controller used with the device.
32 * @max_speed_hz: Maximum clock rate to be used with this chip 32 * @max_speed_hz: Maximum clock rate to be used with this chip
33 * (on this board); may be changed by the device's driver. 33 * (on this board); may be changed by the device's driver.
34 * The spi_transfer.speed_hz can override this for each transfer.
34 * @chip-select: Chipselect, distinguishing chips handled by "master". 35 * @chip-select: Chipselect, distinguishing chips handled by "master".
35 * @mode: The spi mode defines how data is clocked out and in. 36 * @mode: The spi mode defines how data is clocked out and in.
36 * This may be changed by the device's driver. 37 * This may be changed by the device's driver.
38 * The "active low" default for chipselect mode can be overridden,
39 * as can the "MSB first" default for each word in a transfer.
37 * @bits_per_word: Data transfers involve one or more words; word sizes 40 * @bits_per_word: Data transfers involve one or more words; word sizes
38 * like eight or 12 bits are common. In-memory wordsizes are 41 * like eight or 12 bits are common. In-memory wordsizes are
39 * powers of two bytes (e.g. 20 bit samples use 32 bits). 42 * powers of two bytes (e.g. 20 bit samples use 32 bits).
40 * This may be changed by the device's driver. 43 * This may be changed by the device's driver, or left at the
44 * default (0) indicating protocol words are eight bit bytes.
45 * The spi_transfer.bits_per_word can override this for each transfer.
41 * @irq: Negative, or the number passed to request_irq() to receive 46 * @irq: Negative, or the number passed to request_irq() to receive
42 * interrupts from this device. 47 * interrupts from this device.
43 * @controller_state: Controller's runtime state 48 * @controller_state: Controller's runtime state
44 * @controller_data: Board-specific definitions for controller, such as 49 * @controller_data: Board-specific definitions for controller, such as
45 * FIFO initialization parameters; from board_info.controller_data 50 * FIFO initialization parameters; from board_info.controller_data
46 * 51 *
47 * An spi_device is used to interchange data between an SPI slave 52 * An spi_device is used to interchange data between an SPI slave
48 * (usually a discrete chip) and CPU memory. 53 * (usually a discrete chip) and CPU memory.
@@ -65,6 +70,7 @@ struct spi_device {
65#define SPI_MODE_2 (SPI_CPOL|0) 70#define SPI_MODE_2 (SPI_CPOL|0)
66#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA) 71#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
67#define SPI_CS_HIGH 0x04 /* chipselect active high? */ 72#define SPI_CS_HIGH 0x04 /* chipselect active high? */
73#define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */
68 u8 bits_per_word; 74 u8 bits_per_word;
69 int irq; 75 int irq;
70 void *controller_state; 76 void *controller_state;
@@ -73,7 +79,6 @@ struct spi_device {
73 79
74 // likely need more hooks for more protocol options affecting how 80 // likely need more hooks for more protocol options affecting how
75 // the controller talks to each chip, like: 81 // the controller talks to each chip, like:
76 // - bit order (default is wordwise msb-first)
77 // - memory packing (12 bit samples into low bits, others zeroed) 82 // - memory packing (12 bit samples into low bits, others zeroed)
78 // - priority 83 // - priority
79 // - drop chipselect after each word 84 // - drop chipselect after each word
@@ -143,13 +148,13 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
143 * struct spi_master - interface to SPI master controller 148 * struct spi_master - interface to SPI master controller
144 * @cdev: class interface to this driver 149 * @cdev: class interface to this driver
145 * @bus_num: board-specific (and often SOC-specific) identifier for a 150 * @bus_num: board-specific (and often SOC-specific) identifier for a
146 * given SPI controller. 151 * given SPI controller.
147 * @num_chipselect: chipselects are used to distinguish individual 152 * @num_chipselect: chipselects are used to distinguish individual
148 * SPI slaves, and are numbered from zero to num_chipselects. 153 * SPI slaves, and are numbered from zero to num_chipselects.
149 * each slave has a chipselect signal, but it's common that not 154 * each slave has a chipselect signal, but it's common that not
150 * every chipselect is connected to a slave. 155 * every chipselect is connected to a slave.
151 * @setup: updates the device mode and clocking records used by a 156 * @setup: updates the device mode and clocking records used by a
152 * device's SPI controller; protocol code may call this. 157 * device's SPI controller; protocol code may call this.
153 * @transfer: adds a message to the controller's transfer queue. 158 * @transfer: adds a message to the controller's transfer queue.
154 * @cleanup: frees controller-specific state 159 * @cleanup: frees controller-specific state
155 * 160 *
@@ -167,13 +172,13 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
167struct spi_master { 172struct spi_master {
168 struct class_device cdev; 173 struct class_device cdev;
169 174
170 /* other than zero (== assign one dynamically), bus_num is fully 175 /* other than negative (== assign one dynamically), bus_num is fully
171 * board-specific. usually that simplifies to being SOC-specific. 176 * board-specific. usually that simplifies to being SOC-specific.
172 * example: one SOC has three SPI controllers, numbered 1..3, 177 * example: one SOC has three SPI controllers, numbered 0..2,
173 * and one board's schematics might show it using SPI-2. software 178 * and one board's schematics might show it using SPI-2. software
174 * would normally use bus_num=2 for that controller. 179 * would normally use bus_num=2 for that controller.
175 */ 180 */
176 u16 bus_num; 181 s16 bus_num;
177 182
178 /* chipselects will be integral to many controllers; some others 183 /* chipselects will be integral to many controllers; some others
179 * might use board-specific GPIOs. 184 * might use board-specific GPIOs.
@@ -268,10 +273,14 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum);
268 * @tx_dma: DMA address of tx_buf, if spi_message.is_dma_mapped 273 * @tx_dma: DMA address of tx_buf, if spi_message.is_dma_mapped
269 * @rx_dma: DMA address of rx_buf, if spi_message.is_dma_mapped 274 * @rx_dma: DMA address of rx_buf, if spi_message.is_dma_mapped
270 * @len: size of rx and tx buffers (in bytes) 275 * @len: size of rx and tx buffers (in bytes)
276 * @speed_hz: Select a speed other then the device default for this
277 * transfer. If 0 the default (from spi_device) is used.
278 * @bits_per_word: select a bits_per_word other then the device default
279 * for this transfer. If 0 the default (from spi_device) is used.
271 * @cs_change: affects chipselect after this transfer completes 280 * @cs_change: affects chipselect after this transfer completes
272 * @delay_usecs: microseconds to delay after this transfer before 281 * @delay_usecs: microseconds to delay after this transfer before
273 * (optionally) changing the chipselect status, then starting 282 * (optionally) changing the chipselect status, then starting
274 * the next transfer or completing this spi_message. 283 * the next transfer or completing this spi_message.
275 * @transfer_list: transfers are sequenced through spi_message.transfers 284 * @transfer_list: transfers are sequenced through spi_message.transfers
276 * 285 *
277 * SPI transfers always write the same number of bytes as they read. 286 * SPI transfers always write the same number of bytes as they read.
@@ -322,7 +331,9 @@ struct spi_transfer {
322 dma_addr_t rx_dma; 331 dma_addr_t rx_dma;
323 332
324 unsigned cs_change:1; 333 unsigned cs_change:1;
334 u8 bits_per_word;
325 u16 delay_usecs; 335 u16 delay_usecs;
336 u32 speed_hz;
326 337
327 struct list_head transfer_list; 338 struct list_head transfer_list;
328}; 339};
@@ -356,7 +367,7 @@ struct spi_transfer {
356 * and its transfers, ignore them until its completion callback. 367 * and its transfers, ignore them until its completion callback.
357 */ 368 */
358struct spi_message { 369struct spi_message {
359 struct list_head transfers; 370 struct list_head transfers;
360 371
361 struct spi_device *spi; 372 struct spi_device *spi;
362 373
@@ -374,7 +385,7 @@ struct spi_message {
374 */ 385 */
375 386
376 /* completion is reported through a callback */ 387 /* completion is reported through a callback */
377 void (*complete)(void *context); 388 void (*complete)(void *context);
378 void *context; 389 void *context;
379 unsigned actual_length; 390 unsigned actual_length;
380 int status; 391 int status;
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index c961fe9bf3eb..16ce178f54d7 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -30,6 +30,12 @@ struct spi_bitbang {
30 30
31 struct spi_master *master; 31 struct spi_master *master;
32 32
33 /* setup_transfer() changes clock and/or wordsize to match settings
34 * for this transfer; zeroes restore defaults from spi_device.
35 */
36 int (*setup_transfer)(struct spi_device *spi,
37 struct spi_transfer *t);
38
33 void (*chipselect)(struct spi_device *spi, int is_on); 39 void (*chipselect)(struct spi_device *spi, int is_on);
34#define BITBANG_CS_ACTIVE 1 /* normally nCS, active low */ 40#define BITBANG_CS_ACTIVE 1 /* normally nCS, active low */
35#define BITBANG_CS_INACTIVE 0 41#define BITBANG_CS_INACTIVE 0
@@ -51,6 +57,8 @@ struct spi_bitbang {
51extern int spi_bitbang_setup(struct spi_device *spi); 57extern int spi_bitbang_setup(struct spi_device *spi);
52extern void spi_bitbang_cleanup(const struct spi_device *spi); 58extern void spi_bitbang_cleanup(const struct spi_device *spi);
53extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m); 59extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m);
60extern int spi_bitbang_setup_transfer(struct spi_device *spi,
61 struct spi_transfer *t);
54 62
55/* start or stop queue processing */ 63/* start or stop queue processing */
56extern int spi_bitbang_start(struct spi_bitbang *spi); 64extern int spi_bitbang_start(struct spi_bitbang *spi);