MT6735平台GPIO中断调试记录

dws文件配置:kernel-3.10/tools/dct/drvgen.exe 

bootable/bootloader/lk/target/mt6735_66t_a19/dct/dct/codegen.dws

bootable/bootloader/preloader/custom/mt6735_66t_a19/dct/dct/codegen.dws

kernel-3.10/drivers/misc/mediatek/mach/mt6735/mt6735_66t_a19/dct/dct/codegen.dws

vendor/mediatek/proprietary/custom/mt6735_66t_a19/kernel/dct/dct/codegen.dws


MTK中断IC驱动:kernel-3.10/drivers/irqchip/irq-mt-eic.c

 函数:mt_eint_irq_set_type 即设置中断到寄存器。

struct irq_chip mt_irq_eint = {
   .name       = "mt-eint",
   .irq_mask   = mt_eint_irq_mask,
   .irq_unmask = mt_eint_irq_unmask,
   .irq_ack    = mt_eint_irq_ack,
   .irq_set_type   = mt_eint_irq_set_type,
};

linux 驱动设置接口:kernel-3.10/kernel/irq/manage.c

主要流程:request_irq --> request_threaded_irq  --> __irq_set_trigger


MTK平台似乎不支持同时上升沿及下降沿触发。

switch_data->irq = gpio_to_irq(switch_data->gpio);
if (switch_data->irq < 0) {
ret = switch_data->irq;
goto err_detect_irq_num_failed;
}
flags = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | 0;
irq_set_irq_type(switch_data->irq, IRQ_TYPE_EDGE_BOTH);
    DBLOG("request_irq: irq=%d, flag=%lu\n", switch_data->irq, flags);
    ret = request_irq(switch_data->irq, gpio_irq_handler, flags, pdata->name, switch_data);
    if (ret < 0) {
        DBLOG("%s: request_irq fail ret=%d\n", __func__, ret);
        goto err_request_irq;
    }
    enable_irq_wake(switch_data->irq);
/* Perform initial detection */
// gpio_switch_work(&switch_data->work);




移除驱动时注意input devices 设备 input_unregister_device后再/input_free_device会有问题。


static int dbatt_switch_remove(struct platform_device *pdev) {
    struct gpio_switch_data *switch_data = platform_get_drvdata(pdev);


DBLOG("%s: entry\n", __func__);
    disable_irq_wake(switch_data->irq);
    free_irq(switch_data->irq, switch_data);
    gpio_free(switch_data->gpio);
    gpio_free(DBATT_MBATID_DET_PIN);
    gpio_free(DBATT_SWITCH_EN_PIN);
    input_unregister_device(switch_data->input_dev);
    //input_free_device(switch_data->input_dev);
    kfree(switch_data);
    
#ifdef DBATT_HALL_STATUS_NOTIFY
    device_remove_file(&pdev->dev, &hall_dev_attr);
#endif


return 0;
}

你可能感兴趣的:(android,linux,input)