linux-2.6.35.4_fa92
make menuconfig
--->LED SUPPORT
--->
1、.config
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y#
# LED drivers##
CONFIG_LEDS_PCA9532 is not set
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_GPIO_PLATFORM=y
# CONFIG_LEDS_LP3944 is not set
# CONFIG_LEDS_PCA955X is not set
# CONFIG_LEDS_DAC124S085 is not set
# CONFIG_LEDS_BD2802 is not set
# CONFIG_LEDS_LT3593 is not set
CONFIG_LEDS_TRIGGERS=y
## LED Triggers#
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
CONFIG_LEDS_TRIGGER_GPIO=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
2、arch/arm/mach-w55fa92/w55fa92.c
@@ -17,8 +17,13 @@
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
#include <mach/w55fa92_reg.h>
#include <mach/w55fa92_gpio.h>
#include <mach/hardware.h>
#include <mach/serial.h>
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/leds.h>
#include "cpu.h"
#include "dev.h"
#include "clock.h"
@@ -261,6 +266,32 @@
static struct platform_device *uart_devices[] __initdata = {
&w55fa92_uart0,
&w55fa92_uart1
};
/* 添加gpio值 */
static struct gpio_led w55fa92_led_pins[] = {
{
.name = "led-gpio-b",
.gpio = 72,
},
{
.name = "led-gpio-g",
.gpio = 73,
},
{
.name = "led-gpio-r",
.gpio = 74,
},
};
static struct gpio_led_platform_data w55fa92_led_data = {
.num_leds = ARRAY_SIZE(w55fa92_led_pins),
.leds = w55fa92_led_pins,
};
static struct platform_device w55fa92_leds = {
.name = "leds-gpio",
.id = -1,
.dev = {
.platform_data = &w55fa92_led_data,
},
};
static int w55fa92_uart_count = 0;
@@ -507,5 +538,6 @@
void __init w55fa92_board_init(void)
{
platform_add_devices(w55fa92_uart_devs, w55fa92_uart_count);
platform_device_register(&w55fa92_leds);
w55fa92_dev_init();
}
// LED RGB IO是GPC8、GPC9、GPC10
GPIO计算方式
GPA[ 0] = GPIO[ 0x00] = GPIO0
GPA[ 1] = GPIO[ 0x01] = GPIO1
GPA[31] = GPIO[ 0x1F] = GPIO31
GPB[ 0] = GPIO[ 0x20] = GPIO32
GPB[31] = GPIO[ 0x3F] = GPIO63
GPC[ 0] = GPIO[ 0x40] = GPIO64
GPD[ 0] = GPIO[ 0x60] = GPIO96
GPE[ 0] = GPIO[ 0x80] = GPIO128
GPG[ 0] = GPIO[ 0xA0] = GPIO160
GPH[ 0] = GPIO[ 0xC0] = GPIO192
GPH[31] = GPIO[ 0xDF] = GPIO223
GPC8==72、GPC9==73、GPC10==74