2 * LED driver for MTX-1 boards
4 * Copyright 2007 Florian Fainelli <florian@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/leds.h>
16 #include <linux/err.h>
17 #include <asm/mach-au1x00/au1000.h>
19 static struct platform_device
*pdev
;
21 static void mtx1_green_led_set(struct led_classdev
*led_cdev
, enum led_brightness brightness
)
23 /* The power LED cannot be controlled the same way as for the Status LED */
25 au_writel( 0x18000800, GPIO2_OUTPUT
);
27 au_writel( 0x18000000, GPIO2_OUTPUT
);
31 static void mtx1_red_led_set(struct led_classdev
*led_cdev
, enum led_brightness brightness
)
33 /* We store GPIO address (originally address - 200) in the "flags" field*/
34 unsigned long pinmask
= 1 << led_cdev
->flags
;
36 au_writel((pinmask
<< 16) | pinmask
, GPIO2_OUTPUT
);
38 au_writel((pinmask
<< 16) | 0, GPIO2_OUTPUT
);
42 static struct led_classdev mtx1_green_led
= {
44 .brightness_set
= mtx1_green_led_set
,
47 static struct led_classdev mtx1_red_led
= {
50 .brightness_set
= mtx1_red_led_set
,
51 .default_trigger
= "ide-disk",
54 static int mtx1_leds_probe(struct platform_device
*pdev
)
58 ret
= led_classdev_register(&pdev
->dev
, &mtx1_green_led
);
62 ret
= led_classdev_register(&pdev
->dev
, &mtx1_red_led
);
64 led_classdev_unregister(&mtx1_green_led
);
70 static int mtx1_leds_remove(struct platform_device
*pdev
)
72 led_classdev_unregister(&mtx1_green_led
);
73 led_classdev_unregister(&mtx1_red_led
);
77 static struct platform_driver mtx1_leds_driver
= {
78 .probe
= mtx1_leds_probe
,
79 .remove
= mtx1_leds_remove
,
85 static int __init
mtx1_leds_init(void)
89 ret
= platform_driver_register(&mtx1_leds_driver
);
93 pdev
= platform_device_register_simple("mtx1-leds", -1, NULL
, 0);
96 platform_driver_unregister(&mtx1_leds_driver
);
105 static void __exit
mtx1_leds_exit(void)
107 platform_device_unregister(pdev
);
108 platform_driver_unregister(&mtx1_leds_driver
);
111 module_init(mtx1_leds_init
);
112 module_exit(mtx1_leds_exit
);
114 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
115 MODULE_DESCRIPTION("MTX-1 LED driver");
116 MODULE_LICENSE("GPL");