Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 3 additions & 38 deletions debian/sonic-platform-nokia-ixr7220h3.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,6 @@
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
configure)
chmod a+x /usr/local/bin/ixr7220h3_platform_init.sh
systemctl enable ixr7220h3_platform_init.service
systemctl start ixr7220h3_platform_init.service

;;

abort-upgrade|abort-remove|abort-deconfigure)
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
chmod a+x /usr/local/bin/ixr7220h3_platform_init.sh
systemctl enable ixr7220h3_platform_init.service
systemctl start ixr7220h3_platform_init.service
60 changes: 14 additions & 46 deletions ixr7220h3/modules/nokia_7220_h3_cpupld.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,13 @@
#define CPU_CPLD_UPGRADE_REG 0x0B

// REG BIT FIELD POSITION or MASK
#define SYS_CPLD_REV_REG_MNR_MSK 0xF
#define SYS_CPLD_REV_REG_MJR 0x4

#define BOARD_REV_TYPE_REG_TYPE_MSK 0xF
#define BOARD_REV_TYPE_REG_REV 0x4

#define WATCHDOG_REG_WD_PUNCH 0x0
#define WATCHDOG_REG_WD_EN 0x3
#define WATCHDOG_REG_WD_TIMER 0x4

#define CPU_SYS_RST_REG_CPU_PWR_ERR 0x0
#define CPU_SYS_RST_REG_BOOT_FAIL 0x2
#define CPU_SYS_RST_REG_BIOS_SWITCHOVER 0x3
#define CPU_SYS_RST_REG_WD_FAIL 0x4
#define CPU_SYS_RST_REG_WARM_RST 0x6
#define CPU_SYS_RST_REG_COLD_RST 0x7

#define POWER_STATUS_REG_V1P35 0x0
#define POWER_STATUS_REG_V1P8 0x1
#define POWER_STATUS_REG_V3P3 0x2
Expand All @@ -68,10 +58,10 @@ static const unsigned short cpld_address_list[] = {0x31, I2C_CLIENT_END};
struct cpld_data {
struct i2c_client *client;
struct mutex update_lock;
int cpld_major_version;
int cpld_minor_version;
int code_ver;
int board_revision;
int board_type;
int cpu_sys_rst;
};

static int nokia_7220_h3_cpupld_read(struct cpld_data *data, u8 reg)
Expand Down Expand Up @@ -102,16 +92,10 @@ static void nokia_7220_h3_cpupld_write(struct cpld_data *data, u8 reg, u8 value)
mutex_unlock(&data->update_lock);
}

static ssize_t show_cpld_major_version(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct cpld_data *data = dev_get_drvdata(dev);
return sprintf(buf, "0x%02x\n", data->cpld_major_version);
}

static ssize_t show_cpld_minor_version(struct device *dev, struct device_attribute *devattr, char *buf)
static ssize_t show_code_ver(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct cpld_data *data = dev_get_drvdata(dev);
return sprintf(buf, "0x%02x\n", data->cpld_minor_version);
return sprintf(buf, "0x%02x\n", data->code_ver);
}

static ssize_t show_board_revision(struct device *dev, struct device_attribute *devattr, char *buf)
Expand All @@ -133,7 +117,7 @@ static ssize_t show_board_revision(struct device *dev, struct device_attribute *
revision = "X03";
break;
default:
revision = "RSVD";
revision = "RESERVED";
break;
}

