Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <keosung.park@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20240811143757.2538212-3-avri.altman@wdc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Avri Altman and committed by
Martin K. Petersen
f51d7481 b9d10446

+80
+27
Documentation/ABI/testing/sysfs-driver-ufs
··· 1532 1532 Description: 1533 1533 rtc_update_ms indicates how often the host should synchronize or update the 1534 1534 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 <avri.altman@wdc.com> 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 <avri.altman@wdc.com> 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 <avri.altman@wdc.com> 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.
+53
drivers/ufs/core/ufs-sysfs.c
··· 525 525 .attrs = ufs_sysfs_capabilities_attrs, 526 526 }; 527 527 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 + 528 580 static ssize_t monitor_enable_show(struct device *dev, 529 581 struct device_attribute *attr, char *buf) 530 582 { ··· 1560 1508 static const struct attribute_group *ufs_sysfs_groups[] = { 1561 1509 &ufs_sysfs_default_group, 1562 1510 &ufs_sysfs_capabilities_group, 1511 + &ufs_sysfs_ufshci_group, 1563 1512 &ufs_sysfs_monitor_group, 1564 1513 &ufs_sysfs_power_info_group, 1565 1514 &ufs_sysfs_device_descriptor_group,