Skip to contentSkip to conversation

scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

PATCH New stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected] 2 participants 6 messages Feb 21, 2019 – Feb 22, 2019 3 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

This patch adds UFS support for Mediatek SoC chips.

Stanley Chu (2):
dt-bindings: scsi: ufs: Add document for ufs-mediatek
scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

 .../devicetree/bindings/ufs/ufs-mediatek.txt  |  62 +++
 drivers/scsi/ufs/Kconfig                      |  12 +
 drivers/scsi/ufs/Makefile                     |   1 +
 drivers/scsi/ufs/ufs-mediatek.c               | 526 ++++++++++++++++++
 drivers/scsi/ufs/ufs-mediatek.h               |  91 +++
 5 files changed, 692 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-mediatek.txt
 create mode 100644 drivers/scsi/ufs/ufs-mediatek.c
 create mode 100644 drivers/scsi/ufs/ufs-mediatek.h

A message that is not in the archive (sent off-list or not yet received): 1550742637-12385-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected]

#2 lore raw

cover scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

From: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected]>

This patch adds UFS support for Mediatek SoC chips.

Stanley Chu (2):
dt-bindings: scsi: ufs: Add document for ufs-mediatek
scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

 .../devicetree/bindings/ufs/ufs-mediatek.txt  |  62 +++
 drivers/scsi/ufs/Kconfig                      |  12 +
 drivers/scsi/ufs/Makefile                     |   1 +
 drivers/scsi/ufs/ufs-mediatek.c               | 526 ++++++++++++++++++
 drivers/scsi/ufs/ufs-mediatek.h               |  91 +++
 5 files changed, 692 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-mediatek.txt
 create mode 100644 drivers/scsi/ufs/ufs-mediatek.c
 create mode 100644 drivers/scsi/ufs/ufs-mediatek.h
Signature · 1 line
2.18.0
#3 lore raw

PATCH 1/2 dt-bindings: scsi: ufs: Add document for ufs-mediatek

In reply to a message not in the archive

From: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected]>

Add UFS and UFS PHY node document for Mediatek SoC chips.

---
 .../devicetree/bindings/ufs/ufs-mediatek.txt  | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-mediatek.txt
Documentation/devicetree/bindings/ufs/ufs-mediatek.txt new file +62 -0
new file mode 100644
index 000000000000..c09a4f884bea
@@ -0,0 +1,62 @@
+* Mediatek Universal Flash Storage (UFS) Host Controller
+
+UFS nodes are defined to describe on-chip UFS hardware macro.
+Each UFS Host Controller should have its own node.
+
+UFS PHY nodes are defined to describe on-chip UFS PHY hardware macro.
+Each UFS PHY node should have its own node.
+
+Required properties for UFS nodes:
+- compatible         : Compatible list, contains the following controller:
+                       "mediatek,ufshci"
+- reg                : Address and length of the UFS register set.
+- interrupt-parent   : interrupt device.
+- interrupts         : interrupt number.
+- 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. "ufs0-clock", "ufs0-unipro-clk" and
+                       "ufs0-mp-clk" are mandatory.
+- freq-table-hz      : Array of <min max> operating frequencies stored in the same
+                       order as the clocks property. If this property is not
+                       defined or a value in the array is "0" then it is assumed
+                       that the frequency is set by the parent clock or a
+                       fixed rate clock source.
+- vcc-supply         : Power to the UFS device.
+- vcc-fixed-regulator: Specify that vcc-supply is a fixed regulator.
+- lanes-per-direction: Number of lanes available per direction. Shall be 1.
+
+Required properties for UFS PHY nodes:
+- compatible         : Compatible list, contains the following controller:
+                       "mediatek,ufs_mphy"
+- reg                : Address and length of the UFS PHY register set.
+
+Example:
+
+	ufshci:ufshci@11270000 {
+		compatible = "mediatek,ufshci";
+		reg = <0 0x11270000 0 0x2300>;
+		interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>;
+
+		clocks =
+			<&infracfg_ao INFRACFG_AO_UFS_CG>,
+			<&infracfg_ao INFRACFG_AO_UNIPRO_SCK_CG>,
+			<&infracfg_ao INFRACFG_AO_UFS_MP_SAP_BCLK_CG>;
+		clock-names =
+			"ufs0-clock",
+			"ufs0-unipro-clk",
+			"ufs0-mp-clk";
+		freq-table-hz =
+			<0 0>,
+			<0 0>,
+			<0 0>;
+
+		vcc-supply = <&mt_pmic_vemc_ldo_reg>;
+		vcc-fixed-regulator;
+
+		lanes-per-direction = <1>;
+	};
+
+	ufs_mphy@11fa0000 {
+		compatible = "mediatek,ufs_mphy";
+		reg = <0 0x11fa0000 0 0xc000>;
+	};
Signature · 1 line
2.18.0
#4 lore raw

PATCH 2/2 scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

In reply to a message not in the archive

From: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected]>

This patch adds UFS support for Mediatek SoC chips.

---
 drivers/scsi/ufs/Kconfig        |  12 +
 drivers/scsi/ufs/Makefile       |   1 +
 drivers/scsi/ufs/ufs-mediatek.c | 526 ++++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufs-mediatek.h |  91 ++++++
 4 files changed, 630 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufs-mediatek.c
 create mode 100644 drivers/scsi/ufs/ufs-mediatek.h
drivers/scsi/ufs/Kconfig +12 -0
index 2ddbb26d9c26..a595f06d501d 100644
@@ -109,6 +109,18 @@ config SCSI_UFS_QCOM
 	  Select this if you have UFS controller on QCOM chipset.
 	  If unsure, say N.
 
