SAMA5: Enable the 32.768 crystal if SCHED_TICKLESS is selected

This commit is contained in:
Gregory Nutt 2014-08-11 14:29:43 -06:00
parent 56196ecea1
commit 1787b3e600
11 changed files with 58 additions and 11 deletions

View File

@ -20,6 +20,11 @@ config SAMA5D3XPLAINED_528MHZ
endchoice # CPU Frequency
config SAMA5D3XPLAINED_SLOWCLOCK
bool
default y if SCHED_TICKLESS
default n if !SCHED_TICKLESS
choice
prompt "SAMA5D3-Xplained DRAM Type"
default SAMA5D3XPLAINED_MT47H128M16RT

View File

@ -2392,7 +2392,8 @@ Tickless OS
NOTE: In most cases, the slow clock will be used as the timer/counter
input. You should enable the 32.768KHz crystal for the slow clock by
calling sam_sckc_enable(). Otherwise, you will be doing all system
timing using the RC clock!
timing using the RC clock! UPDATE: This will now be selected by default
when you configure for TICKLESS support.
SAMA5 Timer Usage
-----------------

View File

@ -41,6 +41,7 @@
#include <debug.h>
#include "sam_sckc.h"
#include "sama5d3-xplained.h"
/************************************************************************************
@ -67,6 +68,12 @@
void sam_boardinitialize(void)
{
#ifdef CONFIG_SAMA5D3XPLAINED_SLOWCLOCK
/* Enable the external slow clock */
sam_sckc_enable(true);
#endif
/* Configure SPI chip selects if 1) SPI is enable, and 2) the weak function
* sam_spiinitialize() has been brought into the link.
*/

View File

@ -248,6 +248,11 @@ config SAMA5D3xEK_OV2640_DEMO
endif # VIDEO_OV2640
config SAMA5D3xEK_SLOWCLOCK
bool
default y if SCHED_TICKLESS
default n if !SCHED_TICKLESS
if AUDIO_WM8904
config SAMA5D3xEK_WM8904_I2CFREQUENCY
@ -266,6 +271,7 @@ choice
config SAMA5D3xEK_WM8904_SRCMAIN
bool "Main Clock (12MHz)"
select SAMA5D3xEK_SLOWCLOCK
config SAMA5D3xEK_WM8904_SRCSCK
bool "Slow XTAL (32.768KHz)"

View File

@ -2708,7 +2708,8 @@ Tickless OS
NOTE: In most cases, the slow clock will be used as the timer/counter
input. You should enable the 32.768KHz crystal for the slow clock by
calling sam_sckc_enable(). Otherwise, you will be doing all system
timing using the RC clock!
timing using the RC clock! UPDATE: This will now be selected by default
when you configure for TICKLESS support.
SAMA5 Timer Usage
-----------------

View File

@ -41,6 +41,7 @@
#include <debug.h>
#include "sam_sckc.h"
#include "sama5d3x-ek.h"
/************************************************************************************
@ -60,13 +61,19 @@
*
* Description:
* All SAMA5 architectures must provide the following entry point. This entry
* point is called early in the intitialization -- after all memory has been
* point is called early in the initialization -- after all memory has been
* configured and mapped but before any devices have been initialized.
*
************************************************************************************/
void sam_boardinitialize(void)
{
#ifdef CONFIG_SAMA5D3xEK_SLOWCLOCK
/* Enable the external slow clock */
sam_sckc_enable(true);
#endif
/* Configure SPI chip selects if 1) SPI is enable, and 2) the weak function
* sam_spiinitialize() has been brought into the link.
*/

View File

@ -56,7 +56,6 @@
#include "sam_pio.h"
#include "sam_twi.h"
#include "sam_ssc.h"
#include "sam_sckc.h"
#include "sam_pck.h"
#include "sama5d3x-ek.h"
@ -293,9 +292,10 @@ int sam_wm8904_initialize(int minor)
*/
#ifdef CONFIG_SAMA5D3xEK_WM8904_SRCSCK
/* Drive the DAC with the slow clock (32.768 KHz) */
/* Drive the DAC with the slow clock (32.768 KHz). The slow clock was
* enabled in sam_boot.c if needed.
*/
sam_sckc_enable(true);
(void)sam_pck_configure(PCK0, PCKSRC_SCK, BOARD_SLOWCLK_FREQUENCY);
#else
/* Drive the DAC with the main clock (12 MHz) */

View File

@ -268,6 +268,11 @@ config SAMA5D4EK_CHANNEL
Selects the PWM channel number that will be used to perform the PWM
test. See apps/examples/pwm.
config SAMA5D4EK_SLOWCLOCK
bool
default y if SCHED_TICKLESS
default n if !SCHED_TICKLESS
if AUDIO_WM8904
config SAMA5D4EK_WM8904_I2CFREQUENCY
@ -289,6 +294,7 @@ config SAMA5D4EK_WM8904_SRCMAIN
config SAMA5D4EK_WM8904_SRCSCK
bool "Slow XTAL (32.768KHz)"
select SAMA5D4EK_SLOWCLOCK
endchoice # WM8904 MCLK source
endif # AUDIO_WM8904

View File

@ -3172,7 +3172,14 @@ Tickless OS
NOTE: In most cases, the slow clock will be used as the timer/counter
input. You should enable the 32.768KHz crystal for the slow clock by
calling sam_sckc_enable(). Otherwise, you will be doing all system
timing using the RC clock!
timing using the RC clock! UPDATE: This will now be selected by default
when you configure for TICKLESS support.
UPDATE: As of this writing (2014-8-11), the Tickless support is
functional. However, the timing for all delays appears to be half the
duration that it should be. I don't see anything wrong with the setup
and I am suspecting that there may be something I don't understand about
the counting frequency.
SAMA5 Timer Usage
-----------------

View File

@ -41,6 +41,7 @@
#include <debug.h>
#include "sam_sckc.h"
#include "sama5d4-ek.h"
/************************************************************************************
@ -60,13 +61,19 @@
*
* Description:
* All SAMA5 architectures must provide the following entry point. This entry
* point is called early in the intitialization -- after all memory has been
* point is called early in the initialization -- after all memory has been
* configured and mapped but before any devices have been initialized.
*
************************************************************************************/
void sam_boardinitialize(void)
{
#ifdef CONFIG_SAMA5D4EK_SLOWCLOCK
/* Enable the external slow clock */
sam_sckc_enable(true);
#endif
/* Configure SPI chip selects if 1) SPI is enable, and 2) the weak function
* sam_spiinitialize() has been brought into the link.
*/

View File

@ -56,7 +56,6 @@
#include "sam_pio.h"
#include "sam_twi.h"
#include "sam_ssc.h"
#include "sam_sckc.h"
#include "sam_pck.h"
#include "sama5d4-ek.h"
@ -293,9 +292,10 @@ int sam_wm8904_initialize(int minor)
*/
#ifdef CONFIG_SAMA5D4EK_WM8904_SRCSCK
/* Drive the DAC with the slow clock (32.768 KHz) */
/* Drive the DAC with the slow clock (32.768 KHz). The slow clock was
* enabled in sam_boot.c if needed.
*/
sam_sckc_enable(true);
(void)sam_pck_configure(PCK2, PCKSRC_SCK, BOARD_SLOWCLK_FREQUENCY);
#else
/* Drive the DAC with the main clock (12 MHz) */