7 #include <linux/kernel.h>
8 #include <linux/module.h>
10 #include <linux/input.h>
12 #include <linux/slab.h>
49 if (count <= clock_freq >> 20)
52 if (count >= clock_freq >> 12)
56 for (i = 19; i >= 11; i--) {
58 if (count <= clock_freq >> i)
65 static int bbc_spkr_event(
struct input_dev *
dev,
unsigned int type,
unsigned int code,
int value)
69 unsigned int count = 0;
76 case SND_BELL:
if (value) value = 1000;
81 if (value > 20 && value < 32767)
82 count = 1193182 /
value;
84 count = bbc_count_to_reg(info, count);
91 outb((count >> 16) & 0xff, info->
regs + 3);
92 outb((count >> 8) & 0xff, info->
regs + 4);
98 spin_unlock_irqrestore(&state->
lock, flags);
103 static int grover_spkr_event(
struct input_dev *dev,
unsigned int type,
unsigned int code,
int value)
107 unsigned int count = 0;
114 case SND_BELL:
if (value) value = 1000;
119 if (value > 20 && value < 32767)
120 count = 1193182 /
value;
137 spin_unlock_irqrestore(&state->
lock, flags);
145 struct input_dev *input_dev;
148 input_dev = input_allocate_device();
152 input_dev->name = state->
name;
153 input_dev->phys =
"sparc/input0";
154 input_dev->id.bustype =
BUS_ISA;
155 input_dev->id.vendor = 0x001f;
156 input_dev->id.product = 0x0001;
157 input_dev->id.version = 0x0100;
158 input_dev->dev.parent =
dev;
163 input_dev->event = state->
event;
165 error = input_register_device(input_dev);
167 input_free_device(input_dev);
179 struct input_dev *input_dev = state->
input_dev;
196 state->
name =
"Sparc BBC Speaker";
197 state->
event = bbc_spkr_event;
205 info = &state->
u.
bbc;
216 err = sparcspkr_probe(&op->
dev);
218 goto out_clear_drvdata;
235 struct input_dev *input_dev = state->
input_dev;
241 input_unregister_device(input_dev);
254 .compatible =
"SUNW,bbc-beep",
263 .of_match_table = bbc_beep_match,
265 .probe = bbc_beep_probe,
267 .shutdown = sparcspkr_shutdown,
280 state->
name =
"Sparc Grover Speaker";
281 state->
event = grover_spkr_event;
291 goto out_unmap_freq_regs;
295 err = sparcspkr_probe(&op->
dev);
297 goto out_clear_drvdata;
317 struct input_dev *input_dev = state->
input_dev;
322 input_unregister_device(input_dev);
333 static const struct of_device_id grover_beep_match[] = {
336 .compatible =
"SUNW,smbus-beep",
343 .name =
"groverbeep",
345 .of_match_table = grover_beep_match,
347 .probe = grover_beep_probe,
349 .shutdown = sparcspkr_shutdown,
352 static int __init sparcspkr_init(
void)
365 static void __exit sparcspkr_exit(
void)