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