xref: /titanic_44/usr/src/uts/sun4u/sys/grbeep.h (revision 67e3a03ed4a2813074d36330f062ed6e593a4937)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_GRBEEP_H
27 #define	_SYS_GRBEEP_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * grbeep.h : Grover beep driver header file.
37  */
38 
39 /*
40  * beeper start and stop values
41  */
42 #define	GRBEEP_START		0x03
43 #define	GRBEEP_STOP		0x00
44 
45 /*
46  * beeper control register value
47  */
48 #define	GRBEEP_CONTROL		0xb6
49 
50 /*
51  * beeper 8354 input frequency is 1.193 Mhz.
52  * The value to be written in the timer
53  * register is the frequency divisor.
54  * The formula to find freq. divisoer would be
55  *
56  * 	divisor = GRBEEP_INPUT_FREQ / freq
57  *
58  */
59 #define	GRBEEP_INPUT_FREQ	1193000
60 #define	GRBEEP_DIVISOR_MAX	1193000
61 #define	GRBEEP_DIVISOR_MIN	18
62 
63 /* Mode values */
64 #define	GRBEEP_ON		0x01
65 #define	GRBEEP_OFF		0x00
66 
67 typedef volatile struct grbeep_freq_regs {
68 
69 	/* Frequency divisor register */
70 	uint8_t		grbeep_freq_regs_divisor;
71 
72 	/* Freqquency control register */
73 	uint8_t		grbeep_freq_regs_control;
74 
75 } grbeep_freq_regs_t;
76 
77 
78 /*
79  * Beep driver state structure
80  */
81 typedef struct grbeep_state {
82 
83 	/* Dip of grbeep device */
84 	dev_info_t		*grbeep_dip;
85 
86 	/* Frequency control and frequency divisor registers */
87 	grbeep_freq_regs_t	*grbeep_freq_regs;
88 
89 	/* Frequency control and frequency divisor reg handle */
90 	ddi_acc_handle_t	grbeep_freq_regs_handle;
91 
92 	/* Beep start/stop register */
93 	uint8_t			*grbeep_start_stop_reg;
94 
95 	/* Beep start/stop register handle */
96 	ddi_acc_handle_t	grbeep_start_stop_reg_handle;
97 
98 	/* If beeper is active or not */
99 	int			grbeep_mode;
100 
101 } grbeep_state_t;
102 
103 #define	GRBEEP_WRITE_FREQ_CONTROL_REG(val) \
104 	ddi_put8(grbeeptr->grbeep_freq_regs_handle, \
105 	((uint8_t *)&grbeeptr->grbeep_freq_regs->grbeep_freq_regs_control), \
106 		((int8_t)(val)))
107 
108 #define	GRBEEP_WRITE_FREQ_DIVISOR_REG(val) \
109 	ddi_put8(grbeeptr->grbeep_freq_regs_handle, \
110 	((uint8_t *)&grbeeptr->grbeep_freq_regs->grbeep_freq_regs_divisor), \
111 		((int8_t)(val)))
112 
113 #define	GRBEEP_WRITE_START_STOP_REG(val) \
114 	ddi_put8(grbeeptr->grbeep_start_stop_reg_handle, \
115 		((uint8_t *)grbeeptr->grbeep_start_stop_reg), \
116 		((int8_t)(val)))
117 
118 #define	GRBEEP_UNIT(dev)	(getminor((dev)))
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* _SYS_GRBEEP_H */
125