xref: /illumos-gate/usr/src/uts/sun4/sys/bbc_beep.h (revision 598f4ceed9327d2d6c2325dd67cae3aa06f7fea6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_BBC_BEEP_H
28 #define	_SYS_BBC_BEEP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * bbc_beep.h : BBC beep driver's header file.
38  */
39 
40 /* Keyboard Beep Control Register values */
41 #define	BBC_BEEP_ON		0x01
42 #define	BBC_BEEP_OFF		0x00
43 
44 /*
45  * Keyboard Beep Counter Register value :
46  * The most significant of [18..10] selects the bit of
47  * the BBC free running counter (updated on half the system
48  * clock) that is used to generate the audio signal. So, bit[10]
49  * generates a signal at 1/(2^12) the system frequency, and
50  * bit[18], at 1/(2^20). So if s = system frequency(in MHz),
51  * it can generate frequencies in the range (s >> 10) Hz to
52  * (s >> 2) Hz.
53  */
54 #define	BBC_BEEP_MIN_SHIFT	20
55 #define	BBC_BEEP_MAX_SHIFT	12
56 #define	BBC_BEEP_MSBIT		18
57 
58 typedef volatile struct bbc_beep_regs {
59 
60 	/* Beep ON/OFF register */
61 	uint8_t		bbc_beep_control;
62 
63 	/* Reserved */
64 	uint8_t		reserved;
65 
66 	/* Register to set the frequency */
67 	uint8_t		bbc_beep_counter[4];
68 
69 } bbc_beep_regs_t;
70 
71 /*
72  * Beep driver state structure
73  */
74 typedef struct bbc_beep_state {
75 
76 	/* Dip of bbc_beep device */
77 	dev_info_t		*bbc_beep_dip;
78 
79 	/* Beep registers */
80 	bbc_beep_regs_t		*bbc_beep_regsp;
81 
82 	/* Register handle */
83 	ddi_acc_handle_t	bbc_beep_regs_handle;
84 
85 	/* If beeper is active or not */
86 	int			bbc_beep_mode;
87 
88 	} bbc_beep_state_t;
89 
90 #define	BEEP_WRITE_CTRL_REG(val) ddi_put8(bbc_beeptr->bbc_beep_regs_handle, \
91 		((uint8_t *)&bbc_beeptr->bbc_beep_regsp->bbc_beep_control), \
92 					((int8_t)(val)))
93 #define	BEEP_WRITE_COUNTER_REG(no, val) \
94 		ddi_put8(bbc_beeptr->bbc_beep_regs_handle, \
95 	((uint8_t *)&bbc_beeptr->bbc_beep_regsp->bbc_beep_counter[no]), \
96 					((int8_t)(val)))
97 
98 #define	BEEP_UNIT(dev)	(getminor((dev)))
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* _SYS_BBC_BEEP_H */
105