参考ldd6410-manual[1].pdf
向s3c6410系统曾加LED设备的驱动.有四个led 的灯分别与GPIO 的GPK4,GPK5,GPK6,GPK7相连,四个led为共阳。
Linux 内核下的drivers/leds/ledsgpio.c 实现了一个体系结构无关的 GPIO LED 驱动, 使用此 LED 驱动,开发者不需要修改一行代码,只需要在BSP的板文件(/home/wsh/s3c-linux-2.6.28.6-Real6410/arch/arm/mach-s3c6410/mach-smdk6410.c)中定义相关的平台的设备和数据。
///*led driver support*/
static struct gpio_led s3c6410_leds[] = {
[0] = {
.name = "LED10",
.gpio = S3C64XX_GPK(4),
},
[1] = {
.name = "LED12",
.gpio = S3C64XX_GPK(5),
},
[2] = {
.name = "LED13",
.gpio = S3C64XX_GPK(6),
},
[3] = {
.name = "LED14",
.gpio = S3C64XX_GPK(7),
},
};
/*platform data support 其中gpio_led_platform_data在/linux/leds.h中定义了应将此文件包含在bsp文件当中*/
static struct gpio_led_platform_data s3c6410_gpio_led_pdata = {
.num_leds = ARRAY_SIZE(s3c6410_leds),
.leds = s3c6410_leds,
};
/*platform device struct in /linux/platform_device.h define */
static struct platform_device s3c_device_led = {
.name = "leds-gpio",//注册device name 要于加进去的设备驱动一致,不一致就注册不成功
.id = 1,
.dev = {
.platform_data = &s3c6410_gpio_led_pdata,
},
};
并将“&s3c_device_led,”语句填入 struct platform_device *smdk6410_devices[]数组,作为该数组的一个成
员。
编译内核make menuconfig
时会应选择
--- LED Support │ │
│ │ <*> LED Class Support │ │
│ │ *** LED drivers *** │ │
│ │ < > LED driver for PCA9532 dimmer │ │
│ │ <*> LED Support for GPIO connected LEDs │ │
│ │ < > LED Support for PCA955x I2C chips │ │
│ │ *** LED Triggers *** │ │
│ │ [ ] LED Trigger support
通过以下方式能查看系统的驱动
在系统打印的时候会打印如下信息
Registered led device: LED10
Registered led device: LED12
Registered led device: LED13
Registered led device: LED13
[root@FriendlyARM leds]# pwd
/sys/class/leds
[root@FriendlyARM leds]# ls
LED10 LED12 LED13 LED14 mmc0
控制灯亮
[root@FriendlyARM leds]# echo 0 >LED10/brightness
控制灯灭
[root@FriendlyARM leds]# echo 1 >LED10/brightness