Skip to content

Commit f51d748

Browse files
avri-altman-sndkmartinkpetersen
authored andcommitted
scsi: ufs: Add HCI capabilities sysfs group
The standard register map of UFSHCI is comprised of several groups. The first group (starting from offset 0x00), is the host capabilities group. It contains some interesting information that otherwise is not available, e.g. the UFS version of the platform etc. Reviewed-by: Keoseong Park <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Bean Huo <[email protected]> Signed-off-by: Avri Altman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b9d1044 commit f51d748

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

Documentation/ABI/testing/sysfs-driver-ufs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,3 +1532,30 @@ Contact: Bean Huo <[email protected]>
15321532
Description:
15331533
rtc_update_ms indicates how often the host should synchronize or update the
15341534
UFS RTC. If set to 0, this will disable UFS RTC periodic update.
1535+
1536+
What: /sys/devices/platform/.../ufshci_capabilities/version
1537+
Date: August 2024
1538+
Contact: Avri Altman <[email protected]>
1539+
Description:
1540+
Host Capabilities register group: UFS version register.
1541+
Symbol - VER. This file shows the UFSHCD version.
1542+
Example: Version 3.12 would be represented as 0000_0312h.
1543+
The file is read only.
1544+
1545+
What: /sys/devices/platform/.../ufshci_capabilities/product_id
1546+
Date: August 2024
1547+
Contact: Avri Altman <[email protected]>
1548+
Description:
1549+
Host Capabilities register group: product ID register.
1550+
Symbol - HCPID. This file shows the UFSHCD product id.
1551+
The content of this register is vendor specific.
1552+
The file is read only.
1553+
1554+
What: /sys/devices/platform/.../ufshci_capabilities/man_id
1555+
Date: August 2024
1556+
Contact: Avri Altman <[email protected]>
1557+
Description:
1558+
Host Capabilities register group: manufacturer ID register.
1559+
Symbol - HCMID. This file shows the UFSHCD manufacturer id.
1560+
The Manufacturer ID is defined by JEDEC in JEDEC-JEP106.
1561+
The file is read only.

drivers/ufs/core/ufs-sysfs.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,58 @@ static const struct attribute_group ufs_sysfs_capabilities_group = {
525525
.attrs = ufs_sysfs_capabilities_attrs,
526526
};
527527

528+
static ssize_t version_show(struct device *dev,
529+
struct device_attribute *attr, char *buf)
530+
{
531+
struct ufs_hba *hba = dev_get_drvdata(dev);
532+
533+
return sysfs_emit(buf, "0x%x\n", hba->ufs_version);
534+
}
535+
536+
static ssize_t product_id_show(struct device *dev,
537+
struct device_attribute *attr, char *buf)
538+
{
539+
int ret;
540+
u32 val;
541+
struct ufs_hba *hba = dev_get_drvdata(dev);
542+
543+
ret = ufshcd_read_hci_reg(hba, &val, REG_CONTROLLER_PID);
544+
if (ret)
545+
return ret;
546+
547+
return sysfs_emit(buf, "0x%x\n", val);
548+
}
549+
550+
static ssize_t man_id_show(struct device *dev,
551+
struct device_attribute *attr, char *buf)
552+
{
553+
int ret;
554+
u32 val;
555+
struct ufs_hba *hba = dev_get_drvdata(dev);
556+
557+
ret = ufshcd_read_hci_reg(hba, &val, REG_CONTROLLER_MID);
558+
if (ret)
559+
return ret;
560+
561+
return sysfs_emit(buf, "0x%x\n", val);
562+
}
563+
564+
static DEVICE_ATTR_RO(version);
565+
static DEVICE_ATTR_RO(product_id);
566+
static DEVICE_ATTR_RO(man_id);
567+
568+
static struct attribute *ufs_sysfs_ufshci_cap_attrs[] = {
569+
&dev_attr_version.attr,
570+
&dev_attr_product_id.attr,
571+
&dev_attr_man_id.attr,
572+
NULL
573+
};
574+
575+
static const struct attribute_group ufs_sysfs_ufshci_group = {
576+
.name = "ufshci_capabilities",
577+
.attrs = ufs_sysfs_ufshci_cap_attrs,
578+
};
579+
528580
static ssize_t monitor_enable_show(struct device *dev,
529581
struct device_attribute *attr, char *buf)
530582
{
@@ -1508,6 +1560,7 @@ static const struct attribute_group ufs_sysfs_attributes_group = {
15081560
static const struct attribute_group *ufs_sysfs_groups[] = {
15091561
&ufs_sysfs_default_group,
15101562
&ufs_sysfs_capabilities_group,
1563+
&ufs_sysfs_ufshci_group,
15111564
&ufs_sysfs_monitor_group,
15121565
&ufs_sysfs_power_info_group,
15131566
&ufs_sysfs_device_descriptor_group,

0 commit comments

Comments
 (0)