summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-19 13:07:55 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-19 13:07:55 -0600
commitaac310bd799c35e10f5c08513ce24ea2218bb024 (patch)
tree3026d8e8cd0b4472376dbd1d5eebde88e36fd085
parent00b2d4894179ea169fc8cc4cb44f48bb70fe2c42 (diff)
downloadpx4-nuttx-aac310bd799c35e10f5c08513ce24ea2218bb024.tar.gz
px4-nuttx-aac310bd799c35e10f5c08513ce24ea2218bb024.tar.bz2
px4-nuttx-aac310bd799c35e10f5c08513ce24ea2218bb024.zip
SAMA5: Add slow clock support
-rw-r--r--nuttx/arch/arm/src/sama5/Make.defs2
-rw-r--r--nuttx/arch/arm/src/sama5/chip/sam_sckc.h63
-rw-r--r--nuttx/arch/arm/src/sama5/sam_sckc.c103
-rw-r--r--nuttx/arch/arm/src/sama5/sam_sckc.h91
-rw-r--r--nuttx/configs/sama5d3-xplained/include/board.h5
-rw-r--r--nuttx/configs/sama5d3-xplained/include/board_384mhz.h1
-rw-r--r--nuttx/configs/sama5d3-xplained/include/board_396mhz.h1
-rw-r--r--nuttx/configs/sama5d3-xplained/include/board_528mhz.h1
-rw-r--r--nuttx/configs/sama5d3-xplained/include/board_sdram.h1
-rw-r--r--nuttx/configs/sama5d3x-ek/include/board.h5
-rw-r--r--nuttx/configs/sama5d3x-ek/include/board_384mhz.h1
-rw-r--r--nuttx/configs/sama5d3x-ek/include/board_396mhz.h1
-rw-r--r--nuttx/configs/sama5d3x-ek/include/board_528mhz.h1
-rw-r--r--nuttx/configs/sama5d3x-ek/include/board_sdram.h1
-rw-r--r--nuttx/configs/sama5d4-ek/README.txt3
-rw-r--r--nuttx/configs/sama5d4-ek/include/board.h5
-rw-r--r--nuttx/configs/sama5d4-ek/include/board_384mhz.h1
-rw-r--r--nuttx/configs/sama5d4-ek/include/board_396mhz.h1
-rw-r--r--nuttx/configs/sama5d4-ek/include/board_528mhz.h1
-rw-r--r--nuttx/configs/sama5d4-ek/include/board_sdram.h1
-rw-r--r--nuttx/configs/sama5d4-ek/src/sam_wm8904.c16
21 files changed, 291 insertions, 14 deletions
diff --git a/nuttx/arch/arm/src/sama5/Make.defs b/nuttx/arch/arm/src/sama5/Make.defs
index 416a3a785..b6253c0ed 100644
--- a/nuttx/arch/arm/src/sama5/Make.defs
+++ b/nuttx/arch/arm/src/sama5/Make.defs
@@ -99,7 +99,7 @@ CHIP_ASRCS =
CHIP_CSRCS = sam_allocateheap.c sam_boot.c sam_clockconfig.c sam_irq.c
CHIP_CSRCS += sam_lowputc.c sam_memories.c sam_pck.c sam_pio.c sam_pmc.c
-CHIP_CSRCS += sam_serial.c sam_timerisr.c
+CHIP_CSRCS += sam_sckc.c sam_serial.c sam_timerisr.c
# Configuration dependent C and assembly language files
diff --git a/nuttx/arch/arm/src/sama5/chip/sam_sckc.h b/nuttx/arch/arm/src/sama5/chip/sam_sckc.h
new file mode 100644
index 000000000..4cb70f9b8
--- /dev/null
+++ b/nuttx/arch/arm/src/sama5/chip/sam_sckc.h
@@ -0,0 +1,63 @@
+/************************************************************************************
+ * arch/arm/src/sama5/chip/sam_sckc.h
+ *
+ * Copyright (C) 2014 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_CHIP_SAM_SCKC_H
+#define __ARCH_ARM_SRC_SAMA5_CHIP_SAM_SCKC_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include <nuttx/config.h>
+#include "chip/sam_memorymap.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+/* SCKC Register Offsets ************************************************************/
+
+#define SAM_SCKC_CR_OFFSET 0x0000 /* Slow Clock Controller Configuration Register */
+
+/* SCKC Register Addresses **********************************************************/
+
+#define SAM_SCKC_CR (SAM_SCKCR_VBASE+SAM_SCKC_CR_OFFSET)
+
+/* SCKC Register Bit Definitions ****************************************************/
+
+/* Slow Clock Controller Configuration Register */
+
+#define SCKC_CR_OSCSEL (1 << 3) /* Bit 3: Slow Clock Selector */
+
+#endif /* __ARCH_ARM_SRC_SAMA5_CHIP_SAM_SCKC_H */
diff --git a/nuttx/arch/arm/src/sama5/sam_sckc.c b/nuttx/arch/arm/src/sama5/sam_sckc.c
new file mode 100644
index 000000000..b0d1a05f5
--- /dev/null
+++ b/nuttx/arch/arm/src/sama5/sam_sckc.c
@@ -0,0 +1,103 @@
+/****************************************************************************
+ * arch/arm/src/sama5/sam_sckc.c
+ *
+ * Copyright (C) 2014 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+
+#include <arch/board/board.h>
+
+#include "up_arch.h"
+#include "sam_sckc.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sam_sckc_enable
+ *
+ * Description:
+ * Enable or disable the slow clock oscillator driver by an external
+ * crystal.
+ *
+ * Input Parameters:
+ * enable - True: enable the slow clock, False: disable the slow clock
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void sam_sckc_enable(bool enable)
+{
+ uint32_t regval;
+
+ /* Enable / disable the slow clock */
+
+ regval = enable ? SCKC_CR_OSCSEL : 0;
+ putreg32(regval, SAM_SCKC_CR);
+
+ /* Wait 5 slow clock cycles for internal resynchronization */
+
+ up_udelay(5 * USEC_PER_SEC / BOARD_SLOWCLK_FREQUENCY);
+}
diff --git a/nuttx/arch/arm/src/sama5/sam_sckc.h b/nuttx/arch/arm/src/sama5/sam_sckc.h
new file mode 100644
index 000000000..c4296c167
--- /dev/null
+++ b/nuttx/arch/arm/src/sama5/sam_sckc.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * arch/arm/src/sama5/sam_sckc.h
+ *
+ * Copyright (C) 2014 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_SCKC_H
+#define __ARCH_ARM_SRC_SAMA5_SAM_SCKC_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+
+#include "chip.h"
+#include "chip/sam_sckc.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sam_sckc_enable
+ *
+ * Description:
+ * Enable or disable the slow clock oscillator driver by an external
+ * crystal.
+ *
+ * Input Parameters:
+ * enable - True: enable the slow clock, False: disable the slow clock
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void sam_sckc_enable(bool enable);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_SAMA5_SAM_SCKC_H */
diff --git a/nuttx/configs/sama5d3-xplained/include/board.h b/nuttx/configs/sama5d3-xplained/include/board.h
index 3693c62d3..e5d43377b 100644
--- a/nuttx/configs/sama5d3-xplained/include/board.h
+++ b/nuttx/configs/sama5d3-xplained/include/board.h
@@ -52,6 +52,11 @@
* definitions will configure operational clocking.
*/
+/* On-board crystal frequencies */
+
+#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
+#define BOARD_SLOWCLK_FREQUENCY (32768) /* Slow Clock: 32.768KHz */
+
#if defined(CONFIG_SAMA5_BOOT_SDRAM)
/* When booting from SDRAM, NuttX is loaded in SDRAM by an intermediate bootloader.
* That bootloader had to have already configured the PLL and SDRAM for proper
diff --git a/nuttx/configs/sama5d3-xplained/include/board_384mhz.h b/nuttx/configs/sama5d3-xplained/include/board_384mhz.h
index f9d38fba3..e29756803 100644
--- a/nuttx/configs/sama5d3-xplained/include/board_384mhz.h
+++ b/nuttx/configs/sama5d3-xplained/include/board_384mhz.h
@@ -161,7 +161,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (768000000) /* PLLACK: 64 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (384000000) /* CPU: PLLACK / 2 / 1 */
#define BOARD_MCK_FREQUENCY (128000000) /* MCK: PLLACK / 2 / 1 / 3 */
diff --git a/nuttx/configs/sama5d3-xplained/include/board_396mhz.h b/nuttx/configs/sama5d3-xplained/include/board_396mhz.h
index 88369eb49..f41e50f45 100644
--- a/nuttx/configs/sama5d3-xplained/include/board_396mhz.h
+++ b/nuttx/configs/sama5d3-xplained/include/board_396mhz.h
@@ -119,7 +119,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (792000000) /* PLLACK: 66 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (396000000) /* CPU: PLLACK / 2 / 1 */
#define BOARD_MCK_FREQUENCY (132000000) /* MCK: PLLACK / 2 / 1 / 3 */
diff --git a/nuttx/configs/sama5d3-xplained/include/board_528mhz.h b/nuttx/configs/sama5d3-xplained/include/board_528mhz.h
index 78be010ca..5d6d87a74 100644
--- a/nuttx/configs/sama5d3-xplained/include/board_528mhz.h
+++ b/nuttx/configs/sama5d3-xplained/include/board_528mhz.h
@@ -118,7 +118,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (528000000) /* PLLACK: 44 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (528000000) /* CPU: PLLACK / 1 / 1 */
#define BOARD_MCK_FREQUENCY (132000000) /* MCK: PLLACK / 1 / 1 / 4 */
diff --git a/nuttx/configs/sama5d3-xplained/include/board_sdram.h b/nuttx/configs/sama5d3-xplained/include/board_sdram.h
index cd5a5b5df..42d3d1314 100644
--- a/nuttx/configs/sama5d3-xplained/include/board_sdram.h
+++ b/nuttx/configs/sama5d3-xplained/include/board_sdram.h
@@ -57,7 +57,6 @@
* the Main clock source in the on-board 12MHz crystal.
*/
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (sam_pllack_frequency(BOARD_MAINOSC_FREQUENCY))
#define BOARD_PLLADIV2_FREQUENCY (sam_plladiv2_frequency(BOARD_MAINOSC_FREQUENCY))
#define BOARD_PCK_FREQUENCY (sam_pck_frequency(BOARD_MAINOSC_FREQUENCY))
diff --git a/nuttx/configs/sama5d3x-ek/include/board.h b/nuttx/configs/sama5d3x-ek/include/board.h
index 83f146295..b682e9d10 100644
--- a/nuttx/configs/sama5d3x-ek/include/board.h
+++ b/nuttx/configs/sama5d3x-ek/include/board.h
@@ -52,6 +52,11 @@
* definitions will configure operational clocking.
*/
+/* On-board crystal frequencies */
+
+#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
+#define BOARD_SLOWCLK_FREQUENCY (32768) /* Slow Clock: 32.768KHz */
+
#if defined(CONFIG_SAMA5_BOOT_SDRAM)
/* When booting from SDRAM, NuttX is loaded in SDRAM by an intermediate bootloader.
* That bootloader had to have already configured the PLL and SDRAM for proper
diff --git a/nuttx/configs/sama5d3x-ek/include/board_384mhz.h b/nuttx/configs/sama5d3x-ek/include/board_384mhz.h
index 528ff509a..d1bcbc40b 100644
--- a/nuttx/configs/sama5d3x-ek/include/board_384mhz.h
+++ b/nuttx/configs/sama5d3x-ek/include/board_384mhz.h
@@ -161,7 +161,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (768000000) /* PLLACK: 64 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (384000000) /* CPU: PLLACK / 2 / 1 */
#define BOARD_MCK_FREQUENCY (128000000) /* MCK: PLLACK / 2 / 1 / 3 */
diff --git a/nuttx/configs/sama5d3x-ek/include/board_396mhz.h b/nuttx/configs/sama5d3x-ek/include/board_396mhz.h
index 3fbe75b17..f1dcd05fa 100644
--- a/nuttx/configs/sama5d3x-ek/include/board_396mhz.h
+++ b/nuttx/configs/sama5d3x-ek/include/board_396mhz.h
@@ -119,7 +119,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (792000000) /* PLLACK: 66 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (396000000) /* CPU: PLLACK / 2 / 1 */
#define BOARD_MCK_FREQUENCY (132000000) /* MCK: PLLACK / 2 / 1 / 3 */
diff --git a/nuttx/configs/sama5d3x-ek/include/board_528mhz.h b/nuttx/configs/sama5d3x-ek/include/board_528mhz.h
index 08a6fba26..a1ad192aa 100644
--- a/nuttx/configs/sama5d3x-ek/include/board_528mhz.h
+++ b/nuttx/configs/sama5d3x-ek/include/board_528mhz.h
@@ -118,7 +118,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (528000000) /* PLLACK: 44 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (528000000) /* CPU: PLLACK / 1 / 1 */
#define BOARD_MCK_FREQUENCY (132000000) /* MCK: PLLACK / 1 / 1 / 4 */
diff --git a/nuttx/configs/sama5d3x-ek/include/board_sdram.h b/nuttx/configs/sama5d3x-ek/include/board_sdram.h
index 990673aaa..561d9084b 100644
--- a/nuttx/configs/sama5d3x-ek/include/board_sdram.h
+++ b/nuttx/configs/sama5d3x-ek/include/board_sdram.h
@@ -57,7 +57,6 @@
* the Main clock source in the on-board 12MHz crystal.
*/
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (sam_pllack_frequency(BOARD_MAINOSC_FREQUENCY))
#define BOARD_PLLADIV2_FREQUENCY (sam_plladiv2_frequency(BOARD_MAINOSC_FREQUENCY))
#define BOARD_PCK_FREQUENCY (sam_pck_frequency(BOARD_MAINOSC_FREQUENCY))
diff --git a/nuttx/configs/sama5d4-ek/README.txt b/nuttx/configs/sama5d4-ek/README.txt
index 91b961faf..6ff2ede7b 100644
--- a/nuttx/configs/sama5d4-ek/README.txt
+++ b/nuttx/configs/sama5d4-ek/README.txt
@@ -2754,7 +2754,8 @@ Audio Support
CONFIG_SAMA5_SSC_MAXINFLIGHT=16 : Up to 16 pending DMA transfers
CONFIG_SAMA5_SSC0_MASTER=y : Master mode
CONFIG_SAMA5_SSC0_DATALEN=16 : 16-bit data
- CONFIG_SAMA5_SSC0_RX=n : No receiver
+ CONFIG_SAMA5_SSC0_RX=y : Support a receiver
+ CONFIG_SAMA5_SSC0_RX_RKINPUT=y : Receiver gets clock from RK input
CONFIG_SAMA5_SSC0_TX=y : Support a transmitter
CONFIG_SAMA5_SSC0_TX_MCKDIV=y : Transmitter gets clock from MCK/2
CONFIG_SAMA5_SSC0_MCKDIV_SAMPLERATE=48000 : Sampling at 48K samples/sec
diff --git a/nuttx/configs/sama5d4-ek/include/board.h b/nuttx/configs/sama5d4-ek/include/board.h
index ad8a33f93..58da07b46 100644
--- a/nuttx/configs/sama5d4-ek/include/board.h
+++ b/nuttx/configs/sama5d4-ek/include/board.h
@@ -52,6 +52,11 @@
* definitions will configure operational clocking.
*/
+/* On-board crystal frequencies */
+
+#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
+#define BOARD_SLOWCLK_FREQUENCY (32768) /* Slow Clock: 32.768KHz */
+
#if defined(CONFIG_SAMA5_BOOT_SDRAM)
/* When booting from SDRAM, NuttX is loaded in SDRAM by an intermediate bootloader.
* That bootloader had to have already configured the PLL and SDRAM for proper
diff --git a/nuttx/configs/sama5d4-ek/include/board_384mhz.h b/nuttx/configs/sama5d4-ek/include/board_384mhz.h
index fc2d4e4bc..48df412b9 100644
--- a/nuttx/configs/sama5d4-ek/include/board_384mhz.h
+++ b/nuttx/configs/sama5d4-ek/include/board_384mhz.h
@@ -159,7 +159,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (768000000) /* PLLACK: 64 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (384000000) /* CPU: PLLACK / 2 / 1 */
#define BOARD_MCK_FREQUENCY (128000000) /* MCK: PLLACK / 2 / 1 / 3 */
diff --git a/nuttx/configs/sama5d4-ek/include/board_396mhz.h b/nuttx/configs/sama5d4-ek/include/board_396mhz.h
index 34441910f..978d88ebf 100644
--- a/nuttx/configs/sama5d4-ek/include/board_396mhz.h
+++ b/nuttx/configs/sama5d4-ek/include/board_396mhz.h
@@ -117,7 +117,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (792000000) /* PLLACK: 66 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (396000000) /* CPU: PLLACK / 2 / 1 */
#define BOARD_MCK_FREQUENCY (132000000) /* MCK: PLLACK / 2 / 1 / 3 */
diff --git a/nuttx/configs/sama5d4-ek/include/board_528mhz.h b/nuttx/configs/sama5d4-ek/include/board_528mhz.h
index 7b34f09b4..74c63cf59 100644
--- a/nuttx/configs/sama5d4-ek/include/board_528mhz.h
+++ b/nuttx/configs/sama5d4-ek/include/board_528mhz.h
@@ -116,7 +116,6 @@
/* Resulting frequencies */
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (528000000) /* PLLACK: 44 * 12Mhz / 1 */
#define BOARD_PCK_FREQUENCY (528000000) /* CPU: PLLACK / 1 / 1 */
#define BOARD_MCK_FREQUENCY (132000000) /* MCK: PLLACK / 1 / 1 / 4 */
diff --git a/nuttx/configs/sama5d4-ek/include/board_sdram.h b/nuttx/configs/sama5d4-ek/include/board_sdram.h
index f86d2827d..496cd5202 100644
--- a/nuttx/configs/sama5d4-ek/include/board_sdram.h
+++ b/nuttx/configs/sama5d4-ek/include/board_sdram.h
@@ -57,7 +57,6 @@
* the Main clock source in the on-board 12MHz crystal.
*/
-#define BOARD_MAINOSC_FREQUENCY (12000000) /* MAINOSC: 12MHz crystal on-board */
#define BOARD_PLLA_FREQUENCY (sam_pllack_frequency(BOARD_MAINOSC_FREQUENCY))
#define BOARD_PLLADIV2_FREQUENCY (sam_plladiv2_frequency(BOARD_MAINOSC_FREQUENCY))
#define BOARD_PCK_FREQUENCY (sam_pck_frequency(BOARD_MAINOSC_FREQUENCY))
diff --git a/nuttx/configs/sama5d4-ek/src/sam_wm8904.c b/nuttx/configs/sama5d4-ek/src/sam_wm8904.c
index 09d188b84..78b169e04 100644
--- a/nuttx/configs/sama5d4-ek/src/sam_wm8904.c
+++ b/nuttx/configs/sama5d4-ek/src/sam_wm8904.c
@@ -49,10 +49,14 @@
#include <nuttx/audio/i2s.h>
#include <nuttx/audio/wm8904.h>
+#include <arch/board/board.h>
+
#include "up_arch.h"
#include "sam_pio.h"
#include "sam_twi.h"
#include "sam_ssc.h"
+#include "sam_sckc.h"
+#include "sam_pck.h"
#include "sama5d4-ek.h"
@@ -270,6 +274,18 @@ int sam_wm8904_initialize(int minor)
goto errout_with_i2s;
}
+ /* Configure the DAC master clock. This clock is provided by PCK0 (PB26)
+ * that is connected to the WM8904 BCLK/GPIO4 and also drives the SSC
+ * TK0 input clock.
+ */
+
+ sam_sckc_enable(true);
+ (void)sam_pck_configure(PCK0, BOARD_SLOWCLK_FREQUENCY);
+
+ /* Enable the DAC master clock */
+
+ sam_pck_enable(PCK0, true);
+
/* Configure WM8904 interrupts */
sam_pioirq(PIO_INT_WM8904);