u-boot/include
Haavard Skinnemoen d255bb0e78 SPI API improvements
This patch gets rid of the spi_chipsel table and adds a handful of new
functions that makes the SPI layer cleaner and more flexible.

Instead of the spi_chipsel table, each board that wants to use SPI
gets to implement three hooks:
  * spi_cs_activate(): Activates the chipselect for a given slave
  * spi_cs_deactivate(): Deactivates the chipselect for a given slave
  * spi_cs_is_valid(): Determines if the given bus/chipselect
    combination can be activated.

Not all drivers may need those extra functions however. If that's the
case, the board code may just leave them out (assuming they know what
the driver needs) or rely on the linker to strip them out (assuming
--gc-sections is being used.)

To set up communication parameters for a given slave, the driver needs
to call spi_setup_slave(). This returns a pointer to an opaque
spi_slave struct which must be passed as a parameter to subsequent SPI
calls. This struct can be freed by calling spi_free_slave(), but most
driver probably don't want to do this.

Before starting one or more SPI transfers, the driver must call
spi_claim_bus() to gain exclusive access to the SPI bus and initialize
the hardware. When all transfers are done, the driver must call
spi_release_bus() to make the bus available to others, and possibly
shut down the SPI controller hardware.

spi_xfer() behaves mostly the same as before, but it now takes a
spi_slave parameter instead of a spi_chipsel function pointer. It also
got a new parameter, flags, which is used to specify chip select
behaviour. This may be extended with other flags in the future.

This patch has been build-tested on all powerpc and arm boards
involved. I have not tested NIOS since I don't have a toolchain for it
installed, so I expect some breakage there even though I've tried
fixing up everything I could find by visual inspection.

I have run-time tested this on AVR32 ATNGW100 using the atmel_spi and
DataFlash drivers posted as a follow-up. I'd like some help testing
other boards that use the existing SPI API.

But most of all, I'd like some comments on the new API. Is this stuff
usable for everyone? If not, why?

Changed in v4:
  - Build fixes for various boards, drivers and commands
  - Provide common struct spi_slave definition that can be extended by
    drivers
  - Pass a struct spi_slave * to spi_cs_activate and spi_cs_deactivate
  - Make default bus and mode build-time configurable
  - Override default SPI bus ID and mode on mx32ads and imx31_litekit.

Changed in v3:
  - Add opaque struct spi_slave for controller-specific data associated
    with a slave.
  - Add spi_claim_bus() and spi_release_bus()
  - Add spi_free_slave()
  - spi_setup() is now called spi_setup_slave() and returns a
    struct spi_slave
  - soft_spi now supports four SPI modes (CPOL|CPHA)
  - Add bus parameter to spi_setup_slave()
  - Convert the new i.MX32 SPI driver
  - Convert the new MC13783 RTC driver

Changed in v2:
  - Convert the mpc8xxx_spi driver and the mpc8349emds board to the
    new API.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Tested-by: Guennadi Liakhovetski <lg@denx.de>
