diff --git a/arch/arm/src/sam34/sam_gpio.c b/arch/arm/src/sam34/sam_gpio.c index 27a500f07c..d1dc1ef64b 100644 --- a/arch/arm/src/sam34/sam_gpio.c +++ b/arch/arm/src/sam34/sam_gpio.c @@ -190,12 +190,14 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLUP) != 0) { +#ifdef GPIO_HAVE_PULLDOWN /* The pull-up on a pin can not be enabled if its pull-down is still * active. Therefore, we need to disable the pull-down first before * enabling the pull-up. */ putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -286,6 +288,14 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLUP) != 0) { +#ifdef GPIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -298,6 +308,12 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else @@ -357,6 +373,14 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLUP) != 0) { +#ifdef GPIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -369,6 +393,12 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else diff --git a/arch/arm/src/sama5/sama5d3x4x_pio.c b/arch/arm/src/sama5/sama5d3x4x_pio.c index 0165a382ac..806fb9fc08 100644 --- a/arch/arm/src/sama5/sama5d3x4x_pio.c +++ b/arch/arm/src/sama5/sama5d3x4x_pio.c @@ -349,6 +349,14 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin, if ((cfgset & PIO_CFG_PULLUP) != 0) { +#ifdef PIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -361,6 +369,12 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin, if ((cfgset & PIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else @@ -464,6 +478,14 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, if ((cfgset & PIO_CFG_PULLUP) != 0) { +#ifdef PIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -476,6 +498,12 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, if ((cfgset & PIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else @@ -546,6 +574,14 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin, if ((cfgset & PIO_CFG_PULLUP) != 0) { +#ifdef PIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -558,6 +594,12 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin, if ((cfgset & PIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else diff --git a/arch/arm/src/samv7/sam_gpio.c b/arch/arm/src/samv7/sam_gpio.c index cf681e7662..1eac04d576 100644 --- a/arch/arm/src/samv7/sam_gpio.c +++ b/arch/arm/src/samv7/sam_gpio.c @@ -152,6 +152,14 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLUP) != 0) { +#ifdef GPIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -164,6 +172,12 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else @@ -243,6 +257,14 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLUP) != 0) { +#ifdef GPIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -255,6 +277,12 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else @@ -330,6 +358,14 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLUP) != 0) { +#ifdef GPIO_HAVE_PULLDOWN + /* The pull-up on a pin can not be enabled if its pull-down is still + * active. Therefore, we need to disable the pull-down first before + * enabling the pull-up. + */ + + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); +#endif putreg32(pin, base + SAM_PIO_PUER_OFFSET); } else @@ -342,6 +378,12 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin, if ((cfgset & GPIO_CFG_PULLDOWN) != 0) { + /* The pull-down on a pin can not be enabled if its pull-up is still + * active. Therefore, we need to disable the pull-up first before + * enabling the pull-down. + */ + + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); putreg32(pin, base + SAM_PIO_PPDER_OFFSET); } else