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 2000-2002 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_GRBEEP_H 28 #define _SYS_GRBEEP_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * grbeep.h : Grover beep driver header file. 38 */ 39 40 /* 41 * beeper start and stop values 42 */ 43 #define GRBEEP_START 0x03 44 #define GRBEEP_STOP 0x00 45 46 /* 47 * beeper control register value 48 */ 49 #define GRBEEP_CONTROL 0xb6 50 51 /* 52 * beeper 8354 input frequency is 1.193 Mhz. 53 * The value to be written in the timer 54 * register is the frequency divisor. 55 * The formula to find freq. divisoer would be 56 * 57 * divisor = GRBEEP_INPUT_FREQ / freq 58 * 59 */ 60 #define GRBEEP_INPUT_FREQ 1193000 61 #define GRBEEP_DIVISOR_MAX 1193000 62 #define GRBEEP_DIVISOR_MIN 18 63 64 /* Mode values */ 65 #define GRBEEP_ON 0x01 66 #define GRBEEP_OFF 0x00 67 68 typedef volatile struct grbeep_freq_regs { 69 70 /* Frequency divisor register */ 71 uint8_t grbeep_freq_regs_divisor; 72 73 /* Freqquency control register */ 74 uint8_t grbeep_freq_regs_control; 75 76 } grbeep_freq_regs_t; 77 78 79 /* 80 * Beep driver state structure 81 */ 82 typedef struct grbeep_state { 83 84 /* Dip of grbeep device */ 85 dev_info_t *grbeep_dip; 86 87 /* Frequency control and frequency divisor registers */ 88 grbeep_freq_regs_t *grbeep_freq_regs; 89 90 /* Frequency control and frequency divisor reg handle */ 91 ddi_acc_handle_t grbeep_freq_regs_handle; 92 93 /* Beep start/stop register */ 94 uint8_t *grbeep_start_stop_reg; 95 96 /* Beep start/stop register handle */ 97 ddi_acc_handle_t grbeep_start_stop_reg_handle; 98 99 /* If beeper is active or not */ 100 int grbeep_mode; 101 102 /* Mutex for fields that are mutually exclusively accessible */ 103 kmutex_t grbeep_mutex; 104 105 } grbeep_state_t; 106 107 #define GRBEEP_WRITE_FREQ_CONTROL_REG(val) \ 108 ddi_put8(grbeeptr->grbeep_freq_regs_handle, \ 109 ((uint8_t *)&grbeeptr->grbeep_freq_regs->grbeep_freq_regs_control), \ 110 ((int8_t)(val))) 111 112 #define GRBEEP_WRITE_FREQ_DIVISOR_REG(val) \ 113 ddi_put8(grbeeptr->grbeep_freq_regs_handle, \ 114 ((uint8_t *)&grbeeptr->grbeep_freq_regs->grbeep_freq_regs_divisor), \ 115 ((int8_t)(val))) 116 117 #define GRBEEP_WRITE_START_STOP_REG(val) \ 118 ddi_put8(grbeeptr->grbeep_start_stop_reg_handle, \ 119 ((uint8_t *)grbeeptr->grbeep_start_stop_reg), \ 120 ((int8_t)(val))) 121 122 #define GRBEEP_UNIT(dev) (getminor((dev))) 123 124 #ifdef __cplusplus 125 } 126 #endif 127 128 #endif /* _SYS_GRBEEP_H */ 129