diff --git a/.gitignore b/.gitignore index 49861324aa1d..92741be17bc1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ rules/config.user # Build artifacts -fsroot/ +fsroot*/ fs.* target/ *.deb diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/Makefile index 9c453600451d..cc0802f32c9b 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/Makefile +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/Makefile @@ -3,7 +3,10 @@ obj-m:= accton_i2c_cpld.o \ accton_as7326_56x_fan.o accton_as7326_56x_leds.o \ accton_as7326_56x_psu.o ym2651y.o \ pddf_custom_psu.o - + +CFLAGS_pddf_custom_psu.o := -I$(M)/../../../../pddf/i2c/modules/include +KBUILD_EXTRA_SYMBOLS := $(M)/../../../../pddf/i2c/Module.symvers.PDDF + else ifeq (,$(KERNEL_SRC)) $(error KERNEL_SRC is not defined) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c index 606019f3ea44..691942c2cd1f 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c @@ -48,7 +48,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, static ssize_t get_enable(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_enable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); @@ -150,12 +149,6 @@ enum sysfs_fan_attributes { &sensor_dev_attr_pwm##index.dev_attr.attr, \ &sensor_dev_attr_pwm##index##_enable.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr - - #define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) #define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr @@ -200,8 +193,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); -/* System temperature for fancontrol */ -DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); static struct attribute *as7326_56x_fan_attributes[] = { /* fan related attributes */ @@ -230,7 +221,6 @@ static struct attribute *as7326_56x_fan_attributes[] = { DECLARE_FAN_DIRECTION_ATTR(5), DECLARE_FAN_DIRECTION_ATTR(6), DECLARE_FAN_DUTY_CYCLE_ATTR(1), - DECLARE_FAN_SYSTEM_TEMP_ATTR(), NULL }; @@ -451,55 +441,55 @@ static int get_temp_file_path( } /*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} +// static int read_devfile_temp1_input( +// struct device *dev, +// int bus_nr, +// unsigned short addr, +// struct device *hwmon_dev, +// int *miniCelsius) +// { +// struct file *sfd; +// char buffer[96]; +// char devfile[96]; +// int rc, status; +// int rdlen, value; +// mm_segment_t old_fs; + +// rc = 0; +// get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); +// sfd = filp_open(devfile, O_RDONLY, 0); +// if (IS_ERR(sfd)) { +// pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); +// return -ENOENT; +// } +// dev_dbg(dev, "Found device:%s\n",devfile); + +// if(!(sfd->f_op) || !(sfd->f_op->read) ) { +// pr_err("file %s cann't readable ?\n",devfile); +// return -ENOENT; +// } + +// old_fs = get_fs(); +// set_fs(KERNEL_DS); +// rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); +// if (rdlen == 0) { +// pr_err( "File(%s) empty!\n", devfile); +// rc = -EIO; +// goto exit; +// } +// status = sscanf(buffer, "%d", &value); +// if (status != 1) { +// rc = -EIO; +// goto exit; +// } +// *miniCelsius = value; +// dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); + +// exit: +// set_fs(old_fs); +// filp_close(sfd, 0); +// return rc; +// } static u8 is_lm75_data_due(struct i2c_client *client) { @@ -535,79 +525,79 @@ static bool lm75_addr_mached(unsigned short addr) return 0; } -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as7326_56x_fan_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} +// static int _find_lm75_device(struct device *dev, void *data) +// { +// struct device_driver *driver; +// struct as7326_56x_fan_data *prv = data; +// char *driver_name = THERMAL_SENSORS_DRIVER; + +// driver = dev->driver; +// if (driver && driver->name && +// strcmp(driver->name, driver_name) == 0) +// { +// struct i2c_client *client; +// client = to_i2c_client(dev); +// if (client) +// { +// /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ +// struct i2c_adapter *adap = client->adapter; +// int miniCelsius = 0; + +// if (! lm75_addr_mached(client->addr)) +// { +// return 0; +// } + +// if (!adap) { +// return -ENXIO; +// } + +// /* If the data is not updated, read them from devfile +// to drive them updateing data from chip.*/ +// if (is_lm75_data_due(client)) +// { +// struct device *hwmon_dev; + +// hwmon_dev = get_hwmon_dev(client); +// if(0 == read_devfile_temp1_input(dev, adap->nr, +// client->addr, hwmon_dev, &miniCelsius)) +// { +// prv->system_temp += miniCelsius; +// prv->sensors_found++; +// } + +// } +// else +// { +// get_lm75_temp(client, &miniCelsius); +// prv->system_temp += miniCelsius; +// prv->sensors_found++; + +// } +// } +// } +// return 0; +// } /*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} +// static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, +// char *buf) +// { +// ssize_t ret = 0; +// struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); + +// data->system_temp=0; +// data->sensors_found=0; +// i2c_for_each_dev(data, _find_lm75_device); +// if (NUM_THERMAL_SENSORS != data->sensors_found) +// { +// dev_dbg(dev,"only %d of %d temps are found\n", +// data->sensors_found, NUM_THERMAL_SENSORS); +// data->system_temp = INT_MAX; +// } +// ret = sprintf(buf, "%d\n",data->system_temp); +// return ret; +// } static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c index 33bd7618c3a0..4e3d4af3ef3f 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c @@ -9,7 +9,7 @@ #include #include #include -#include "../../../../pddf/i2c/modules/include/pddf_psu_defs.h" +#include "pddf_psu_defs.h" ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribute *da, char *buf); ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf);