Skip to content

Commit

Permalink
[devices]: Reset I2C MUX in S6000 while invoking platform reboot (#2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
sridhar-ravindran authored and lguohan committed Feb 16, 2019
1 parent a9a61d4 commit be92a25
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
2 changes: 2 additions & 0 deletions device/dell/x86_64-dell_s6000_s1220-r0/installer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ echo "Replace ONIE reboot with Dell reset commands"
# set I2C GPIO mux
[ -d /sys/class/gpio/gpio1 ] || echo 1 > /sys/class/gpio/export
[ -d /sys/class/gpio/gpio2 ] || echo 2 > /sys/class/gpio/export
[ -d /sys/class/gpio/gpio10 ] || echo 10 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio1/direction
echo out > /sys/class/gpio/gpio2/direction
echo out > /sys/class/gpio/gpio10/direction
echo 0 > /sys/class/gpio/gpio1/value
echo 0 > /sys/class/gpio/gpio2/value

Expand Down
10 changes: 10 additions & 0 deletions device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/bin/sh

# Export GPIO10 if needed
[ -d /sys/class/gpio/gpio10 ] || echo 10 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio10/direction

#Toggle GPIO10 pin (to reset MUX)
echo 1 > /sys/class/gpio/gpio10/value
echo 0 > /sys/class/gpio/gpio10/value


#Power Reset
echo 1 > /sys/devices/platform/dell-s6000-cpld.0/power_reset
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,14 @@ static ssize_t set_power_reset(struct device *dev, struct device_attribute *deva

static ssize_t get_power_reset(struct device *dev, struct device_attribute *devattr, char *buf)
{
return sprintf(buf, "0\n");
uint8_t ret = 0;
struct cpld_platform_data *pdata = dev->platform_data;

ret = i2c_smbus_read_byte_data(pdata[system_cpld].client, 0x1);
if (ret < 0)
return sprintf(buf, "read error");

return sprintf(buf, "0x%x\n", ret);
}

static ssize_t get_fan_prs(struct device *dev, struct device_attribute *devattr, char *buf)
Expand Down Expand Up @@ -1006,6 +1013,55 @@ static ssize_t set_fan2_led(struct device *dev, struct device_attribute *devattr
return count;
}

static ssize_t get_system_cpld_ver(struct device *dev,
struct device_attribute *devattr, char *buf)
{
uint8_t ret;
u32 data = 0;
struct cpld_platform_data *pdata = dev->platform_data;

ret = i2c_smbus_read_byte_data(pdata[system_cpld].client, 0x0);
if (ret < 0)
return sprintf(buf, "read error");

data = ret & (0x0f);

return sprintf(buf, "0x%x\n", data);
}

static ssize_t get_master_cpld_ver(struct device *dev,
struct device_attribute *devattr, char *buf)
{
uint8_t ret;
u32 data = 0;
struct cpld_platform_data *pdata = dev->platform_data;

ret = i2c_smbus_read_byte_data(pdata[master_cpld].client, 0x1);
if (ret < 0)
return sprintf(buf, "read error");

data = ret & (0x0f);

return sprintf(buf, "0x%x\n", data);
}

static ssize_t get_slave_cpld_ver(struct device *dev,
struct device_attribute *devattr, char *buf)
{
uint8_t ret;
u32 data = 0;
struct cpld_platform_data *pdata = dev->platform_data;

ret = i2c_smbus_read_byte_data(pdata[slave_cpld].client, 0xa);
if (ret < 0)
return sprintf(buf, "read error");

data = ret & (0x0f);

return sprintf(buf, "0x%x\n", data);
}


static DEVICE_ATTR(qsfp_modsel, S_IRUGO, get_modsel, NULL);
static DEVICE_ATTR(qsfp_modprs, S_IRUGO, get_modprs, NULL);
static DEVICE_ATTR(qsfp_lpmode, S_IRUGO | S_IWUSR, get_lpmode, set_lpmode);
Expand All @@ -1024,6 +1080,9 @@ static DEVICE_ATTR(fan_led, S_IRUGO | S_IWUSR, get_fan_led, set_fan_led);
static DEVICE_ATTR(fan0_led, S_IRUGO | S_IWUSR, get_fan0_led, set_fan0_led);
static DEVICE_ATTR(fan1_led, S_IRUGO | S_IWUSR, get_fan1_led, set_fan1_led);
static DEVICE_ATTR(fan2_led, S_IRUGO | S_IWUSR, get_fan2_led, set_fan2_led);
static DEVICE_ATTR(system_cpld_ver, S_IRUGO, get_system_cpld_ver, NULL);
static DEVICE_ATTR(master_cpld_ver, S_IRUGO, get_master_cpld_ver, NULL);
static DEVICE_ATTR(slave_cpld_ver, S_IRUGO, get_slave_cpld_ver, NULL);

static struct attribute *s6000_cpld_attrs[] = {
&dev_attr_qsfp_modsel.attr,
Expand All @@ -1044,6 +1103,9 @@ static struct attribute *s6000_cpld_attrs[] = {
&dev_attr_fan0_led.attr,
&dev_attr_fan1_led.attr,
&dev_attr_fan2_led.attr,
&dev_attr_system_cpld_ver.attr,
&dev_attr_master_cpld_ver.attr,
&dev_attr_slave_cpld_ver.attr,
NULL,
};

Expand Down

0 comments on commit be92a25

Please sign in to comment.