Skip to content

Commit ec4ea65

Browse files
author
fishtan
committed
According the review comment, we use Linux native driver for sfp and optoe.
1 parent 2015066 commit ec4ea65

File tree

14 files changed

+625
-4562
lines changed

14 files changed

+625
-4562
lines changed

device/inspur/x86_64-inspur_sc5630el-r0/plugins/sfputil.py

Lines changed: 523 additions & 408 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"skip_thermalctld": true,
3+
"skip_syseepromd": true,
4+
"skip_fancontrol": true,
5+
"skip_ledd": true
6+
}

platform/broadcom/sonic-platform-modules-inspur/sc5630el/modules/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ COMMON_DIR := ../../common
22
COMMON_OBJS := $(COMMON_DIR)/ipmi_util.o
33
EXTRA_CFLAGS += -I$(obj)/$(COMMON_DIR)
44

5-
obj-m := insp_sc5630el_psu.o insp_sc5630el_sfp.o insp_sc5630el_eeprom.o inspur_sc5630el_platform.o inspur-pca9641.o inspur_psu.o inspur_sc5630el_cpld.o inspur_sc5630el_optoe.o inspur_sc5630el_sfpio.o
5+
obj-m := insp_sc5630el_psu.o insp_sc5630el_sfp.o insp_sc5630el_eeprom.o inspur_sc5630el_platform.o inspur-pca9641.o inspur_psu.o inspur_sc5630el_cpld.o
66
insp_sc5630el_psu-objs := inspur_sc5630el_psu.o $(COMMON_OBJS)
77
insp_sc5630el_sfp-objs := inspur_sc5630el_sfp.o $(COMMON_OBJS)
88
insp_sc5630el_eeprom-objs := inspur_sc5630el_eeprom.o $(COMMON_OBJS)

platform/broadcom/sonic-platform-modules-inspur/sc5630el/modules/inspur-pca9641.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
* I2C master demultiplexer driver for PCA9641
33
*
4-
* Copyright (c) 2010 Ericsson AB.
4+
* Copyright (c) 2018 Inspur Electronic Information Industry Co.,Ltd
55
*
66
* Author: ChihPeiChang <[email protected]>
77
*
8-
* Derived from:
8+
* Derived from: pca9541.c
99
*
1010
* This file is licensed under the terms of the GNU General Public
1111
* License version 2. This program is licensed "as is" without any

platform/broadcom/sonic-platform-modules-inspur/sc5630el/modules/inspur_psu.c

Lines changed: 7 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Based on pmbus_core driver and ltc2978 driver
66
*
7-
* Author:
7+
* History:
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License as published by
@@ -27,138 +27,16 @@
2727
#include <linux/err.h>
2828
#include <linux/slab.h>
2929
#include <linux/i2c.h>
30-
#include "pmbus.h"
3130
#include <linux/delay.h>
3231
#include <linux/pmbus.h>
32+
#include "pmbus.h" /* FIXME :based on pmbus_core need pmbus definition, but it would
33+
need to migrated when different version of kernel */
3334

3435

3536
enum id_name {
3637
ps2551
3738
};
3839

