remove auto exit of production and added sysfs interface
Subsystems (3)
Andreas Werner
maintainerv2 cover remove auto exit of production and added sysfs interface
This patch set introduces new sysfs entries for BMC status information as well as the ABI documention.
The mfd core driver now does not exit the production mode automatically. The new sysfs entry allows the userland to exit the production mode if required.
Changes in v2:
- added I2C maintainer in CC because this patches are also I2C related.
- fixed irrelevant changes (alignments) in the mfd driver
- update subject lines
that they match the format of the subsystem
Andreas Werner (4):
mfd: menf21bmc: Remove auto exiting of production mode and add sysfs
interface
doc: ABI: Added sysfs description for the menf21bmc MFD driver
mfd: menf21bmc: Add additional sysfs entries for BMC status
information
doc: ABI: Add documentation for the additional sysfs status
information
.../ABI/testing/sysfs-bus-i2c-devices-menf21bmc | 40 ++++++ drivers/mfd/menf21bmc.c | 158 ++++++++++++++++++--- 2 files changed, 177 insertions(+), 21 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-menf21bmc
Signature · 1 line
2.6.2
Andreas Werner
maintainerPATCH v2 1/4 mfd: menf21bmc: Remove auto exiting of production mode and add sysfs interface
Changed "exit production mode" from automatic exiting to manually using the sysfs interface.
If the driver exit the production mode automatically, the board will not start anymore if the bootloader does not already have the "BIOS life sign" feature.
This patch remove the auto mechanism and add a sysfs interface to manually exiting the production e.g. during the EOL test of the board.
--- drivers/mfd/menf21bmc.c | 65 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 21 deletions(-)
drivers/mfd/menf21bmc.c +44 -21
@@ -27,31 +27,57 @@ static struct mfd_cell menf21bmc_cell[] = { { .name = "menf21bmc_hwmon", } }; -static int menf21bmc_wdt_exit_prod_mode (struct i2c_client *client) +static ssize_t menf21bmc_mode_show (struct device *dev, +struct device_attribute *attr,char *buf) { -int val, ret; +struct i2c_client *client =to_i2c_client (dev); +int val; val =i2c_smbus_read_byte_data (client,BMC_CMD_WDT_PROD_STAT );if (val <0 )return val; +return sprintf (buf,"%d\n" , val); +} + +static ssize_t menf21bmc_mode_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t size) +{ +struct i2c_client *client =to_i2c_client (dev); +unsigned long mode_val; +int ret; + +if (kstrtoul (buf,0 , &mode_val)) +return -EINVAL ; +/* -* Production mode should be not active after delivery of the Board. -* To be sure we check it, inform the user and exit the mode -* if active. +* We cannot set the production mode (0). +* This is the default mode. If exited once, +* it cannot be set anymore. */ -if (val ==0x00 ) { -dev_info (&client->dev, -"BMC in production mode. Exit production mode\n" ); +if (!mode_val) +return -EINVAL ; - ret =i2c_smbus_write_byte (client,BMC_CMD_WDT_EXIT_PROD ); -if (ret <0 ) -return ret; - } + ret =i2c_smbus_write_byte (client,BMC_CMD_WDT_EXIT_PROD ); +if (ret <0 ) +return ret; -return 0 ; +return size; } +static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, menf21bmc_mode_show, + menf21bmc_mode_store); + +static struct attribute *menf21bmc_attributes[] = { + &dev_attr_mode.attr, +NULL +}; + +static const struct attribute_group menf21bmc_attr_group = { + .attrs = menf21bmc_attributes, +}; +static int menf21bmc_probe (struct i2c_client *client,const struct i2c_device_id *ids) {
@@ -86,20 +112,15 @@ menf21bmc_probe(struct i2c_client *client, const struct i2c_device_id *ids)dev_info (&client->dev,"FW Revision: %02d.%02d.%02d\n" , rev_major, rev_minor, rev_main); -/* -* We have to exit the Production Mode of the BMC to activate the -* Watchdog functionality and the BIOS life sign monitoring. -*/ - ret =menf21bmc_wdt_exit_prod_mode (client); -if (ret <0 ) { -dev_err (&client->dev,"failed to leave production mode\n" ); + ret =sysfs_create_group (&client->dev.kobj, &menf21bmc_attr_group); +if (ret)return ret; - } ret =mfd_add_devices (&client->dev,0 , menf21bmc_cell,ARRAY_SIZE (menf21bmc_cell),NULL ,0 ,NULL );if (ret <0 ) {dev_err (&client->dev,"failed to add BMC sub-devices\n" ); +sysfs_remove_group (&client->dev.kobj, &menf21bmc_attr_group);return ret; }
@@ -108,7 +129,9 @@ menf21bmc_probe(struct i2c_client *client, const struct i2c_device_id *ids)static int menf21bmc_remove (struct i2c_client *client) { +sysfs_remove_group (&client->dev.kobj, &menf21bmc_attr_group);mfd_remove_devices (&client->dev); +return 0 ; }
Signature · 1 line
2.6.2
Re: [PATCH v2 1/4] mfd: menf21bmc: Remove auto exiting of production mode and add sysfs interface
Quoted 7 lines · Andreas Werner
Changed "exit production mode" from automatic exiting to manually using the sysfs interface.
If the driver exit the production mode automatically, the board will not start anymore if the bootloader does not already have the "BIOS life sign" feature.
Quoted 7 lines
This patch remove the auto mechanism and add a sysfs interface to manually exiting the production e.g. during the EOL test of the board.
Signed-off-by Andreas Werner <[email protected]>--- drivers/mfd/menf21bmc.c | 65 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 21 deletions(-)
Quoted 109 lines
drivers/mfd/menf21bmc.c +44
-21@@ -27,31 +27,57 @@ static struct mfd_cell menf21bmc_cell[] = { { .name = "menf21bmc_hwmon", } }; -static int menf21bmc_wdt_exit_prod_mode (struct i2c_client *client) +static ssize_t menf21bmc_mode_show (struct device *dev, +struct device_attribute *attr,char *buf) { -int val, ret; +struct i2c_client *client =to_i2c_client (dev); +int val; val =i2c_smbus_read_byte_data (client,BMC_CMD_WDT_PROD_STAT );if (val <0 )return val; +return sprintf (buf,"%d\n" , val); +} + +static ssize_t menf21bmc_mode_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t size) +{ +struct i2c_client *client =to_i2c_client (dev); +unsigned long mode_val; +int ret; + +if (kstrtoul (buf,0 , &mode_val)) +return -EINVAL ; +/* -* Production mode should be not active after delivery of the Board. -* To be sure we check it, inform the user and exit the mode -* if active. +* We cannot set the production mode (0). +* This is the default mode. If exited once, +* it cannot be set anymore. */ -if (val ==0x00 ) { -dev_info (&client->dev, -"BMC in production mode. Exit production mode\n" ); +if (!mode_val) +return -EINVAL ; - ret =i2c_smbus_write_byte (client,BMC_CMD_WDT_EXIT_PROD ); -if (ret <0 ) -return ret; - } + ret =i2c_smbus_write_byte (client,BMC_CMD_WDT_EXIT_PROD ); +if (ret <0 ) +return ret; -return 0 ; +return size; } +static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, menf21bmc_mode_show, + menf21bmc_mode_store); + +static struct attribute *menf21bmc_attributes[] = { + &dev_attr_mode.attr, +NULL +}; + +static const struct attribute_group menf21bmc_attr_group = { + .attrs = menf21bmc_attributes, +}; +static int menf21bmc_probe (struct i2c_client *client,const struct i2c_device_id *ids) {@@ -86,20 +112,15 @@ menf21bmc_probe(struct i2c_client *client, const struct i2c_device_id *ids)dev_info (&client->dev,"FW Revision: %02d.%02d.%02d\n" , rev_major, rev_minor, rev_main); -/* -* We have to exit the Production Mode of the BMC to activate the -* Watchdog functionality and the BIOS life sign monitoring. -*/ - ret =menf21bmc_wdt_exit_prod_mode (client); -if (ret <0 ) { -dev_err (&client->dev,"failed to leave production mode\n" ); + ret =sysfs_create_group (&client->dev.kobj, &menf21bmc_attr_group); +if (ret)return ret; - } ret =mfd_add_devices (&client->dev,0 , menf21bmc_cell,ARRAY_SIZE (menf21bmc_cell),NULL ,0 ,NULL );if (ret <0 ) {dev_err (&client->dev,"failed to add BMC sub-devices\n" ); +sysfs_remove_group (&client->dev.kobj, &menf21bmc_attr_group);return ret; }@@ -108,7 +129,9 @@ menf21bmc_probe(struct i2c_client *client, const struct i2c_device_id *ids)static int menf21bmc_remove (struct i2c_client *client) { +sysfs_remove_group (&client->dev.kobj, &menf21bmc_attr_group);mfd_remove_devices (&client->dev); +return 0 ; }
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Andreas Werner
maintainerPATCH v2 2/4 doc: ABI: Added sysfs description for the menf21bmc MFD driver
In reply to Andreas WernerThis patch add the description of the "mode" sysfs interface for the menf21bmc MFD driver.
--- Documentation/ABI/testing/sysfs-bus-i2c-devices-menf21bmc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-menf21bmc
Documentation/ABI/testing/sysfs-bus-i2c-devices-menf21bmc new file +14 -0
@@ -0,0 +1,14 @@ +What: /sys/bus/i2c/devices/.../mode +Date: December 2015 +KernelVersion: 4.4 +Contact: Andreas Werner <[email protected]> +Description: Set and get the mode of the device. + The production mode cannot be set again if the device + is set to active once. + + In production mode the BMC does not wait for BIOS life sign, + did not reset the CPU board on Watchdog timeout and allow the + programming of the HW Variant. + + 0 = production mode + 1 = active mode
Signature · 1 line
2.6.2
Andreas Werner
maintainerPATCH v2 3/4 mfd: menf21bmc: Add additional sysfs entries for BMC status information
In reply to Andreas WernerThis patch adds additional sysfs entries to provide status information to the userland.
The following informations are now provided:
- Get operation hours counter
- Get board slot address
- Get powercycle counter
- Set/get Hw Variant
--- drivers/mfd/menf21bmc.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)
drivers/mfd/menf21bmc.c +93 -0
@@ -20,6 +20,10 @@#define BMC_CMD_REV_MAJOR 0x80#define BMC_CMD_REV_MINOR 0x81#define BMC_CMD_REV_MAIN 0x82 +#define BMC_CMD_SLOT_ADDRESS 0x8c +#define BMC_CMD_HW_VARIANT 0x8f +#define BMC_CMD_PWRCYCL_CNT 0x93 +#define BMC_CMD_OP_HRS_CNT 0x94static struct mfd_cell menf21bmc_cell[] = { { .name ="menf21bmc_wdt" , },
@@ -66,11 +70,100 @@ static ssize_t menf21bmc_mode_store(struct device *dev,return size; } +static ssize_t menf21bmc_hw_variant_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_word_data (client,BMC_CMD_HW_VARIANT ); +if (val <0 ) +return val; + +return sprintf (buf,"0x%04x\n" , val); + +} + +static ssize_t menf21bmc_hw_variant_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t size) +{ +struct i2c_client *client =to_i2c_client (dev); +unsigned long hw_variant; +int ret; + +if (kstrtoul (buf,0 , &hw_variant)) +return -EINVAL ; + +if (hw_variant <0 || hw_variant >0xffff ) +return -EINVAL ; + + ret =i2c_smbus_write_word_data (client,BMC_CMD_HW_VARIANT , + hw_variant); +if (ret <0 ) +return ret; + +return size; + +} + +static ssize_t menf21bmc_pwrcycl_cnt_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_word_data (client,BMC_CMD_PWRCYCL_CNT ); +if (val <0 ) +return val; + +return sprintf (buf,"%d\n" , val); +} + +static ssize_t menf21bmc_op_hrs_cnt_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_word_data (client,BMC_CMD_OP_HRS_CNT ); +if (val <0 ) +return val; + +return sprintf (buf,"%d\n" , val); +} + +static ssize_t menf21bmc_slot_address_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_byte_data (client,BMC_CMD_SLOT_ADDRESS ); +if (val <0 ) +return val; + +return sprintf (buf,"%d\n" , val); +} + static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, menf21bmc_mode_show, menf21bmc_mode_store); +static DEVICE_ATTR(hw_variant, S_IRUGO | S_IWUSR, menf21bmc_hw_variant_show, + menf21bmc_hw_variant_store); +static DEVICE_ATTR(pwrcycl_cnt, S_IRUGO, menf21bmc_pwrcycl_cnt_show, NULL); +static DEVICE_ATTR(op_hrs_cnt, S_IRUGO, menf21bmc_op_hrs_cnt_show, NULL); +static DEVICE_ATTR(slot_address, S_IRUGO, menf21bmc_slot_address_show, NULL);static struct attribute *menf21bmc_attributes[] = { &dev_attr_mode.attr, + &dev_attr_hw_variant.attr, + &dev_attr_pwrcycl_cnt.attr, + &dev_attr_op_hrs_cnt.attr, + &dev_attr_slot_address.attr,NULL };
Signature · 1 line
2.6.2
Re: [PATCH v2 3/4] mfd: menf21bmc: Add additional sysfs entries for BMC status information
Quoted 9 lines · Andreas Werner
This patch adds additional sysfs entries to provide status information to the userland.
The following informations are now provided:
- Get operation hours counter
- Get board slot address
- Get powercycle counter
- Set/get Hw Variant
Quoted 4 lines
Signed-off-by Andreas Werner <[email protected]>--- drivers/mfd/menf21bmc.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)
Quoted 116 lines
drivers/mfd/menf21bmc.c +93
-0@@ -20,6 +20,10 @@#define BMC_CMD_REV_MAJOR 0x80#define BMC_CMD_REV_MINOR 0x81#define BMC_CMD_REV_MAIN 0x82 +#define BMC_CMD_SLOT_ADDRESS 0x8c +#define BMC_CMD_HW_VARIANT 0x8f +#define BMC_CMD_PWRCYCL_CNT 0x93 +#define BMC_CMD_OP_HRS_CNT 0x94static struct mfd_cell menf21bmc_cell[] = { { .name ="menf21bmc_wdt" , },@@ -66,11 +70,100 @@ static ssize_t menf21bmc_mode_store(struct device *dev,return size; } +static ssize_t menf21bmc_hw_variant_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_word_data (client,BMC_CMD_HW_VARIANT ); +if (val <0 ) +return val; + +return sprintf (buf,"0x%04x\n" , val); + +} + +static ssize_t menf21bmc_hw_variant_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t size) +{ +struct i2c_client *client =to_i2c_client (dev); +unsigned long hw_variant; +int ret; + +if (kstrtoul (buf,0 , &hw_variant)) +return -EINVAL ; + +if (hw_variant <0 || hw_variant >0xffff ) +return -EINVAL ; + + ret =i2c_smbus_write_word_data (client,BMC_CMD_HW_VARIANT , + hw_variant); +if (ret <0 ) +return ret; + +return size; + +} + +static ssize_t menf21bmc_pwrcycl_cnt_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_word_data (client,BMC_CMD_PWRCYCL_CNT ); +if (val <0 ) +return val; + +return sprintf (buf,"%d\n" , val); +} + +static ssize_t menf21bmc_op_hrs_cnt_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_word_data (client,BMC_CMD_OP_HRS_CNT ); +if (val <0 ) +return val; + +return sprintf (buf,"%d\n" , val); +} + +static ssize_t menf21bmc_slot_address_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +int val; + + val =i2c_smbus_read_byte_data (client,BMC_CMD_SLOT_ADDRESS ); +if (val <0 ) +return val; + +return sprintf (buf,"%d\n" , val); +} + static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, menf21bmc_mode_show, menf21bmc_mode_store); +static DEVICE_ATTR(hw_variant, S_IRUGO | S_IWUSR, menf21bmc_hw_variant_show, + menf21bmc_hw_variant_store); +static DEVICE_ATTR(pwrcycl_cnt, S_IRUGO, menf21bmc_pwrcycl_cnt_show, NULL); +static DEVICE_ATTR(op_hrs_cnt, S_IRUGO, menf21bmc_op_hrs_cnt_show, NULL); +static DEVICE_ATTR(slot_address, S_IRUGO, menf21bmc_slot_address_show, NULL);static struct attribute *menf21bmc_attributes[] = { &dev_attr_mode.attr, + &dev_attr_hw_variant.attr, + &dev_attr_pwrcycl_cnt.attr, + &dev_attr_op_hrs_cnt.attr, + &dev_attr_slot_address.attr,NULL };
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Andreas Werner
maintainerPATCH v2 4/4 doc: ABI: Add documentation for the additional sysfs status information
In reply to Andreas Werner--- .../ABI/testing/sysfs-bus-i2c-devices-menf21bmc | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+)
Documentation/ABI/testing/sysfs-bus-i2c-devices-menf21bmc +26 -0
@@ -12,3 +12,29 @@ Description: Set and get the mode of the device. 0 = production mode 1 = active mode + +What: /sys/bus/i2c/devices/.../hw_variant +Date: December 2015 +KernelVersion: 4.4 +Contact: Andreas Werner <[email protected]> +Description: Set and get the hardware variant ID. + +What: /sys/bus/i2c/devices/.../pwrcycl_cnt +Date: December 2015 +KernelVersion: 4.4 +Contact: Andreas Werner <[email protected]> +Description: Read the BMC powercycle counter. + +What: /sys/bus/i2c/devices/.../op_hrs_cnt +Date: December 2015 +KernelVersion: 4.4 +Contact: Andreas Werner <[email protected]> +Description: Read the operation hours counter + +What: /sys/bus/i2c/devices/.../slot_address +Date: December 2015 +KernelVersion: 4.4 +Contact: Andreas Werner <[email protected]> +Description: Read the slot address of the board. + Slot address is the geographical address + in a CPCI rack/backplane.
Signature · 1 line
2.6.2