dbcool_var.h revision 1.3 1 /* $NetBSD: dbcool_var.h,v 1.3 2008/10/09 10:25:47 pgoyette 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.3 2008/10/09 10:25:47 pgoyette Exp $");
45
46 #include <dev/i2c/i2cvar.h>
47
48 #include <dev/sysmon/sysmonvar.h>
49
50 #include <dev/i2c/dbcool_reg.h>
51
52 enum dbc_pwm_params {
53 DBC_PWM_BEHAVIOR = 0,
54 DBC_PWM_MIN_DUTY,
55 DBC_PWM_MAX_DUTY,
56 DBC_PWM_CUR_DUTY,
57 DBC_PWM_LAST_PARAM
58 };
59
60 enum dbc_sensor_type {
61 DBC_CTL = 0,
62 DBC_TEMP,
63 DBC_VOLT,
64 DBC_FAN,
65 DBC_EOF
66 };
67
68 #define DBCFLAG_TEMPOFFSET 0x0001
69 #define DBCFLAG_HAS_MAXDUTY 0x0002
70 #define DBCFLAG_HAS_SHDN 0x0004
71 #define DBCFLAG_MULTI_VCC 0x0008
72 #define DBCFLAG_4BIT_VER 0x0010
73 #define DBCFLAG_HAS_VID 0x0020
74 #define DBCFLAG_HAS_VID_SEL 0x0040
75 #define DBCFLAG_HAS_PECI 0x0080
76 #define DBCFLAG_ADM1027 0x1000
77 #define DBCFLAG_ADM1030 0x2000
78 #define DBCFLAG_ADT7466 0x4000
79
80 /* Maximum sensors for any dbCool device */
81 #define DBCOOL_MAXSENSORS 15
82
83 struct reg_list {
84 uint8_t val_reg;
85 uint8_t hi_lim_reg;
86 uint8_t lo_lim_reg;
87 };
88
89 struct dbcool_sensor {
90 enum dbc_sensor_type type;
91 struct reg_list reg;
92 int name_index;
93 int sysctl_index;
94 int nom_volt_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 power_regs[DBC_PWM_LAST_PARAM];
103 const char *desc;
104 };
105
106 struct chip_id;
107
108 struct dbcool_softc {
109 struct device *sc_dev;
110 i2c_tag_t sc_tag;
111 i2c_addr_t sc_addr;
112 struct chip_id *sc_chip;
113 struct sysmon_envsys *sc_sme;
114 envsys_data_t sc_sensor[DBCOOL_MAXSENSORS];
115 int sc_sysctl_num[DBCOOL_MAXSENSORS];
116 struct reg_list *sc_regs[DBCOOL_MAXSENSORS];
117 int sc_nom_volt[DBCOOL_MAXSENSORS];
118 int sc_temp_offset;
119 int64_t sc_supply_voltage;
120 bool sc_suspend;
121 #ifdef DBCOOL_DEBUG
122 uint8_t sc_user_reg;
123 #endif
124 };
125
126 struct chip_id {
127 uint8_t company;
128 uint8_t device;
129 uint8_t rev;
130 struct dbcool_sensor *table;
131 struct dbcool_power_control *power;
132 int flags;
133 int rpm_dividend;
134 const char *name;
135 };
136
137 /*
138 * Expose some routines for the macppc's ki2c match/attach routines
139 */
140 uint8_t dbcool_readreg(struct dbcool_softc *, uint8_t);
141 void dbcool_writereg(struct dbcool_softc *, uint8_t, uint8_t);
142 void dbcool_setup(device_t);
143 int dbcool_chip_ident(struct dbcool_softc *);
144 bool dbcool_pmf_suspend(device_t PMF_FN_PROTO);
145 bool dbcool_pmf_resume(device_t PMF_FN_PROTO);
146
147 #endif /* def DBCOOLVAR_H */
148