scsi: ufs: set the device reference clock setting
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v15 1/2 scsi: ufs: set the device reference clock setting
From: Subhash Jadavani <[email protected]>
UFS host supplies the reference clock to UFS device and UFS device specification allows host to provide one of the 4 frequencies (19.2 MHz, 26 MHz, 38.4 MHz, 52 MHz) for reference clock. Host should set the device reference clock frequency setting in the device based on what frequency it is supplying to UFS device.
--- .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 6 ++ drivers/scsi/ufs/ufs.h | 14 ++++ drivers/scsi/ufs/ufshcd.c | 83 ++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 2 + 4 files changed, 105 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +6 -0
@@ -33,6 +33,12 @@ Optional properties: - clocks : List of phandle and clock specifier pairs - clock-names : List of clock input name strings sorted in the same order as the clocks property. + "ref_clk" indicates reference clock frequency. + UFS host supplies reference clock to UFS device and UFS device + specification allows host to provide one of the 4 frequencies (19.2 MHz, + 26 MHz, 38.4 MHz, 52MHz) for reference clock. This "ref_clk" entry is + parsed and used to update the reference clock setting in device. + Defaults to 26 MHz(as per specification) if not specified by host. - freq-table-hz : Array of <min max> operating frequencies stored in the same order as the clocks property. If this property is not defined or a value in the array is "0" then it is assumed
drivers/scsi/ufs/ufs.h +14 -0
@@ -378,6 +378,20 @@ enum query_opcode { UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, }; +/* bRefClkFreq attribute values */ +enum ufs_ref_clk_freq { +REF_CLK_FREQ_19_2_MHZ =0 , +REF_CLK_FREQ_26_MHZ =1 , +REF_CLK_FREQ_38_4_MHZ =2 , +REF_CLK_FREQ_52_MHZ =3 , +REF_CLK_FREQ_INVAL =-1 , +}; + +struct ufs_ref_clk { +unsigned long freq_hz; +enum ufs_ref_clk_freq val; +}; +/* Query response result code */ enum {QUERY_RESULT_SUCCESS =0x00 ,
drivers/scsi/ufs/ufshcd.c +83 -0
107 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +2 -0
@@ -548,6 +548,7 @@ struct ufs_hba {void *priv;unsigned int irq;bool is_irq_enabled; +enum ufs_ref_clk_freq dev_ref_clk_freq;/* Interrupt aggregation support is broken */ #define UFSHCD_QUIRK_BROKEN_INTR_AGGR 0x1
@@ -746,6 +747,7 @@ static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)int ufshcd_wait_for_register (struct ufs_hba *hba,u32 reg,u32 mask,u32 val,unsigned long interval_us,unsigned long timeout_ms,bool can_sleep); +void ufshcd_parse_dev_ref_clk_freq (struct ufs_hba *hba,struct clk *refclk);static inline void check_upiu_size (void ) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 8 lines · Sayali Lokhande
From: Subhash Jadavani <[email protected]>
UFS host supplies the reference clock to UFS device and UFS device specification allows host to provide one of the 4 frequencies (19.2 MHz, 26 MHz, 38.4 MHz, 52 MHz) for reference clock. Host should set the device reference clock frequency setting in the device based on what frequency it is supplying to UFS device.
Quoted 6 lines
Signed-off-by Subhash Jadavani <[email protected]>Signed-off-by Can Guo <[email protected]>Signed-off-by Sayali Lokhande <[email protected]>Reviewed-by Evan Green <[email protected]>--- .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 6 ++
Quoted 4 lines
drivers/scsi/ufs/ufs.h | 14 ++++ drivers/scsi/ufs/ufshcd.c | 83 ++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 2 + 4 files changed, 105 insertions(+)
PATCH v15 2/2 scsi: ufs: Add configfs support for UFS provisioning
In reply to a message not in the archiveThis patch adds configfs support to provision UFS device at runtime. This feature can be primarily useful in factory or assembly line as some devices may be required to be configured multiple times during initial system development phase. Configuration Descriptors can be written multiple times until bConfigDescrLock attribute is zero.
Configuration descriptor buffer consists of Device and Unit descriptor configurable parameters which are parsed from vendor specific provisioning file and then passed via configfs node at runtime to provision ufs device.CONFIG_CONFIGFS_FS and CONFIG_SCSI_UFS_PROVISION needs to be enabled for using this feature.
Usage:
1) To read current configuration descriptor with index X (where index X can be 0/1/2/3) :
cat /config/<device_name>/ufs_config_desc_X
2) To write configuration descriptor with index X :
echo <config_desc_buf> > /config/<device_name>/ufs_config_desc_X
--- Documentation/ABI/testing/configfs-driver-ufs | 12 ++ drivers/scsi/ufs/Kconfig | 10 ++ drivers/scsi/ufs/Makefile | 4 +- drivers/scsi/ufs/ufs-configfs.c | 237 ++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.c | 3 +- drivers/scsi/ufs/ufshcd.h | 18 ++ 6 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-driver-ufs create mode 100644 drivers/scsi/ufs/ufs-configfs.c
Documentation/ABI/testing/configfs-driver-ufs new file +12 -0
@@ -0,0 +1,12 @@ +What: /config/*/ufs_config_desc_X +Date: Jun 2018 +KernelVersion: 4.20 +Description: + This file shows bytes of the current ufs configuration descriptor + with index X (where X = 0/1/2/3) set in device. This can be used to + provision ufs device if bConfigDescrLock is 0. + For more details, refer 14.1.6.3 Configuration Descriptor and + table 14-12 - Unit Descriptor configurable parameters from specs for + description and format of each configuration descriptor parameter. + Parameters of Configuration descriptor buffer for respective index + needs to be passed as bytes in space separated format.
drivers/scsi/ufs/Kconfig +10 -0
@@ -100,3 +100,13 @@ config SCSI_UFS_QCOM Select this if you have UFS controller on QCOM chipset. If unsure, say N. + +config SCSI_UFS_PROVISION + bool "Runtime UFS Provisioning support" + depends on SCSI_UFSHCD && CONFIGFS_FS + help + This enables runtime UFS provisioning support. This can be used + primarily during assembly line as some devices may be required to + be configured multiple times during initial development phase. + + If unsure, say N.
drivers/scsi/ufs/Makefile +3 -1
@@ -4,6 +4,8 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210. obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o -ufshcd-core-objs := ufshcd.o ufs-sysfs.o +ufshcd-core-objs-y := ufshcd.o ufs-sysfs.o +ufshcd-core-objs-$(CONFIG_SCSI_UFS_PROVISION) += ufs-configfs.o +ufshcd-core-objs := $(ufshcd-core-objs-y) obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufs-configfs.c new file +237 -0
237 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.c +2 -1
@@ -7704,6 +7704,7 @@ int ufshcd_shutdown(struct ufs_hba *hba)void ufshcd_remove (struct ufs_hba *hba) {ufs_sysfs_remove_nodes (hba->dev); +ufshcd_configfs_exit (hba);scsi_remove_host (hba->host);/* disable interrupts */ ufshcd_disable_intr (hba, hba->intr_mask);
@@ -7958,7 +7959,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)async_schedule (ufshcd_async_scan, hba);ufs_sysfs_add_nodes (hba->dev); - +ufshcd_configfs_init (hba,dev_name (hba->dev));return 0 ; out_remove_scsi_host:
drivers/scsi/ufs/ufshcd.h +18 -0
@@ -37,6 +37,7 @@#ifndef _UFSHCD_H#define _UFSHCD_H +#include <linux/configfs.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h>
@@ -515,6 +516,9 @@ struct ufs_hba {struct Scsi_Host *host;struct device *dev; +#ifdef CONFIG_SCSI_UFS_PROVISION +struct configfs_subsystem subsys; +#endif /* * This field is to keep a reference to "scsi_device" corresponding to * "UFS device" W-LU.
@@ -868,6 +872,20 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index,int ufshcd_hold (struct ufs_hba *hba,bool async);void ufshcd_release (struct ufs_hba *hba); +/* Expose UFS configfs API's */ +#ifndef CONFIG_SCSI_UFS_PROVISION +static inline void ufshcd_configfs_init (struct ufs_hba *hba,const char *name) +{ +} + +static inline void ufshcd_configfs_exit (struct ufs_hba *hba) +{ +} +#else +void ufshcd_configfs_init (struct ufs_hba *hba,const char *name); +void ufshcd_configfs_exit (struct ufs_hba *hba); +#endif +int ufshcd_map_desc_id_to_length (struct ufs_hba *hba,enum desc_idn desc_id,int *desc_length);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Avri Altman
reviewerRE: [PATCH V15 2/2] scsi: ufs: Add configfs support for UFS provisioning
Hi,
drivers/scsi/ufs/Makefile obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210. · line 9
Quoted 11 lines
+++ b/drivers/scsi/ufs/Makefile
(quoted diff) +0
-0@@ -4,6 +4,8 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.
obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
ufshcd-dwc.o tc-dwc-g210.o
obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.odrivers/scsi/ufs/Makefile +3
-1-ufshcd-core-objs := ufshcd.o ufs-sysfs.o +ufshcd-core-objs-y := ufshcd.o ufs-sysfs.o +ufshcd-core-objs-$(CONFIG_SCSI_UFS_PROVISION) += ufs-configfs.o +ufshcd-core-objs := $(ufshcd-core-objs-y)
This will work, but I think it should be:
ufshcd-core-y += ufshcd.o ufs-sysfs.o
ufshcd-core-$( CONFIG_SCSI_UFS_PROVISION) += ufs-configfs.o
Also, you may want to rebase your patches with Martin's 4.20/scsi-queue
Thanks,
Avri