Skip to content

Commit b85a8a7

Browse files
committed
board input power: rename instances of "pwr" to "power"
Replace the abbreviation "pwr" with "power" to improve readability. Signed-off-by: Petra Alexson <[email protected]>
1 parent e868817 commit b85a8a7

File tree

13 files changed

+108
-54
lines changed

13 files changed

+108
-54
lines changed

app/dmc/src/main.c

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

130-
void ina228_pwr_update(void)
130+
void ina228_power_update(void)
131131
{
132132
struct sensor_value sensor_val;
133133

@@ -137,11 +137,11 @@ void ina228_pwr_update(void)
137137
int32_t power = (sensor_val.val1 << 16) + (sensor_val.val2 * 65536ULL) / 1000000ULL;
138138

139139
ARRAY_FOR_EACH_PTR(BH_CHIPS, chip) {
140-
bh_chip_set_input_pwr(chip, &power);
140+
bh_chip_set_input_power(chip, &power);
141141
}
142142
}
143143

144-
uint16_t detect_max_pwr(void)
144+
uint16_t detect_max_power(void)
145145
{
146146
static const struct gpio_dt_spec psu_sense0 =
147147
GPIO_DT_SPEC_GET_OR(DT_PATH(psu_sense0), gpios, {0});
@@ -154,28 +154,28 @@ uint16_t detect_max_pwr(void)
154154
int sense0_val = gpio_pin_get_dt(&psu_sense0);
155155
int sense1_val = gpio_pin_get_dt(&psu_sense1);
156156

157-
uint16_t psu_pwr;
157+
uint16_t psu_power;
158158

159159
if (!sense0_val && !sense1_val) {
160-
psu_pwr = 600;
160+
psu_power = 600;
161161
} else if (sense0_val && !sense1_val) {
162-
psu_pwr = 450;
162+
psu_power = 450;
163163
} else if (!sense0_val && sense1_val) {
164-
psu_pwr = 300;
164+
psu_power = 300;
165165
} else {
166166
/* Pins could either be open or shorted together */
167167
/* Pull down one and check the other */
168168
gpio_pin_configure_dt(&psu_sense0, GPIO_OUTPUT_LOW);
169169
if (!gpio_pin_get_dt(&psu_sense1)) {
170170
/* If shorted together then max power is 150W */
171-
psu_pwr = 150;
171+
psu_power = 150;
172172
} else {
173-
psu_pwr = 0;
173+
psu_power = 0;
174174
}
175175
gpio_pin_configure_dt(&psu_sense0, GPIO_INPUT);
176176
}
177177

178-
return psu_pwr;
178+
return psu_power;
179179
}
180180

181181
int main(void)
@@ -298,7 +298,7 @@ int main(void)
298298
dmStaticInfo static_info =
299299
(dmStaticInfo){.version = 1, .bl_version = 0, .app_version = APPVERSION};
300300

301-
uint16_t max_pwr = detect_max_pwr();
301+
uint16_t max_power = detect_max_power();
302302

