From 596dbc20ef2c646999ce12c0ce5dd70b2dd6f1bb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 2 Jul 2014 15:31:52 -0600 Subject: [PATCH] SAMA5D4-EK: NSH should run at 528MHz --- arch/arm/src/sama5/chip/sam_pmc.h | 2 +- arch/arm/src/sama5/sam_twi.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/sama5/chip/sam_pmc.h b/arch/arm/src/sama5/chip/sam_pmc.h index 449abc489ff..222149d7c9b 100644 --- a/arch/arm/src/sama5/chip/sam_pmc.h +++ b/arch/arm/src/sama5/chip/sam_pmc.h @@ -420,7 +420,7 @@ #define PMC_PCR_CMD (1 << 12) /* Bit 12: Command */ #ifdef ATSAMA5D3 -# define SAMA5_HAVE_PMC_PCR 1 /* Supports conditional compilation */ +# define SAMA5_HAVE_PMC_PCR_DIV 1 /* Supports conditional compilation */ # define PMC_PCR_DIV_SHIFT (16) /* Bits 16-17: Divisor Value */ # define PMC_PCR_DIV_MASK (3 << PMC_PCR_DIV_SHIFT) # define PMC_PCR_DIV1 (0 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK */ diff --git a/arch/arm/src/sama5/sam_twi.c b/arch/arm/src/sama5/sam_twi.c index 9d3e2f72c90..b5fc202c3a8 100644 --- a/arch/arm/src/sama5/sam_twi.c +++ b/arch/arm/src/sama5/sam_twi.c @@ -1169,6 +1169,8 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid, mck = BOARD_MCK_FREQUENCY; #ifdef SAMA5_HAVE_PMC_PCR_DIV + /* Select the optimal value for the PCR DIV field */ + DEBUGASSERT((mck >> 3) <= TWI_MAX_FREQUENCY); if (mck <= TWI_MAX_FREQUENCY) { @@ -1193,7 +1195,7 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid, #else /* No DIV field in the PCR register */ - + priv->frequency = mck; regval = 0;