summaryrefslogtreecommitdiff
path: root/src/soc/qualcomm/qcs405/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/qualcomm/qcs405/gpio.c')
-rw-r--r--src/soc/qualcomm/qcs405/gpio.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/soc/qualcomm/qcs405/gpio.c b/src/soc/qualcomm/qcs405/gpio.c
index 18aacf4ce4..7b2238d77f 100644
--- a/src/soc/qualcomm/qcs405/gpio.c
+++ b/src/soc/qualcomm/qcs405/gpio.c
@@ -71,3 +71,28 @@ void gpio_output(gpio_t gpio, int value)
gpio_configure(gpio, GPIO_FUNC_GPIO,
GPIO_NO_PULL, GPIO_2MA, GPIO_ENABLE);
}
+
+void gpio_input_irq(gpio_t gpio, enum gpio_irq_type type, uint32_t pull)
+{
+ struct tlmm_gpio *regs = (void *)(uintptr_t)gpio.addr;
+
+ gpio_configure(gpio, GPIO_FUNC_GPIO,
+ pull, GPIO_2MA, GPIO_DISABLE);
+
+ clrsetbits_le32(&regs->intr_cfg, GPIO_INTR_DECT_CTL_MASK <<
+ GPIO_INTR_DECT_CTL_SHIFT, type << GPIO_INTR_DECT_CTL_SHIFT);
+ clrsetbits_le32(&regs->intr_cfg, GPIO_INTR_RAW_STATUS_ENABLE
+ << GPIO_INTR_RAW_STATUS_EN_SHIFT, GPIO_INTR_RAW_STATUS_ENABLE
+ << GPIO_INTR_RAW_STATUS_EN_SHIFT);
+}
+
+int gpio_irq_status(gpio_t gpio)
+{
+ struct tlmm_gpio *regs = (void *)(uintptr_t)gpio.addr;
+
+ if (!(read32(&regs->intr_status) & GPIO_INTR_STATUS_MASK))
+ return 0;
+
+ write32(&regs->intr_status, GPIO_INTR_STATUS_DISABLE);
+ return 1;
+}