summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx-2.6.21/patches/a780-vibrator.patch
blob: 7436c40f5fb8b20a014b654f014488c5ec16d154 (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
Index: linux-2.6.21/drivers/leds/leds-a780.c
===================================================================
--- linux-2.6.21.orig/drivers/leds/leds-a780.c	2007-05-08 15:09:26.000000000 -0300
+++ linux-2.6.21/drivers/leds/leds-a780.c	2007-05-08 15:19:26.000000000 -0300
@@ -18,10 +18,13 @@
 #include <linux/leds.h>
 #include <asm/arch/ezx-pcap.h>
 
+extern void ezx_pcap_vibrator_level(u_int32_t);
+
 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 );
+#warning FIXME: use read/write operations
 	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);
@@ -33,6 +36,7 @@
 {
 	if ( value > 31 ) value = 31;
 	printk( KERN_DEBUG "a780led_aux_set: %d\n", value );
+#warning FIXME: use read/write operations
 	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);
@@ -40,6 +44,43 @@
 	ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_PERIPH_BL2_CTRL4, value & 0x10);
 }
 
+static void a780vibrator_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+	if ( value > 4 ) value = 4;
+	printk( KERN_DEBUG "a780vibrator_set: %d\n", value );
+
+	switch(value)
+	{
+		case 0:
+			/* turn off vibrator */
+			ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_AUX_VREG_V_VIB_EN, 0);
+			break;
+
+		case 1:
+			ezx_pcap_vibrator_level(PCAP_VIBRATOR_VOLTAGE_LEVEL0);
+			ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_AUX_VREG_V_VIB_EN, 1);
+			break;
+
+		case 2:
+			ezx_pcap_vibrator_level(PCAP_VIBRATOR_VOLTAGE_LEVEL1);
+			ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_AUX_VREG_V_VIB_EN, 1);
+			break;
+
+		case 3:
+			ezx_pcap_vibrator_level(PCAP_VIBRATOR_VOLTAGE_LEVEL2);
+			ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_AUX_VREG_V_VIB_EN, 1);
+			break;
+
+		case 4:
+			ezx_pcap_vibrator_level(PCAP_VIBRATOR_VOLTAGE_LEVEL3);
+			ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_AUX_VREG_V_VIB_EN, 1);
+			break;
+
+		default:
+			break;
+	}
+}
+
 static struct led_classdev a780_main_led = {
 	.name			= "a780:main",
 	.default_trigger	= "none",
@@ -52,11 +93,18 @@
 	.brightness_set		= a780led_aux_set,
 };
 
+static struct led_classdev a780_vibrator = {
+	.name			= "a780:vibrator",
+	.default_trigger	= "none",
+	.brightness_set		= a780vibrator_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);
+	led_classdev_suspend(&a780_vibrator);
 	return 0;
 }
 
@@ -64,6 +112,7 @@
 {
 	led_classdev_resume(&a780_main_led);
 	led_classdev_resume(&a780_aux_led);
+	led_classdev_resume(&a780_vibrator);
 	return 0;
 }
 #endif
@@ -77,8 +126,16 @@
 		return ret;
 
 	ret = led_classdev_register(&pdev->dev, &a780_aux_led);
-	if (ret < 0)
+	if (ret < 0) {
+		led_classdev_unregister(&a780_main_led);
+		return ret;
+	}
+
+	ret = led_classdev_register(&pdev->dev, &a780_vibrator);
+	if (ret < 0) {
 		led_classdev_unregister(&a780_main_led);
+		led_classdev_unregister(&a780_aux_led);
+	}
 
 	return ret;
 }
@@ -87,6 +144,7 @@
 {
 	led_classdev_unregister(&a780_main_led);
 	led_classdev_unregister(&a780_aux_led);
+	led_classdev_unregister(&a780_vibrator);
 	return 0;
 }
 
@@ -111,6 +169,8 @@
 {
 	a780led_main_set( &a780_main_led, 0 );
 	a780led_aux_set( &a780_aux_led, 0 );
+	a780vibrator_set( &a780_vibrator, 0 );
+
 	platform_driver_unregister(&a780led_driver);
 }
 
Index: linux-2.6.21/drivers/leds/Kconfig
===================================================================
--- linux-2.6.21.orig/drivers/leds/Kconfig	2007-05-08 15:09:26.000000000 -0300
+++ linux-2.6.21/drivers/leds/Kconfig	2007-05-08 15:09:26.000000000 -0300
@@ -105,11 +105,11 @@
 	  be configured via sysfs. If unsure, say Y.
 
 config LEDS_A780
-	tristate "LED Support for the Motorola A780 GSM Phone"
+	tristate "LED/Vibrator 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.
+	  This option enables support for the LEDs and the
+	  vibrator on the Motorola A780 GSM Phone.
 
 config LEDS_E680
 	tristate "LED Support for the Motorola E680(i) GSM Phone"