dbcool_var.h revision 1.1.2.2 1 /* $NetBSD: dbcool_var.h,v 1.1.2.2 2008/10/05 20:11:29 mjf Exp $ */
2
3 /*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Goyette
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * A driver for dbCool(tm) family of environmental controllers
34 */
35
36 #ifndef DBCOOLVAR_H
37 #define DBCOOLVAR_H
38
39 #define DBCOOL_DEBUG
40 /*
41 */
42
43 #include <sys/cdefs.h>
44 __KERNEL_RCSID(0, "$NetBSD: dbcool_var.h,v 1.1.2.2 2008/10/05 20:11:29 mjf Exp $");
45
46 #include <dev/i2c/i2cvar.h>
47
48 #include <dev/sysmon/sysmonvar.h>
49 #include "sysmon_envsys.h"
50
51 #include <dev/i2c/dbcool_reg.h>
52
53 enum dbc_pwm_params {
54 DBC_PWM_BEHAVIOR = 0,
55 DBC_PWM_RANGE,
56 DBC_PWM_MIN_DUTY,
57 DBC_PWM_MAX_DUTY,
58 DBC_PWM_CUR_DUTY,
59 DBC_PWM_LAST_PARAM
60 };
61
62 enum dbc_sensor_type {
63 DBC_CTL = 0,
64 DBC_TEMP,
65 DBC_VOLT,
66 DBC_FAN,
67 DBC_EOF
68 };
69
70 #define DBCFLAG_TEMPOFFSET 0x0001
71 #define DBCFLAG_HAS_MAXDUTY 0x0002
72 #define DBCFLAG_HAS_SHDN 0x0004
73 #define DBCFLAG_MULTI_VCC 0x0008
74 #define DBCFLAG_4BIT_VER 0x0010
75 #define DBCFLAG_HAS_VID 0x0020
76 #define DBCFLAG_HAS_VID_SEL 0x0040
77 #define DBCFLAG_ADM1027 0x1000
78 #define DBCFLAG_ADM1030 0x2000
79 #define DBCFLAG_ADT7466 0x4000
80
81 /* Maximum sensors for any dbCool device */
82 #define DBCOOL_MAXSENSORS 15
83
84 struct reg_list {
85 uint8_t val_reg;
86 uint8_t hi_lim_reg;
87 uint8_t lo_lim_reg;
88 };
89
90 struct dbcool_sensor {
91 enum dbc_sensor_type type;
92 struct reg_list reg;
93 int name_index;
94 int sysctl_index;
95 };
96
97 /*
98 * The members of dbcool_power_control need to stay in the same order
99 * as the enum dbc_pwm_params above
100 */
101 struct dbcool_power_control {
102 uint8_t behavior;
103 uint8_t range;
104 uint8_t min;
105 uint8_t max;
106 uint8_t cur;
107 const char *desc;
108 };
109
110 struct chip_id;
111
112 struct dbcool_softc {
113 struct device *parent;
114 i2c_tag_t sc_tag;
115 i2c_addr_t sc_addr;
116 struct chip_id *sc_chip;
117 struct sysmon_envsys *sc_sme;
118 envsys_data_t sc_sensor[DBCOOL_MAXSENSORS];
119 int sc_sysctl_num[DBCOOL_MAXSENSORS];
120 struct reg_list *sc_regs[DBCOOL_MAXSENSORS];
121 uint8_t sc_suspend;
122 uint8_t sc_temp_offset;
123 #ifdef DBCOOL_DEBUG
124 uint8_t sc_user_reg;
125 #endif
126 };
127
128 struct chip_id {
129 uint8_t company;
130 uint8_t device;
131 uint8_t rev;
132 struct dbcool_sensor *table;
133 struct dbcool_power_control *power;
134 int flags;
135 int rpm_dividend;
136 const char *name;
137 };
138
139 /*
140 * Expose some routines for the macppc's ki2c match/attach routines
141 */
142 uint8_t dbcool_readreg(struct dbcool_softc *, uint8_t);
143 void dbcool_writereg(struct dbcool_softc *, uint8_t, uint8_t);
144 void dbcool_setup(device_t);
145 int dbcool_chip_ident(struct dbcool_softc *);
146 bool dbcool_pmf_suspend(device_t PMF_FN_PROTO);
147 bool dbcool_pmf_resume(device_t PMF_FN_PROTO);
148
149 #endif /* def DBCOOLVAR_H */
150