1 /* $NetBSD: dbcool_var.h,v 1.7 2010/01/08 20:04:31 dyoung 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.7 2010/01/08 20:04:31 dyoung 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_chipset { 109 i2c_tag_t dc_tag; 110 i2c_addr_t dc_addr; 111 void (*dc_writereg)(struct dbcool_chipset *, uint8_t, uint8_t); 112 uint8_t (*dc_readreg)(struct dbcool_chipset *, uint8_t); 113 struct chip_id *dc_chip; 114 }; 115 116 struct dbcool_softc { 117 device_t sc_dev; 118 struct sysmon_envsys *sc_sme; 119 struct dbcool_chipset sc_dc; 120 envsys_data_t sc_sensor[DBCOOL_MAXSENSORS]; 121 int sc_sysctl_num[DBCOOL_MAXSENSORS]; 122 struct reg_list *sc_regs[DBCOOL_MAXSENSORS]; 123 int sc_nom_volt[DBCOOL_MAXSENSORS]; 124 int sc_temp_offset; 125 int64_t sc_supply_voltage; 126 bool sc_suspend; 127 #ifdef DBCOOL_DEBUG 128 uint8_t sc_user_reg; 129 #endif 130 }; 131 132 struct chip_id { 133 uint8_t company; 134 uint8_t device; 135 uint8_t rev; 136 struct dbcool_sensor *table; 137 struct dbcool_power_control *power; 138 int flags; 139 int rpm_dividend; 140 const char *name; 141 }; 142 143 /* 144 * Expose some routines for the macppc's ki2c match/attach routines 145 */ 146 uint8_t dbcool_readreg(struct dbcool_chipset *, uint8_t); 147 void dbcool_writereg(struct dbcool_chipset *, uint8_t, uint8_t); 148 void dbcool_setup(device_t); 149 int dbcool_chip_ident(struct dbcool_chipset *); 150 bool dbcool_pmf_suspend(device_t, pmf_qual_t); 151 bool dbcool_pmf_resume(device_t, pmf_qual_t); 152 153 #endif /* def DBCOOLVAR_H */ 154