配置文件sys_config.fex中没有按键相关的配置项,而我现在想要加入一个GPIO口的按键板,配置文件应该怎么修改,之前都是使用设备数,突然用sys_config.fex配置文件,发现不知道该怎么弄了,麻烦知道的指点一下,感谢大家!!!
离线
linux3.4 还是 linux3.10 ?
linux3.4,好的,我试试。
离线
照猫画虎, 找一下 sys_config.fex 里面的关键字 ctp_int_port, 再搜一下驱动的实现.
你好,我参考这个链接使用内核自带的gpio-keys驱动,还不不能够生成一个event设备,是不是还有那些地方没有配置到位??
[gpiokey]
compatibel = "gpio-keys"
[gpiokey/ok_key]
lable = "ok_key"
gpios = port:PE11<6><default><default><default>
linux,input-type = <1>
linux,code = 139
离线
在驱动代码里面加一些调试日志
加了调试信息,连最基本的probe函数都没有调用
static int __devinit gpio_keys_probe(struct platform_device *pdev)
{
printk("%s %d %s\n",__FILE__,__LINE__,__FUNCTION__);
const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct gpio_keys_drvdata *ddata;
struct device *dev = &pdev->dev;
struct gpio_keys_platform_data alt_pdata;
struct input_dev *input;
int i, error;
int wakeup = 0;
if (!pdata) {
error = gpio_keys_get_devtree_pdata(dev, &alt_pdata);
。。。。。。
}
表明配置信息完全没有注册到内核里面去,也就是说上面的配置没有起到作用。不知道问题出在哪里
离线
驱动 module_init() 有执行吗?
执行了,应该是配置没有生效,在内核中找不到对应的platform,所以没有调用probe函数
离线
请问一下,我查了下IO口是没有被占用的,但是一直申请不了中断,提示中断错误。
[ 78.427800] drivers/input/keyboard/gpio_keys.c 855 gpio_keys_init
[ 78.434972] drivers/input/keyboard/gpio_keys.c 671 gpio_keys_probe
[ 78.442008] gpio-keys gpio-keys.0: Unable to get irq number for GPIO 128, error -6
出错的地方,看了下源码。IO口能够申请,但是就是不能申请中断
static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
struct input_dev *input,
struct gpio_button_data *bdata,
const struct gpio_keys_button *button)
{
const char *desc = button->desc ? button->desc : "gpio_keys";
struct device *dev = &pdev->dev;
irq_handler_t isr;
unsigned long irqflags;
int irq, error;
__u32 config;
bdata->input = input;
bdata->button = button;
spin_lock_init(&bdata->lock);
if (gpio_is_valid(button->gpio)) {
error = gpio_request(button->gpio, desc);
if (error < 0) {
dev_err(dev, "Failed to request GPIO %d %s, error %d\n",
button->gpio, button->desc, error);
return error;
}
config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_PUD, 1);
pin_config_set_pin(SUNXI_PINCTRL, button->gpio, config);
config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_DRV, 3);
pin_config_set_pin(SUNXI_PINCTRL, button->gpio, config);
error = gpio_direction_input(button->gpio);
if (error < 0) {
dev_err(dev,
"Failed to configure direction for GPIO %d, error %d\n",
button->gpio, error);
goto fail;
}
if (button->debounce_interval) {
error = gpio_set_debounce(button->gpio,
button->debounce_interval * 1000);
/* use timer if gpiolib doesn't provide debounce */
if (error < 0)
bdata->timer_debounce =
button->debounce_interval;
}
irq = gpio_to_irq(button->gpio);
if (irq < 0) {
error = irq;
dev_err(dev,
"Unable to get irq number for GPIO %d, error %d\n", =================》这个位置
button->gpio, error);
goto fail;
}
bdata->irq = irq;
INIT_WORK(&bdata->work, gpio_keys_gpio_work_func);
setup_timer(&bdata->timer,
gpio_keys_gpio_timer, (unsigned long)bdata);
isr = gpio_keys_gpio_isr;
irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
} else {
if (!button->irq) {
dev_err(dev, "No IRQ specified\n");
return -EINVAL;
}
bdata->irq = button->irq;
if (button->type && button->type != EV_KEY) {
dev_err(dev, "Only EV_KEY allowed for IRQ buttons.\n");
return -EINVAL;
}
bdata->timer_debounce = button->debounce_interval;
setup_timer(&bdata->timer,
gpio_keys_irq_timer, (unsigned long)bdata);
isr = gpio_keys_irq_isr;
irqflags = 0;
}
input_set_capability(input, button->type ?: EV_KEY, button->code);
/*
* If platform has specified that the button can be disabled,
* we don't want it to share the interrupt line.
*/
if (!button->can_disable)
irqflags |= IRQF_SHARED;
error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata);
if (error < 0) {
dev_err(dev, "Unable to claim irq %d; error %d\n",
bdata->irq, error);
goto fail;
}
return 0;
fail:
if (gpio_is_valid(button->gpio))
gpio_free(button->gpio);
return error;
}
离线
也是变态了,问题出在A33的一些IO口不能够申请中断,仔细注意了一下数据手册才发现。
离线