2007-03-19 19:34:37 +02:00
|
|
|
/*
|
|
|
|
* ADM5120 LED (GPIO) driver
|
|
|
|
*
|
|
|
|
* Copyright (C) Jeroen Vreeken (pe1rxq@amsat.org), 2005
|
2007-05-11 12:57:01 +03:00
|
|
|
* Copyright (C) OpenWrt.org, Florian Fainelli <florian@openwrt.org>, 2007
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
2007-03-19 19:34:37 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2007-05-11 12:57:01 +03:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/leds.h>
|
2007-03-19 19:34:37 +02:00
|
|
|
|
|
|
|
#define GPIO_IO ((unsigned long *)0xb20000b8)
|
|
|
|
|
2007-05-11 12:57:01 +03:00
|
|
|
static void adm5120_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-05-11 12:57:01 +03:00
|
|
|
if (brightness)
|
|
|
|
*GPIO_IO=(*GPIO_IO & 0x00ffffff) | (brightness << 24);
|
|
|
|
else
|
|
|
|
*GPIO_IO=(*GPIO_IO & 0x00ffffff) | (0 << 24);
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-05-11 12:57:01 +03:00
|
|
|
static struct led_classdev adm5120_gpio_led = {
|
|
|
|
.name = "adm5120:led",
|
|
|
|
.brightness_set = adm5120_led_set,
|
2007-03-19 19:34:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init adm5120_led_init(void)
|
|
|
|
{
|
2007-05-11 12:57:01 +03:00
|
|
|
int ret = led_classdev_register(NULL, &adm5120_gpio_led);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
printk(KERN_WARNING "adm5120: unable to register LED device\n");
|
|
|
|
|
|
|
|
return ret;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit adm5120_led_exit(void)
|
|
|
|
{
|
2007-05-11 12:57:01 +03:00
|
|
|
led_classdev_unregister(&adm5120_gpio_led);
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(adm5120_led_init);
|
|
|
|
module_exit(adm5120_led_exit);
|
|
|
|
|
2007-05-11 12:57:01 +03:00
|
|
|
MODULE_DESCRIPTION("ADM5120 LED driver");
|
|
|
|
MODULE_AUTHOR("Jeroen Vreeken, OpenWrt.org");
|
2007-03-19 19:34:37 +02:00
|
|
|
MODULE_LICENSE("GPL");
|