scsi: ufs: add support of generic PHY and ICE in Qualcomm chips
Subsystems (5)
PATCH v4 1/1 scsi: ufs: add support of generic PHY and ICE in Qualcomm chips
In this change we add support to the generic PHY framework. Two UFS phys are implemented:
qmp-20nm and qmp-28nm.
Also, the files in this change implement the UFS HW (controller & PHY) specific behavior in Qualcomm chips.
Relocation of a few header files is needed in order to expose routines and data structures between PHY driver and UFS driver.
Also, this change include the implementation of Inline Crypto Engine (ICE) in Qualcomm chips.
--- Documentation/devicetree/bindings/ufs/ufs-msm.txt | 49 + .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 113 +- drivers/phy/Makefile | 3 + drivers/phy/phy-qcom-ufs-qmp-20nm.c | 266 +++++ drivers/phy/phy-qcom-ufs-qmp-20nm.h | 232 ++++ drivers/phy/phy-qcom-ufs-qmp-28nm.c | 331 ++++++ drivers/phy/phy-qcom-ufs-qmp-28nm.h | 738 ++++++++++++ drivers/phy/phy-qcom-ufs.c | 777 +++++++++++++ drivers/scsi/ufs/Kconfig | 24 + drivers/scsi/ufs/Makefile | 2 + drivers/scsi/ufs/ufs-qcom-ice.c | 522 +++++++++ drivers/scsi/ufs/ufs-qcom-ice.h | 113 ++ drivers/scsi/ufs/ufs-qcom.c | 1204 ++++++++++++++++++++ drivers/scsi/ufs/ufs.h | 491 -------- drivers/scsi/ufs/ufshcd-pci.c | 2 +- drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +- drivers/scsi/ufs/ufshcd.c | 97 +- drivers/scsi/ufs/ufshcd.h | 596 ---------- drivers/scsi/ufs/unipro.h | 207 ---- include/linux/phy/phy-qcom-ufs.h | 205 ++++ include/linux/scsi/ufs/ufs-qcom.h | 210 ++++ include/linux/scsi/ufs/ufs.h | 491 ++++++++ include/linux/scsi/ufs/ufshcd.h | 654 +++++++++++ include/linux/scsi/ufs/unipro.h | 207 ++++ 24 files changed, 6232 insertions(+), 1304 deletions(-) create mode 100644 Documentation/devicetree/bindings/ufs/ufs-msm.txt create mode 100644 drivers/phy/phy-qcom-ufs-qmp-20nm.c create mode 100644 drivers/phy/phy-qcom-ufs-qmp-20nm.h create mode 100644 drivers/phy/phy-qcom-ufs-qmp-28nm.c create mode 100644 drivers/phy/phy-qcom-ufs-qmp-28nm.h create mode 100644 drivers/phy/phy-qcom-ufs.c create mode 100644 drivers/scsi/ufs/ufs-qcom-ice.c create mode 100644 drivers/scsi/ufs/ufs-qcom-ice.h create mode 100644 drivers/scsi/ufs/ufs-qcom.c delete mode 100644 drivers/scsi/ufs/ufs.h delete mode 100644 drivers/scsi/ufs/ufshcd.h delete mode 100644 drivers/scsi/ufs/unipro.h create mode 100644 include/linux/phy/phy-qcom-ufs.h create mode 100644 include/linux/scsi/ufs/ufs-qcom.h create mode 100644 include/linux/scsi/ufs/ufs.h create mode 100644 include/linux/scsi/ufs/ufshcd.h create mode 100644 include/linux/scsi/ufs/unipro.h
Documentation/devicetree/bindings/ufs/ufs-msm.txt new file +49 -0
@@ -0,0 +1,49 @@ +* MSM Universal Flash Storage (UFS) PHY + +UFSPHY nodes are defined to describe on-chip UFS PHY hardware macro. +Each UFS PHY node should have its own node. + +To bind UFS PHY with UFS host controller, the controller node should +contain a phandle reference to UFS PHY node. + +Required properties: +- compatible : compatible list, contains "qcom,ufs-phy-qmp-28nm", + "qcom,ufs-phy-qmp-20nm" or "qcom,ufs-phy-qmp-14nm" + according to the relevant phy in use +- reg : should contain PHY register address space (mandatory), + device PHY control register map (optional). +- reg-names : indicates various resources passed to driver (via reg proptery) by name. + Required "reg-names" is "phy_mem" and "dev_ref_clk_ctrl_mem" is optional. +- #phy-cells : This property shall be set to 0 +- vdda-phy-supply : phandle to main PHY supply for analog domain +- vdda-pll-supply : phandle to PHY PLL and Power-Gen block power supply +- 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_src", "ref_clk", + "tx_iface_clk" & "rx_iface_clk" are mandatory but + "ref_clk_parent" is optional + +Optional properties: +- vdda-phy-max-microamp : specifies max. load that can be drawn from phy supply +- vdda-pll-max-microamp : specifies max. load that can be drawn from pll supply +- vddp-ref-clk-supply : phandle to UFS device ref_clk pad power supply +- vddp-ref-clk-max-microamp : specifies max. load that can be drawn from this supply +- vddp-ref-clk-always-on : specifies if this supply needs to be kept always on + +Example: + + ufsphy1: ufsphy@0xfc597000 { + compatible = "qcom,ufs-phy-qmp-28nm"; + reg = <0xfc597000 0x800>, <0xfd512074 0x4>; + reg-names = "phy_mem", "dev_ref_clk_ctrl_mem"; + #phy-cells = <0>; + vdda-phy-supply = <&pma8084_l4>; + vdda-pll-supply = <&pma8084_l12>; + vdda-phy-max-microamp = <50000>; + vdda-pll-max-microamp = <1000>; + }; + + ufshc@0xfc598000 { + ... + phys = <&ufsphy1>; + };
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +112 -1
139 lines not on this page · raw message
drivers/phy/Makefile +3 -0
@@ -31,3 +31,6 @@ obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-usb.o obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o +obj-$(CONFIG_SCSI_UFS_QCOM) += phy-qcom-ufs.o +obj-$(CONFIG_SCSI_UFS_QCOM) += phy-qcom-ufs-qmp-28nm.o +obj-$(CONFIG_SCSI_UFS_QCOM) += phy-qcom-ufs-qmp-20nm.o
drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +266 -0
266 lines not on this page · raw message
drivers/phy/phy-qcom-ufs-qmp-20nm.h new file +232 -0
232 lines not on this page · raw message
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +331 -0
331 lines not on this page · raw message
drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +738 -0
738 lines not on this page · raw message
drivers/phy/phy-qcom-ufs.c new file +777 -0
777 lines not on this page · raw message
drivers/scsi/ufs/Kconfig +24 -0
@@ -70,3 +70,27 @@ config SCSI_UFSHCD_PLATFORM If you have a controller with this interface, say Y or M here. If unsure, say N. + +config SCSI_UFS_QCOM + bool "QCOM specific hooks to UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM && ARCH_MSM + help + This selects the QCOM specific additions to UFSHCD platform driver. + UFS host on QCOM needs some vendor specific configuration before + accessing the hardware which includes PHY configuration and vendor + specific registers. + + Select this if you have UFS controller on QCOM chipset. + If unsure, say N. + +config SCSI_UFS_QCOM_ICE + bool "QCOM specific hooks to Inline Crypto Engine for UFS driver" + depends on SCSI_UFS_QCOM && CRYPTO_DEV_QCOM_ICE + help + This selects the QCOM specific additions to support Inline Crypto + Engine (ICE). + ICE accelerates the crypto operations and maintains the high UFS + performance. + + Select this if you have ICE supported for UFS on QCOM chipset. + If unsure, say N.
drivers/scsi/ufs/Makefile +2 -0
@@ -1,4 +1,6 @@ # UFSHCD makefile +obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o +obj-$(CONFIG_SCSI_UFS_QCOM_ICE) += ufs-qcom-ice.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufs-qcom-ice.c new file +522 -0
428 lines not on this page · raw message
drivers/scsi/ufs/ufs-qcom-ice.h new file +113 -0
113 lines not on this page · raw message
drivers/scsi/ufs/ufs-qcom.c new file +1204 -0
1,204 lines not on this page · raw message
drivers/scsi/ufs/ufs.h deleted +0 -491
491 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.c +90 -7
97 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h deleted +0 -596
596 lines not on this page · raw message
drivers/scsi/ufs/unipro.h deleted +0 -207
207 lines not on this page · raw message
include/linux/phy/phy-qcom-ufs.h new file +205 -0
205 lines not on this page · raw message
include/linux/scsi/ufs/ufs-qcom.h new file +210 -0
210 lines not on this page · raw message
include/linux/scsi/ufs/ufs.h new file +491 -0
491 lines not on this page · raw message
include/linux/scsi/ufs/ufshcd.h new file +654 -0
654 lines not on this page · raw message
include/linux/scsi/ufs/unipro.h new file +207 -0
207 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.5.2
Part of the diff is not shown here. View the raw message.
Quoted 8,126 lines
In this change we add support to the generic PHY framework. Two UFS phys are implemented:
qmp-20nm and qmp-28nm.Also, the files in this change implement the UFS HW (controller & PHY) specific behavior in Qualcomm chips.
Relocation of a few header files is needed in order to expose routines and data structures between PHY driver and UFS driver.Also, this change include the implementation of Inline Crypto Engine (ICE) in Qualcomm chips.
Signed-off-by Yaniv Gardi <[email protected]>--- Documentation/devicetree/bindings/ufs/ufs-msm.txt | 49 + .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 113 +- drivers/phy/Makefile | 3 + drivers/phy/phy-qcom-ufs-qmp-20nm.c | 266 +++++ drivers/phy/phy-qcom-ufs-qmp-20nm.h | 232 ++++ drivers/phy/phy-qcom-ufs-qmp-28nm.c | 331 ++++++ drivers/phy/phy-qcom-ufs-qmp-28nm.h | 738 ++++++++++++ drivers/phy/phy-qcom-ufs.c | 777 +++++++++++++ drivers/scsi/ufs/Kconfig | 24 + drivers/scsi/ufs/Makefile | 2 + drivers/scsi/ufs/ufs-qcom-ice.c | 522 +++++++++ drivers/scsi/ufs/ufs-qcom-ice.h | 113 ++ drivers/scsi/ufs/ufs-qcom.c | 1204 ++++++++++++++++++++ drivers/scsi/ufs/ufs.h | 491 -------- drivers/scsi/ufs/ufshcd-pci.c | 2 +- drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +- drivers/scsi/ufs/ufshcd.c | 97 +- drivers/scsi/ufs/ufshcd.h | 596 ---------- drivers/scsi/ufs/unipro.h | 207 ---- include/linux/phy/phy-qcom-ufs.h | 205 ++++ include/linux/scsi/ufs/ufs-qcom.h | 210 ++++ include/linux/scsi/ufs/ufs.h | 491 ++++++++ include/linux/scsi/ufs/ufshcd.h | 654 +++++++++++ include/linux/scsi/ufs/unipro.h | 207 ++++ 24 files changed, 6232 insertions(+), 1304 deletions(-) create mode 100644 Documentation/devicetree/bindings/ufs/ufs-msm.txt create mode 100644 drivers/phy/phy-qcom-ufs-qmp-20nm.c create mode 100644 drivers/phy/phy-qcom-ufs-qmp-20nm.h create mode 100644 drivers/phy/phy-qcom-ufs-qmp-28nm.c create mode 100644 drivers/phy/phy-qcom-ufs-qmp-28nm.h create mode 100644 drivers/phy/phy-qcom-ufs.c create mode 100644 drivers/scsi/ufs/ufs-qcom-ice.c create mode 100644 drivers/scsi/ufs/ufs-qcom-ice.h create mode 100644 drivers/scsi/ufs/ufs-qcom.c delete mode 100644 drivers/scsi/ufs/ufs.h delete mode 100644 drivers/scsi/ufs/ufshcd.h delete mode 100644 drivers/scsi/ufs/unipro.h create mode 100644 include/linux/phy/phy-qcom-ufs.h create mode 100644 include/linux/scsi/ufs/ufs-qcom.h create mode 100644 include/linux/scsi/ufs/ufs.h create mode 100644 include/linux/scsi/ufs/ufshcd.h create mode 100644 include/linux/scsi/ufs/unipro.hDocumentation/devicetree/bindings/ufs/ufs-msm.txt new file +13
-0@@ -0,0 +1,49 @@ +* MSM Universal Flash Storage (UFS) PHY + +UFSPHY nodes are defined to describe on-chip UFS PHY hardware macro. +Each UFS PHY node should have its own node. + +To bind UFS PHY with UFS host controller, the controller node should +contain a phandle reference to UFS PHY node. + +Required properties: +- compatible : compatible list, contains "qcom,ufs-phy-qmp-28nm", + "qcom,ufs-phy-qmp-20nm" or "qcom,ufs-phy-qmp-14nm" + according to the relevant phy in use +- reg : should contain PHY register address space(mandatory),
+ device PHY control register map (optional).
+- reg-names : indicates various resources passed to driver (via
reg proptery) by name.
+ Required "reg-names" is "phy_mem" and
"dev_ref_clk_ctrl_mem" is optional.+- #phy-cells : This property shall be set to 0 +- vdda-phy-supply : phandle to main PHY supply for analog domain +- vdda-pll-supply : phandle to PHY PLL and Power-Gen block power supply +- clocks : List of phandle and clock specifier pairs +- clock-names : List of clock input name strings sorted in the sameDocumentation/devicetree/bindings/ufs/ufs-msm.txt new file +6
-0+ order as the clocks property. "ref_clk_src", "ref_clk", + "tx_iface_clk" & "rx_iface_clk" are mandatory but + "ref_clk_parent" is optional + +Optional properties: +- vdda-phy-max-microamp : specifies max. load that can be drawn from physupply
+- vdda-pll-max-microamp : specifies max. load that can be drawn from pll supply+- vddp-ref-clk-supply : phandle to UFS device ref_clk pad power supply +- vddp-ref-clk-max-microamp : specifies max. load that can be drawn fromthis supply
+- vddp-ref-clk-always-on : specifies if this supply needs to be kept always onDocumentation/devicetree/bindings/ufs/ufs-msm.txt new file +18
-0+ +Example: + + ufsphy1: ufsphy@0xfc597000 { + compatible = "qcom,ufs-phy-qmp-28nm"; + reg = <0xfc597000 0x800>, <0xfd512074 0x4>; + reg-names = "phy_mem", "dev_ref_clk_ctrl_mem"; + #phy-cells = <0>; + vdda-phy-supply = <&pma8084_l4>; + vdda-pll-supply = <&pma8084_l12>; + vdda-phy-max-microamp = <50000>; + vdda-pll-max-microamp = <1000>; + }; + + ufshc@0xfc598000 { + ... + phys = <&ufsphy1>; + };Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0
-0@@ -4,11 +4,14 @@ UFSHC nodes are defined to describe on-chip UFS hostcontrollers.
Each UFS controller instance should have its own node.Required properties:
-- compatible : compatible list, contains "jedec,ufs-1.1"
+- compatible : compatible list, contains "jedec,ufs-1.1",
"qcom,ufshc"
- interrupts : <interrupt mapping for UFS host controller IRQ>
- reg : <registers mapping>Optional properties:
+- phys : phandle to UFS PHY node +- phy-names : the string "ufsphy" when is found in a node,along
+ with "phys" attribute, provides phandle to UFS
PHY node
- vdd-hba-supply : phandle to UFS host controller supply regulator
node
- vcc-supply : phandle to VCC supply regulator node
- vccq-supply : phandle to VCCQ supply regulator nodeDocumentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1
-0@@ -31,6 +34,15 @@ Optional properties: defined or a value in the array is "0" then it is assumed that the frequency is set by the parent clock or a fixed rate clock source. +- rpm-level : UFS Runtime power management level. Following PM levelsare suppported:
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1
-0+ 0 - Both UFS device and Link in active state (Highest powerconsumption)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +3
-0+ 1 - UFS device in active state but Link in Hibern8 state + 2 - UFS device in Sleep state but Link in active state + 3 - UFS device in Sleep state and Link in hibern8 state (default PMlevel)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2
-0+ 4 - UFS device in Power-down state and Link in Hibern8 state + 5 - UFS device in Power-down state and Link in OFF state (Lowestpower consumption)
+- spm-level : UFS System power management level. Allowed PM levels are
same as rpm-level.
+- ufs-qcom-crypto : phandle to UFS-QCOM ICE (Inline Cryptographic Engine)
nodeNote: If above properties are not defined it can be assumed that the
supply
regulators or clocks are always on.Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +35
-0@@ -41,6 +53,8 @@ Example: reg = <0xfc598000 0x800>; interrupts = <0 28 0>; + ufs-phy = <&ufsphy>; + ufs-qcom-crypto = <&ufs_ice>; vdd-hba-supply = <&xxx_reg0>; vdd-hba-fixed-regulator; vcc-supply = <&xxx_reg1>;@@ -54,4 +68,101 @@ Example: clocks = <&core 0>, <&ref 0>, <&iface 0>; clock-names = "core_clk", "ref_clk", "iface_clk"; freq-table-hz = <100000000 200000000>, <0 0>, <0 0>; + rpm-level = <3>; + spm-level = <5>; + }; + +==== MSM UFS platform driver properties ===== +* For UFS host controller in MSM platform following clocks are required - + Controller clock source - + "core_clk_src", max-clock-frequency-hz = 200MHz + + Controller System clock branch: + "core_clk" - Controller core clock + + AHB/AXI interface clocks: + "iface_clk" - AHB interface clock + "bus_clk" - AXI bus master clock + + PHY to controller symbol synchronization clocks: + "rx_lane0_sync_clk" - RX Lane 0 + "rx_lane1_sync_clk" - RX Lane 1 + "tx_lane0_sync_clk" - TX Lane 0 + "tx_lane1_sync_clk" - TX Lane 1 + + Optional reference clock input to UFS device + "ref_clk", max-clock-frequency-hz = 19.2MHz + +* Following bus parameters are required - +- qcom,msm-bus,name +- qcom,msm-bus,num-cases +- qcom,msm-bus,num-paths +- qcom,msm-bus,vectors-KBps +For the above four properties please refer to +Documentation/devicetree/bindings/arm/msm/msm_bus.txt +Note: The instantaneous bandwidth (IB) value in the vectors-KBps fieldshould
+ be zero as UFS data transfer path doesn't have latency requirements
andDocumentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +7
-0+ voting for aggregated bandwidth (AB) should take care of providing + optimum throughput requested. + +- qcom,bus-vector-names: specifies string IDs for the corresponding +bus vectors in the same order as qcom,msm-bus,vectors-KBps property. + +- qcom,cpu-dma-latency-us: optional parameter specifying the allowedCPU-DMA
+ latency parameter for PM QOS, in units of microseconds. If this parameter is
+ not specified a default of 200us is used.
+- qcom,cpu-affinity: this is a string that specifies the pm QoS request type.Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2
-0+ The supported cpu affinity modes are: + "all_cores" - PM_QOS_REQ_ALL_CORES is applicable to all CPU cores thatare
+ online and this would have a power impact when there are more number of CPUs.
+ "affine_irq" -PM_QOS_REQ_AFFINE_IRQrequest type shall update/apply the voteDocumentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2
-0+ only to that CPU to which this IRQ's affinity is set to. + "affine_cores" - PM_QOS_REQ_AFFINE_CORES request type is used fortargets that
+ have little cluster and will update/apply the vote to all the cores in theDocumentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +46
-0+ little cluster. + The default CPU affinity mode is PM_QOS_REQ_AFFINE_IRQ. + +Example: + ufshc@0xfc598000 { + ... + + qcom,msm-bus,name = "ufs1"; + qcom,msm-bus,num-cases = <22>; + qcom,msm-bus,num-paths = <2>; + qcom,msm-bus,vectors-KBps = + <95 512 0 0>, <1 650 0 0>, /* No vote */ + + <95 512 922 0>, <1 650 1000 0>, /* PWM G1 */ + <95 512 1844 0>, <1 650 1000 0>, /* PWM G2 */ + <95 512 3688 0>, <1 650 1000 0>, /* PWM G3 */ + <95 512 7376 0>, <1 650 1000 0>, /* PWM G4 */ + <95 512 1844 0>, <1 650 1000 0>, /* PWM G1 L2 */ + <95 512 3688 0>, <1 650 1000 0>, /* PWM G2 L2 */ + <95 512 7376 0>, <1 650 1000 0>, /* PWM G3 L2 */ + <95 512 14752 0>, <1 650 1000 0>, /* PWM G4 L2 */ + + <95 512 127796 0>, <1 650 1000 0>, /* HS G1 RA */ + <95 512 255591 0>, <1 650 1000 0>, /* HS G2 RA */ + <95 512 511181 0>, <1 650 1000 0>, /* HS G3 RA */ + <95 512 255591 0>, <1 650 1000 0>, /* HS G1 RA L2 */ + <95 512 511181 0>, <1 650 1000 0>, /* HS G2 RA L2 */ + <95 512 1022362 0>, <1 650 1000 0>, /* HS G3 RA L2 */ + + <95 512 149422 0>, <1 650 1000 0>, /* HS G1 RB */ + <95 512 298189 0>, <1 650 1000 0>, /* HS G2 RB */ + <95 512 596378 0>, <1 650 1000 0>, /* HS G3 RB */ + <95 512 298189 0>, <1 650 1000 0>, /* HS G1 RB L2 */ + <95 512 596378 0>, <1 650 1000 0>, /* HS G2 RB L2 */ + <95 512 1192756 0>, <1 650 1000 0>, /* HS G3 RB L2 */ + + <95 512 4096000 0>, <1 650 1000 0>; /* Max. bandwidth */ + + qcom,bus-vector-names = "MIN", + "PWM_G1_L1", "PWM_G2_L1", "PWM_G3_L1", "PWM_G4_L1", + "PWM_G1_L2", "PWM_G2_L2", "PWM_G3_L2", "PWM_G4_L2", + "HS_RA_G1_L1", "HS_RA_G2_L1", "HS_RA_G3_L1", + "HS_RA_G1_L2", "HS_RA_G2_L2", "HS_RA_G3_L2", + "HS_RB_G1_L1", "HS_RB_G2_L1", "HS_RB_G3_L1", + "HS_RB_G1_L2", "HS_RB_G2_L2", "HS_RB_G3_L2", + "MAX"; };drivers/phy/Makefile +0
-0@@ -31,3 +31,6 @@ obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) +=phy-spear1340-miphy.o
obj-$(CONFIG_PHY_XGENE) += phy-xgene.o
obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-usb.o
obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.odrivers/phy/Makefile +3
-0+obj-$(CONFIG_SCSI_UFS_QCOM) += phy-qcom-ufs.o +obj-$(CONFIG_SCSI_UFS_QCOM) += phy-qcom-ufs-qmp-28nm.o +obj-$(CONFIG_SCSI_UFS_QCOM) += phy-qcom-ufs-qmp-20nm.odrivers/phy/phy-qcom-ufs-qmp-20nm.c new file +29
-0@@ -0,0 +1,266 @@ +/* +* Copyright (c) 2013-2014, Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/time.h> +#include <linux/clk.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +#include <linux/phy/phy-qcom-ufs.h> +#include "phy-qcom-ufs-qmp-20nm.h" + +#define UFS_PHY_NAME "ufs_phy_qmp_20nm" + +static +int ufs_qcom_phy_qmp_20nm_phy_calibrate(struct ufs_qcom_phy
*ufs_qcom_phy)drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +17
-0+{ +struct ufs_qcom_phy_calibration *tbl_A, *tbl_B; +int tbl_size_A, tbl_size_B; +int rate =UFS_QCOM_LIMIT_HS_RATE ; +u8 major = ufs_qcom_phy->host_ctrl_rev_major; +u16 minor = ufs_qcom_phy->host_ctrl_rev_minor; +u16 step = ufs_qcom_phy->host_ctrl_rev_step; +int err; + +if ((major ==0x1 ) && (minor ==0x002 ) && (step ==0x0000 )) { + tbl_size_A =ARRAY_SIZE (phy_cal_table_rate_A_1_2_0); + tbl_A = phy_cal_table_rate_A_1_2_0; + }else if ((major ==0x1 ) && (minor ==0x003 ) && (step ==0x0000 )) { + tbl_size_A =ARRAY_SIZE (phy_cal_table_rate_A_1_3_0); + tbl_A = phy_cal_table_rate_A_1_3_0; + }else { + dev_err(ufs_qcom_phy->dev, "%s: Unknown UFS-PHY version, no calibrationvalues\n",
drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +21
-0+ __func__); + err = -ENODEV ; + goto out; + } + + tbl_size_B =ARRAY_SIZE (phy_cal_table_rate_B); + tbl_B = phy_cal_table_rate_B; + + err =ufs_qcom_phy_calibrate (ufs_qcom_phy, tbl_A, tbl_size_A, + tbl_B, tbl_size_B, rate); + +if (err) +dev_err (ufs_qcom_phy->dev,"%s: ufs_qcom_phy_calibrate() failed %d\n" , + __func__, err); + +out: +return err; +} + +static +void ufs_qcom_phy_qmp_20nm_advertise_quirks(struct ufs_qcom_phy
*phy_common)drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +21
-0+{ + phy_common->quirks = +UFS_QCOM_PHY_QUIRK_HIBERN8_EXIT_AFTER_PHY_PWR_COLLAPSE ; +} + +static int ufs_qcom_phy_qmp_20nm_init (struct phy *generic_phy) +{ +struct ufs_qcom_phy_qmp_20nm *phy =phy_get_drvdata (generic_phy); +struct ufs_qcom_phy *phy_common = &phy->common_cfg; +int err =0 ; + + err =ufs_qcom_phy_init_clks (generic_phy, phy_common); +if (err) { +dev_err (phy_common->dev,"%s: ufs_qcom_phy_init_clks() failed %d\n" , + __func__, err); + goto out; + } + + err =ufs_qcom_phy_init_vregulators (generic_phy, phy_common); +if (err) { + dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed%d\n",
drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +12
-0+ __func__, err); + goto out; + } + +ufs_qcom_phy_qmp_20nm_advertise_quirks (phy_common); + +out: +return err; +} + +static +void ufs_qcom_phy_qmp_20nm_power_control(struct ufs_qcom_phy *phy, boolval)
drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +52
-0+{ +bool hibern8_exit_after_pwr_collapse = phy->quirks & +UFS_QCOM_PHY_QUIRK_HIBERN8_EXIT_AFTER_PHY_PWR_COLLAPSE ; + +if (val) { +writel_relaxed (0x1 , phy->mmio +UFS_PHY_POWER_DOWN_CONTROL ); +/* +* Before any transactions involving PHY, ensure PHY knows +* that it's analog rail is powered ON. +*/ +mb (); + +if (hibern8_exit_after_pwr_collapse) { +/* +* Give atleast 1us delay after restoring PHY analog +* power. +*/ +usleep_range (1 ,2 ); +writel_relaxed (0x0A , phy->mmio + +QSERDES_COM_SYSCLK_EN_SEL_TXBAND ); +writel_relaxed (0x08 , phy->mmio + +QSERDES_COM_SYSCLK_EN_SEL_TXBAND ); +/* +* Make sure workaround is deactivated before proceeding +* with normal PHY operations. +*/ +mb (); + } + }else { +if (hibern8_exit_after_pwr_collapse) { +writel_relaxed (0x0A , phy->mmio + +QSERDES_COM_SYSCLK_EN_SEL_TXBAND ); +writel_relaxed (0x02 , phy->mmio + +QSERDES_COM_SYSCLK_EN_SEL_TXBAND ); +/* +* Make sure that above workaround is activated before +* PHY analog power collapse. +*/ +mb (); + } + +writel_relaxed (0x0 , phy->mmio +UFS_PHY_POWER_DOWN_CONTROL ); +/* +* ensure that PHY knows its PHY analog rail is going +* to be powered down +*/ +mb (); + } +} + +static +void ufs_qcom_phy_qmp_20nm_set_tx_lane_enable(struct ufs_qcom_phy *phy,u32 val)
drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +7
-0+{ +writel_relaxed (val &UFS_PHY_TX_LANE_ENABLE_MASK , + phy->mmio +UFS_PHY_TX_LANE_ENABLE ); +mb (); +} + +static inline void ufs_qcom_phy_qmp_20nm_start_serdes(struct ufs_qcom_phy*phy)
drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +11
-0+{ +u32 tmp; + + tmp =readl_relaxed (phy->mmio +UFS_PHY_PHY_START ); + tmp &= ~MASK_SERDES_START ; + tmp |= (1 <<OFFSET_SERDES_START ); +writel_relaxed (tmp, phy->mmio +UFS_PHY_PHY_START ); +mb (); +} + +static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct ufs_qcom_phy
*phy_common)drivers/phy/phy-qcom-ufs-qmp-20nm.c new file +96
-0+{ +int err =0 ; +u32 val; + + err =readl_poll_timeout (phy_common->mmio +UFS_PHY_PCS_READY_STATUS , + val, (val &MASK_PCS_READY ),10 ,1000000 ); +if (err) +dev_err (phy_common->dev,"%s: poll for pcs failed err = %d\n" , + __func__, err); +return err; +} + +struct phy_ops ufs_qcom_phy_qmp_20nm_phy_ops = { + .init = ufs_qcom_phy_qmp_20nm_init, + .exit = ufs_qcom_phy_exit, + .power_on = ufs_qcom_phy_power_on, + .power_off = ufs_qcom_phy_power_off, + .owner =THIS_MODULE , +}; + +struct ufs_qcom_phy_specific_ops phy_20nm_ops = { + .calibrate_phy = ufs_qcom_phy_qmp_20nm_phy_calibrate, + .start_serdes = ufs_qcom_phy_qmp_20nm_start_serdes, + .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_20nm_is_pcs_ready, + .set_tx_lane_enable = ufs_qcom_phy_qmp_20nm_set_tx_lane_enable, + .power_control = ufs_qcom_phy_qmp_20nm_power_control, +}; + +static int ufs_qcom_phy_qmp_20nm_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct phy *generic_phy; +struct ufs_qcom_phy_qmp_20nm *phy; +int err =0 ; + + phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL ); +if (!phy) { +dev_err (dev,"%s: failed to allocate phy\n" , __func__); + err = -ENOMEM ; + goto out; + } + + generic_phy =ufs_qcom_phy_generic_probe (pdev, &phy->common_cfg, + &ufs_qcom_phy_qmp_20nm_phy_ops, &phy_20nm_ops); + +if (!generic_phy) { +dev_err (dev,"%s: ufs_qcom_phy_generic_probe() failed\n" , + __func__); + err = -EIO ; + goto out; + } + +phy_set_drvdata (generic_phy, phy); + +strlcpy (phy->common_cfg.name,UFS_PHY_NAME , +sizeof (phy->common_cfg.name)); + +out: +return err; +} + +static int ufs_qcom_phy_qmp_20nm_remove (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct phy *generic_phy =to_phy (dev); +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int err =0 ; + + err =ufs_qcom_phy_remove (generic_phy, ufs_qcom_phy); +if (err) +dev_err (dev,"%s: ufs_qcom_phy_remove failed = %d\n" , + __func__, err); + +return err; +} + +static const struct of_device_id ufs_qcom_phy_qmp_20nm_of_match[] = { + {.compatible ="qcom,ufs-phy-qmp-20nm" }, + {}, +}; +MODULE_DEVICE_TABLE (of, ufs_qcom_phy_qmp_20nm_of_match); + +static struct platform_driver ufs_qcom_phy_qmp_20nm_driver = { + .probe = ufs_qcom_phy_qmp_20nm_probe, + .remove = ufs_qcom_phy_qmp_20nm_remove, + .driver = { + .of_match_table = ufs_qcom_phy_qmp_20nm_of_match, + .name ="ufs_qcom_phy_qmp_20nm" , + .owner =THIS_MODULE , + }, +}; + +module_platform_driver (ufs_qcom_phy_qmp_20nm_driver); + +MODULE_DESCRIPTION ("Universal Flash Storage (UFS) QCOM PHY QMP 20nm" ); +MODULE_LICENSE ("GPL v2" );drivers/phy/phy-qcom-ufs-qmp-20nm.h new file +232
-0@@ -0,0 +1,232 @@ +/* +* Copyright (c) 2013-2014, Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#ifndef UFS_QCOM_PHY_QMP_20NM_H_ +#define UFS_QCOM_PHY_QMP_20NM_H_ + +#include <linux/phy/phy-qcom-ufs.h> + +/* QCOM UFS PHY control registers */ + +#define COM_OFF (x) (0x000 + x) +#define PHY_OFF (x) (0xC00 + x) +#define TX_OFF (n, x) (0x400 + (0x400 * n) + x) +#define RX_OFF (n, x) (0x600 + (0x400 * n) + x) + +/* UFS PHY PLL block registers */ +#define QSERDES_COM_SYS_CLK_CTRL COM_OFF(0x0) +#define QSERDES_COM_PLL_VCOTAIL_EN COM_OFF(0x04) +#define QSERDES_COM_PLL_CNTRL COM_OFF(0x14) +#define QSERDES_COM_PLL_IP_SETI COM_OFF(0x24) +#define QSERDES_COM_CORE_CLK_IN_SYNC_SEL COM_OFF(0x28) +#define QSERDES_COM_BIAS_EN_CLKBUFLR_EN COM_OFF(0x30) +#define QSERDES_COM_PLL_CP_SETI COM_OFF(0x34) +#define QSERDES_COM_PLL_IP_SETP COM_OFF(0x38) +#define QSERDES_COM_PLL_CP_SETP COM_OFF(0x3C) +#define QSERDES_COM_SYSCLK_EN_SEL_TXBAND COM_OFF(0x48) +#define QSERDES_COM_RESETSM_CNTRL COM_OFF(0x4C) +#define QSERDES_COM_RESETSM_CNTRL2 COM_OFF(0x50) +#define QSERDES_COM_PLLLOCK_CMP1 COM_OFF(0x90) +#define QSERDES_COM_PLLLOCK_CMP2 COM_OFF(0x94) +#define QSERDES_COM_PLLLOCK_CMP3 COM_OFF(0x98) +#define QSERDES_COM_PLLLOCK_CMP_EN COM_OFF(0x9C) +#define QSERDES_COM_BGTC COM_OFF(0xA0) +#define QSERDES_COM_DEC_START1 COM_OFF(0xAC) +#define QSERDES_COM_PLL_AMP_OS COM_OFF(0xB0) +#define QSERDES_COM_RES_CODE_UP_OFFSET COM_OFF(0xD8) +#define QSERDES_COM_RES_CODE_DN_OFFSET COM_OFF(0xDC) +#define QSERDES_COM_DIV_FRAC_START1 COM_OFF(0x100) +#define QSERDES_COM_DIV_FRAC_START2 COM_OFF(0x104) +#define QSERDES_COM_DIV_FRAC_START3 COM_OFF(0x108) +#define QSERDES_COM_DEC_START2 COM_OFF(0x10C) +#define QSERDES_COM_PLL_RXTXEPCLK_EN COM_OFF(0x110) +#define QSERDES_COM_PLL_CRCTRL COM_OFF(0x114) +#define QSERDES_COM_PLL_CLKEPDIV COM_OFF(0x118) + +/* TX LANE n (0, 1) registers */ +#define QSERDES_TX_EMP_POST1_LVL (n) TX_OFF(n, 0x08) +#define QSERDES_TX_DRV_LVL (n) TX_OFF(n, 0x0C) +#define QSERDES_TX_LANE_MODE (n) TX_OFF(n, 0x54) + +/* RX LANE n (0, 1) registers */ +#define QSERDES_RX_CDR_CONTROL1 (n) RX_OFF(n, 0x0) +#define QSERDES_RX_CDR_CONTROL_HALF (n) RX_OFF(n, 0x8) +#define QSERDES_RX_RX_EQ_GAIN1_LSB (n) RX_OFF(n, 0xA8) +#define QSERDES_RX_RX_EQ_GAIN1_MSB (n) RX_OFF(n, 0xAC) +#define QSERDES_RX_RX_EQ_GAIN2_LSB (n) RX_OFF(n, 0xB0) +#define QSERDES_RX_RX_EQ_GAIN2_MSB (n) RX_OFF(n, 0xB4) +#define QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 (n) RX_OFF(n, 0xBC) +#define QSERDES_RX_CDR_CONTROL_QUARTER (n) RX_OFF(n, 0xC) +#define QSERDES_RX_SIGDET_CNTRL (n) RX_OFF(n, 0x100) + +/* UFS PHY registers */ +#define UFS_PHY_PHY_START PHY_OFF(0x00) +#define UFS_PHY_POWER_DOWN_CONTROL PHY_OFF(0x4) +#define UFS_PHY_TX_LANE_ENABLE PHY_OFF(0x44) +#define UFS_PHY_PWM_G1_CLK_DIVIDER PHY_OFF(0x08) +#define UFS_PHY_PWM_G2_CLK_DIVIDER PHY_OFF(0x0C) +#define UFS_PHY_PWM_G3_CLK_DIVIDER PHY_OFF(0x10) +#define UFS_PHY_PWM_G4_CLK_DIVIDER PHY_OFF(0x14) +#define UFS_PHY_CORECLK_PWM_G1_CLK_DIVIDER PHY_OFF(0x34) +#define UFS_PHY_CORECLK_PWM_G2_CLK_DIVIDER PHY_OFF(0x38) +#define UFS_PHY_CORECLK_PWM_G3_CLK_DIVIDER PHY_OFF(0x3C) +#define UFS_PHY_CORECLK_PWM_G4_CLK_DIVIDER PHY_OFF(0x40) +#define UFS_PHY_OMC_STATUS_RDVAL PHY_OFF(0x68) +#define UFS_PHY_LINE_RESET_TIME PHY_OFF(0x28) +#define UFS_PHY_LINE_RESET_GRANULARITY PHY_OFF(0x2C) +#define UFS_PHY_TSYNC_RSYNC_CNTL PHY_OFF(0x48) +#define UFS_PHY_PLL_CNTL PHY_OFF(0x50) +#define UFS_PHY_TX_LARGE_AMP_DRV_LVL PHY_OFF(0x54) +#define UFS_PHY_TX_SMALL_AMP_DRV_LVL PHY_OFF(0x5C) +#define UFS_PHY_TX_LARGE_AMP_POST_EMP_LVL PHY_OFF(0x58) +#define UFS_PHY_TX_SMALL_AMP_POST_EMP_LVL PHY_OFF(0x60) +#define UFS_PHY_CFG_CHANGE_CNT_VAL PHY_OFF(0x64) +#define UFS_PHY_RX_SYNC_WAIT_TIME PHY_OFF(0x6C) +#define UFS_PHY_TX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xB4) +#define UFS_PHY_RX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xE0) +#define UFS_PHY_TX_MIN_STALL_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xB8) +#define UFS_PHY_RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xE4) +#define UFS_PHY_TX_MIN_SAVE_CONFIG_TIME_CAPABILITY PHY_OFF(0xBC) +#define UFS_PHY_RX_MIN_SAVE_CONFIG_TIME_CAPABILITY PHY_OFF(0xE8) +#define UFS_PHY_RX_PWM_BURST_CLOSURE_LENGTH_CAPABILITY PHY_OFF(0xFC) +#define UFS_PHY_RX_MIN_ACTIVATETIME_CAPABILITY PHY_OFF(0x100) +#define UFS_PHY_RMMI_ATTR_CTRL PHY_OFF(0x160) +#define UFS_PHY_RMMI_RX_CFGUPDT_L1 (1 << 7) +#define UFS_PHY_RMMI_TX_CFGUPDT_L1 (1 << 6) +#define UFS_PHY_RMMI_CFGWR_L1 (1 << 5) +#define UFS_PHY_RMMI_CFGRD_L1 (1 << 4) +#define UFS_PHY_RMMI_RX_CFGUPDT_L0 (1 << 3) +#define UFS_PHY_RMMI_TX_CFGUPDT_L0 (1 << 2) +#define UFS_PHY_RMMI_CFGWR_L0 (1 << 1) +#define UFS_PHY_RMMI_CFGRD_L0 (1 << 0) +#define UFS_PHY_RMMI_ATTRID PHY_OFF(0x164) +#define UFS_PHY_RMMI_ATTRWRVAL PHY_OFF(0x168) +#define UFS_PHY_RMMI_ATTRRDVAL_L0_STATUS PHY_OFF(0x16C) +#define UFS_PHY_RMMI_ATTRRDVAL_L1_STATUS PHY_OFF(0x170) +#define UFS_PHY_PCS_READY_STATUS PHY_OFF(0x174) + +#define UFS_PHY_TX_LANE_ENABLE_MASK 0x3 + +/* +* This structure represents the 20nm specific phy. +* common_cfg MUST remain the first field in this structure +* in case extra fields are added. This way, when calling +* get_ufs_qcom_phy() of generic phy, we can extract the +* common phy structure (struct ufs_qcom_phy) out of it +* regardless of the relevant specific phy. +*/ +struct ufs_qcom_phy_qmp_20nm { +struct ufs_qcom_phy common_cfg; +}; + +static struct ufs_qcom_phy_calibration phy_cal_table_rate_A_1_2_0[] = { +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_POWER_DOWN_CONTROL ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_VCOTAIL_EN ,0xe1 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CRCTRL ,0xcc ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_SYSCLK_EN_SEL_TXBAND ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CLKEPDIV ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_RXTXEPCLK_EN ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START1 ,0x82 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START1 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START2 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START3 ,0x40 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP1 ,0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP2 ,0x19 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP3 ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP_EN ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RESETSM_CNTRL ,0x90 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RESETSM_CNTRL2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL1 (0 ),0xf2 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (0 ),0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (0 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL1 (1 ),0xf2 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (1 ),0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (1 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_LSB (0 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_MSB (0 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_LSB (0 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_MSB (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_LSB (1 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_MSB (1 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_LSB (1 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_MSB (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETI ,0x3f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETP ,0x1b ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETP ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETI ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_EMP_POST1_LVL (0 ),0x2F ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_DRV_LVL (0 ),0x20 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_EMP_POST1_LVL (1 ),0x2F ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_DRV_LVL (1 ),0x20 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_LANE_MODE (0 ),0x68 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_LANE_MODE (1 ),0x68 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 (1 ),0xdc ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 (0 ),0xdc ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_BIAS_EN_CLKBUFLR_EN ,0x3 ), +}; + +static struct ufs_qcom_phy_calibration phy_cal_table_rate_A_1_3_0[] = { +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_POWER_DOWN_CONTROL ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_VCOTAIL_EN ,0xe1 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CRCTRL ,0xcc ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_SYSCLK_EN_SEL_TXBAND ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CLKEPDIV ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_RXTXEPCLK_EN ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START1 ,0x82 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START1 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START2 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START3 ,0x40 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP1 ,0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP2 ,0x19 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP3 ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP_EN ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RESETSM_CNTRL ,0x90 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RESETSM_CNTRL2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL1 (0 ),0xf2 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (0 ),0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (0 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL1 (1 ),0xf2 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (1 ),0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (1 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_LSB (0 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_MSB (0 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_LSB (0 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_MSB (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_LSB (1 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1_MSB (1 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_LSB (1 ),0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2_MSB (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETI ,0x2b ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETP ,0x38 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETP ,0x3c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RES_CODE_UP_OFFSET ,0x02 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RES_CODE_DN_OFFSET ,0x02 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETI ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CNTRL ,0x40 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_LANE_MODE (0 ),0x68 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_LANE_MODE (1 ),0x68 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 (1 ),0xdc ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 (0 ),0xdc ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_BIAS_EN_CLKBUFLR_EN ,0x3 ), +}; + +static struct ufs_qcom_phy_calibration phy_cal_table_rate_B[] = { +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START1 ,0x98 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP1 ,0x65 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP2 ,0x1e ), +}; + +#endif drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +30
-0@@ -0,0 +1,331 @@ +/* +* Copyright (c) 2013-2014, Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/time.h> +#include <linux/clk.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/phy/phy.h> + +#include <linux/phy/phy-qcom-ufs.h> +#include "phy-qcom-ufs-qmp-28nm.h" + +#define UFS_PHY_NAME "ufs_qcom_phy_qmp_28nm" + +static +void ufs_qcom_phy_qmp_28nm_power_control(struct ufs_qcom_phy *phy, boolval)
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +45
-0+{ +if (val) { +writel_relaxed (0x1 , phy->mmio +UFS_PHY_POWER_DOWN_CONTROL ); +/* +* Before any transactions involving PHY, ensure PHY knows +* that it's analog rail is powered ON. This also ensures +* that PHY is out of power collapse before enabling the +* SIGDET. +*/ +mb (); +if (phy->quirks &UFS_QCOM_PHY_DIS_SIGDET_BEFORE_PWR_COLLAPSE ) { +writel_relaxed (0xC0 , + phy->mmio +QSERDES_RX_SIGDET_CNTRL (0 )); +writel_relaxed (0xC0 , + phy->mmio +QSERDES_RX_SIGDET_CNTRL (1 )); +/* +* make sure that SIGDET is enabled before proceeding +* further. +*/ +mb (); + } + }else { +if (phy->quirks & +UFS_QCOM_PHY_DIS_SIGDET_BEFORE_PWR_COLLAPSE ) { +writel_relaxed (0x0 , + phy->mmio +QSERDES_RX_SIGDET_CNTRL (0 )); +writel_relaxed (0x0 , + phy->mmio +QSERDES_RX_SIGDET_CNTRL (1 )); +/* +* Ensure that SIGDET is disabled before PHY power +* collapse +*/ +mb (); + } +writel_relaxed (0x0 , phy->mmio +UFS_PHY_POWER_DOWN_CONTROL ); +/* +* ensure that PHY knows its PHY analog rail is going +* to be powered down +*/ +mb (); + } +} + +static +void ufs_qcom_phy_qmp_28nm_advertise_quirks(struct ufs_qcom_phy
*phy_common)drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +21
-0+{ + phy_common->quirks =UFS_QCOM_PHY_QUIRK_CFG_RESTORE + |UFS_QCOM_PHY_DIS_SIGDET_BEFORE_PWR_COLLAPSE ; +} + +static int ufs_qcom_phy_qmp_28nm_init (struct phy *generic_phy) +{ +struct ufs_qcom_phy_qmp_28nm *phy =phy_get_drvdata (generic_phy); +struct ufs_qcom_phy *phy_common = &phy->common_cfg; +int err =0 ; + + err =ufs_qcom_phy_init_clks (generic_phy, phy_common); +if (err) { +dev_err (phy_common->dev,"%s: ufs_qcom_phy_init_clks() failed %d\n" , + __func__, err); + goto out; + } + + err =ufs_qcom_phy_init_vregulators (generic_phy, phy_common); +if (err) { + dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed%d\n",
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +11
-0+ __func__, err); + goto out; + } + +ufs_qcom_phy_qmp_28nm_advertise_quirks (phy_common); + +out: +return err; +} + +static int ufs_qcom_phy_qmp_28nm_calibrate(struct ufs_qcom_phy
*ufs_qcom_phy)drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +31
-0+{ +struct ufs_qcom_phy_calibration *tbl_A =NULL , *tbl_B; +int tbl_size_A =0 , tbl_size_B; +int rate =UFS_QCOM_LIMIT_HS_RATE ; +u8 major = ufs_qcom_phy->host_ctrl_rev_major; +u16 minor = ufs_qcom_phy->host_ctrl_rev_minor; +u16 step = ufs_qcom_phy->host_ctrl_rev_step; +int err; + +if ((major ==0x1 ) && (minor ==0x001 ) && (step ==0x0000 )) { + tbl_size_A =ARRAY_SIZE (phy_cal_table_ctrl_1_1_0_rate_A); + tbl_A = phy_cal_table_ctrl_1_1_0_rate_A; + }else if ((major ==0x1 ) && (minor ==0x001 ) && (step ==0x0001 )) { + tbl_size_A =ARRAY_SIZE (phy_cal_table_ctrl_1_1_1_rate_A); + tbl_A = phy_cal_table_ctrl_1_1_1_rate_A; + } + + tbl_B = phy_cal_table_rate_B; + tbl_size_B =ARRAY_SIZE (phy_cal_table_rate_B); + + err =ufs_qcom_phy_calibrate (ufs_qcom_phy, tbl_A, tbl_size_A, + tbl_B, tbl_size_B, rate); +if (err) +dev_err (ufs_qcom_phy->dev,"%s: ufs_qcom_phy_calibrate() failed %d\n" , + __func__, err); + +return err; +} + +static +u32 ufs_qcom_phy_qmp_28nm_read_attr(struct ufs_qcom_phy *phy_common, u32attr)
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +14
-0+ +{ +u32 l0, l1; + +writel_relaxed (attr, phy_common->mmio +UFS_PHY_RMMI_ATTRID ); +/* Read attribute value for both lanes */ +writel_relaxed ((UFS_PHY_RMMI_CFGRD_L0 |UFS_PHY_RMMI_CFGRD_L1 ), + phy_common->mmio +UFS_PHY_RMMI_ATTR_CTRL ); + + l0 =readl_relaxed (phy_common->mmio +UFS_PHY_RMMI_ATTRRDVAL_L0_STATUS ); + l1 =readl_relaxed (phy_common->mmio +UFS_PHY_RMMI_ATTRRDVAL_L1_STATUS ); +/* Both lanes should have the same value for same attribute type */ +if (unlikely (l0 != l1)) + dev_warn(phy_common->dev, "%s: attr 0x%x values are not same for Lane-0and Lane-1, l0=0x%x, l1=0x%x",
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +31
-0+ __func__, attr, l0, l1); + +/* must clear now */ +writel_relaxed (0x00 , phy_common->mmio +UFS_PHY_RMMI_ATTR_CTRL ); + +return l0; +} + +static void +ufs_qcom_phy_qmp_28nm_write_attr (struct ufs_qcom_phy *phy_common, +u32 attr,u32 val) +{ +writel_relaxed (attr, phy_common->mmio +UFS_PHY_RMMI_ATTRID ); +writel_relaxed (val, phy_common->mmio +UFS_PHY_RMMI_ATTRWRVAL ); +/* update attribute for both lanes */ +writel_relaxed ((UFS_PHY_RMMI_CFGWR_L0 |UFS_PHY_RMMI_CFGWR_L1 ), + phy_common->mmio +UFS_PHY_RMMI_ATTR_CTRL ); +if (is_mphy_tx_attr (attr)) +writel_relaxed ((UFS_PHY_RMMI_TX_CFGUPDT_L0 | +UFS_PHY_RMMI_TX_CFGUPDT_L1 ), + phy_common->mmio +UFS_PHY_RMMI_ATTR_CTRL ); +else +writel_relaxed ((UFS_PHY_RMMI_RX_CFGUPDT_L0 | +UFS_PHY_RMMI_RX_CFGUPDT_L1 ), + phy_common->mmio +UFS_PHY_RMMI_ATTR_CTRL ); + +writel_relaxed (0x00 , phy_common->mmio +UFS_PHY_RMMI_ATTR_CTRL ); +} + +static +void ufs_qcom_phy_qmp_28nm_save_configuration(struct ufs_qcom_phy
*phy_common)drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +16
-0+{ +int i; + +for (i =0 ; i <ARRAY_SIZE (cached_phy_regs); i++) + cached_phy_regs[i].cfg_value = +readl_relaxed (phy_common->mmio + + cached_phy_regs[i].reg_offset); + +for (i =0 ; i <ARRAY_SIZE (cached_phy_attr); i++) + cached_phy_attr[i].value = +ufs_qcom_phy_qmp_28nm_read_attr (phy_common, + cached_phy_attr[i].att); +} + +static void +ufs_qcom_phy_qmp_28nm_restore_configuration(struct ufs_qcom_phy
*phy_common)drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +10
-0+{ +int i; + +for (i =0 ; i <ARRAY_SIZE (cached_phy_attr); i++) +ufs_qcom_phy_qmp_28nm_write_attr (phy_common, + cached_phy_attr[i].att, cached_phy_attr[i].value); +} + +static +void ufs_qcom_phy_qmp_28nm_set_tx_lane_enable(struct ufs_qcom_phy *phy,u32 val)
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +7
-0+{ +writel_relaxed (val &UFS_PHY_TX_LANE_ENABLE_MASK , + phy->mmio +UFS_PHY_TX_LANE_ENABLE ); +mb (); +} + +static inline void ufs_qcom_phy_qmp_28nm_start_serdes(struct ufs_qcom_phy*phy)
drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +11
-0+{ +u32 tmp; + + tmp =readl_relaxed (phy->mmio +UFS_PHY_PHY_START ); + tmp &= ~MASK_SERDES_START ; + tmp |= (1 <<OFFSET_SERDES_START ); +writel_relaxed (tmp, phy->mmio +UFS_PHY_PHY_START ); +mb (); +} + +static int ufs_qcom_phy_qmp_28nm_is_pcs_ready(struct ufs_qcom_phy
*phy_common)drivers/phy/phy-qcom-ufs-qmp-28nm.c new file +104
-0+{ +int err =0 ; +u32 val; + + err =readl_poll_timeout (phy_common->mmio +UFS_PHY_PCS_READY_STATUS , + val, (val &MASK_PCS_READY ),10 ,1000000 ); +if (err) +dev_err (phy_common->dev,"%s: phy init failed, %d\n" , + __func__, err); + +return err; +} + +struct phy_ops ufs_qcom_phy_qmp_28nm_phy_ops = { + .init = ufs_qcom_phy_qmp_28nm_init, + .exit = ufs_qcom_phy_exit, + .power_on = ufs_qcom_phy_power_on, + .power_off = ufs_qcom_phy_power_off, + .owner =THIS_MODULE , +}; + +struct ufs_qcom_phy_specific_ops phy_28nm_ops = { + .calibrate_phy = ufs_qcom_phy_qmp_28nm_calibrate, + .start_serdes = ufs_qcom_phy_qmp_28nm_start_serdes, + .save_configuration = ufs_qcom_phy_qmp_28nm_save_configuration, + .restore_configuration = ufs_qcom_phy_qmp_28nm_restore_configuration, + .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_28nm_is_pcs_ready, + .set_tx_lane_enable = ufs_qcom_phy_qmp_28nm_set_tx_lane_enable, + .power_control = ufs_qcom_phy_qmp_28nm_power_control, +}; + +static int ufs_qcom_phy_qmp_28nm_probe (struct platform_device *pdev) +{ +struct ufs_qcom_phy_qmp_28nm *phy; +struct device *dev = &pdev->dev; +int err =0 ; +struct phy *generic_phy; + + phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL ); +if (!phy) { + err = -ENOMEM ; +dev_err (dev,"%s: failed to allocate phy\n" , __func__); + goto out; + } + + phy->common_cfg.cached_regs = + (struct ufs_qcom_phy_calibration *)cached_phy_regs; + phy->common_cfg.cached_regs_table_size = +ARRAY_SIZE (cached_phy_regs); + + generic_phy =ufs_qcom_phy_generic_probe (pdev, &phy->common_cfg, + &ufs_qcom_phy_qmp_28nm_phy_ops, &phy_28nm_ops); + +if (!generic_phy) { +dev_err (dev,"%s: ufs_qcom_phy_generic_probe() failed\n" , + __func__); + err = -EIO ; + goto out; + } + +phy_set_drvdata (generic_phy, phy); + +strlcpy (phy->common_cfg.name,UFS_PHY_NAME , +sizeof (phy->common_cfg.name)); + +out: +return err; +} + +static int ufs_qcom_phy_qmp_28nm_remove (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct phy *generic_phy =to_phy (dev); +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int err =0 ; + + err =ufs_qcom_phy_remove (generic_phy, ufs_qcom_phy); +if (err) +dev_err (dev,"%s: ufs_qcom_phy_remove failed = %d\n" , + __func__, err); + +return err; +} + +static const struct of_device_id ufs_qcom_phy_qmp_28nm_of_match[] = { + {.compatible ="qcom,ufs-phy-qmp-28nm" }, + {}, +}; +MODULE_DEVICE_TABLE (of, ufs_qcom_phy_qmp_28nm_of_match); + +static struct platform_driver ufs_qcom_phy_qmp_28nm_driver = { + .probe = ufs_qcom_phy_qmp_28nm_probe, + .remove = ufs_qcom_phy_qmp_28nm_remove, + .driver = { + .of_match_table = ufs_qcom_phy_qmp_28nm_of_match, + .name ="ufs_qcom_phy_qmp_28nm" , + .owner =THIS_MODULE , + }, +}; + +module_platform_driver (ufs_qcom_phy_qmp_28nm_driver); + +MODULE_DESCRIPTION ("Universal Flash Storage (UFS) QCOM PHY QMP 28nm" ); +MODULE_LICENSE ("GPL v2" );drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +142
-0@@ -0,0 +1,738 @@ +/* +* Copyright (c) 2013-2014, Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#ifndef UFS_QCOM_PHY_QMP_28NM_H_ +#define UFS_QCOM_PHY_QMP_28NM_H_ + +#include <linux/phy/phy-qcom-ufs.h> + +/* QCOM UFS PHY control registers */ + +#define COM_OFF (x) (0x000 + x) +#define PHY_OFF (x) (0x700 + x) +#define TX_OFF (n, x) (0x100 + (0x400 * n) + x) +#define RX_OFF (n, x) (0x200 + (0x400 * n) + x) + +/* UFS PHY PLL block registers */ +#define QSERDES_COM_SYS_CLK_CTRL COM_OFF(0x00) +#define QSERDES_COM_PLL_VCOTAIL_EN COM_OFF(0x04) +#define QSERDES_COM_CMN_MODE COM_OFF(0x08) +#define QSERDES_COM_IE_TRIM COM_OFF(0x0C) +#define QSERDES_COM_IP_TRIM COM_OFF(0x10) +#define QSERDES_COM_PLL_CNTRL COM_OFF(0x14) +#define QSERDES_COM_PLL_IP_SETI COM_OFF(0x18) +#define QSERDES_COM_CORE_CLK_IN_SYNC_SEL COM_OFF(0x1C) +#define QSERDES_COM_BIAS_EN_CLKBUFLR_EN COM_OFF(0x20) +#define QSERDES_COM_PLL_CP_SETI COM_OFF(0x24) +#define QSERDES_COM_PLL_IP_SETP COM_OFF(0x28) +#define QSERDES_COM_PLL_CP_SETP COM_OFF(0x2C) +#define QSERDES_COM_ATB_SEL1 COM_OFF(0x30) +#define QSERDES_COM_ATB_SEL2 COM_OFF(0x34) +#define QSERDES_COM_SYSCLK_EN_SEL COM_OFF(0x38) +#define QSERDES_COM_RES_CODE_TXBAND COM_OFF(0x3C) +#define QSERDES_COM_RESETSM_CNTRL COM_OFF(0x40) +#define QSERDES_COM_PLLLOCK_CMP1 COM_OFF(0x44) +#define QSERDES_COM_PLLLOCK_CMP2 COM_OFF(0x48) +#define QSERDES_COM_PLLLOCK_CMP3 COM_OFF(0x4C) +#define QSERDES_COM_PLLLOCK_CMP_EN COM_OFF(0x50) +#define QSERDES_COM_RES_TRIM_OFFSET COM_OFF(0x54) +#define QSERDES_COM_BGTC COM_OFF(0x58) +#define QSERDES_COM_PLL_TEST_UPDN_RESTRIMSTEP COM_OFF(0x5C) +#define QSERDES_COM_PLL_VCO_TUNE COM_OFF(0x60) +#define QSERDES_COM_DEC_START1 COM_OFF(0x64) +#define QSERDES_COM_PLL_AMP_OS COM_OFF(0x68) +#define QSERDES_COM_SSC_EN_CENTER COM_OFF(0x6C) +#define QSERDES_COM_SSC_ADJ_PER1 COM_OFF(0x70) +#define QSERDES_COM_SSC_ADJ_PER2 COM_OFF(0x74) +#define QSERDES_COM_SSC_PER1 COM_OFF(0x78) +#define QSERDES_COM_SSC_PER2 COM_OFF(0x7C) +#define QSERDES_COM_SSC_STEP_SIZE1 COM_OFF(0x80) +#define QSERDES_COM_SSC_STEP_SIZE2 COM_OFF(0x84) +#define QSERDES_COM_RES_TRIM_SEARCH COM_OFF(0x88) +#define QSERDES_COM_RES_TRIM_FREEZE COM_OFF(0x8C) +#define QSERDES_COM_RES_TRIM_EN_VCOCALDONE COM_OFF(0x90) +#define QSERDES_COM_FAUX_EN COM_OFF(0x94) +#define QSERDES_COM_DIV_FRAC_START1 COM_OFF(0x98) +#define QSERDES_COM_DIV_FRAC_START2 COM_OFF(0x9C) +#define QSERDES_COM_DIV_FRAC_START3 COM_OFF(0xA0) +#define QSERDES_COM_DEC_START2 COM_OFF(0xA4) +#define QSERDES_COM_PLL_RXTXEPCLK_EN COM_OFF(0xA8) +#define QSERDES_COM_PLL_CRCTRL COM_OFF(0xAC) +#define QSERDES_COM_PLL_CLKEPDIV COM_OFF(0xB0) +#define QSERDES_COM_PLL_FREQUPDATE COM_OFF(0xB4) +#define QSERDES_COM_PLL_VCO_HIGH COM_OFF(0xB8) +#define QSERDES_COM_RESET_SM COM_OFF(0xBC) + +/* UFS PHY registers */ +#define UFS_PHY_PHY_START PHY_OFF(0x00) +#define UFS_PHY_POWER_DOWN_CONTROL PHY_OFF(0x04) +#define UFS_PHY_PWM_G1_CLK_DIVIDER PHY_OFF(0x08) +#define UFS_PHY_PWM_G2_CLK_DIVIDER PHY_OFF(0x0C) +#define UFS_PHY_PWM_G3_CLK_DIVIDER PHY_OFF(0x10) +#define UFS_PHY_PWM_G4_CLK_DIVIDER PHY_OFF(0x14) +#define UFS_PHY_TIMER_100US_SYSCLK_STEPS_MSB PHY_OFF(0x18) +#define UFS_PHY_TIMER_100US_SYSCLK_STEPS_LSB PHY_OFF(0x1C) +#define UFS_PHY_TIMER_20US_CORECLK_STEPS_MSB PHY_OFF(0x20) +#define UFS_PHY_TIMER_20US_CORECLK_STEPS_LSB PHY_OFF(0x24) +#define UFS_PHY_LINE_RESET_TIME PHY_OFF(0x28) +#define UFS_PHY_LINE_RESET_GRANULARITY PHY_OFF(0x2C) +#define UFS_PHY_CONTROLSYM_ONE_HOT_DISABLE PHY_OFF(0x30) +#define UFS_PHY_CORECLK_PWM_G1_CLK_DIVIDER PHY_OFF(0x34) +#define UFS_PHY_CORECLK_PWM_G2_CLK_DIVIDER PHY_OFF(0x38) +#define UFS_PHY_CORECLK_PWM_G3_CLK_DIVIDER PHY_OFF(0x3C) +#define UFS_PHY_CORECLK_PWM_G4_CLK_DIVIDER PHY_OFF(0x40) +#define UFS_PHY_TX_LANE_ENABLE PHY_OFF(0x44) +#define UFS_PHY_TSYNC_RSYNC_CNTL PHY_OFF(0x48) +#define UFS_PHY_RETIME_BUFFER_EN PHY_OFF(0x4C) +#define UFS_PHY_PLL_CNTL PHY_OFF(0x50) +#define UFS_PHY_TX_LARGE_AMP_DRV_LVL PHY_OFF(0x54) +#define UFS_PHY_TX_LARGE_AMP_POST_EMP_LVL PHY_OFF(0x58) +#define UFS_PHY_TX_SMALL_AMP_DRV_LVL PHY_OFF(0x5C) +#define UFS_PHY_TX_SMALL_AMP_POST_EMP_LVL PHY_OFF(0x60) +#define UFS_PHY_CFG_CHANGE_CNT_VAL PHY_OFF(0x64) +#define UFS_PHY_OMC_STATUS_RDVAL PHY_OFF(0x68) +#define UFS_PHY_RX_SYNC_WAIT_TIME PHY_OFF(0x6C) +#define UFS_PHY_L0_BIST_CTRL PHY_OFF(0x70) +#define UFS_PHY_L1_BIST_CTRL PHY_OFF(0x74) +#define UFS_PHY_BIST_PRBS_POLY0 PHY_OFF(0x78) +#define UFS_PHY_BIST_PRBS_POLY1 PHY_OFF(0x7C) +#define UFS_PHY_BIST_PRBS_SEED0 PHY_OFF(0x80) +#define UFS_PHY_BIST_PRBS_SEED1 PHY_OFF(0x84) +#define UFS_PHY_BIST_FIXED_PAT_CTRL PHY_OFF(0x88) +#define UFS_PHY_BIST_FIXED_PAT0_DATA PHY_OFF(0x8C) +#define UFS_PHY_BIST_FIXED_PAT1_DATA PHY_OFF(0x90) +#define UFS_PHY_BIST_FIXED_PAT2_DATA PHY_OFF(0x94) +#define UFS_PHY_BIST_FIXED_PAT3_DATA PHY_OFF(0x98) +#define UFS_PHY_TX_HSGEAR_CAPABILITY PHY_OFF(0x9C) +#define UFS_PHY_TX_PWMGEAR_CAPABILITY PHY_OFF(0xA0) +#define UFS_PHY_TX_AMPLITUDE_CAPABILITY PHY_OFF(0xA4) +#define UFS_PHY_TX_EXTERNALSYNC_CAPABILITY PHY_OFF(0xA8) +#define UFS_PHY_TX_HS_UNTERMINATED_LINE_DRIVE_CAPABILITY PHY_OFF(0xAC) +#define UFS_PHY_TX_LS_TERMINATED_LINE_DRIVE_CAPABILITY PHY_OFF(0xB0) +#define UFS_PHY_TX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xB4) +#define UFS_PHY_TX_MIN_STALL_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xB8) +#define UFS_PHY_TX_MIN_SAVE_CONFIG_TIME_CAPABILITY PHY_OFF(0xBC) +#define UFS_PHY_TX_REF_CLOCK_SHARED_CAPABILITY PHY_OFF(0xC0) +#define UFS_PHY_TX_PHY_MAJORMINOR_RELEASE_CAPABILITY PHY_OFF(0xC4) +#define UFS_PHY_TX_PHY_EDITORIAL_RELEASE_CAPABILITY PHY_OFF(0xC8) +#define UFS_PHY_TX_HIBERN8TIME_CAPABILITY PHY_OFF(0xCC) +#define UFS_PHY_RX_HSGEAR_CAPABILITY PHY_OFF(0xD0) +#define UFS_PHY_RX_PWMGEAR_CAPABILITY PHY_OFF(0xD4) +#define UFS_PHY_RX_HS_UNTERMINATED_CAPABILITY PHY_OFF(0xD8) +#define UFS_PHY_RX_LS_TERMINATED_CAPABILITY PHY_OFF(0xDC) +#define UFS_PHY_RX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xE0) +#define UFS_PHY_RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xE4) +#define UFS_PHY_RX_MIN_SAVE_CONFIG_TIME_CAPABILITY PHY_OFF(0xE8) +#define UFS_PHY_RX_REF_CLOCK_SHARED_CAPABILITY PHY_OFF(0xEC) +#define UFS_PHY_RX_HS_G1_SYNC_LENGTH_CAPABILITY PHY_OFF(0xF0) +#define UFS_PHY_RX_HS_G1_PREPARE_LENGTH_CAPABILITY PHY_OFF(0xF4) +#define UFS_PHY_RX_LS_PREPARE_LENGTH_CAPABILITY PHY_OFF(0xF8) +#define UFS_PHY_RX_PWM_BURST_CLOSURE_LENGTH_CAPABILITY PHY_OFF(0xFC) +#define UFS_PHY_RX_MIN_ACTIVATETIME_CAPABILITY
PHY_OFF(0x100)
+#defineUFS_PHY_RX_PHY_MAJORMINOR_RELEASE_CAPABILITYPHY_OFF(0x104)
+#defineUFS_PHY_RX_PHY_EDITORIAL_RELEASE_CAPABILITYPHY_OFF(0x108)
+#defineUFS_PHY_RX_HIBERN8TIME_CAPABILITYPHY_OFF(0x10C)
+#defineUFS_PHY_RX_HS_G2_SYNC_LENGTH_CAPABILITYPHY_OFF(0x110)
+#defineUFS_PHY_RX_HS_G3_SYNC_LENGTH_CAPABILITYPHY_OFF(0x114)
+#defineUFS_PHY_RX_HS_G2_PREPARE_LENGTH_CAPABILITYPHY_OFF(0x118)
+#defineUFS_PHY_RX_HS_G3_PREPARE_LENGTH_CAPABILITYPHY_OFF(0x11C)
+#defineUFS_PHY_DEBUG_BUS_SELPHY_OFF(0x120)
+#defineUFS_PHY_DEBUG_BUS_0_STATUS_CHKPHY_OFF(0x124)
+#defineUFS_PHY_DEBUG_BUS_1_STATUS_CHKPHY_OFF(0x128)
+#defineUFS_PHY_DEBUG_BUS_2_STATUS_CHKPHY_OFF(0x12C)
+#defineUFS_PHY_DEBUG_BUS_3_STATUS_CHKPHY_OFF(0x130)
+#defineUFS_PHY_PCS_READY_STATUSPHY_OFF(0x134)
+#defineUFS_PHY_L0_BIST_CHK_ERR_CNT_L_STATUSPHY_OFF(0x138)
+#defineUFS_PHY_L0_BIST_CHK_ERR_CNT_H_STATUSPHY_OFF(0x13C)
+#defineUFS_PHY_L1_BIST_CHK_ERR_CNT_L_STATUSPHY_OFF(0x140)
+#defineUFS_PHY_L1_BIST_CHK_ERR_CNT_H_STATUSPHY_OFF(0x144)
+#defineUFS_PHY_L0_BIST_CHK_STATUSPHY_OFF(0x148)
+#defineUFS_PHY_L1_BIST_CHK_STATUSPHY_OFF(0x14C)
+#defineUFS_PHY_DEBUG_BUS_0_STATUSPHY_OFF(0x150)
+#defineUFS_PHY_DEBUG_BUS_1_STATUSPHY_OFF(0x154)
+#defineUFS_PHY_DEBUG_BUS_2_STATUSPHY_OFF(0x158)
+#defineUFS_PHY_DEBUG_BUS_3_STATUSPHY_OFF(0x15C)
+#defineUFS_PHY_RMMI_ATTR_CTRLPHY_OFF(0x16C)drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +15
-0+#define UFS_PHY_RMMI_RX_CFGUPDT_L1 (1 << 7) +#define UFS_PHY_RMMI_TX_CFGUPDT_L1 (1 << 6) +#define UFS_PHY_RMMI_CFGWR_L1 (1 << 5) +#define UFS_PHY_RMMI_CFGRD_L1 (1 << 4) +#define UFS_PHY_RMMI_RX_CFGUPDT_L0 (1 << 3) +#define UFS_PHY_RMMI_TX_CFGUPDT_L0 (1 << 2) +#define UFS_PHY_RMMI_CFGWR_L0 (1 << 1) +#define UFS_PHY_RMMI_CFGRD_L0 (1 << 0) +#define UFS_PHY_RMMI_ATTRID PHY_OFF(0x170) +#define UFS_PHY_RMMI_ATTRWRVAL PHY_OFF(0x174) +#define UFS_PHY_RMMI_ATTRRDVAL_L0_STATUS PHY_OFF(0x178) +#define UFS_PHY_RMMI_ATTRRDVAL_L1_STATUS PHY_OFF(0x17C) + +/* TX LANE n (0, 1) registers */ +#define QSERDES_TX_BIST_MODE_LANENO (n) TX_OFF(n,
0x00)
+#defineQSERDES_TX_CLKBUF_ENABLE(n)TX_OFF(n,0x04)
+#defineQSERDES_TX_TX_EMP_POST1_LVL(n)TX_OFF(n,0x08)
+#defineQSERDES_TX_TX_DRV_LVL(n)TX_OFF(n,0x0C)
+#defineQSERDES_TX_RESET_TSYNC_EN(n)TX_OFF(n,0x10)
+#defineQSERDES_TX_LPB_EN(n)TX_OFF(n,0x14)
+#defineQSERDES_TX_RES_CODE(n)TX_OFF(n,0x18)
+#defineQSERDES_TX_PERL_LENGTH1(n)TX_OFF(n,0x1C)
+#defineQSERDES_TX_PERL_LENGTH2(n)TX_OFF(n,0x20)
+#defineQSERDES_TX_SERDES_BYP_EN_OUT(n)TX_OFF(n,0x24)
+#defineQSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_EN(n)TX_OFF(n,0x28)
+#defineQSERDES_TX_PARRATE_REC_DETECT_IDLE_EN(n)TX_OFF(n,0x2C)
+#defineQSERDES_TX_BIST_PATTERN1(n)TX_OFF(n,0x30)
+#defineQSERDES_TX_BIST_PATTERN2(n)TX_OFF(n,0x34)
+#defineQSERDES_TX_BIST_PATTERN3(n)TX_OFF(n,0x38)
+#defineQSERDES_TX_BIST_PATTERN4(n)TX_OFF(n,0x3C)
+#defineQSERDES_TX_BIST_PATTERN5(n)TX_OFF(n,0x40)
+#defineQSERDES_TX_BIST_PATTERN6(n)TX_OFF(n,0x44)
+#defineQSERDES_TX_BIST_PATTERN7(n)TX_OFF(n,0x48)
+#defineQSERDES_TX_BIST_PATTERN8(n)TX_OFF(n,0x4C)
+#defineQSERDES_TX_LANE_MODE(n)TX_OFF(n,0x50)
+#defineQSERDES_TX_ATB_SEL(n)TX_OFF(n,0x54)
+#defineQSERDES_TX_REC_DETECT_LVL(n)TX_OFF(n,0x58)
+#defineQSERDES_TX_PRBS_SEED1(n)TX_OFF(n,0x5C)
+#defineQSERDES_TX_PRBS_SEED2(n)TX_OFF(n,0x60)
+#defineQSERDES_TX_PRBS_SEED3(n)TX_OFF(n,0x64)
+#defineQSERDES_TX_PRBS_SEED4(n)TX_OFF(n,0x68)
+#defineQSERDES_TX_RESET_GEN(n)TX_OFF(n,0x6C)
+#defineQSERDES_TX_TRAN_DRVR_EMP_EN(n)TX_OFF(n,0x70)
+#defineQSERDES_TX_TX_INTERFACE_MODE(n)TX_OFF(n,0x74)
+#defineQSERDES_TX_BIST_STATUS(n)TX_OFF(n,0x78)
+#defineQSERDES_TX_BIST_ERROR_COUNT1(n)TX_OFF(n,0x7C)
+#defineQSERDES_TX_BIST_ERROR_COUNT2(n)TX_OFF(n,0x80)drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +3
-0+ +/* RX LANE n (0, 1) registers */ +#define QSERDES_RX_CDR_CONTROL (n) RX_OFF(n,
0x00)
+#defineQSERDES_RX_AUX_CONTROL(n)RX_OFF(n,0x04)
+#defineQSERDES_RX_AUX_DATA_TCODE(n)RX_OFF(n,0x08)
+#defineQSERDES_RX_RCLK_AUXDATA_SEL(n)RX_OFF(n,0x0C)
+#defineQSERDES_RX_EQ_CONTROL(n)RX_OFF(n,0x10)
+#defineQSERDES_RX_RX_EQ_GAIN2(n)RX_OFF(n,0x14)
+#defineQSERDES_RX_AC_JTAG_INIT(n)RX_OFF(n,0x18)
+#defineQSERDES_RX_AC_JTAG_LVL_EN(n)RX_OFF(n,0x1C)
+#defineQSERDES_RX_AC_JTAG_MODE(n)RX_OFF(n,0x20)
+#defineQSERDES_RX_AC_JTAG_RESET(n)RX_OFF(n,0x24)
+#defineQSERDES_RX_RX_IQ_RXDET_EN(n)RX_OFF(n,0x28)
+#defineQSERDES_RX_RX_TERM_HIGHZ_CM_AC_COUPLE(n)RX_OFF(n,0x2C)
+#defineQSERDES_RX_RX_EQ_GAIN1(n)RX_OFF(n,0x30)
+#defineQSERDES_RX_SIGDET_CNTRL(n)RX_OFF(n,0x34)
+#defineQSERDES_RX_RX_BAND(n)RX_OFF(n,0x38)
+#defineQSERDES_RX_CDR_FREEZE_UP_DN(n)RX_OFF(n,0x3C)
+#defineQSERDES_RX_RX_INTERFACE_MODE(n)RX_OFF(n,0x40)
+#defineQSERDES_RX_JITTER_GEN_MODE(n)RX_OFF(n,0x44)
+#defineQSERDES_RX_BUJ_AMP(n)RX_OFF(n,0x48)
+#defineQSERDES_RX_SJ_AMP1(n)RX_OFF(n,0x4C)
+#defineQSERDES_RX_SJ_AMP2(n)RX_OFF(n,0x50)
+#defineQSERDES_RX_SJ_PER1(n)RX_OFF(n,0x54)
+#defineQSERDES_RX_SJ_PER2(n)RX_OFF(n,0x58)
+#defineQSERDES_RX_BUJ_STEP_FREQ1(n)RX_OFF(n,0x5C)
+#defineQSERDES_RX_BUJ_STEP_FREQ2(n)RX_OFF(n,0x60)
+#defineQSERDES_RX_PPM_OFFSET1(n)RX_OFF(n,0x64)
+#defineQSERDES_RX_PPM_OFFSET2(n)RX_OFF(n,0x68)
+#defineQSERDES_RX_SIGN_PPM_PERIOD1(n)RX_OFF(n,0x6C)
+#defineQSERDES_RX_SIGN_PPM_PERIOD2(n)RX_OFF(n,0x70)
+#defineQSERDES_RX_SSC_CTRL(n)RX_OFF(n,0x74)
+#defineQSERDES_RX_SSC_COUNT1(n)RX_OFF(n,0x78)
+#defineQSERDES_RX_SSC_COUNT2(n)RX_OFF(n,0x7C)
+#defineQSERDES_RX_PWM_CNTRL1(n)RX_OFF(n,0x80)
+#defineQSERDES_RX_PWM_CNTRL2(n)RX_OFF(n,0x84)
+#defineQSERDES_RX_PWM_NDIV(n)RX_OFF(n,0x88)
+#defineQSERDES_RX_SIGDET_CNTRL2(n)RX_OFF(n,0x8C)
+#defineQSERDES_RX_UFS_CNTRL(n)RX_OFF(n,0x90)
+#defineQSERDES_RX_CDR_CONTROL3(n)RX_OFF(n,0x94)
+#defineQSERDES_RX_CDR_CONTROL_HALF(n)RX_OFF(n,0x98)
+#defineQSERDES_RX_CDR_CONTROL_QUARTER(n)RX_OFF(n,0x9C)
+#defineQSERDES_RX_CDR_CONTROL_EIGHTH(n)RX_OFF(n,0xA0)
+#defineQSERDES_RX_UCDR_FO_GAIN(n)RX_OFF(n,0xA4)
+#defineQSERDES_RX_UCDR_SO_GAIN(n)RX_OFF(n,0xA8)
+#defineQSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE(n)RX_OFF(n,0xAC)
+#defineQSERDES_RX_UCDR_FO_TO_SO_DELAY(n)RX_OFF(n,0xB0)
+#defineQSERDES_RX_PI_CTRL1(n)RX_OFF(n,0xB4)
+#defineQSERDES_RX_PI_CTRL2(n)RX_OFF(n,0xB8)
+#defineQSERDES_RX_PI_QUAD(n)RX_OFF(n,0xBC)
+#defineQSERDES_RX_IDATA1(n)RX_OFF(n,0xC0)
+#defineQSERDES_RX_IDATA2(n)RX_OFF(n,0xC4)
+#defineQSERDES_RX_AUX_DATA1(n)RX_OFF(n,0xC8)
+#defineQSERDES_RX_AUX_DATA2(n)RX_OFF(n,0xCC)
+#defineQSERDES_RX_AC_JTAG_OUTP(n)RX_OFF(n,0xD0)
+#defineQSERDES_RX_AC_JTAG_OUTN(n)RX_OFF(n,0xD4)
+#defineQSERDES_RX_RX_SIGDET_PWMDECSTATUS(n)RX_OFF(n,0xD8)drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +16
-0+ +#define UFS_PHY_TX_LANE_ENABLE_MASK 0x3 + +/* +* This structure represents the 28nm specific phy. +* common_cfg MUST remain the first field in this structure +* in case extra fields are added. This way, when calling +* get_ufs_qcom_phy() of generic phy, we can extract the +* common phy structure (struct ufs_qcom_phy) out of it +* regardless of the relevant specific phy. +*/ +struct ufs_qcom_phy_qmp_28nm { +struct ufs_qcom_phy common_cfg; +}; + +static struct ufs_qcom_phy_calibration phy_cal_table_ctrl_1_1_0_rate_A[]= {
drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +168
-0+UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_POWER_DOWN_CONTROL ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CRCTRL ,0xFF ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CNTRL ,0x24 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_SYSCLK_EN_SEL ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_SYS_CLK_CTRL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CLKEPDIV ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START1 ,0x82 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START1 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START2 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START3 ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP1 ,0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP2 ,0x67 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP3 ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP_EN ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RESETSM_CNTRL ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_RXTXEPCLK_EN ,0x13 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_PWM_CNTRL1 (0 ),0x43 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_PWM_CNTRL1 (1 ),0x43 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL (0 ),0x22 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (0 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (0 ),0x2a ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL (1 ),0x22 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (1 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (1 ),0x2a ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL (0 ),0xC0 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL (1 ),0xC0 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL2 (0 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL2 (1 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G1_CLK_DIVIDER ,0x50 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G2_CLK_DIVIDER ,0x28 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G3_CLK_DIVIDER ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G4_CLK_DIVIDER ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G1_CLK_DIVIDER ,0xa8 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G2_CLK_DIVIDER ,0x54 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G3_CLK_DIVIDER ,0x2a ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G4_CLK_DIVIDER ,0x15 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_OMC_STATUS_RDVAL ,0xff ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_LINE_RESET_TIME ,0x1f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_LINE_RESET_GRANULARITY ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TSYNC_RSYNC_CNTL ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PLL_CNTL ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_LARGE_AMP_DRV_LVL ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_SMALL_AMP_DRV_LVL ,0x1a ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_LARGE_AMP_POST_EMP_LVL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_SMALL_AMP_POST_EMP_LVL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CFG_CHANGE_CNT_VAL ,0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_SYNC_WAIT_TIME ,0x30 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_MIN_STALL_NOCONFIG_TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_MIN_SAVE_CONFIG_TIME_CAPABILITY ,0x04 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_MIN_SAVE_CONFIG_TIME_CAPABILITY ,0xc8 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_PWM_BURST_CLOSURE_LENGTH_CAPABILITY ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_MIN_ACTIVATETIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1 (0 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2 (0 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1 (1 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2 (1 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL3 (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL3 (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETI ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETI ,0x3f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETP ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETP ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RES_TRIM_OFFSET ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_BGTC ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_AMP_OS ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_DRV_LVL (0 ),0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_DRV_LVL (1 ),0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_BIST_MODE_LANENO (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_BIST_MODE_LANENO (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_EMP_POST1_LVL (0 ),0x04 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_EMP_POST1_LVL (1 ),0x04 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_EN (0 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_EN (1 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_100US_SYSCLK_STEPS_MSB ,0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_100US_SYSCLK_STEPS_LSB ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_20US_CORECLK_STEPS_MSB ,0x27 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_20US_CORECLK_STEPS_LSB ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CONTROLSYM_ONE_HOT_DISABLE ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RETIME_BUFFER_EN ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_HSGEAR_CAPABILITY ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_PWMGEAR_CAPABILITY ,0x04 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_AMPLITUDE_CAPABILITY ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_EXTERNALSYNC_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_HS_UNTERMINATED_LINE_DRIVE_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_LS_TERMINATED_LINE_DRIVE_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_REF_CLOCK_SHARED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_HIBERN8TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HSGEAR_CAPABILITY ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_PWMGEAR_CAPABILITY ,0x04 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_UNTERMINATED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_LS_TERMINATED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_REF_CLOCK_SHARED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G1_SYNC_LENGTH_CAPABILITY ,0x48 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_HS_G1_PREPARE_LENGTH_CAPABILITY ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_LS_PREPARE_LENGTH_CAPABILITY ,0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HIBERN8TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G2_SYNC_LENGTH_CAPABILITY ,0x48 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G3_SYNC_LENGTH_CAPABILITY ,0x48 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_HS_G2_PREPARE_LENGTH_CAPABILITY ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_HS_G3_PREPARE_LENGTH_CAPABILITY ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_CLKBUF_ENABLE (0 ),0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RESET_TSYNC_EN (0 ),0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RES_CODE (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_SERDES_BYP_EN_OUT (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_REC_DETECT_LVL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_PARRATE_REC_DETECT_IDLE_EN (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TRAN_DRVR_EMP_EN (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_CONTROL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_DATA_TCODE (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RCLK_AUXDATA_SEL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_EQ_CONTROL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_IQ_RXDET_EN (0 ),0x73 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_TERM_HIGHZ_CM_AC_COUPLE (0 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_FREEZE_UP_DN (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UFS_CNTRL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_EIGHTH (0 ),0x22 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_GAIN (0 ),0x0a ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_SO_GAIN (0 ),0x06 ), +UFS_QCOM_PHY_CAL_ENTRY ( +QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE (0 ),0x35 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_TO_SO_DELAY (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_CLKBUF_ENABLE (1 ),0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RESET_TSYNC_EN (1 ),0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RES_CODE (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_SERDES_BYP_EN_OUT (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_REC_DETECT_LVL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_PARRATE_REC_DETECT_IDLE_EN (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TRAN_DRVR_EMP_EN (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_CONTROL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_DATA_TCODE (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RCLK_AUXDATA_SEL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_EQ_CONTROL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_IQ_RXDET_EN (1 ),0x73 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_TERM_HIGHZ_CM_AC_COUPLE (1 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_FREEZE_UP_DN (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UFS_CNTRL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_EIGHTH (1 ),0x22 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_GAIN (1 ),0x0a ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_SO_GAIN (1 ),0x06 ), +UFS_QCOM_PHY_CAL_ENTRY ( +QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE (1 ),0x35 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_TO_SO_DELAY (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_CMN_MODE ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_IE_TRIM ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_IP_TRIM ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_CORE_CLK_IN_SYNC_SEL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_BIAS_EN_CLKBUFLR_EN ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_TEST_UPDN_RESTRIMSTEP ,0x00 ), + UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_FAUX_EN, 0x00), +}; + +static struct ufs_qcom_phy_calibration phy_cal_table_ctrl_1_1_1_rate_A[]= {
drivers/phy/phy-qcom-ufs-qmp-28nm.h new file +284
-0+UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_POWER_DOWN_CONTROL ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CRCTRL ,0x43 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CNTRL ,0x24 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_SYSCLK_EN_SEL ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_SYS_CLK_CTRL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CLKEPDIV ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START1 ,0x82 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START1 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START2 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START3 ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP1 ,0xff ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP2 ,0x19 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP3 ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP_EN ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RESETSM_CNTRL ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_RXTXEPCLK_EN ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_PWM_CNTRL1 (0 ),0x43 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_PWM_CNTRL1 (1 ),0x43 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL (0 ),0x40 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (0 ),0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (0 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL (1 ),0x40 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_HALF (1 ),0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_QUARTER (1 ),0x12 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL (0 ),0xC0 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL (1 ),0xC0 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL2 (0 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_SIGDET_CNTRL2 (1 ),0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G1_CLK_DIVIDER ,0x30 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G2_CLK_DIVIDER ,0x18 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G3_CLK_DIVIDER ,0x0c ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PWM_G4_CLK_DIVIDER ,0x06 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G1_CLK_DIVIDER ,0xa8 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G2_CLK_DIVIDER ,0x54 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G3_CLK_DIVIDER ,0x2a ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CORECLK_PWM_G4_CLK_DIVIDER ,0x15 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_OMC_STATUS_RDVAL ,0xff ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_LINE_RESET_TIME ,0x1f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_LINE_RESET_GRANULARITY ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TSYNC_RSYNC_CNTL ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_PLL_CNTL ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_LARGE_AMP_DRV_LVL ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_SMALL_AMP_DRV_LVL ,0x1a ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_LARGE_AMP_POST_EMP_LVL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_SMALL_AMP_POST_EMP_LVL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CFG_CHANGE_CNT_VAL ,0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_SYNC_WAIT_TIME ,0x30 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY ,0x08 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_MIN_STALL_NOCONFIG_TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_MIN_SAVE_CONFIG_TIME_CAPABILITY ,0x04 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_MIN_SAVE_CONFIG_TIME_CAPABILITY ,0xc8 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_RX_PWM_BURST_CLOSURE_LENGTH_CAPABILITY ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_MIN_ACTIVATETIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1 (0 ),0x1f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2 (0 ),0x17 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN1 (1 ),0x1f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_EQ_GAIN2 (1 ),0x17 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL3 (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL3 (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETI ,0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETI ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_IP_SETP ,0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CP_SETP ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_RES_TRIM_OFFSET ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_BGTC ,0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_AMP_OS ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_DRV_LVL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_DRV_LVL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_BIST_MODE_LANENO (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_BIST_MODE_LANENO (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_EMP_POST1_LVL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TX_EMP_POST1_LVL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_EN (0 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_EN (1 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_100US_SYSCLK_STEPS_MSB ,0x07 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_100US_SYSCLK_STEPS_LSB ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_20US_CORECLK_STEPS_MSB ,0x27 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TIMER_20US_CORECLK_STEPS_LSB ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_CONTROLSYM_ONE_HOT_DISABLE ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RETIME_BUFFER_EN ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_HSGEAR_CAPABILITY ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_PWMGEAR_CAPABILITY ,0x04 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_AMPLITUDE_CAPABILITY ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_EXTERNALSYNC_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_HS_UNTERMINATED_LINE_DRIVE_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY ( +UFS_PHY_TX_LS_TERMINATED_LINE_DRIVE_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_REF_CLOCK_SHARED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_TX_HIBERN8TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HSGEAR_CAPABILITY ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_PWMGEAR_CAPABILITY ,0x04 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_UNTERMINATED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_LS_TERMINATED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_REF_CLOCK_SHARED_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G1_SYNC_LENGTH_CAPABILITY ,0x48 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G1_PREPARE_LENGTH_CAPABILITY , +0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_LS_PREPARE_LENGTH_CAPABILITY ,0x0a ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HIBERN8TIME_CAPABILITY ,0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G2_SYNC_LENGTH_CAPABILITY ,0x48 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G3_SYNC_LENGTH_CAPABILITY ,0x48 ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G2_PREPARE_LENGTH_CAPABILITY , +0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (UFS_PHY_RX_HS_G3_PREPARE_LENGTH_CAPABILITY , +0x0f ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_CLKBUF_ENABLE (0 ),0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RESET_TSYNC_EN (0 ),0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RES_CODE (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_SERDES_BYP_EN_OUT (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_REC_DETECT_LVL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_PARRATE_REC_DETECT_IDLE_EN (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TRAN_DRVR_EMP_EN (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_CONTROL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_DATA_TCODE (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RCLK_AUXDATA_SEL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_EQ_CONTROL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_IQ_RXDET_EN (0 ),0x51 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_TERM_HIGHZ_CM_AC_COUPLE (0 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_FREEZE_UP_DN (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UFS_CNTRL (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_EIGHTH (0 ),0x22 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_GAIN (0 ),0x0a ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_SO_GAIN (0 ),0x06 ), +UFS_QCOM_PHY_CAL_ENTRY ( +QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE (0 ),0x35 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_TO_SO_DELAY (0 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_CLKBUF_ENABLE (1 ),0x09 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RESET_TSYNC_EN (1 ),0x01 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_RES_CODE (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_SERDES_BYP_EN_OUT (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_REC_DETECT_LVL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_PARRATE_REC_DETECT_IDLE_EN (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_TRAN_DRVR_EMP_EN (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_CONTROL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_AUX_DATA_TCODE (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RCLK_AUXDATA_SEL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_EQ_CONTROL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_IQ_RXDET_EN (1 ),0x51 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_RX_TERM_HIGHZ_CM_AC_COUPLE (1 ),0x05 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_FREEZE_UP_DN (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UFS_CNTRL (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_CDR_CONTROL_EIGHTH (1 ),0x22 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_GAIN (1 ),0x0a ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_SO_GAIN (1 ),0x06 ), +UFS_QCOM_PHY_CAL_ENTRY ( +QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE (1 ),0x35 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_RX_UCDR_FO_TO_SO_DELAY (1 ),0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_CMN_MODE ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_IE_TRIM ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_IP_TRIM ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_CORE_CLK_IN_SYNC_SEL ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_BIAS_EN_CLKBUFLR_EN ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_TEST_UPDN_RESTRIMSTEP ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_FAUX_EN ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_TX_LANE_MODE (0 ),0x08 ), + UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_LANE_MODE(1), 0x08), +}; + +static struct ufs_qcom_phy_calibration phy_cal_table_rate_B[] = { +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLL_CLKEPDIV ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START1 ,0x98 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DEC_START2 ,0x03 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START1 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START2 ,0x80 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_DIV_FRAC_START3 ,0x10 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP1 ,0x65 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP2 ,0x1E ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP3 ,0x00 ), +UFS_QCOM_PHY_CAL_ENTRY (QSERDES_COM_PLLLOCK_CMP_EN ,0x03 ), +}; + +static struct ufs_qcom_phy_calibration cached_phy_regs[] = { + {QSERDES_COM_PLL_CRCTRL }, + {QSERDES_COM_PLL_CNTRL }, + {QSERDES_COM_SYSCLK_EN_SEL }, + {QSERDES_COM_SYS_CLK_CTRL }, + {QSERDES_COM_PLL_CLKEPDIV }, + {QSERDES_COM_DEC_START1 }, + {QSERDES_COM_DEC_START2 }, + {QSERDES_COM_DIV_FRAC_START1 }, + {QSERDES_COM_DIV_FRAC_START2 }, + {QSERDES_COM_DIV_FRAC_START3 }, + {QSERDES_COM_PLLLOCK_CMP1 }, + {QSERDES_COM_PLLLOCK_CMP2 }, + {QSERDES_COM_PLLLOCK_CMP3 }, + {QSERDES_COM_PLLLOCK_CMP_EN }, + {QSERDES_COM_RESETSM_CNTRL }, + {QSERDES_COM_PLL_RXTXEPCLK_EN }, + {QSERDES_RX_PWM_CNTRL1 (0 )}, + {QSERDES_RX_PWM_CNTRL1 (1 )}, + {QSERDES_RX_CDR_CONTROL (0 )}, + {QSERDES_RX_CDR_CONTROL_HALF (0 )}, + {QSERDES_RX_CDR_CONTROL_QUARTER (0 )}, + {QSERDES_RX_CDR_CONTROL (1 )}, + {QSERDES_RX_CDR_CONTROL_HALF (1 )}, + {QSERDES_RX_CDR_CONTROL_QUARTER (1 )}, + {QSERDES_RX_SIGDET_CNTRL (0 )}, + {QSERDES_RX_SIGDET_CNTRL (1 )}, + {QSERDES_RX_SIGDET_CNTRL2 (0 )}, + {QSERDES_RX_SIGDET_CNTRL2 (1 )}, + {QSERDES_RX_RX_EQ_GAIN1 (0 )}, + {QSERDES_RX_RX_EQ_GAIN2 (0 )}, + {QSERDES_RX_RX_EQ_GAIN1 (1 )}, + {QSERDES_RX_RX_EQ_GAIN2 (1 )}, + {QSERDES_COM_PLL_IP_SETI }, + {QSERDES_COM_PLL_CP_SETI }, + {QSERDES_COM_PLL_IP_SETP }, + {QSERDES_COM_PLL_CP_SETP }, + {UFS_PHY_PWM_G1_CLK_DIVIDER }, + {UFS_PHY_PWM_G2_CLK_DIVIDER }, + {UFS_PHY_PWM_G3_CLK_DIVIDER }, + {UFS_PHY_PWM_G4_CLK_DIVIDER }, + {UFS_PHY_CORECLK_PWM_G1_CLK_DIVIDER }, + {UFS_PHY_CORECLK_PWM_G2_CLK_DIVIDER }, + {UFS_PHY_CORECLK_PWM_G3_CLK_DIVIDER }, + {UFS_PHY_CORECLK_PWM_G4_CLK_DIVIDER }, + {UFS_PHY_OMC_STATUS_RDVAL }, + {UFS_PHY_LINE_RESET_TIME }, + {UFS_PHY_LINE_RESET_GRANULARITY }, + {UFS_PHY_TSYNC_RSYNC_CNTL }, + {UFS_PHY_PLL_CNTL }, + {UFS_PHY_TX_LARGE_AMP_DRV_LVL }, + {UFS_PHY_TX_SMALL_AMP_DRV_LVL }, + {UFS_PHY_TX_LARGE_AMP_POST_EMP_LVL }, + {UFS_PHY_TX_SMALL_AMP_POST_EMP_LVL }, + {UFS_PHY_CFG_CHANGE_CNT_VAL }, + {UFS_PHY_RX_SYNC_WAIT_TIME }, + {UFS_PHY_TX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY }, + {UFS_PHY_RX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY }, + {UFS_PHY_TX_MIN_STALL_NOCONFIG_TIME_CAPABILITY }, + {UFS_PHY_RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY }, + {UFS_PHY_TX_MIN_SAVE_CONFIG_TIME_CAPABILITY }, + {UFS_PHY_RX_MIN_SAVE_CONFIG_TIME_CAPABILITY }, + {UFS_PHY_RX_PWM_BURST_CLOSURE_LENGTH_CAPABILITY }, + {UFS_PHY_RX_MIN_ACTIVATETIME_CAPABILITY }, + {QSERDES_RX_CDR_CONTROL3 (0 )}, + {QSERDES_RX_CDR_CONTROL3 (1 )}, + {QSERDES_COM_RES_TRIM_OFFSET }, + {QSERDES_COM_BGTC }, + {QSERDES_COM_PLL_AMP_OS }, +}; + +static struct ufs_qcom_phy_stored_attributes cached_phy_attr[] = { + {TX_MODE }, + {TX_HSRATE_SERIES }, + {TX_HSGEAR }, + {TX_PWMGEAR }, + {TX_AMPLITUDE }, + {TX_HS_SLEWRATE }, + {TX_SYNC_SOURCE }, + {TX_HS_PREPARE_LENGTH }, + {TX_LS_PREPARE_LENGTH }, + {TX_LCC_ENABLE }, + {TX_PWM_BURST_CLOSURE_EXTENSION }, + {TX_BYPASS_8B10B_ENABLE }, + {TX_DRIVER_POLARITY }, + {TX_HS_UNTERMINATED_LINE_DRIVE_ENABLE }, + {TX_LS_TERMINATED_LINE_DRIVE_ENABLE }, + {TX_LCC_SEQUENCER }, + {TX_MIN_ACTIVATETIME }, + {TX_PWM_G6_G7_SYNC_LENGTH }, + {RX_MODE }, + {RX_HSRATE_SERIES }, + {RX_HSGEAR }, + {RX_PWMGEAR }, + {RX_LS_TERMINATED_ENABLE }, + {RX_HS_UNTERMINATED_ENABLE }, + {RX_ENTER_HIBERN8 }, + {RX_BYPASS_8B10B_ENABLE }, + {RX_TERMINATION_FORCE_ENABLE }, +}; + +#endif drivers/phy/phy-qcom-ufs.c new file +25
-0@@ -0,0 +1,777 @@ +/* +* Copyright (c) 2013-2014, Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/time.h> +#include <linux/clk.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +#include <linux/phy/phy-qcom-ufs.h> + +static int __ufs_qcom_phy_init_vreg(struct phy *, struct
ufs_qcom_phy_vreg*,drivers/phy/phy-qcom-ufs.c new file +2
-0+ const char *, bool); +static int ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg*,
drivers/phy/phy-qcom-ufs.c new file +132
-0+ const char *); + +int ufs_qcom_phy_calibrate(struct ufs_qcom_phy *ufs_qcom_phy, +struct ufs_qcom_phy_calibration *tbl_A, +int tbl_size_A, +struct ufs_qcom_phy_calibration *tbl_B, +int tbl_size_B,int rate) +{ +int i; +int ret =0 ; + +if (!tbl_A) { +dev_err (ufs_qcom_phy->dev,"%s: tbl_A is NULL" , __func__); + ret =EINVAL ; + goto out; + } + +for (i =0 ; i < tbl_size_A; i++) +writel_relaxed (tbl_A[i].cfg_value, + ufs_qcom_phy->mmio + tbl_A[i].reg_offset); + +/* +* In case we would like to work in rate B, we need +* to override a registers that were configured in rate A table +* with registers of rate B table. +* table. +*/ +if (rate ==PA_HS_MODE_B ) { +if (!tbl_B) { +dev_err (ufs_qcom_phy->dev,"%s: tbl_B is NULL" , + __func__); + ret =EINVAL ; + goto out; + } + +for (i =0 ; i < tbl_size_B; i++) +writel_relaxed (tbl_B[i].cfg_value, + ufs_qcom_phy->mmio + tbl_B[i].reg_offset); + } + +/* flush buffered writes */ +mb (); + +out: +return ret; +} + +struct phy *ufs_qcom_phy_generic_probe (struct platform_device *pdev, +struct ufs_qcom_phy *common_cfg, +struct phy_ops *ufs_qcom_phy_gen_ops, +struct ufs_qcom_phy_specific_ops *phy_spec_ops) +{ +int err; +struct device *dev = &pdev->dev; +struct phy *generic_phy =NULL ; +struct phy_provider *phy_provider; + + err =ufs_qcom_phy_base_init (pdev, common_cfg); +if (err) { +dev_err (dev,"%s: phy base init failed %d\n" , __func__, err); + goto out; + } + + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) { + err =PTR_ERR (phy_provider); +dev_err (dev,"%s: failed to register phy %d\n" , __func__, err); + goto out; + } + + generic_phy =devm_phy_create (dev,NULL , ufs_qcom_phy_gen_ops,NULL ); +if (IS_ERR (generic_phy)) { + err =PTR_ERR (generic_phy); +dev_err (dev,"%s: failed to create phy %d\n" , __func__, err); + goto out; + } + + common_cfg->phy_spec_ops = phy_spec_ops; + common_cfg->dev = dev; + +out: +return generic_phy; +} + +/* +* This assumes the embedded phy structure inside generic_phy is of type +* struct ufs_qcom_phy. In order to function properly it's crucial +* to keep the embedded struct "struct ufs_qcom_phy common_cfg" +* as the first inside generic_phy. +*/ +struct ufs_qcom_phy *get_ufs_qcom_phy (struct phy *generic_phy) +{ +return (struct ufs_qcom_phy *)phy_get_drvdata (generic_phy); +} + +int ufs_qcom_phy_base_init (struct platform_device *pdev, +struct ufs_qcom_phy *phy_common) +{ +struct device *dev = &pdev->dev; +struct resource *res; +int err =0 ; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"phy_mem" ); +if (!res) { +dev_err (dev,"%s: phy_mem resource not found\n" , __func__); + err = -ENOMEM ; + goto out; + } + + phy_common->mmio =devm_ioremap_resource (dev, res); +if (IS_ERR (phy_common->mmio)) { + err =PTR_ERR (phy_common->mmio); + phy_common->mmio =NULL ; +dev_err (dev,"%s: ioremap for phy_mem resource failed %d\n" , + __func__, err); + goto out; + } + +/* "dev_ref_clk_ctrl_mem" is optional resource */ + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , +"dev_ref_clk_ctrl_mem" ); +if (!res) { +dev_dbg (dev,"%s: dev_ref_clk_ctrl_mem resource not found\n" , + __func__); + goto out; + } + + phy_common->dev_ref_clk_ctrl_mmio =devm_ioremap_resource (dev, res); +if (IS_ERR (phy_common->dev_ref_clk_ctrl_mmio)) { + err =PTR_ERR (phy_common->dev_ref_clk_ctrl_mmio); + phy_common->dev_ref_clk_ctrl_mmio =NULL ; + dev_err(dev, "%s: ioremap for dev_ref_clk_ctrl_mem resource failed%d\n",
drivers/phy/phy-qcom-ufs.c new file +325
-0+ __func__, err); + } + +out: +return err; +} + +static int __ufs_qcom_phy_clk_get (struct phy *phy, +const char *name,struct clk **clk_out,bool err_print) +{ +struct clk *clk; +int err =0 ; +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (phy); +struct device *dev = ufs_qcom_phy->dev; + + clk =devm_clk_get (dev, name); +if (IS_ERR (clk)) { + err =PTR_ERR (clk); +if (err_print) +dev_err (dev,"failed to get %s err %d" , name, err); + }else { + *clk_out = clk; + } + +return err; +} + +int ufs_qcom_phy_clk_get (struct phy *phy, +const char *name,struct clk **clk_out) +{ +return __ufs_qcom_phy_clk_get (phy, name, clk_out, true); +} + +int +ufs_qcom_phy_init_clks (struct phy *generic_phy, +struct ufs_qcom_phy *phy_common) +{ +int err; + + err =ufs_qcom_phy_clk_get (generic_phy,"tx_iface_clk" , + &phy_common->tx_iface_clk); +if (err) + goto out; + + err =ufs_qcom_phy_clk_get (generic_phy,"rx_iface_clk" , + &phy_common->rx_iface_clk); +if (err) + goto out; + + err =ufs_qcom_phy_clk_get (generic_phy,"ref_clk_src" , + &phy_common->ref_clk_src); +if (err) + goto out; + +/* +* "ref_clk_parent" is optional hence don't abort init if it's not +* found. +*/ +__ufs_qcom_phy_clk_get (generic_phy,"ref_clk_parent" , + &phy_common->ref_clk_parent, false); + + err =ufs_qcom_phy_clk_get (generic_phy,"ref_clk" , + &phy_common->ref_clk); + +out: +return err; +} + +int +ufs_qcom_phy_init_vregulators (struct phy *generic_phy, +struct ufs_qcom_phy *phy_common) +{ +int err; + + err =ufs_qcom_phy_init_vreg (generic_phy, &phy_common->vdda_pll, +"vdda-pll" ); +if (err) + goto out; + + err =ufs_qcom_phy_init_vreg (generic_phy, &phy_common->vdda_phy, +"vdda-phy" ); + +if (err) + goto out; + +/* vddp-ref-clk-* properties are optional */ +__ufs_qcom_phy_init_vreg (generic_phy, &phy_common->vddp_ref_clk, +"vddp-ref-clk" , true); +out: +return err; +} + +static int __ufs_qcom_phy_init_vreg (struct phy *phy, +struct ufs_qcom_phy_vreg *vreg,const char *name,bool optional) +{ +int err =0 ; +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (phy); +struct device *dev = ufs_qcom_phy->dev; + +char prop_name[MAX_PROP_NAME ]; + + vreg->name =kstrdup (name,GFP_KERNEL ); +if (!vreg->name) { + err = -ENOMEM ; + goto out; + } + + vreg->reg =devm_regulator_get (dev, name); +if (IS_ERR (vreg->reg)) { + err =PTR_ERR (vreg->reg); + vreg->reg =NULL ; +if (!optional) +dev_err (dev,"failed to get %s, %d\n" , name, err); + goto out; + } + +if (dev->of_node) { +snprintf (prop_name,MAX_PROP_NAME ,"%s-max-microamp" , name); + err =of_property_read_u32 (dev->of_node, + prop_name, &vreg->max_uA); +if (err && err != -EINVAL ) { +dev_err (dev,"%s: failed to read %s\n" , + __func__, prop_name); + goto out; + }else if (err == -EINVAL || !vreg->max_uA) { +if (regulator_count_voltages (vreg->reg) >0 ) { +dev_err (dev,"%s: %s is mandatory\n" , + __func__, prop_name); + goto out; + } + err =0 ; + } +snprintf (prop_name,MAX_PROP_NAME ,"%s-always-on" , name); +if (of_get_property (dev->of_node, prop_name,NULL )) + vreg->is_always_on = true; +else + vreg->is_always_on = false; + } + +if (!strcmp (name,"vdda-pll" )) { + vreg->max_uV =VDDA_PLL_MAX_UV ; + vreg->min_uV =VDDA_PLL_MIN_UV ; + }else if (!strcmp (name,"vdda-phy" )) { + vreg->max_uV =VDDA_PHY_MAX_UV ; + vreg->min_uV =VDDA_PHY_MIN_UV ; + }else if (!strcmp (name,"vddp-ref-clk" )) { + vreg->max_uV =VDDP_REF_CLK_MAX_UV ; + vreg->min_uV =VDDP_REF_CLK_MIN_UV ; + } + +out: +if (err) +kfree (vreg->name); +return err; +} + +static int ufs_qcom_phy_init_vreg (struct phy *phy, +struct ufs_qcom_phy_vreg *vreg,const char *name) +{ +return __ufs_qcom_phy_init_vreg (phy, vreg, name, false); +} + +int ufs_qcom_phy_cfg_vreg (struct phy *phy, +struct ufs_qcom_phy_vreg *vreg,bool on) +{ +int ret =0 ; +struct regulator *reg = vreg->reg; +const char *name = vreg->name; +int min_uV; +int uA_load; +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (phy); +struct device *dev = ufs_qcom_phy->dev; + +BUG_ON (!vreg); + +if (regulator_count_voltages (reg) >0 ) { + min_uV = on ? vreg->min_uV :0 ; + ret =regulator_set_voltage (reg, min_uV, vreg->max_uV); +if (ret) { +dev_err (dev,"%s: %s set voltage failed, err=%d\n" , + __func__, name, ret); + goto out; + } + uA_load = on ? vreg->max_uA :0 ; + ret =regulator_set_optimum_mode (reg, uA_load); +if (ret >=0 ) { +/* +* regulator_set_optimum_mode() returns new regulator +* mode upon success. +*/ + ret =0 ; + }else { +dev_err (dev,"%s: %s set optimum mode(uA_load=%d) failed, err=%d\n" , + __func__, name, uA_load, ret); + goto out; + } + } +out: +return ret; +} + +int ufs_qcom_phy_enable_vreg (struct phy *phy, +struct ufs_qcom_phy_vreg *vreg) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (phy); +struct device *dev = ufs_qcom_phy->dev; +int ret =0 ; + +if (!vreg || vreg->enabled) + goto out; + + ret =ufs_qcom_phy_cfg_vreg (phy, vreg, true); +if (ret) { +dev_err (dev,"%s: ufs_qcom_phy_cfg_vreg() failed, err=%d\n" , + __func__, ret); + goto out; + } + + ret =regulator_enable (vreg->reg); +if (ret) { +dev_err (dev,"%s: enable failed, err=%d\n" , + __func__, ret); + goto out; + } + + vreg->enabled = true; +out: +return ret; +} + +int ufs_qcom_phy_enable_ref_clk (struct phy *generic_phy) +{ +int ret =0 ; +struct ufs_qcom_phy *phy =get_ufs_qcom_phy (generic_phy); + +if (phy->is_ref_clk_enabled) + goto out; + +/* +* reference clock is propagated in a daisy-chained manner from +* source to phy, so ungate them at each stage. +*/ + ret =clk_prepare_enable (phy->ref_clk_src); +if (ret) { +dev_err (phy->dev,"%s: ref_clk_src enable failed %d\n" , + __func__, ret); + goto out; + } + +/* +* "ref_clk_parent" is optional clock hence make sure that clk reference +* is available before trying to enable the clock. +*/ +if (phy->ref_clk_parent) { + ret =clk_prepare_enable (phy->ref_clk_parent); +if (ret) { +dev_err (phy->dev,"%s: ref_clk_parent enable failed %d\n" , + __func__, ret); + goto out_disable_src; + } + } + + ret =clk_prepare_enable (phy->ref_clk); +if (ret) { +dev_err (phy->dev,"%s: ref_clk enable failed %d\n" , + __func__, ret); + goto out_disable_parent; + } + + phy->is_ref_clk_enabled = true; + goto out; + +out_disable_parent: +if (phy->ref_clk_parent) +clk_disable_unprepare (phy->ref_clk_parent); +out_disable_src: +clk_disable_unprepare (phy->ref_clk_src); +out: +return ret; +} + +int ufs_qcom_phy_disable_vreg (struct phy *phy, +struct ufs_qcom_phy_vreg *vreg) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (phy); +struct device *dev = ufs_qcom_phy->dev; +int ret =0 ; + +if (!vreg || !vreg->enabled || vreg->is_always_on) + goto out; + + ret =regulator_disable (vreg->reg); + +if (!ret) { +/* ignore errors on applying disable config */ +ufs_qcom_phy_cfg_vreg (phy, vreg, false); + vreg->enabled = false; + }else { +dev_err (dev,"%s: %s disable failed, err=%d\n" , + __func__, vreg->name, ret); + } +out: +return ret; +} + +void ufs_qcom_phy_disable_ref_clk (struct phy *generic_phy) +{ +struct ufs_qcom_phy *phy =get_ufs_qcom_phy (generic_phy); + +if (phy->is_ref_clk_enabled) { +clk_disable_unprepare (phy->ref_clk); +/* +* "ref_clk_parent" is optional clock hence make sure that clk +* reference is available before trying to disable the clock. +*/ +if (phy->ref_clk_parent) +clk_disable_unprepare (phy->ref_clk_parent); +clk_disable_unprepare (phy->ref_clk_src); + phy->is_ref_clk_enabled = false; + } +} + +#define UFS_REF_CLK_EN (1 << 5) + +static void ufs_qcom_phy_dev_ref_clk_ctrl(struct phy *generic_phy, boolenable)
drivers/phy/phy-qcom-ufs.c new file +64
-0+{ +struct ufs_qcom_phy *phy =get_ufs_qcom_phy (generic_phy); + +if (phy->dev_ref_clk_ctrl_mmio && + (enable ^ phy->is_dev_ref_clk_enabled)) { +u32 temp =readl_relaxed (phy->dev_ref_clk_ctrl_mmio); + +if (enable) + temp |=UFS_REF_CLK_EN ; +else + temp &= ~UFS_REF_CLK_EN ; + +writel_relaxed (temp, phy->dev_ref_clk_ctrl_mmio); +/* ensure that ref_clk is enabled/disabled before we return */ +wmb (); + phy->is_dev_ref_clk_enabled = enable; + } +} + +void ufs_qcom_phy_enable_dev_ref_clk (struct phy *generic_phy) +{ +ufs_qcom_phy_dev_ref_clk_ctrl (generic_phy, true); +} + +void ufs_qcom_phy_disable_dev_ref_clk (struct phy *generic_phy) +{ +ufs_qcom_phy_dev_ref_clk_ctrl (generic_phy, false); +} + +void ufs_qcom_phy_restore_swi_regs (struct phy *generic_phy) +{ +int i; +struct ufs_qcom_phy *phy =get_ufs_qcom_phy (generic_phy); + +for (i =0 ; i < phy->cached_regs_table_size; i++) { +struct ufs_qcom_phy_calibration *table = + (struct ufs_qcom_phy_calibration *)phy->cached_regs; +writel_relaxed (table[i].cfg_value, phy->mmio + + table[i].reg_offset); + } + +/* flush buffered writes */ +mb (); +} + +/* Turn ON M-PHY RMMI interface clocks */ +int ufs_qcom_phy_enable_iface_clk (struct phy *generic_phy) +{ +struct ufs_qcom_phy *phy =get_ufs_qcom_phy (generic_phy); +int ret =0 ; + +if (phy->is_iface_clk_enabled) + goto out; + + ret =clk_prepare_enable (phy->tx_iface_clk); +if (ret) { +dev_err (phy->dev,"%s: tx_iface_clk enable failed %d\n" , + __func__, ret); + goto out; + } + ret =clk_prepare_enable (phy->rx_iface_clk); +if (ret) { +clk_disable_unprepare (phy->tx_iface_clk); + dev_err(phy->dev, "%s: rx_iface_clk enable failed %d. disabling alsotx_iface_clk\n",
drivers/phy/phy-qcom-ufs.c new file +35
-0+ __func__, ret); + goto out; + } + phy->is_iface_clk_enabled = true; + +out: +return ret; +} + +/* Turn OFF M-PHY RMMI interface clocks */ +void ufs_qcom_phy_disable_iface_clk (struct phy *generic_phy) +{ +struct ufs_qcom_phy *phy =get_ufs_qcom_phy (generic_phy); + +if (phy->is_iface_clk_enabled) { +clk_disable_unprepare (phy->tx_iface_clk); +clk_disable_unprepare (phy->rx_iface_clk); + phy->is_iface_clk_enabled = false; + } +} + +int ufs_qcom_phy_is_cfg_restore_quirk_enabled (struct phy *phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (phy); + +return ufs_qcom_phy->quirks &UFS_QCOM_PHY_QUIRK_CFG_RESTORE ; +} + +int ufs_qcom_phy_start_serdes (struct phy *generic_phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int ret =0 ; + +if (!ufs_qcom_phy->phy_spec_ops->start_serdes) { + dev_err(ufs_qcom_phy->dev, "%s: start_serdes() callback is notsupported\n",
drivers/phy/phy-qcom-ufs.c new file +10
-0+ __func__); + ret = -ENOTSUPP ; + }else { + ufs_qcom_phy->phy_spec_ops->start_serdes (ufs_qcom_phy); + } + +return ret; +} + +int ufs_qcom_phy_set_tx_lane_enable(struct phy *generic_phy, u32
tx_lanes)drivers/phy/phy-qcom-ufs.c new file +6
-0+{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int ret =0 ; + +if (!ufs_qcom_phy->phy_spec_ops->set_tx_lane_enable) { + dev_err(ufs_qcom_phy->dev, "%s: set_tx_lane_enable() callback is notsupported\n",
drivers/phy/phy-qcom-ufs.c new file +27
-0+ __func__); + ret = -ENOTSUPP ; + }else { + ufs_qcom_phy->phy_spec_ops->set_tx_lane_enable (ufs_qcom_phy, + tx_lanes); + } + +return ret; +} + +void ufs_qcom_phy_save_controller_version (struct phy *generic_phy, +u8 major,u16 minor,u16 step) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); + + ufs_qcom_phy->host_ctrl_rev_major = major; + ufs_qcom_phy->host_ctrl_rev_minor = minor; + ufs_qcom_phy->host_ctrl_rev_step = step; +} + +int ufs_qcom_phy_calibrate_phy (struct phy *generic_phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int ret =0 ; + +if (!ufs_qcom_phy->phy_spec_ops->calibrate_phy) { + dev_err(ufs_qcom_phy->dev, "%s: calibrate_phy() callback is notsupported\n",
drivers/phy/phy-qcom-ufs.c new file +40
-0+ __func__); + ret = -ENOTSUPP ; + }else { + ret = ufs_qcom_phy->phy_spec_ops-> +calibrate_phy (ufs_qcom_phy); +if (ret) +dev_err (ufs_qcom_phy->dev,"%s: calibrate_phy() failed %d\n" , + __func__, ret); + } + +return ret; +} + +int ufs_qcom_phy_remove (struct phy *generic_phy, +struct ufs_qcom_phy *ufs_qcom_phy) +{ +phy_power_off (generic_phy); + +kfree (ufs_qcom_phy->vdda_pll.name); +kfree (ufs_qcom_phy->vdda_phy.name); + +return 0 ; +} + +int ufs_qcom_phy_exit (struct phy *generic_phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); + +if (ufs_qcom_phy->is_powered_on) +phy_power_off (generic_phy); + +return 0 ; +} + +int ufs_qcom_phy_is_pcs_ready (struct phy *generic_phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); + +if (!ufs_qcom_phy->phy_spec_ops->is_physical_coding_sublayer_ready) { + dev_err(ufs_qcom_phy->dev, "%s: is_physical_coding_sublayer_ready()callback is not supported\n",
drivers/phy/phy-qcom-ufs.c new file +15
-0+ __func__); +return -ENOTSUPP ; + } + +return ufs_qcom_phy->phy_spec_ops-> +is_physical_coding_sublayer_ready (ufs_qcom_phy); +} + +int ufs_qcom_phy_save_configuration (struct phy *generic_phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int ret =0 ; + +if (!ufs_qcom_phy->phy_spec_ops->save_configuration) { + dev_err(ufs_qcom_phy->dev, "%s: save_configuration() callback is notsupported\n",
drivers/phy/phy-qcom-ufs.c new file +16
-0+ __func__); + ret = -ENOTSUPP ; + }else { + ufs_qcom_phy->phy_spec_ops->save_configuration (ufs_qcom_phy); + } + +return ret; +} + +int ufs_qcom_phy_restore_configuration (struct phy *generic_phy) +{ +struct ufs_qcom_phy *ufs_qcom_phy =get_ufs_qcom_phy (generic_phy); +int ret =0 ; + +if (!ufs_qcom_phy->phy_spec_ops->restore_configuration) { + dev_err(ufs_qcom_phy->dev, "%s: restore_configuration() callback is notsupported\n",
drivers/phy/phy-qcom-ufs.c new file +80
-0+ __func__); + ret = -ENOTSUPP ; + }else { + ufs_qcom_phy->phy_spec_ops->restore_configuration (ufs_qcom_phy); + } + +return ret; +} + +int ufs_qcom_phy_power_on (struct phy *generic_phy) +{ +struct ufs_qcom_phy *phy_common =get_ufs_qcom_phy (generic_phy); +struct device *dev = phy_common->dev; +int err; + + err =ufs_qcom_phy_enable_vreg (generic_phy, &phy_common->vdda_phy); +if (err) { +dev_err (dev,"%s enable vdda_phy failed, err=%d\n" , + __func__, err); + goto out; + } + + phy_common->phy_spec_ops->power_control (phy_common, true); + +/* vdda_pll also enables ref clock LDOs so enable it first */ + err =ufs_qcom_phy_enable_vreg (generic_phy, &phy_common->vdda_pll); +if (err) { +dev_err (dev,"%s enable vdda_pll failed, err=%d\n" , + __func__, err); + goto out_disable_phy; + } + + err =ufs_qcom_phy_enable_ref_clk (generic_phy); +if (err) { +dev_err (dev,"%s enable phy ref clock failed, err=%d\n" , + __func__, err); + goto out_disable_pll; + } + +/* enable device PHY ref_clk pad rail */ +if (phy_common->vddp_ref_clk.reg) { + err =ufs_qcom_phy_enable_vreg (generic_phy, + &phy_common->vddp_ref_clk); +if (err) { +dev_err (dev,"%s enable vddp_ref_clk failed, err=%d\n" , + __func__, err); + goto out_disable_ref_clk; + } + } + + phy_common->is_powered_on = true; + goto out; + +out_disable_ref_clk: +ufs_qcom_phy_disable_ref_clk (generic_phy); +out_disable_pll: +ufs_qcom_phy_disable_vreg (generic_phy, &phy_common->vdda_pll); +out_disable_phy: +ufs_qcom_phy_disable_vreg (generic_phy, &phy_common->vdda_phy); +out: +return err; +} + +int ufs_qcom_phy_power_off (struct phy *generic_phy) +{ +struct ufs_qcom_phy *phy_common =get_ufs_qcom_phy (generic_phy); + + phy_common->phy_spec_ops->power_control (phy_common, false); + +if (phy_common->vddp_ref_clk.reg) +ufs_qcom_phy_disable_vreg (generic_phy, + &phy_common->vddp_ref_clk); +ufs_qcom_phy_disable_ref_clk (generic_phy); + +ufs_qcom_phy_disable_vreg (generic_phy, &phy_common->vdda_pll); +ufs_qcom_phy_disable_vreg (generic_phy, &phy_common->vdda_phy); + phy_common->is_powered_on = false; + +return 0 ; +}drivers/scsi/ufs/Kconfig +24
-0@@ -70,3 +70,27 @@ config SCSI_UFSHCD_PLATFORM If you have a controller with this interface, say Y or M here. If unsure, say N. + +config SCSI_UFS_QCOM + bool "QCOM specific hooks to UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM && ARCH_MSM + help + This selects the QCOM specific additions to UFSHCD platform driver. + UFS host on QCOM needs some vendor specific configuration before + accessing the hardware which includes PHY configuration and vendor + specific registers. + + Select this if you have UFS controller on QCOM chipset. + If unsure, say N. + +config SCSI_UFS_QCOM_ICE + bool "QCOM specific hooks to Inline Crypto Engine for UFS driver" + depends on SCSI_UFS_QCOM && CRYPTO_DEV_QCOM_ICE + help + This selects the QCOM specific additions to support Inline Crypto + Engine (ICE). + ICE accelerates the crypto operations and maintains the high UFS + performance. + + Select this if you have ICE supported for UFS on QCOM chipset. + If unsure, say N.drivers/scsi/ufs/Makefile +2
-0@@ -1,4 +1,6 @@ # UFSHCD makefile +obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o +obj-$(CONFIG_SCSI_UFS_QCOM_ICE) += ufs-qcom-ice.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.odrivers/scsi/ufs/ufs-qcom-ice.c new file +42
-0@@ -0,0 +1,522 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/io.h> +#include <linux/of.h> +#include <linux/async.h> +#include <linux/blkdev.h> +#include <linux/scsi/ufs/ufshcd.h> +#include <crypto/ice.h> + +#include "ufs-qcom-ice.h" + + +#define UFS_QCOM_CRYPTO_LABEL "ufs-qcom-crypto" +/* Timeout waiting for ICE initialization, that requires TZ access */ +#define UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS 500 + +static void ufs_qcom_ice_success_cb (void *host_ctrl, +enum ice_event_completion evt) +{ +struct ufs_qcom_host *qcom_host = (struct ufs_qcom_host *)host_ctrl; + +if (qcom_host->ice.state ==UFS_QCOM_ICE_STATE_DISABLED && + evt ==ICE_INIT_COMPLETION ) + qcom_host->ice.state =UFS_QCOM_ICE_STATE_ACTIVE ; +else if (qcom_host->ice.state ==UFS_QCOM_ICE_STATE_SUSPENDED && + evt ==ICE_RESUME_COMPLETION ) + qcom_host->ice.state =UFS_QCOM_ICE_STATE_ACTIVE ; + +complete (&qcom_host->ice.async_done); +} + +static void ufs_qcom_ice_error_cb(void *host_ctrl, enum ice_error_codeevt)
drivers/scsi/ufs/ufs-qcom-ice.c new file +13
-0+{ +struct ufs_qcom_host *qcom_host = (struct ufs_qcom_host *)host_ctrl; + +dev_err (qcom_host->hba->dev,"%s: Error in ice operation %d" , + __func__, evt); + +if (qcom_host->ice.state ==UFS_QCOM_ICE_STATE_ACTIVE ) + qcom_host->ice.state =UFS_QCOM_ICE_STATE_DISABLED ; + +complete (&qcom_host->ice.async_done); +} + +static struct platform_device *ufs_qcom_ice_get_pdevice(struct device
*ufs_dev)drivers/scsi/ufs/ufs-qcom-ice.c new file +19
-0+{ +struct device_node *node; +struct platform_device *ice_pdev =NULL ; + + node =of_parse_phandle (ufs_dev->of_node,UFS_QCOM_CRYPTO_LABEL ,0 ); + +if (!node) { +dev_err (ufs_dev,"%s: ufs-qcom-crypto property not specified\n" , + __func__); + goto out; + } + + ice_pdev =qcom_ice_get_pdevice (node); +out: +return ice_pdev; +} + +static +struct qcom_ice_variant_ops *ufs_qcom_ice_get_vops(struct device
*ufs_dev)drivers/scsi/ufs/ufs-qcom-ice.c new file +24
-0+{ +struct qcom_ice_variant_ops *ice_vops =NULL ; +struct device_node *node; + + node =of_parse_phandle (ufs_dev->of_node,UFS_QCOM_CRYPTO_LABEL ,0 ); + +if (!node) { +dev_err (ufs_dev,"%s: ufs-qcom-crypto property not specified\n" , + __func__); + goto out; + } + + ice_vops =qcom_ice_get_variant_ops (node); + +if (!ice_vops) +dev_err (ufs_dev,"%s: invalid ice_vops\n" , __func__); + +of_node_put (node); +out: +return ice_vops; +} + +/** +* ufs_qcom_ice_get_dev() - sets pointers to ICE data structs in UFS QCom host
+ * @qcom_host: Pointer to a UFS QCom internal host structure.
+ *
+ * Sets ICE platform device pointer and ICE vops structure
+ * corresponding to the current UFS device.
+ *
+ * Return:-EINVALin-case of invalid input parameters:
+ *qcom_host,qcom_host->hbaorqcom_host->hba->dev
+ *-ENODEVin-case ICE device is not required
+ * -EPROBE_DEFER in-case ICE is required and hasn't been probed
yet
+ * 0 otherwise
+ */drivers/scsi/ufs/ufs-qcom-ice.c new file +7
-0+int ufs_qcom_ice_get_dev (struct ufs_qcom_host *qcom_host) +{ +struct device *ufs_dev; +int err =0 ; + +if (!qcom_host || !qcom_host->hba || !qcom_host->hba->dev) { + pr_err("%s: invalid qcom_host %p or qcom_host->hba orqcom_host->hba->dev\n",
drivers/scsi/ufs/ufs-qcom-ice.c new file +97
-0+ __func__, qcom_host); + err = -EINVAL ; + goto out; + } + + ufs_dev = qcom_host->hba->dev; + + qcom_host->ice.vops =ufs_qcom_ice_get_vops (ufs_dev); + qcom_host->ice.pdev =ufs_qcom_ice_get_pdevice (ufs_dev); + +if (qcom_host->ice.pdev ==ERR_PTR (-EPROBE_DEFER )) { +dev_err (ufs_dev,"%s: ICE device not probed yet\n" , + __func__); + qcom_host->ice.pdev =NULL ; + qcom_host->ice.vops =NULL ; + err = -EPROBE_DEFER ; + goto out; + } + +if (!qcom_host->ice.pdev || !qcom_host->ice.vops) { +dev_err (ufs_dev,"%s: invalid platform device %p or vops %p\n" , + __func__, qcom_host->ice.pdev, qcom_host->ice.vops); + qcom_host->ice.pdev =NULL ; + qcom_host->ice.vops =NULL ; + err = -ENODEV ; + goto out; + } + + qcom_host->ice.state =UFS_QCOM_ICE_STATE_DISABLED ; + +out: +return err; + +} + +/** +* ufs_qcom_ice_init() - initializes the ICE-UFS interface and ICE device +* @qcom_host: Pointer to a UFS QCom internal host structure. +* qcom_host, qcom_host->hba and qcom_host->hba->dev should all +* be valid pointers. +* +* Return: -EINVAL in-case of an error +* 0 otherwise +*/ +int ufs_qcom_ice_init (struct ufs_qcom_host *qcom_host) +{ +struct device *ufs_dev = qcom_host->hba->dev; +int err = -EINVAL ; + +init_completion (&qcom_host->ice.async_done); + err = qcom_host->ice.vops->init (qcom_host->ice.pdev, + qcom_host, + ufs_qcom_ice_success_cb, + ufs_qcom_ice_error_cb); +if (err) { +dev_err (ufs_dev,"%s: ice init failed. err = %d\n" , + __func__, err); + goto out; + } + +if (!wait_for_completion_timeout (&qcom_host->ice.async_done, +msecs_to_jiffies (UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS ))) { +dev_err (qcom_host->hba->dev, +"%s: error. got timeout after %d ms\n" , + __func__,UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS ); + err = -ETIMEDOUT ; + goto out; + } + +if (qcom_host->ice.state !=UFS_QCOM_ICE_STATE_ACTIVE ) { +dev_err (qcom_host->hba->dev, +"%s: error. ice.state (%d) is not in active state\n" , + __func__, qcom_host->ice.state); + err = -EINVAL ; + } + +out: +return err; +} + +static inline bool ufs_qcom_is_data_cmd (char cmd_op,bool is_write) +{ +if (is_write) { +if (cmd_op ==WRITE_6 || cmd_op ==WRITE_10 || + cmd_op ==WRITE_16 ) +return true; + }else { +if (cmd_op ==READ_6 || cmd_op ==READ_10 || + cmd_op ==READ_16 ) +return true; + } + +return false; +} + +/** +* ufs_qcom_ice_cfg() - configures UFS's ICE registers for an ICE transaction
+ * @qcom_host: Pointer to a UFS QCom internal host structure.
+ *qcom_host,qcom_host->hbaandqcom_host->hba->devshould all
+ * be valid pointers.
+ * @cmd: Pointer to a valid scsi command.cmd->requestshould also be
+ * a valid pointer.
+ *
+ * Return:-EINVALin-case of an error
+ * 0 otherwise
+ */
+intufs_qcom_ice_cfg(struct ufs_qcom_host *qcom_host, struct scsi_cmnd *cmd)drivers/scsi/ufs/ufs-qcom-ice.c new file +147
-0+{ +struct device *dev = qcom_host->hba->dev; +int err =0 ; +struct ice_data_setting ice_set; +unsigned int slot =0 ; +sector_t lba =0 ; +unsigned int ctrl_info_2_val =0 ; +unsigned int bypass =0 ; +struct request *req; +char cmd_op; + +if (!qcom_host->ice.pdev || !qcom_host->ice.vops) { +dev_dbg (dev,"%s: ice device is not enabled\n" , __func__); + goto out; + } + +if (qcom_host->ice.state !=UFS_QCOM_ICE_STATE_ACTIVE ) { +dev_err (dev,"%s: ice state (%d) is not active\n" , + __func__, qcom_host->ice.state); +return -EINVAL ; + } + + req = cmd->request; +if (req->bio) + lba = req->bio->bi_sector; + + slot = req->tag; +if (slot <0 || slot > qcom_host->hba->nutrs) { +dev_err (dev,"%s: slot (%d) is out of boundaries (0...%d)\n" , + __func__, slot, qcom_host->hba->nutrs); +return -EINVAL ; + } + +memset (&ice_set,sizeof (ice_set),0 ); +if (qcom_host->ice.vops->config) { + err = qcom_host->ice.vops->config (qcom_host->ice.pdev, + req, &ice_set); + +if (err) { +dev_err (dev,"%s: error in ice_vops->config %d\n" , + __func__, err); + goto out; + } + } + + cmd_op = cmd->cmnd[0 ]; + +#define UFS_QCOM_DIR_WRITE true +#define UFS_QCOM_DIR_READ false +/* if non data command, bypass shall be enabled */ +if (!ufs_qcom_is_data_cmd (cmd_op,UFS_QCOM_DIR_WRITE ) && + !ufs_qcom_is_data_cmd (cmd_op,UFS_QCOM_DIR_READ )) + bypass =UFS_QCOM_ICE_ENABLE_BYPASS ; +/* if writing data command */ +else if (ufs_qcom_is_data_cmd (cmd_op,UFS_QCOM_DIR_WRITE )) + bypass = ice_set.encr_bypass ?UFS_QCOM_ICE_ENABLE_BYPASS : +UFS_QCOM_ICE_DISABLE_BYPASS ; +/* if reading data command */ +else if (ufs_qcom_is_data_cmd (cmd_op,UFS_QCOM_DIR_READ )) + bypass = ice_set.decr_bypass ?UFS_QCOM_ICE_ENABLE_BYPASS : +UFS_QCOM_ICE_DISABLE_BYPASS ; + +/* Configure ICE index */ + ctrl_info_2_val = + (ice_set.crypto_data.key_index & +MASK_UFS_QCOM_ICE_CTRL_INFO_2_KEY_INDEX ) + <<OFFSET_UFS_QCOM_ICE_CTRL_INFO_2_KEY_INDEX ; + +/* Configure data unit size of transfer request */ + ctrl_info_2_val |= + (UFS_QCOM_ICE_TR_DATA_UNIT_4_KB & +MASK_UFS_QCOM_ICE_CTRL_INFO_2_CDU ) + <<OFFSET_UFS_QCOM_ICE_CTRL_INFO_2_CDU ; + +/* Configure ICE bypass mode */ + ctrl_info_2_val |= + (bypass &MASK_UFS_QCOM_ICE_CTRL_INFO_2_BYPASS ) + <<OFFSET_UFS_QCOM_ICE_CTRL_INFO_2_BYPASS ; + +ufshcd_writel (qcom_host->hba, lba, + (REG_UFS_QCOM_ICE_CTRL_INFO_1_n +8 * slot)); + +ufshcd_writel (qcom_host->hba, ctrl_info_2_val, + (REG_UFS_QCOM_ICE_CTRL_INFO_2_n +8 * slot)); + +/* +* Ensure UFS-ICE registers are being configured +* before next operation, otherwise UFS Host Controller might +* set get errors +*/ +mb (); +out: +return err; +} + +/** +* ufs_qcom_ice_reset() - resets UFS-ICE interface and ICE device +* @qcom_host: Pointer to a UFS QCom internal host structure. +* qcom_host, qcom_host->hba and qcom_host->hba->dev should all +* be valid pointers. +* +* Return: -EINVAL in-case of an error +* 0 otherwise +*/ +int ufs_qcom_ice_reset (struct ufs_qcom_host *qcom_host) +{ +struct device *dev = qcom_host->hba->dev; +int err =0 ; + +if (!qcom_host->ice.pdev) { +dev_dbg (dev,"%s: ice device is not enabled\n" , __func__); + goto out; + } + +if (!qcom_host->ice.vops) { +dev_err (dev,"%s: invalid ice_vops\n" , __func__); +return -EINVAL ; + } + +if (qcom_host->ice.state !=UFS_QCOM_ICE_STATE_ACTIVE ) + goto out; + +init_completion (&qcom_host->ice.async_done); + +if (qcom_host->ice.vops->reset) { + err = qcom_host->ice.vops->reset (qcom_host->ice.pdev); +if (err) { +dev_err (dev,"%s: ice_vops->reset failed. err %d\n" , + __func__, err); + goto out; + } + } + +if (!wait_for_completion_timeout (&qcom_host->ice.async_done, +msecs_to_jiffies (UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS ))) { +dev_err (dev, +"%s: error. got timeout after %d ms\n" , + __func__,UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS ); + err = -ETIMEDOUT ; + } + +out: +return err; +} + +/** +* ufs_qcom_ice_resume() - resumes UFS-ICE interface and ICE device from power
+ * collapse
+ * @qcom_host: Pointer to a UFS QCom internal host structure.
+ *qcom_host,qcom_host->hbaandqcom_host->hba->devshould all
+ * be valid pointers.
+ *
+ * Return:-EINVALin-case of an error
+ * 0 otherwise
+ */drivers/scsi/ufs/ufs-qcom-ice.c new file +101
-0+int ufs_qcom_ice_resume (struct ufs_qcom_host *qcom_host) +{ +struct device *dev = qcom_host->hba->dev; +int err =0 ; + +if (!qcom_host->ice.pdev) { +dev_dbg (dev,"%s: ice device is not enabled\n" , __func__); + goto out; + } + +if (qcom_host->ice.state != +UFS_QCOM_ICE_STATE_SUSPENDED ) { + goto out; + } + +if (!qcom_host->ice.vops) { +dev_err (dev,"%s: invalid ice_vops\n" , __func__); +return -EINVAL ; + } + +init_completion (&qcom_host->ice.async_done); + +if (qcom_host->ice.vops->resume) { + err = qcom_host->ice.vops->resume (qcom_host->ice.pdev); +if (err) { +dev_err (dev,"%s: ice_vops->resume failed. err %d\n" , + __func__, err); +return -EINVAL ; + } + } + +if (!wait_for_completion_timeout (&qcom_host->ice.async_done, +msecs_to_jiffies (UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS ))) { +dev_err (dev, +"%s: error. got timeout after %d ms\n" , + __func__,UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS ); + err = -ETIMEDOUT ; + goto out; + } + +if (qcom_host->ice.state !=UFS_QCOM_ICE_STATE_ACTIVE ) + err = -EINVAL ; +out: +return err; +} + +/** +* ufs_qcom_ice_suspend() - suspends UFS-ICE interface and ICE device +* @qcom_host: Pointer to a UFS QCom internal host structure. +* qcom_host, qcom_host->hba and qcom_host->hba->dev should all +* be valid pointers. +* +* Return: -EINVAL in-case of an error +* 0 otherwise +*/ +int ufs_qcom_ice_suspend (struct ufs_qcom_host *qcom_host) +{ +struct device *dev = qcom_host->hba->dev; +int err =0 ; + +if (!qcom_host->ice.pdev) { +dev_dbg (dev,"%s: ice device is not enabled\n" , __func__); + goto out; + } + +if (qcom_host->ice.vops->suspend) { + err = qcom_host->ice.vops->suspend (qcom_host->ice.pdev); +if (err) { +dev_err (qcom_host->hba->dev, +"%s: ice_vops->suspend failed. err %d\n" , + __func__, err); +return -EINVAL ; + } + } + +if (qcom_host->ice.state ==UFS_QCOM_ICE_STATE_ACTIVE ) { + qcom_host->ice.state =UFS_QCOM_ICE_STATE_SUSPENDED ; + }else if (qcom_host->ice.state ==UFS_QCOM_ICE_STATE_DISABLED ) { +dev_err (qcom_host->hba->dev, +"%s: ice state is invalid: disabled\n" , + __func__); + err = -EINVAL ; + } + +out: +return err; +} + +/** +* ufs_qcom_ice_get_status() - returns the status of an ICE transaction +* @qcom_host: Pointer to a UFS QCom internal host structure. +* qcom_host, qcom_host->hba and qcom_host->hba->dev should all +* be valid pointers. +* @ice_status: Pointer to a valid output parameter. +* < 0 in case of ICE transaction failure. +* 0 otherwise. +* +* Return: -EINVAL in-case of an error +* 0 otherwise +*/ +int ufs_qcom_ice_get_status(struct ufs_qcom_host *qcom_host, int
*ice_status)drivers/scsi/ufs/ufs-qcom-ice.c new file +43
-0+{ +struct device *dev =NULL ; +int err =0 ; +int stat = -EINVAL ; + + ice_status =0 ; + + dev = qcom_host->hba->dev; +if (!dev) { + err = -EINVAL ; + goto out; + } + +if (!qcom_host->ice.pdev) { +dev_dbg (dev,"%s: ice device is not enabled\n" , __func__); + goto out; + } + +if (qcom_host->ice.state !=UFS_QCOM_ICE_STATE_ACTIVE ) { + err = -EINVAL ; + goto out; + } + +if (!qcom_host->ice.vops) { +dev_err (dev,"%s: invalid ice_vops\n" , __func__); +return -EINVAL ; + } + +if (qcom_host->ice.vops->status) { + stat = qcom_host->ice.vops->status (qcom_host->ice.pdev); +if (stat <0 ) { +dev_err (dev,"%s: ice_vops->status failed. stat %d\n" , + __func__, stat); + err = -EINVAL ; + goto out; + } + + *ice_status = stat; + } + +out: +return err; +}drivers/scsi/ufs/ufs-qcom-ice.h new file +71
-0@@ -0,0 +1,113 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#ifndef _UFS_QCOM_ICE_H_ +#define _UFS_QCOM_ICE_H_ + +#include <scsi/scsi_cmnd.h> + +#include <linux/scsi/ufs/ufs-qcom.h> + +/* +* UFS host controller ICE registers. There are n [0..31] +* of each of these registers +*/ +enum { + REG_UFS_QCOM_ICE_CTRL_INFO_1_n =0x2204 , + REG_UFS_QCOM_ICE_CTRL_INFO_2_n =0x2208 , +}; + +/* UFS QCOM ICE CTRL Info 2 register offset */ +enum { +OFFSET_UFS_QCOM_ICE_CTRL_INFO_2_BYPASS =0 , +OFFSET_UFS_QCOM_ICE_CTRL_INFO_2_KEY_INDEX =0x1 , +OFFSET_UFS_QCOM_ICE_CTRL_INFO_2_CDU =0x6 , +}; + +/* UFS QCOM ICE CTRL Info 2 register masks */ +enum { +MASK_UFS_QCOM_ICE_CTRL_INFO_2_BYPASS =0x1 , +MASK_UFS_QCOM_ICE_CTRL_INFO_2_KEY_INDEX =0x1F , +MASK_UFS_QCOM_ICE_CTRL_INFO_2_CDU =0x8 , +}; + +/* UFS QCOM ICE encryption/decryption bypass state */ +enum { +UFS_QCOM_ICE_DISABLE_BYPASS =0 , +UFS_QCOM_ICE_ENABLE_BYPASS =1 , +}; + +/* UFS QCOM ICE Crypto Data Unit of target DUN of Transfer Request */ +enum { +UFS_QCOM_ICE_TR_DATA_UNIT_512_B =0 , +UFS_QCOM_ICE_TR_DATA_UNIT_1_KB =1 , +UFS_QCOM_ICE_TR_DATA_UNIT_2_KB =2 , +UFS_QCOM_ICE_TR_DATA_UNIT_4_KB =3 , +UFS_QCOM_ICE_TR_DATA_UNIT_8_KB =4 , +UFS_QCOM_ICE_TR_DATA_UNIT_16_KB =5 , +UFS_QCOM_ICE_TR_DATA_UNIT_32_KB =6 , +}; + +/* UFS QCOM ICE internal state */ +enum { +UFS_QCOM_ICE_STATE_DISABLED =0 , +UFS_QCOM_ICE_STATE_ACTIVE =1 , +UFS_QCOM_ICE_STATE_SUSPENDED =2 , +}; + +#ifdef CONFIG_SCSI_UFS_QCOM_ICE +int ufs_qcom_ice_get_dev (struct ufs_qcom_host *qcom_host); +int ufs_qcom_ice_init (struct ufs_qcom_host *qcom_host); +int ufs_qcom_ice_cfg(struct ufs_qcom_host *qcom_host, struct scsi_cmnd*cmd);
drivers/scsi/ufs/ufs-qcom-ice.h new file +4
-0+int ufs_qcom_ice_reset (struct ufs_qcom_host *qcom_host); +int ufs_qcom_ice_resume (struct ufs_qcom_host *qcom_host); +int ufs_qcom_ice_suspend (struct ufs_qcom_host *qcom_host); +int ufs_qcom_ice_get_status(struct ufs_qcom_host *qcom_host, int
*ice_status);drivers/scsi/ufs/ufs-qcom-ice.h new file +38
-0+#else +inline int ufs_qcom_ice_get_dev (struct ufs_qcom_host *qcom_host) +{ +if (qcom_host) { + qcom_host->ice.pdev =NULL ; + qcom_host->ice.vops =NULL ; + } +return -ENODEV ; +} +inline int ufs_qcom_ice_init (struct ufs_qcom_host *qcom_host) +{ +return 0 ;Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*result);
drivers/scsi/ufs/ufs-qcom.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
restore_sec_cfg);drivers/scsi/ufs/ufs-qcom.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*tx_lanes)drivers/scsi/ufs/ufs-qcom.c new file +112
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
host->lanes_per_direction);drivers/scsi/ufs/ufs-qcom.c new file +99
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
%d\n",
drivers/scsi/ufs/ufs-qcom.c new file +22
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
= %d\n",
drivers/scsi/ufs/ufs-qcom.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
CGCs.
+ * Hardware CGCs disable the clock to inactivate UTP sub-modules not involved
+ * in a specific operation, UTP controller CGCs are by default disabled and
+ * this function enables them (after every UFS link startup) to save some power
+ * leakage.
+ */drivers/scsi/ufs/ufs-qcom.c new file +269
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
%d\n",
drivers/scsi/ufs/ufs-qcom.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
err = %d\n",
drivers/scsi/ufs/ufs-qcom.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
= %d\n",
drivers/scsi/ufs/ufs-qcom.c new file +20
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
task_tag)drivers/scsi/ufs/ufs-qcom.c new file +79
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*qcom_param,drivers/scsi/ufs/ufs-qcom.c new file +26
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
but requested power is HS)\n",
drivers/scsi/ufs/ufs-qcom.c new file +139
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
%d\n",
drivers/scsi/ufs/ufs-qcom.c new file +19
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
quirks
+ * @hba: host controller instance
+ *
+ * QCOM UFS host controller might have some non standard behaviours (quirks)
+ * than what is specified by UFSHCI specification. Advertise all such
+ * quirks to standard UFS host controller driver so standard takes them into
+ * account.
+ */drivers/scsi/ufs/ufs-qcom.c new file +52
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*result)
drivers/scsi/ufs/ufs-qcom.c new file +218
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
of UFS
+ * register space after coming out of UFS host core power collapse.
+ *
+ * @hba: host controller instance
+ * @restore_sec_cfg: Set "true" if secure configuration needs to be restored
+ * and set "false" when secure configuration is lost.
+ */
+static intufs_qcom_update_sec_cfg(struct ufs_hba *hba, bool restore_sec_cfg)drivers/scsi/ufs/ufs-qcom.c new file +40
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
ret %d
scm_ret%d\n",drivers/scsi/ufs/ufs-qcom.c new file +28
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
/**
drivers/scsi/ufs/ufshcd.c +8
-1Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
out:
drivers/scsi/ufs/ufshcd.c +16
-2Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
requests.
+ * @hba: per adapter instance
+ * @result: error result to inform scsi layer about
+ */
+voidufshcd_abort_outstanding_transfer_requests(struct ufs_hba *hba, int result)drivers/scsi/ufs/ufshcd.c +35
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
drivers/scsi/ufs/ufshcd.c +5
-1Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
drivers/scsi/ufs/ufshcd.c +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
UIC_LINK_OFF_STATE)drivers/scsi/ufs/ufshcd.h deleted +0
-5Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
UIC_LINK_OFF_STATE)drivers/scsi/ufs/ufshcd.h deleted +0
-38Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
aggregation)
- */drivers/scsi/ufs/ufshcd.h deleted +0
-31Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
commands
- * @type: device management command type - Query, NOP OUT
- * @lock: lock to allow one command at a time
- * @complete: internal commands completion
- * @tag_wq: wait queue until free command slot is available
- */drivers/scsi/ufs/ufshcd.h deleted +0
-55Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
allow
- * variant specific Uni-Pro initialization.
- * @link_startup_notify: called before and after Link startup is carried out
- * to allow variant specific Uni-Pro
initialization.
- * @pwr_change_notify: called before and after a power mode change
- * is carried out to allow vendor spesific capabilities
- * to be set.
- * @suspend: called during host controller PM callback
- * @resume: called during host controller PM callback
- */drivers/scsi/ufs/ufshcd.h deleted +0
-36Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
for
- * completion before gating clocks.
- */drivers/scsi/ufs/ufshcd.h deleted +0
-19Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
during
- * initialization
- * @icc_level: icc level which was read during initialization
- */drivers/scsi/ufs/ufshcd.h deleted +0
-39Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
initialization
- * @init_prefetch_data: data pre-fetched during initialization
- * @eh_work: Worker to handle UFS errors that require s/w attention
- * @eeh_work: Worker to handle exception events
- * @errors: HBA errors
- * @uic_error: UFS interconnect layer error status
- * @saved_err: sticky error mask
- * @saved_uic_err: sticky UIC error mask
- * @dev_cmd: ufs device management command information
- * @auto_bkops_enabled: to track whether bkops is enabled in device
- * @vreg_info: UFS device voltage regulator information
- * @clk_list_head: UFS host controller clocks list node head
- * @pwr_info: holds current power mode
- * @max_pwr_info: keeps the device max valid pwm
- */drivers/scsi/ufs/ufshcd.h deleted +0
-117Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*hba)
drivers/scsi/ufs/ufshcd.h deleted +0
-17Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
u32 reg)
drivers/scsi/ufs/ufshcd.h deleted +0
-67Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
attr_sel,drivers/scsi/ufs/ufshcd.h deleted +0
-21Lines of this file are not shown. View the raw message.
include/linux/phy/phy-qcom-ufs.h new file +138
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
have a
+ * specific implementation per phy. Each UFS phy, should implement
+ * those functions according to its spec and requirements
+ * @calibrate_phy: pointer to a function that calibrate the phy
+ * @start_serdes: pointer to a function that starts the serdes
+ * @save_configuration: pointer to a function that saves phy
+ * configuration
+ * @is_physical_coding_sublayer_ready: pointer to a function that
+ * checks pcs readiness
+ * @set_tx_lane_enable: pointer to a function that enable tx lanes
+ * @power_control: pointer to a function that controls analog rail of phy
+ * and writes toQSERDES_RX_SIGDET_CNTRLattribute
+ */include/linux/phy/phy-qcom-ufs.h new file +31
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
tx_lanes);include/linux/phy/phy-qcom-ufs.h new file +24
-0Lines of this file are not shown. View the raw message.
include/linux/scsi/ufs/ufs-qcom.h new file +159
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
nature
+ * @pdev: pointer to the proper ICE platform device
+ * @state: UFS-ICE interface's internal state (see
+ *ufs-qcom-ice.hfor possible internal states)
+ * @quirks: UFS-ICE interface related quirks
+ * @crypto_engine_err: crypto engine errors
+ */include/linux/scsi/ufs/ufs-qcom.h new file +45
-0Lines of this file are not shown. View the raw message.
include/linux/scsi/ufs/ufs.h new file +491
-0Lines of this file are not shown. View the raw message.
include/linux/scsi/ufs/ufshcd.h new file +75
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
met or a timeout occurs
+ * @addr: Address to poll
+ * @val: Variable to read the value into
+ * @cond: Break condition (usually involving @val)
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops)
+ * @timeout_us: Timeout in us, 0 means never timeout
+ *
+ * Returns 0 on success and-ETIMEDOUTupon a timeout. In either
+ * case, the last read value at @addr is stored in @val. Must not
+ * be called from atomic context ifsleep_usortimeout_usare used.
+ */include/linux/scsi/ufs/ufshcd.h new file +62
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
UIC_LINK_OFF_STATE)include/linux/scsi/ufs/ufshcd.h new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
UIC_LINK_OFF_STATE)include/linux/scsi/ufs/ufshcd.h new file +38
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
aggregation)
+ */include/linux/scsi/ufs/ufshcd.h new file +31
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
commands
+ * @type: device management command type - Query, NOP OUT
+ * @lock: lock to allow one command at a time
+ * @complete: internal commands completion
+ * @tag_wq: wait queue until free command slot is available
+ */include/linux/scsi/ufs/ufshcd.h new file +55
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
allow
+ * variant specific Uni-Pro initialization.
+ * @link_startup_notify: called before and after Link startup is carried out
+ * to allow variant specific Uni-Pro
initialization.
+ * @pwr_change_notify: called before and after a power mode change
+ * is carried out to allow vendor spesific capabilities
+ * to be set.
+ * @suspend: called during host controller PM callback
+ * @resume: called during host controller PM callback
+ */include/linux/scsi/ufs/ufshcd.h new file +41
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
for
+ * completion before gating clocks.
+ */include/linux/scsi/ufs/ufshcd.h new file +19
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
during
+ * initialization
+ * @icc_level: icc level which was read during initialization
+ */include/linux/scsi/ufs/ufshcd.h new file +39
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
initialization
+ * @init_prefetch_data: data pre-fetched during initialization
+ * @eh_work: Worker to handle UFS errors that require s/w attention
+ * @eeh_work: Worker to handle exception events
+ * @errors: HBA errors
+ * @uic_error: UFS interconnect layer error status
+ * @saved_err: sticky error mask
+ * @saved_uic_err: sticky UIC error mask
+ * @dev_cmd: ufs device management command information
+ * @auto_bkops_enabled: to track whether bkops is enabled in device
+ * @vreg_info: UFS device voltage regulator information
+ * @clk_list_head: UFS host controller clocks list node head
+ * @pwr_info: holds current power mode
+ * @max_pwr_info: keeps the device max valid pwm
+ */include/linux/scsi/ufs/ufshcd.h new file +153
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*hba)
include/linux/scsi/ufs/ufshcd.h new file +17
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
u32 reg)
include/linux/scsi/ufs/ufshcd.h new file +52
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
attr_sel,include/linux/scsi/ufs/ufshcd.h new file +23
-0Lines of this file are not shown. View the raw message.
include/linux/scsi/ufs/unipro.h new file +207
-1Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
1.8.5.2
Signature · 13 lines
Thanks, Dolev -- Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Part of the diff is not shown here. View the raw message.
Quoted 11 lines · Yaniv Gardi
In this change we add support to the generic PHY framework. Two UFS phys are implemented:
qmp-20nm and qmp-28nm.Also, the files in this change implement the UFS HW (controller & PHY) specific behavior in Qualcomm chips.
Relocation of a few header files is needed in order to expose routines and data structures between PHY driver and UFS driver.Also, this change include the implementation of Inline Crypto Engine (ICE) in Qualcomm chips.
This whole patch is a mess. It does way to many things in one patch, and it doesn't explain enough of it.
Please explain why you need it. Especially as the PHY API is a generic phy abstraction, so having to share defintions between the provider and consumer seems wrong. Even if you need some shared bits keep them to an absolute minium insted of moving so much out of the driver directory. Also if at all possible keep the shared data in a single header under include/linux instead of having lots of global headers in a deep directory structure.
Second split this into patches that do a single things, and explain why you're doing each:
1) header move if/as needed
2) add 20nm phy driver
3) add 28nm phy driver
4) add ufs-qcom driver
5) add ufs-qcom-ice support
and so on.
Quoted 27 lines · Christoph Hellwig
Quoted 11 lines · Yaniv Gardi
In this change we add support to the generic PHY framework. Two UFS phys are implemented:
qmp-20nm and qmp-28nm.Also, the files in this change implement the UFS HW (controller & PHY) specific behavior in Qualcomm chips.
Relocation of a few header files is needed in order to expose routines and data structures between PHY driver and UFS driver.Also, this change include the implementation of Inline Crypto Engine (ICE) in Qualcomm chips.
This whole patch is a mess. It does way to many things in one patch, and it doesn't explain enough of it.
Please explain why you need it. Especially as the PHY API is a generic phy abstraction, so having to share defintions between the provider and consumer seems wrong. Even if you need some shared bits keep them to an absolute minium insted of moving so much out of the driver directory. Also if at all possible keep the shared data in a single header under
include/linuxinstead of having lots of global headers in a deep directory structure.Second split this into patches that do a single things, and explain why you're doing each:
Quoted 7 lines
1) header move if/as needed
2) add 20nm phy driver
3) add 28nm phy driver
4) add ufs-qcom driver
5) add ufs-qcom-ice supportand so on.
+1
-Kishon
thanks for inputs.
shortly I will upload a new version, where I address you comments
thanks,
Yaniv
Quoted 46 lines · Christoph Hellwig
Quoted 28 lines · Yaniv Gardi
Quoted 4 lines
In this change we add support to the generic PHY framework. Two UFS phys are implemented:
qmp-20nm and qmp-28nm.Quoted 8 lines
Also, the files in this change implement the UFS HW (controller & PHY) specific behavior in Qualcomm chips.
Relocation of a few header files is needed in order to expose routines and data structures between PHY driver and UFS driver.Also, this change include the implementation of Inline Crypto Engine (ICE)
in Qualcomm chips.This whole patch is a mess. It does way to many things in one patch, and it doesn't explain enough of it.
Please explain why you need it. Especially as the PHY API is a generic phy abstraction, so having to share defintions between the provider and consumer seems wrong. Even if you need some shared bits keep them to an absolute minium insted of moving so much out of the driver directory. Also if at all possible keep the shared data in a single header under
include/linuxinstead of having lots of global headers in a deep directory structure.Second split this into patches that do a single things, and explain why you're doing each:
Quoted 7 lines
1) header move if/as needed
2) add 20nm phy driver
3) add 28nm phy driver
4) add ufs-qcom driver
5) add ufs-qcom-ice supportand so on.
+1
-Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html