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 143c8042b8
commit 4214dc9ce9
9 changed files with 1449 additions and 39 deletions

View File

@ -5984,4 +5984,8 @@
* include/nuttx/audio/i2s.h: First cut at an I2S interface
definition. This initial definition is sparse will will
probably evolve significantly (2011-11-7).
* arch/arm/src/sama5/sam_ssc.c and .h: Skeleton and build setup
for a forthcoming SSC (aka I2S) driver for the SAMA5. The
initial check-in is just the SAMA5 SPI driver gutted and hacked
to use the I2S interface. More coming (2013-11-7).

View File

@ -481,6 +481,15 @@ config DEBUG_SPI
Support for this debug option is architecture-specific and may not
be available for some MCUs.
config DEBUG_I2S
bool "I2S Debug Output"
default n
depends on I2S
---help---
Enable I2S driver debug SYSLOG output (disabled by default).
Support for this debug option is architecture-specific and may not
be available for some MCUs.
config DEBUG_CAN
bool "CAN Debug Output"
default n

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 ***********************************************************/

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 */

View File

@ -161,6 +161,17 @@ if SPI
source drivers/spi/Kconfig
endif
menuconfig I2S
bool "I2S Driver Support"
default n
---help---
This selection enables selection of common I2S options. This option
should be enabled by all platforms that support I2S interfaces.
See include/nuttx/audio/i2s.h for further I2S driver information.
if I2S
endif # I2S
menuconfig RTC
bool "RTC Driver Support"
default n
@ -170,10 +181,11 @@ menuconfig RTC
Most RTC drivers are MCU specific and may require other specific
settings.
if RTC
config RTC_DATETIME
bool "Date/Time RTC Support"
default n
depends on RTC
---help---
There are two general types of RTC: (1) A simple battery backed
counter that keeps the time when power is down, and (2) a full
@ -182,10 +194,11 @@ config RTC_DATETIME
of RTC. In this case, the RTC is used to "seed" the normal NuttX timer
and the NuttX system timer provides for higher resolution time.
if !RTC_DATETIME
config RTC_HIRES
bool "Hi-Res RTC Support"
default n
depends on RTC && !RTC_DATETIME
---help---
If RTC_DATETIME not selected, then the simple, battery backed counter
is used. There are two different implementations of such simple
@ -201,20 +214,23 @@ config RTC_HIRES
config RTC_FREQUENCY
int "Hi-Res RTC frequency"
default 1
depends on RTC && !RTC_DATETIME && RTC_HIRES
depends on RTC_HIRES
---help---
If RTC_HIRES is defined, then the frequency of the high resolution RTC
must be provided. If RTC_HIRES is not defined, RTC_FREQUENCY is
assumed to be one Hz.
endif # !RTC_DATETIME
config RTC_ALARM
bool "RTC Alarm Support"
default n
depends on RTC
---help---
Enable if the RTC hardware supports setting of an alarm. A callback
function will be executed when the alarm goes off.
endif # RTC
menuconfig WATCHDOG
bool "Watchdog Timer Support"
default n
@ -224,7 +240,7 @@ menuconfig WATCHDOG
information.
if WATCHDOG
endif
endif # WATCHDOG
menuconfig ANALOG
bool "Analog Device(ADC/DAC) Support"

View File

@ -46,6 +46,8 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef CONFIG_I2S
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -68,7 +70,7 @@
*
****************************************************************************/
#define I2S_FREQUENCY(d,f) ((d)->ops->frequency(d,f))
#define I2S_FREQUENCY(d,f) ((d)->ops->i2s_frequency(d,f))
/****************************************************************************
* Name: I2S_SEND
@ -86,8 +88,7 @@
*
****************************************************************************/
#define I2S_SEND(d,b,n) ((d)->ops->send(d,b,n))
#endif
#define I2S_SEND(d,b,n) ((d)->ops->i2s_send(d,b,n))
/****************************************************************************
* Name: I2S_RECEIVE
@ -106,7 +107,7 @@
*
****************************************************************************/
#define I2S_RECEIVE(d,b,n) ((d)->ops->recvblock(d,b,n))
#define I2S_RECEIVE(d,b,n) ((d)->ops->i2s_receive(d,b,n))
/****************************************************************************
* Public Types
@ -117,10 +118,10 @@
struct i2s_dev_s;
struct i2s_ops_s
{
uint32_t (*frequency)(FAR struct i2s_dev_s *dev, uint32_t frequency);
void (*send)(FAR struct i2s_dev_s *dev, FAR const void *buffer,
uint32_t (*i2s_frequency)(FAR struct i2s_dev_s *dev, uint32_t frequency);
void (*i2s_send)(FAR struct i2s_dev_s *dev, FAR const void *buffer,
size_t nbytes);
void (*receive)(FAR struct i2s_dev_s *dev, FAR void *buffer,
void (*i2s_receive)(FAR struct i2s_dev_s *dev, FAR void *buffer,
size_t nbytes);
};
@ -135,7 +136,7 @@ struct i2s_dev_s
};
/****************************************************************************
* Public Functions
* Public Data
****************************************************************************/
#undef EXTERN
@ -148,30 +149,13 @@ extern "C"
#endif
/****************************************************************************
* Name: up_i2cinitialize
*
* Description:
* Initialize the selected I2S port.
*
* This is a generic prototype for the I2S initialize logic. Specific
* architectures may support different I2S initialization functions if,
* for example, those architectures support multiple, incompatible I2S
* implementations. In any event, the prototype of those architecture-
* specific initialization functions should be the same as
* up_i2cinitialize()
*
* Input Parameter:
* Port number (for hardware that has mutiple I2S interfaces)
*
* Returned Value:
* Valid I2S device structure reference on succcess; a NULL on failure
*
* Public Functions
****************************************************************************/
FAR struct i2s_dev_s *up_i2cinitialize(int port);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* CONFIG_I2S */
#endif /* __INCLUDE_NUTTX_AUDIO_I2S_H */