OpenBIC
OpenSource Bridge-IC
nct7363.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef NCT7363_H
17#define NCT7363_H
18
19#include "sensor.h"
20
21#define NCT7363_REG_DID 0xFD
22#define NCT7363_ID_MASK 0xFFFFFF
23#define NCT7363_ID (0x491988 & NCT7363_ID_MASK) /* Chip ID */
24
25#define NCT7363_REG_I2C_ADDR 0x46
26#define NCT7363_REG_GLOBAL_CONTROL 0x00
27
28#define GPIO0X_IO_CONF_REG 0x03
29#define GPIO1X_IO_CONF_REG 0x13
30
31#define GPIO_00_TO_03_PIN_CONFIGURATION_REG 0x20
32#define GPIO_04_TO_07_PIN_CONFIGURATION_REG 0x21
33#define GPIO_10_TO_13_PIN_CONFIGURATION_REG 0x22
34#define GPIO_14_TO_17_PIN_CONFIGURATION_REG 0x23
35
36#define NCT7363_PWM_CTRL_OUTPUT_0_TO_7_REG 0x38
37#define NCT7363_PWM_CTRL_OUTPUT_8_TO_15_REG 0x39
38
39#define NCT7363_FANIN_ENABLE_0_TO_7_REG 0x41
40#define NCT7363_FANIN_ENABLE_8_TO_15_REG 0x42
41
42#define NCT7363_REG_FAN_COUNT_VALUE_HIGH_BYTE_BASE_OFFSET 0x48
43#define NCT7363_REG_FAN_COUNT_VALUE_LOW_BYTE_BASE_OFFSET 0x49
44
45#define FANIN_MONOTORING_GLOBAL_CONTROLLER_REG 0x40
46#define NCT7363_REG_PWM_BASE_OFFSET 0x90
47
48#define SPEED_CONTROL_PORT_CONF_REG_BASE_OFFSET 0xB0
49#define SPEED_CONTROL_PORT_DIVISOR_BASE_OFFSET 0x91
50
51/* nct7363 port*/
69};
70
71#define FAN_STATUS_0_TO_7_REG 0x34
72#define FAN_STATUS_8_TO_15_REG 0x35
73
74#define NCT7363_FAN_COUNT_THRESHOLD_REG_HIGH_BYTE_BASE_OFFSET 0x6C
75#define NCT7363_FAN_COUNT_THRESHOLD_REG_LOW_BYTE_BASE_OFFSET 0x6D
76
77#define NCT7363_GPIO0x_INPUT_PORT_REG_OFFSET 0x00
78#define NCT7363_GPIO1x_INPUT_PORT_REG_OFFSET 0x10
79
80#define NCT7363_GPIO0x_OUTPUT_PORT_REG_OFFSET 0x01
81#define NCT7363_GPIO1x_OUTPUT_PORT_REG_OFFSET 0x11
82
83#define NCT7363_GPIO03_GPIO07_ALERT_LED_REG_OFFSET 0x09
84
85#define NCT7363_WDT_REG_OFFSET 0x2A
86
87typedef struct _nct7363_init_arg {
88 bool is_init;
89 uint8_t value;
90 // According to the pin position on the right side of the component, from top to bottom, there are 16 pins in total.
91 uint8_t pin_type[16];
92 uint8_t fan_poles[16];
93 union {
94 struct {
95 uint8_t gpio_00 : 1;
96 uint8_t gpio_01 : 1;
97 uint8_t gpio_02 : 1;
98 uint8_t gpio_03 : 1;
99 uint8_t gpio_04 : 1;
100 uint8_t gpio_05 : 1;
101 uint8_t gpio_06 : 1;
102 uint8_t gpio_07 : 1;
103 uint8_t gpio_10 : 1;
104 uint8_t gpio_11 : 1;
105 uint8_t gpio_12 : 1;
106 uint8_t gpio_13 : 1;
107 uint8_t gpio_14 : 1;
108 uint8_t gpio_15 : 1;
109 uint8_t gpio_16 : 1;
110 uint8_t gpio_17 : 1;
111 };
113 };
114 float fan_frequency[16];
115 uint8_t duty[16];
116 uint16_t threshold[16];
117 uint8_t wdt_cfg;
119
124};
125
134
136
138
139bool nct7363_set_duty(sensor_cfg *cfg, uint8_t duty, uint8_t port);
140#endif
141uint8_t nct7363_init(sensor_cfg *cfg);
142bool nct7363_setting_wdt(sensor_cfg *cfg, uint8_t wdt);
143bool nct7363_read_back_data(sensor_cfg *cfg, uint8_t reading_offset, uint8_t *val);
144bool nct7363_write(sensor_cfg *cfg, uint8_t offset, uint8_t val);
uint32_t val
Definition: plat_util.c:40
struct _nct7363_init_arg nct7363_init_arg
nct7363_gpio_type
Definition: nct7363.h:135
@ NCT7363_GPIO_INPUT
Definition: nct7363.h:135
@ NCT7363_GPIO_OUTPUT
Definition: nct7363.h:135
bool nct7363_read_back_data(sensor_cfg *cfg, uint8_t reading_offset, uint8_t *val)
Definition: nct7363.c:41
uint8_t nct7363_init(sensor_cfg *cfg)
Definition: nct7363.c:432
bool nct7363_set_duty(sensor_cfg *cfg, uint8_t duty, uint8_t port)
Definition: nct7363.c:133
nct7363_port
Definition: nct7363.h:52
@ NCT7363_15_PORT
Definition: nct7363.h:66
@ NCT7363_8_PORT
Definition: nct7363.h:60
@ NCT7363_2_PORT
Definition: nct7363.h:54
@ NCT7363_6_PORT
Definition: nct7363.h:58
@ NCT7363_10_PORT
Definition: nct7363.h:61
@ NCT7363_4_PORT
Definition: nct7363.h:56
@ NCT7363_7_PORT
Definition: nct7363.h:59
@ NCT7363_16_PORT
Definition: nct7363.h:67
@ NCT7363_5_PORT
Definition: nct7363.h:57
@ NCT7363_12_PORT
Definition: nct7363.h:63
@ NCT7363_11_PORT
Definition: nct7363.h:62
@ NCT7363_13_PORT
Definition: nct7363.h:64
@ NCT7363_14_PORT
Definition: nct7363.h:65
@ NCT7363_1_PORT
Definition: nct7363.h:53
@ NCT7363_3_PORT
Definition: nct7363.h:55
@ NCT7363_17_PORT
Definition: nct7363.h:68
bool nct7363_write(sensor_cfg *cfg, uint8_t offset, uint8_t val)
Definition: nct7363.c:160
nct7363_pin_type
Definition: nct7363.h:126
@ NCT7363_PIN_TPYE_ERROR
Definition: nct7363.h:132
@ NCT7363_PIN_TPYE_RESERVED
Definition: nct7363.h:130
@ NCT7363_PIN_TPYE_GPIO_DEFAULT_OUTPUT
Definition: nct7363.h:131
@ NCT7363_PIN_TPYE_FANIN
Definition: nct7363.h:129
@ NCT7363_PIN_TPYE_PWM
Definition: nct7363.h:128
@ NCT7363_PIN_TPYE_GPIO
Definition: nct7363.h:127
nct7363_wdt_sec
Definition: nct7363.h:137
@ WDT_7_5_SEC
Definition: nct7363.h:137
@ WDT_ERROR
Definition: nct7363.h:137
@ WDT_DISABLE
Definition: nct7363.h:137
@ WDT_30_SEC
Definition: nct7363.h:137
@ WDT_15_SEC
Definition: nct7363.h:137
@ WDT_3_75_SEC
Definition: nct7363.h:137
nct7363_sensor_offset
Definition: nct7363.h:120
@ NCT7363_GPIO_READ_OFFSET
Definition: nct7363.h:123
@ NCT7363_FAN_STATUS_OFFSET
Definition: nct7363.h:122
@ NCT7363_FAN_SPEED_OFFSET
Definition: nct7363.h:121
bool nct7363_setting_wdt(sensor_cfg *cfg, uint8_t wdt)
Definition: nct7363.c:194
uint32_t offset
Definition: pldm_firmware_update.h:0
Definition: nct7363.h:87
uint8_t gpio_16
Definition: nct7363.h:109
uint8_t gpio_03
Definition: nct7363.h:98
uint8_t gpio_00
Definition: nct7363.h:95
uint8_t wdt_cfg
Definition: nct7363.h:117
uint8_t value
Definition: nct7363.h:89
uint8_t gpio_17
Definition: nct7363.h:110
uint8_t gpio_14
Definition: nct7363.h:107
uint8_t fan_poles[16]
Definition: nct7363.h:92
bool is_init
Definition: nct7363.h:88
uint8_t gpio_07
Definition: nct7363.h:102
uint8_t pin_type[16]
Definition: nct7363.h:91
uint8_t gpio_04
Definition: nct7363.h:99
uint8_t gpio_11
Definition: nct7363.h:104
uint8_t gpio_06
Definition: nct7363.h:101
uint8_t gpio_01
Definition: nct7363.h:96
uint16_t gpio_out_default_val
Definition: nct7363.h:112
float fan_frequency[16]
Definition: nct7363.h:114
uint8_t duty[16]
Definition: nct7363.h:115
uint8_t gpio_12
Definition: nct7363.h:105
uint16_t threshold[16]
Definition: nct7363.h:116
uint8_t gpio_15
Definition: nct7363.h:108
uint8_t gpio_02
Definition: nct7363.h:97
uint8_t gpio_05
Definition: nct7363.h:100
uint8_t gpio_10
Definition: nct7363.h:103
uint8_t gpio_13
Definition: nct7363.h:106
Definition: sensor.h:256