Expand Down Expand Up @@ -284,11 +268,7 @@ static ssize_t set_watchdog(struct device *dev, struct device_attribute *devattr
static ssize_t show_sys_rst_cause(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct cpld_data *data = dev_get_drvdata(dev);
struct sensor_device_attribute *sda = to_sensor_dev_attr(devattr);
u8 val = 0;
val = nokia_7220_h3_cpupld_read(data, CPU_SYS_RST_REG);

return sprintf(buf, "%d\n", (val>>sda->index) & 0x1 ? 1:0);
return sprintf(buf, "%02x\n", data->cpu_sys_rst);
}

static ssize_t show_cpu_pwr_status(struct device *dev, struct device_attribute *devattr, char *buf)
Expand Down Expand Up @@ -337,20 +317,14 @@ static ssize_t set_cpu_cpld_upgrade(struct device *dev, struct device_attribute
}

// sysfs attributes
static SENSOR_DEVICE_ATTR(cpld_major_version, S_IRUGO, show_cpld_major_version, NULL, 0);
static SENSOR_DEVICE_ATTR(cpld_minor_version, S_IRUGO, show_cpld_minor_version, NULL, SYS_CPLD_REV_REG_MJR);
static SENSOR_DEVICE_ATTR(code_ver, S_IRUGO, show_code_ver, NULL, 0);
static SENSOR_DEVICE_ATTR(board_revision, S_IRUGO, show_board_revision, NULL, 0);
static SENSOR_DEVICE_ATTR(board_type, S_IRUGO, show_board_type, NULL, BOARD_REV_TYPE_REG_REV);
static SENSOR_DEVICE_ATTR(scratch, S_IRUGO | S_IWUSR, show_scratch, set_scratch, 0);
static SENSOR_DEVICE_ATTR(wd_punch, S_IRUGO | S_IWUSR, show_watchdog, set_watchdog, WATCHDOG_REG_WD_PUNCH);
static SENSOR_DEVICE_ATTR(wd_enable, S_IRUGO | S_IWUSR, show_watchdog, set_watchdog, WATCHDOG_REG_WD_EN);
static SENSOR_DEVICE_ATTR(wd_timer, S_IRUGO | S_IWUSR, show_watchdog, set_watchdog, WATCHDOG_REG_WD_TIMER);
static SENSOR_DEVICE_ATTR(cpu_pwr_err, S_IRUGO, show_sys_rst_cause, NULL, CPU_SYS_RST_REG_CPU_PWR_ERR);
static SENSOR_DEVICE_ATTR(boot_fail, S_IRUGO, show_sys_rst_cause, NULL, CPU_SYS_RST_REG_BOOT_FAIL);
static SENSOR_DEVICE_ATTR(bios_switchover, S_IRUGO, show_sys_rst_cause, NULL, CPU_SYS_RST_REG_BIOS_SWITCHOVER);
static SENSOR_DEVICE_ATTR(wd_reset, S_IRUGO, show_sys_rst_cause, NULL, CPU_SYS_RST_REG_WD_FAIL);
static SENSOR_DEVICE_ATTR(warm_reset, S_IRUGO, show_sys_rst_cause, NULL, CPU_SYS_RST_REG_WARM_RST);
static SENSOR_DEVICE_ATTR(cold_reset, S_IRUGO, show_sys_rst_cause, NULL, CPU_SYS_RST_REG_COLD_RST);
static SENSOR_DEVICE_ATTR(cpu_sys_rst, S_IRUGO, show_sys_rst_cause, NULL, 0);
static SENSOR_DEVICE_ATTR(cpu_pwr_1v35, S_IRUGO, show_cpu_pwr_status, NULL, POWER_STATUS_REG_V1P35);
static SENSOR_DEVICE_ATTR(cpu_pwr_1v8, S_IRUGO, show_cpu_pwr_status, NULL, POWER_STATUS_REG_V1P8);
static SENSOR_DEVICE_ATTR(cpu_pwr_3v3, S_IRUGO, show_cpu_pwr_status, NULL, POWER_STATUS_REG_V3P3);
Expand All @@ -362,20 +336,14 @@ static SENSOR_DEVICE_ATTR(cpu_pwr_1v5, S_IRUGO, show_cpu_pwr_status, NULL, POWER
static SENSOR_DEVICE_ATTR(cpu_cpld_upgrade, S_IRUGO | S_IWUSR, show_cpu_cpld_upgrade, set_cpu_cpld_upgrade, 0);

static struct attribute *nokia_7220_h3_cpupld_attributes[] = {
&sensor_dev_attr_cpld_major_version.dev_attr.attr,
&sensor_dev_attr_cpld_minor_version.dev_attr.attr,
&sensor_dev_attr_code_ver.dev_attr.attr,
&sensor_dev_attr_board_revision.dev_attr.attr,
&sensor_dev_attr_board_type.dev_attr.attr,
&sensor_dev_attr_scratch.dev_attr.attr,
&sensor_dev_attr_wd_punch.dev_attr.attr,
&sensor_dev_attr_wd_enable.dev_attr.attr,
&sensor_dev_attr_wd_timer.dev_attr.attr,
&sensor_dev_attr_cpu_pwr_err.dev_attr.attr,
&sensor_dev_attr_boot_fail.dev_attr.attr,
&sensor_dev_attr_bios_switchover.dev_attr.attr,
&sensor_dev_attr_wd_reset.dev_attr.attr,
&sensor_dev_attr_warm_reset.dev_attr.attr,
&sensor_dev_attr_cold_reset.dev_attr.attr,
&sensor_dev_attr_cpu_sys_rst.dev_attr.attr,
&sensor_dev_attr_cpu_pwr_1v35.dev_attr.attr,
&sensor_dev_attr_cpu_pwr_1v8.dev_attr.attr,
&sensor_dev_attr_cpu_pwr_3v3.dev_attr.attr,
Expand Down Expand Up @@ -422,10 +390,10 @@ static int nokia_7220_h3_cpupld_probe(struct i2c_client *client)
goto exit;
}

data->cpld_major_version = nokia_7220_h3_cpupld_read(data, SYS_CPLD_REV_REG) & SYS_CPLD_REV_REG_MNR_MSK;
data->cpld_minor_version = nokia_7220_h3_cpupld_read(data, SYS_CPLD_REV_REG) >> SYS_CPLD_REV_REG_MJR;
data->code_ver = nokia_7220_h3_cpupld_read(data, SYS_CPLD_REV_REG);
data->board_revision = nokia_7220_h3_cpupld_read(data, BOARD_REV_TYPE_REG) & BOARD_REV_TYPE_REG_TYPE_MSK;
data->board_type = nokia_7220_h3_cpupld_read(data, BOARD_REV_TYPE_REG) >> BOARD_REV_TYPE_REG_REV;
data->board_type = nokia_7220_h3_cpupld_read(data, BOARD_REV_TYPE_REG) >> BOARD_REV_TYPE_REG_REV;
data->cpu_sys_rst = nokia_7220_h3_cpupld_read(data, CPU_SYS_RST_REG);

return 0;

Expand Down Expand Up @@ -481,4 +449,4 @@ MODULE_DESCRIPTION("NOKIA-7220-IXR-H3 CPLD driver");
MODULE_LICENSE("GPL");

module_init(nokia_7220_h3_cpupld_init);
module_exit(nokia_7220_h3_cpupld_exit);
module_exit(nokia_7220_h3_cpupld_exit);
10 changes: 5 additions & 5 deletions ixr7220h3/modules/nokia_7220_h3_swpld1.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct cpld_data {
int swbd_id;
int swbd_version;
int cpld_type;
int cpld_version;
int code_ver;
};

static int nokia_7220_h3_swpld_read(struct cpld_data *data, u8 reg)
Expand Down Expand Up @@ -226,7 +226,7 @@ static ssize_t show_cpld_type(struct device *dev, struct device_attribute *devat
static ssize_t show_cpld_version(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct cpld_data *data = dev_get_drvdata(dev);
return sprintf(buf, "0x%02x\n", data->cpld_version);
return sprintf(buf, "0x%02x\n", data->code_ver);
}

static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf)
Expand Down Expand Up @@ -604,7 +604,7 @@ static ssize_t set_misc_sel_reg(struct device *dev, struct device_attribute *dev
static SENSOR_DEVICE_ATTR(swbd_id, S_IRUGO, show_swbd_id, NULL, 0);
static SENSOR_DEVICE_ATTR(swbd_version, S_IRUGO, show_swbd_version, NULL, 0);
static SENSOR_DEVICE_ATTR(cpld_type, S_IRUGO, show_cpld_type, NULL, SWPLD1_CPLD_REV_REG_TYPE);
static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO, show_cpld_version, NULL, 0);
static SENSOR_DEVICE_ATTR(code_ver, S_IRUGO, show_cpld_version, NULL, 0);
static SENSOR_DEVICE_ATTR(scratch, S_IRUGO | S_IWUSR, show_scratch, set_scratch, 0);

static SENSOR_DEVICE_ATTR(psu2_alert, S_IRUGO, show_psu1_reg, NULL, SWPLD1_PSU1_REG_PSU2_INT);
Expand Down Expand Up @@ -690,7 +690,7 @@ static struct attribute *nokia_7220_h3_swpld1_attributes[] = {
&sensor_dev_attr_swbd_id.dev_attr.attr,
&sensor_dev_attr_swbd_version.dev_attr.attr,
&sensor_dev_attr_cpld_type.dev_attr.attr,
&sensor_dev_attr_cpld_version.dev_attr.attr,
&sensor_dev_attr_code_ver.dev_attr.attr,
&sensor_dev_attr_scratch.dev_attr.attr,

&sensor_dev_attr_psu2_alert.dev_attr.attr,
Expand Down Expand Up @@ -811,7 +811,7 @@ static int nokia_7220_h3_swpld1_probe(struct i2c_client *client)
data->swbd_id = nokia_7220_h3_swpld_read(data, SWPLD1_SWBD_ID_REG);
data->swbd_version = nokia_7220_h3_swpld_read(data, SWPLD1_SWBD_VER_REG);
data->cpld_type = nokia_7220_h3_swpld_read(data, SWPLD1_CPLD_REV_REG) >> SWPLD1_CPLD_REV_REG_TYPE;
data->cpld_version = nokia_7220_h3_swpld_read(data, SWPLD1_CPLD_REV_REG) & SWPLD1_CPLD_REV_REG_MSK;
data->code_ver = nokia_7220_h3_swpld_read(data, SWPLD1_CPLD_REV_REG) & SWPLD1_CPLD_REV_REG_MSK;

return 0;

Expand Down
Loading
Loading