uboot-mt623x/common
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
..
ACEX1K.c Improve configuration of FPGA subsystem 2008-01-09 13:34:20 +01:00
Makefile Altera Stratix II support 2008-04-13 14:52:48 -07:00
altera.c Altera Stratix II support 2008-04-13 14:52:48 -07:00
bedbug.c common/cmd_[af]*: Remove obsolete references to CONFIG_COMMANDS. 2007-07-08 17:55:57 -05:00
circbuf.c Add support for Siemens SX1 mobile phone; 2004-03-12 00:14:09 +00:00
cmd_ambapp.c Coding Style cleanup; update CHANGELOG 2008-04-13 09:59:26 -07:00
cmd_autoscript.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_bdinfo.c SPARC: added SPARC board information to the command bdinfo. 2008-04-08 07:58:32 +00:00
cmd_bedbug.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_bmp.c Fix compilation problem in common/cmd_bmp.c 2008-01-12 00:35:48 +01:00
cmd_boot.c allow ports to override go behavior 2008-04-18 00:31:41 -07:00
cmd_bootldr.c Blackfin: move bootldr command to common code 2008-03-15 22:13:58 -04:00
cmd_bootm.c Fix build errors when CONFIG_LOGBUFFER and CONFIG_FIT are enabled 2008-05-10 00:11:25 +02:00
cmd_cache.c common/: Remove lingering references to CFG_CMD_* symbols. 2007-07-10 11:02:44 -05:00
cmd_console.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_cplbinfo.c Blackfin: new cplbinfo command for viewing cplb tables 2008-03-15 22:14:54 -04:00
cmd_date.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_dcr.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_df.c SPI API improvements 2008-06-03 20:28:50 +02:00
cmd_diag.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_display.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_doc.c [new uImage] Use show_boot_progress() for new uImage format 2008-03-12 10:33:01 +01:00
cmd_dtt.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_eeprom.c common/: Remove lingering references to CFG_CMD_* symbols. 2007-07-10 11:02:44 -05:00
cmd_elf.c allow ports to override bootelf behavior 2008-04-18 00:30:42 -07:00
cmd_ext2.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_fat.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_fdc.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_fdos.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_fdt.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_flash.c Fix CFG_NO_FLASH compilation. 2008-03-30 21:19:40 +02:00
cmd_fpga.c [new uImage] Add new uImage fromat support to fpga command 2008-03-12 10:33:01 +01:00
cmd_i2c.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_ide.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_immap.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_itest.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_jffs2.c Fix building with CRAMFS but not JFFS2 support 2008-01-09 13:04:37 +01:00
cmd_load.c [new uImage] Add new uImage format support to autoscript routine 2008-03-12 10:33:00 +01:00
cmd_log.c Avoid initrd and logbuffer area overlaps 2008-06-03 19:34:19 +02:00
cmd_mac.c FSL: Fix common EEPROM_data structure definition 2008-01-17 12:26:56 -06:00
cmd_mem.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_mfsl.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_mii.c Add CONFIG_MII_INIT support to related boards 2008-04-13 23:03:02 -07:00
cmd_misc.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_mmc.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_mp.c 85xx: Update multicore boot mechanism to ePAPR v0.81 spec 2008-03-26 11:43:04 -05:00
cmd_nand.c Cleanup nand_info[] declaration. 2008-05-28 11:06:25 -05:00
cmd_net.c [new uImage] Add new uImage format support to autoscript routine 2008-03-12 10:33:00 +01:00
cmd_nvedit.c environment: cleanup prototype declarations of env functions. 2008-05-14 12:22:49 +02:00
cmd_onenand.c Fix OneNAND erase command 2008-04-13 23:10:39 -07:00
cmd_otp.c interface to Blackfin on-chip One-Time-Programmable memory 2008-02-04 19:26:57 -05:00
cmd_pci.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_pcmcia.c common/cmd_[p-x]*: Remove obsolete references to CONFIG_COMMANDS. 2007-07-08 18:05:39 -05:00
cmd_portio.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_reginfo.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_reiser.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_sata.c ata: add the support for SATA framework 2008-03-26 23:38:51 +01:00
cmd_scsi.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_setexpr.c Add setexpr command 2008-03-25 22:16:15 +01:00
cmd_spi.c SPI API improvements 2008-06-03 20:28:50 +02:00
cmd_strings.c new command for displaying strings at specified memory locations 2008-02-04 19:26:57 -05:00
cmd_terminal.c add 'terminal program' functionality 2008-01-09 13:26:38 +01:00
cmd_universe.c [BUILD] conditionally compile common/cmd_*.c in common/Makefile 2007-11-20 22:33:54 -07:00
cmd_usb.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_vfd.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
cmd_ximg.c Memory footprint optimizations 2008-04-24 17:21:55 +02:00
command.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
console.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
crc16.c Code cleanup 2006-07-21 11:56:05 +02:00
cyclon2.c Improve configuration of FPGA subsystem 2008-01-09 13:34:20 +01:00
devices.c GCC-4.x fixes: clean up global data pointer initialization for all boards. 2006-03-31 18:32:53 +02:00
dlmalloc.c Make sure common.h is the first include. 2008-06-03 19:42:05 +02:00
dlmalloc.src * Code cleanup: 2003-06-27 21:31:46 +00:00
docecc.c common/* non-cmd*: Remove obsolete references to CONFIG_COMMANDS 2007-07-08 18:10:08 -05:00
env_common.c Revert "Change env_get_char from a global function ptr to a function." 2008-05-12 00:40:58 +02:00
env_dataflash.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
env_eeprom.c environment: cleanup prototype declarations of env functions. 2008-05-14 12:22:49 +02:00
env_flash.c fix building when saveenv is disabled in some setups 2008-05-04 00:22:45 +02:00
env_nand.c Cleanup nand_info[] declaration. 2008-05-28 11:06:25 -05:00
env_nowhere.c GCC-4.x fixes: clean up global data pointer initialization for all boards. 2006-03-31 18:32:53 +02:00
env_nvram.c environment: cleanup prototype declarations of env functions. 2008-05-14 12:22:49 +02:00
env_onenand.c Fix OneNAND erase command 2008-04-13 23:10:39 -07:00
environment.c fix building on Blackfin as the assembler supports the .set syntax, not the = syntax, for assigning symbols 2008-02-04 19:26:54 -05:00
exports.c Add functions to list of exported functions 2007-08-06 00:45:40 +02:00
fdt_support.c 83xx/fdt_support: let user specifiy FSL USB Dual-Role controller role 2008-03-25 19:19:39 -05:00
flash.c ppc4xx: Update AMCC Bamboo 440EP support 2007-07-31 10:24:56 +02:00
fpga.c Altera Stratix II support 2008-04-13 14:52:48 -07:00
ft_build.c environment: cleanup prototype declarations of env functions. 2008-05-14 12:22:49 +02:00
gunzip.c [new uImage] Move gunzip() common code to common/gunzip.c 2008-02-07 01:12:55 +01:00
hush.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
image.c Avoid initrd and logbuffer area overlaps 2008-06-03 19:34:19 +02:00
kgdb.c common/kgdb.c: fix 'dereferencing type-punned pointer' warning 2008-03-09 10:33:31 +01:00
lcd.c Cleanup nand_info[] declaration. 2008-05-13 21:49:04 +02:00
lists.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
lynxkdi.c [new uImage] Cleanup cmd_bootm.c 2008-02-07 01:12:56 +01:00
main.c Fix readline_into_buffer() with CONFIG_CMDLINE_EDITING before relocating 2008-05-09 22:18:15 +02:00
memsize.c Sequential accesses to non-existent memory must be synchronized, 2006-11-06 17:06:36 +01:00
miiphybb.c Cleanup compile warnings. Prepare for release 1.1.5 2006-10-20 17:54:33 +02:00
miiphyutil.c common/miiphyutil.c: Cleanup MII_DEBUG and debug() 2008-02-14 22:10:38 +01:00
s_record.c Initial revision 2002-08-17 09:36:01 +00:00
serial.c ARM: s3c24xx: Multiple serial port support 2008-02-04 23:52:49 +01:00
soft_i2c.c soft_i2c: Pull SDA high before reading 2008-06-03 20:25:56 +02:00
soft_spi.c SPI API improvements 2008-06-03 20:28:50 +02:00
spartan2.c Fix MSB check in Xilinx Spartan slave serial mode 2008-01-09 13:37:08 +01:00
spartan3.c Fix MSB check in Xilinx Spartan slave serial mode 2008-01-09 13:37:08 +01:00
stratixII.c Altera Stratix II support 2008-04-13 14:52:48 -07:00
usb.c USB: replace old swap_ with proper endianess conversion macros 2008-05-22 17:29:32 +02:00
usb_kbd.c USB: replace old swap_ with proper endianess conversion macros 2008-05-22 17:29:32 +02:00
usb_storage.c USB: replace old swap_ with proper endianess conversion macros 2008-05-22 17:29:32 +02:00
virtex2.c Big white-space cleanup. 2008-05-21 00:14:08 +02:00
xilinx.c Improve configuration of FPGA subsystem 2008-01-09 13:34:20 +01:00
xyzModem.c Coding Style cleanup. 2006-08-31 16:46:53 +02:00