diff --git a/arch/arm/src/sam34/sam_gpio.c b/arch/arm/src/sam34/sam_gpio.c index 89461c58369c2fc6fe2ef3e8a311a873c99b6c2f..5b2b65a0eef701cc248e089de54a0c36f8ec0f6a 100644 --- a/arch/arm/src/sam34/sam_gpio.c +++ b/arch/arm/src/sam34/sam_gpio.c @@ -54,6 +54,7 @@ #include "chip.h" #include "sam_gpio.h" +#include "sam_periphclks.h" #if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) || \ defined(CONFIG_ARCH_CHIP_SAM3A) @@ -179,6 +180,31 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin, putreg32(pin, base + SAM_PIO_ODR_OFFSET); putreg32(pin, base + SAM_PIO_PER_OFFSET); + /* Enable the peripheral clock for the GPIO's port controller. + * A GPIO input value is only sampled if the peripheral clock for its + * controller is enabled. + */ + + switch (cfgset & GPIO_PORT_MASK) + { + case GPIO_PORT_PIOA: + sam_pioa_enableclk(); + break; + + case GPIO_PORT_PIOB: + sam_piob_enableclk(); + break; + +#ifdef GPIO_HAVE_PERIPHCD + case GPIO_PORT_PIOC: + sam_pioc_enableclk(); + break; +#endif + + default: + return -EINVAL; + } + /* To-Do: If DEGLITCH is selected, need to configure DIFSR, SCIFSR, and * IFDGSR registers. This would probably best be done with * another, new API... perhaps sam_configfilter()