summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx-2.6.21/a780-leds.patch
blob: 09913df2ca1e21303dfb8d6bbdb51537c47c00e4 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181

#
# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
#

Index: linux-2.6.21/drivers/leds/Kconfig
===================================================================
--- linux-2.6.21.orig/drivers/leds/Kconfig	2007-05-08 04:09:08.000000000 -0300
+++ linux-2.6.21/drivers/leds/Kconfig	2007-05-08 14:09:03.000000000 -0300
@@ -104,6 +104,13 @@
 	  These triggers allow kernel events to drive the LEDs and can
 	  be configured via sysfs. If unsure, say Y.
 
+config LEDS_A780
+	tristate "LED Support for the Motorola A780 GSM Phone"
+	depends LEDS_CLASS && PXA_EZX_A780
+	help
+	  This option enables support for the LEDs on the
+	  Motorola A780 GSM Phone.
+
 config LEDS_TRIGGER_TIMER
 	tristate "LED Timer Trigger"
 	depends on LEDS_TRIGGERS
Index: linux-2.6.21/drivers/leds/Makefile
===================================================================
--- linux-2.6.21.orig/drivers/leds/Makefile	2007-05-08 04:09:08.000000000 -0300
+++ linux-2.6.21/drivers/leds/Makefile	2007-05-08 14:09:03.000000000 -0300
@@ -16,6 +16,7 @@
 obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
 obj-$(CONFIG_LEDS_H1940)		+= leds-h1940.o
 obj-$(CONFIG_LEDS_COBALT)		+= leds-cobalt.o
+obj-$(CONFIG_LEDS_A780)		+= leds-a780.o
 
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)	+= ledtrig-timer.o
Index: linux-2.6.21/drivers/leds/leds-a780.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.21/drivers/leds/leds-a780.c	2007-05-08 14:09:03.000000000 -0300
@@ -0,0 +1,122 @@
+/*
+ * EZX Platform LED Driver for the Motorola A780 GSM Phone
+ *
+ * Copyright 2006 Vanille-Media
+ *
+ * Author: Michael Lauer <mickey@Vanille.de>
+ *
+ * Based on keylight.c by Motorola and leds-corgi.c by Richard Purdie
+ *
+ * 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/platform_device.h>
+#include <linux/leds.h>
+#include <asm/arch/ezx-pcap.h>
+
+static void a780led_main_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+	if ( value > 31 ) value = 31;
+	printk( KERN_DEBUG "a780led_main_set: %d\n", value );
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL_CTRL0, value & 0x01);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL_CTRL1, value & 0x02);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL_CTRL2, value & 0x04);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL_CTRL3, value & 0x08);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL_CTRL4, value & 0x10);
+}
+
+static void a780led_aux_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+	if ( value > 31 ) value = 31;
+	printk( KERN_DEBUG "a780led_aux_set: %d\n", value );
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL2_CTRL0, value & 0x01);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL2_CTRL1, value & 0x02);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL2_CTRL2, value & 0x04);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL2_CTRL3, value & 0x08);
+	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL2_CTRL4, value & 0x10);
+}
+
+static struct led_classdev a780_main_led = {
+	.name			= "a780:main",
+	.default_trigger	= "none",
+	.brightness_set		= a780led_main_set,
+};
+
+static struct led_classdev a780_aux_led = {
+	.name			= "a780:aux",
+	.default_trigger	= "none",
+	.brightness_set		= a780led_aux_set,
+};
+
+#ifdef CONFIG_PM
+static int a780led_suspend(struct platform_device *dev, pm_message_t state)
+{
+	led_classdev_suspend(&a780_main_led);
+	led_classdev_suspend(&a780_aux_led);
+	return 0;
+}
+
+static int a780led_resume(struct platform_device *dev)
+{
+	led_classdev_resume(&a780_main_led);
+	led_classdev_resume(&a780_aux_led);
+	return 0;
+}
+#endif
+
+static int a780led_probe(struct platform_device *pdev)
+{
+	int ret;
+
+	ret = led_classdev_register(&pdev->dev, &a780_main_led);
+	if (ret < 0)
+		return ret;
+
+	ret = led_classdev_register(&pdev->dev, &a780_aux_led);
+	if (ret < 0)
+		led_classdev_unregister(&a780_main_led);
+
+	return ret;
+}
+
+static int a780led_remove(struct platform_device *pdev)
+{
+	led_classdev_unregister(&a780_main_led);
+	led_classdev_unregister(&a780_aux_led);
+	return 0;
+}
+
+static struct platform_driver a780led_driver = {
+	.probe		= a780led_probe,
+	.remove		= a780led_remove,
+#ifdef CONFIG_PM
+	.suspend	= a780led_suspend,
+	.resume		= a780led_resume,
+#endif
+	.driver		= {
+		.name		= "a780-led",
+	},
+};
+
+static int __init a780led_init(void)
+{
+	return platform_driver_register(&a780led_driver);
+}
+
+static void __exit a780led_exit(void)
+{
+	a780led_main_set( &a780_main_led, 0 );
+	a780led_aux_set( &a780_aux_led, 0 );
+	platform_driver_unregister(&a780led_driver);
+}
+
+module_init(a780led_init);
+module_exit(a780led_exit);
+
+MODULE_AUTHOR("Michael Lauer <mickey@Vanille.de>");
+MODULE_DESCRIPTION("Motorola A780 LED driver");
+MODULE_LICENSE("GPL");
Index: linux-2.6.21/arch/arm/mach-pxa/ezx-a780.c
===================================================================
--- linux-2.6.21.orig/arch/arm/mach-pxa/ezx-a780.c	2007-05-08 14:09:13.000000000 -0300
+++ linux-2.6.21/arch/arm/mach-pxa/ezx-a780.c	2007-05-08 14:11:37.000000000 -0300
@@ -215,9 +215,14 @@
        },
 };
 
+static struct platform_device a780led_device = {
+	.name		= "a780-led",
+	.id		= -1,
+};
 
 static struct platform_device *devices[] __initdata = {
 	&a780flip_device,
+	&a780led_device,
 };
 
 static void __init a780_init(void)