mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-24 02:48:26 +02:00
add proper led support to ifxmips
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@11137 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
8cbfca3491
commit
11770b809e
@ -31,8 +31,10 @@
|
|||||||
#include <asm/ifxmips/ifxmips.h>
|
#include <asm/ifxmips/ifxmips.h>
|
||||||
#include <asm/ifxmips/ifxmips_gpio.h>
|
#include <asm/ifxmips/ifxmips_gpio.h>
|
||||||
#include <asm/ifxmips/ifxmips_pmu.h>
|
#include <asm/ifxmips/ifxmips_pmu.h>
|
||||||
|
#include <linux/leds.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
|
||||||
#define DRVNAME "ifxmips_led"
|
#define DRVNAME "ifxmips_led"
|
||||||
|
|
||||||
#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING
|
#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING
|
||||||
//#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING
|
//#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING
|
||||||
@ -41,7 +43,12 @@
|
|||||||
|
|
||||||
#define IFXMIPS_LED_GPIO_PORT 0
|
#define IFXMIPS_LED_GPIO_PORT 0
|
||||||
|
|
||||||
static int ifxmips_led_major;
|
#define IFXMIPS_MAX_LED 24
|
||||||
|
|
||||||
|
struct ifxmips_led {
|
||||||
|
struct led_classdev cdev;
|
||||||
|
u8 bit;
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
ifxmips_led_set (unsigned int led)
|
ifxmips_led_set (unsigned int led)
|
||||||
@ -75,6 +82,17 @@ ifxmips_led_blink_clear (unsigned int led)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ifxmips_led_blink_clear);
|
EXPORT_SYMBOL(ifxmips_led_blink_clear);
|
||||||
|
|
||||||
|
void
|
||||||
|
ifxmips_ledapi_set(struct led_classdev *led_cdev, enum led_brightness value)
|
||||||
|
{
|
||||||
|
struct ifxmips_led *led_dev = container_of(led_cdev, struct ifxmips_led, cdev);
|
||||||
|
|
||||||
|
if(value)
|
||||||
|
ifxmips_led_set(1 << led_dev->bit);
|
||||||
|
else
|
||||||
|
ifxmips_led_clear(1 << led_dev->bit);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ifxmips_led_setup_gpio (void)
|
ifxmips_led_setup_gpio (void)
|
||||||
{
|
{
|
||||||
@ -90,41 +108,10 @@ ifxmips_led_setup_gpio (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
led_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
int ret = -EINVAL;
|
|
||||||
|
|
||||||
switch ( cmd )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
led_open (struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
led_release (struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct file_operations ifxmips_led_fops = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.ioctl = led_ioctl,
|
|
||||||
.open = led_open,
|
|
||||||
.release = led_release
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ifxmips_led_probe(struct platform_device *dev)
|
ifxmips_led_probe(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int i = 0;
|
||||||
|
|
||||||
ifxmips_led_setup_gpio();
|
ifxmips_led_setup_gpio();
|
||||||
|
|
||||||
@ -155,26 +142,23 @@ ifxmips_led_probe(struct platform_device *dev)
|
|||||||
/* per default, the leds are turned on */
|
/* per default, the leds are turned on */
|
||||||
ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED);
|
ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED);
|
||||||
|
|
||||||
ifxmips_led_major = register_chrdev(0, "ifxmips_led", &ifxmips_led_fops);
|
for(i = 0; i < IFXMIPS_MAX_LED; i++)
|
||||||
|
|
||||||
if (!ifxmips_led_major)
|
|
||||||
{
|
{
|
||||||
printk("ifxmips_led: Error! Could not register device. %d\n", ifxmips_led_major);
|
struct ifxmips_led *tmp = kzalloc(sizeof(struct ifxmips_led), GFP_KERNEL);
|
||||||
ret = -EINVAL;
|
tmp->cdev.brightness_set = ifxmips_ledapi_set;
|
||||||
|
tmp->cdev.name = kmalloc(sizeof("ifxmips:led:00"), GFP_KERNEL);
|
||||||
goto out;
|
sprintf(tmp->cdev.name, "ifxmips:led:%02d", i);
|
||||||
|
tmp->cdev.default_trigger = NULL;
|
||||||
|
tmp->bit = i;
|
||||||
|
led_classdev_register(&dev->dev, &tmp->cdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
printk(KERN_INFO "ifxmips_led: device successfully initialized #%d.\n", ifxmips_led_major);
|
return 0;
|
||||||
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ifxmips_led_remove(struct platform_device *pdev)
|
ifxmips_led_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
unregister_chrdev(ifxmips_led_major, "ifxmips_led");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,23 +172,6 @@ platform_driver ifxmips_led_driver = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
Map for LED on reference board
|
|
||||||
WLAN_READ LED11 OUT1 15
|
|
||||||
WARNING LED12 OUT2 14
|
|
||||||
FXS1_LINK LED13 OUT3 13
|
|
||||||
FXS2_LINK LED14 OUT4 12
|
|
||||||
FXO_ACT LED15 OUT5 11
|
|
||||||
USB_LINK LED16 OUT6 10
|
|
||||||
ADSL2_LINK LED19 OUT7 9
|
|
||||||
BT_LINK LED17 OUT8 8
|
|
||||||
SD_LINK LED20 OUT9 7
|
|
||||||
ADSL2_TRAFFIC LED31 OUT16 0
|
|
||||||
Map for hardware relay on reference board
|
|
||||||
USB Power On OUT11 5
|
|
||||||
RELAY OUT12 4
|
|
||||||
*/
|
|
||||||
|
|
||||||
int __init
|
int __init
|
||||||
ifxmips_led_init (void)
|
ifxmips_led_init (void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user