drivers: gpio: mec172x: Add message to warn about pins not in GPIO mode
Warn about potential device tree errors for cases when driver's client tries to configure a pin as GPIO but which is not in GPIO mode. Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
This commit is contained in:
parent
83c031556b
commit
b5778f1b38
|
@ -11,6 +11,7 @@
|
|||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/dt-bindings/gpio/gpio.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/dt-bindings/pinctrl/mchp-xec-pinctrl.h>
|
||||
#include <soc.h>
|
||||
#include <zephyr/irq.h>
|
||||
|
@ -19,6 +20,8 @@
|
|||
|
||||
#define XEC_GPIO_EDGE_DLY_COUNT 4
|
||||
|
||||
LOG_MODULE_REGISTER(gpio, CONFIG_GPIO_LOG_LEVEL);
|
||||
|
||||
static const uint32_t valid_ctrl_masks[NUM_MCHP_GPIO_PORTS] = {
|
||||
(MCHP_GPIO_PORT_A_BITMAP),
|
||||
(MCHP_GPIO_PORT_B_BITMAP),
|
||||
|
@ -141,6 +144,12 @@ static int gpio_xec_configure(const struct device *dev,
|
|||
pcr1_addr = pin_ctrl_addr(dev, pin);
|
||||
pcr1 = sys_read32(pcr1_addr);
|
||||
|
||||
/* Check if pin is in GPIO mode */
|
||||
if (MCHP_GPIO_CTRL_MUX_GET(pcr1) != MCHP_GPIO_CTRL_MUX_F0) {
|
||||
LOG_WRN("Port:%d pin:0x%x not in GPIO mode. CTRL[%x]=%x", config->port_num, pin,
|
||||
(uint32_t)pcr1_addr, pcr1);
|
||||
}
|
||||
|
||||
if (flags == GPIO_DISCONNECTED) {
|
||||
pcr1 = (pcr1 & ~MCHP_GPIO_CTRL_PWRG_MASK) | MCHP_GPIO_CTRL_PWRG_OFF;
|
||||
sys_write32(pcr1, pcr1_addr);
|
||||
|
|
Loading…
Reference in a new issue