+config SCSI_UFS_MEDIATEK
+	tristate "Mediatek specific hooks to UFS controller platform driver"
+	depends on SCSI_UFSHCD_PLATFORM && ARCH_MEDIATEK
+	help
+	  This selects the Mediatek specific additions to UFSHCD platform driver.
+	  UFS host on Mediatek 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 Mediatek chipset.
+	  If unsure, say N.
+
 config SCSI_UFS_HISI
 	tristate "Hisilicon specific hooks to UFS controller platform driver"
 	depends on (ARCH_HISI || COMPILE_TEST) && SCSI_UFSHCD_PLATFORM
drivers/scsi/ufs/Makefile +1 -0
index a3bd70c3652c..2a9097939bcb 100644
@@ -10,3 +10,4 @@ ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
 obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
+obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o
drivers/scsi/ufs/ufs-mediatek.c new file +526 -0

526 lines not on this page · raw message

drivers/scsi/ufs/ufs-mediatek.h new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
2.18.0

A message that is not in the archive (sent off-list or not yet received): 1550742637-12385-4-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected]

#6 lore raw

Hi,

Quoted 5 lines
drivers/scsi/ufs/ufs-mediatek.c new file +5 -0
+
+struct ufs_mtk_dev_params {
+	u32 pwm_rx_gear;        /* pwm rx gear to work in */
+	u32 pwm_tx_gear;        /* pwm tx gear to work in */
+	u32 hs_rx_gear;         /* hs rx gear to work in */

drivers/scsi/ufs/ufs-mediatek.c line 131

Quoted 10 lines
drivers/scsi/ufs/ufs-mediatek.c new file +10 -0
+	u32 hs_tx_gear;         /* hs tx gear to work in */
+	u32 rx_lanes;           /* number of rx lanes */
+	u32 tx_lanes;           /* number of tx lanes */
+	u32 rx_pwr_pwm;         /* rx pwm working pwr */
+	u32 tx_pwr_pwm;         /* tx pwm working pwr */
+	u32 rx_pwr_hs;          /* rx hs working pwr */
+	u32 tx_pwr_hs;          /* tx hs working pwr */
+	u32 hs_rate;            /* rate A/B to work in HS */
+	u32 desired_working_mode;
+};

As this is essentially identical to ufs_qcom_dev_params and ufs_hisi_dev_params etc., Maybe move it to ufshcd-platform.h in a short preparatory patch, so it can be reused?

Also, the vast majority of the code in these platform-dependent modules is pretty much the same. I wonder if it can be shape to fit some standard form?
But this is out of scope of your series.

drivers/scsi/ufs/ufs-mediatek.h line 60

Quoted 4 lines
drivers/scsi/ufs/ufs-mediatek.h new file +4 -0
+/*
+ * PHY Adpater attributes
+ */
+#define PA_LOCALTXLCCENABLE         0x155E

Already in unipro.h

Thanks,
Avri

A message that is not in the archive (sent off-list or not yet received): SN6PR04MB4925CDAF80047DBCED9E2836FC7F0-UKdxhu0+N/[email protected]

#8 lore raw

Hi Avri,

Quoted 11 lines · Avri Altman

Hi,

Quoted 9 lines
drivers/scsi/ufs/ufs-mediatek.c new file +9 -0
+
+struct ufs_mtk_dev_params {
+	u32 pwm_rx_gear;        /* pwm rx gear to work in */
+	u32 pwm_tx_gear;        /* pwm tx gear to work in */
+	u32 hs_rx_gear;         /* hs rx gear to work in */
+	u32 hs_tx_gear;         /* hs tx gear to work in */
+	u32 rx_lanes;           /* number of rx lanes */
+	u32 tx_lanes;           /* number of tx lanes */
+	u32 rx_pwr_pwm;         /* rx pwm working pwr */
Quoted 9 lines

drivers/scsi/ufs/ufs-mediatek.c line 131

Quoted 6 lines
drivers/scsi/ufs/ufs-mediatek.c new file +6 -0
+	u32 tx_pwr_pwm;         /* tx pwm working pwr */
+	u32 rx_pwr_hs;          /* rx hs working pwr */
+	u32 tx_pwr_hs;          /* tx hs working pwr */
+	u32 hs_rate;            /* rate A/B to work in HS */
+	u32 desired_working_mode;
+};

As this is essentially identical to ufs_qcom_dev_params and ufs_hisi_dev_params etc., Maybe move it to ufshcd-platform.h in a short preparatory patch, so it can be reused?

Good suggestion. This is currently also our preferred way to define host limitation. I can help re-factor this in next patch.

Quoted 4 lines

Also, the vast majority of the code in these platform-dependent modules is pretty much the same. I wonder if it can be shape to fit some standard form?
But this is out of scope of your series.

Currently ufs-mediatek driver is a "shell" only for basic UFS operations in Mediatek SoC chips. We are planning to try to add more rich features in the near future and thus more and more different platform-dependent codes will be uploaded.

However, as you mentioned, there may be still lots of similar codes and flows in these platform-dependent drivers. And we can think how to simplify or standardize them later.

Quoted 6 lines

drivers/scsi/ufs/ufs-mediatek.h line 60

Quoted 5 lines
drivers/scsi/ufs/ufs-mediatek.h new file +4 -0
+/*
+ * PHY Adpater attributes
+ */
+#define PA_LOCALTXLCCENABLE         0x155E

Already in unipro.h

Will remove this.

Quoted 3 lines

Thanks,
Avri

Thanks,
Stanley

Quoted 5 lines

_______________________________________________
Linux-mediatek mailing list [email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek