SAMV7: Add configuration options to select SPI slave (slave driver not yet committed)

This commit is contained in:
Gregory Nutt 2015-08-09 09:47:06 -06:00
parent 05aae51c89
commit 7e7150899a
4 changed files with 110 additions and 17 deletions

View File

@ -147,10 +147,6 @@ config SAMV7_HAVE_SDRAMC
bool
default n
config SAMV7_HAVE_SPI
bool
default n
config SAMV7_HAVE_SPI0
bool
default n
@ -191,6 +187,18 @@ config SAMV7_HAVE_USART2
bool
default n
config SAMV7_SPI
bool
default n
config SAMV7_SPI_MASTER
bool
default n
config SAMV7_SPI_SLAVE
bool
default n
# Peripheral Selection
menu "SAMV7 Peripheral Selection"
@ -299,14 +307,14 @@ config SAMV7_SPI0
bool "Serial Peripheral Interface 0 (SPI0)"
default n
depends on SAMV7_HAVE_SPI0
select SAMV7_HAVE_SPI
select SAMV7_SPI
select SPI
config SAMV7_SPI1
bool "Serial Peripheral Interface 1 (SPI1)"
default n
depends on SAMV7_HAVE_SPI1
select SAMV7_HAVE_SPI
select SAMV7_SPI
select SPI
config SAMV7_SSC0
@ -526,8 +534,51 @@ config SAMV7_SDRAMHEAP
endmenu # SDRAM Configuration
menu "SAMV7 SPI device driver options"
depends on AMV7_SPI0 || SAMV7_SPI1
menu "SPI Device Driver Configuration"
depends on SAMV7_SPI
choice
prompt "SPI0 Configuration"
default SAMV7_SPI0_MASTER
depends on SAMV7_SPI0
config SAMV7_SPI0_MASTER
bool "Master"
select SAMV7_SPI_MASTER
---help---
Configure SPI0 as an SPI master driver. Default: Master
config SAMV7_SPI0_SLAVE
bool "Slave"
depends on EXPERIMENTAL
select SAMV7_SPI_SLAVE
---help---
Configure SPI0 as an SPI slave driver. Default: Master
endchoice # SPI0 Configuration
choice
prompt "SPI1 Configuration"
default SAMV7_SPI1_MASTER
depends on SAMV7_SPI1
config SAMV7_SPI1_MASTER
bool "Master"
select SAMV7_SPI_MASTER
---help---
Configure SPI1 as an SPI master driver. Default: Master
config SAMV7_SPI1_SLAVE
bool "Slave"
depends on EXPERIMENTAL
select SAMV7_SPI_SLAVE
---help---
Configure SPI1 as an SPI slave driver. Default: Master
endchoice # SPI1 Configuration
if SAMV7_SPI_MASTER
comment "SPI Master Configuration"
config SAMV7_SPI_DMA
bool "SPI DMA"
@ -555,6 +606,8 @@ config SAMV7_SPI_DMADEBUG
registers at key points in the data transfer and then dumps all of
the registers at the end of the transfer.
endif # SAMV7_SPI_MASTER
config SAMV7_SPI_REGDEBUG
bool "SPI Register level debug"
depends on DEBUG

View File

@ -124,12 +124,14 @@ ifeq ($(CONFIG_SAMV7_XDMAC),y)
CHIP_CSRCS += sam_xdmac.c
endif
ifeq ($(CONFIG_SAMV7_SPI0),y)
CHIP_CSRCS += sam_spi.c
else ifeq ($(CONFIG_SAMV7_SPI1),y)
ifeq ($(CONFIG_SAMV7_SPI_MASTER),y)
CHIP_CSRCS += sam_spi.c
endif
ifeq ($(CONFIG_SAMV7_SPI_SLAVE),y)
CHIP_CSRCS += sam_spi_slave.c
endif
ifeq ($(CONFIG_SAMV7_TWIHS0),y)
CHIP_CSRCS += sam_twihs.c
else ifeq ($(CONFIG_SAMV7_TWIHS1),y)

View File

