Hammer LED Class Driver

UserSpace Access
the LED onboard the hammer as well as the LED on the carrier board can be accessed from userspace via the sysfs interface. example interfaces are in /sys/devices/platform/s3c24xx_led.0/leds:led0/ and /sys/devices/platform/s3c24xx_led.1/leds:led1/. both directories include a file entry "brightness". to turn a LED on, echo a non zero value to the brightness file entry: echo 1 > /sys/devices/platform/s3c24xx_led.0/leds:led0/brightness to turn a LED off, echo a zero to the the brightness file entry: echo 0 > /sys/devices/platform/s3c24xx_led.0/leds:led0/brightness

you can also check the current status of the LED by using cat on the brightness file entry: cat /sys/devices/platform/s3c24xx_led.0/leds:led0/brightness

Adding New LEDS
a new LED connected via a GPIO can be defined in the linux-2.6.xx/arch/arm/mach-s3c2410/mach-tct_hammer.c file. each LED will need to include some platform data and a platform device definition:

static struct s3c24xx_led_platdata tct_hammer_pdata_led0 = { .gpio		= S3C2410_GPF0, .flags		= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, .name		= "led0", .def_trigger	= "timer", };

static struct platform_device tct_hammer_led0 = { .name		= "s3c24xx_led", .id		= 0, .dev		= { .platform_data = &tct_hammer_pdata_led0, }, };

this uses the standard LEDS class in the main kernel tree. for additional information see the linux-2.6.xx/Documentation/leds-class.txt file.

Nail Board LED's
static struct s3c24xx_led_platdata tct_hammer_pdata_led1 = { .gpio		= S3C2410_GPH0, .flags		= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, .name		= "led1", .def_trigger	= "timer", };

static struct s3c24xx_led_platdata tct_hammer_pdata_led2 = { .gpio		= S3C2410_GPH1, .flags		= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, .name		= "led2", .def_trigger	= "timer", };

static struct platform_device tct_hammer_led1 = { .name		= "s3c24xx_led", .id		= 1, .dev		= { .platform_data = &tct_hammer_pdata_led1, }, };

static struct platform_device tct_hammer_led2 = { .name		= "s3c24xx_led", .id		= 2, .dev		= { .platform_data = &tct_hammer_pdata_led2, }, };

you will also need to add some gpio setup in the machine init function:

static void __init tct_hammer_init(void) {

s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPIO_OUTPUT); s3c2410_gpio_setpin(S3C2410_GPF0, 1);

/* add these lines to setup the leds on the nail board */ s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPIO_OUTPUT); s3c2410_gpio_setpin(S3C2410_GPH0, 1); s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPIO_OUTPUT); s3c2410_gpio_setpin(S3C2410_GPH1, 1);

s3c2410_gpio_cfgpin(S3C2410_GPC12, S3C2410_GPIO_OUTPUT); s3c2410_gpio_setpin(S3C2410_GPC12, 1);

/*uncomment these these to enable the second serial port */ /*	s3c2410_gpio_cfgpin(S3C2410_GPH6, S3C2410_GPH6_TXD0); s3c2410_gpio_pullup(S3C2410_GPH6, 1); s3c2410_gpio_cfgpin(S3C2410_GPH7, S3C2410_GPH7_RXD0); s3c2410_gpio_pullup(S3C2410_GPH7, 1); s3c24xx_fb_set_platdata(&tct_hammer_lcd_info); platform_add_devices(tct_hammer_devices, ARRAY_SIZE(tct_hammer_devices)); }
 * 1) ifdef CONFIG_FB_S3C2410
 * 1) ifdef CONFIG_FB_S3C2410
 * 1) endif

in addition you will need to add the leds to the device list:

static struct platform_device *tct_hammer_devices[] __initdata = { &s3c_device_lcd, &s3c_device_adc, &s3c_device_wdt, &s3c_device_i2c, &s3c_device_usb, &s3c_device_rtc, &s3c_device_usbgadget, &s3c_device_sdi, &tct_hammer_led0, /* add these two entries for the new LEDs */ &tct_hammer_led1, &tct_hammer_led2, &tct_hammer_beeper, &tct_hammer_buttons, &tct_hammer_device_nor, };
 * 1) ifdef CONFIG_FB_S3C2410
 * 1) endif
 * 1) ifdef CONFIG_MTD_PARTITIONS
 * 1) endif