Add UFS host controller support for NVIDIA Tegra264
v2 cover Add UFS host controller support for NVIDIA Tegra264
Add UFS host controller support for NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
This series depends on the Tegra264 M-PHY series: the binding references the M-PHY provider, and drivers/ufs/host/Kconfig selects PHY_TEGRA_MPHY. The driver consumes the M-PHY through the generic PHY API.
Changes in v2:
- Rename the UFS functional clock to "core" and the host-consumed UPHY
PLL clock to "hs" in the binding and driver.
- Use raw M-PHY cell values in the binding example so it can be checked independently of the prerequisite series.
- Drop the unnecessary mod_devicetable.h include and clean up the OF
match table initializers.
- Limit compile testing to 64-bit architectures because the high-speed
link clock rate exceeds the range of unsigned long on 32-bit systems.
- Tear down the M-PHY lanes in reverse initialization order.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Kartik Rajput (4):
dt-bindings: ufs: Add nvidia,tegra264-ufs
scsi: ufs: Add UIC DEBUGSAVECONFIGTIME attribute and its field masks
scsi: ufs: hisi: Use VS_DEBUGSAVECONFIGTIME instead of a literal address
scsi: ufs: tegra: Add Tegra264 UFS host controller driver
.../bindings/ufs/nvidia,tegra264-ufs.yaml | 120 ++++ drivers/ufs/host/Kconfig | 14 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-hisi.c | 6 +- drivers/ufs/host/ufs-tegra.c | 686 +++++++++++++++++++++ include/ufs/unipro.h | 6 + 6 files changed, 829 insertions(+), 4 deletions(-)
---
base-commit: 6375e61c01e93e35ee7acd336a689ac1fae4b509
change-id: 20260909-tegra264-ufs-92edda57c75a
prerequisite-change-id: 20260909-tegra264-mphy-f3edf6fa4321:v1
prerequisite-patch-id: 1c46e1bce9f6106dbabf81e50cd366d3d2da01fc
prerequisite-patch-id: d367971b99f7308cef032b436c054d005b94eded
Best regards,
Signature · 1 line
Kartik Rajput <[email protected]>
PATCH v2 1/4 dt-bindings: ufs: Add nvidia,tegra264-ufs
Add binding for the UFS host controller on NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
--- .../bindings/ufs/nvidia,tegra264-ufs.yaml | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+)
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +120 -0
@@ -0,0 +1,120 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ufs/nvidia,tegra264-ufs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra264 UFS Host Controller + +maintainers: + - Kartik Rajput <[email protected]> + - Thierry Reding <[email protected]> + +properties: + compatible: + const: nvidia,tegra264-ufs + + reg: + items: + - description: UFS Host Controller registers + - description: UFS auxiliary registers + + reg-names: + items: + - const: ufs + - const: aux + + clocks: + items: + - description: UFS host controller core clock + - description: UFS host controller divider clock + - description: UFS reference clock (PLLREFUFS output) + - description: UFS device-side reference clock + - description: UFS high-speed link clock (UPHY0 PLL4 digital output) + + clock-names: + items: + - const: core + - const: div + - const: ref + - const: ref-dev + - const: hs + + resets: + items: + - description: UFS host controller reset + - description: UFS host controller AXI-master reset + - description: UFS host controller low-power sequencer reset + + reset-names: + items: + - const: ufs + - const: axi + - const: lp + + phys: + items: + - description: M-PHY lane 0 transmit + - description: M-PHY lane 0 receive + - description: M-PHY lane 1 transmit + - description: M-PHY lane 1 receive + + phy-names: + items: + - const: mphy-l0-tx + - const: mphy-l0-rx + - const: mphy-l1-tx + - const: mphy-l1-rx + + iommus: + maxItems: 1 + + dma-coherent: true + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - phys + - phy-names + - iommus + - dma-coherent + +allOf: + - $ref: ufs-common.yaml + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/nvidia,tegra264.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/nvidia,tegra264.h> + + ufs@b8d0000 { + compatible = "nvidia,tegra264-ufs"; + reg = <0xb8d0000 0x10000>, + <0xb8e0000 0x8000>; + reg-names = "ufs", "aux"; + interrupts = <GIC_SPI 951 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bpmp TEGRA264_CLK_UFSHC_CG_SYS>, + <&bpmp TEGRA264_CLK_UFSHC_CG_SYS_DIV>, + <&bpmp TEGRA264_CLK_PLLREFUFS_CLKOUT624>, + <&bpmp TEGRA264_CLK_PLLREFUFS_UFSDEV_REFCLKOUT>, + <&bpmp TEGRA264_CLK_UPHY0_PLL4_XDIG>; + clock-names = "core", "div", "ref", "ref-dev", "hs"; + resets = <&bpmp TEGRA264_RESET_UFSHC>, + <&bpmp TEGRA264_RESET_UFSHC_AXI_M>, + <&bpmp TEGRA264_RESET_UFSHC_LP_SEQ>; + reset-names = "ufs", "axi", "lp"; + phys = <&mphy 0>, <&mphy 1>, <&mphy 2>, <&mphy 3>; + phy-names = "mphy-l0-tx", "mphy-l0-rx", + "mphy-l1-tx", "mphy-l1-rx"; + iommus = <&smmu 0x20>; + dma-coherent; + }; +...
Signature · 1 line
2.43.0
Re: [PATCH v2 1/4] dt-bindings: ufs: Add nvidia,tegra264-ufs
Quoted 4 lines · Kartik Rajput
Add binding for the UFS host controller on NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
Signed-off-by Kartik Rajput <[email protected]>
I do not understand why you added dependency on the phy in this patchset. Looks like fake/not real dependency, so you only stall your work and raise questions.
Cover letter mentions "the binding references
the M-PHY provider" but this is simply NOT TRUE.
Patch itself is correct but I suggest to be careful what you send, to avoid questions on trivial stuff.
Best regards,
Krzysztof
Krzysztof Kozlowski
Reviewed-byRe: [PATCH v2 1/4] dt-bindings: ufs: Add nvidia,tegra264-ufs
Quoted 10 lines · Krzysztof Kozlowski
Quoted 4 lines · Kartik Rajput
Add binding for the UFS host controller on NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
Signed-off-by Kartik Rajput <[email protected]>I do not understand why you added dependency on the phy in this patchset. Looks like fake/not real dependency, so you only stall your work and raise questions.
Quoted 5 lines
Cover letter mentions "the binding references
the M-PHY provider" but this is simply NOT TRUE.Patch itself is correct but I suggest to be careful what you send, to avoid questions on trivial stuff.
Forgot the tag:
But honestly, this fake dependency is a no-go and I commented on driver patch regarding it.
Best regards,
Krzysztof
PATCH v2 2/4 scsi: ufs: Add UIC DEBUGSAVECONFIGTIME attribute and its field masks
In reply to Kartik RajputAdd the UniPro vendor-specific save-config-time attribute and masks for the two fields within it:
VS_DEBUGSAVECONFIGTIME Save-config-time attribute (0xD0A0) VS_DEBUGSAVECONFIGTIME_TREF Field masks within that attribute, for VS_DEBUGSAVECONFIGTIME_SCT use with FIELD_PREP()
ufs-hisi already writes this attribute by its literal address, so name it in the shared header rather than in the driver. Add it here in preparation for the Tegra264 UFS host controller driver, which also programs the two fields.
--- include/ufs/unipro.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/ufs/unipro.h +6 -0
@@ -6,6 +6,8 @@#ifndef _UNIPRO_H_#define _UNIPRO_H_ +#include <linux/bits.h> +/* * M-TX Configuration Attributes */
@@ -232,8 +234,12 @@#define VS_POWERSTATE 0xD083#define VS_MPHYCFGUPDT 0xD085#define VS_DEBUGOMC 0xD09E +#define VS_DEBUGSAVECONFIGTIME 0xD0A0#define VS_MPHYDISABLE 0xD0C1 +#define VS_DEBUGSAVECONFIGTIME_TREF GENMASK(4, 2) +#define VS_DEBUGSAVECONFIGTIME_SCT GENMASK(1, 0) +#define PA_GRANULARITY_MIN_VAL 1#define PA_GRANULARITY_MAX_VAL 6
Signature · 1 line
2.43.0
PATCH v2 3/4 scsi: ufs: hisi: Use VS_DEBUGSAVECONFIGTIME instead of a literal address
In reply to Kartik Rajputufs-hisi writes the VS_DebugSaveConfigTime UIC attribute twice by its literal address, with a comment naming it each time. The attribute now has a name in the shared UniPro header, so use it and drop the comments and the redundant (u32) cast.
No functional change.
--- drivers/ufs/host/ufs-hisi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ufs/host/ufs-hisi.c +2 -4
@@ -318,8 +318,7 @@ static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)* Boston platform need to set SaveConfigTime to 0x13, * and change sync length to maximum value */ -/* VS_DebugSaveConfigTime */ -ufshcd_dme_set (hba,UIC_ARG_MIB ((u32 )0xD0A0 ),0x13 ); +ufshcd_dme_set (hba,UIC_ARG_MIB (VS_DEBUGSAVECONFIGTIME ),0x13 );/* g1 sync length */ ufshcd_dme_set (hba,UIC_ARG_MIB ((u32 )0x1552 ),0x4f );/* g2 sync length */
@@ -335,8 +334,7 @@ static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)if (hba->dev_quirks &UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME ) {pr_info ("ufs flash device must set VS_DebugSaveConfigTime 0x10\n" ); -/* VS_DebugSaveConfigTime */ -ufshcd_dme_set (hba,UIC_ARG_MIB (0xD0A0 ),0x10 ); +ufshcd_dme_set (hba,UIC_ARG_MIB (VS_DEBUGSAVECONFIGTIME ),0x10 );/* sync length */ ufshcd_dme_set (hba,UIC_ARG_MIB (0x1556 ),0x48 ); }
Signature · 1 line
2.43.0
PATCH v2 4/4 scsi: ufs: tegra: Add Tegra264 UFS host controller driver
In reply to Kartik RajputAdd a driver for the UFS host controller found on NVIDIA Tegra264 SoCs. The controller has Tegra-specific auxiliary registers, clocks and resets, and it drives the four M-PHY lane directions exposed by the Tegra264 M-PHY driver.
--- drivers/ufs/host/Kconfig | 14 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-tegra.c | 686 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 701 insertions(+)
drivers/ufs/host/Kconfig +14 -0
@@ -168,3 +168,17 @@ config SCSI_UFS_AMD_VERSAL2 Select this if you have UFS controller on AMD Versal Gen 2 SoC. If unsure, say N. + +config SCSI_UFS_TEGRA + tristate "NVIDIA Tegra264 UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM + depends on ARCH_TEGRA_264_SOC || (COMPILE_TEST && 64BIT) + select PHY_TEGRA_MPHY + help + Enable support for the UFS host controller on NVIDIA Tegra264 + SoCs. The driver relies on the Tegra264 M-PHY driver + (PHY_TEGRA_MPHY) for the two data lanes and implements the + vendor register programming required for HS-mode transitions + and system suspend/resume. + + If unsure, say N.
drivers/ufs/host/Makefile +1 -0
@@ -14,5 +14,6 @@ obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o obj-$(CONFIG_SCSI_UFS_RENESAS) += ufs-renesas.o obj-$(CONFIG_SCSI_UFS_ROCKCHIP) += ufs-rockchip.o obj-$(CONFIG_SCSI_UFS_SPRD) += ufs-sprd.o +obj-$(CONFIG_SCSI_UFS_TEGRA) += ufs-tegra.o ufshcd-dwc.o obj-$(CONFIG_SCSI_UFS_TI_J721E) += ti-j721e-ufs.o obj-$(CONFIG_SCSI_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
drivers/ufs/host/ufs-tegra.c new file +686 -0
686 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] ufs: tegra: missing hardware reset assertion in teardown path - [Medium] ufs: tegra: missing…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] ufs: tegra: missing hardware reset assertion in teardown path
- [Medium] ufs: tegra: missing dummy readl() after writel() to guarantee delay timing and ordering --
commit 1b8e042f5d752753eca62f28d9beaa880236dcb0
Author: Kartik Rajput <[email protected]>
scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Add a driver for the UFS host controller found on NVIDIA Tegra264 SoCs. The controller has Tegra-specific auxiliary registers, clocks and resets, and it drives the four M-PHY lane directions exposed by the Tegra264 M-PHY driver.
Quoted 5 lines
drivers/ufs/host/ufs-tegra.c new file +0
-0
[ ... ]
drivers/ufs/host/ufs-tegra.c line 164
Quoted 11 lines
drivers/ufs/host/ufs-tegra.c new file +11
-0+static void ufs_tegra_configure_aux (struct ufs_hba *hba) +{ +struct ufs_tegra *ufs =ufshcd_get_variant (hba); +u32 value; + + value =readl (ufs->aux +UFSHC_AUX_DEV_CTRL ); + value |=DEV_CTRL_CLK_EN ; +writel (value, ufs->aux +UFSHC_AUX_DEV_CTRL ); + +/* Let the reference clock stabilise before deasserting device reset. */ +usleep_range (1000 ,2000 );
[Severity: Medium]
Memory-mapped peripheral writes via writel() provide CPU ordering but do not guarantee that the write has reached the interconnect. Does this sleep begin without guaranteeing the clock enable write has reached the peripheral?
Without a dummy readl() to flush the posted write, the CPU can proceed while the write is still buffered, causing the timing delay to execute prematurely.
Quoted 6 lines
drivers/ufs/host/ufs-tegra.c new file +6
-0+ + value |=DEV_CTRL_RESET ; +writel (value, ufs->aux +UFSHC_AUX_DEV_CTRL ); +} + +static void ufs_tegra_aux_init (struct ufs_hba *hba)
drivers/ufs/host/ufs-tegra.c line 180
Quoted 10 lines
drivers/ufs/host/ufs-tegra.c new file +10
-0+{ +struct ufs_tegra *ufs =ufshcd_get_variant (hba); +u32 value; + + value =readl (ufs->aux +UFSHC_AUX_DEV_CTRL ); + value &= ~(DEV_CTRL_CLK_EN |DEV_CTRL_RESET ); +writel (value, ufs->aux +UFSHC_AUX_DEV_CTRL ); + +/* Ensure the clear is observed before we re-enable. */ +usleep_range (100 ,200 );
[Severity: Medium]
Similarly here, does this sleep begin without guaranteeing the clear operation has reached the peripheral? A dummy readl() might be needed to flush the posted write before delaying.
Quoted 3 lines
drivers/ufs/host/ufs-tegra.c new file +3
-0+ +ufs_tegra_configure_aux (hba); +}
[ ... ]
Quoted 9 lines
drivers/ufs/host/ufs-tegra.c new file +9
-0+static int ufs_tegra_hce_enable_notify (struct ufs_hba *hba,enum ufs_notify_change_status status) +{ +struct ufs_tegra *ufs =ufshcd_get_variant (hba); +u32 value; +int err; + +switch (status) { +case PRE_CHANGE : + err =ufs_tegra_power_up_sequence (hba);
drivers/ufs/host/ufs-tegra.c line 515
Quoted 10 lines
drivers/ufs/host/ufs-tegra.c new file +10
-0+if (err) +return err; + +/* Assert device reset; POST_CHANGE releases it via +* ufs_tegra_configure_aux() so the HCE toggle pulses it. +*/ + value =readl (ufs->aux +UFSHC_AUX_DEV_CTRL ); + value &= ~DEV_CTRL_RESET ; +writel (value, ufs->aux +UFSHC_AUX_DEV_CTRL ); +break ;
[Severity: Medium]
Does this write need to be flushed before returning? Without flushing the auxiliary write, the core driver proceeds to write REG_CONTROLLER_ENABLE. The HCE toggle might beat the reset assertion, causing hardware initialization failures.
Quoted 1 line
drivers/ufs/host/ufs-tegra.c new file +1
-0+case POST_CHANGE :
[ ... ]
drivers/ufs/host/ufs-tegra.c line 427
Quoted 4 lines
drivers/ufs/host/ufs-tegra.c new file +4
-0+static void ufs_tegra_exit (struct ufs_hba *hba) +{ +ufs_tegra_mphy_disable (hba); +}
[Severity: Medium]
Does this teardown function lack a call to reset_control_bulk_assert()?
The hardware resets are initially deasserted in ufs_tegra_init() via reset_control_bulk_deassert(). However, the teardown callback ufs_tegra_exit() misses the matching assertion. The API devm_reset_control_bulk_get_exclusive() only releases the references but does not auto-assert the reset lines upon unbind.
This leaves the UFS host controller hardware unquiesced (active) when the driver is unbound, potentially leading to state issues on kexec or power leaks.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v2 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
In reply to Kartik RajputQuoted 19 lines · Kartik Rajput
Add a driver for the UFS host controller found on NVIDIA Tegra264 SoCs. The controller has Tegra-specific auxiliary registers, clocks and resets, and it drives the four M-PHY lane directions exposed by the Tegra264 M-PHY driver.
Co-developed-by Thierry Reding <[email protected]>Signed-off-by Thierry Reding <[email protected]>Signed-off-by Kartik Rajput <[email protected]>--- drivers/ufs/host/Kconfig | 14 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-tegra.c | 686 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 701 insertions(+)drivers/ufs/host/Kconfig +0
-0
drivers/ufs/host/Kconfig config SCSI_UFS_AMD_VERSAL2 · line 176
Quoted 9 lines
drivers/ufs/host/Kconfig +6
-0@@ -168,3 +168,17 @@ config SCSI_UFS_AMD_VERSAL2 Select this if you have UFS controller on AMD Versal Gen 2 SoC. If unsure, say N. + +config SCSI_UFS_TEGRA + tristate "NVIDIA Tegra264 UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM + depends on ARCH_TEGRA_264_SOC || (COMPILE_TEST && 64BIT) + select PHY_TEGRA_MPHY
Nope.
There is nothing here which depends on the phy. If there is, you wrote this wrong and did not use proper Linux interfaces (the Generic PHY).
Also, you must NOT select user-visible symbols, that's basic rules now.
Best regards,
Krzysztof
Thierry Reding
maintainerRe: [PATCH v2 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
In reply to Kartik RajputQuoted 19 lines · Kartik Rajput
Add a driver for the UFS host controller found on NVIDIA Tegra264 SoCs. The controller has Tegra-specific auxiliary registers, clocks and resets, and it drives the four M-PHY lane directions exposed by the Tegra264 M-PHY driver.
Co-developed-by Thierry Reding <[email protected]>Signed-off-by Thierry Reding <[email protected]>Signed-off-by Kartik Rajput <[email protected]>--- drivers/ufs/host/Kconfig | 14 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-tegra.c | 686 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 701 insertions(+)drivers/ufs/host/Kconfig +0
-0
drivers/ufs/host/Kconfig config SCSI_UFS_AMD_VERSAL2 · line 175
Quoted 8 lines
drivers/ufs/host/Kconfig +5
-0@@ -168,3 +168,17 @@ config SCSI_UFS_AMD_VERSAL2 Select this if you have UFS controller on AMD Versal Gen 2 SoC. If unsure, say N. + +config SCSI_UFS_TEGRA + tristate "NVIDIA Tegra264 UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM + depends on ARCH_TEGRA_264_SOC || (COMPILE_TEST && 64BIT)
From a quick look I couldn't spot anything specific to 64-bit in the driver. Did I miss anything?
Also, we really shouldn't depend on ARCH_TEGRA_264_SOC since this controller exists on prior generations and we will eventually want to support them, too.
drivers/ufs/host/Kconfig config SCSI_UFS_AMD_VERSAL2 · line 176
Quoted 1 line
drivers/ufs/host/Kconfig +1
-0+ select PHY_TEGRA_MPHY
Maybe to complement what Krzysztof already said: Kconfig dependencies are primarily build-time dependencies. This driver uses the generic PHY API to access the M-PHY functionality, so GENERIC_PHY is the correct build-time dependency. The driver is purposefully agnostic to the specific implementation of the PHYs that it uses so that it can work with (potentially) many different PHY implementations.
We use device tree to hook up the runtime dependencies. If the M-PHY driver is not enabled we get the probe deferred because the PHYs that were hooked up in DT haven't been registered and hence can't be found (by the generic PHY framework). On other devices the PHYs might end up being backed by completely different implementations and they could still work just fine.
drivers/ufs/host/Kconfig config SCSI_UFS_AMD_VERSAL2 · line 179
Quoted 3 lines
drivers/ufs/host/Kconfig +3
-0+ help + Enable support for the UFS host controller on NVIDIA Tegra264 + SoCs. The driver relies on the Tegra264 M-PHY driver
I would suggest dropping references to Tegra264 here. The driver is not specific to Tegra264. There are older Tegra SoCs that have (earlier) generations of this IP and that should still work with this driver (maybe with some parameterization).
drivers/ufs/host/ufs-tegra.c line 3
Quoted 9 lines
drivers/ufs/host/ufs-tegra.c new file +3
-0@@ -0,0 +1,686 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// NVIDIA Tegra264 UFS host controller driver.
Tegra264 can be dropped here as well.
[...]
drivers/ufs/host/ufs-tegra.c line 35
Quoted 1 line
drivers/ufs/host/ufs-tegra.c new file +1
-0+#define UFS_TEGRA_HS_CLK_RATE_HZ 5840000000UL
Do we assume that this will always be the same value? Maybe this should be turned into SoC data? We could always do that when necessary, of course.
[...]
Quoted 30 lines
drivers/ufs/host/ufs-tegra.c new file +30
-0+static int ufs_tegra_mphy_power_on (struct ufs_hba *hba) +{ +struct ufs_tegra *ufs =ufshcd_get_variant (hba); +int err; + + err =phy_power_on (ufs->mphy_l0_rx); +if (err) { +dev_err (hba->dev,"failed to power on mphy-l0-rx\n" ); +return err; + } + + err =phy_power_on (ufs->mphy_l0_tx); +if (err) { +dev_err (hba->dev,"failed to power on mphy-l0-tx\n" ); + goto out_power_off_l0_rx; + } + + err =phy_power_on (ufs->mphy_l1_rx); +if (err) { +dev_err (hba->dev,"failed to power on mphy-l1-rx\n" ); + goto out_power_off_l0_tx; + } + + err =phy_power_on (ufs->mphy_l1_tx); +if (err) { +dev_err (hba->dev,"failed to power on mphy-l1-tx\n" ); + goto out_power_off_l1_rx; + } + +return 0 ;
drivers/ufs/host/ufs-tegra.c line 329
Quoted 10 lines
drivers/ufs/host/ufs-tegra.c new file +10
-0+ +out_power_off_l1_rx: +phy_power_off (ufs->mphy_l1_rx); +out_power_off_l0_tx: +phy_power_off (ufs->mphy_l0_tx); +out_power_off_l0_rx: +phy_power_off (ufs->mphy_l0_rx); + +return err; +}
Almost seems like we need phy_bulk APIs. Again, doesn't need to be part of this series, but maybe something to keep in mind.
[...]
drivers/ufs/host/ufs-tegra.c line 438
Quoted 10 lines
drivers/ufs/host/ufs-tegra.c new file +10
-0+static int ufs_tegra_suspend (struct ufs_hba *hba,enum ufs_pm_op pm_op, +enum ufs_notify_change_status status) +{ +if (status ==PRE_CHANGE ) +return 0 ; + +/* Runtime H8 park keeps the M-PHY powered; only tear it down +* on the full-teardown paths (system suspend, shutdown, or +* runtime PM with LINK_OFF). +*/
Comment style needs the first line to be /* on its own, except for the net subsystem, if I recall correctly. There are other occurrences of this elsewhere in the file.
Also, I read "H8" as "hate" at first and it took me a little bit to realize it meant "hibernate" in this case. Looks like the rest of UFS uses "hibern8". Maybe stick to the convention?
[...]
Quoted 4 lines
drivers/ufs/host/ufs-tegra.c new file +4
-0+static int ufs_tegra_pwr_change_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status, +struct ufs_pa_layer_attr *dev_req_params) +{
[...]
drivers/ufs/host/ufs-tegra.c line 614
Quoted 3 lines
drivers/ufs/host/ufs-tegra.c new file +3
-0+if (dev_req_params->hs_rate ==PA_HS_MODE_A || + dev_req_params->hs_rate ==PA_HS_MODE_B ) { + err =clk_set_rate (ufs->hs_clk,UFS_TEGRA_HS_CLK_RATE_HZ );
What if hs_rate != PA_HS_MODE_A or PA_HS_MODE_B?
drivers/ufs/host/ufs-tegra.c line 629
Quoted 4 lines
drivers/ufs/host/ufs-tegra.c new file +4
-0+static int ufs_tegra_set_dma_mask (struct ufs_hba *hba) +{ +return dma_set_mask_and_coherent (hba->dev,DMA_BIT_MASK (32 )); +}
I have a feeling like the 32 is here on purpose, but I can't fully remember why it's not something like 40, which is the standard on recent Tegra devices.
Maybe we should add a comment explaining why this needs to be so narrow.
Thierry