Enabling FPGA device support in PDDF (#13477)
Why I did it To enable FPGA support in PDDF. How I did it Added FPGAI2C and FPGAPCI in the build path for the PDDF debian package Added the support for FPGA access APIs in the drivers of fan, xcvr, led etc. Added the FPGA device creation support in PDDF utils and parsers How to verify it These changes can be verified on some platform using such FPGAs. For testing purpose, we took Dell S5232f platform and brought it up using PDDF. In doing so, FPGA devices are created using PDDF and optics eeproms were accessed using common FPGA drivers. Below are some of the logs.
This commit is contained in:
parent
8bd6a8891c
commit
f822373e53
@ -27,8 +27,8 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include "../../../../../pddf/i2c/modules/include/pddf_led_defs.h"
|
||||
#include "../../../../../pddf/i2c/modules/include/pddf_client_defs.h"
|
||||
#include "pddf_led_defs.h"
|
||||
#include "pddf_client_defs.h"
|
||||
|
||||
#define DEBUG 0
|
||||
LED_OPS_DATA sys_led_ops_data[1]={0};
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include "../../../../../pddf/i2c/modules/include/pddf_led_defs.h"
|
||||
#include "../../../../../pddf/i2c/modules/include/pddf_client_defs.h"
|
||||
#include "../../../ra-b6510-32c/modules/driver/pddf_led_defs.h"
|
||||
#include "../../../ra-b6510-32c/modules/driver//pddf_client_defs.h"
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/slab.h>
|
||||
|
@ -330,6 +330,106 @@ int fan_cpld_client_read(FAN_DATA_ATTR *udata)
|
||||
return status;
|
||||
}
|
||||
|
||||
int fan_cpld_client_write(FAN_DATA_ATTR *udata, uint32_t val)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
if (udata->len==1)
|
||||
{
|
||||
status = board_i2c_cpld_write(udata->devaddr, udata->offset, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the I2C client for the CPLD */
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
client_ptr = (struct i2c_client *)get_device_table(udata->devname);
|
||||
if (client_ptr)
|
||||
{
|
||||
if (udata->len==2)
|
||||
{
|
||||
uint8_t val_lsb = val & 0xFF;
|
||||
uint8_t val_hsb = (val >> 8) & 0xFF;
|
||||
/* TODO: Check this logic for LE and BE */
|
||||
status = i2c_smbus_write_byte_data(client_ptr, udata->offset, val_lsb);
|
||||
if (status==0) status = i2c_smbus_write_byte_data(client_ptr, udata->offset+1, val_hsb);
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "PDDF_FAN: Doesn't support block CPLD write yet");
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int fan_fpgai2c_client_read(FAN_DATA_ATTR *udata)
|
||||
{
|
||||
int status = -1;
|
||||
|
||||
if (udata!=NULL)
|
||||
{
|
||||
if (udata->len==1)
|
||||
{
|
||||
status = board_i2c_fpga_read(udata->devaddr , udata->offset);
|
||||
/*printk(KERN_ERR "### Reading offset 0x%x from 0x%x device ... val 0x%x\n", udata->offset, udata->devaddr, status);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the I2C client for the FPGAI2C */
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
client_ptr = (struct i2c_client *)get_device_table(udata->devname);
|
||||
if (client_ptr)
|
||||
{
|
||||
if (udata->len==2)
|
||||
{
|
||||
status = i2c_smbus_read_word_swapped(client_ptr, udata->offset);
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "PDDF_FAN: Doesn't support block FPGAI2C read yet");
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int fan_fpgai2c_client_write(FAN_DATA_ATTR *udata, uint32_t val)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
if (udata->len==1)
|
||||
{
|
||||
status = board_i2c_fpga_write(udata->devaddr, udata->offset, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the I2C client for the FPGAI2C */
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
client_ptr = (struct i2c_client *)get_device_table(udata->devname);
|
||||
if (client_ptr)
|
||||
{
|
||||
if (udata->len==2)
|
||||
{
|
||||
uint8_t val_lsb = val & 0xFF;
|
||||
uint8_t val_hsb = (val >> 8) & 0xFF;
|
||||
/* TODO: Check this logic for LE and BE */
|
||||
status = i2c_smbus_write_byte_data(client_ptr, udata->offset, val_lsb);
|
||||
if (status==0) status = i2c_smbus_write_byte_data(client_ptr, udata->offset+1, val_hsb);
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "PDDF_FAN: Doesn't support block FPGAI2C write yet");
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void *info)
|
||||
{
|
||||
@ -341,6 +441,10 @@ int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void *
|
||||
{
|
||||
val = fan_cpld_client_read(udata);
|
||||
}
|
||||
else if (strcmp(udata->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
val = fan_fpgai2c_client_read(udata);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset);
|
||||
@ -365,6 +469,10 @@ int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info
|
||||
{
|
||||
val = fan_cpld_client_read(udata);
|
||||
}
|
||||
else if (strcmp(udata->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
val = fan_fpgai2c_client_read(udata);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (udata->len == 1)
|
||||
@ -395,18 +503,26 @@ int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info
|
||||
int sonic_i2c_get_fan_direction_default(void *client, FAN_DATA_ATTR *udata, void *info)
|
||||
{
|
||||
int status = 0;
|
||||
uint32_t val = 0;
|
||||
int val = 0;
|
||||
struct fan_attr_info *painfo = (struct fan_attr_info *)info;
|
||||
|
||||
if (strcmp(udata->devtype, "cpld") == 0)
|
||||
{
|
||||
val = fan_cpld_client_read(udata);
|
||||
}
|
||||
else if (strcmp(udata->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
val = fan_fpgai2c_client_read(udata);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset);
|
||||
}
|
||||
painfo->val.intval = ((val & udata->mask) == udata->cmpval);
|
||||
|
||||
if (val < 0)
|
||||
status = val;
|
||||
else
|
||||
painfo->val.intval = ((val & udata->mask) == udata->cmpval);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -415,7 +531,7 @@ int sonic_i2c_get_fan_direction_default(void *client, FAN_DATA_ATTR *udata, void
|
||||
int sonic_i2c_set_fan_pwm_default(struct i2c_client *client, FAN_DATA_ATTR *udata, void *info)
|
||||
{
|
||||
int status = 0;
|
||||
uint32_t val = 0;
|
||||
int val = 0;
|
||||
struct fan_attr_info *painfo = (struct fan_attr_info *)info;
|
||||
|
||||
val = painfo->val.intval & udata->mask;
|
||||
@ -427,52 +543,31 @@ int sonic_i2c_set_fan_pwm_default(struct i2c_client *client, FAN_DATA_ATTR *udat
|
||||
|
||||
if (strcmp(udata->devtype, "cpld") == 0)
|
||||
{
|
||||
if (udata->len==1)
|
||||
{
|
||||
status = board_i2c_cpld_write(udata->devaddr , udata->offset, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the I2C client for the CPLD */
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
client_ptr = (struct i2c_client *)get_device_table(udata->devname);
|
||||
if (client_ptr)
|
||||
{
|
||||
if (udata->len==2)
|
||||
{
|
||||
uint8_t val_lsb = val & 0xFF;
|
||||
uint8_t val_hsb = (val >> 8) & 0xFF;
|
||||
/* TODO: Check this logic for LE and BE */
|
||||
i2c_smbus_write_byte_data(client, udata->offset, val_lsb);
|
||||
i2c_smbus_write_byte_data(client, udata->offset+1, val_hsb);
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "PDDF_FAN: Doesn't support block CPLD write yet");
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", udata->devname);
|
||||
}
|
||||
|
||||
status = fan_cpld_client_write(udata, val);
|
||||
}
|
||||
else if (strcmp(udata->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = fan_fpgai2c_client_write(udata, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (udata->len == 1)
|
||||
i2c_smbus_write_byte_data(client, udata->offset, val);
|
||||
status = i2c_smbus_write_byte_data(client, udata->offset, val);
|
||||
else if (udata->len == 2)
|
||||
{
|
||||
uint8_t val_lsb = val & 0xFF;
|
||||
uint8_t val_hsb = (val >> 8) & 0xFF;
|
||||
/* TODO: Check this logic for LE and BE */
|
||||
i2c_smbus_write_byte_data(client, udata->offset, val_lsb);
|
||||
i2c_smbus_write_byte_data(client, udata->offset+1, val_hsb);
|
||||
status = i2c_smbus_write_byte_data(client, udata->offset, val_lsb);
|
||||
if (status == 0) status = i2c_smbus_write_byte_data(client, udata->offset+1, val_hsb);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_DEBUG "%s: pwm should be of len 1/2 bytes. Not setting the pwm as the length is %d\n", __FUNCTION__, udata->len);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@ -486,6 +581,10 @@ int sonic_i2c_get_fan_pwm_default(void *client, FAN_DATA_ATTR *udata, void *info
|
||||
{
|
||||
val = fan_cpld_client_read(udata);
|
||||
}
|
||||
else if (strcmp(udata->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
val = fan_fpgai2c_client_read(udata);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (udata->len == 1)
|
||||
@ -520,6 +619,10 @@ int sonic_i2c_get_fan_fault_default(void *client, FAN_DATA_ATTR *udata, void *in
|
||||
{
|
||||
val = fan_cpld_client_read(udata);
|
||||
}
|
||||
else if (strcmp(udata->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
val = fan_fpgai2c_client_read(udata);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset);
|
||||
|
@ -88,4 +88,6 @@ typedef struct FAN_PDATA
|
||||
extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg);
|
||||
extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value);
|
||||
|
||||
extern int board_i2c_fpga_read(unsigned short cpld_addr, u8 reg);
|
||||
extern int board_i2c_fpga_write(unsigned short cpld_addr, u8 reg, u8 value);
|
||||
#endif
|
||||
|
@ -33,6 +33,7 @@ struct kobject *cur_state_kobj=NULL;
|
||||
* space JSON data file
|
||||
*****************************************/
|
||||
#define NAME_SIZE 32
|
||||
#define VALUE_SIZE 5
|
||||
typedef enum {
|
||||
STATUS_LED_COLOR_GREEN,
|
||||
STATUS_LED_COLOR_GREEN_BLINK,
|
||||
@ -42,20 +43,24 @@ typedef enum {
|
||||
STATUS_LED_COLOR_AMBER_BLINK,
|
||||
STATUS_LED_COLOR_BLUE,
|
||||
STATUS_LED_COLOR_BLUE_BLINK,
|
||||
STATUS_LED_COLOR_YELLOW,
|
||||
STATUS_LED_COLOR_YELLOW_BLINK,
|
||||
STATUS_LED_COLOR_OFF,
|
||||
MAX_LED_STATUS
|
||||
}LED_STATUS;
|
||||
|
||||
char* LED_STATUS_STR[] = {
|
||||
"STATUS_LED_COLOR_GREEN",
|
||||
"STATUS_LED_COLOR_GREEN_BLINK",
|
||||
"STATUS_LED_COLOR_RED",
|
||||
"STATUS_LED_COLOR_RED_BLINK",
|
||||
"STATUS_LED_COLOR_AMBER",
|
||||
"STATUS_LED_COLOR_AMBER_BLINK",
|
||||
"STATUS_LED_COLOR_BLUE",
|
||||
"STATUS_LED_COLOR_BLUE_BLINK",
|
||||
"STATUS_LED_COLOR_OFF"
|
||||
"green",
|
||||
"green_blink",
|
||||
"red",
|
||||
"red_blink",
|
||||
"amber",
|
||||
"amber_blink",
|
||||
"blue",
|
||||
"blue_blink",
|
||||
"yellow",
|
||||
"yellow_blink",
|
||||
"off"
|
||||
};
|
||||
|
||||
|
||||
@ -71,7 +76,10 @@ typedef struct
|
||||
int swpld_addr;
|
||||
int swpld_addr_offset;
|
||||
MASK_BITS bits;
|
||||
unsigned short value;
|
||||
u8 reg_values[VALUE_SIZE];
|
||||
char value[NAME_SIZE];
|
||||
char attr_devtype[NAME_SIZE];
|
||||
char attr_devname[NAME_SIZE];
|
||||
} LED_DATA;
|
||||
|
||||
typedef struct
|
||||
@ -88,6 +96,8 @@ typedef struct
|
||||
LED_DATA data[MAX_LED_STATUS];
|
||||
int swpld_addr;
|
||||
int swpld_addr_offset;
|
||||
char attr_devtype[NAME_SIZE];
|
||||
char attr_devname[NAME_SIZE];
|
||||
} LED_OPS_DATA;
|
||||
|
||||
typedef enum{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -383,7 +383,7 @@ int psu_init(void)
|
||||
}
|
||||
EXPORT_SYMBOL(psu_init);
|
||||
|
||||
void __exit psu_exit(void)
|
||||
void psu_exit(void)
|
||||
{
|
||||
pddf_dbg(PSU, "GENERIC_PSU_DRIVER.. exit\n");
|
||||
if (pddf_psu_ops.pre_exit) (pddf_psu_ops.pre_exit)();
|
||||
|
@ -40,6 +40,10 @@
|
||||
|
||||
extern XCVR_SYSFS_ATTR_OPS xcvr_ops[];
|
||||
extern void *get_device_table(char *name);
|
||||
extern int (*ptr_fpgapci_read)(uint32_t);
|
||||
extern int (*ptr_fpgapci_write)(uint32_t, uint32_t);
|
||||
|
||||
|
||||
|
||||
int get_xcvr_module_attr_data(struct i2c_client *client, struct device *dev,
|
||||
struct device_attribute *da);
|
||||
@ -146,6 +150,148 @@ int xcvr_i2c_cpld_write(XCVR_ATTR *info, uint32_t val)
|
||||
return status;
|
||||
}
|
||||
|
||||
int xcvr_i2c_fpga_read(XCVR_ATTR *info)
|
||||
{
|
||||
int status = -1;
|
||||
int retry = 10;
|
||||
|
||||
if (info!=NULL)
|
||||
{
|
||||
/* Get the I2C client for the CPLD */
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
if (client_ptr)
|
||||
{
|
||||
if (info->len==1)
|
||||
{
|
||||
while(retry)
|
||||
{
|
||||
status = i2c_smbus_read_byte_data(client_ptr , info->offset);
|
||||
if (unlikely(status < 0))
|
||||
{
|
||||
msleep(60);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (info->len==2)
|
||||
{
|
||||
retry = 10;
|
||||
while(retry)
|
||||
{
|
||||
status = i2c_smbus_read_word_swapped(client_ptr, info->offset);
|
||||
if (unlikely(status < 0))
|
||||
{
|
||||
msleep(60);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block FPGAI2C read yet");
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int xcvr_i2c_fpga_write(XCVR_ATTR *info, uint32_t val)
|
||||
{
|
||||
int status = 0;
|
||||
unsigned int val_mask = 0, dnd_value = 0;
|
||||
uint32_t reg;
|
||||
struct i2c_client *client_ptr = NULL;
|
||||
|
||||
val_mask = BIT_INDEX(info->mask);
|
||||
/* Get the I2C client for the CPLD */
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
|
||||
if (client_ptr)
|
||||
{
|
||||
if (info->len == 1)
|
||||
status = i2c_smbus_read_byte_data(client_ptr, info->offset);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_read_word_swapped(client_ptr, info->offset);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block FPGAI2C read yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
msleep(60);
|
||||
dnd_value = status & ~val_mask;
|
||||
if (((val == 1) && (info->cmpval != 0)) || ((val == 0) && (info->cmpval == 0)))
|
||||
reg = dnd_value | val_mask;
|
||||
else
|
||||
reg = dnd_value;
|
||||
if (info->len == 1)
|
||||
status = i2c_smbus_write_byte_data(client_ptr, info->offset, (uint8_t)reg);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block FPGAI2C write yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int xcvr_fpgapci_read(XCVR_ATTR *info)
|
||||
{
|
||||
int reg_val= 0;
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (ptr_fpgapci_read == NULL) {
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support FPGAPCI read yet");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
offset = info->devaddr + info->offset;
|
||||
reg_val = ptr_fpgapci_read(offset);
|
||||
return reg_val;
|
||||
}
|
||||
|
||||
int xcvr_fpgapci_write(XCVR_ATTR *info, uint32_t val)
|
||||
{
|
||||
int status= 0;
|
||||
uint32_t reg, val_mask = 0, dnd_value = 0, reg_val;
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (ptr_fpgapci_read == NULL || ptr_fpgapci_write == NULL) {
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support FPGAPCI read or write yet");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
offset = info->devaddr + info->offset;
|
||||
val_mask = BIT_INDEX(info->mask);
|
||||
reg_val = ptr_fpgapci_read(offset);
|
||||
dnd_value = reg_val & ~val_mask;
|
||||
|
||||
if (((val == 1) && (info->cmpval != 0)) || ((val == 0) && (info->cmpval == 0)))
|
||||
reg = dnd_value | val_mask;
|
||||
else
|
||||
reg = dnd_value;
|
||||
|
||||
status = ptr_fpgapci_write(offset, reg);
|
||||
return status;
|
||||
}
|
||||
|
||||
int sonic_i2c_get_mod_pres(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data)
|
||||
{
|
||||
@ -164,6 +310,31 @@ int sonic_i2c_get_mod_pres(struct i2c_client *client, XCVR_ATTR *info, struct xc
|
||||
sfp_dbg(KERN_INFO "\nMod presence :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
modpres = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nMod presence :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgapci") == 0)
|
||||
{
|
||||
status = xcvr_fpgapci_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
modpres = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nMod presence :0x%x, status= 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
|
||||
else if(strcmp(info->devtype, "eeprom") == 0)
|
||||
{
|
||||
/* get client client for eeprom - Not Applicable */
|
||||
@ -189,6 +360,30 @@ int sonic_i2c_get_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct x
|
||||
sfp_dbg(KERN_INFO "\nMod Reset :0x%x, reg_value = 0x%x\n", modreset, status);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
modreset = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nMod reset :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgapci") == 0)
|
||||
{
|
||||
status = xcvr_fpgapci_read(info);
|
||||
sfp_dbg(KERN_INFO "\n[%s] status=%x\n", __FUNCTION__, status);
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
modreset = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nMod reset :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modreset, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if(strcmp(info->devtype, "eeprom") == 0)
|
||||
{
|
||||
/* get client client for eeprom - Not Applicable */
|
||||
@ -214,6 +409,31 @@ int sonic_i2c_get_mod_intr_status(struct i2c_client *client, XCVR_ATTR *info, st
|
||||
sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x\n", mod_intr, status);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
mod_intr = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgapci") == 0)
|
||||
{
|
||||
status = xcvr_fpgapci_read(info);
|
||||
sfp_dbg(KERN_INFO "\n[%s] status=%x\n", __FUNCTION__, status);
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
mod_intr = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", mod_intr, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
|
||||
else if(strcmp(info->devtype, "eeprom") == 0)
|
||||
{
|
||||
/* get client client for eeprom - Not Applicable */
|
||||
@ -240,6 +460,30 @@ int sonic_i2c_get_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct
|
||||
sfp_dbg(KERN_INFO "\nModule LPmode :0x%x, reg_value = 0x%x\n", lpmode, status);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
lpmode = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule LPmode :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgapci") == 0)
|
||||
{
|
||||
status = xcvr_fpgapci_read(info);
|
||||
sfp_dbg(KERN_INFO "\n[%s] status=%x\n", __FUNCTION__, status);
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
lpmode = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nlpmode :0x%x, reg_val = 0x%x, op=0x%x, mask=0x%x, offset=0x%x\n", lpmode, status, status & BIT_INDEX(info->mask), info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
else if (strcmp(info->devtype, "eeprom") == 0)
|
||||
{
|
||||
/* get client client for eeprom - Not Applicable */
|
||||
@ -266,6 +510,18 @@ int sonic_i2c_get_mod_rxlos(struct i2c_client *client, XCVR_ATTR *info, struct x
|
||||
sfp_dbg(KERN_INFO "\nModule RxLOS :0x%x, reg_value = 0x%x\n", rxlos, status);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
rxlos = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule RxLOS :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
data->rxlos = rxlos;
|
||||
|
||||
return 0;
|
||||
@ -287,6 +543,18 @@ int sonic_i2c_get_mod_txdisable(struct i2c_client *client, XCVR_ATTR *info, stru
|
||||
sfp_dbg(KERN_INFO "\nModule TxDisable :0x%x, reg_value = 0x%x\n", txdis, status);
|
||||
}
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
txdis = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule TxDisable :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
data->txdisable = txdis;
|
||||
|
||||
return 0;
|
||||
@ -309,6 +577,18 @@ int sonic_i2c_get_mod_txfault(struct i2c_client *client, XCVR_ATTR *info, struct
|
||||
}
|
||||
|
||||
}
|
||||
else if ( strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_read(info);
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
txflt = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule Txfault :0x%x, reg_value = 0x%x, devaddr=0x%x, mask=0x%x, offset=0x%x\n", modpres, status, info->devaddr, info->mask, info->offset);
|
||||
}
|
||||
}
|
||||
data->txfault = txflt;
|
||||
|
||||
return 0;
|
||||
@ -322,6 +602,14 @@ int sonic_i2c_set_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct x
|
||||
{
|
||||
status = xcvr_i2c_cpld_write(info, data->reset);
|
||||
}
|
||||
else if (strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_write(info, data->reset);
|
||||
}
|
||||
else if (strcmp(info->devtype, "fpgapci") == 0)
|
||||
{
|
||||
status = xcvr_fpgapci_write(info, data->reset);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr reset\n", info->devtype);
|
||||
@ -339,6 +627,14 @@ int sonic_i2c_set_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct
|
||||
{
|
||||
status = xcvr_i2c_cpld_write(info, data->lpmode);
|
||||
}
|
||||
else if (strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_write(info, data->lpmode);
|
||||
}
|
||||
else if (strcmp(info->devtype, "fpgapci") == 0)
|
||||
{
|
||||
status = xcvr_fpgapci_write(info, data->lpmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr lpmode\n", info->devtype);
|
||||
@ -356,6 +652,10 @@ int sonic_i2c_set_mod_txdisable(struct i2c_client *client, XCVR_ATTR *info, stru
|
||||
{
|
||||
status = xcvr_i2c_cpld_write(info, data->txdisable);
|
||||
}
|
||||
else if (strcmp(info->devtype, "fpgai2c") == 0)
|
||||
{
|
||||
status = xcvr_i2c_fpga_write(info, data->txdisable);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr txdisable\n", info->devtype);
|
||||
|
@ -278,7 +278,7 @@ int xcvr_init(void)
|
||||
}
|
||||
EXPORT_SYMBOL(xcvr_init);
|
||||
|
||||
void __exit xcvr_exit(void)
|
||||
void xcvr_exit(void)
|
||||
{
|
||||
pddf_dbg(XCVR, "PDDF XCVR DRIVER.. exit\n");
|
||||
if (pddf_xcvr_ops.pre_exit) (pddf_xcvr_ops.pre_exit)();
|
||||
@ -288,9 +288,9 @@ void __exit xcvr_exit(void)
|
||||
}
|
||||
EXPORT_SYMBOL(xcvr_exit);
|
||||
|
||||
module_init(xcvr_init);
|
||||
module_exit(xcvr_exit);
|
||||
|
||||
MODULE_AUTHOR("Broadcom");
|
||||
MODULE_DESCRIPTION("Driver for transceiver operations");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(xcvr_init);
|
||||
module_exit(xcvr_exit);
|
||||
|
@ -203,7 +203,9 @@ def config_pddf_utils():
|
||||
if not os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_BK):
|
||||
# bsp 2.0 classes are installed. Take a backup and copy pddf 2.0 whl pkg
|
||||
log_os_system('mv '+SONIC_PLATFORM_BSP_WHL_PKG+' '+SONIC_PLATFORM_BSP_WHL_PKG_BK, 1)
|
||||
log_os_system('sync', 1)
|
||||
shutil.copy(SONIC_PLATFORM_PDDF_WHL_PKG, SONIC_PLATFORM_BSP_WHL_PKG)
|
||||
log_os_system('sync', 1)
|
||||
# uninstall the existing bsp whl pkg
|
||||
status, output = log_os_system("pip3 uninstall sonic-platform -y &> /dev/null", 1)
|
||||
if status:
|
||||
@ -328,6 +330,7 @@ def create_pddf_log_files():
|
||||
log_os_system("sudo touch /var/log/pddf/cpldmux.txt", 1)
|
||||
log_os_system("sudo touch /var/log/pddf/client.txt", 1)
|
||||
log_os_system("sudo touch /var/log/pddf/mux.txt", 1)
|
||||
log_os_system("sudo touch /var/log/pddf/fpgapci.txt", 1)
|
||||
|
||||
def driver_install():
|
||||
global FORCE
|
||||
|
@ -18,19 +18,6 @@ PLATFORM_KEY = 'DEVICE_METADATA.localhost.platform'
|
||||
|
||||
dirname = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
color_map = {
|
||||
"STATUS_LED_COLOR_GREEN" : "green",
|
||||
"STATUS_LED_COLOR_RED" : "red",
|
||||
"STATUS_LED_COLOR_AMBER" : "amber",
|
||||
"STATUS_LED_COLOR_BLUE" : "blue",
|
||||
"STATUS_LED_COLOR_GREEN_BLINK" : "blinking green",
|
||||
"STATUS_LED_COLOR_RED_BLINK" : "blinking red",
|
||||
"STATUS_LED_COLOR_AMBER_BLINK" : "blinking amber",
|
||||
"STATUS_LED_COLOR_BLUE_BLINK" : "blinking blue",
|
||||
"STATUS_LED_COLOR_OFF" : "off"
|
||||
}
|
||||
|
||||
|
||||
class PddfParse():
|
||||
def __init__(self):
|
||||
if not os.path.exists("/usr/share/sonic/platform"):
|
||||
@ -128,7 +115,7 @@ class PddfParse():
|
||||
except IOError:
|
||||
return ("Error")
|
||||
|
||||
return (color_map[color])
|
||||
return (color)
|
||||
|
||||
###################################################################################################################
|
||||
# CREATE DEFS
|
||||
@ -262,6 +249,30 @@ class PddfParse():
|
||||
|
||||
return create_ret.append(ret)
|
||||
|
||||
def create_fpgai2c_device(self, dev, ops):
|
||||
create_ret = []
|
||||
ret = 0
|
||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAI2C']:
|
||||
ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/fpgai2c", ops)
|
||||
if ret!=0:
|
||||
return create_ret.append(ret)
|
||||
|
||||
cmd= "echo '%s' > /sys/kernel/pddf/devices/fpgai2c/i2c_name"%(dev['dev_info']['device_name'])
|
||||
ret = self.runcmd(cmd)
|
||||
if ret!=0:
|
||||
return create_ret.append(ret)
|
||||
cmd= "echo 'add' > /sys/kernel/pddf/devices/fpgai2c/dev_ops"
|
||||
ret = self.runcmd(cmd)
|
||||
if ret!=0:
|
||||
return create_ret.append(ret)
|
||||
else:
|
||||
cmd= "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0))
|
||||
ret = self.runcmd(cmd)
|
||||
if ret!=0:
|
||||
return create_ret.append(ret)
|
||||
|
||||
return create_ret.append(ret)
|
||||
|
||||
def create_cpldmux_device(self, dev, ops):
|
||||
create_ret = []
|
||||
ret = 0
|
||||
@ -436,7 +447,19 @@ class PddfParse():
|
||||
|
||||
return create_ret.append(ret)
|
||||
|
||||
###################################################################################################################
|
||||
def create_fpgapci_device(self, dev, ops):
|
||||
create_ret = []
|
||||
ret = 0
|
||||
ret = self.create_device(dev['i2c']['dev_attr'], "pddf/devices/fpgapci", ops)
|
||||
if ret!=0:
|
||||
return create_ret.append(ret)
|
||||
|
||||
cmd = "echo 'fpgapci_init' > /sys/kernel/pddf/devices/fpgapci/dev_ops"
|
||||
ret = self.runcmd(cmd)
|
||||
return create_ret.append(ret)
|
||||
|
||||
|
||||
#################################################################################################################################
|
||||
# DELETE DEFS
|
||||
###################################################################################################################
|
||||
def delete_eeprom_device(self, dev, ops):
|
||||
@ -494,6 +517,16 @@ class PddfParse():
|
||||
int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0))
|
||||
self.runcmd(cmd)
|
||||
|
||||
def delete_fpgai2c_device(self, dev, ops):
|
||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAI2C']:
|
||||
cmd= "echo '%s' > /sys/kernel/pddf/devices/fpgai2c/i2c_name"%(dev['dev_info']['device_name'])
|
||||
self.runcmd(cmd)
|
||||
cmd= "echo 'delete' > /sys/kernel/pddf/devices/fpgai2c/dev_ops"
|
||||
self.runcmd(cmd)
|
||||
else:
|
||||
cmd= "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0))
|
||||
self.runcmd(cmd)
|
||||
|
||||
def delete_cpldmux_device(self, dev, ops):
|
||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLDMUX']:
|
||||
cmd = "echo '%s' > /sys/kernel/pddf/devices/cpldmux/i2c_name" % (dev['dev_info']['device_name'])
|
||||
@ -534,7 +567,9 @@ class PddfParse():
|
||||
self.delete_psu_i2c_device(dev, ops)
|
||||
return
|
||||
|
||||
###################################################################################################################
|
||||
def delete_fpgapci_device(self, dev, ops):
|
||||
return
|
||||
#################################################################################################################################
|
||||
# SHOW ATTRIBIUTES DEFS
|
||||
###################################################################################################################
|
||||
def is_led_device_configured(self, device_name, attr_name):
|
||||
@ -991,6 +1026,21 @@ class PddfParse():
|
||||
'/sys/kernel/pddf/devices/cpld/error']
|
||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list)
|
||||
|
||||
def show_fpgai2c_device(self, dev, ops):
|
||||
KEY ='fpgai2c'
|
||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAI2C']:
|
||||
if not KEY in self.sysfs_obj:
|
||||
self.sysfs_obj[KEY] = []
|
||||
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/fpgai2c", self.sysfs_obj, KEY)
|
||||
sysfs_path = "/sys/kernel/pddf/devices/fpgai2c/dev_ops"
|
||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
||||
self.sysfs_obj[KEY].append(sysfs_path)
|
||||
extra_list = ['/sys/kernel/pddf/devices/fpgai2c/i2c_type',
|
||||
'/sys/kernel/pddf/devices/fpgai2c/i2c_name',
|
||||
'/sys/kernel/pddf/devices/fpgai2c/error']
|
||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list)
|
||||
|
||||
|
||||
def show_led_platform_device(self, key, ops):
|
||||
if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM':
|
||||
KEY = 'platform'
|
||||
@ -1006,21 +1056,36 @@ class PddfParse():
|
||||
if not KEY in self.sysfs_obj:
|
||||
self.sysfs_obj[KEY] = []
|
||||
path="pddf/devices/led"
|
||||
for attr in self.data[key]['i2c']['attr_list']:
|
||||
self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'],path,self.sysfs_obj,KEY)
|
||||
self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'],path,self.sysfs_obj, KEY)
|
||||
self.sysfs_attr('swpld_addr_offset',self.data[key]['dev_info']['device_name'],
|
||||
path,self.sysfs_obj, KEY)
|
||||
self.sysfs_device(self.data[key]['dev_attr'], path, self.sysfs_obj, KEY)
|
||||
for attr_key in attr.keys():
|
||||
attr_path = "pddf/devices/led/" + attr['attr_name']
|
||||
if (attr_key != 'attr_name' and attr_key != 'swpld_addr' and attr_key != 'swpld_addr_offset'):
|
||||
self.sysfs_attr(attr_key, attr[attr_key], attr_path, self.sysfs_obj, KEY)
|
||||
self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY)
|
||||
self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY)
|
||||
self.sysfs_attr('swpld_addr_offset', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY)
|
||||
state_attr_path="pddf/devices/led/state_attr"
|
||||
self.sysfs_attr('bits', self.data[key]['dev_info']['device_name'], state_attr_path, self.sysfs_obj, KEY)
|
||||
self.sysfs_attr('value', self.data[key]['dev_info']['device_name'], state_attr_path, self.sysfs_obj, KEY)
|
||||
sysfs_path="/sys/kernel/pddf/devices/led/dev_ops"
|
||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
||||
self.sysfs_obj[KEY].append(sysfs_path)
|
||||
list=['/sys/kernel/pddf/devices/led/cur_state/color']
|
||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||
extra_list=['/sys/kernel/pddf/devices/led/cur_state/color']
|
||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list)
|
||||
|
||||
|
||||
def show_fpgapci_device(self, dev, ops):
|
||||
KEY ='fpgapci'
|
||||
if dev['dev_info']['device_type'] in self.data['PLATFORM']['pddf_dev_types']['FPGAPCIE']:
|
||||
if not KEY in self.sysfs_obj:
|
||||
self.sysfs_obj[KEY] = []
|
||||
sysfs_path = "/sys/kernel/pddf/devices/fpgapci"
|
||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
||||
self.sysfs_obj[KEY].append(sysfs_path)
|
||||
extra_list = ['/sys/kernel/pddf/devices/fpgapci/vendor_id',
|
||||
'/sys/kernel/pddf/devices/fpgapci/virt_bus',
|
||||
'/sys/kernel/pddf/devices/fpgapci/device_id',
|
||||
'/sys/kernel/pddf/devices/fpgapci/data_base_offset',
|
||||
'/sys/kernel/pddf/devices/fpgapci/data_size',
|
||||
'/sys/kernel/pddf/devices/fpgapci/i2c_ch_base_offset',
|
||||
'/sys/kernel/pddf/devices/fpgapci/i2c_ch_size',
|
||||
'/sys/kernel/pddf/devices/fpgapci/virt_i2c_ch']
|
||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, extra_list)
|
||||
|
||||
|
||||
def validate_xcvr_device(self, dev, ops):
|
||||
@ -1077,6 +1142,13 @@ class PddfParse():
|
||||
ret_val = "cpld success"
|
||||
print(ret_val)
|
||||
|
||||
def validate_fpgai2c_device(self, dev, ops):
|
||||
devtype_list = ['i2c_fpga']
|
||||
ret_val = "fpgai2c failed"
|
||||
|
||||
if dev['i2c']['topo_info']['dev_type'] in devtype_list:
|
||||
ret_val = "fpgai2c success"
|
||||
print(ret_val)
|
||||
|
||||
def validate_sysstatus_device(self, dev, ops):
|
||||
dev_attribs = ['board_info', 'cpld1_version', 'power_module_status', 'system_reset5',
|
||||
@ -1284,7 +1356,7 @@ class PddfParse():
|
||||
else:
|
||||
print("Loaded")
|
||||
else:
|
||||
print(validate_type + " not configured" )
|
||||
print(validate_type + " not configured")
|
||||
|
||||
|
||||
|
||||
@ -1530,7 +1602,28 @@ class PddfParse():
|
||||
val.extend(ret)
|
||||
return val
|
||||
|
||||
def fpgapci_parse(self, dev, ops):
|
||||
val = []
|
||||
ret = getattr(self, ops['cmd']+"_fpgapci_device")(dev, ops)
|
||||
if ret:
|
||||
if str(ret[0]).isdigit():
|
||||
if ret[0]!=0:
|
||||
# in case if 'create' functions
|
||||
print("{}_fpgapci_device() cmd failed".format(ops['cmd']))
|
||||
return ret
|
||||
else:
|
||||
val.extend(ret)
|
||||
|
||||
for bus in dev['i2c']['channel']:
|
||||
ret = self.dev_parse(self.data[bus['dev']], ops)
|
||||
if ret:
|
||||
if str(ret[0]).isdigit():
|
||||
if ret[0]!=0:
|
||||
# in case if 'create' functions
|
||||
return ret
|
||||
else:
|
||||
val.extend(ret)
|
||||
return val
|
||||
|
||||
# 'create' and 'show_attr' ops returns an array
|
||||
# 'delete', 'show' and 'validate' ops return None
|
||||
@ -1542,6 +1635,9 @@ class PddfParse():
|
||||
else:
|
||||
return self.cpu_parse(dev, ops)
|
||||
|
||||
if attr['device_type'] == 'FPGAPCIE':
|
||||
return self.fpgapci_parse(dev, ops)
|
||||
|
||||
if attr['device_type'] == 'EEPROM':
|
||||
return self.eeprom_parse(dev, ops)
|
||||
|
||||
@ -1568,6 +1664,9 @@ class PddfParse():
|
||||
attr['device_type'] == 'QSFP-DD':
|
||||
return self.optic_parse(dev, ops)
|
||||
|
||||
if attr['device_type'] == 'FPGAI2C':
|
||||
return self.fpgai2c_parse(dev, ops)
|
||||
|
||||
if attr['device_type'] == 'CPLD':
|
||||
return self.cpld_parse(dev, ops)
|
||||
|
||||
@ -1589,9 +1688,10 @@ class PddfParse():
|
||||
return False, "[FAILED]: Invalid color"
|
||||
|
||||
|
||||
def create_attr(self, key, value, path):
|
||||
cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key)
|
||||
self.runcmd(cmd)
|
||||
def create_attr(self, key, value, path, exceptions=[]):
|
||||
if key not in exceptions:
|
||||
cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key)
|
||||
self.runcmd(cmd)
|
||||
|
||||
def create_led_platform_device(self, key, ops):
|
||||
if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM':
|
||||
@ -1601,16 +1701,23 @@ class PddfParse():
|
||||
|
||||
def create_led_device(self, key, ops):
|
||||
if ops['attr']=='all' or ops['attr']==self.data[key]['dev_info']['device_name']:
|
||||
path="pddf/devices/led"
|
||||
path = "pddf/devices/led"
|
||||
ops_state = ""
|
||||
if 'bmc' in self.data[key]:
|
||||
return
|
||||
for attr in self.data[key]['i2c']['attr_list']:
|
||||
self.create_attr('device_name', self.data[key]['dev_info']['device_name'], path)
|
||||
self.create_device(self.data[key]['dev_attr'], path, ops)
|
||||
self.create_attr('index', self.data[key]['dev_attr']['index'], path)
|
||||
#attr_devtype and attr_devname are optional in json file.
|
||||
#if attr_devtype is not defined, it means it is "cpld"
|
||||
if 'attr_devtype' not in attr.keys():
|
||||
self.create_attr('attr_devtype', 'cpld', path)
|
||||
for attr_key in attr.keys():
|
||||
if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr'):
|
||||
if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr' or \
|
||||
attr_key == 'attr_devtype' or attr_key == 'attr_devname' ):
|
||||
self.create_attr(attr_key, attr[attr_key], path)
|
||||
elif (attr_key != 'attr_name' and attr_key != 'descr' and
|
||||
attr_key != 'attr_devtype' and attr_key != 'attr_devname'):
|
||||
state_path=path+'/state_attr'
|
||||
elif (attr_key != 'attr_name' and attr_key != 'descr' and attr_key != 'state'):
|
||||
state_path = path+'/state_attr'
|
||||
self.create_attr(attr_key, attr[attr_key],state_path)
|
||||
cmd="echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops"
|
||||
self.runcmd(cmd)
|
||||
|
Reference in New Issue
Block a user