[device] Update ag9032v1 and ag9064 modules. (#1690)
* Update ag9032v1 and ag9064 modules. Signed-off-by: neal tai <neal.tai@deltaww.com> * Fix the sfputil.py when convert an integer to hexadecimal without the 'L' trailing. Signed-off-by: neal tai <neal.tai@deltaww.com>
This commit is contained in:
parent
fd5a3cf6fb
commit
2cce4aec1c
@ -120,7 +120,7 @@ class SfpUtil(SfpUtilBase):
|
|||||||
reg_value = reg_value & ~mask
|
reg_value = reg_value & ~mask
|
||||||
|
|
||||||
# Convert our register value back to a hex string and write back
|
# Convert our register value back to a hex string and write back
|
||||||
content = hex(reg_value)
|
content = hex(reg_value).rstrip("L") or "0"
|
||||||
|
|
||||||
reg_file.seek(0)
|
reg_file.seek(0)
|
||||||
reg_file.write(content)
|
reg_file.write(content)
|
||||||
|
@ -1,387 +1,387 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/hwmon.h>
|
#include <linux/hwmon.h>
|
||||||
#include <linux/hwmon-sysfs.h>
|
#include <linux/hwmon-sysfs.h>
|
||||||
|
|
||||||
#define CPUPLD_REG 0x31
|
#define CPUPLD_REG 0x31
|
||||||
|
|
||||||
enum cpld_type {
|
enum cpld_type {
|
||||||
cpld,
|
cpld,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct platform_data {
|
struct platform_data {
|
||||||
int reg_addr;
|
int reg_addr;
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
BUS0 = 0,
|
BUS0 = 0,
|
||||||
BUS1,
|
BUS1,
|
||||||
BUS2,
|
BUS2,
|
||||||
BUS3,
|
BUS3,
|
||||||
BUS4,
|
BUS4,
|
||||||
BUS5,
|
BUS5,
|
||||||
BUS6,
|
BUS6,
|
||||||
BUS7,
|
BUS7,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cpld_attributes {
|
enum cpld_attributes {
|
||||||
CPLD_VER,
|
CPLD_VER,
|
||||||
CPU_BOARD_VER,
|
CPU_BOARD_VER,
|
||||||
CPU_ID,
|
CPU_ID,
|
||||||
CPLD_RST,
|
CPLD_RST,
|
||||||
MB_RST,
|
MB_RST,
|
||||||
I2C_SW_RST,
|
I2C_SW_RST,
|
||||||
MB_PWR,
|
MB_PWR,
|
||||||
PSU_FAN_INT,
|
PSU_FAN_INT,
|
||||||
SPI_WP_GBE,
|
SPI_WP_GBE,
|
||||||
EEPROM_WP,
|
EEPROM_WP,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void device_release(struct device *dev)
|
static void device_release(struct device *dev)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------- CPUPLD - start ------------- */
|
/*---------------- CPUPLD - start ------------- */
|
||||||
static struct platform_data ag9032v1_cpld_platform_data[] = {
|
static struct platform_data ag9032v1_cpld_platform_data[] = {
|
||||||
[cpld] = {
|
[cpld] = {
|
||||||
.reg_addr = CPUPLD_REG,
|
.reg_addr = CPUPLD_REG,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct platform_device ag9032v1_cpld = {
|
static struct platform_device ag9032v1_cpld = {
|
||||||
.name = "delta-ag9032v1-cpupld",
|
.name = "delta-ag9032v1-cpupld",
|
||||||
.id = 0,
|
.id = 0,
|
||||||
.dev = {
|
.dev = {
|
||||||
.platform_data = ag9032v1_cpld_platform_data,
|
.platform_data = ag9032v1_cpld_platform_data,
|
||||||
.release = device_release
|
.release = device_release
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
static unsigned char cpld_reg_addr;
|
static unsigned char cpld_reg_addr;
|
||||||
static ssize_t get_cpld_reg_value(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t get_cpld_reg_value(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct platform_data *pdata = dev->platform_data;
|
struct platform_data *pdata = dev->platform_data;
|
||||||
|
|
||||||
ret = i2c_smbus_read_byte_data(pdata[cpld].client, cpld_reg_addr);
|
ret = i2c_smbus_read_byte_data(pdata[cpld].client, cpld_reg_addr);
|
||||||
|
|
||||||
return sprintf(buf, "0x%02x\n", ret);
|
return sprintf(buf, "0x%02x\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t set_cpld_reg_value(struct device *dev, struct device_attribute *attr,
|
static ssize_t set_cpld_reg_value(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
unsigned long data;
|
unsigned long data;
|
||||||
int err;
|
int err;
|
||||||
struct platform_data *pdata = dev->platform_data;
|
struct platform_data *pdata = dev->platform_data;
|
||||||
err = kstrtoul(buf, 0, &data);
|
err = kstrtoul(buf, 0, &data);
|
||||||
if (err){
|
if (err){
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data > 0xff){
|
if (data > 0xff){
|
||||||
printk(KERN_ALERT "address out of range (0x00-0xFF)\n");
|
printk(KERN_ALERT "address out of range (0x00-0xFF)\n");
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_smbus_write_byte_data(pdata[cpld].client, cpld_reg_addr, data);
|
i2c_smbus_write_byte_data(pdata[cpld].client, cpld_reg_addr, data);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t get_cpld_reg_addr(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t get_cpld_reg_addr(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
|
|
||||||
return sprintf(buf, "0x%02x\n", cpld_reg_addr);
|
return sprintf(buf, "0x%02x\n", cpld_reg_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t set_cpld_reg_addr(struct device *dev, struct device_attribute *attr,
|
static ssize_t set_cpld_reg_addr(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
unsigned long data;
|
unsigned long data;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = kstrtoul(buf, 0, &data);
|
err = kstrtoul(buf, 0, &data);
|
||||||
if (err){
|
if (err){
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (data > 0xff){
|
if (data > 0xff){
|
||||||
printk(KERN_ALERT "address out of range (0x00-0xFF)\n");
|
printk(KERN_ALERT "address out of range (0x00-0xFF)\n");
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
cpld_reg_addr = data;
|
cpld_reg_addr = data;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t get_cpld_data(struct device *dev, struct device_attribute *dev_attr, char *buf)
|
static ssize_t get_cpld_data(struct device *dev, struct device_attribute *dev_attr, char *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
|
||||||
struct platform_data *pdata = dev->platform_data;
|
struct platform_data *pdata = dev->platform_data;
|
||||||
unsigned char reg;
|
unsigned char reg;
|
||||||
int mask;
|
int mask;
|
||||||
int value;
|
int value;
|
||||||
char note[180];
|
char note[180];
|
||||||
switch (attr->index) {
|
switch (attr->index) {
|
||||||
case CPLD_VER:
|
case CPLD_VER:
|
||||||
reg = 0x01;
|
reg = 0x01;
|
||||||
value = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
value = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
||||||
sprintf(note, "\nCPLD Version, controlled by CPLD editor.\n");
|
sprintf(note, "\nCPLD Version, controlled by CPLD editor.\n");
|
||||||
return sprintf(buf, "0x%02x%s", value, note);
|
return sprintf(buf, "0x%02x%s", value, note);
|
||||||
break;
|
break;
|
||||||
case CPU_BOARD_VER:
|
case CPU_BOARD_VER:
|
||||||
reg = 0x02;
|
reg = 0x02;
|
||||||
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
||||||
value = ret >> 4;
|
value = ret >> 4;
|
||||||
sprintf(note, "\n“0x00”: proto A1\n“0x01”: proto A2\n“0x02”: proto B\n");
|
sprintf(note, "\n“0x00”: proto A1\n“0x01”: proto A2\n“0x02”: proto B\n");
|
||||||
return sprintf(buf, "0x%02x%s", value, note);
|
return sprintf(buf, "0x%02x%s", value, note);
|
||||||
break;
|
break;
|
||||||
case CPU_ID:
|
case CPU_ID:
|
||||||
reg = 0x02;
|
reg = 0x02;
|
||||||
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
||||||
value = ret & 0x0F;
|
value = ret & 0x0F;
|
||||||
sprintf(note, "\n“0x00”: P2041 ECC\n“0x01”: Rangeley ECC\n“0x02”: T2080 ECC\n");
|
sprintf(note, "\n“0x00”: P2041 ECC\n“0x01”: Rangeley ECC\n“0x02”: T2080 ECC\n");
|
||||||
return sprintf(buf, "0x%02x%s", value, note);
|
return sprintf(buf, "0x%02x%s", value, note);
|
||||||
break;
|
break;
|
||||||
case CPLD_RST:
|
case CPLD_RST:
|
||||||
reg = 0x05;
|
reg = 0x05;
|
||||||
mask = 7;
|
mask = 7;
|
||||||
sprintf(note, "\n“1” = Normal operation\n“0” = Reset\n");
|
sprintf(note, "\n“1” = Normal operation\n“0” = Reset\n");
|
||||||
break;
|
break;
|
||||||
case MB_RST:
|
case MB_RST:
|
||||||
reg = 0x05;
|
reg = 0x05;
|
||||||
mask = 1;
|
mask = 1;
|
||||||
sprintf(note, "\n“1” = Normal operation\n“0” = Reset\n");
|
sprintf(note, "\n“1” = Normal operation\n“0” = Reset\n");
|
||||||
break;
|
break;
|
||||||
case I2C_SW_RST:
|
case I2C_SW_RST:
|
||||||
reg = 0x05;
|
reg = 0x05;
|
||||||
mask = 0;
|
mask = 0;
|
||||||
sprintf(note, "\n“1” = Normal operation\n“0” = Reset\n");
|
sprintf(note, "\n“1” = Normal operation\n“0” = Reset\n");
|
||||||
break;
|
break;
|
||||||
case MB_PWR:
|
case MB_PWR:
|
||||||
reg = 0x08;
|
reg = 0x08;
|
||||||
mask = 4;
|
mask = 4;
|
||||||
sprintf(note, "\n“1” = Power rail is good\n“0” = Power rail is failed\n");
|
sprintf(note, "\n“1” = Power rail is good\n“0” = Power rail is failed\n");
|
||||||
break;
|
break;
|
||||||
case PSU_FAN_INT:
|
case PSU_FAN_INT:
|
||||||
reg = 0x0A;
|
reg = 0x0A;
|
||||||
mask = 0;
|
mask = 0;
|
||||||
sprintf(note, "\n“1” = Interrupt doesn’t occur\n“0” = Interrupt occurs\n");
|
sprintf(note, "\n“1” = Interrupt doesn’t occur\n“0” = Interrupt occurs\n");
|
||||||
break;
|
break;
|
||||||
case SPI_WP_GBE:
|
case SPI_WP_GBE:
|
||||||
reg = 0x10;
|
reg = 0x10;
|
||||||
mask = 3;
|
mask = 3;
|
||||||
sprintf(note, "\n“1” = overrides the lock-down function enabling blocks to be erased or programmed using software commands.\n“0” = enables the lock-down mechanism.\n");
|
sprintf(note, "\n“1” = overrides the lock-down function enabling blocks to be erased or programmed using software commands.\n“0” = enables the lock-down mechanism.\n");
|
||||||
break;
|
break;
|
||||||
case EEPROM_WP:
|
case EEPROM_WP:
|
||||||
reg = 0x10;
|
reg = 0x10;
|
||||||
mask = 2;
|
mask = 2;
|
||||||
sprintf(note, "\n“1” = overrides the lock-down function enabling blocks to be erased or programmed using software commands.\n“0” = enables the lock-down mechanism.\n");
|
sprintf(note, "\n“1” = overrides the lock-down function enabling blocks to be erased or programmed using software commands.\n“0” = enables the lock-down mechanism.\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return sprintf(buf, "%d not found", attr->index);
|
return sprintf(buf, "%d not found", attr->index);
|
||||||
}
|
}
|
||||||
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
||||||
value = (ret & (1 << mask)) >> mask;
|
value = (ret & (1 << mask)) >> mask;
|
||||||
return sprintf(buf, "%d%s", value, note);
|
return sprintf(buf, "%d%s", value, note);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t set_cpld_data(struct device *dev, struct device_attribute *dev_attr,
|
static ssize_t set_cpld_data(struct device *dev, struct device_attribute *dev_attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
int mask;
|
int mask;
|
||||||
int err;
|
int err;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned long data;
|
unsigned long data;
|
||||||
unsigned char reg;
|
unsigned char reg;
|
||||||
unsigned char mask_shift;
|
unsigned char mask_shift;
|
||||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
|
||||||
struct platform_data *pdata = dev->platform_data;
|
struct platform_data *pdata = dev->platform_data;
|
||||||
err = kstrtoul(buf, 0, &data);
|
err = kstrtoul(buf, 0, &data);
|
||||||
if (err){
|
if (err){
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data > 0xff){
|
if (data > 0xff){
|
||||||
printk(KERN_ALERT "address out of range (0x00-0xFF)\n");
|
printk(KERN_ALERT "address out of range (0x00-0xFF)\n");
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
switch (attr->index) {
|
switch (attr->index) {
|
||||||
case CPLD_RST:
|
case CPLD_RST:
|
||||||
reg = 0x05;
|
reg = 0x05;
|
||||||
mask = 7;
|
mask = 7;
|
||||||
break;
|
break;
|
||||||
case MB_RST:
|
case MB_RST:
|
||||||
reg = 0x05;
|
reg = 0x05;
|
||||||
mask = 1;
|
mask = 1;
|
||||||
break;
|
break;
|
||||||
case I2C_SW_RST:
|
case I2C_SW_RST:
|
||||||
reg = 0x05;
|
reg = 0x05;
|
||||||
mask = 0;
|
mask = 0;
|
||||||
break;
|
break;
|
||||||
case SPI_WP_GBE:
|
case SPI_WP_GBE:
|
||||||
reg = 0x10;
|
reg = 0x10;
|
||||||
mask = 3;
|
mask = 3;
|
||||||
break;
|
break;
|
||||||
case EEPROM_WP:
|
case EEPROM_WP:
|
||||||
reg = 0x10;
|
reg = 0x10;
|
||||||
mask = 2;
|
mask = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
ret = i2c_smbus_read_byte_data(pdata[cpld].client, reg);
|
||||||
mask_shift = 1 << mask;
|
mask_shift = 1 << mask;
|
||||||
data = (ret & ~mask_shift) | (data << mask);
|
data = (ret & ~mask_shift) | (data << mask);
|
||||||
i2c_smbus_write_byte_data(pdata[cpld].client, cpld_reg_addr, data);
|
i2c_smbus_write_byte_data(pdata[cpld].client, cpld_reg_addr, data);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(cpld_reg_value, S_IRUGO | S_IWUSR, get_cpld_reg_value, set_cpld_reg_value);
|
static DEVICE_ATTR(cpld_reg_value, S_IRUGO | S_IWUSR, get_cpld_reg_value, set_cpld_reg_value);
|
||||||
static DEVICE_ATTR(cpld_reg_addr, S_IRUGO | S_IWUSR, get_cpld_reg_addr, set_cpld_reg_addr);
|
static DEVICE_ATTR(cpld_reg_addr, S_IRUGO | S_IWUSR, get_cpld_reg_addr, set_cpld_reg_addr);
|
||||||
|
|
||||||
static SENSOR_DEVICE_ATTR(cpld_ver, S_IRUGO, get_cpld_data, NULL, CPLD_VER);
|
static SENSOR_DEVICE_ATTR(cpld_ver, S_IRUGO, get_cpld_data, NULL, CPLD_VER);
|
||||||
static SENSOR_DEVICE_ATTR(cpu_board_ver, S_IRUGO, get_cpld_data, NULL, CPU_BOARD_VER);
|
static SENSOR_DEVICE_ATTR(cpu_board_ver, S_IRUGO, get_cpld_data, NULL, CPU_BOARD_VER);
|
||||||
static SENSOR_DEVICE_ATTR(cpu_id, S_IRUGO, get_cpld_data, NULL, CPU_ID);
|
static SENSOR_DEVICE_ATTR(cpu_id, S_IRUGO, get_cpld_data, NULL, CPU_ID);
|
||||||
static SENSOR_DEVICE_ATTR(cpld_rst, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, CPLD_RST);
|
static SENSOR_DEVICE_ATTR(cpld_rst, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, CPLD_RST);
|
||||||
static SENSOR_DEVICE_ATTR(mb_rst, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, MB_RST);
|
static SENSOR_DEVICE_ATTR(mb_rst, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, MB_RST);
|
||||||
static SENSOR_DEVICE_ATTR(i2c_sw_rst, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, I2C_SW_RST);
|
static SENSOR_DEVICE_ATTR(i2c_sw_rst, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, I2C_SW_RST);
|
||||||
static SENSOR_DEVICE_ATTR(mb_pwr, S_IRUGO, get_cpld_data, NULL, MB_PWR);
|
static SENSOR_DEVICE_ATTR(mb_pwr, S_IRUGO, get_cpld_data, NULL, MB_PWR);
|
||||||
static SENSOR_DEVICE_ATTR(psu_fan_int, S_IRUGO, get_cpld_data, NULL, PSU_FAN_INT);
|
static SENSOR_DEVICE_ATTR(psu_fan_int, S_IRUGO, get_cpld_data, NULL, PSU_FAN_INT);
|
||||||
static SENSOR_DEVICE_ATTR(spi_wp_gbe, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, SPI_WP_GBE);
|
static SENSOR_DEVICE_ATTR(spi_wp_gbe, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, SPI_WP_GBE);
|
||||||
static SENSOR_DEVICE_ATTR(eeprom_wp, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, EEPROM_WP);
|
static SENSOR_DEVICE_ATTR(eeprom_wp, S_IRUGO | S_IWUSR, get_cpld_data, set_cpld_data, EEPROM_WP);
|
||||||
|
|
||||||
static struct attribute *ag9032v1_cpld_attrs[] = {
|
static struct attribute *ag9032v1_cpld_attrs[] = {
|
||||||
&dev_attr_cpld_reg_value.attr,
|
&dev_attr_cpld_reg_value.attr,
|
||||||
&dev_attr_cpld_reg_addr.attr,
|
&dev_attr_cpld_reg_addr.attr,
|
||||||
&sensor_dev_attr_cpld_ver.dev_attr.attr,
|
&sensor_dev_attr_cpld_ver.dev_attr.attr,
|
||||||
&sensor_dev_attr_cpu_board_ver.dev_attr.attr,
|
&sensor_dev_attr_cpu_board_ver.dev_attr.attr,
|
||||||
&sensor_dev_attr_cpu_id.dev_attr.attr,
|
&sensor_dev_attr_cpu_id.dev_attr.attr,
|
||||||
&sensor_dev_attr_cpld_rst.dev_attr.attr,
|
&sensor_dev_attr_cpld_rst.dev_attr.attr,
|
||||||
&sensor_dev_attr_mb_rst.dev_attr.attr,
|
&sensor_dev_attr_mb_rst.dev_attr.attr,
|
||||||
&sensor_dev_attr_i2c_sw_rst.dev_attr.attr,
|
&sensor_dev_attr_i2c_sw_rst.dev_attr.attr,
|
||||||
&sensor_dev_attr_mb_pwr.dev_attr.attr,
|
&sensor_dev_attr_mb_pwr.dev_attr.attr,
|
||||||
&sensor_dev_attr_psu_fan_int.dev_attr.attr,
|
&sensor_dev_attr_psu_fan_int.dev_attr.attr,
|
||||||
&sensor_dev_attr_spi_wp_gbe.dev_attr.attr,
|
&sensor_dev_attr_spi_wp_gbe.dev_attr.attr,
|
||||||
&sensor_dev_attr_eeprom_wp.dev_attr.attr,
|
&sensor_dev_attr_eeprom_wp.dev_attr.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct attribute_group ag9032v1_cpld_attr_group = {
|
static struct attribute_group ag9032v1_cpld_attr_group = {
|
||||||
.attrs = ag9032v1_cpld_attrs,
|
.attrs = ag9032v1_cpld_attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init cpld_probe(struct platform_device *pdev)
|
static int __init cpld_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct platform_data *pdata;
|
struct platform_data *pdata;
|
||||||
struct i2c_adapter *parent;
|
struct i2c_adapter *parent;
|
||||||
int ret;
|
int ret;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
pdata = pdev->dev.platform_data;
|
pdata = pdev->dev.platform_data;
|
||||||
if (!pdata) {
|
if (!pdata) {
|
||||||
dev_err(&pdev->dev, "CPUPLD platform data not found\n");
|
dev_err(&pdev->dev, "CPUPLD platform data not found\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = i2c_get_adapter(BUS2);
|
parent = i2c_get_adapter(BUS2);
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
printk(KERN_WARNING "Parent adapter (%d) not found\n",BUS2);
|
printk(KERN_WARNING "Parent adapter (%d) not found\n",BUS2);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata[cpld].client = i2c_new_dummy(parent, pdata[cpld].reg_addr);
|
pdata[cpld].client = i2c_new_dummy(parent, pdata[cpld].reg_addr);
|
||||||
if (!pdata[cpld].client) {
|
if (!pdata[cpld].client) {
|
||||||
printk(KERN_WARNING "Fail to create dummy i2c client for addr %d\n", pdata[cpld].reg_addr);
|
printk(KERN_WARNING "Fail to create dummy i2c client for addr %d\n", pdata[cpld].reg_addr);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = sysfs_create_group(&pdev->dev.kobj, &ag9032v1_cpld_attr_group);
|
retval = sysfs_create_group(&pdev->dev.kobj, &ag9032v1_cpld_attr_group);
|
||||||
if (retval){
|
if (retval){
|
||||||
printk(KERN_WARNING "Fail to create cpupld attribute group");
|
printk(KERN_WARNING "Fail to create cpupld attribute group");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
i2c_unregister_device(pdata[cpld].client);
|
i2c_unregister_device(pdata[cpld].client);
|
||||||
i2c_put_adapter(parent);
|
i2c_put_adapter(parent);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit cpld_remove(struct platform_device *pdev)
|
static int __exit cpld_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct i2c_adapter *parent = NULL;
|
struct i2c_adapter *parent = NULL;
|
||||||
struct platform_data *pdata = pdev->dev.platform_data;
|
struct platform_data *pdata = pdev->dev.platform_data;
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &ag9032v1_cpld_attr_group);
|
sysfs_remove_group(&pdev->dev.kobj, &ag9032v1_cpld_attr_group);
|
||||||
|
|
||||||
if (!pdata) {
|
if (!pdata) {
|
||||||
dev_err(&pdev->dev, "Missing platform data\n");
|
dev_err(&pdev->dev, "Missing platform data\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pdata[cpld].client) {
|
if (pdata[cpld].client) {
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
parent = (pdata[cpld].client)->adapter;
|
parent = (pdata[cpld].client)->adapter;
|
||||||
}
|
}
|
||||||
i2c_unregister_device(pdata[cpld].client);
|
i2c_unregister_device(pdata[cpld].client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i2c_put_adapter(parent);
|
i2c_put_adapter(parent);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver cpld_driver = {
|
static struct platform_driver cpld_driver = {
|
||||||
.probe = cpld_probe,
|
.probe = cpld_probe,
|
||||||
.remove = __exit_p(cpld_remove),
|
.remove = __exit_p(cpld_remove),
|
||||||
.driver = {
|
.driver = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.name = "delta-ag9032v1-cpupld",
|
.name = "delta-ag9032v1-cpupld",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
/*---------------- CPUPLD - end ------------- */
|
/*---------------- CPUPLD - end ------------- */
|
||||||
|
|
||||||
|
|
||||||
/*---------------- module initialization ------------- */
|
/*---------------- module initialization ------------- */
|
||||||
static int __init delta_ag9032v1_cpupld_init(void)
|
static int __init delta_ag9032v1_cpupld_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
printk(KERN_WARNING "ag9032v1_platform_cpupld module initialization\n");
|
printk(KERN_WARNING "ag9032v1_platform_cpupld module initialization\n");
|
||||||
|
|
||||||
// set the CPUPLD prob and remove
|
// set the CPUPLD prob and remove
|
||||||
ret = platform_driver_register(&cpld_driver);
|
ret = platform_driver_register(&cpld_driver);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING "Fail to register cpupld driver\n");
|
printk(KERN_WARNING "Fail to register cpupld driver\n");
|
||||||
goto error_cpupld_driver;
|
goto error_cpupld_driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the CPUPLD
|
// register the CPUPLD
|
||||||
ret = platform_device_register(&ag9032v1_cpld);
|
ret = platform_device_register(&ag9032v1_cpld);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING "Fail to create cpupld device\n");
|
printk(KERN_WARNING "Fail to create cpupld device\n");
|
||||||
goto error_ag9032v1_cpupld;
|
goto error_ag9032v1_cpupld;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_ag9032v1_cpupld:
|
error_ag9032v1_cpupld:
|
||||||
platform_driver_unregister(&cpld_driver);
|
platform_driver_unregister(&cpld_driver);
|
||||||
error_cpupld_driver:
|
error_cpupld_driver:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit delta_ag9032v1_cpupld_exit(void)
|
static void __exit delta_ag9032v1_cpupld_exit(void)
|
||||||
{
|
{
|
||||||
platform_device_unregister(&ag9032v1_cpld);
|
platform_device_unregister(&ag9032v1_cpld);
|
||||||
platform_driver_unregister(&cpld_driver);
|
platform_driver_unregister(&cpld_driver);
|
||||||
}
|
}
|
||||||
module_init(delta_ag9032v1_cpupld_init);
|
module_init(delta_ag9032v1_cpupld_init);
|
||||||
module_exit(delta_ag9032v1_cpupld_exit);
|
module_exit(delta_ag9032v1_cpupld_exit);
|
||||||
|
|
||||||
MODULE_DESCRIPTION("DNI ag9032v1 CPLD Platform Support");
|
MODULE_DESCRIPTION("DNI ag9032v1 CPLD Platform Support");
|
||||||
MODULE_AUTHOR("Stanley Chi <stanley.chi@deltaww.com>");
|
MODULE_AUTHOR("Stanley Chi <stanley.chi@deltaww.com>");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,5 +5,8 @@
|
|||||||
#fan speed monitol start
|
#fan speed monitol start
|
||||||
/usr/share/sonic/device/x86_64-delta_ag9032v1-r0/fancontrol.service /usr/share/sonic/device/x86_64-delta_ag9032v1-r0/fancontrol &
|
/usr/share/sonic/device/x86_64-delta_ag9032v1-r0/fancontrol.service /usr/share/sonic/device/x86_64-delta_ag9032v1-r0/fancontrol &
|
||||||
|
|
||||||
|
#set led status
|
||||||
|
/usr/local/bin/led_status.sh &
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ FAN2_EEPROM="-y 32 0x52 0x0a"
|
|||||||
FAN3_EEPROM="-y 33 0x53 0x0a"
|
FAN3_EEPROM="-y 33 0x53 0x0a"
|
||||||
FAN4_EEPROM="-y 34 0x54 0x0a"
|
FAN4_EEPROM="-y 34 0x54 0x0a"
|
||||||
FAN5_EEPROM="-y 35 0x55 0x0a"
|
FAN5_EEPROM="-y 35 0x55 0x0a"
|
||||||
LED_CONTROL="/sys/devices/platform/delta-ag9032v1-cpld.0/led_control"
|
LED_CONTROL="/sys/devices/platform/delta-ag9032v1-swpld.0/led_control"
|
||||||
FAN1_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/i2c-37/37-002c/fan5_input"
|
FAN1_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/i2c-37/37-002c/fan5_input"
|
||||||
FAN1_REAR_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/i2c-38/38-002d/fan5_input"
|
FAN1_REAR_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/i2c-38/38-002d/fan5_input"
|
||||||
FAN2_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/i2c-37/37-002c/fan4_input"
|
FAN2_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/i2c-37/37-002c/fan4_input"
|
||||||
|
@ -28,7 +28,6 @@ start)
|
|||||||
modprobe delta_ag9032v1_cpupld
|
modprobe delta_ag9032v1_cpupld
|
||||||
|
|
||||||
/usr/local/bin/ag9032v1_platform_init.sh
|
/usr/local/bin/ag9032v1_platform_init.sh
|
||||||
|
|
||||||
echo "done."
|
echo "done."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user