Skip to content

Commit 1cc577e

Browse files
Ram Kumar Dwivedimartinkpetersen
authored andcommitted
scsi: ufs: pltfrm: Add DT support to limit HS gear and gear rate
Introduce parsing of 'limit-hs-gear' and 'limit-gear-rate' device tree properties to restrict high-speed gear and rate during initialization. This is useful in cases where the customer board may have signal integrity, clock configuration or layout issues that prevent reliable operation at higher gears. Such limitations are especially critical in those platforms, where stability is prioritized over peak performance. Co-developed-by: Nitin Rawat <[email protected]> Signed-off-by: Nitin Rawat <[email protected]> Signed-off-by: Ram Kumar Dwivedi <[email protected]> Reviewed-by: Alim Akhtar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d471a07 commit 1cc577e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/ufs/host/ufshcd-pltfrm.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,39 @@ int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
430430
}
431431
EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_params);
432432

433+
/**
434+
* ufshcd_parse_gear_limits - Parse DT-based gear and rate limits for UFS
435+
* @hba: Pointer to UFS host bus adapter instance
436+
* @host_params: Pointer to UFS host parameters structure to be updated
437+
*
438+
* This function reads optional device tree properties to apply
439+
* platform-specific constraints.
440+
*
441+
* "limit-hs-gear": Specifies the max HS gear.
442+
* "limit-gear-rate": Specifies the max High-Speed rate.
443+
*/
444+
void ufshcd_parse_gear_limits(struct ufs_hba *hba, struct ufs_host_params *host_params)
445+
{
446+
struct device_node *np = hba->dev->of_node;
447+
u32 hs_gear;
448+
const char *hs_rate;
449+
450+
if (!of_property_read_u32(np, "limit-hs-gear", &hs_gear)) {
451+
host_params->hs_tx_gear = hs_gear;
452+
host_params->hs_rx_gear = hs_gear;
453+
}
454+
455+
if (!of_property_read_string(np, "limit-gear-rate", &hs_rate)) {
456+
if (!strcmp(hs_rate, "rate-a"))
457+
host_params->hs_rate = PA_HS_MODE_A;
458+
else if (!strcmp(hs_rate, "rate-b"))
459+
host_params->hs_rate = PA_HS_MODE_B;
460+
else
461+
dev_warn(hba->dev, "Invalid rate: %s\n", hs_rate);
462+
}
463+
}
464+
EXPORT_SYMBOL_GPL(ufshcd_parse_gear_limits);
465+
433466
void ufshcd_init_host_params(struct ufs_host_params *host_params)
434467
{
435468
*host_params = (struct ufs_host_params){

drivers/ufs/host/ufshcd-pltfrm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
2929
const struct ufs_pa_layer_attr *dev_max,
3030
struct ufs_pa_layer_attr *agreed_pwr);
3131
void ufshcd_init_host_params(struct ufs_host_params *host_params);
32+
void ufshcd_parse_gear_limits(struct ufs_hba *hba, struct ufs_host_params *host_params);
3233
int ufshcd_pltfrm_init(struct platform_device *pdev,
3334
const struct ufs_hba_variant_ops *vops);
3435
void ufshcd_pltfrm_remove(struct platform_device *pdev);

0 commit comments

Comments
 (0)