blob: d11fbcfc663b69edc642ea8bfede97e986a5809c [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Rothe899e512012-12-05 16:07:11 -07002
3#ifndef _SB800_FAN_H_
4#define _SB800_FAN_H_
5
Kyösti Mälkki5be75d52019-08-19 08:41:50 +03006#include <device/device.h>
7
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +02008void init_sb800_IMC_fans(struct device *dev);
9void init_sb800_MANUAL_fans(struct device *dev);
Martin Rothe899e512012-12-05 16:07:11 -070010
11/* Fan Register Definitions */
12#define FAN_0_OFFSET 0x00
13#define FAN_1_OFFSET 0x10
14#define FAN_2_OFFSET 0x20
15#define FAN_3_OFFSET 0x30
16#define FAN_4_OFFSET 0x40
17
18#define FAN_INPUT_CONTROL_REG 0x00
19#define FAN_CONTROL_REG 0x01
20#define FAN_FREQUENCY_REG 0x02
21#define FAN_LOW_DUTY_REG 0x03
22#define FAN_MED_DUTY_REG 0x04
23#define FAN_MULTIPLIER_REG 0x05
24#define FAN_LOW_TEMP_LO_REG 0x06
25#define FAN_LOW_TEMP_HI_REG 0x07
26#define FAN_MED_TEMP_LO_REG 0x08
27#define FAN_MED_TEMP_HI_REG 0x09
28#define FAN_HIGH_TEMP_LO_REG 0x0A
29#define FAN_HIGH_TEMP_HI_REG 0x0B
30#define FAN_LINEAR_RANGE_REG 0x0C
31#define FAN_LINEAR_HOLD_REG 0x0D
32
33/* FanXInputControl Definitions */
34#define FAN_INPUT_INTERNAL_DIODE 0
35#define FAN_INPUT_TEMP0 1
36#define FAN_INPUT_TEMP1 2
37#define FAN_INPUT_TEMP2 3
38#define FAN_INPUT_TEMP3 4
39#define FAN_INPUT_TEMP0_FILTER 5
40#define FAN_INPUT_ZERO 6
41#define FAN_INPUT_DISABLED 7
42
43/* FanXControl Definitions */
44#define FAN_AUTOMODE (1 << 0)
45#define FAN_LINEARMODE (1 << 1)
46#define FAN_STEPMODE 0 /* ~(1 << 1) */
47#define FAN_POLARITY_HIGH (1 << 2)
48#define FAN_POLARITY_LOW 0 /*~(1 << 2) */
49
50/* FanXLowDuty Definitions */
51#define FAN_POLARITY_HIGH_MAX_SPEED 0xff
52#define FAN_POLARITY_LOW_MAX_SPEED 0x00
53
54/* FanXFreq Definitions */
55/* Typically, fans run at 25KHz */
56#define FREQ_28KHZ 0x0
57#define FREQ_25KHZ 0x1
58#define FREQ_23KHZ 0x2
59#define FREQ_21KHZ 0x3
60#define FREQ_29KHZ 0x4
61#define FREQ_18KHZ 0x5
62/* Any value > 05h and < F7: Freq = 1/(FreqDiv * 2048 * 15ns) */
63#define FREQ_100HZ 0xF7
64#define FREQ_87HZ 0xF8
65#define FREQ_58HZ 0xF9
66#define FREQ_44HZ 0xFA
67#define FREQ_35HZ 0xFB
68#define FREQ_29HZ 0xFC
69#define FREQ_22HZ 0xFD
70#define FREQ_14HZ 0xFE
71#define FREQ_11HZ 0xFF
72
Martin Rothe899e512012-12-05 16:07:11 -070073/* IMC Fan Control Definitions */
74#define IMC_MODE1_FAN_ENABLED ( 1 << 0 )
75#define IMC_MODE1_FAN_IMC_CONTROLLED ( 1 << 2 )
76#define IMC_MODE1_FAN_LINEAR_MODE ( 1 << 4 )
77#define IMC_MODE1_FAN_STEP_MODE 0 /* ~( 1 << 4 ) */
78#define IMC_MODE1_NO_FANOUT 0 /* ~( 7 << 5 ) */
79#define IMC_MODE1_FANOUT0 ( 1 << 5 )
80#define IMC_MODE1_FANOUT1 ( 2 << 5 )
81#define IMC_MODE1_FANOUT2 ( 3 << 5 )
82#define IMC_MODE1_FANOUT3 ( 4 << 5 )
83#define IMC_MODE1_FANOUT4 ( 5 << 5 )
84
85#define IMC_MODE2_TEMPIN_NONE 0 /* ~( 7 << 0) */
86#define IMC_MODE2_TEMPIN_0 1
87#define IMC_MODE2_TEMPIN_1 2
88#define IMC_MODE2_TEMPIN_2 3
89#define IMC_MODE2_TEMPIN_3 4
90#define IMC_MODE2_INT_TEMPIN 5
91#define IMC_MODE2_TEMPIN_SB_TSI 6
92#define IMC_MODE2_TEMPIN_OTHER 7
93#define IMC_MODE2_FANIN_NONE 0 /* ~ (7 << 3) */
94#define IMC_MODE2_FANIN0 ( 1 << 3 )
95#define IMC_MODE2_FANIN1 ( 2 << 3 )
96#define IMC_MODE2_FANIN2 ( 3 << 3 )
97#define IMC_MODE2_FANIN3 ( 4 << 3 )
98#define IMC_MODE2_FANIN4 ( 5 << 3 )
99#define IMC_MODE2_TEMP_AVERAGING_ENABLED ( 1 << 6 )
100#define IMC_MODE2_TEMP_AVERAGING_DISABLED 0 /* ~( 1 << 6 ) */
101
102#define IMC_TEMP_SENSOR_ON_SMBUS_0 0
103#define IMC_TEMP_SENSOR_ON_SMBUS_2 1
104#define IMC_TEMP_SENSOR_ON_SMBUS_3 2
105#define IMC_TEMP_SENSOR_ON_SMBUS_4 3
106
107#define IMC_ZONE0 0
108#define IMC_ZONE1 1
109#define IMC_ZONE2 2
110#define IMC_ZONE3 3
111#define IMC_ZONE4 4
112
113#define IMC_TEMPIN_TUNING_DEFAULT_MODE 0
114#define IMC_TEMPIN_TUNING_HIGH_CURRENT_RATIO 1
115#define IMC_TEMPIN_TUNING_HIGH_CURRENT 2
116#define IMC_TEMPIN_TUNING_DISABLE_FILTERING ( 1 << 2 )
117
118/* IMCFUNSupportBitMap - Zone enable values */
119#define IMC_ENABLE_ZONE0 0x111
120#define IMC_ENABLE_ZONE1 0x222
121#define IMC_ENABLE_ZONE2 0x333
122#define IMC_ENABLE_ZONE3 0x444
123#define IMC_ENABLE_TEMPIN0 ( 1 << 12 )
124#define IMC_ENABLE_TEMPIN1 ( 1 << 13 )
125#define IMC_ENABLE_TEMPIN2 ( 1 << 14 )
126#define IMC_ENABLE_TEMPIN3 ( 1 << 15 )
127
128/* Array size settings */
129#define IMC_FAN_THRESHOLD_COUNT 9
130#define IMC_FAN_SPEED_COUNT 8
131#define IMC_FAN_CONFIG_COUNT 8
132#define FAN_REGISTER_COUNT 15
133
134#endif