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