drivers: gpio: Add support for Apollo510 GPIO
This commit adds support for Apollo510 SoC in ambiq gpio driver Signed-off-by: Hao Luo <hluo@ambiq.com>
This commit is contained in:
parent
b9f05070be
commit
6618a673e5
2 changed files with 49 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <zephyr/drivers/gpio/gpio_utils.h>
|
||||
#include <zephyr/irq.h>
|
||||
#include <zephyr/spinlock.h>
|
||||
#include <zephyr/drivers/gpio/gpio_ambiq.h>
|
||||
|
||||
#include <soc.h>
|
||||
|
||||
|
@ -488,7 +489,12 @@ static int ambiq_gpio_pin_interrupt_configure(const struct device *dev, gpio_pin
|
|||
* GPIO_INT_TRIG_BOTH is not supported on Ambiq Apollo4 Plus Platform
|
||||
* ERR008: GPIO: Dual-edge interrupts are not vectoring
|
||||
*/
|
||||
#if defined(CONFIG_SOC_SERIES_APOLLO4X)
|
||||
return -ENOTSUP;
|
||||
#elif defined(CONFIG_SOC_SERIES_APOLLO5X)
|
||||
pincfg.GP.cfg_b.eIntDir = AM_HAL_GPIO_PIN_INTDIR_BOTH;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -567,6 +573,18 @@ static DEVICE_API(gpio, ambiq_gpio_drv_api) = {
|
|||
#endif
|
||||
};
|
||||
|
||||
gpio_pin_t ambiq_gpio_get_pinnum(const struct device *dev, gpio_pin_t pin)
|
||||
{
|
||||
const struct ambiq_gpio_config *const dev_cfg = dev->config;
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_APOLLO3X)
|
||||
pin += dev_cfg->offset;
|
||||
#else
|
||||
pin += (dev_cfg->offset >> 2);
|
||||
#endif
|
||||
return pin;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_APOLLO3X)
|
||||
/* Apollo3 GPIO banks share the same irq number, connect irq here will cause build error, so we
|
||||
* leave this function blank here and do it in ambiq_gpio_cfg_func
|
||||
|
|
31
include/zephyr/drivers/gpio/gpio_ambiq.h
Normal file
31
include/zephyr/drivers/gpio/gpio_ambiq.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Ambiq Micro Inc. <www.ambiq.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_DRIVERS_GPIO_GPIO_AMBIQ_H_
|
||||
#define ZEPHYR_DRIVERS_GPIO_GPIO_AMBIQ_H_
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the actual gpio pin number.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param pin Pin number of the select gpio group.
|
||||
*
|
||||
* @retval pin number.
|
||||
*/
|
||||
gpio_pin_t ambiq_gpio_get_pinnum(const struct device *dev, gpio_pin_t pin);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_GPIO_GPIO_AMBIQ_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue