summaryrefslogtreecommitdiff
path: root/target/linux/rdc-2.6/files/drivers/leds/leds-rdc3211.c
blob: 6a15a16ad539607ab12decbdbf9765a4bd974d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * LED driver for RDC3211 boards
 *
 * Copyright 2007 Florian Fainelli <florian@openwrt.org>
 * 
 * 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.
 *
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/err.h>

#include <asm/gpio.h>

/* This is just for testing purpose */
int gpio;
module_param(gpio, int, 0444);
MODULE_PARM_DESC(gpio, " GPIO line");

static void rdc321x_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
{
	gpio_set_value(gpio, brightness ? 1 : 0);
}

/* The DMZ led is at GPIO line 1 */
static struct led_classdev rdc321x_dmz_led = {
	.name = "rdc321x:dmz",
	.brightness_set = rdc321x_led_set,
};

static int rdc321x_leds_probe(struct platform_device *pdev)
{
	return led_classdev_register(&pdev->dev, &rdc321x_dmz_led);
}

static int rdc321x_leds_remove(struct platform_device *pdev)
{
	led_classdev_unregister(&rdc321x_dmz_led);
	return 0;
}

static struct platform_driver rdc321x_leds_driver = {
	.probe = rdc321x_leds_probe,
	.remove = rdc321x_leds_remove,
	.driver = {
		.name = "rdc321x-leds",
		.owner = THIS_MODULE,
	}
};

static int __init rdc321x_leds_init(void)
{
	int ret;

	ret = platform_driver_register(&rdc321x_leds_driver);

	return ret;
}
		
static void __exit rdc321x_leds_exit(void)
{
	platform_driver_unregister(&rdc321x_leds_driver);
}

module_init(rdc321x_leds_init);
module_exit(rdc321x_leds_exit);
		
MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
MODULE_DESCRIPTION("RDC321x LED driver");
MODULE_LICENSE("GPL");