Commit 3bd70aec authored by Martin K. Petersen's avatar Martin K. Petersen
Browse files

Merge patch series "Add DT-based gear and rate limiting support"



Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com> says:

This patch series adds support for limiting the maximum high-speed
gear and rate used by the UFS controller via device tree properties.

Some platforms may have signal integrity, clock configuration, or
layout issues that prevent reliable operation at higher gears or
rates.  This is especially critical in automotive and other platforms
where stability is prioritized over peak performance.

The series follows this logical progression:

 1. Document the new DT properties in the common UFS binding

 2. Clean up existing redundant code in the qcom driver

 3. Add platform-level parsing support for the new properties

 4. Integrate the platform support in the qcom driver

This approach makes the functionality available to other UFS host
drivers and provides a cleaner, more maintainable implementation.

Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parents 79dde5f7 88f4d3aa
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -89,6 +89,22 @@ properties:

  msi-parent: true

  limit-hs-gear:
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 1
    maximum: 6
    default: 6
    description:
      Restricts the maximum HS gear used in both TX and RX directions.

  limit-gear-rate:
    $ref: /schemas/types.yaml#/definitions/string
    enum: [rate-a, rate-b]
    default: rate-b
    description:
      Restricts the UFS controller to rate-a or rate-b for both TX and
      RX directions.

dependencies:
  freq-table-hz: [ clocks ]
  operating-points-v2: [ clocks, clock-names ]
+15 −6
Original line number Diff line number Diff line
@@ -497,12 +497,8 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
	 * If the HS-G5 PHY gear is used, update host_params->hs_rate to Rate-A,
	 * so that the subsequent power mode change shall stick to Rate-A.
	 */
	if (host->hw_ver.major == 0x5) {
		if (host->phy_gear == UFS_HS_G5)
	if (host->hw_ver.major == 0x5 && host->phy_gear == UFS_HS_G5)
		host_params->hs_rate = PA_HS_MODE_A;
		else
			host_params->hs_rate = PA_HS_MODE_B;
	}

	mode = host_params->hs_rate == PA_HS_MODE_B ? PHY_MODE_UFS_HS_B : PHY_MODE_UFS_HS_A;

@@ -1117,6 +1113,18 @@ static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host)
	}
}

static void ufs_qcom_parse_gear_limits(struct ufs_hba *hba)
{
	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
	struct ufs_host_params *host_params = &host->host_params;
	u32 hs_gear_old = host_params->hs_tx_gear;

	ufshcd_parse_gear_limits(hba, host_params);
	if (host_params->hs_tx_gear != hs_gear_old) {
		host->phy_gear = host_params->hs_tx_gear;
	}
}

static void ufs_qcom_set_host_params(struct ufs_hba *hba)
{
	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
@@ -1368,6 +1376,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
	ufs_qcom_advertise_quirks(hba);
	ufs_qcom_set_host_params(hba);
	ufs_qcom_set_phy_gear(host);
	ufs_qcom_parse_gear_limits(hba);

	err = ufs_qcom_ice_init(host);
	if (err)
+33 −0
Original line number Diff line number Diff line
@@ -430,6 +430,39 @@ int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
}
EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_params);

/**
 * ufshcd_parse_gear_limits - Parse DT-based gear and rate limits for UFS
 * @hba: Pointer to UFS host bus adapter instance
 * @host_params: Pointer to UFS host parameters structure to be updated
 *
 * This function reads optional device tree properties to apply
 * platform-specific constraints.
 *
 * "limit-hs-gear": Specifies the max HS gear.
 * "limit-gear-rate": Specifies the max High-Speed rate.
 */
void ufshcd_parse_gear_limits(struct ufs_hba *hba, struct ufs_host_params *host_params)
{
	struct device_node *np = hba->dev->of_node;
	u32 hs_gear;
	const char *hs_rate;

	if (!of_property_read_u32(np, "limit-hs-gear", &hs_gear)) {
		host_params->hs_tx_gear = hs_gear;
		host_params->hs_rx_gear = hs_gear;
	}

	if (!of_property_read_string(np, "limit-gear-rate", &hs_rate)) {
		if (!strcmp(hs_rate, "rate-a"))
			host_params->hs_rate = PA_HS_MODE_A;
		else if (!strcmp(hs_rate, "rate-b"))
			host_params->hs_rate = PA_HS_MODE_B;
		else
			dev_warn(hba->dev, "Invalid rate: %s\n", hs_rate);
	}
}
EXPORT_SYMBOL_GPL(ufshcd_parse_gear_limits);

void ufshcd_init_host_params(struct ufs_host_params *host_params)
{
	*host_params = (struct ufs_host_params){
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
				const struct ufs_pa_layer_attr *dev_max,
				struct ufs_pa_layer_attr *agreed_pwr);
void ufshcd_init_host_params(struct ufs_host_params *host_params);
void ufshcd_parse_gear_limits(struct ufs_hba *hba, struct ufs_host_params *host_params);
int ufshcd_pltfrm_init(struct platform_device *pdev,
		       const struct ufs_hba_variant_ops *vops);
void ufshcd_pltfrm_remove(struct platform_device *pdev);