emcfanvar.h revision 1.1 1 /* $NetBSD: emcfanvar.h,v 1.1 2025/03/11 13:56:46 brad Exp $ */
2
3 /*
4 * Copyright (c) 2025 Brad Spencer <brad (at) anduin.eldar.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef _DEV_I2C_EMCFANVAR_H_
20 #define _DEV_I2C_EMCFANVAR_H_
21
22 #include <sys/gpio.h>
23 #include <dev/gpio/gpiovar.h>
24
25 #define EMCFAN_NUM_FANS 5
26 #define EMCFAN_NUM_SENSORS 8 /* Up to 5 tachs, or 8 temperature zones (1 internal, 4 external,
27 * 1 VIN4) and 2 tachs and some combos in between.
28 */
29
30 struct emcfan_sc;
31
32 #define EMCFAN_INTERNAL_TEMP 0x01
33 #define EMCFAN_VIN4_TEMP 0x02
34 #define EMCFAN_MAX_PINS 6
35
36 /* This supplements the envsys_data_t structure stored in the sc. */
37
38 struct emcfan_sensor_instance {
39 uint8_t sc_i_flags;
40 int sc_i_member;
41 int sc_i_envnum;
42 };
43
44 struct emcfan_sc {
45 int sc_emcfandebug;
46 struct sysctllog *sc_emcfanlog;
47 device_t sc_dev;
48 i2c_tag_t sc_tag;
49 i2c_addr_t sc_addr;
50 int sc_info_index;
51 bool sc_dying;
52 bool sc_opened;
53 kmutex_t sc_mutex;
54 struct sysmon_envsys *sc_sme;
55 int sc_ftach;
56 bool sc_vin4_temp;
57 int sc_num_poles[EMCFAN_NUM_FANS];
58 struct emcfan_sensor_instance sc_sensor_instances[EMCFAN_NUM_SENSORS];
59 envsys_data_t sc_sensors[EMCFAN_NUM_SENSORS];
60 device_t sc_gpio_dev;
61 struct gpio_chipset_tag sc_gpio_gc;
62 gpio_pin_t sc_gpio_pins[EMCFAN_MAX_PINS];
63 };
64
65 #endif
66