@ -257,20 +257,58 @@
#if CHIP_NSPI < 1
# undef CONFIG_SAMV7_SPI0
# undef CONFIG_SAMV7_SPI0_MASTER
# undef CONFIG_SAMV7_SPI0_SLAVE
# undef CONFIG_SAMV7_SPI1
# undef CONFIG_SAMV7_SPI1_MASTER
# undef CONFIG_SAMV7_SPI1_SLAVE
#elif CHIP_NSPI < 2
# undef CONFIG_SAMV7_SPI1
# undef CONFIG_SAMV7_SPI1_MASTER
# undef CONFIG_SAMV7_SPI1_SLAVE
#endif
#ifndef CONFIG_SAMV7_HAVE_SPI
#ifndef CONFIG_SAMV7_SPI
# undef CONFIG_SAMV7_SPI0
# undef CONFIG_SAMV7_SPI0_MASTER
# undef CONFIG_SAMV7_SPI0_SLAVE
# undef CONFIG_SAMV7_SPI1
# undef CONFIG_SAMV7_SPI1_MASTER
# undef CONFIG_SAMV7_SPI1_SLAVE
#endif
/* Are any SPI peripherals enabled? */
#if !defined(CONFIG_SAMV7_SPI0) && !defined(CONFIG_SAMV7_SPI0)
# undef CONFIG_SAMV7_HAVE_SPI
# undef CONFIG_SAMV7_SPI
# undef CONFIG_SAMV7_SPI_MASTER
# undef CONFIG_SAMV7_SPI_SLAVE
#endif
/* Each SPI peripheral must be enabled as a MASTER or as a SLAVE */
#ifndef CONFIG_SAMV7_SPI_MASTER
# undef CONFIG_SAMV7_SPI0_MASTER
# undef CONFIG_SAMV7_SPI1_MASTER
#endif
#if !defined(CONFIG_SAMV7_SPI0_MASTER) && !defined(CONFIG_SAMV7_SPI1_MASTER)
# undef CONFIG_SAMV7_SPI_MASTER
#endif
#ifndef CONFIG_SAMV7_SPI_SLAVE
# undef CONFIG_SAMV7_SPI0_SLAVE
# undef CONFIG_SAMV7_SPI1_SLAVE
#endif
#if !defined(CONFIG_SAMV7_SPI0_SLAVE) && !defined(CONFIG_SAMV7_SPI1_SLAVE)
# undef CONFIG_SAMV7_SPI_SLAVE
#endif
#if !defined(CONFIG_SAMV7_SPI_MASTER) && !defined(CONFIG_SAMV7_SPI_SLAVE)
# undef CONFIG_SAMV7_SPI
# undef CONFIG_SAMV7_SPI0
# undef CONFIG_SAMV7_SPI1
#endif
/****************************************************************************

View File

@ -69,7 +69,7 @@
#include "chip/sam_spi.h"
#include "chip/sam_pinmap.h"
#if defined(CONFIG_SAMV7_SPI0) || defined(CONFIG_SAMV7_SPI1)
#ifdef CONFIG_SAMV7_SPI_MASTER
/****************************************************************************
* Pre-processor Definitions
@ -118,7 +118,7 @@
#define DMA_TIMEOUT_TICKS MSEC2TICK(DMA_TIMEOUT_MS)
/* Debug *******************************************************************/
/* Check if SPI debut is enabled (non-standard.. no support in
/* Check if SPI debug is enabled (non-standard.. no support in
* include/debug.h
*/
@ -273,7 +273,7 @@ static inline uintptr_t spi_regaddr(struct sam_spics_s *spics,
unsigned int offset);
#endif
/* SPI methods */
/* SPI master methods */
#ifndef CONFIG_SPI_OWNBUS
static int spi_lock(struct spi_dev_s *dev, bool lock);
@ -1938,4 +1938,4 @@ struct spi_dev_s *up_spiinitialize(int port)
return &spics->spidev;
}
#endif /* CONFIG_SAMV7_SPI0 || CONFIG_SAMV7_SPI1 */
#endif /* CONFIG_SAMV7_SPI_MASTER */