2 * m68k beeper driver for Linux
4 * Copyright (c) 2002 Richard Zidlicky
5 * Copyright (c) 2002 Vojtech Pavlik
6 * Copyright (c) 1992 Orest Zborowski
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published by
13 * the Free Software Foundation
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/input.h>
20 #include <linux/platform_device.h>
21 #include <asm/machdep.h>
24 MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>");
25 MODULE_DESCRIPTION("m68k beeper driver");
26 MODULE_LICENSE("GPL");
28 static struct platform_device
*m68kspkr_platform_device
;
30 static int m68kspkr_event(struct input_dev
*dev
, unsigned int type
, unsigned int code
, int value
)
32 unsigned int count
= 0;
38 case SND_BELL
: if (value
) value
= 1000;
43 if (value
> 20 && value
< 32767)
44 count
= 1193182 / value
;
51 static int m68kspkr_probe(struct platform_device
*dev
)
53 struct input_dev
*input_dev
;
56 input_dev
= input_allocate_device();
60 input_dev
->name
= "m68k beeper";
61 input_dev
->phys
= "m68k/generic";
62 input_dev
->id
.bustype
= BUS_HOST
;
63 input_dev
->id
.vendor
= 0x001f;
64 input_dev
->id
.product
= 0x0001;
65 input_dev
->id
.version
= 0x0100;
66 input_dev
->dev
.parent
= &dev
->dev
;
68 input_dev
->evbit
[0] = BIT_MASK(EV_SND
);
69 input_dev
->sndbit
[0] = BIT_MASK(SND_BELL
) | BIT_MASK(SND_TONE
);
70 input_dev
->event
= m68kspkr_event
;
72 err
= input_register_device(input_dev
);
74 input_free_device(input_dev
);
78 platform_set_drvdata(dev
, input_dev
);
83 static int m68kspkr_remove(struct platform_device
*dev
)
85 struct input_dev
*input_dev
= platform_get_drvdata(dev
);
87 input_unregister_device(input_dev
);
88 /* turn off the speaker */
89 m68kspkr_event(NULL
, EV_SND
, SND_BELL
, 0);
94 static void m68kspkr_shutdown(struct platform_device
*dev
)
96 /* turn off the speaker */
97 m68kspkr_event(NULL
, EV_SND
, SND_BELL
, 0);
100 static struct platform_driver m68kspkr_platform_driver
= {
103 .owner
= THIS_MODULE
,
105 .probe
= m68kspkr_probe
,
106 .remove
= m68kspkr_remove
,
107 .shutdown
= m68kspkr_shutdown
,
110 static int __init
m68kspkr_init(void)
115 printk(KERN_INFO
"m68kspkr: no lowlevel beep support\n");
119 err
= platform_driver_register(&m68kspkr_platform_driver
);
123 m68kspkr_platform_device
= platform_device_alloc("m68kspkr", -1);
124 if (!m68kspkr_platform_device
) {
126 goto err_unregister_driver
;
129 err
= platform_device_add(m68kspkr_platform_device
);
131 goto err_free_device
;
136 platform_device_put(m68kspkr_platform_device
);
137 err_unregister_driver
:
138 platform_driver_unregister(&m68kspkr_platform_driver
);
143 static void __exit
m68kspkr_exit(void)
145 platform_device_unregister(m68kspkr_platform_device
);
146 platform_driver_unregister(&m68kspkr_platform_driver
);
149 module_init(m68kspkr_init
);
150 module_exit(m68kspkr_exit
);