Chinaunix首页 | 论坛 | 博客
  • 博客访问: 458505
  • 博文数量: 40
  • 博客积分: 1410
  • 博客等级: 军士长
  • 技术积分: 1396
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-22 19:26
个人简介

嵌入式系统工程师,从事视频、图像、网络、虚拟化等方面的底层软件开发与优化。

文章存档

2014年(4)

2013年(10)

2012年(14)

2011年(12)

分类: LINUX

2011-12-04 15:59:49

      这几天看输入子系统,以下是在友善Tiny6410开发板上的基于输入子系统的GPIO按键驱动配置。GPN(5)在LCD Power里被占用了,故会在驱动加载时,提示error -16,即EBUSY。注释掉后,即可使用。
  1. diff -uNr linux-2.6.38/arch/arm/mach-s3c64xx/mach-mini6410.c linux-2.6.38-jason//arch/arm/mach-s3c64xx/mach-mini6410.c
  2. --- linux-2.6.38/arch/arm/mach-s3c64xx/mach-mini6410.c    2011-07-18 12:10:46.000000000 +0800
  3. +++ linux-2.6.38-jason//arch/arm/mach-s3c64xx/mach-mini6410.c    2011-12-02 16:16:22.725178722 +0800
  4. @@ -32,6 +32,8 @@
  5.  #include <linux/mtd/mtd.h>
  6.  #include <linux/mtd/partitions.h>
  7.  #include <linux/proc_fs.h>
  8. +#include <linux/gpio_keys.h>    //add by Jason
  9. +#include <linux/input.h>    //add by Jason
  10.  
  11.  #include <video/platform_lcd.h>

  12. @@ -333,7 +335,75 @@
  13.  #endif
  14.  };
  15.  
  16. +/* Tiny6410 Buttons */
  17. +static struct gpio_keys_button tiny6410_buttons[] = {        //add by Jason
  18. +    {
  19. +        .gpio        = S3C64XX_GPN(0),
  20. +        .code        = KEY_1,
  21. +        .desc        = "key1",
  22. +        .active_low    = 1,
  23. +    },
  24. +    {
  25. +        .gpio        = S3C64XX_GPN(1),
  26. +        .code        = KEY_2,
  27. +        .desc        = "key2",
  28. +        .active_low    = 1,
  29. +    },
  30. +    {
  31. +        .gpio        = S3C64XX_GPN(2),
  32. +        .code        = KEY_3,
  33. +        .desc        = "key3",
  34. +        .active_low    = 1,
  35. +    },
  36. +    {
  37. +        .gpio        = S3C64XX_GPN(3),
  38. +        .code        = KEY_4,
  39. +        .desc        = "key4",
  40. +        .active_low    = 1,
  41. +    },
  42. +    {
  43. +        .gpio        = S3C64XX_GPN(4),
  44. +        .code        = KEY_5,
  45. +        .desc        = "key5",
  46. +        .active_low    = 1,
  47. +    },
  48. +    /* be used by LCD
  49. +    {
  50. +        .gpio        = S3C64XX_GPN(5),
  51. +        .code        = KEY_6,
  52. +        .desc        = "key6",
  53. +        .active_low    = 1,
  54. +    },
  55. +    */
  56. +    {
  57. +        .gpio        = S3C64XX_GPL(11),
  58. +        .code        = KEY_7,
  59. +        .desc        = "key7",
  60. +        .active_low    = 1,
  61. +    },
  62. +    {
  63. +        .gpio        = S3C64XX_GPL(12),
  64. +        .code        = KEY_8,
  65. +        .desc        = "key8",
  66. +        .active_low    = 1,
  67. +    },
  68. +};
  69. +
  70. +static struct gpio_keys_platform_data tiny6410_button_data = {    //add by Jason
  71. +    .buttons    = tiny6410_buttons,
  72. +    .nbuttons    = ARRAY_SIZE(tiny6410_buttons),
  73. +};
  74. +
  75. +static struct platform_device tiny6410_device_button = {    //add by Jason
  76. +    .name    = "gpio-keys",
  77. +    .id    = -1,
  78. +    .dev    = {
  79. +        .platform_data    = &tiny6410_button_data,
  80. +    }
  81. +};
  82. +
  83.  static struct platform_device *mini6410_devices[] __initdata = {
  84. +    &tiny6410_device_button,                //add by Jason
  85.  #ifdef CONFIG_MINI6410_SD_CH0
  86.      &s3c_device_hsmmc0,
  87.  #endif
  88. diff -uNr linux-2.6.38/drivers/input/keyboard/gpio_keys.c linux-2.6.38-jason//drivers/input/keyboard/gpio_keys.c
  89. --- linux-2.6.38/drivers/input/keyboard/gpio_keys.c    2011-03-18 17:02:19.000000000 +0800
  90. +++ linux-2.6.38-jason//drivers/input/keyboard/gpio_keys.c    2011-12-02 15:42:44.369090912 +0800
  91. @@ -373,8 +373,8 @@
  92.  
  93.      error = gpio_request(button->gpio, desc);
  94.      if (error < 0) {
  95. -        dev_err(dev, "failed to request GPIO %d, error %d\n",
  96. -            button->gpio, error);
  97. +        dev_err(dev, "failed to request GPIO %d, error %d\ndesc = %s",
  98. +            button->gpio, error, desc);
  99.          goto fail2;
  100.      }




阅读(4244) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~