SAMA5 SSC: Add framework (only) for a forthcoming SSC-based I2S driver

This commit is contained in:
Gregory Nutt 2013-11-07 12:26:53 -06:00
parent fdac30a7e6
commit 904f171afa
5 changed files with 1401 additions and 4 deletions

View File

@ -249,10 +249,12 @@ config SAMA5_ISI
config SAMA5_SSC0
bool "Synchronous Serial Controller 0 (SSC0)"
default n
select I2S
config SAMA5_SSC1
bool "Synchronous Serial Controller 1 (SSC1)"
default n
select I2S
config SAMA5_CAN0
bool "CAN controller 0 (CAN0)"
@ -1373,6 +1375,238 @@ config SAMA5_TWI_REGDEBUG
endmenu # TWI device driver options
endif # SAMA5_TWI0 || SAMA5_TWI1 || SAMA5_TWI2
if SAMA5_SSC0 || SAMA5_SSC1
menu "SSC Configuration"
config SAMA5_SSC_DMA
bool "Enable SSC DMA"
default n
depends on (SAMA5_DMAC0 && SAMA5_SSC0) || (SAMA5_DMAC1 && SAMA5_SSC1)
---help---
Enable use of DMA in I2C tranfers
config SAMA5_SSC_DMATHRESHOLD
int "DMA transfer threshold"
default 4
depends on SAMA5_SSC_DMA
---help---
Small I2S transfers are better performed without using DMA. This
setting defines a threshold to select when small transfer should
be performed without using DMA.
if SAMA5_SSC0
comment "SSC0 Configuration"
config SAMA5_SSC0_RX
bool "Enable I2C receive"
default n
---help---
Enable I2S receipt logic
if SAMA5_SSC0_RX
choice
prompt "Receiver clock source"
default SAMA5_SSC0_RX_INTCLK
config SAMA5_SSC0_RX_EXTCLK
bool "External Clock"
---help---
The SSC receiver clock is an external clock provided on the RK input
pin.
config SAMA5_SSC0_RX_TXCLK
bool "Transmitter Clock"
---help---
The SSC receiver clock is transmitter clock.
config SAMA5_SSC0_RX_INTCLK
bool "MCK/2"
---help---
The SSC receiver clock is the MCK/2 divided by a up to 4095.
endchoice # Receiver clock source
config SAMA5_SSC0_RX_EXTFREQ
int "External reciver clock frequency"
default 100
depends on SAMA5_SSC0_RX_EXTCLK
---help---
If the receiver clock is provided via a clock input on the RK pin,
then the frequency of the receiver clock must be provided.
endif # SAMA5_SSC0_RX
config SAMA5_SSC0_TX
bool "Enable I2C transmit"
default n
---help---
Enable I2S transmission logic
if SAMA5_SSC0_TX
choice
prompt "Transmitter clock source"
default SAMA5_SSC0_TX_INTCLK
config SAMA5_SSC0_TX_EXTCLK
bool "External Clock"
---help---
The SSC transmitter clock is an external clock provided on the TK input
pin.
config SAMA5_SSC0_TX_RXCLK
bool "Receiver Clock"
---help---
The SSC transmitter clock is receiver clock.
config SAMA5_SSC0_TX_INTCLK
bool "MCK/2"
---help---
The SSC transmitter clock is the MCK/2 divided by a up to 4095.
endchoice # Transmitter clock source
config SAMA5_SSC0_TX_EXTFREQ
int "External transmitter clock frequency"
default 100
depends on SAMA5_SSC0_TX_EXTCLK
---help---
If the transmitter clock is provided via a clock input on the TK pin,
then the frequency of the transmitter clock must be provided.
endif # SAMA5_SSC0_TX
config SAMA5_SSC0_TX_INTCLK_FREQUENCY
int "Internal transmitter clock frequency"
default 100
depends on SAMA5_SSC0_RX_INTCLK || SAMA5_SSC0_TX_INTCLK
---help---
If the either the receiver or transmitter clock is provided by MCK/2 divided
down, then the target frequency must be provided. The SSC driver will
determine the best divider to obtain that frequency (up to 4095). If the
frequency is too low to be obtained by dividing down the MCK/2, a compile
time error will occur.
endif # SAMA5_SSC0
if SAMA5_SSC1
comment "SSC1 Configuration"
config SAMA5_SSC1_RX
bool "Enable I2C receive"
default n
---help---
Enable I2S receipt logic
if SAMA5_SSC1_RX
choice
prompt "Receiver clock source"
default SAMA5_SSC1_RX_INTCLK
config SAMA5_SSC1_RX_EXTCLK
bool "External Clock"
---help---
The SSC receiver clock is an external clock provided on the RK input
pin.
config SAMA5_SSC1_RX_TXCLK
bool "Transmitter Clock"
---help---
The SSC receiver clock is transmitter clock.
config SAMA5_SSC1_RX_INTCLK
bool "MCK/2"
---help---
The SSC receiver clock is the MCK/2 divided by a up to 4095.
endchoice # Receiver clock source
config SAMA5_SSC1_RX_EXTFREQ
int "External reciver clock frequency"
default 100
depends on SAMA5_SSC1_RX_EXTCLK
---help---
If the receiver clock is provided via a clock input on the RK pin,
then the frequency of the receiver clock must be provided.
endif # SAMA5_SSC0_RX
config SAMA5_SSC1_TX
bool "Enable I2C transmit"
default n
---help---
Enable I2S transmission logic
if SAMA5_SSC1_TX
choice
prompt "Transmitter clock source"
default SAMA5_SSC1_TX_INTCLK
config SAMA5_SSC1_TX_EXTCLK
bool "External Clock"
---help---
The SSC transmitter clock is an external clock provided on the TK input
pin.
config SAMA5_SSC1_TX_RXCLK
bool "Receiver Clock"
---help---
The SSC transmitter clock is receiver clock.
config SAMA5_SSC1_TX_INTCLK
bool "MCK/2"
---help---
The SSC transmitter clock is the MCK/2 divided by a up to 4095.
endchoice # Transmitter clock source
config SAMA5_SSC1_TX_EXTFREQ
int "External transmitter clock frequency"
default 100
depends on SAMA5_SSC1_TX_EXTCLK
---help---
If the transmitter clock is provided via a clock input on the TK pin,
then the frequency of the transmitter clock must be provided.
endif # SAMA5_SSC1_TX
config SAMA5_SSC1_TX_INTCLK_FREQUENCY
int "Internal transmitter clock frequency"
default 100
depends on SAMA5_SSC1_RX_INTCLK || SAMA5_SSC1_TX_INTCLK
---help---
If the either the receiver or transmitter clock is provided by MCK/2 divided
down, then the target frequency must be provided. The SSC driver will
determine the best divider to obtain that frequency (up to 4095). If the
frequency is too low to be obtained by dividing down the MCK/2, a compile
time error will occur.
endif # SAMA5_SSC1
config SAMA5_SSC_DMADEBUG
bool "SSC DMA transfer debug"
depends on SAMA5_SSC_DMA && DEBUG && DEBUG_DMA
default n
---help---
Enable special debug instrumentation analyze SSC DMA data transfers.
This logic is as non-invasive as possible: It samples DMA
registers at key points in the data transfer and then dumps all of
the registers at the end of the transfer.
config SAMA5_SSC_REGDEBUG
bool "SSC Register level debug"
depends on DEBUG
default n
---help---
Output detailed register-level SSC device debug information.
Very invasive! Requires also DEBUG.
endmenu # SSC Configuration
endif # SAMA5_SSC0 || SAMA5_SSC1
if SAMA5_HSMCI0 || SAMA5_HSMCI1 || SAMA5_HSMCI2
menu "HSMCI device driver options"