39-
#if 0
40-
#define DELAY_TIME 1000 /* uS */
41-
42-
/* Needed to access the mutex. Copied from pmbus_core.c */
43-
#define PB_STATUS_BASE 0
44-
#define PB_STATUS_VOUT_BASE (PB_STATUS_BASE + PMBUS_PAGES)
45-
#define PB_STATUS_IOUT_BASE (PB_STATUS_VOUT_BASE + PMBUS_PAGES)
46-
#define PB_STATUS_FAN_BASE (PB_STATUS_IOUT_BASE + PMBUS_PAGES)
47-
#define PB_STATUS_FAN34_BASE (PB_STATUS_FAN_BASE + PMBUS_PAGES)
48-
#define PB_STATUS_TEMP_BASE (PB_STATUS_FAN34_BASE + PMBUS_PAGES)
49-
#define PB_STATUS_INPUT_BASE (PB_STATUS_TEMP_BASE + PMBUS_PAGES)
50-
#define PB_STATUS_VMON_BASE (PB_STATUS_INPUT_BASE + 1)
51-
#define PB_NUM_STATUS_REG (PB_STATUS_VMON_BASE + 1)
52-
struct pmbus_data {
53-
struct device *dev;
54-
struct device *hwmon_dev;
55-
56-
u32 flags; /* from platform data */
57-
58-
int exponent[PMBUS_PAGES];
59-
/* linear mode: exponent for output voltages */
60-
61-
const struct pmbus_driver_info *info;
62-
63-
int max_attributes;
64-
int num_attributes;
65-
struct attribute_group group;
66-
const struct attribute_group *groups[2];
67-
68-
struct pmbus_sensor *sensors;
69-
70-
struct mutex update_lock;
71-
bool valid;
72-
unsigned long last_updated; /* in jiffies */
73-
74-
/*
75-
* A single status register covers multiple attributes,
76-
* so we keep them all together.
77-
*/
78-
u8 status[PB_NUM_STATUS_REG];
79-
u8 status_register;
80-
81-
u8 currpage;
82-
};
83-
84-
/*
85-
* Identify chip parameters.
86-
*/
87-
static int pmbus_identify(struct i2c_client *client,
88-
struct pmbus_driver_info *info)
89-
{
90-
int ret = 0;
91-
92-
if (!info->pages) {
93-
/*
94-
* Check if the PAGE command is supported. If it is,
95-
* keep setting the page number until it fails or until the
96-
* maximum number of pages has been reached. Assume that
97-
* this is the number of pages supported by the chip.
98-
*/
99-
if (pmbus_check_byte_register(client, 0, PMBUS_PAGE)) {
100-
int page;
101-
102-
for (page = 1; page < PMBUS_PAGES; page++) {
103-
if (pmbus_set_page(client, page) < 0)
104-
break;
105-
}
106-
pmbus_set_page(client, 0);
107-
info->pages = page;
108-
} else {
109-
info->pages = 1;
110-
}
111-
}
112-
113-
return ret;
114-
}
115-
116-
int pmbus_set_page(struct i2c_client *client, u8 page)
117-
{
118-
struct pmbus_data *data = i2c_get_clientdata(client);
119-
int rv = 0;
120-
int newpage;
121-
122-
if (page != data->currpage) {
123-
rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
124-
udelay(DELAY_TIME);
125-
newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
126-
if (newpage != page)
127-
rv = -EIO;
128-
else
129-
data->currpage = page;
130-
}
131-
return rv;
132-
}
133-
134-
int write_byte(struct i2c_client *client, int page, u8 value)
135-
{
136-
int rv;
137-
138-
if (page >= 0) {
139-
rv = pmbus_set_page(client, page);
140-
if (rv < 0)
141-
return rv;
142-
}
143-
144-
rv = i2c_smbus_write_byte(client, value);
145-
udelay(DELAY_TIME);
146-
return rv;
147-
}
148-
149-
int write_word_data(struct i2c_client *client, int page, int reg, u16 word)
150-
{
151-
int rv;
152-
153-
rv = pmbus_set_page(client, page);
154-
if (rv < 0)
155-
return rv;
156-
157-
rv = i2c_smbus_write_word_data(client, reg, word);
158-
udelay(DELAY_TIME);
159-
return rv;
160-
}
161-
#endif
16240

16341
static int pmbus_read_block(struct i2c_client *client, u8 command, int data_len, u8 *data)
16442
{
@@ -298,7 +176,7 @@ static struct attribute_group pmbus_inventory_attr_grp = {
298176
.attrs = pmbus_inventory_attrs
299177
};
300178

301-
/* FIXME: add project specific id here */
179+
/* FIXME: add psu specific id here */
302180
static const struct i2c_device_id pmbus_id[] = {
303181
{"ps2551", ps2551},
304182
{}
@@ -319,7 +197,7 @@ static int pmbus_probe(struct i2c_client *client,
319197
I2C_FUNC_SMBUS_READ_WORD_DATA))
320198
return -ENODEV;
321199

322-
info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info),
200+
info = devm_kzalloc(&client->dev, sizeof(*info),
323201
GFP_KERNEL);
324202

