mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-01 12:24:34 +08:00
[dm][pinctrl] new interface for 'pin_gpio_request'
Some GPIO should apply GPIO mode by pinctrl, add `pin_ctrl_gpio_request` for GPIO driver to apply it auto. Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
@@ -224,6 +224,7 @@ struct rt_pin_ops
|
|||||||
#endif
|
#endif
|
||||||
#ifdef RT_USING_PINCTRL
|
#ifdef RT_USING_PINCTRL
|
||||||
rt_err_t (*pin_ctrl_confs_apply)(struct rt_device *device, void *fw_conf_np);
|
rt_err_t (*pin_ctrl_confs_apply)(struct rt_device *device, void *fw_conf_np);
|
||||||
|
rt_err_t (*pin_ctrl_gpio_request)(struct rt_device *device, rt_base_t gpio, rt_uint32_t flags);
|
||||||
#endif /* RT_USING_PINCTRL */
|
#endif /* RT_USING_PINCTRL */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -456,3 +456,20 @@ rt_ssize_t rt_pin_get_named_pin_count(struct rt_device *dev, const char *propnam
|
|||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_USING_PINCTRL
|
||||||
|
rt_err_t pin_gpio_request(struct rt_device_pin *pinctrl, rt_base_t gpio, rt_uint32_t flags)
|
||||||
|
{
|
||||||
|
if (!pinctrl || gpio < 0)
|
||||||
|
{
|
||||||
|
return -RT_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pinctrl->ops->pin_ctrl_gpio_request)
|
||||||
|
{
|
||||||
|
return pinctrl->ops->pin_ctrl_gpio_request(&pinctrl->parent, gpio, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
#endif /* RT_USING_PINCTRL */
|
||||||
|
|||||||
@@ -15,9 +15,47 @@
|
|||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <rtdevice.h>
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind GPIO pin to system PIN API
|
||||||
|
*
|
||||||
|
* @param gpio Pin device
|
||||||
|
* @param pin_nr GPIO pin number
|
||||||
|
*
|
||||||
|
* @return RT_EOK on success, error code otherwise
|
||||||
|
*/
|
||||||
rt_err_t pin_api_init(struct rt_device_pin *gpio, rt_size_t pin_nr);
|
rt_err_t pin_api_init(struct rt_device_pin *gpio, rt_size_t pin_nr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind GPIO pin to system PIN PIC
|
||||||
|
*
|
||||||
|
* @param gpio Pin device
|
||||||
|
* @param pin_irq GPIO irqno
|
||||||
|
*
|
||||||
|
* @return RT_EOK on success, error code otherwise
|
||||||
|
*/
|
||||||
rt_err_t pin_pic_init(struct rt_device_pin *gpio, int pin_irq);
|
rt_err_t pin_pic_init(struct rt_device_pin *gpio, int pin_irq);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle GPIO one pin's ISR
|
||||||
|
*
|
||||||
|
* @param gpio Pin device
|
||||||
|
* @param pin GPIO pin
|
||||||
|
*
|
||||||
|
* @return RT_EOK on success, error code otherwise
|
||||||
|
*/
|
||||||
rt_err_t pin_pic_handle_isr(struct rt_device_pin *gpio, rt_base_t pin);
|
rt_err_t pin_pic_handle_isr(struct rt_device_pin *gpio, rt_base_t pin);
|
||||||
|
|
||||||
|
#ifdef RT_USING_PINCTRL
|
||||||
|
/**
|
||||||
|
* Request GPIO pin configuration from pinctrl
|
||||||
|
*
|
||||||
|
* @param pinctrl Pinctrl device
|
||||||
|
* @param gpio GPIO pin number
|
||||||
|
* @param flags GPIO configuration flags
|
||||||
|
*
|
||||||
|
* @return RT_EOK on success, error code otherwise
|
||||||
|
*/
|
||||||
|
rt_err_t pin_gpio_request(struct rt_device_pin *pinctrl, rt_base_t gpio, rt_uint32_t flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __DEV_PIN_DM_H__ */
|
#endif /* __DEV_PIN_DM_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user