48
48
#define HCI_UNIPRO_APB_CLK_CTRL 0x68
49
49
#define UNIPRO_APB_CLK (v , x ) (((v) & ~0xF) | ((x) & 0xF))
50
50
#define HCI_AXIDMA_RWDATA_BURST_LEN 0x6C
51
+ #define WLU_EN BIT(31)
52
+ #define WLU_BURST_LEN (x ) ((x) << 27 | ((x) & 0xF))
51
53
#define HCI_GPIO_OUT 0x70
52
54
#define HCI_ERR_EN_PA_LAYER 0x78
53
55
#define HCI_ERR_EN_DL_LAYER 0x7C
74
76
#define CLK_CTRL_EN_MASK (REFCLK_CTRL_EN |\
75
77
UNIPRO_PCLK_CTRL_EN |\
76
78
UNIPRO_MCLK_CTRL_EN)
79
+
80
+ #define HCI_IOP_ACG_DISABLE 0x100
81
+ #define HCI_IOP_ACG_DISABLE_EN BIT(0)
82
+
77
83
/* Device fatal error */
78
84
#define DFES_ERR_EN BIT(31)
79
85
#define DFES_DEF_L2_ERRS (UIC_DATA_LINK_LAYER_ERROR_RX_BUF_OF |\
@@ -198,27 +204,41 @@ static inline void exynos_ufs_ungate_clks(struct exynos_ufs *ufs)
198
204
exynos_ufs_ctrl_clkstop (ufs , false);
199
205
}
200
206
201
- static int exynos7_ufs_drv_init (struct device * dev , struct exynos_ufs * ufs )
202
- {
203
- return 0 ;
204
- }
205
-
206
- static int exynosauto_ufs_drv_init (struct device * dev , struct exynos_ufs * ufs )
207
+ static int exynos_ufs_shareability (struct exynos_ufs * ufs )
207
208
{
208
- struct exynos_ufs_uic_attr * attr = ufs -> drv_data -> uic_attr ;
209
-
210
209
/* IO Coherency setting */
211
210
if (ufs -> sysreg ) {
212
211
return regmap_update_bits (ufs -> sysreg ,
213
212
ufs -> shareability_reg_offset ,
214
213
UFS_SHARABLE , UFS_SHARABLE );
215
214
}
216
215
217
- attr -> tx_dif_p_nsec = 3200000 ;
218
-
219
216
return 0 ;
220
217
}
221
218
219
+ static int gs101_ufs_drv_init (struct exynos_ufs * ufs )
220
+ {
221
+ struct ufs_hba * hba = ufs -> hba ;
222
+ u32 reg ;
223
+
224
+ /* Enable WriteBooster */
225
+ hba -> caps |= UFSHCD_CAP_WB_EN ;
226
+
227
+ /* Enable clock gating and hibern8 */
228
+ hba -> caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING ;
229
+
230
+ /* set ACG to be controlled by UFS_ACG_DISABLE */
231
+ reg = hci_readl (ufs , HCI_IOP_ACG_DISABLE );
232
+ hci_writel (ufs , reg & (~HCI_IOP_ACG_DISABLE_EN ), HCI_IOP_ACG_DISABLE );
233
+
234
+ return exynos_ufs_shareability (ufs );
235
+ }
236
+
237
+ static int exynosauto_ufs_drv_init (struct exynos_ufs * ufs )
238
+ {
239
+ return exynos_ufs_shareability (ufs );
240
+ }
241
+
222
242
static int exynosauto_ufs_post_hce_enable (struct exynos_ufs * ufs )
223
243
{
224
244
struct ufs_hba * hba = ufs -> hba ;
@@ -546,6 +566,9 @@ static void exynos_ufs_specify_phy_time_attr(struct exynos_ufs *ufs)
546
566
struct exynos_ufs_uic_attr * attr = ufs -> drv_data -> uic_attr ;
547
567
struct ufs_phy_time_cfg * t_cfg = & ufs -> t_cfg ;
548
568
569
+ if (ufs -> opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR )
570
+ return ;
571
+
549
572
t_cfg -> tx_linereset_p =
550
573
exynos_ufs_calc_time_cntr (ufs , attr -> tx_dif_p_nsec );
551
574
t_cfg -> tx_linereset_n =
@@ -724,6 +747,9 @@ static void exynos_ufs_config_smu(struct exynos_ufs *ufs)
724
747
{
725
748
u32 reg , val ;
726
749
750
+ if (ufs -> opts & EXYNOS_UFS_OPT_UFSPR_SECURE )
751
+ return ;
752
+
727
753
exynos_ufs_disable_auto_ctrl_hcc_save (ufs , & val );
728
754
729
755
/* make encryption disabled by default */
@@ -771,6 +797,21 @@ static void exynos_ufs_config_sync_pattern_mask(struct exynos_ufs *ufs,
771
797
exynos_ufs_disable_ov_tm (hba );
772
798
}
773
799
800
+ #define UFS_HW_VER_MAJOR_MASK GENMASK(15, 8)
801
+
802
+ static u32 exynos_ufs_get_hs_gear (struct ufs_hba * hba )
803
+ {
804
+ u8 major ;
805
+
806
+ major = FIELD_GET (UFS_HW_VER_MAJOR_MASK , hba -> ufs_version );
807
+
808
+ if (major >= 3 )
809
+ return UFS_HS_G4 ;
810
+
811
+ /* Default is HS-G3 */
812
+ return UFS_HS_G3 ;
813
+ }
814
+
774
815
static int exynos_ufs_pre_pwr_mode (struct ufs_hba * hba ,
775
816
struct ufs_pa_layer_attr * dev_max_params ,
776
817
struct ufs_pa_layer_attr * dev_req_params )
@@ -788,6 +829,10 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
788
829
789
830
ufshcd_init_host_params (& host_params );
790
831
832
+ /* This driver only support symmetric gear setting e.g. hs_tx_gear == hs_rx_gear */
833
+ host_params .hs_tx_gear = exynos_ufs_get_hs_gear (hba );
834
+ host_params .hs_rx_gear = exynos_ufs_get_hs_gear (hba );
835
+
791
836
ret = ufshcd_negotiate_pwr_params (& host_params , dev_max_params , dev_req_params );
792
837
if (ret ) {
793
838
pr_err ("%s: failed to determine capabilities\n" , __func__ );
@@ -1429,7 +1474,7 @@ static int exynos_ufs_init(struct ufs_hba *hba)
1429
1474
exynos_ufs_fmp_init (hba , ufs );
1430
1475
1431
1476
if (ufs -> drv_data -> drv_init ) {
1432
- ret = ufs -> drv_data -> drv_init (dev , ufs );
1477
+ ret = ufs -> drv_data -> drv_init (ufs );
1433
1478
if (ret ) {
1434
1479
dev_err (dev , "failed to init drv-data\n" );
1435
1480
goto out ;
@@ -1440,8 +1485,8 @@ static int exynos_ufs_init(struct ufs_hba *hba)
1440
1485
if (ret )
1441
1486
goto out ;
1442
1487
exynos_ufs_specify_phy_time_attr (ufs );
1443
- if (!( ufs -> opts & EXYNOS_UFS_OPT_UFSPR_SECURE ))
1444
- exynos_ufs_config_smu (ufs );
1488
+
1489
+ exynos_ufs_config_smu (ufs );
1445
1490
1446
1491
hba -> host -> dma_alignment = DATA_UNIT_SIZE - 1 ;
1447
1492
return 0 ;
@@ -1484,12 +1529,12 @@ static void exynos_ufs_dev_hw_reset(struct ufs_hba *hba)
1484
1529
hci_writel (ufs , 1 << 0 , HCI_GPIO_OUT );
1485
1530
}
1486
1531
1487
- static void exynos_ufs_pre_hibern8 (struct ufs_hba * hba , u8 enter )
1532
+ static void exynos_ufs_pre_hibern8 (struct ufs_hba * hba , enum uic_cmd_dme cmd )
1488
1533
{
1489
1534
struct exynos_ufs * ufs = ufshcd_get_variant (hba );
1490
1535
struct exynos_ufs_uic_attr * attr = ufs -> drv_data -> uic_attr ;
1491
1536
1492
- if (! enter ) {
1537
+ if (cmd == UIC_CMD_DME_HIBER_EXIT ) {
1493
1538
if (ufs -> opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL )
1494
1539
exynos_ufs_disable_auto_ctrl_hcc (ufs );
1495
1540
exynos_ufs_ungate_clks (ufs );
@@ -1517,30 +1562,11 @@ static void exynos_ufs_pre_hibern8(struct ufs_hba *hba, u8 enter)
1517
1562
}
1518
1563
}
1519
1564
1520
- static void exynos_ufs_post_hibern8 (struct ufs_hba * hba , u8 enter )
1565
+ static void exynos_ufs_post_hibern8 (struct ufs_hba * hba , enum uic_cmd_dme cmd )
1521
1566
{
1522
1567
struct exynos_ufs * ufs = ufshcd_get_variant (hba );
1523
1568
1524
- if (!enter ) {
1525
- u32 cur_mode = 0 ;
1526
- u32 pwrmode ;
1527
-
1528
- if (ufshcd_is_hs_mode (& ufs -> dev_req_params ))
1529
- pwrmode = FAST_MODE ;
1530
- else
1531
- pwrmode = SLOW_MODE ;
1532
-
1533
- ufshcd_dme_get (hba , UIC_ARG_MIB (PA_PWRMODE ), & cur_mode );
1534
- if (cur_mode != (pwrmode << 4 | pwrmode )) {
1535
- dev_warn (hba -> dev , "%s: power mode change\n" , __func__ );
1536
- hba -> pwr_info .pwr_rx = (cur_mode >> 4 ) & 0xf ;
1537
- hba -> pwr_info .pwr_tx = cur_mode & 0xf ;
1538
- ufshcd_config_pwr_mode (hba , & hba -> max_pwr_info .info );
1539
- }
1540
-
1541
- if (!(ufs -> opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB ))
1542
- exynos_ufs_establish_connt (ufs );
1543
- } else {
1569
+ if (cmd == UIC_CMD_DME_HIBER_ENTER ) {
1544
1570
ufs -> entry_hibern8_t = ktime_get ();
1545
1571
exynos_ufs_gate_clks (ufs );
1546
1572
if (ufs -> opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL )
@@ -1627,15 +1653,15 @@ static int exynos_ufs_pwr_change_notify(struct ufs_hba *hba,
1627
1653
}
1628
1654
1629
1655
static void exynos_ufs_hibern8_notify (struct ufs_hba * hba ,
1630
- enum uic_cmd_dme enter ,
1656
+ enum uic_cmd_dme cmd ,
1631
1657
enum ufs_notify_change_status notify )
1632
1658
{
1633
1659
switch ((u8 )notify ) {
1634
1660
case PRE_CHANGE :
1635
- exynos_ufs_pre_hibern8 (hba , enter );
1661
+ exynos_ufs_pre_hibern8 (hba , cmd );
1636
1662
break ;
1637
1663
case POST_CHANGE :
1638
- exynos_ufs_post_hibern8 (hba , enter );
1664
+ exynos_ufs_post_hibern8 (hba , cmd );
1639
1665
break ;
1640
1666
}
1641
1667
}
@@ -1891,6 +1917,12 @@ static int gs101_ufs_post_link(struct exynos_ufs *ufs)
1891
1917
{
1892
1918
struct ufs_hba * hba = ufs -> hba ;
1893
1919
1920
+ /*
1921
+ * Enable Write Line Unique. This field has to be 0x3
1922
+ * to support Write Line Unique transaction on gs101.
1923
+ */
1924
+ hci_writel (ufs , WLU_EN | WLU_BURST_LEN (3 ), HCI_AXIDMA_RWDATA_BURST_LEN );
1925
+
1894
1926
exynos_ufs_enable_dbg_mode (hba );
1895
1927
ufshcd_dme_set (hba , UIC_ARG_MIB (PA_SAVECONFIGTIME ), 0x3e8 );
1896
1928
exynos_ufs_disable_dbg_mode (hba );
@@ -2036,7 +2068,6 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {
2036
2068
EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX |
2037
2069
EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB |
2038
2070
EXYNOS_UFS_OPT_USE_SW_HIBERN8_TIMER ,
2039
- .drv_init = exynos7_ufs_drv_init ,
2040
2071
.pre_link = exynos7_ufs_pre_link ,
2041
2072
.post_link = exynos7_ufs_post_link ,
2042
2073
.pre_pwr_change = exynos7_ufs_pre_pwr_change ,
@@ -2045,26 +2076,6 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {
2045
2076
2046
2077
static struct exynos_ufs_uic_attr gs101_uic_attr = {
2047
2078
.tx_trailingclks = 0xff ,
2048
- .tx_dif_p_nsec = 3000000 , /* unit: ns */
2049
- .tx_dif_n_nsec = 1000000 , /* unit: ns */
2050
- .tx_high_z_cnt_nsec = 20000 , /* unit: ns */
2051
- .tx_base_unit_nsec = 100000 , /* unit: ns */
2052
- .tx_gran_unit_nsec = 4000 , /* unit: ns */
2053
- .tx_sleep_cnt = 1000 , /* unit: ns */
2054
- .tx_min_activatetime = 0xa ,
2055
- .rx_filler_enable = 0x2 ,
2056
- .rx_dif_p_nsec = 1000000 , /* unit: ns */
2057
- .rx_hibern8_wait_nsec = 4000000 , /* unit: ns */
2058
- .rx_base_unit_nsec = 100000 , /* unit: ns */
2059
- .rx_gran_unit_nsec = 4000 , /* unit: ns */
2060
- .rx_sleep_cnt = 1280 , /* unit: ns */
2061
- .rx_stall_cnt = 320 , /* unit: ns */
2062
- .rx_hs_g1_sync_len_cap = SYNC_LEN_COARSE (0xf ),
2063
- .rx_hs_g2_sync_len_cap = SYNC_LEN_COARSE (0xf ),
2064
- .rx_hs_g3_sync_len_cap = SYNC_LEN_COARSE (0xf ),
2065
- .rx_hs_g1_prep_sync_len_cap = PREP_LEN (0xf ),
2066
- .rx_hs_g2_prep_sync_len_cap = PREP_LEN (0xf ),
2067
- .rx_hs_g3_prep_sync_len_cap = PREP_LEN (0xf ),
2068
2079
.pa_dbg_opt_suite1_val = 0x90913C1C ,
2069
2080
.pa_dbg_opt_suite1_off = PA_GS101_DBG_OPTION_SUITE1 ,
2070
2081
.pa_dbg_opt_suite2_val = 0xE01C115F ,
@@ -2122,11 +2133,10 @@ static const struct exynos_ufs_drv_data gs101_ufs_drvs = {
2122
2133
UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
2123
2134
UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |
2124
2135
UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING ,
2125
- .opts = EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
2126
- EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
2136
+ .opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
2127
2137
EXYNOS_UFS_OPT_UFSPR_SECURE |
2128
2138
EXYNOS_UFS_OPT_TIMER_TICK_SELECT ,
2129
- .drv_init = exynosauto_ufs_drv_init ,
2139
+ .drv_init = gs101_ufs_drv_init ,
2130
2140
.pre_link = gs101_ufs_pre_link ,
2131
2141
.post_link = gs101_ufs_post_link ,
2132
2142
.pre_pwr_change = gs101_ufs_pre_pwr_change ,
0 commit comments