Skip to content

Commit

Permalink
Merge pull request #76 from SW-CSA/cel_develop
Browse files Browse the repository at this point in the history
Cel develop
  • Loading branch information
MickeyZhan authored May 20, 2019
2 parents 7b75a03 + 6dff49a commit 8d5dbfd
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ int reset_i2c_mux(int bus)
if(syscpld_client == NULL)
return -ENODEV;

printk(KERN_WARNING "bus %d is hanged, try to reset the PCA9548\n", bus);
//printk(KERN_WARNING "bus %d is hanged, try to reset the PCA9548\n", bus);
data = i2c_get_clientdata(syscpld_client);
mutex_lock(&data->idd_lock);
/* get reset reigster status */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#define SYSFS_READ 0
#define SYSFS_WRITE 1

#define DPS1100_PSU_NUM 4

#define DPS1100_OP_REG_ADDR PMBUS_OPERATION
#define DPS1100_OP_SHUTDOWN_CMD 0x0
#define DPS1100_OP_POWERON_CMD 0x80
Expand Down Expand Up @@ -159,13 +161,18 @@ struct dps1100_data {
struct sysfs_attr_t *sysfs_attr;
};


struct dps1100_vin_threshold_t {
int bus;
int vin_min;
int vin_max;
};

static const struct i2c_device_id dps1100_id[] = {
{"dps550", DPS550 },
{"dps1100", DPS1100 },
{ }
};
struct dps1100_vin_threshold_t dps1100_vin_threshold[DPS1100_PSU_NUM];

enum PSU {
PSU1 = 1,
Expand Down Expand Up @@ -295,6 +302,89 @@ static int dps1100_reg_byte_store(struct device *dev,
}



static ssize_t dps1100_vin_threshold_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int i;
int read_val = 0;
int bus = -1;
struct pmbus_data *pdata = dev_get_drvdata(dev);
struct i2c_client *client = to_i2c_client(pdata->dev);
struct sysfs_attr_t *sysfs_attr = TO_I2C_SYSFS_ATTR(attr);
struct i2c_dev_attr_t *dev_attr = sysfs_attr->i2c_attr;

if(client->adapter)
bus = client->adapter->nr;

if(bus < 0)
return -1;

for(i = 0; i < DPS1100_PSU_NUM; i++) {
if(dps1100_vin_threshold[i].bus == bus) {
if(dev_attr->reg == 0)
read_val = dps1100_vin_threshold[i].vin_min;
else
read_val = dps1100_vin_threshold[i].vin_max;
break;
}
}

return sprintf(buf, "%d\n", read_val);
}

static int dps1100_vin_threshold_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int i;
int rc = 0;
int write_value = 0;
int bus = -1;
struct pmbus_data *pdata = dev_get_drvdata(dev);
struct i2c_client *client = to_i2c_client(pdata->dev);
struct sysfs_attr_t *sysfs_attr = TO_I2C_SYSFS_ATTR(attr);
struct i2c_dev_attr_t *dev_attr = sysfs_attr->i2c_attr;


if (buf == NULL) {
return -ENXIO;
}

if(client->adapter)
bus = client->adapter->nr;

if(bus < 0)
return -1;

rc = kstrtol(buf, 0, &write_value);
if (rc != 0) {
return count;
}

for(i = 0; i < DPS1100_PSU_NUM; i++) {
if(dps1100_vin_threshold[i].bus == bus) {
if(dev_attr->reg == 0)
dps1100_vin_threshold[i].vin_min = write_value;
else
dps1100_vin_threshold[i].vin_max = write_value;
return count;
}
}
for(i = 0; i < DPS1100_PSU_NUM; i++) {
if(dps1100_vin_threshold[i].bus == 0) {
if(dev_attr->reg == 0)
dps1100_vin_threshold[i].vin_min = write_value;
else
dps1100_vin_threshold[i].vin_max = write_value;
dps1100_vin_threshold[i].bus = bus;
break;
}
}

return count;
}


