Skip to content

Commit bd62888

Browse files
michallenclupyuen
authored andcommitted
arch/arm/src/samv7: enable GPIO clock even if interrupt not enabled
GPIO peripheral clocks have to be enabled even if interrupt support on the peripheral is not enabled, otherwise GPIO input will not work. This is probably caused by input filters that need clock signal. This commit moves the clock enable call from interrupt specific function to common initialization function that is called from _start entry point function. Signed-off-by: Michal Lenc <[email protected]>
1 parent 2cee5c0 commit bd62888

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

arch/arm/src/samv7/sam_gpio.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include "arm_internal.h"
4040
#include "sam_gpio.h"
41+
#include "sam_periphclks.h"
4142
#include "hardware/sam_pio.h"
4243
#include "hardware/sam_matrix.h"
4344

@@ -471,18 +472,32 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin,
471472
*
472473
****************************************************************************/
473474

474-
#if !defined(CONFIG_SAMV7_ERASE_ENABLE) || \
475-
!defined(CONFIG_SAMV7_JTAG_FULL_ENABLE)
476475
void sam_gpioinit(void)
477476
{
477+
#if !defined(CONFIG_SAMV7_ERASE_ENABLE) || \
478+
!defined(CONFIG_SAMV7_JTAG_FULL_ENABLE)
478479
uint32_t regval;
479480

480481
regval = getreg32(SAM_MATRIX_CCFG_SYSIO);
481482
regval |= (SYSIO_ERASE_BIT | SYSIO_BITS);
482483
putreg32(regval, SAM_MATRIX_CCFG_SYSIO);
483-
}
484484
#endif
485485

486+
sam_pioa_enableclk();
487+
#if SAMV7_NPIO > 1
488+
sam_piob_enableclk();
489+
#endif
490+
#if SAMV7_NPIO > 2
491+
sam_pioc_enableclk();
492+
#endif
493+
#if SAMV7_NPIO > 3
494+
sam_piod_enableclk();
495+
#endif
496+
#if SAMV7_NPIO > 4
497+
sam_pioe_enableclk();
498+
#endif
499+
}
500+
486501
/****************************************************************************
487502
* Name: sam_configgpio
488503
*

arch/arm/src/samv7/sam_gpio.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,7 @@ static inline int sam_gpio_pinmask(gpio_pinset_t cfgset)
265265
*
266266
****************************************************************************/
267267

268-
#if !defined(CONFIG_SAMV7_ERASE_ENABLE) || \
269-
!defined(CONFIG_SAMV7_JTAG_FULL_ENABLE)
270268
void sam_gpioinit(void);
271-
#else
272-
# define sam_gpioinit()
273-
#endif
274269

275270
/****************************************************************************
276271
* Name: sam_gpioirqinitialize

arch/arm/src/samv7/sam_gpioirq.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
#include "arm_internal.h"
4141
#include "sam_gpio.h"
42-
#include "sam_periphclks.h"
4342
#include "hardware/sam_pmc.h"
4443
#include "hardware/sam_pio.h"
4544

@@ -235,10 +234,6 @@ void sam_gpioirqinitialize(void)
235234
/* Configure GPIOA interrupts */
236235

237236
#ifdef CONFIG_SAMV7_GPIOA_IRQ
238-
/* Enable GPIOA clocking */
239-
240-
sam_pioa_enableclk();
241-
242237
/* Clear and disable all GPIOA interrupts */
243238

244239
getreg32(SAM_PIOA_ISR);
@@ -253,10 +248,6 @@ void sam_gpioirqinitialize(void)
253248
/* Configure GPIOB interrupts */
254249

255250
#ifdef CONFIG_SAMV7_GPIOB_IRQ
256-
/* Enable GPIOB clocking */
257-
258-
sam_piob_enableclk();
259-
260251
/* Clear and disable all GPIOB interrupts */
261252

262253
getreg32(SAM_PIOB_ISR);
@@ -271,10 +262,6 @@ void sam_gpioirqinitialize(void)
271262
/* Configure GPIOC interrupts */
272263

273264
#ifdef CONFIG_SAMV7_GPIOC_IRQ
274-
/* Enable GPIOC clocking */
275-
276-
sam_pioc_enableclk();
277-
278265
/* Clear and disable all GPIOC interrupts */
279266

280267
getreg32(SAM_PIOC_ISR);
@@ -289,10 +276,6 @@ void sam_gpioirqinitialize(void)
289276
/* Configure GPIOD interrupts */
290277

291278
#ifdef CONFIG_SAMV7_GPIOD_IRQ
292-
/* Enable GPIOD clocking */
293-
294-
sam_piod_enableclk();
295-
296279
/* Clear and disable all GPIOD interrupts */
297280

298281
getreg32(SAM_PIOD_ISR);
@@ -307,10 +290,6 @@ void sam_gpioirqinitialize(void)
307290
/* Configure GPIOE interrupts */
308291

309292
#ifdef CONFIG_SAMV7_GPIOE_IRQ
310-
/* Enable GPIOE clocking */
311-
312-
sam_pioe_enableclk();
313-
314293
/* Clear and disable all GPIOE interrupts */
315294

316295
getreg32(SAM_PIOE_ISR);

0 commit comments

Comments
 (0)