summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx/a780-leds-r0.patch
blob: 31fdfc635bba948f51bb48584041778e65adafbb (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
182
183
184
185

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

--- linux-2.6.16/drivers/leds/Kconfig~a780-leds-r0.patch	2006-06-05 18:05:32.000000000 +0200
+++ linux-2.6.16/drivers/leds/Kconfig	2006-06-05 18:05:32.000000000 +0200
@@ -66,6 +66,13 @@
 	  This options enables support for the LEDs on the
 	  Motorola E680(i) GSM Phone.
 
+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 LEDS_TRIGGERS
--- linux-2.6.16/drivers/leds/Makefile~a780-leds-r0.patch	2006-06-05 18:05:32.000000000 +0200
+++ linux-2.6.16/drivers/leds/Makefile	2006-06-05 18:05:32.000000000 +0200
@@ -11,6 +11,7 @@
 obj-$(CONFIG_LEDS_IXP4XX)		+= leds-ixp4xx-gpio.o
 obj-$(CONFIG_LEDS_TOSA)			+= leds-tosa.o
 obj-$(CONFIG_LEDS_E680)		+= leds-e680.o
+obj-$(CONFIG_LEDS_A780)		+= leds-a780.o
 
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)	+= ledtrig-timer.o
--- linux-2.6.16/arch/arm/mach-pxa/ezx.c~a780-leds-r0.patch	2006-06-05 18:05:32.000000000 +0200
+++ linux-2.6.16/arch/arm/mach-pxa/ezx.c	2006-06-05 18:05:32.000000000 +0200
@@ -367,6 +367,15 @@
 };
 #endif
 
+#ifdef CONFIG_PXA_EZX_A780
+/*
+ * A780 LEDs
+ */
+static struct platform_device a780led_device = {
+	.name		= "a780-led",
+	.id		= -1,
+};
+#endif
 
 /* keyboard */
 
@@ -780,6 +789,9 @@
 #ifdef CONFIG_PXA_EZX_E680
 	&e680led_device,
 #endif
+#ifdef CONFIG_PXA_EZX_A780
+	&a780led_device,
+#endif
 };
 
 static void __init
--- /dev/null	2006-06-05 13:59:28.329930680 +0200
+++ linux-2.6.16/drivers/leds/leds-a780.c	2006-06-05 18:27:13.000000000 +0200
@@ -0,0 +1,123 @@
+/*
+ * 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/config.h>
+#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");