diff --git a/arch/arm/src/sama5/Make.defs b/arch/arm/src/sama5/Make.defs index 416a3a7858..b6253c0ed5 100644 --- a/arch/arm/src/sama5/Make.defs +++ b/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/arch/arm/src/sama5/chip/sam_sckc.h b/arch/arm/src/sama5/chip/sam_sckc.h new file mode 100644 index 0000000000..4cb70f9b8b --- /dev/null +++ b/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 + * + * 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 +#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/arch/arm/src/sama5/sam_sckc.c b/arch/arm/src/sama5/sam_sckc.c new file mode 100644 index 0000000000..b0d1a05f51 --- /dev/null +++ b/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 + * + * 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 + +#include + +#include +#include + +#include + +#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/arch/arm/src/sama5/sam_sckc.h b/arch/arm/src/sama5/sam_sckc.h new file mode 100644 index 0000000000..c4296c167c --- /dev/null +++ b/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 + * + * 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 + +#include + +#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/configs/sama5d3-xplained/include/board.h b/configs/sama5d3-xplained/include/board.h index 3693c62d3e..e5d43377bd 100644 --- a/configs/sama5d3-xplained/include/board.h +++ b/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/configs/sama5d3-xplained/include/board_384mhz.h b/configs/sama5d3-xplained/include/board_384mhz.h index f9d38fba3e..e297568033 100644 --- a/configs/sama5d3-xplained/include/board_384mhz.h +++ b/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/configs/sama5d3-xplained/include/board_396mhz.h b/configs/sama5d3-xplained/include/board_396mhz.h index 88369eb494..f41e50f45c 100644 --- a/configs/sama5d3-xplained/include/board_396mhz.h +++ b/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/configs/sama5d3-xplained/include/board_528mhz.h b/configs/sama5d3-xplained/include/board_528mhz.h index 78be010cab..5d6d87a740 100644 --- a/configs/sama5d3-xplained/include/board_528mhz.h +++ b/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/configs/sama5d3-xplained/include/board_sdram.h b/configs/sama5d3-xplained/include/board_sdram.h index cd5a5b5dfc..42d3d1314a 100644 --- a/configs/sama5d3-xplained/include/board_sdram.h +++ b/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/configs/sama5d3x-ek/include/board.h b/configs/sama5d3x-ek/include/board.h index 83f146295e..b682e9d10b 100644 --- a/configs/sama5d3x-ek/include/board.h +++ b/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/configs/sama5d3x-ek/include/board_384mhz.h b/configs/sama5d3x-ek/include/board_384mhz.h index 528ff509a3..d1bcbc40b4 100644 --- a/configs/sama5d3x-ek/include/board_384mhz.h +++ b/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/configs/sama5d3x-ek/include/board_396mhz.h b/configs/sama5d3x-ek/include/board_396mhz.h index 3fbe75b17e..f1dcd05fa7 100644 --- a/configs/sama5d3x-ek/include/board_396mhz.h +++ b/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/configs/sama5d3x-ek/include/board_528mhz.h b/configs/sama5d3x-ek/include/board_528mhz.h index 08a6fba26b..a1ad192aa8 100644 --- a/configs/sama5d3x-ek/include/board_528mhz.h +++ b/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/configs/sama5d3x-ek/include/board_sdram.h b/configs/sama5d3x-ek/include/board_sdram.h index 990673aaae..561d9084b9 100644 --- a/configs/sama5d3x-ek/include/board_sdram.h +++ b/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/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt index 91b961faf0..6ff2ede7b2 100644 --- a/configs/sama5d4-ek/README.txt +++ b/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/configs/sama5d4-ek/include/board.h b/configs/sama5d4-ek/include/board.h index ad8a33f930..58da07b46b 100644 --- a/configs/sama5d4-ek/include/board.h +++ b/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/configs/sama5d4-ek/include/board_384mhz.h b/configs/sama5d4-ek/include/board_384mhz.h index fc2d4e4bc1..48df412b98 100644 --- a/configs/sama5d4-ek/include/board_384mhz.h +++ b/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/configs/sama5d4-ek/include/board_396mhz.h b/configs/sama5d4-ek/include/board_396mhz.h index 34441910ff..978d88ebf7 100644 --- a/configs/sama5d4-ek/include/board_396mhz.h +++ b/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/configs/sama5d4-ek/include/board_528mhz.h b/configs/sama5d4-ek/include/board_528mhz.h index 7b34f09b48..74c63cf599 100644 --- a/configs/sama5d4-ek/include/board_528mhz.h +++ b/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/configs/sama5d4-ek/include/board_sdram.h b/configs/sama5d4-ek/include/board_sdram.h index f86d2827dc..496cd52025 100644 --- a/configs/sama5d4-ek/include/board_sdram.h +++ b/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/configs/sama5d4-ek/src/sam_wm8904.c b/configs/sama5d4-ek/src/sam_wm8904.c index 09d188b84c..78b169e042 100644 --- a/configs/sama5d4-ek/src/sam_wm8904.c +++ b/configs/sama5d4-ek/src/sam_wm8904.c @@ -49,10 +49,14 @@ #include #include +#include + #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);