2008-06-03 20:28:50 +02:00
..
asm-arm Move definition of container_of() to common.h 2008-06-03 20:27:23 +02:00
asm-avr32 Move definition of container_of() to common.h 2008-06-03 20:27:23 +02:00
asm-blackfin Merge branch 'lwmon5' of /home/wd/git/u-boot/projects 2008-05-21 01:13:39 +02:00
asm-i386 Merge branch 'lwmon5' of /home/wd/git/u-boot/projects 2008-05-21 01:13:39 +02:00
asm-m68k Merge branch 'lwmon5' of /home/wd/git/u-boot/projects 2008-05-21 01:13:39 +02:00
asm-microblaze Merge branch 'lwmon5' of /home/wd/git/u-boot/projects 2008-05-21 01:13:39 +02:00
asm-mips mips: Add an 'include/asm/errno.h', like all other architectures 2008-05-30 00:53:38 +09:00
asm-nios Merge branch 'lwmon5' of /home/wd/git/u-boot/projects 2008-05-21 01:13:39 +02:00
asm-nios2 POST: replace the LOGBUFF_INITIALIZED flag in gd->post_log_word (1 << 31) with the GD_FLG_LOGINIT flag in gd->flags. 2008-05-20 23:24:38 +02:00
asm-ppc Fix warnings from gcc-4.3.0 build on a ppc host 2008-06-03 19:52:52 +02:00
asm-sh Merge branch 'lwmon5' of /home/wd/git/u-boot/projects 2008-05-21 01:13:39 +02:00
asm-sparc POST: replace the LOGBUFF_INITIALIZED flag in gd->post_log_word (1 << 31) with the GD_FLG_LOGINIT flag in gd->flags. 2008-05-20 23:24:38 +02:00
bedbug Big white-space cleanup. 2008-05-21 00:14:08 +02:00
configs SPI API improvements 2008-06-03 20:28:50 +02:00
cramfs Fix endianess problem in cramfs code (cramfs is always host-endian in Linux) 2008-03-03 22:08:08 +01:00
galileo Big white-space cleanup. 2008-05-21 00:14:08 +02:00
jffs2 Add common (with Linux) MTD partition scheme and "mtdparts" command 2005-08-08 01:03:24 +02:00
linux NAND: Provide a sane default for NAND_MAX_CHIPS. 2008-05-28 11:06:24 -05:00
pcmcia Fix IDE stability problems on CPC45 board. 2005-01-22 18:26:04 +00:00
u-boot Add support for calculating hashes with watchdog triggering 2008-04-25 00:01:06 +02:00
.gitignore include/gitignore: update to all architectures 2008-05-09 20:59:21 +02:00
4xx_i2c.h ppc4xx: Add basic support for AMCC 460EX/460GT (3/5) 2008-03-15 07:28:04 +01:00
74xx_7xx.h [ppc] Fix build breakage for all non-4xx PowerPC variants. 2007-06-22 14:58:04 +02:00
405_dimm.h * Code cleanup: 2003-06-27 21:31:46 +00:00
405_mal.h ppc4xx: Add basic support for AMCC 460EX/460GT (3/5) 2008-03-15 07:28:04 +01:00
_exports.h [ARM] TI DaVinci support, hopefully final 2007-08-10 20:26:18 +02:00
ACEX1K.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ahci.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
altera.h Altera Stratix II support 2008-04-13 14:52:48 -07:00
ambapp.h Coding Style cleanup; update CHANGELOG 2008-04-13 09:59:26 -07:00
api_public.h API: Add (c) and licensing notice to the public API header. 2008-02-21 11:56:44 +01:00
arm920t.h * Code cleanup: 2003-06-27 21:31:46 +00:00
arm925t.h [PATCH] omap925.c: Remove unused functions 2006-10-28 17:13:12 +02:00
arm926ejs.h * Patch by George G. Davis, 19 Aug 2003: 2003-08-29 22:00:43 +00:00
arm946es.h Add ARM946E cpu and core module targets; remap memory to 0x00000000 2005-09-25 01:48:28 +02:00
armcoremodule.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
at45.h Coding style cleanup. Update CHANGELOG. 2007-08-14 18:42:36 +02:00
at91rm9200_i2c.h Code Cleanup 2004-10-10 18:03:33 +00:00
at91rm9200_net.h * Move dm9161.c and lxt972.c into cpu/arm920t/at91rm9200 2005-10-05 01:51:29 +02:00
ata.h Minor coding style cleanup. 2007-05-15 23:38:05 +02:00
atmel_lcdc.h Add ATMEL LCD driver 2008-05-10 11:44:55 +02:00
bcd.h rtc: Add Xicor/Intersil X1205 RTC support 2007-10-31 21:20:50 +01:00
bcm5221.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
bmp_layout.h * Implement new mechanism to export U-Boot's functions to standalone 2003-07-24 23:38:38 +00:00
bzlib.h * Patches by Xianghua Xiao, 15 Oct 2003: 2003-10-15 23:53:47 +00:00
circbuf.h Add support for Siemens SX1 mobile phone; 2004-03-12 00:14:09 +00:00
clps7111.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
command.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
common.h Move definition of container_of() to common.h 2008-06-03 20:27:23 +02:00
commproc.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
config_cmd_all.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
config_cmd_default.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
console.h Initial revision 2000-11-12 23:38:42 +00:00
crc.h Some code cleanup 2006-04-16 10:51:58 +02:00
da9030.h This patch adds USB storage support for the delta board. This is the first 2006-05-22 16:33:54 +02:00
dataflash.h Clean up dataflash partitioning 2008-04-18 00:24:05 -07:00
devices.h Add support for console over UDP (compatible to Ingo Molnar's 2004-08-02 21:11:11 +00:00
div64.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
dm9161.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
dp83848.h [ARM] TI DaVinci support, hopefully final 2007-08-10 20:26:18 +02:00
dtt.h Add driver for National Semiconductor LM73 temperature sensor 2007-12-27 19:35:35 +01:00
e500.h Reworked FSL Book-E TLB macros to be more readable 2008-01-09 16:25:03 -06:00
elf.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
environment.h environment: fix bug introduced by commit a8409f4f1a 2008-05-14 23:36:10 +02:00
exports.h [ARM] TI DaVinci support, hopefully final 2007-08-10 20:26:18 +02:00
ext2fs.h ext2fs support added 2004-12-16 17:33:10 +00:00
fat.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
fdc.h * Code cleanup: 2003-06-27 21:31:46 +00:00
fdt.h Fix host tool build breakage, take two 2008-03-27 23:49:12 +01:00
fdt_support.h 83xx/fdt_support: let user specifiy FSL USB Dual-Role controller role 2008-03-25 19:19:39 -05:00
fis.h ata: add the fis struct for SATA 2008-03-26 23:38:54 +01:00
flash.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
fpga.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ft_build.h * Fix a bunch of compiler warnings for gcc 4.0 2006-10-19 11:33:52 -05:00
hush.h Initial revision 2002-11-03 00:07:02 +00:00
i2c.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
i8042.h * Patch by Marc Singer, 29 May 2003: 2003-05-31 18:35:21 +00:00
ide.h IDE: - make ide_inb () and ide_outb () "weak", so boards can 2007-08-28 17:39:14 +02:00
image.h Use watchdog-aware functions when calculating hashes of images - take two 2008-04-25 14:05:21 +02:00
ioports.h Stop using immap_t for cpm offset on 85xx 2007-12-11 22:34:19 -06:00
keyboard.h [Strange. I _did_ check these in before. Seems SF restored an old 2004-01-16 00:30:56 +00:00
kgdb.h Initial revision 2002-08-27 10:38:37 +00:00
lcd.h Add ATMEL LCD driver 2008-05-10 11:44:55 +02:00
lcdvideo.h Initial revision 2001-11-03 22:15:16 +00:00
lh7a40x.h * Patch by Paul Ruhland, 10 Jun 2004: 2004-06-10 21:55:33 +00:00
lh7a400.h * Patch by Paul Ruhland, 10 Jun 2004: 2004-06-10 21:55:33 +00:00
lh7a404.h * Patch by Paul Ruhland, 10 Jun 2004: 2004-06-10 21:55:33 +00:00
libata.h ata: update the libata.h from ata.h of linux kernel 2008-04-13 23:20:16 -07:00
libfdt.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
libfdt_env.h Fix host tool build breakage, take two 2008-03-27 23:49:12 +01:00
linux_logo.h Initial revision 2002-09-17 21:37:55 +00:00
lists.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
lmb.h [new uImage] Introduce lmb from linux kernel for memory mgmt of boot images 2008-02-29 13:15:55 +01:00
logbuff.h Avoid initrd and logbuffer area overlaps 2008-06-03 19:34:19 +02:00
lpd7a400_cpld.h * Patch by Paul Ruhland, 17 May 2004: 2004-06-09 13:37:52 +00:00
lxt971a.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
lynxkdi.h * Patch by Scott McNutt, 21 Jul 2003: 2003-07-27 00:21:01 +00:00
malloc.h * Code cleanup: 2003-06-27 21:31:46 +00:00
mb862xx.h Add Fujitsu CoralP/Lime video driver 2008-01-11 16:05:36 +01:00
MCD_dma.h ColdFire: Add MCF547x_8x dma code and header files 2008-01-17 14:59:42 -06:00
MCD_progCheck.h ColdFire: Add MCF547x_8x dma code and header files 2008-01-17 14:59:42 -06:00
MCD_tasksInit.h ColdFire: Add MCF547x_8x dma code and header files 2008-01-17 14:59:42 -06:00
mii_phy.h * Code cleanup: 2003-06-27 21:31:46 +00:00
miiphy.h NET: Add Ethernet 1000BASE-X support for PPC4xx 2007-11-06 10:25:33 -05:00
mk48t59.h include/: Remove obsolete references to CONFIG_COMMANDS 2007-07-09 17:15:49 -05:00
mmc.h * Fix CONFIG_NET_MULTI support in include/net.h 2003-06-15 22:40:42 +00:00
mpc5xx.h Coding stylke cleanup; rebuild CHANGELOG 2007-06-22 23:59:00 +02:00
mpc5xxx.h [ppc] Fix build breakage for all non-4xx PowerPC variants. 2007-06-22 14:58:04 +02:00
mpc8xx.h Coding stylke cleanup; rebuild CHANGELOG 2007-06-22 23:59:00 +02:00
mpc8xx_irq.h Initial revision 2001-04-28 17:59:11 +00:00
mpc83xx.h mpc83xx: cleanup System Part and Revision ID Register (SPRIDR) code 2008-03-28 16:01:06 -05:00
mpc85xx.h 85xx start.S cleanup and exception support 2007-08-14 01:34:21 -05:00
mpc86xx.h [ppc] Fix build breakage for all non-4xx PowerPC variants. 2007-06-22 14:58:04 +02:00
mpc106.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
mpc512x.h MPC5121e ADS PCI support take 3 2008-03-02 21:44:59 +01:00
mpc824x.h Coding stylke cleanup; rebuild CHANGELOG 2007-06-22 23:59:00 +02:00
mpc8220.h [ppc] Fix build breakage for all non-4xx PowerPC variants. 2007-06-22 14:58:04 +02:00
mpc8260.h Coding stylke cleanup; rebuild CHANGELOG 2007-06-22 23:59:00 +02:00
mpc8260_irq.h Patches by Murray Jensen, 17 Jun 2003: 2003-06-19 23:40:20 +00:00
nand.h NAND: fix some strict-aliasing compiler warnings 2008-04-28 12:08:18 +02:00
net.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
nios-io.h Patch by Scott McNutt, 25 Apr 2004: 2004-05-19 21:33:14 +00:00
nios.h * Patch by Scott McNutt, 04 Oct 2003: 2003-10-08 23:26:14 +00:00
nios2-epcs.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
nios2-io.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
nios2.h Patches by Scott McNutt, 24 Aug 2004: 2004-10-10 21:27:30 +00:00
ns7520_eth.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_bbus.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_eth.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_mem.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_ser.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_sys.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns16550.h Add support for TB5200 board 2006-07-19 13:50:38 +02:00
ns87308.h Initial revision 2002-04-01 14:29:03 +00:00
onenand_uboot.h Make onenand_uboot.h self-sufficient. 2008-05-28 11:06:28 -05:00
part.h Coding style cleanup, update CHANGELOG 2008-03-27 00:03:57 +01:00
pc_keyb.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
pci.h Update pci code to use phys_addr_t 2008-05-10 00:59:57 +02:00
pci_ids.h Additional PCI IDs for IDE and network controllers 2008-04-17 13:37:57 -07:00
pcmcia.h cpu/ rtc/ include/: Remove lingering references to CFG_CMD_* symbols. 2007-07-10 10:27:39 -05:00
post.h POST: add POST_STOP flag 2008-05-20 23:24:37 +02:00
ppc4xx.h ppc4xx: Consolidate some of the 405 and 440 macros/structs into 4xx 2007-10-31 21:20:50 +01:00
ppc4xx_enet.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ppc405.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ppc440.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ppc_asm.tmpl e500 needs ppc_asm.tmp MCK_EXCEPTION 2007-08-14 01:21:22 -05:00
ppc_defs.h Initial revision 2000-07-19 14:09:16 +00:00
ps2mult.h * The PS/2 mux on the BMS2003 board needs 450 ms after power on 2004-01-20 23:12:12 +00:00
radeon.h Extend ATI Radeon driver to support more video modes 2008-02-15 00:54:01 +01:00
reiserfs.h Code cleanup 2004-03-25 15:14:43 +00:00
rtc.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
s3c24x0.h * Code cleanup: 2003-06-27 21:31:46 +00:00
s3c2400.h Cleanup trab board for GCC-4.x 2006-06-26 10:54:52 +02:00
s3c2410.h Fix compiler warning in include/s3c2410.h 2007-08-29 02:05:53 +02:00
s_record.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
SA-1100.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
sa1100.h Initial revision 2002-03-27 13:48:44 +00:00
sata.h drivers: code clean up 2008-04-13 14:57:46 -07:00
scsi.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
sed156x.h * Patches by Pantelis Antoniou, 30 Mar 2004: 2004-04-15 21:16:42 +00:00
sed13806.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
serial.h ARM: s3c24xx: Multiple serial port support 2008-02-04 23:52:49 +01:00
sha1.h Add support for calculating hashes with watchdog triggering 2008-04-25 00:01:06 +02:00
sm501.h Add SM501 support to HH405 board. 2005-09-22 09:04:17 +02:00
smiLynxEM.h * Code cleanup: 2003-06-27 21:31:46 +00:00
spartan2.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
spartan3.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
spd.h Fix style issues primarily in 85xx and 83xx boards. 2005-08-01 13:20:47 -05:00
spd_sdram.h Support for DDR with 32-data path. Addotional notes on injecting 2006-03-16 17:46:46 +01:00
spi.h SPI API improvements 2008-06-03 20:28:50 +02:00
status_led.h Coding Style cleanup. 2007-10-13 21:15:39 +02:00
stratixII.h Altera Stratix II support 2008-04-13 14:52:48 -07:00
sym53c8xx.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
systemace.h * CVS add missing files 2004-02-23 16:11:30 +00:00
tsi108.h Clean up the code according to codestyle: 2006-12-01 11:47:36 +08:00
universe.h Code cleanup. 2004-12-16 21:44:03 +00:00
usb.h Fix compilation error in cmd_usb.c 2008-03-27 00:12:56 +01:00
usb_cdc_acm.h Code cleanup 2006-06-14 18:14:56 +02:00
usb_defs.h Remove unnecessary defines from usb_defs.h again. 2005-08-02 15:08:46 +02:00
usbdcore.h Various USB related patches 2006-06-14 17:45:53 +02:00
usbdcore_ep0.h Add support for Siemens SX1 mobile phone; 2004-03-12 00:14:09 +00:00
usbdcore_mpc8xx.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
usbdcore_omap1510.h Various USB related patches 2006-06-14 17:45:53 +02:00
usbdescriptors.h Code cleanup 2006-06-14 18:14:56 +02:00
version.h Makefile: fix "error: version_autogenerated.h: No such file or directory" 2008-05-13 23:15:52 +02:00
vfd_logo.h * Add support for arbitrary bitmaps for TRAB's VFD command 2003-05-20 20:49:01 +00:00
video.h Initial revision 2001-11-03 22:21:15 +00:00
video_ad7176.h * Patches by Yuli Barcohen, 13 Jul 2003: 2003-07-14 22:13:32 +00:00
video_ad7177.h * Patches by Yuli Barcohen, 13 Jul 2003: 2003-07-14 22:13:32 +00:00
video_ad7179.h * Add support for IceCube board (with MGT5100 and MPC5200 CPUs) 2003-07-16 21:53:01 +00:00
video_easylogo.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
video_fb.h * Code cleanup: 2003-06-27 21:31:46 +00:00
video_font.h Initial revision 2000-10-25 11:24:22 +00:00
video_logo.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
virtex2.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
vsc7385.h Cleanup coding style, update CHANGELOG 2008-03-26 11:48:46 +01:00
w83c553f.h Initial revision 2002-03-08 21:31:05 +00:00
watchdog.h Cleanup (PPC4xx is AMCC now) 2005-09-23 11:05:55 +02:00
xilinx.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
xyzModem.h More code cleanup 2006-07-21 15:24:56 +02:00
zlib.h * Code cleanup: 2003-06-27 21:31:46 +00:00