SAMA5 SSC: Add support for loopback mode. Plus unrelated Make.defs file from the last checkin

This commit is contained in:
Gregory Nutt 2013-11-10 11:46:45 -06:00
parent 8cc9d6a572
commit 53667316be
2 changed files with 50 additions and 1 deletions

View File

@ -1528,6 +1528,17 @@ config SAMA5_SSC0_MCKDIV_SAMPLERATE
divider to obtain that bitrate (up to 4095). If the bitrate can be realized
by dividing down the MCK/2, a compile time error will occur.
config SAMA5_SSC0_LOOPBACK
bool "Loopback mode"
default n
depends on SAMA5_SSC0_TX && SAMA5_SSC0_RX
---help---
If both the receiver and transmitter are enabled, then the SSC can
be configured in loopback mode. This setting selects SSC loopback
and will cause the LOOP bit to be set in the SSC_RFMR regsiter. In
this case, RD is connected to TD, RF is connected to TF and RK is
connected to TK.
endif # SAMA5_SSC0
if SAMA5_SSC1
@ -1669,6 +1680,17 @@ config SAMA5_SSC1_MCKDIV_SAMPLERATE
divider to obtain that bitrate (up to 4095). If the bitrate can be realized
by dividing down the MCK/2, a compile time error will occur.
config SAMA5_SSC1_LOOPBACK
bool "Loopback mode"
default n
depends on SAMA5_SSC1_TX && SAMA5_SSC1_RX
---help---
If both the receiver and transmitter are enabled, then the SSC can
be configured in loopback mode. This setting selects SSC loopback
and will cause the LOOP bit to be set in the SSC_RFMR regsiter. In
this case, RD is connected to TD, RF is connected to TF and RK is
connected to TK.
endif # SAMA5_SSC1
config SAMA5_SSC_DMADEBUG

View File

@ -260,6 +260,7 @@ struct sam_ssc_s
uint16_t master:1; /* True: Master mode transfers */
uint16_t rx:1; /* True: RX transfers supported */
uint16_t tx:1; /* True: TX transfers supported */
uint16_t loopback:1; /* True: Loopback mode */
uint16_t sscno:1; /* SSC controller number (0 or 1) */
uint16_t rxclk:2; /* Receiver clock source. See SSC_CLKSRC_* definitions */
uint16_t txclk:2; /* Transmitter clock source. See SSC_CLKSRC_* definitions */
@ -2132,7 +2133,7 @@ static int ssc_rx_configure(struct sam_ssc_s *priv)
* Currently hardcoded to:
*
* SSC_RFMR_DATLEN(n) 'n' deterimined by configuration
* SSC_RFMR_LOOP Loop mode not selected
* SSC_RFMR_LOOP Determined by configuration
* SSC_RFMR_MSBF Most significant bit first
* SSC_RFMR_DATNB(n) Data number 'n' per frame (hard-coded)
* SSC_RFMR_FSLEN(0) Receive frame sync length = 0
@ -2144,6 +2145,14 @@ static int ssc_rx_configure(struct sam_ssc_s *priv)
regval = (SSC_RFMR_DATLEN(CONFIG_SAMA5_SSC0_DATALEN - 1) | SSC_RFMR_MSBF |
SSC_RFMR_DATNB(SSC_DATNB - 1) | SSC_RFMR_FSLEN(0) |
SSC_RFMR_FSOS_NONE | SSC_RFMR_FSLENEXT(0));
/* Loopback mode? */
if (priv->loopback)
{
regval |= SSC_RFMR_LOOP;
}
ssc_putreg(priv, SAM_SSC_RFMR_OFFSET, regval);
#else
@ -2614,6 +2623,15 @@ static void ssc0_configure(struct sam_ssc_s *priv)
#endif /* CONFIG_SAMA5_SSC0_TX */
/* Set/clear loopback mode */
#if defined(CONFIG_SAMA5_SSC0_TX) && defined(CONFIG_SAMA5_SSC0_TX) && \
defined(SAMA5_SSC0_LOOPBACK)
priv->loopback = true;
#else
priv->loopback = false;
#endif
/* Does the receiver or transmitter need to have the MCK divider set up? */
#if defined(SSC0_HAVE_MCK2)
@ -2740,6 +2758,15 @@ static void ssc1_configure(struct sam_ssc_s *priv)
#endif /* CONFIG_SAMA5_SSC1_TX */
/* Set/clear loopback mode */
#if defined(CONFIG_SAMA5_SSC1_TX) && defined(CONFIG_SAMA5_SSC1_TX) && \
defined(SAMA5_SSC1_LOOPBACK)
priv->loopback = true;
#else
priv->loopback = false;
#endif
/* Does the receiver or transmitter need to have the MCK divider set up? */
#if defined(SSC1_HAVE_MCK2)