Home | History | Annotate | Line # | Download | only in ic
ugvar.h revision 1.1
      1 /* $NetBSD: ugvar.h,v 1.1 2007/05/08 16:48:38 xtraeme Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2007 Mihai Chelaru <kefren (at) netbsd.ro>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. The name of the author may not be used to endorse or promote products
     13  *    derived from this software without specific prior written permission.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     20  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     22  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     23  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  * SUCH DAMAGE.
     26  */
     27 
     28 #ifndef _UGVAR_H_
     29 #define _UGVAR_H_
     30 
     31 /*
     32  * sc->sensors sub-intervals for each unit type.
     33  */
     34 static const struct envsys_range ug_ranges[] = {
     35 	{ 0,	2,	ENVSYS_STEMP },
     36 	{ 14,	18,	ENVSYS_SFANRPM },
     37 	{ 1,	0,	ENVSYS_SVOLTS_AC },	/* None */
     38 	{ 3,	13,	ENVSYS_SVOLTS_DC },
     39 	{ 1,	0,	ENVSYS_SOHMS },		/* None */
     40 	{ 1,	0,	ENVSYS_SWATTS },	/* None */
     41 	{ 1,	0,	ENVSYS_SAMPS }		/* None */
     42 };
     43 
     44 struct ug_softc {
     45 	struct device sc_dev;
     46 
     47 	bus_space_tag_t sc_iot;
     48 	bus_space_handle_t sc_ioh;
     49 
     50 	struct sysmon_envsys sc_sysmon;
     51 	envsys_tre_data_t sc_data[UG_MAX_SENSORS];
     52 	envsys_basic_info_t sc_info[UG_MAX_SENSORS];
     53 	uint8_t version;
     54 	void *mbsens;
     55 };
     56 
     57 struct ug2_sensor_info {
     58 	const char *name;
     59 	int port;
     60 	int type;
     61 	int multiplier;
     62 	int divisor;
     63 	int offset;
     64 };
     65 
     66 struct ug2_motherboard_info {
     67 	uint16_t id;
     68 	const char *name;
     69 	struct ug2_sensor_info sensors[UG2_MAX_NO_SENSORS + 1];
     70 };
     71 
     72 /* driver internal functions */
     73 int ug_reset(struct ug_softc *);
     74 uint8_t ug_read(struct ug_softc *, unsigned short);
     75 int ug_waitfor(struct ug_softc *, uint16_t, uint8_t);
     76 void ug_setup_sensors(struct ug_softc *);
     77 void ug2_attach(struct ug_softc *);
     78 int ug2_wait_ready(struct ug_softc *);
     79 int ug2_wait_readable(struct ug_softc *);
     80 int ug2_sync(struct ug_softc *);
     81 int ug2_read(struct ug_softc *, uint8_t, uint8_t, uint8_t, uint8_t*);
     82 
     83 /* Envsys */
     84 int ug_gtredata(struct sysmon_envsys *, envsys_tre_data_t *);
     85 int ug_streinfo_ni(struct sysmon_envsys *, envsys_basic_info_t *);
     86 int ug2_gtredata(struct sysmon_envsys *, envsys_tre_data_t *);
     87 
     88 #endif		/* _UGVAR_H_ */
     89