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