summaryrefslogtreecommitdiff
path: root/include/spi.h
AgeCommit message (Collapse)Author
2011-08-29Modify the API for doing transfers over SPI.Gabe Black
This change modifies the spi_xfer function to take read and write buffers and read and write bit counts which is similar to what flashrom does. This has the nice effect of simiplifying many call sights, and will allow integrating SPI controllers which don't allow arbitrary control of the chip select lines. Only boards which are being used with ChromeOS and the functionality they use will be updated immediately. That's because those are the cases which can actually be tested effectively, and fixing up the other locations can be put off until later. These change and the eventual change that updates all the other call sights/drivers can also be reviewed and tested independently. It will also make rebasing easier. To try to make the transition less painful, the new interface is selectable using the CONFIG_NEW_SPI_XFER option. This selects whether the new or old interface is used. BUG=chrome-os-partner:4722 TEST=With this and related changes, built for x86-alex, tegra2_kaen, tegra2_aebl, tegra2_seaboard, and tegra2_asymptote. Flashed the firmware on a Kaen, verified the checksums matched, and booted to ChromeOS login. Built with the option turned off on x86-alex and tegra2_kaen. Change-Id: If32843255584544b08b9c8e18bbd9f36273fb71b Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://gerrit.chromium.org/gerrit/5374 Reviewed-by: Stefan Reinauer <reinauer@google.com>
2011-04-29powerpc: eSPI and eSPI controller supportMingkai Hu
Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com> Singed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com> Signed-off-by: Shaohui Xie <b21989@freescale.com> Cc: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2011-04-25spi: add spi_set_speed funcThomas Chou
This func helps mmc_spi driver set correct speed for mmc/sd, as mmc card needs 400KHz clock for spi mode initialization. Signed-off-by: Thomas Chou <thomas@wytron.com.tw> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2008-07-01Move conditional compilation of MPC8XXX SPI driver to MakefileBen Warren
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2008-06-03SPI API improvementsHaavard Skinnemoen
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-04-18New i.MX31 SPI driverGuennadi Liakhovetski
This is an SPI driver for i.MX and MXC based SoCs from Freescale. So far only implemented and tested on i.MX31, can with a modified register layout and definitions be used for i.MX27, I think, MXC CPUs have similar SPI controllers too. Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
2002-09-26Initial revisionwdenk