325203
if (!info)
@@ -342,30 +220,7 @@ static int pmbus_probe(struct i2c_client *client,
342220
;
343221
dev_info(dev, "inspur-psu pmbus_probe : info->func[0] %x \n", info->func[0]);
344222
break;
345-
/*
346-
case ly8:
347-
info->pages = 1;
348-
info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT
349-
| PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12
350-
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
351-
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
352-
;
353-
break;
354-
case ix1:
355-
case ix2:
356-
case ix1b:
357-
info->pages = 1;
358-
info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
359-
| PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT
360-
| PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12
361-
| PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
362-
| PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP
363-
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
364-
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
365-
| PMBUS_HAVE_POUT
366-
;
367-
break;
368-
*/
223+
369224
default:
370225
break;
371226
}
@@ -400,7 +255,7 @@ static struct i2c_driver pmbus_driver = {
400255
module_i2c_driver(pmbus_driver);
401256

402257

403-
MODULE_AUTHOR("switchsupport@inspur.com");
258+
MODULE_AUTHOR("sdn@inspur.com");
404259
MODULE_VERSION("1.0");
405260
MODULE_DESCRIPTION("SONiC platform driver for Inspur PSU");
406261
MODULE_LICENSE("GPL");

platform/broadcom/sonic-platform-modules-inspur/sc5630el/modules/inspur_sc5630el_cpld.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@
126126
*/
127127
#define SYS_OS_LED_REG 0x1E
128128
#define SYS_OS_LED_BITS 0x1
129-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
130129
#define SYS_PORT_LED_BITS 0x4
131-
#endif
132130

133131
//Port Reset register
134132
#define PORT_RESET_REG 0xE
@@ -301,9 +299,7 @@ enum sysfs_cpld_attributes {
301299
R54210_2_RESET,
302300
R5387_RESET,
303301
DEBUG_RESET,
304-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
305302
PORT_CONTROL,
306-
#endif
307303
};
308304

309305
/* ------------------------------------------------------------------------------
@@ -331,11 +327,7 @@ static SENSOR_DEVICE_ATTR(os_control, (0660), sys_led_read, sys_led_write, OS_C
331327
static SENSOR_DEVICE_ATTR(first_cpld_version, S_IRUGO, cpld_show_version, NULL, FIRST_CPLD_VERSION);
332328
static SENSOR_DEVICE_ATTR(second_cpld_version, S_IRUGO, cpld_show_version, NULL, SECOND_CPLD_VERSION);
333329
static SENSOR_DEVICE_ATTR(third_cpld_version, S_IRUGO, cpld_show_version, NULL, THIRD_CPLD_VERSION);
334-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
335330
static SENSOR_DEVICE_ATTR(port_control, (0660), sys_led_read, sys_led_write, PORT_CONTROL);
336-
#endif
337-
338-
339331

340332
static SENSOR_DEVICE_ATTR(p0_fault, (0660), port_fault_read, port_fault_write, P0_FAULT);
341333
static SENSOR_DEVICE_ATTR(p1_fault, (0660), port_fault_read, port_fault_write, P1_FAULT);
@@ -491,9 +483,7 @@ static struct attribute *inspur_sc5630el_cpld_attributes[] = {
491483
&sensor_dev_attr_r54210_2_reset.dev_attr.attr,
492484
&sensor_dev_attr_r5387_reset.dev_attr.attr,
493485
&sensor_dev_attr_debug_reset.dev_attr.attr,
494-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
495486
&sensor_dev_attr_port_control.dev_attr.attr,
496-
#endif
497487
NULL
498488
};
499489

@@ -581,9 +571,7 @@ static ssize_t sys_led_read(struct device *dev, struct device_attribute *attr, c
581571
case LOC_LED:
582572
command = SYS_LOC_LED_REG;
583573
break;
584-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
585574
case PORT_CONTROL:
586-
#endif
587575
case OS_CONTORL:
588576
command = SYS_OS_LED_REG;
589577
break;
@@ -642,10 +630,8 @@ static ssize_t sys_led_read(struct device *dev, struct device_attribute *attr, c
642630
dev_dbg(&client->dev, "should be read 20 regs, but now only read %d\n", data_num);
643631
val=ret_data[19];
644632
res = val;
645-
break;
646-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
633+
break;
647634
case PORT_CONTROL:
648-
#endif
649635
case OS_CONTORL:
650636
data_num = i2c_smbus_read_i2c_block_data(client, CPLD_MB_BASE_REG, 31, ret_data);
651637
if (data_num != 31)
@@ -665,11 +651,9 @@ static ssize_t sys_led_write(struct device *dev, struct device_attribute *attr,
665651
struct i2c_client *client = to_i2c_client(dev);
666652
struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
667653
int error, write, command;
668-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
669654
unsigned char ret_data[32];
670655
int data_num =0;
671656
int read = 0;
672-
#endif
673657

674658
error = kstrtoint(buf, 10, &write);
675659
if (error)
@@ -702,7 +686,6 @@ static ssize_t sys_led_write(struct device *dev, struct device_attribute *attr,
702686
return -EINVAL;
703687
command = SYS_LOC_LED_REG;
704688
break;
705-
#if 1//zhougl, 2019-10-23, ISU20191008259600026, add port led register bit.
706689
case OS_CONTORL:
707690
if (write < 0 || write > 3)
708691
return -EINVAL;
@@ -726,7 +709,6 @@ static ssize_t sys_led_write(struct device *dev, struct device_attribute *attr,
726709
write |= read << 0;
727710
command = SYS_OS_LED_REG;
728711
break;
729-
#endif
730712
}
731713

732714

@@ -1771,9 +1753,12 @@ int platform_inspur_sc5630el(void)
17711753
}
17721754
EXPORT_SYMBOL(platform_inspur_sc5630el);
17731755

1774-
MODULE_AUTHOR("inspur");
1775-
MODULE_DESCRIPTION("inspur_cpld driver");
1776-
MODULE_LICENSE("GPL");
1777-
17781756
module_init(inspur_i2c_cpld_init);
17791757
module_exit(inspur_i2c_cpld_exit);
1758+
1759+
1760+
MODULE_AUTHOR("[email protected]");
1761+
MODULE_VERSION("1.0");
1762+
MODULE_DESCRIPTION("Inspur cpld driver");
1763+
MODULE_LICENSE("GPL");
1764+

platform/broadcom/sonic-platform-modules-inspur/sc5630el/modules/inspur_sc5630el_eeprom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,6 @@ static struct i2c_driver _i2c_device_driver = {
181181

182182
module_i2c_driver(_i2c_device_driver); // Simply module_init() & module_exit()
183183

184-
MODULE_AUTHOR("switchsupport@inspur.com");
185-
MODULE_DESCRIPTION ("SONiC EEPROM platform driver for SC5630EL");
184+
MODULE_AUTHOR("sdn@inspur.com");
185+
MODULE_DESCRIPTION ("SONiC EEPROM driver via ipmi");
186186
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)