Skip to content

Commit 179068e

Browse files
committed
bh_chip: add handle_pgood_event to bh_chip library
Move pgood handler from the DMC app to the bh_chip library. Signed-off-by: Petra Alexson <[email protected]>
1 parent 0d77676 commit 179068e

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

app/dmc/src/main.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -345,29 +345,7 @@ int main(void)
345345

346346
/* handler for PGOOD */
347347
ARRAY_FOR_EACH_PTR(BH_CHIPS, chip) {
348-
if (chip->data.pgood_fall_triggered && !chip->data.pgood_severe_fault) {
349-
int64_t current_uptime_ms = k_uptime_get();
350-
/* Assert board fault */
351-
gpio_pin_set_dt(&board_fault_led, 1);
352-
/* Report over SMBus - to add later */
353-
/* Assert ASIC reset */
354-
bh_chip_assert_asic_reset(chip);
355-
/* If pgood went down again within 1 second */
356-
if (chip->data.pgood_last_trip_ms != 0 &&
357-
current_uptime_ms - chip->data.pgood_last_trip_ms < 1000) {
358-
/* Assert more severe fault over IPMI - to add later */
359-
chip->data.pgood_severe_fault = true;
360-
}
361-
chip->data.pgood_last_trip_ms = current_uptime_ms;
362-
chip->data.pgood_fall_triggered = false;
363-
}
364-
if (chip->data.pgood_rise_triggered && !chip->data.pgood_severe_fault) {
365-
/* Follow out of reset procedure */
366-
bh_chip_reset_chip(chip, true);
367-
/* Clear board fault */
368-
gpio_pin_set_dt(&board_fault_led, 0);
369-
chip->data.pgood_rise_triggered = false;
370-
}
348+
handle_pgood_event(chip, board_fault_led);
371349
}
372350

373351
/* TODO(drosen): Turn this into a task which will re-arm until static data is sent

include/tenstorrent/bh_chip.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ int bh_chip_reset_chip(struct bh_chip *chip, bool force_reset);
141141
int therm_trip_gpio_setup(struct bh_chip *chip);
142142
int pgood_gpio_setup(struct bh_chip *chip);
143143

144+
void handle_pgood_event(struct bh_chip *chip, struct gpio_dt_spec board_fault_led);
145+
144146
#ifdef __cplusplus
145147
}
146148
#endif

lib/tenstorrent/bh_chip/bh_chip.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,30 @@ int pgood_gpio_setup(struct bh_chip *chip)
185185

186186
return ret;
187187
}
188+
189+
void handle_pgood_event(struct bh_chip *chip, struct gpio_dt_spec board_fault_led)
190+
{
191+
if (chip->data.pgood_fall_triggered && !chip->data.pgood_severe_fault) {
192+
int64_t current_uptime_ms = k_uptime_get();
193+
/* Assert board fault */
194+
gpio_pin_set_dt(&board_fault_led, 1);
195+
/* Report over SMBus - to add later */
196+
/* Assert ASIC reset */
197+
bh_chip_assert_asic_reset(chip);
198+
/* If pgood went down again within 1 second */
199+
if (chip->data.pgood_last_trip_ms != 0 &&
200+
current_uptime_ms - chip->data.pgood_last_trip_ms < 1000) {
201+
/* Assert more severe fault over IPMI - to add later */
202+
chip->data.pgood_severe_fault = true;
203+
}
204+
chip->data.pgood_last_trip_ms = current_uptime_ms;
205+
chip->data.pgood_fall_triggered = false;
206+
}
207+
if (chip->data.pgood_rise_triggered && !chip->data.pgood_severe_fault) {
208+
/* Follow out of reset procedure */
209+
bh_chip_reset_chip(chip, true);
210+
/* Clear board fault */
211+
gpio_pin_set_dt(&board_fault_led, 0);
212+
chip->data.pgood_rise_triggered = false;
213+
}
214+
}

0 commit comments

Comments
 (0)