在MT9669的Linux Kernel中,驱动要如何实现中断操作呢?下面是对于非PM GPIO口实现IRQ的相应操作说明:
1.在MT9669中对于GPIO IRQ的对应关系说明如下:
在bootable/bootloader/mboot-mtk/mboot/sboot/inc/M7642/board/BD_MT167B_10AT_MT5888_M7642.h中有如下内容:
#define PADS_EXTINT0 DISABLE //CONFIG_PADMUX_MODE1: EXT INT0
#define PADS_EXTINT1 DISABLE //CONFIG_PADMUX_MODE1: EXT INT1
//CONFIG_PADMUX_MODE2: EXT INT1
#define PADS_EXTINT2 DISABLE //CONFIG_PADMUX_MODE1: EXT INT2
//CONFIG_PADMUX_MODE2: EXT INT2
#define PADS_EXTINT3 DISABLE //CONFIG_PADMUX_MODE1: EXT INT3
//CONFIG_PADMUX_MODE2: EXT INT3
#define PADS_EXTINT4 DISABLE //CONFIG_PADMUX_MODE1: EXT INT4
//CONFIG_PADMUX_MODE2: EXT INT4
#define PADS_EXTINT5 DISABLE //CONFIG_PADMUX_MODE1: EXT INT5
#define PADS_EXTINT6 DISABLE //CONFIG_PADMUX_MODE1: EXT INT6
//CONFIG_PADMUX_MODE2: EXT INT6
#define PADS_EXTINT7 DISABLE //CONFIG_PADMUX_MODE1: EXT INT7
在kernel/fusion/mstar2/hal/m7642/gpio/mhal_gpio.c中有如下内容:
/* ext_gpio_int in nonPM FIQ page in interrupt table */
/* must check gpio_func_mux page in chiptop table */
/* extend pad mux in below struct */
const int gpio_IntPad[INT_COUNT]=
{
132, //PAD_PWM2
133, //PAD_SPDIF_IN
79, //PAD_I2S_OUT_MCK
95, //PAD_PCM2_RESET
63, //PAD_GPIO9
64, //PAD_GPIO10
65, //PAD_GPIO11
66 //PAD_GPIO12
};
const int gpio_IRQnum[INT_COUNT]= {
E_FIQEXPL_EXT_GPIO0, /*E_INT_FIQ_GPIO0,*/
E_FIQEXPL_EXT_GPIO1, /*E_INT_FIQ_GPIO1,*/
E_FIQEXPL_EXT_GPIO2, /*E_INT_FIQ_GPIO2,*/
E_FIQEXPH_EXT_GPIO3, /*E_INT_FIQ_GPIO3,*/
E_FIQEXPH_EXT_GPIO4, /*E_INT_FIQ_GPIO4,*/
E_FIQEXPH_EXT_GPIO5, /*E_INT_FIQ_GPIO5,*/
E_FIQEXPH_EXT_GPIO6, /*E_INT_FIQ_GPIO6,*/
E_FIQEXPH_GPIOINIT7, /*E_INT_FIQ_GPIO7,*/
};
在mhal_gpio.c文件中也有关于PM口的定义,如需使用到,请查阅该文件。
从上面的代码,我们很清楚看到了非PM口IRQ的映射关系,以及哪些GPIO口可用于做为中断口。下面步骤2和3中以GPIO12口作为中断口为例说明相应的代码配置过程。
2.mboot部分
目前,我们测试了GPIO12口作为IRQ功能,在mboot中需要修改bootable/bootloader/mboot-mtk/mboot/sboot/inc/M7642/board/BD_MT167B_10AT_MT5888_M7642.h文件,对应的设置项如下:
#define PADS_EXTINT7 CONFIG_PADMUX_MODE1
#define PAD_GPIO12_IS_GPIO GPIO_IN
3.Kernel部分
内核配置文件中,需要打开如下配置才能使用相关API:
CONFIG_EXT_INTERRUPT_SUPPORT=y
Register IRQ:
static irq_handler_t handle_my_gpio_irq(unsigned int irq, void* device, struct pt_regs* registers) {
/* TODO Something */
return (irq_handler_t) IRQ_HANDLED;
}
static int my_gpio_irq = PAD_GPIO12;
ret = gpio_direction_input(my_gpio_irq);
ret = request_gpio_irq(
my_gpio_irq,
(irq_handler_t) handle_my_gpio_irq,
IRQF_TRIGGER_FALLING,
NULL);
Get IRQ Num:
my_gpio_irq_num = MHal_GPIO_Get_Interrupt_Num(my_gpio_irq);
Enable IRQ:
enable_irq(MHal_GPIO_Get_Interrupt_Num(my_gpio_irq));
Disable IRQ:
disable_irq(MHal_GPIO_Get_Interrupt_Num(my_gpio_irq));
Unregister IRQ:
MHal_GPIO_Disable_Interrupt(my_gpio_irq, NULL);
标签:MT9669,GPIO,IRQ,PADMUX,EXT,irq,gpio,CONFIG
From: https://blog.csdn.net/guochongxin/article/details/139754769