Skip to content

Commit 784b985

Browse files
authored
Merge pull request #953 from WillyLiu-EC/as7535_28xb_add_new_thermal
[Edgecore][AS7535-28XB] Support R01 version DUT with 6 thermals and R02 version DUT with 8 thermals
2 parents 3c3c9e0 + 5cf7eb1 commit 784b985

6 files changed

Lines changed: 205 additions & 22 deletions

File tree

packages/platforms/accton/x86-64/as7535-28xb/modules/builds/x86-64-accton-as7535-28xb-thermal.c

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define DRVNAME "as7535_28xb_thermal"
3636
#define ACCTON_IPMI_NETFN 0x34
3737
#define IPMI_THERMAL_READ_CMD 0x12
38+
#define IPMI_FPGA_READ_CMD 0x22
3839

3940
#define IPMI_TIMEOUT (5 * HZ)
4041
#define IPMI_ERR_RETRY_TIMES 1
@@ -47,6 +48,9 @@ static ssize_t set_max(struct device *dev, struct device_attribute *da,
4748
static int as7535_28xb_thermal_probe(struct platform_device *pdev);
4849
static int as7535_28xb_thermal_remove(struct platform_device *pdev);
4950

51+
static int get_pcb_id(void);
52+
static int g_pcb_id = 0;
53+
5054
enum temp_data_index {
5155
TEMP_ADDR,
5256
TEMP_FAULT,
@@ -95,17 +99,21 @@ static struct platform_driver as7535_28xb_thermal_driver = {
9599

96100
enum as7535_28xb_thermal_sysfs_attrs {
97101
TEMP1_INPUT, // 0x4B
98-
TEMP2_INPUT, // 0x4C tmp43 local
99-
TEMP3_INPUT, // 0x4C tmp43 remote
102+
TEMP2_INPUT, // TMP431_0x4C_U50
103+
TEMP3_INPUT, // TMP431_0x4C_MAC
100104
TEMP4_INPUT, // 0x4D lm75
101105
TEMP5_INPUT, // 0x4E lm75
102106
TEMP6_INPUT, // 0x4F lm75
107+
TEMP7_INPUT, // TMP431_0x4C_U93
108+
TEMP8_INPUT, // TMP431_0x4C_C10
103109
TEMP1_MAX,
104110
TEMP2_MAX,
105111
TEMP3_MAX,
106112
TEMP4_MAX,
107113
TEMP5_MAX,
108-
TEMP6_MAX
114+
TEMP6_MAX,
115+
TEMP7_MAX,
116+
TEMP8_MAX
109117
};
110118

111119
// Read only temp_input
@@ -125,6 +133,8 @@ DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(3);
125133
DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(4);
126134
DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(5);
127135
DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(6);
136+
DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(7);
137+
DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(8);
128138

129139
static struct attribute *as7535_28xb_thermal_attributes[] = {
130140
DECLARE_THERMAL_ATTR(1),
@@ -133,6 +143,8 @@ static struct attribute *as7535_28xb_thermal_attributes[] = {
133143
DECLARE_THERMAL_ATTR(4),
134144
DECLARE_THERMAL_ATTR(5),
135145
DECLARE_THERMAL_ATTR(6),
146+
DECLARE_THERMAL_ATTR(7),
147+
DECLARE_THERMAL_ATTR(8),
136148
NULL
137149
};
138150

@@ -276,28 +288,63 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
276288
complete(&ipmi->read_complete);
277289
}
278290

291+
static int get_pcb_id(void)
292+
{
293+
int status = 0;
294+
int pcb_id = 0;
295+
/* Get PCB ID */
296+
data->ipmi_tx_data[0] = 0x60;
297+
data->ipmi_tx_data[1] = 0x0;
298+
status = ipmi_send_message(&data->ipmi, IPMI_FPGA_READ_CMD, data->ipmi_tx_data, 2,
299+
data->ipmi_resp, sizeof(data->ipmi_resp));
300+
if (unlikely(status != 0))
301+
goto exit;
302+
303+
if (unlikely(data->ipmi.rx_result != 0)) {
304+
status = -EIO;
305+
goto exit;
306+
}
307+
/* (bit 3, bit 2) 00: No C10+IDT, 01: CY10+IDT, 10: no CY10+microchip, 11: CY10+microchip
308+
Support 8 thermals for CY10+IDT */
309+
pcb_id = (((s8)data->ipmi_resp[0]) >> 2) & 0xff;
310+
return pcb_id;
311+
312+
exit:
313+
return status;
314+
}
315+
279316
static ssize_t show_temp(struct device *dev, struct device_attribute *da,
280317
char *buf)
281318
{
282319
int status = 0;
283320
int index = 0;
284321
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
285-
286322
mutex_lock(&data->update_lock);
287-
288-
if (attr->index >= TEMP1_MAX && attr->index <= TEMP6_MAX) {
323+
if (attr->index >= TEMP1_MAX && attr->index <= TEMP8_MAX) {
289324
int max = data->temp_max[attr->index - TEMP1_MAX];
290325
mutex_unlock(&data->update_lock);
291326
return sprintf(buf, "%d\n", max * 1000);
292327
}
328+
/* Set 0 to Temp 7 and 8 if pcb id is not 01: CY10+IDT */
329+
if (g_pcb_id != 1)
330+
{
331+
if ((attr->index == TEMP7_INPUT) || (attr->index == TEMP8_INPUT))
332+
{
333+
status = 0;
334+
mutex_unlock(&data->update_lock);
335+
return sprintf(buf, "%d\n", status);
336+
}
337+
}
293338

294339
if (time_after(jiffies, data->last_updated + HZ * 5) || !data->valid) {
295340
data->valid = 0;
296341

297342
status = ipmi_send_message(&data->ipmi, IPMI_THERMAL_READ_CMD, NULL, 0,
298343
data->ipmi_resp, sizeof(data->ipmi_resp));
299344
if (unlikely(status != 0))
345+
{
300346
goto exit;
347+
}
301348

302349
if (unlikely(data->ipmi.rx_result != 0)) {
303350
status = -EIO;
@@ -307,14 +354,12 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
307354
data->last_updated = jiffies;
308355
data->valid = 1;
309356
}
310-
311357
/* Get temp fault status */
312358
index = attr->index * TEMP_DATA_COUNT + TEMP_FAULT;
313359
if (unlikely(data->ipmi_resp[index] == 0)) {
314360
status = -EIO;
315361
goto exit;
316362
}
317-
318363
/* Get temperature in degree celsius */
319364
index = attr->index * TEMP_DATA_COUNT + TEMP_INPUT;
320365
status = ((s8)data->ipmi_resp[index]) * 1000;
@@ -402,6 +447,8 @@ static int __init as7535_28xb_thermal_init(void)
402447
data->temp_max[i] = 70; /* default high threshold */
403448
}
404449

450+
g_pcb_id = get_pcb_id();
451+
405452
return 0;
406453

407454
ipmi_err:

packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src/platform_lib.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,25 @@ enum onlp_fan_dir onlp_get_fan_dir(int fid)
5858
AIM_FREE_IF_PTR(str);
5959
return dir;
6060
}
61+
62+
int get_pcb_id()
63+
{
64+
FILE *pf;
65+
char command[32];
66+
char data[8];
67+
int pcb_id = 0;
68+
69+
sprintf(command, "ipmitool raw 0x34 0x22 0x60 0");
70+
pf = popen(command,"r");
71+
fgets(data, 8 , pf);
72+
73+
if (pclose(pf) != 0)
74+
{
75+
fprintf(stderr," Error: Failed to close command stream \n");
76+
return ONLP_STATUS_E_INTERNAL;
77+
}
78+
/* get the pcb id to check the thermal number */
79+
pcb_id = (atoi(data) >> 2) & 0xff;
80+
81+
return pcb_id;
82+
}

packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src/platform_lib.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#define CHASSIS_FAN_COUNT 6
3232
#define CHASSIS_THERMAL_COUNT 7
33+
#define CHASSIS_THERMAL_COUNT_R02 9
3334
#define CHASSIS_LED_COUNT 6
3435
#define CHASSIS_PSU_COUNT 2
3536
#define NUM_OF_THERMAL_PER_PSU 3
@@ -42,6 +43,8 @@
4243
#define SYS_LED_PATH "/sys/devices/platform/as7535_28xb_led/"
4344
#define IDPROM_PATH "/sys/devices/platform/as7535_28xb_sys/eeprom"
4445

46+
int get_pcb_id();
47+
4548
enum onlp_thermal_id {
4649
THERMAL_RESERVED = 0,
4750
THERMAL_CPU_CORE,
@@ -51,6 +54,8 @@ enum onlp_thermal_id {
5154
THERMAL_4_ON_MAIN_BROAD,
5255
THERMAL_5_ON_MAIN_BROAD,
5356
THERMAL_6_ON_MAIN_BROAD,
57+
THERMAL_7_ON_MAIN_BROAD,
58+
THERMAL_8_ON_MAIN_BROAD,
5459
THERMAL_1_ON_PSU1,
5560
THERMAL_2_ON_PSU1,
5661
THERMAL_3_ON_PSU1,

packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src/psui.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
6363
int ret = ONLP_STATUS_OK;
6464
int pid = ONLP_OID_ID_GET(id);
6565
VALIDATE(id);
66+
int pcb_id = 0;
67+
int thermal_count = 0;
6668

6769
memset(info, 0, sizeof(onlp_psu_info_t));
6870
*info = pinfo[pid]; /* Set the onlp_oid_hdr_t */
@@ -102,12 +104,15 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
102104
info->caps = ONLP_PSU_CAPS_AC;
103105

104106
/* Set the associated oid_table */
105-
info->hdr.coids[0] = ONLP_THERMAL_ID_CREATE(CHASSIS_THERMAL_COUNT +
106-
(pid-1)*NUM_OF_THERMAL_PER_PSU + 1);
107-
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(CHASSIS_THERMAL_COUNT +
108-
(pid-1)*NUM_OF_THERMAL_PER_PSU + 2);
109-
info->hdr.coids[2] = ONLP_THERMAL_ID_CREATE(CHASSIS_THERMAL_COUNT +
110-
(pid-1)*NUM_OF_THERMAL_PER_PSU + 3);
107+
pcb_id = get_pcb_id();
108+
if (pcb_id == 1)
109+
thermal_count = CHASSIS_THERMAL_COUNT_R02;
110+
else
111+
thermal_count = CHASSIS_THERMAL_COUNT;
112+
113+
info->hdr.coids[0] = ONLP_THERMAL_ID_CREATE(thermal_count + (pid-1)*NUM_OF_THERMAL_PER_PSU + 1);
114+
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(thermal_count + (pid-1)*NUM_OF_THERMAL_PER_PSU + 2);
115+
info->hdr.coids[2] = ONLP_THERMAL_ID_CREATE(thermal_count + (pid-1)*NUM_OF_THERMAL_PER_PSU + 3);
111116
info->hdr.coids[3] = ONLP_FAN_ID_CREATE(pid + CHASSIS_FAN_COUNT);
112117

113118
/* Read voltage, current and power */

packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src/sysi.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,22 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max)
7070
int i;
7171
onlp_oid_t* e = table;
7272
memset(table, 0, max*sizeof(onlp_oid_t));
73-
74-
/* 8 Thermal sensors on the chassis */
75-
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) {
76-
*e++ = ONLP_THERMAL_ID_CREATE(i);
73+
int pcb_id = 0;
74+
75+
pcb_id = get_pcb_id();
76+
if (pcb_id == 1)
77+
{
78+
/* 9 Thermal sensors on the chassis */
79+
for (i = 1; i <= CHASSIS_THERMAL_COUNT_R02; i++) {
80+
*e++ = ONLP_THERMAL_ID_CREATE(i);
81+
}
82+
}
83+
else
84+
{
85+
/* 7 Thermal sensors on the chassis */
86+
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) {
87+
*e++ = ONLP_THERMAL_ID_CREATE(i);
88+
}
7789
}
7890

7991
/* 5 LEDs on the chassis */

0 commit comments

Comments
 (0)