xref: /illumos-gate/usr/src/uts/sun4u/sys/grbeep.h (revision c35aa225)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*c35aa225Smarx  * Common Development and Distribution License (the "License").
6*c35aa225Smarx  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*c35aa225Smarx  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_GRBEEP_H
277c478bd9Sstevel@tonic-gate #define	_SYS_GRBEEP_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef __cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * grbeep.h : Grover beep driver header file.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * beeper start and stop values
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate #define	GRBEEP_START		0x03
437c478bd9Sstevel@tonic-gate #define	GRBEEP_STOP		0x00
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * beeper control register value
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate #define	GRBEEP_CONTROL		0xb6
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * beeper 8354 input frequency is 1.193 Mhz.
527c478bd9Sstevel@tonic-gate  * The value to be written in the timer
537c478bd9Sstevel@tonic-gate  * register is the frequency divisor.
547c478bd9Sstevel@tonic-gate  * The formula to find freq. divisoer would be
557c478bd9Sstevel@tonic-gate  *
567c478bd9Sstevel@tonic-gate  * 	divisor = GRBEEP_INPUT_FREQ / freq
577c478bd9Sstevel@tonic-gate  *
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate #define	GRBEEP_INPUT_FREQ	1193000
607c478bd9Sstevel@tonic-gate #define	GRBEEP_DIVISOR_MAX	1193000
617c478bd9Sstevel@tonic-gate #define	GRBEEP_DIVISOR_MIN	18
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /* Mode values */
647c478bd9Sstevel@tonic-gate #define	GRBEEP_ON		0x01
657c478bd9Sstevel@tonic-gate #define	GRBEEP_OFF		0x00
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate typedef volatile struct grbeep_freq_regs {
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate 	/* Frequency divisor register */
707c478bd9Sstevel@tonic-gate 	uint8_t		grbeep_freq_regs_divisor;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate 	/* Freqquency control register */
737c478bd9Sstevel@tonic-gate 	uint8_t		grbeep_freq_regs_control;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate } grbeep_freq_regs_t;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * Beep driver state structure
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate typedef struct grbeep_state {
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	/* Dip of grbeep device */
847c478bd9Sstevel@tonic-gate 	dev_info_t		*grbeep_dip;
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 	/* Frequency control and frequency divisor registers */
877c478bd9Sstevel@tonic-gate 	grbeep_freq_regs_t	*grbeep_freq_regs;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 	/* Frequency control and frequency divisor reg handle */
907c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	grbeep_freq_regs_handle;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	/* Beep start/stop register */
937c478bd9Sstevel@tonic-gate 	uint8_t			*grbeep_start_stop_reg;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	/* Beep start/stop register handle */
967c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	grbeep_start_stop_reg_handle;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 	/* If beeper is active or not */
997c478bd9Sstevel@tonic-gate 	int			grbeep_mode;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate } grbeep_state_t;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #define	GRBEEP_WRITE_FREQ_CONTROL_REG(val) \
1047c478bd9Sstevel@tonic-gate 	ddi_put8(grbeeptr->grbeep_freq_regs_handle, \
1057c478bd9Sstevel@tonic-gate 	((uint8_t *)&grbeeptr->grbeep_freq_regs->grbeep_freq_regs_control), \
1067c478bd9Sstevel@tonic-gate 		((int8_t)(val)))
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate #define	GRBEEP_WRITE_FREQ_DIVISOR_REG(val) \
1097c478bd9Sstevel@tonic-gate 	ddi_put8(grbeeptr->grbeep_freq_regs_handle, \
1107c478bd9Sstevel@tonic-gate 	((uint8_t *)&grbeeptr->grbeep_freq_regs->grbeep_freq_regs_divisor), \
1117c478bd9Sstevel@tonic-gate 		((int8_t)(val)))
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #define	GRBEEP_WRITE_START_STOP_REG(val) \
1147c478bd9Sstevel@tonic-gate 	ddi_put8(grbeeptr->grbeep_start_stop_reg_handle, \
1157c478bd9Sstevel@tonic-gate 		((uint8_t *)grbeeptr->grbeep_start_stop_reg), \
1167c478bd9Sstevel@tonic-gate 		((int8_t)(val)))
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #define	GRBEEP_UNIT(dev)	(getminor((dev)))
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate #endif
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #endif /* _SYS_GRBEEP_H */
125