summaryrefslogtreecommitdiff
path: root/packages/linux/nslu2-kernel/2.6.14/50-nslu2-beeper.patch
blob: cf2de14c686d296e1f6a69a663640ea14a40800c (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
diff -urN linux-2.6.14-rc2/drivers/input/misc/Kconfig test6/drivers/input/misc/Kconfig
--- linux-2.6.14-rc2/drivers/input/misc/Kconfig	2005-09-17 12:42:09.000000000 +0200
+++ test6/drivers/input/misc/Kconfig	2005-09-28 19:24:52.000000000 +0200
@@ -40,6 +40,18 @@
 	tristate "M68k Beeper support"
 	depends on M68K
 
+config INPUT_NSLU2_BEEPER
+	tristate "NSLU2 Beeper support"
+	depends on MACH_NSLU2
+	help
+	  Say Y here if you want the embedded beeper on the LinkSys NSLU2
+	  to be used for bells and whistles.
+
+	  If unsure, say Y.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called nslu2spkr.
+
 config INPUT_UINPUT
 	tristate "User level driver support"
 	help
diff -urN linux-2.6.14-rc2/drivers/input/misc/Makefile test6/drivers/input/misc/Makefile
--- linux-2.6.14-rc2/drivers/input/misc/Makefile	2005-09-17 12:42:09.000000000 +0200
+++ test6/drivers/input/misc/Makefile	2005-09-28 17:01:19.000000000 +0200
@@ -10,3 +10,4 @@
 obj-$(CONFIG_INPUT_98SPKR)		+= 98spkr.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
+obj-$(CONFIG_INPUT_NSLU2_BEEPER)	+= nslu2spkr.o
diff -urN linux-2.6.14-rc2/drivers/input/misc/nslu2spkr.c test6/drivers/input/misc/nslu2spkr.c
--- linux-2.6.14-rc2/drivers/input/misc/nslu2spkr.c	1970-01-01 01:00:00.000000000 +0100
+++ test6/drivers/input/misc/nslu2spkr.c	2005-09-28 19:23:34.000000000 +0200
@@ -0,0 +1,110 @@
+/*
+ * drivers/input/misc/nslu2spkr.c
+ *
+ * NSLU2 Beeper driver
+ *
+ * Copyright (C) 2005 Tower Technologies
+ *
+ * based on nslu2-io.c  
+ *  Copyright (C) 2004 Karen Spearel
+ *
+ * Author: Alessandro Zummo <a.zummo@towertech.it>
+ * Maintainers: http://www.nslu2-linux.org/
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+
+#include <asm/arch/nslu2.h>
+#include <asm-arm/delay.h>
+
+DEFINE_SPINLOCK(beep_lock);
+
+static int nslu2_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
+{
+	unsigned int count = 0;
+	unsigned long flags;
+
+	if (type != EV_SND)
+		return -1;
+
+	switch (code) {
+		case SND_BELL:
+			if (value) value = 5000;
+		case SND_TONE:
+			break;
+		default:
+			return -1;
+	}
+
+	if (value > 20 && value < 32767)
+		count = 1193182 / value;
+
+	spin_lock_irqsave(&beep_lock, flags);
+
+	*IXP4XX_GPIO_GPOER &= ~NSLU2_BZ_BM;
+
+	while (count) {
+		*IXP4XX_GPIO_GPOUTR &= ~NSLU2_BZ_BM;
+		udelay(500);
+
+		*IXP4XX_GPIO_GPOUTR |= NSLU2_BZ_BM;
+		udelay(500);
+
+		count--;
+	}
+
+	*IXP4XX_GPIO_GPOER |= NSLU2_BZ_BM;
+
+	spin_unlock_irqrestore(&beep_lock, flags);
+
+	return 0;
+}
+
+static struct input_dev nslu2_spkr_dev = {
+	.phys		= "nslu2/gpio4",
+	.name		= "NSLU2 Beeper",
+	.evbit[0]	= BIT(EV_SND),
+	.sndbit[0]	= BIT(SND_BELL),
+	.event		= nslu2_spkr_event,
+	.id		= {
+		.bustype	= BUS_HOST,
+		.vendor		= 0x001f,
+		.product	= 0x0001,
+		.version	= 0x0100
+	}
+};
+
+
+static int __init nslu2_spkr_init(void)
+{
+	input_register_device(&nslu2_spkr_dev);
+
+	nslu2_spkr_event(NULL, EV_SND, SND_BELL, 1);
+
+        printk(KERN_INFO "input: %s\n",  nslu2_spkr_dev.name);
+	return 0;
+}
+
+static void __exit nslu2_spkr_exit(void)
+{
+	input_unregister_device(&nslu2_spkr_dev);
+
+	/* turn it off */
+	nslu2_spkr_event(NULL, EV_SND, SND_BELL, 0);
+}
+
+module_init(nslu2_spkr_init);
+module_exit(nslu2_spkr_exit);
+
+MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
+MODULE_DESCRIPTION("NSLU2 Beeper driver");
+MODULE_LICENSE("GPL");