Home | History | Annotate | Line # | Download | only in emcfanctl
      1 /*	$NetBSD: emcfanctl.h,v 1.1 2025/03/11 13:56:48 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 _EMCFANCTL_H_
     20 #define _EMCFANCTL_H_
     21 
     22 /* Top level commands */
     23 #define EMCFANCTL_INFO 1
     24 #define EMCFANCTL_REGISTER 2
     25 #define EMCFANCTL_FAN 3
     26 #define EMCFANCTL_APD 4
     27 #define EMCFANCTL_SMBUSTO 5
     28 
     29 /* REGISTER sub commands */
     30 #define EMCFANCTL_REGISTER_LIST 1
     31 #define EMCFANCTL_REGISTER_READ 2
     32 #define EMCFANCTL_REGISTER_WRITE 3
     33 
     34 /* FAN sub commands */
     35 #define EMCFANCTL_FAN_STATUS 1
     36 #define EMCFANCTL_FAN_DRIVE 2
     37 #define EMCFANCTL_FAN_DIVIDER 3
     38 #define EMCFANCTL_FAN_MINEXPECTED_RPM 4
     39 #define EMCFANCTL_FAN_EDGES 5
     40 #define EMCFANCTL_FAN_POLARITY 6
     41 #define EMCFANCTL_FAN_PWM_BASEFREQ 7
     42 #define EMCFANCTL_FAN_PWM_OUTPUTTYPE 8
     43 
     44 /* APD and SMSBUS timeout sub command */
     45 
     46 #define EMCFANCTL_APD_READ 1
     47 #define EMCFANCTL_APD_ON 2
     48 #define EMCFANCTL_APD_OFF 3
     49 
     50 /* FAN driver, divider, edges, min_expected_rpm
     51  * and base_freqsub commands
     52  */
     53 #define EMCFANCTL_FAN_DD_READ 1
     54 #define EMCFANCTL_FAN_DD_WRITE 2
     55 
     56 /* FAN polarity sub commands */
     57 #define EMCFANCTL_FAN_P_READ 1
     58 #define EMCFANCTL_FAN_P_INVERTED 2
     59 #define EMCFANCTL_FAN_P_NONINVERTED 3
     60 
     61 /* FAN pwm_output_type sub commands */
     62 #define EMCFANCTL_FAN_OT_READ 1
     63 #define EMCFANCTL_FAN_OT_PUSHPULL 2
     64 #define EMCFANCTL_FAN_OT_OPENDRAIN 3
     65 
     66 struct emcfanctlcmd {
     67 	const char	*cmd;
     68 	const int	id;
     69 	const char	*helpargs;
     70 };
     71 
     72 struct emcfan_registers {
     73 	const char	*name;
     74 	const uint8_t	reg;
     75 };
     76 
     77 #define EMCFAN_TRANSLATE_INT 1
     78 #define EMCFAN_TRANSLATE_STR 2
     79 #define EMCFAN_NO_INSTANCE -10191
     80 
     81 struct emcfan_bits_translate {
     82 	const int	type;
     83 	const uint8_t	clear_mask;
     84 	const uint8_t	bit_mask;
     85 	const int	human_int;
     86 	const char	*human_str;
     87 	const int	instance;
     88 };
     89 
     90 #define EMCFAN_FAMILY_UNKNOWN 0
     91 
     92 #endif
     93