Skip to content

Commit fabeb81

Browse files
committed
tenstorrent: bh_chip: enable input power reading in BMC FW
Enable input power reading in BMC FW using the INA228. Send input power to ASIC instead of input current, since SMC FW just only uses input current to calculate input power for throttling. Signed-off-by: Petra Alexson <[email protected]>
1 parent 366ade2 commit fabeb81

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

app/dmc/src/main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,17 @@ void process_cm2dm_message(struct bh_chip *chip)
127127
}
128128
}
129129

130-
void ina228_current_update(void)
130+
void ina228_pwr_update(void)
131131
{
132-
struct sensor_value current_sensor_val;
132+
struct sensor_value sensor_val;
133133

134-
sensor_sample_fetch_chan(ina228, SENSOR_CHAN_CURRENT);
135-
sensor_channel_get(ina228, SENSOR_CHAN_CURRENT, &current_sensor_val);
134+
sensor_sample_fetch_chan(ina228, SENSOR_CHAN_POWER);
135+
sensor_channel_get(ina228, SENSOR_CHAN_POWER, &sensor_val);
136136

137-
int32_t current =
138-
(current_sensor_val.val1 << 16) + (current_sensor_val.val2 * 65536ULL) / 1000000ULL;
137+
int32_t power = (sensor_val.val1 << 16) + (sensor_val.val2 * 65536ULL) / 1000000ULL;
139138

140139
ARRAY_FOR_EACH_PTR(BH_CHIPS, chip) {
141-
bh_chip_set_input_current(chip, &current);
140+
bh_chip_set_input_pwr(chip, &power);
142141
}
143142
}
144143

@@ -349,7 +348,7 @@ int main(void)
349348
}
350349

351350
if (IS_ENABLED(CONFIG_INA228)) {
352-
ina228_current_update();
351+
ina228_pwr_update();
353352
}
354353

355354
if (IS_ENABLED(CONFIG_TT_FAN_CTRL)) {

include/tenstorrent/bh_chip.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ void bh_chip_cancel_bus_transfer_clear(struct bh_chip *chip);
117117
cm2dmMessageRet bh_chip_get_cm2dm_message(struct bh_chip *chip);
118118
int bh_chip_set_static_info(struct bh_chip *chip, dmStaticInfo *info);
119119
int bh_chip_set_input_current(struct bh_chip *chip, int32_t *current);
120+
int bh_chip_set_input_pwr(struct bh_chip *chip, uint32_t *power);
121+
int bh_chip_set_input_pwr_lim(struct bh_chip *chip, uint16_t max_pwr);
120122
int bh_chip_set_fan_rpm(struct bh_chip *chip, uint16_t rpm);
121-
int bh_chip_set_board_pwr_lim(struct bh_chip *chip, uint16_t max_pwr);
122123

123124
void bh_chip_assert_asic_reset(const struct bh_chip *chip);
124125
void bh_chip_deassert_asic_reset(const struct bh_chip *chip);

lib/tenstorrent/bh_arc/throttler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void CalculateThrottlers(void)
195195
UpdateThrottler(kThrottlerFastTDC, telemetry_internal_data.vcore_current);
196196
UpdateThrottler(kThrottlerTDC, telemetry_internal_data.vcore_current);
197197
UpdateThrottler(kThrottlerThm, telemetry_internal_data.asic_temperature);
198-
UpdateThrottler(kThrottlerBoardPwr, 12 * ConvertTelemetryToFloat(GetInputCurrent()));
198+
UpdateThrottler(kThrottlerBoardPwr, ConvertTelemetryToFloat(GetInputPower()));
199199
UpdateThrottler(kThrottlerGDDRThm, GetMaxGDDRTemp());
200200

201201
for (ThrottlerId i = 0; i < kThrottlerCount; i++) {

lib/tenstorrent/bh_chip/bh_chip.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,17 @@ int bh_chip_set_input_current(struct bh_chip *chip, int32_t *current)
6666

6767
return ret;
6868
}
69-
int bh_chip_set_fan_rpm(struct bh_chip *chip, uint16_t rpm)
69+
70+
int bh_chip_set_input_pwr(struct bh_chip *chip, uint32_t *power)
7071
{
7172
int ret;
7273

73-
ret = bharc_smbus_word_data_write(&chip->config.arc, 0x23, rpm);
74+
ret = bharc_smbus_block_write(&chip->config.arc, 0x25, 4, (uint8_t *)power);
7475

7576
return ret;
7677
}
7778

78-
int bh_chip_set_board_pwr_lim(struct bh_chip *chip, uint16_t max_pwr)
79+
int bh_chip_set_input_pwr_lim(struct bh_chip *chip, uint16_t max_pwr)
7980
{
8081
int ret;
8182

@@ -84,6 +85,15 @@ int bh_chip_set_board_pwr_lim(struct bh_chip *chip, uint16_t max_pwr)
8485
return ret;
8586
}
8687

88+
int bh_chip_set_fan_rpm(struct bh_chip *chip, uint16_t rpm)
89+
{
90+
int ret;
91+
92+
ret = bharc_smbus_word_data_write(&chip->config.arc, 0x23, rpm);
93+
94+
return ret;
95+
}
96+
8797
void bh_chip_assert_asic_reset(const struct bh_chip *chip)
8898
{
8999
gpio_pin_set_dt(&chip->config.asic_reset, 1);

0 commit comments

Comments
 (0)