Skip to content

Commit 571a18a

Browse files
StanleyCilguohan
authored andcommitted
[Delta ag9032v1]Add attributes for cpupld and swpld. (#1437)
Signed-off-by: Stanley Chi <[email protected]>
1 parent 1e6576c commit 571a18a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

platform/broadcom/sonic-platform-modules-delta/ag9032v1/modules/delta_ag9032v1_platform.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ enum cpld_type {
583583
struct cpld_platform_data {
584584
int reg_addr;
585585
struct i2c_client *client;
586-
//struct kobject *kobj;
587586
};
588587

589588
enum swpld_attributes {
@@ -672,7 +671,7 @@ static struct platform_device ag9032v1_cpld = {
672671
.id = 0,
673672
.dev = {
674673
.platform_data = ag9032v1_cpld_platform_data,
675-
.release = device_release
674+
.release = device_release,
676675
},
677676
};
678677

@@ -1547,6 +1546,7 @@ static struct attribute_group ag9032v1_cpld_attr_grp = {
15471546
.attrs = ag9032v1_cpld_attrs,
15481547
};
15491548

1549+
static struct kobject *kobj_swpld;
15501550
static struct kobject *kobj_board;
15511551
static struct kobject *kobj_psu;
15521552
static struct kobject *kobj_hot_swap;
@@ -1557,8 +1557,10 @@ static ssize_t get_swpld_data(struct device *dev, struct device_attribute *dev_a
15571557
{
15581558
int ret;
15591559
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
1560-
struct device *i2cdev = kobj_to_dev(kobj_board->parent);
1560+
struct device *i2cdev = kobj_to_dev(kobj_swpld);
15611561
struct cpld_platform_data *pdata = i2cdev->platform_data;
1562+
1563+
15621564
unsigned char reg;
15631565
int mask;
15641566
int value;
@@ -1572,33 +1574,29 @@ static ssize_t get_swpld_data(struct device *dev, struct device_attribute *dev_a
15721574
value = ret >> 4;
15731575
sprintf(note, "\n“0x00”: L9032NB-AL-R\n“0x01”: AK9032-R\n“0x02”: AG9032-R\n“0x03”: AG9032R-R\n“0x04”: AG9032 V1-R\n");
15741576
return sprintf(buf, "0x%02x%s", value, note);
1575-
break;
15761577
case SW_BOARD_VER:
15771578
reg = 0x00;
15781579
ret = i2c_smbus_read_byte_data(pdata[system_cpld].client, reg);
15791580
value = ret & 0x0F;
15801581
sprintf(note, "\n“0x00”: proto-A\n“0x01”: proto-B\n");
15811582
return sprintf(buf, "0x%02x%s", value, note);
1582-
break;
15831583
case SWPLD_VER:
15841584
reg = 0x01;
15851585
ret = i2c_smbus_read_byte_data(pdata[system_cpld].client, reg);
15861586
value = ret & 0xFF;
15871587
sprintf(note, " ");
15881588
return sprintf(buf, "0x%02x%s", value, note);
1589-
break;
15901589
//other attributes
15911590
case SYS_RST ... QSFP32_MOD_INT:
15921591
reg = controller_interrupt_data[attr->index].reg_addr;
15931592
mask = controller_interrupt_data[attr->index].reg_mask;
15941593
sprintf(note, "\n%s\n",controller_interrupt_data[attr->index].reg_note);
1595-
break;
1594+
ret = i2c_smbus_read_byte_data(pdata[system_cpld].client, reg);
1595+
value = (ret & (1 << mask)) >> mask;
1596+
return sprintf(buf, "%d%s", value, note);
15961597
default:
15971598
return sprintf(buf, "%d not found", attr->index);
15981599
}
1599-
ret = i2c_smbus_read_byte_data(pdata[system_cpld].client, reg);
1600-
value = (ret & (1 << mask)) >> mask;
1601-
return sprintf(buf, "%d%s", value, note);
16021600
}
16031601

16041602
static ssize_t set_swpld_data(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count)
@@ -1633,7 +1631,6 @@ static ssize_t set_swpld_data(struct device *dev, struct device_attribute *dev_a
16331631
case QSFP_01TO08_MASK_INT... QSFP_25TO32_MASK_ABS:
16341632
reg = controller_interrupt_data[attr->index].reg_addr;
16351633
mask = controller_interrupt_data[attr->index].reg_mask;
1636-
sprintf(note, "\n%s\n",controller_interrupt_data[attr->index].reg_note);
16371634
break;
16381635
default:
16391636
return sprintf(buf, "%d not found", attr->index);
@@ -1856,6 +1853,7 @@ static int __init cpld_probe(struct platform_device *pdev)
18561853
goto error;
18571854
}
18581855

1856+
kobj_swpld = &pdev->dev.kobj;
18591857
kobj_board = kobject_create_and_add("Board", &pdev->dev.kobj);
18601858
if (!kobj_board){
18611859
printk(KERN_WARNING "Fail to create directory");
@@ -1925,6 +1923,7 @@ static int __init cpld_probe(struct platform_device *pdev)
19251923
return 0;
19261924

19271925
error:
1926+
kobject_put(kobj_swpld);
19281927
kobject_put(kobj_board);
19291928
kobject_put(kobj_psu);
19301929
kobject_put(kobj_hot_swap);
@@ -1947,6 +1946,7 @@ static int __exit cpld_remove(struct platform_device *pdev)
19471946
dev_err(&pdev->dev, "Missing platform data\n");
19481947
}
19491948
else {
1949+
kobject_put(kobj_swpld);
19501950
kobject_put(kobj_board);
19511951
kobject_put(kobj_psu);
19521952
kobject_put(kobj_hot_swap);
@@ -2266,7 +2266,7 @@ static void __init delta_ag9032v1_platform_init(void)
22662266
struct i2c_client *client;
22672267
struct i2c_adapter *adapter;
22682268
struct cpld_platform_data *cpld_pdata;
2269-
struct swpld_mux_platform_data *swpld_pdata;
2269+
struct swpld_mux_platform_data *swpld_mux_pdata;
22702270
int ret,i = 0;
22712271
printk("ag9032v1_platform module initialization\n");
22722272

@@ -2308,8 +2308,8 @@ static void __init delta_ag9032v1_platform_init(void)
23082308

23092309
for (i = 0; i < ARRAY_SIZE(ag9032v1_swpld_mux); i++)
23102310
{
2311-
swpld_pdata = ag9032v1_swpld_mux[i].dev.platform_data;
2312-
swpld_pdata->cpld = cpld_pdata[system_cpld].client;
2311+
swpld_mux_pdata = ag9032v1_swpld_mux[i].dev.platform_data;
2312+
swpld_mux_pdata->cpld = cpld_pdata[system_cpld].client;
23132313
ret = platform_device_register(&ag9032v1_swpld_mux[i]);
23142314
if (ret) {
23152315
printk(KERN_WARNING "Fail to create swpld mux %d\n", i);

0 commit comments

Comments
 (0)