Modified GPIO allocation per rev1.02 board
[openwrt.git] / target / linux / au1000-2.6 / patches / 011-mtx1_leds.patch
1 diff -urN linux-2.6.19.2/drivers/leds/Kconfig linux-2.6.19.2.new/drivers/leds/Kconfig
2 --- linux-2.6.19.2/drivers/leds/Kconfig 2007-01-10 20:10:37.000000000 +0100
3 +++ linux-2.6.19.2.new/drivers/leds/Kconfig 2007-03-02 13:50:28.000000000 +0100
4 @@ -76,6 +76,13 @@
5 This option enables support for the Soekris net4801 and net4826 error
6 LED.
7
8 +config LEDS_MTX1
9 + tristate "LED Support for MTX-1 boards"
10 + depends on LEDS_CLASS && MIPS_MTX1
11 + help
12 + This option enables support for the MTX-1 power and status LED.
13 +
14 +
15 comment "LED Triggers"
16
17 config LEDS_TRIGGERS
18 diff -urN linux-2.6.19.2/drivers/leds/Makefile linux-2.6.19.2.new/drivers/leds/Makefile
19 --- linux-2.6.19.2/drivers/leds/Makefile 2007-01-10 20:10:37.000000000 +0100
20 +++ linux-2.6.19.2.new/drivers/leds/Makefile 2007-03-02 13:49:35.000000000 +0100
21 @@ -13,6 +13,7 @@
22 obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
23 obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
24 obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
25 +obj-$(CONFIG_LEDS_MTX1) += leds-mtx1.o
26
27 # LED Triggers
28 obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
29 diff -urN linux-2.6.19.2/drivers/leds/leds-mtx1.c linux-2.6.19.2.new/drivers/leds/leds-mtx1.c
30 --- linux-2.6.19.2/drivers/leds/leds-mtx1.c 1970-01-01 01:00:00.000000000 +0100
31 +++ linux-2.6.19.2.new/drivers/leds/leds-mtx1.c 2007-03-02 13:49:08.000000000 +0100
32 @@ -0,0 +1,116 @@
33 +/*
34 + * LED driver for MTX-1 boards
35 + *
36 + * Copyright 2007 Florian Fainelli <florian@openwrt.org>
37 + *
38 + * This program is free software; you can redistribute it and/or modify
39 + * it under the terms of the GNU General Public License version 2 as
40 + * published by the Free Software Foundation.
41 + *
42 + */
43 +
44 +#include <linux/kernel.h>
45 +#include <linux/init.h>
46 +#include <linux/platform_device.h>
47 +#include <linux/leds.h>
48 +#include <linux/err.h>
49 +#include <asm/mach-au1x00/au1000.h>
50 +
51 +static struct platform_device *pdev;
52 +
53 +static void mtx1_green_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
54 +{
55 + /* The power LED cannot be controlled the same way as for the Status LED */
56 + if (brightness) {
57 + au_writel( 0x18000800, GPIO2_OUTPUT );
58 + } else {
59 + au_writel( 0x18000000, GPIO2_OUTPUT);
60 + }
61 +}
62 +
63 +static void mtx1_red_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
64 +{
65 + /* We store GPIO address (originally address - 200) in the "flags" field*/
66 + unsigned long pinmask = 1 << led_cdev->flags;
67 + if (brightness) {
68 + au_writel((pinmask << 16) | pinmask, GPIO2_OUTPUT);
69 + } else {
70 + au_writel((pinmask << 16) | 0, GPIO2_OUTPUT);
71 + }
72 +}
73 +
74 +static struct led_classdev mtx1_green_led = {
75 + .name = "mtx1:green",
76 + .brightness_set = mtx1_green_led_set,
77 +};
78 +
79 +static struct led_classdev mtx1_red_led = {
80 + .name = "mtx1:red",
81 + .flags = 12,
82 + .brightness_set = mtx1_red_led_set,
83 + .default_trigger = "ide-disk",
84 +};
85 +
86 +static int mtx1_leds_probe(struct platform_device *pdev)
87 +{
88 + int ret;
89 +
90 + ret = led_classdev_register(&pdev->dev, &mtx1_green_led);
91 + if (ret < 0)
92 + goto out;
93 +
94 + ret = led_classdev_register(&pdev->dev, &mtx1_red_led);
95 + if (ret < 0)
96 + led_classdev_unregister(&mtx1_green_led);
97 +
98 +out:
99 + return ret;
100 +}
101 +
102 +static int mtx1_leds_remove(struct platform_device *pdev)
103 +{
104 + led_classdev_unregister(&mtx1_green_led);
105 + led_classdev_unregister(&mtx1_red_led);
106 + return 0;
107 +}
108 +
109 +static struct platform_driver mtx1_leds_driver = {
110 + .probe = mtx1_leds_probe,
111 + .remove = mtx1_leds_remove,
112 + .driver = {
113 + .name = "mtx1-leds",
114 + }
115 +};
116 +
117 +static int __init mtx1_leds_init(void)
118 +{
119 + int ret;
120 +
121 + ret = platform_driver_register(&mtx1_leds_driver);
122 + if (ret < 0)
123 + goto out;
124 +
125 + pdev = platform_device_register_simple("mtx1-leds", -1, NULL, 0);
126 + if (IS_ERR(pdev)) {
127 + ret = PTR_ERR(pdev);
128 + platform_driver_unregister(&mtx1_leds_driver);
129 + goto out;
130 + }
131 +
132 +out:
133 + return ret;
134 +
135 +}
136 +
137 +static void __exit mtx1_leds_exit(void)
138 +{
139 + platform_device_unregister(pdev);
140 + platform_driver_unregister(&mtx1_leds_driver);
141 +}
142 +
143 +module_init(mtx1_leds_init);
144 +module_exit(mtx1_leds_exit);
145 +
146 +MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
147 +MODULE_DESCRIPTION("MTX-1 LED driver");
148 +MODULE_LICENSE("GPL");
This page took 0.047534 seconds and 5 git commands to generate.