@@ -274,9 +274,7 @@ static int ufs_qcom_check_hibern8(struct ufs_hba *hba)
274274
275275static void ufs_qcom_select_unipro_mode (struct ufs_qcom_host * host )
276276{
277- ufshcd_rmwl (host -> hba , QUNIPRO_SEL ,
278- ufs_qcom_cap_qunipro (host ) ? QUNIPRO_SEL : 0 ,
279- REG_UFS_CFG1 );
277+ ufshcd_rmwl (host -> hba , QUNIPRO_SEL , QUNIPRO_SEL , REG_UFS_CFG1 );
280278
281279 if (host -> hw_ver .major >= 0x05 )
282280 ufshcd_rmwl (host -> hba , QUNIPRO_G4_SEL , 0 , REG_UFS_CFG0 );
@@ -333,18 +331,8 @@ static u32 ufs_qcom_get_hs_gear(struct ufs_hba *hba)
333331{
334332 struct ufs_qcom_host * host = ufshcd_get_variant (hba );
335333
336- if (host -> hw_ver .major == 0x1 ) {
337- /*
338- * HS-G3 operations may not reliably work on legacy QCOM
339- * UFS host controller hardware even though capability
340- * exchange during link startup phase may end up
341- * negotiating maximum supported gear as G3.
342- * Hence downgrade the maximum supported gear to HS-G2.
343- */
344- return UFS_HS_G2 ;
345- } else if (host -> hw_ver .major >= 0x4 ) {
334+ if (host -> hw_ver .major >= 0x4 )
346335 return UFS_QCOM_MAX_GEAR (ufshcd_readl (hba , REG_UFS_PARAM0 ));
347- }
348336
349337 /* Default is HS-G3 */
350338 return UFS_HS_G3 ;
@@ -457,41 +445,16 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear,
457445{
458446 struct ufs_qcom_host * host = ufshcd_get_variant (hba );
459447 struct ufs_clk_info * clki ;
460- u32 core_clk_period_in_ns ;
461- u32 tx_clk_cycles_per_us = 0 ;
462448 unsigned long core_clk_rate = 0 ;
463449 u32 core_clk_cycles_per_us ;
464450
465- static u32 pwm_fr_table [][2 ] = {
466- {UFS_PWM_G1 , 0x1 },
467- {UFS_PWM_G2 , 0x1 },
468- {UFS_PWM_G3 , 0x1 },
469- {UFS_PWM_G4 , 0x1 },
470- };
471-
472- static u32 hs_fr_table_rA [][2 ] = {
473- {UFS_HS_G1 , 0x1F },
474- {UFS_HS_G2 , 0x3e },
475- {UFS_HS_G3 , 0x7D },
476- };
477-
478- static u32 hs_fr_table_rB [][2 ] = {
479- {UFS_HS_G1 , 0x24 },
480- {UFS_HS_G2 , 0x49 },
481- {UFS_HS_G3 , 0x92 },
482- };
483-
484451 /*
485- * The Qunipro controller does not use following registers:
486- * SYS1CLK_1US_REG, TX_SYMBOL_CLK_1US_REG, CLK_NS_REG &
487- * UFS_REG_PA_LINK_STARTUP_TIMER.
488- * However UTP controller uses SYS1CLK_1US_REG register for Interrupt
452+ * UTP controller uses SYS1CLK_1US_REG register for Interrupt
489453 * Aggregation logic.
490454 * It is mandatory to write SYS1CLK_1US_REG register on UFS host
491455 * controller V4.0.0 onwards.
492456 */
493- if (host -> hw_ver .major < 4 && ufs_qcom_cap_qunipro (host ) &&
494- !ufshcd_is_intr_aggr_allowed (hba ))
457+ if (host -> hw_ver .major < 4 && !ufshcd_is_intr_aggr_allowed (hba ))
495458 return 0 ;
496459
497460 if (gear == 0 ) {
@@ -524,87 +487,13 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear,
524487 mb ();
525488 }
526489
527- if (ufs_qcom_cap_qunipro (host ))
528- return 0 ;
529-
530- core_clk_period_in_ns = NSEC_PER_SEC / core_clk_rate ;
531- core_clk_period_in_ns <<= OFFSET_CLK_NS_REG ;
532- core_clk_period_in_ns &= MASK_CLK_NS_REG ;
533-
534- switch (hs ) {
535- case FASTAUTO_MODE :
536- case FAST_MODE :
537- if (rate == PA_HS_MODE_A ) {
538- if (gear > ARRAY_SIZE (hs_fr_table_rA )) {
539- dev_err (hba -> dev ,
540- "%s: index %d exceeds table size %zu\n" ,
541- __func__ , gear ,
542- ARRAY_SIZE (hs_fr_table_rA ));
543- return - EINVAL ;
544- }
545- tx_clk_cycles_per_us = hs_fr_table_rA [gear - 1 ][1 ];
546- } else if (rate == PA_HS_MODE_B ) {
547- if (gear > ARRAY_SIZE (hs_fr_table_rB )) {
548- dev_err (hba -> dev ,
549- "%s: index %d exceeds table size %zu\n" ,
550- __func__ , gear ,
551- ARRAY_SIZE (hs_fr_table_rB ));
552- return - EINVAL ;
553- }
554- tx_clk_cycles_per_us = hs_fr_table_rB [gear - 1 ][1 ];
555- } else {
556- dev_err (hba -> dev , "%s: invalid rate = %d\n" ,
557- __func__ , rate );
558- return - EINVAL ;
559- }
560- break ;
561- case SLOWAUTO_MODE :
562- case SLOW_MODE :
563- if (gear > ARRAY_SIZE (pwm_fr_table )) {
564- dev_err (hba -> dev ,
565- "%s: index %d exceeds table size %zu\n" ,
566- __func__ , gear ,
567- ARRAY_SIZE (pwm_fr_table ));
568- return - EINVAL ;
569- }
570- tx_clk_cycles_per_us = pwm_fr_table [gear - 1 ][1 ];
571- break ;
572- case UNCHANGED :
573- default :
574- dev_err (hba -> dev , "%s: invalid mode = %d\n" , __func__ , hs );
575- return - EINVAL ;
576- }
577-
578- if (ufshcd_readl (hba , REG_UFS_TX_SYMBOL_CLK_NS_US ) !=
579- (core_clk_period_in_ns | tx_clk_cycles_per_us )) {
580- /* this register 2 fields shall be written at once */
581- ufshcd_writel (hba , core_clk_period_in_ns | tx_clk_cycles_per_us ,
582- REG_UFS_TX_SYMBOL_CLK_NS_US );
583- /*
584- * make sure above write gets applied before we return from
585- * this function.
586- */
587- mb ();
588- }
589-
590- if (update_link_startup_timer && host -> hw_ver .major != 0x5 ) {
591- ufshcd_writel (hba , ((core_clk_rate / MSEC_PER_SEC ) * 100 ),
592- REG_UFS_CFG0 );
593- /*
594- * make sure that this configuration is applied before
595- * we return
596- */
597- mb ();
598- }
599-
600490 return 0 ;
601491}
602492
603493static int ufs_qcom_link_startup_notify (struct ufs_hba * hba ,
604494 enum ufs_notify_change_status status )
605495{
606496 int err = 0 ;
607- struct ufs_qcom_host * host = ufshcd_get_variant (hba );
608497
609498 switch (status ) {
610499 case PRE_CHANGE :
@@ -615,11 +504,9 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
615504 return - EINVAL ;
616505 }
617506
618- if (ufs_qcom_cap_qunipro (host )) {
619- err = ufs_qcom_set_core_clk_ctrl (hba , true);
620- if (err )
621- dev_err (hba -> dev , "cfg core clk ctrl failed\n" );
622- }
507+ err = ufs_qcom_set_core_clk_ctrl (hba , true);
508+ if (err )
509+ dev_err (hba -> dev , "cfg core clk ctrl failed\n" );
623510 /*
624511 * Some UFS devices (and may be host) have issues if LCC is
625512 * enabled. So we are setting PA_Local_TX_LCC_Enable to 0
@@ -918,12 +805,7 @@ static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
918805
919806static u32 ufs_qcom_get_ufs_hci_version (struct ufs_hba * hba )
920807{
921- struct ufs_qcom_host * host = ufshcd_get_variant (hba );
922-
923- if (host -> hw_ver .major == 0x1 )
924- return ufshci_version (1 , 1 );
925- else
926- return ufshci_version (2 , 0 );
808+ return ufshci_version (2 , 0 );
927809}
928810
929811/**
@@ -939,46 +821,21 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
939821{
940822 struct ufs_qcom_host * host = ufshcd_get_variant (hba );
941823
942- if (host -> hw_ver .major == 0x01 ) {
943- hba -> quirks |= UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS
944- | UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP
945- | UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE ;
946-
947- if (host -> hw_ver .minor == 0x0001 && host -> hw_ver .step == 0x0001 )
948- hba -> quirks |= UFSHCD_QUIRK_BROKEN_INTR_AGGR ;
949-
950- hba -> quirks |= UFSHCD_QUIRK_BROKEN_LCC ;
951- }
952-
953- if (host -> hw_ver .major == 0x2 ) {
824+ if (host -> hw_ver .major == 0x2 )
954825 hba -> quirks |= UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION ;
955826
956- if (!ufs_qcom_cap_qunipro (host ))
957- /* Legacy UniPro mode still need following quirks */
958- hba -> quirks |= (UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS
959- | UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE
960- | UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP );
961- }
962-
963827 if (host -> hw_ver .major > 0x3 )
964828 hba -> quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH ;
965829}
966830
967831static void ufs_qcom_set_caps (struct ufs_hba * hba )
968832{
969- struct ufs_qcom_host * host = ufshcd_get_variant (hba );
970-
971833 hba -> caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING ;
972834 hba -> caps |= UFSHCD_CAP_CLK_SCALING | UFSHCD_CAP_WB_WITH_CLK_SCALING ;
973835 hba -> caps |= UFSHCD_CAP_AUTO_BKOPS_SUSPEND ;
974836 hba -> caps |= UFSHCD_CAP_WB_EN ;
975837 hba -> caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE ;
976838 hba -> caps |= UFSHCD_CAP_RPM_AUTOSUSPEND ;
977-
978- if (host -> hw_ver .major >= 0x2 ) {
979- host -> caps = UFS_QCOM_CAP_QUNIPRO |
980- UFS_QCOM_CAP_RETAIN_SEC_CFG_AFTER_PWR_COLLAPSE ;
981- }
982839}
983840
984841/**
@@ -1101,9 +958,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
1101958{
1102959 int err ;
1103960 struct device * dev = hba -> dev ;
1104- struct platform_device * pdev = to_platform_device (dev );
1105961 struct ufs_qcom_host * host ;
1106- struct resource * res ;
1107962 struct ufs_clk_info * clki ;
1108963
1109964 host = devm_kzalloc (dev , sizeof (* host ), GFP_KERNEL );
@@ -1154,25 +1009,8 @@ static int ufs_qcom_init(struct ufs_hba *hba)
11541009 ufs_qcom_get_controller_revision (hba , & host -> hw_ver .major ,
11551010 & host -> hw_ver .minor , & host -> hw_ver .step );
11561011
1157- /*
1158- * for newer controllers, device reference clock control bit has
1159- * moved inside UFS controller register address space itself.
1160- */
1161- if (host -> hw_ver .major >= 0x02 ) {
1162- host -> dev_ref_clk_ctrl_mmio = hba -> mmio_base + REG_UFS_CFG1 ;
1163- host -> dev_ref_clk_en_mask = BIT (26 );
1164- } else {
1165- /* "dev_ref_clk_ctrl_mem" is optional resource */
1166- res = platform_get_resource_byname (pdev , IORESOURCE_MEM ,
1167- "dev_ref_clk_ctrl_mem" );
1168- if (res ) {
1169- host -> dev_ref_clk_ctrl_mmio =
1170- devm_ioremap_resource (dev , res );
1171- if (IS_ERR (host -> dev_ref_clk_ctrl_mmio ))
1172- host -> dev_ref_clk_ctrl_mmio = NULL ;
1173- host -> dev_ref_clk_en_mask = BIT (5 );
1174- }
1175- }
1012+ host -> dev_ref_clk_ctrl_mmio = hba -> mmio_base + REG_UFS_CFG1 ;
1013+ host -> dev_ref_clk_en_mask = BIT (26 );
11761014
11771015 list_for_each_entry (clki , & hba -> clk_list_head , list ) {
11781016 if (!strcmp (clki -> name , "core_clk_unipro" ))
@@ -1351,9 +1189,6 @@ static int ufs_qcom_clk_scale_up_pre_change(struct ufs_hba *hba)
13511189 struct ufs_pa_layer_attr * attr = & host -> dev_req_params ;
13521190 int ret ;
13531191
1354- if (!ufs_qcom_cap_qunipro (host ))
1355- return 0 ;
1356-
13571192 ret = ufs_qcom_cfg_timers (hba , attr -> gear_rx , attr -> pwr_rx ,
13581193 attr -> hs_rate , false, true);
13591194 if (ret ) {
@@ -1371,13 +1206,9 @@ static int ufs_qcom_clk_scale_up_post_change(struct ufs_hba *hba)
13711206
13721207static int ufs_qcom_clk_scale_down_pre_change (struct ufs_hba * hba )
13731208{
1374- struct ufs_qcom_host * host = ufshcd_get_variant (hba );
13751209 int err ;
13761210 u32 core_clk_ctrl_reg ;
13771211
1378- if (!ufs_qcom_cap_qunipro (host ))
1379- return 0 ;
1380-
13811212 err = ufshcd_dme_get (hba ,
13821213 UIC_ARG_MIB (DME_VS_CORE_CLK_CTRL ),
13831214 & core_clk_ctrl_reg );
@@ -1396,11 +1227,6 @@ static int ufs_qcom_clk_scale_down_pre_change(struct ufs_hba *hba)
13961227
13971228static int ufs_qcom_clk_scale_down_post_change (struct ufs_hba * hba )
13981229{
1399- struct ufs_qcom_host * host = ufshcd_get_variant (hba );
1400-
1401- if (!ufs_qcom_cap_qunipro (host ))
1402- return 0 ;
1403-
14041230 /* set unipro core clock attributes and clear clock divider */
14051231 return ufs_qcom_set_core_clk_ctrl (hba , false);
14061232}
0 commit comments