303303
while (true) {
304304
tt_event_wait(TT_EVENT_WAKE, K_MSEC(20));
@@ -341,14 +341,14 @@ int main(void)
341341
ARRAY_FOR_EACH_PTR(BH_CHIPS, chip) {
342342
if (chip->data.arc_needs_init_msg) {
343343
if (bh_chip_set_static_info(chip, &static_info) == 0 &&
344-
bh_chip_set_board_pwr_lim(chip, max_pwr) == 0) {
344+
bh_chip_set_input_power_lim(chip, max_power) == 0) {
345345
chip->data.arc_needs_init_msg = false;
346346
}
347347
}
348348
}
349349

350350
if (IS_ENABLED(CONFIG_INA228)) {
351-
ina228_pwr_update();
351+
ina228_power_update();
352352
}
353353

354354
if (IS_ENABLED(CONFIG_TT_FAN_CTRL)) {

include/tenstorrent/bh_chip.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ 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);
120+
int bh_chip_set_input_power(struct bh_chip *chip, uint32_t *power);
121+
int bh_chip_set_input_power_lim(struct bh_chip *chip, uint16_t max_power);
122122
int bh_chip_set_fan_rpm(struct bh_chip *chip, uint16_t rpm);
123123

124124
void bh_chip_assert_asic_reset(const struct bh_chip *chip);

lib/tenstorrent/bh_arc/aiclk_ppm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ typedef enum {
1414
kAiclkArbMaxFastTDC,
1515
kAiclkArbMaxTDC,
1616
kAiclkArbMaxThm,
17-
kAiclkArbMaxBoardPwr,
17+
kAiclkArbMaxBoardPower,
1818
kAiclkArbMaxVoltage,
1919
kAiclkArbMaxGDDRThm,
2020
kAiclkArbMaxCount,

lib/tenstorrent/bh_arc/cm2bm_msg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ int32_t Bm2CmPingHandler(const uint8_t *data, uint8_t size)
224224
return 0;
225225
}
226226

227+
227228
int32_t Bm2CmSendCurrentHandler(const uint8_t *data, uint8_t size)
228229
{
229230
if (size != 4) {
@@ -235,7 +236,7 @@ int32_t Bm2CmSendCurrentHandler(const uint8_t *data, uint8_t size)
235236
return 0;
236237
}
237238

238-
int32_t Bm2CmSendPwrHandler(const uint8_t *data, uint8_t size)
239+
int32_t Bm2CmSendPowerHandler(const uint8_t *data, uint8_t size)
239240
{
240241
if (size != 4) {
241242
return -1;

lib/tenstorrent/bh_arc/cm2bm_msg.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2024 Tenstorrent AI ULC
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef CM2BM_MSG_H
7+
#define CM2BM_MSG_H
8+
9+
#include <stdint.h>
10+
#include <zephyr/toolchain.h>
11+
12+
typedef enum {
13+
kCm2BmMsgIdNull = 0,
14+
kCm2BmMsgIdResetReq = 1,
15+
kCm2BmMsgIdPing = 2,
16+
kCm2BmMsgIdFanSpeedUpdate = 3,
17+
} Cm2BmMsgId;
18+
19+
typedef struct {
20+
uint8_t msg_id;
21+
uint32_t data;
22+
} Cm2BmMsg;
23+
24+
typedef struct {
25+
uint8_t msg_id;
26+
uint8_t seq_num;
27+
uint32_t data;
28+
} __packed Cm2BmSmbusReqMsg;
29+
30+
typedef struct {
31+
uint8_t msg_id;
32+
uint8_t seq_num;
33+
} __packed Cm2BmSmbusAckMsg;
34+
35+
int32_t EnqueueCm2BmMsg(const Cm2BmMsg *msg);
36+
int32_t Cm2BmMsgReqSmbusHandler(uint8_t *data, uint8_t size);
37+
int32_t Cm2BmMsgAckSmbusHandler(const uint8_t *data, uint8_t size);
38+
int32_t ResetBoardByte(uint8_t *data, uint8_t size);
39+
40+
void ChipResetRequest(void *arg);
41+
void UpdateFanSpeedRequest(uint32_t fan_speed);
42+
43+
typedef struct bmStaticInfo {
44+
/* Non-zero for valid data */
45+
/* Allows for breaking changes */
46+
uint32_t version;
47+
uint32_t bl_version;
48+
uint32_t app_version;
49+
} __packed bmStaticInfo;
50+
51+
int32_t Bm2CmSendDataHandler(const uint8_t *data, uint8_t size);
52+
int32_t Bm2CmPingHandler(const uint8_t *data, uint8_t size);
53+
int32_t Bm2CmSendCurrentHandler(const uint8_t *data, uint8_t size);
54+
int32_t Bm2CmSendPowerHandler(const uint8_t *data, uint8_t size);
55+
int32_t GetInputCurrent(void);
56+
uint32_t GetInputPower(void);
57+
int32_t Bm2CmSendFanRPMHandler(const uint8_t *data, uint8_t size);
58+
59+
#endif

lib/tenstorrent/bh_arc/cm2dm_msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ int32_t Dm2CmPingHandler(const uint8_t *data, uint8_t size)
230230
return 0;
231231
}
232232

233-
int32_t Dm2CmSendPwrHandler(const uint8_t *data, uint8_t size)
233+
int32_t Dm2CmSendPowerHandler(const uint8_t *data, uint8_t size)
234234
{
235235
if (size != 4) {
236236
return -1;

lib/tenstorrent/bh_arc/cm2dm_msg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef struct dmStaticInfo {
5353
int32_t Dm2CmSendDataHandler(const uint8_t *data, uint8_t size);
5454
int32_t Dm2CmPingHandler(const uint8_t *data, uint8_t size);
5555
int32_t Dm2CmSendCurrentHandler(const uint8_t *data, uint8_t size);
56-
int32_t Dm2CmSendPwrHandler(const uint8_t *data, uint8_t size);
56+
int32_t Dm2CmSendPowerHandler(const uint8_t *data, uint8_t size);
5757
int32_t GetInputCurrent(void);
5858
uint32_t GetInputPower(void);
5959
int32_t Dm2CmSendFanRPMHandler(const uint8_t *data, uint8_t size);

lib/tenstorrent/bh_arc/smbus_target.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ static SmbusConfig smbus_config = {
174174
#ifndef CONFIG_TT_SMC_RECOVERY
175175
[0x24] = {.valid = 1,
176176
.trans_type = kSmbusTransWriteWord,
177-
.handler = {.rcv_handler = &Dm2CmSetBoardPwrLimit}},
177+
.handler = {.rcv_handler = &Dm2CmSetBoardPowerLimit}},
178178
[0x25] = {
179179
.valid = 1,
180180
.trans_type = kSmbusTransBlockWrite,
181181
.expected_blocksize = 4,
182182
.handler = {
183-
.rcv_handler = &Dm2CmSendPwrHandler
183+
.rcv_handler = &Dm2CmSendPowerHandler
184184
}},
185185
#endif
186186
[0xD8] = {.valid = 1,

lib/tenstorrent/bh_arc/telemetry.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static void update_tag_table(void)
321321
tag_table[47] = (struct telemetry_entry){TAG_GDDR_UNCORR_ERRS, GDDR_UNCORR_ERRS};
322322
tag_table[48] = (struct telemetry_entry){TAG_MAX_GDDR_TEMP, MAX_GDDR_TEMP};
323323
tag_table[49] = (struct telemetry_entry){TAG_ASIC_LOCATION, ASIC_LOCATION};
324-
tag_table[50] = (struct telemetry_entry){TAG_BOARD_PWR_LIMIT, BOARD_PWR_LIMIT};
324+
tag_table[50] = (struct telemetry_entry){TAG_BOARD_POWER_LIMIT, BOARD_POWER_LIMIT};
325325
tag_table[51] = (struct telemetry_entry){TAG_INPUT_POWER, INPUT_POWER};
326326
tag_table[52] = (struct telemetry_entry){TAG_TELEM_ENUM_COUNT, TELEM_ENUM_COUNT};
327327
}
@@ -381,7 +381,7 @@ void UpdateTelemetryNocTranslation(bool translation_enabled)
381381
telemetry[NOC_TRANSLATION] = translation_enabled;
382382
}
383383

384-
void UpdateTelemetryBoardPwrLimit(uint32_t pwr_limit)
384+
void UpdateTelemetryBoardPowerLimit(uint32_t power_limit)
385385
{
386-
telemetry[BOARD_PWR_LIMIT] = pwr_limit;
386+
telemetry[BOARD_POWER_LIMIT] = power_limit;
387387
}

lib/tenstorrent/bh_arc/telemetry.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
#define TAG_GDDR_UNCORR_ERRS 50
6868
#define TAG_MAX_GDDR_TEMP 51
6969
#define TAG_ASIC_LOCATION 52
70-
#define TAG_BOARD_PWR_LIMIT 53
71-
#define TAG_INPUT_POWER 54
70+
#define TAG_BOARD_POWER_LIMIT 53
71+
#define TAG_INPUT_POWER 54
7272

7373
/* Enums are subject to updates */
7474
typedef enum {
@@ -123,7 +123,7 @@ typedef enum {
123123
/* Board telemetry */
124124
FAN_SPEED,
125125
FAN_RPM,
126-
BOARD_PWR_LIMIT,
126+
BOARD_POWER_LIMIT,
127127
INPUT_POWER,
128128

129129
/* Tile enablement/harvesting information */
@@ -160,6 +160,6 @@ int GetMaxGDDRTemp(void);
160160
void StartTelemetryTimer(void);
161161
void UpdateDmFwVersion(uint32_t bl_version, uint32_t app_version);
162162
void UpdateTelemetryNocTranslation(bool translation_enabled);
163-
void UpdateTelemetryBoardPwrLimit(uint32_t pwr_limit);
163+
void UpdateTelemetryBoardPowerLimit(uint32_t power_limit);
164164

165165
#endif

0 commit comments

Comments
 (0)