工具/软件:
你(们)好
在 SDK 10中、我们希望使用 E27作为中断端口。
所以我修改了代码
From 967005c5ab27b8a757fd713f4d6462495314ef83 Mon Sep 17 00:00:00 2001 From: Keerthy <j-keerthy@ti.com> Date: Thu, 11 Nov 2021 20:39:59 +0530 Subject: [PATCH] davinci_gpio: Test interrupts This specifically tries out wkup_gpio52 Signed-off-by: Keerthy <j-keerthy@ti.com> --- .../dts/ti/k3-j721e-common-proc-board.dts | 17 ++++++++ drivers/gpio/gpio-davinci.c | 41 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts b/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts index c0d32b806..9079f82e3 100644 --- a/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts +++ b/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts @@ -93,6 +93,12 @@ <3300000 0x1>; }; + gpio_test: gpio_test { + compatible = "ti,gpio_test"; + interrupt-parent = <&wkup_gpio0>; + interrupts = <52 IRQ_TYPE_EDGE_BOTH>; + }; + sound0: sound@0 { compatible = "ti,j721e-cpb-audio"; model = "j721e-cpb"; @@ -301,6 +307,12 @@ >; }; + test_key_pins_default: test-key-pins-default { + pinctrl-single,pins = < + J721E_WKUP_IOPAD(0x90, PIN_INPUT, 7) /* (E27) WKUP_GPIO0_52 */ + >; + }; + mcu_fss0_ospi1_pins_default: mcu-fss0-ospi1-pins-default { pinctrl-single,pins = < J721E_WKUP_IOPAD(0x34, PIN_OUTPUT, 0) /* (F22) MCU_OSPI1_CLK */ @@ -433,6 +445,11 @@ status = "disabled"; }; +&wkup_gpio0 { + pinctrl-names = "default"; + pinctrl-0 = <&test_key_pins_default>; +}; + &main_sdhci0 { /* eMMC */ non-removable; diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 6f2138503..9c71df4fa 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -23,8 +23,15 @@ #include <linux/irqchip/chained_irq.h> #include <linux/spinlock.h> + #include <asm-generic/gpio.h> +#include <linux/interrupt.h> +#include <linux/of_irq.h> +#include <linux/of_gpio.h> + +int gpio_test_init(void); + #define MAX_REGS_BANKS 5 #define MAX_INT_PER_BANK 32 @@ -187,6 +194,35 @@ davinci_gpio_get_pdata(struct platform_device *pdev) return NULL; } +static irqreturn_t test_irq(int irq, void *data) +{ + pr_info("%s: irq %d, val=%d\n", __func__, irq, + gpio_get_value(432)); + return IRQ_HANDLED; +} + +int gpio_test_init(void) +{ + struct device_node *np; + int irq; + int ret = 0; + + np = of_find_node_by_name(NULL, "gpio_test"); + + if (np) { + pr_info("Initializing gpio test\n"); + irq = irq_of_parse_and_map(np, 0); + printk("irq number is %d\n", irq); + ret = request_irq(irq, test_irq, //IRQF_TRIGGER_RISING, + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, + "key-gpio", NULL); + if (ret) + pr_err("request_irq returns %d\n", ret); + } + + return ret; +} + static int davinci_gpio_probe(struct platform_device *pdev) { int bank, i, ret = 0; @@ -195,6 +231,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) struct davinci_gpio_platform_data *pdata; struct device *dev = &pdev->dev; + printk("Name of gpio dev is %s\n", pdev->name); pdata = davinci_gpio_get_pdata(pdev); if (!pdata) { dev_err(dev, "No platform data found\n"); @@ -273,6 +310,10 @@ static int davinci_gpio_probe(struct platform_device *pdev) if (ret) return ret; + if (!strcmp("42110000.gpio", pdev->name)) { + gpio_test_init(); + } + return 0; } -- 2.17.1
但这是不起作用的
日志为:
[1.399969]##### GPIO DEV 的名称是42110000.gpio
[ 1.404119] mmc0:使用 ADMA 64位的4f80000.mmc [4f80000.mmc]上的 SDHCI 控制器
[ 1.404865] mmc1:使用 ADMA 64位的4fb0000.mmc [4fb0000.MMC]上的 SDHCI 控制器
[ 1.419787] DaVinci _GPIO 42110000。GPIO:错误-ENXIO:未找到 IRQ 索引0
BR
中断