xref: /illumos-gate/usr/src/uts/sun4u/excalibur/sys/xcalppm_var.h (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Platform Power Management
29  */
30 
31 #ifndef	_SYS_XCALPPM_VAR_H
32 #define	_SYS_XCALPPM_VAR_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * External function declarations
42  */
43 extern int	ppm_init(struct modlinkage *, size_t, char *);
44 extern int	ppm_open(dev_t *, int, int, cred_t *);
45 extern int	ppm_close(dev_t, int, int, cred_t *);
46 extern int	ppm_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
47 extern int	ppm_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
48 extern void	spm_change_schizo_speed(int);
49 
50 /*
51  * ppm device flags
52  */
53 #define	XCPPMF_PCIB		0x1
54 #define	XCPPMF_UPA		0x2
55 
56 /*
57  * Defines used for verification of CPU running at lowest speed.
58  */
59 #define	XCPPM_VCL_TRIES		5
60 #define	XCPPM_VCL_DELAY		10
61 #define	XCPPM_VCL_DIVISOR	32
62 
63 /*
64  * driver private data
65  */
66 typedef struct {
67 	dev_info_t	*dip;		/* ptr to our dev_info node */
68 	struct xcppmreg	regs;		/* register accessed by ppm */
69 	struct xcppmhndl hndls;		/* handles */
70 	kmutex_t	gpio_lock;	/* protects GPIO register */
71 	kmutex_t	unit_lock;	/* for state, led_tid fields below */
72 	kmutex_t	creator_lock;	/* held to create ppm_dev_t structs */
73 	uint_t		state;		/* ppm internal state */
74 	timeout_id_t	led_tid;	/* timeout id for LED */
75 } xcppm_unit_t;
76 
77 /*
78  * Flags for the state word of ppm_unit
79  */
80 #define	XCPPM_ST_SUSPENDED	0x00000001	/* DDI_SUSPEND received */
81 
82 #define	XCPPM_GET8(handle, address)			\
83 	ddi_get8(handle, (uint8_t *)(address))
84 
85 #define	XCPPM_SETGET8(handle, address, data)		\
86 	ddi_put8(handle, (uint8_t *)(address), data);	\
87 	data = XCPPM_GET8(handle, address)
88 
89 #define	XCPPM_GET16(handle, address)			\
90 	ddi_get16(handle, (uint16_t *)(address))
91 
92 #define	XCPPM_SETGET16(handle, address, data)		\
93 	ddi_put16(handle, (uint16_t *)(address), data);	\
94 	data = XCPPM_GET16(handle, address)
95 
96 #define	XCPPM_GET32(handle, address)			\
97 	ddi_get32(handle, (uint32_t *)(address))
98 
99 #define	XCPPM_SETGET32(handle, address, data)		\
100 	ddi_put32(handle, (uint32_t *)(address), data); \
101 	data = XCPPM_GET32(handle, address)
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif	/* _SYS_XCALPPM_VAR_H */
108