This patch adds a few read-only sysfs attributes which provide
some device information that is exposed from the devices. Primarily
component and device names and versions. These are documented in
Documentation/ABI/testing/sysfs-class-switchtec.
Signed-off-by: Logan Gunthorpe
Signed-off-by: Stephen Bates
Tested-by: Krishna Dhulipala
Reviewed-by: Wei Zhang
Reviewed-by: Jens Axboe
Reviewed-by: Greg Kroah-Hartman
---
Documentation/ABI/testing/sysfs-class-switchtec | 96
MAINTAINERS | 1 +
drivers/pci/switch/switchtec.c | 113
3 files changed, 210 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-class-switchtec
diff --git a/Documentation/ABI/testing/sysfs-class-switchtec
b/Documentation/ABI/testing/sysfs-class-switchtec
new file mode 100644
index 000..48cb4c1
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-switchtec
@@ -0,0 +1,96 @@
+switchtec - Microsemi Switchtec PCI Switch Management Endpoint
+
+For details on this subsystem look at Documentation/switchtec.txt.
+
+What: /sys/class/switchtec
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: The switchtec class subsystem folder.
+ Each registered switchtec driver is represented by a switchtecX
+ subfolder (X being an integer >= 0).
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/component_id
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Component identifier as stored in the hardware (eg. PM8543)
+ (read only)
+Values:arbitrary string.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/component_revision
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Component revision stored in the hardware (read only)
+Values:integer.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/component_vendor
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Component vendor as stored in the hardware (eg. MICROSEM)
+ (read only)
+Values:arbitrary string.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/device_version
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Device version as stored in the hardware (read only)
+Values:integer.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/fw_version
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Currently running firmware version (read only)
+Values:integer (in hexadecimal).
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/partition
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Partition number for this device in the switch (read only)
+Values:integer.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/partition_count
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Total number of partitions in the switch (read only)
+Values:integer.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/product_id
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Product identifier as stored in the hardware (eg. PSX 48XG3)
+ (read only)
+Values:arbitrary string.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/product_revision
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Product revision stored in the hardware (eg. RevB)
+ (read only)
+Values:arbitrary string.
+
+
+What: /sys/class/switchtec/switchtec[0-9]+/product_vendor
+Date: 05-Jan-2017
+KernelVersion: v4.11
+Contact: Logan Gunthorpe
+Description: Product vendor as stored in the hardware (eg. MICROSEM)
+ (read only)
+Values:arbitrary string.
diff --git a/MAINTAINERS b/MAINTAINERS
index aa702b0..6fed938 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9513,6 +9513,7 @@ M:Logan Gunthorpe
L: linux-...@vger.kernel.org
S: Maintained
F: Documentation/switchtec.txt
+F: Documentation/ABI/testing/sysfs-class-switchtec
F: drivers/pci/switch/switchtec*
PCI DRIVER FOR NVIDIA TEGRA
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 4aaf89b..2e47d79 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -495,6 +495,118 @@ static void mrpc_timeout_work(struct work_struct *work)
mutex_unlock(>mrpc_mutex);
}
+static ssize_t device_version_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct switchtec_dev *stdev = to_stdev(dev);
+ u32 ver;
+
+ ver =