static ssize_t dps1100_reg_word_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand Down Expand Up @@ -352,16 +442,16 @@ static const struct i2c_dev_attr_t psu_attr_table[] = {
{
"in1_min",
NULL,
I2C_DEV_ATTR_SHOW_DEFAULT,
I2C_DEV_ATTR_STORE_DEFAULT,
dps1100_vin_threshold_show,
dps1100_vin_threshold_store,
0,
},
{
"in1_max",
NULL,
I2C_DEV_ATTR_SHOW_DEFAULT,
I2C_DEV_ATTR_STORE_DEFAULT,
0,
dps1100_vin_threshold_show,
dps1100_vin_threshold_store,
1,
},
{
"in2_min",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,123 @@ set_hwmon_threshold() {
echo "-1"
fi
}

bmc_reboot() {
slave=0
if [ $# -lt 1 ] ; then
return 1
fi
if /usr/local/bin/boot_info.sh |grep "Slave Flash" ; then
slave=1
else
slave=0
fi
if [ "$1" == "master" ]; then
if [ $slave -eq 1 ]; then #current is slave booting
devmem_set_bit 0x1e78502c 7
logger -p user.warning "Set BMC booting flash to master"
fi
return 0
elif [ "$1" == "slave" ]; then
if [ $slave -eq 0 ]; then ##current is master booting
devmem_set_bit 0x1e78502c 7
logger -p user.warning "Set BMC booting flash to slave"
fi
return 0
elif [ "$1" == "reboot" ]; then
((val=$(devmem 0x1e78502c)))
((ret=$val&0x80))
if [ $ret -gt 0 ]; then
if [ $slave -eq 1 ]; then #current is slave, switch to master
logger -p user.warning "BMC will be booting from master flash"
boot_from master
else
logger -p user.warning "BMC will be booting from slave flash"
boot_from slave
fi
else
logger -p user.warning "BMC will be booting from current flash"
reboot #not set boot flash, just reboot bmc
fi
return 0
fi
return 1
}

cpld_refresh() {
ret=1
if [ $# -lt 2 ]; then
echo "cpld_refresh <type> <image_path>"
return 1
fi
boardtype=$(board_type)
if [ "$boardtype" = "Fishbone32" ] || [ "$boardtype" = "Fishbone48" ]; then
#power off CPU
logger -p user.warning "cpld_refresh: power off CPU"
/usr/local/bin/wedge_power.sh off
sleep 1
logger -p user.warning "cpld_refresh: power on Switch"
i2cset -f -y 0 0x0d 0x40 0x1
sleep 3

logger -p user.warning "cpld_refresh: start $1 CPLD refreshing"
gpio_set L2 1
ispvm -f 1000 dll /usr/lib/libcpldupdate_dll_gpio.so $2 --tdo 212 --tdi 213 --tms 214 --tck 215
ret=$?
logger -p user.warning "cpld_refresh: done, result=$ret"
gpio_set L2 0
logger -p user.warning "cpld_refresh: power cycle CPU"
/usr/local/bin/wedge_power.sh cycle
logger -p user.warning "cpld_refresh: BMC rebooting"
reboot
elif [ $boardtype = "Phalanx" ]; then
#power off CPU
logger -p user.warning "cpld_refresh: power off CPU"
/usr/local/bin/wedge_power.sh off
sleep 1
logger -p user.warning "cpld_refresh: start $1 CPLD refreshing"
if [ "$1" = "fan" -o "$1" = "switch" -o "$1" = "cpu" -o "$1" = "base" -o "$1" = "combo" ]; then #loop1
if [ -e $2 ]; then
gpio_set L2 1
gpio_set P0 0
ispvm -f 1000 dll /usr/lib/libcpldupdate_dll_gpio.so $2 --tdo 212 --tdi 213 --tms 214 --tck 215
ret=$?
gpio_set L2 0
gpio_set P0 0
gpio_set O0 0
fi
elif [ "$1" = "top_lc" ]; then #loop2
if [ -e $2 ]; then
gpio_set L2 1
gpio_set P0 1
gpio_set O0 0
ispvm -f 1000 dll /usr/lib/libcpldupdate_dll_gpio.so $2 --tdo 212 --tdi 213 --tms 214 --tck 215
ret=$?
gpio_set L2 0
gpio_set P0 0
gpio_set O0 0
fi
elif [ "$1" = "bottom_lc" ]; then #loop3
if [ -e $2 ]; then
gpio_set L2 1
gpio_set P0 1
gpio_set O0 1
ispvm -f 1000 dll /usr/lib/libcpldupdate_dll_gpio.so $2 --tdo 212 --tdi 213 --tms 214 --tck 215
ret=$?
gpio_set L2 0
gpio_set P0 0
gpio_set O0 0
fi
else
echo "cpld_refresh <type> <image_path>"
fi
logger -p user.warning "cpld_refresh: done, result=$ret"
logger -p user.warning "cpld_refresh: power cycle CPU"
/usr/local/bin/wedge_power.sh cycle
logger -p user.warning "cpld_refresh: BMC rebooting"
reboot
else
echo "Board not support"
fi
return $ret
}
Loading

0 comments on commit 8d5dbfd

Please sign in to comment.