From 83d645aff0279effbf279d7441f2d847a7983221 Mon Sep 17 00:00:00 2001 From: Jingchang Lu Date: Tue, 3 Jul 2012 13:26:54 +0800 Subject: Add quad SPI support for Vybrid Signed-off-by: TsiChung Liew --- drivers/spi/Makefile | 1 + drivers/spi/quad_spi.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 drivers/spi/quad_spi.c (limited to 'drivers') diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index c967d87834..c3746b035c 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -40,6 +40,7 @@ COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o COBJS-$(CONFIG_MXS_SPI) += mxs_spi.o COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o +COBJS-$(CONFIG_QUAD_SPI) += quad_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o COBJS-$(CONFIG_SH_SPI) += sh_spi.o COBJS-$(CONFIG_FSL_ESPI) += fsl_espi.o diff --git a/drivers/spi/quad_spi.c b/drivers/spi/quad_spi.c new file mode 100644 index 0000000000..7afeacf72e --- /dev/null +++ b/drivers/spi/quad_spi.c @@ -0,0 +1,133 @@ +/* + * Copyright 2012 Freescale Semiconductor, Inc. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include +#include + +struct quadspi_slave { + struct spi_slave slave; + uint baudrate; + int charbit; +}; + +int quadspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, + void *din, ulong flags); +struct spi_slave *quadspi_setup_slave(struct quadspi_slave *slave, uint mode); +void quadspi_init(void); +void quadspi_tx(u32 ctrl, u16 data); +u16 quadspi_rx(void); + +extern void setup_iomux_quadspi(void); +extern int quadspi_claim_bus(uint bus, uint cs); +extern void quadspi_release_bus(uint bus, uint cs); + +DECLARE_GLOBAL_DATA_PTR; + +#ifdef CONFIG_QUAD_SPI +void quadspi_init(void) +{ + setup_iomux_quadspi(); /* port configuration */ +} + +void quadspi_tx(u32 ctrl, u16 data) +{ +} + +u16 quadspi_rx(void) +{ + return 0; +} + +int quadspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, + void *din, ulong flags) +{ + return 0; +} + +struct spi_slave *quadspi_setup_slave(struct quadspi_slave *slave, uint mode) +{ + return 0; +} +#endif /* CONFIG_QUAD_SPI */ + +#ifdef CONFIG_CMD_SPI +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return 0; +} + +void spi_init_f(void) +{ +} + +void spi_init_r(void) +{ +} + +void spi_init(void) +{ + quadspi_init(); +} + +struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, + unsigned int max_hz, unsigned int mode) +{ + struct quadspi_slave *slave; + + if (!spi_cs_is_valid(bus, cs)) + return NULL; + + slave = malloc(sizeof(struct quadspi_slave)); + if (!slave) + return NULL; + + slave->slave.bus = bus; + slave->slave.cs = cs; + slave->baudrate = max_hz; + + /* specific setup */ + return quadspi_setup_slave(slave, mode); +} + +void spi_free_slave(struct spi_slave *slave) +{ + free(slave); +} + +int spi_claim_bus(struct spi_slave *slave) +{ + return quadspi_claim_bus(slave->bus, slave->cs); +} + +void spi_release_bus(struct spi_slave *slave) +{ + quadspi_release_bus(slave->bus, slave->cs); +} + +int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, + void *din, unsigned long flags) +{ + return quadspi_xfer(slave, bitlen, dout, din, flags); +} +#endif /* CONFIG_CMD_SPI */ -- cgit v1.2.3