Skip to content

Commit 24cc827

Browse files
jostar-yangJostar Yang
and
Jostar Yang
authored
[as4630-54pe] Modify to read correct psu SN and ID (#5389)
Co-authored-by: Jostar Yang <[email protected]>
1 parent a3a7944 commit 24cc827

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-psu.c

+24-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <linux/dmi.h>
3636

3737
#define MAX_MODEL_NAME 20
38-
#define MAX_SERIAL_NUMBER 18
38+
#define MAX_SERIAL_NUMBER 19
3939

4040
static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf);
4141
static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf);
@@ -90,8 +90,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da,
9090
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
9191
struct as4630_54pe_psu_data *data = as4630_54pe_psu_update_device(dev);
9292
u8 status = 0;
93-
94-
//printk("data->status=0x%x, attr->index=%d,data->index=%d \n", data->status, attr->index, data->index);
93+
9594
if (attr->index == PSU_PRESENT) {
9695
if(data->index==0)
9796
status = !( (data->status >> 5) & 0x1);
@@ -267,7 +266,6 @@ static struct as4630_54pe_psu_data *as4630_54pe_psu_update_device(struct device
267266

268267
/* Read psu status */
269268
status = as4630_54pe_cpld_read(0x60, 0x22);
270-
//printk("status=0x%x in %s\n", status, __FUNCTION__);
271269
if (status < 0) {
272270
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
273271
}
@@ -286,21 +284,36 @@ static struct as4630_54pe_psu_data *as4630_54pe_psu_update_device(struct device
286284
if (status < 0) {
287285
data->model_name[0] = '\0';
288286
dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr);
289-
printk("unable to read model name from (0x%x)\n", client->addr);
290287
}
291-
else {
288+
else if(!strncmp(data->model_name, "YPEB1200", strlen("YPEB1200")))
289+
{
290+
if (data->model_name[9]=='A' && data->model_name[10]=='M')
291+
{
292+
data->model_name[8]='A';
293+
data->model_name[9]='M';
294+
data->model_name[strlen("YPEB1200AM")]='\0';
295+
}
296+
else
297+
data->model_name[strlen("YPEB1200")]='\0';
298+
}
299+
else
300+
{
292301
data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0';
293-
294302
}
295-
/* Read from offset 0x2e ~ 0x3d (16 bytes) */
303+
/* Read from offset 0x35 ~ 0x46 (18 bytes) */
296304
status = as4630_54pe_psu_read_block(client, 0x35,data->serial_number, MAX_SERIAL_NUMBER);
297305
if (status < 0)
298306
{
299307
data->serial_number[0] = '\0';
300-
dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x2e)\n", client->addr);
301-
printk("unable to read model name from (0x%x) offset(0x2e)\n", client->addr);
308+
dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x35)\n", client->addr);
309+
}
310+
if (!strncmp(data->model_name, "YPEB1200AM", strlen("YPEB1200AM"))) /*for YPEB1200AM, SN length=18*/
311+
{
312+
data->serial_number[MAX_SERIAL_NUMBER-1]='\0';
302313
}
303-
data->serial_number[MAX_SERIAL_NUMBER-1]='\0';
314+
else
315+
data->serial_number[MAX_SERIAL_NUMBER-2]='\0';
316+
304317
}
305318

306319
data->last_updated = jiffies;

platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_monitor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
try:
2323
import commands
24-
import getopt
25-
import sys
24+
import getopt, sys
2625
import logging
2726
import logging.config
2827
import logging.handlers

0 commit comments

Comments
 (0)