View File

@ -131,6 +131,15 @@ else
endif
endif
ifeq ($(CONFIG_SAMA5_SSC0),y)
CHIP_CSRCS += sam_ssc.c
else
ifeq ($(CONFIG_SAMA5_SSC1),y)
CHIP_CSRCS += sam_ssc.c
else
endif
endif
ifeq ($(CONFIG_SAMA5_LCDC),y)
CHIP_CSRCS += sam_lcd.c
endif

View File

@ -68,7 +68,7 @@
#define SAM_SSC_IMR_OFFSET 0x004c /* Interrupt Mask Register */
#define SAM_SSC_WPMR_OFFSET 0x00e4 /* Write Protect Mode Register */
#define SAM_SSC_WPSR_OFFSET 0x00e8 /* Write Protect Status Register */
/* 0x50-0x124 Reserved
/* 0x50-0x124 Reserved */
/* SSC Register Addresses ***********************************************************/
@ -193,9 +193,9 @@
#define SSC_TCMR_CKS_SHIFT (0) /* Bits 0-1: Transmit Clock Selection */
#define SSC_TCMR_CKS_MASK (3 << SSC_TCMR_CKS_SHIFT)
# define SSC_TCMR_CKS_ MCK (0 << SSC_TCMR_CKS_SHIFT) /* Divided Clock */
# define SSC_TCMR_CKS_ RK (1 << SSC_TCMR_CKS_SHIFT) /* RK Clock signal */
# define SSC_TCMR_CKS_ TK (2 << SSC_TCMR_CKS_SHIFT) /* TK pin */
# define SSC_TCMR_CKS_MCK (0 << SSC_TCMR_CKS_SHIFT) /* Divided Clock */
# define SSC_TCMR_CKS_RK (1 << SSC_TCMR_CKS_SHIFT) /* RK Clock signal */
# define SSC_TCMR_CKS_TK (2 << SSC_TCMR_CKS_SHIFT) /* TK pin */
#define SSC_TCMR_CKO_SHIFT (2) /* Bits 2-3: Transmit Clock Output Mode Selection */
#define SSC_TCMR_CKO_MASK (3 << SSC_TCMR_CKO_SHIFT)
# define SSC_TCMR_CKO_NONE (0 << SSC_TCMR_CKO_SHIFT) /* None, TK pin is an input */

1052
arch/arm/src/sama5/sam_ssc.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,102 @@
/************************************************************************************
* arch/arm/src/sama5/sam_ssc.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
#ifndef __ARCH_ARM_SRC_SAMA5_SAM_SSC_H
#define __ARCH_ARM_SRC_SAMA5_SAM_SSC_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/audio/i2s.h>
#include "chip.h"
#include "chip/sam_ssc.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/****************************************************************************
* Name: sam_ssc_initialize
*
* Description:
* Initialize the selected I2S port.
*
* Input Parameter:
* Port number (for hardware that has mutiple I2S interfaces)
*
* Returned Value:
* Valid I2S device structure reference on succcess; a NULL on failure
*
****************************************************************************/
FAR struct i2s_dev_s *sam_ssc_initialize(int port);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMA5_SAM_SSC_H */