34
34
* Exynos's Vendor specific registers for UFSHCI
35
35
*/
36
36
#define HCI_TXPRDT_ENTRY_SIZE 0x00
37
- #define PRDT_PREFECT_EN BIT(31)
37
+ #define PRDT_PREFETCH_EN BIT(31)
38
38
#define HCI_RXPRDT_ENTRY_SIZE 0x04
39
39
#define HCI_1US_TO_CNT_VAL 0x0C
40
40
#define CNT_VAL_1US_MASK 0x3FF
92
92
UIC_TRANSPORT_NO_CONNECTION_RX |\
93
93
UIC_TRANSPORT_BAD_TC)
94
94
95
- /* FSYS UFS Shareability */
96
- #define UFS_WR_SHARABLE BIT(2)
97
- #define UFS_RD_SHARABLE BIT(1)
98
- #define UFS_SHARABLE (UFS_WR_SHARABLE | UFS_RD_SHARABLE)
99
- #define UFS_SHAREABILITY_OFFSET 0x710
95
+ /* UFS Shareability */
96
+ #define UFS_EXYNOSAUTO_WR_SHARABLE BIT(2)
97
+ #define UFS_EXYNOSAUTO_RD_SHARABLE BIT(1)
98
+ #define UFS_EXYNOSAUTO_SHARABLE (UFS_EXYNOSAUTO_WR_SHARABLE | \
99
+ UFS_EXYNOSAUTO_RD_SHARABLE)
100
+ #define UFS_GS101_WR_SHARABLE BIT(1)
101
+ #define UFS_GS101_RD_SHARABLE BIT(0)
102
+ #define UFS_GS101_SHARABLE (UFS_GS101_WR_SHARABLE | \
103
+ UFS_GS101_RD_SHARABLE)
104
+ #define UFS_SHAREABILITY_OFFSET 0x710
100
105
101
106
/* Multi-host registers */
102
107
#define MHCTRL 0xC4
@@ -209,8 +214,8 @@ static int exynos_ufs_shareability(struct exynos_ufs *ufs)
209
214
/* IO Coherency setting */
210
215
if (ufs -> sysreg ) {
211
216
return regmap_update_bits (ufs -> sysreg ,
212
- ufs -> shareability_reg_offset ,
213
- UFS_SHARABLE , UFS_SHARABLE );
217
+ ufs -> iocc_offset ,
218
+ ufs -> iocc_mask , ufs -> iocc_val );
214
219
}
215
220
216
221
return 0 ;
@@ -957,6 +962,12 @@ static int exynos_ufs_phy_init(struct exynos_ufs *ufs)
957
962
}
958
963
959
964
phy_set_bus_width (generic_phy , ufs -> avail_ln_rx );
965
+
966
+ if (generic_phy -> power_count ) {
967
+ phy_power_off (generic_phy );
968
+ phy_exit (generic_phy );
969
+ }
970
+
960
971
ret = phy_init (generic_phy );
961
972
if (ret ) {
962
973
dev_err (hba -> dev , "%s: phy init failed, ret = %d\n" ,
@@ -1049,21 +1060,21 @@ static int exynos_ufs_pre_link(struct ufs_hba *hba)
1049
1060
exynos_ufs_config_intr (ufs , DFES_DEF_L4_ERRS , UNIPRO_L4 );
1050
1061
exynos_ufs_set_unipro_pclk_div (ufs );
1051
1062
1063
+ exynos_ufs_setup_clocks (hba , true, PRE_CHANGE );
1064
+
1052
1065
/* unipro */
1053
1066
exynos_ufs_config_unipro (ufs );
1054
1067
1068
+ if (ufs -> drv_data -> pre_link )
1069
+ ufs -> drv_data -> pre_link (ufs );
1070
+
1055
1071
/* m-phy */
1056
1072
exynos_ufs_phy_init (ufs );
1057
1073
if (!(ufs -> opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR )) {
1058
1074
exynos_ufs_config_phy_time_attr (ufs );
1059
1075
exynos_ufs_config_phy_cap_attr (ufs );
1060
1076
}
1061
1077
1062
- exynos_ufs_setup_clocks (hba , true, PRE_CHANGE );
1063
-
1064
- if (ufs -> drv_data -> pre_link )
1065
- ufs -> drv_data -> pre_link (ufs );
1066
-
1067
1078
return 0 ;
1068
1079
}
1069
1080
@@ -1087,12 +1098,17 @@ static int exynos_ufs_post_link(struct ufs_hba *hba)
1087
1098
struct exynos_ufs * ufs = ufshcd_get_variant (hba );
1088
1099
struct phy * generic_phy = ufs -> phy ;
1089
1100
struct exynos_ufs_uic_attr * attr = ufs -> drv_data -> uic_attr ;
1101
+ u32 val = ilog2 (DATA_UNIT_SIZE );
1090
1102
1091
1103
exynos_ufs_establish_connt (ufs );
1092
1104
exynos_ufs_fit_aggr_timeout (ufs );
1093
1105
1094
1106
hci_writel (ufs , 0xa , HCI_DATA_REORDER );
1095
- hci_writel (ufs , ilog2 (DATA_UNIT_SIZE ), HCI_TXPRDT_ENTRY_SIZE );
1107
+
1108
+ if (hba -> caps & UFSHCD_CAP_CRYPTO )
1109
+ val |= PRDT_PREFETCH_EN ;
1110
+ hci_writel (ufs , val , HCI_TXPRDT_ENTRY_SIZE );
1111
+
1096
1112
hci_writel (ufs , ilog2 (DATA_UNIT_SIZE ), HCI_RXPRDT_ENTRY_SIZE );
1097
1113
hci_writel (ufs , (1 << hba -> nutrs ) - 1 , HCI_UTRL_NEXUS_TYPE );
1098
1114
hci_writel (ufs , (1 << hba -> nutmrs ) - 1 , HCI_UTMRL_NEXUS_TYPE );
@@ -1168,12 +1184,22 @@ static int exynos_ufs_parse_dt(struct device *dev, struct exynos_ufs *ufs)
1168
1184
ufs -> sysreg = NULL ;
1169
1185
else {
1170
1186
if (of_property_read_u32_index (np , "samsung,sysreg" , 1 ,
1171
- & ufs -> shareability_reg_offset )) {
1187
+ & ufs -> iocc_offset )) {
1172
1188
dev_warn (dev , "can't get an offset from sysreg. Set to default value\n" );
1173
- ufs -> shareability_reg_offset = UFS_SHAREABILITY_OFFSET ;
1189
+ ufs -> iocc_offset = UFS_SHAREABILITY_OFFSET ;
1174
1190
}
1175
1191
}
1176
1192
1193
+ ufs -> iocc_mask = ufs -> drv_data -> iocc_mask ;
1194
+ /*
1195
+ * no 'dma-coherent' property means the descriptors are
1196
+ * non-cacheable so iocc shareability should be disabled.
1197
+ */
1198
+ if (of_dma_is_coherent (dev -> of_node ))
1199
+ ufs -> iocc_val = ufs -> iocc_mask ;
1200
+ else
1201
+ ufs -> iocc_val = 0 ;
1202
+
1177
1203
ufs -> pclk_avail_min = PCLK_AVAIL_MIN ;
1178
1204
ufs -> pclk_avail_max = PCLK_AVAIL_MAX ;
1179
1205
@@ -1496,6 +1522,14 @@ static int exynos_ufs_init(struct ufs_hba *hba)
1496
1522
return ret ;
1497
1523
}
1498
1524
1525
+ static void exynos_ufs_exit (struct ufs_hba * hba )
1526
+ {
1527
+ struct exynos_ufs * ufs = ufshcd_get_variant (hba );
1528
+
1529
+ phy_power_off (ufs -> phy );
1530
+ phy_exit (ufs -> phy );
1531
+ }
1532
+
1499
1533
static int exynos_ufs_host_reset (struct ufs_hba * hba )
1500
1534
{
1501
1535
struct exynos_ufs * ufs = ufshcd_get_variant (hba );
@@ -1666,6 +1700,12 @@ static void exynos_ufs_hibern8_notify(struct ufs_hba *hba,
1666
1700
}
1667
1701
}
1668
1702
1703
+ static int gs101_ufs_suspend (struct exynos_ufs * ufs )
1704
+ {
1705
+ hci_writel (ufs , 0 << 0 , HCI_GPIO_OUT );
1706
+ return 0 ;
1707
+ }
1708
+
1669
1709
static int exynos_ufs_suspend (struct ufs_hba * hba , enum ufs_pm_op pm_op ,
1670
1710
enum ufs_notify_change_status status )
1671
1711
{
@@ -1674,6 +1714,9 @@ static int exynos_ufs_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
1674
1714
if (status == PRE_CHANGE )
1675
1715
return 0 ;
1676
1716
1717
+ if (ufs -> drv_data -> suspend )
1718
+ ufs -> drv_data -> suspend (ufs );
1719
+
1677
1720
if (!ufshcd_is_link_active (hba ))
1678
1721
phy_power_off (ufs -> phy );
1679
1722
@@ -1951,6 +1994,7 @@ static int gs101_ufs_pre_pwr_change(struct exynos_ufs *ufs,
1951
1994
static const struct ufs_hba_variant_ops ufs_hba_exynos_ops = {
1952
1995
.name = "exynos_ufs" ,
1953
1996
.init = exynos_ufs_init ,
1997
+ .exit = exynos_ufs_exit ,
1954
1998
.hce_enable_notify = exynos_ufs_hce_enable_notify ,
1955
1999
.link_startup_notify = exynos_ufs_link_startup_notify ,
1956
2000
.pwr_change_notify = exynos_ufs_pwr_change_notify ,
@@ -1989,13 +2033,7 @@ static int exynos_ufs_probe(struct platform_device *pdev)
1989
2033
1990
2034
static void exynos_ufs_remove (struct platform_device * pdev )
1991
2035
{
1992
- struct ufs_hba * hba = platform_get_drvdata (pdev );
1993
- struct exynos_ufs * ufs = ufshcd_get_variant (hba );
1994
-
1995
2036
ufshcd_pltfrm_remove (pdev );
1996
-
1997
- phy_power_off (ufs -> phy );
1998
- phy_exit (ufs -> phy );
1999
2037
}
2000
2038
2001
2039
static struct exynos_ufs_uic_attr exynos7_uic_attr = {
@@ -2034,6 +2072,7 @@ static const struct exynos_ufs_drv_data exynosauto_ufs_drvs = {
2034
2072
.opts = EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
2035
2073
EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
2036
2074
EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX ,
2075
+ .iocc_mask = UFS_EXYNOSAUTO_SHARABLE ,
2037
2076
.drv_init = exynosauto_ufs_drv_init ,
2038
2077
.post_hce_enable = exynosauto_ufs_post_hce_enable ,
2039
2078
.pre_link = exynosauto_ufs_pre_link ,
@@ -2135,10 +2174,12 @@ static const struct exynos_ufs_drv_data gs101_ufs_drvs = {
2135
2174
.opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
2136
2175
EXYNOS_UFS_OPT_UFSPR_SECURE |
2137
2176
EXYNOS_UFS_OPT_TIMER_TICK_SELECT ,
2177
+ .iocc_mask = UFS_GS101_SHARABLE ,
2138
2178
.drv_init = gs101_ufs_drv_init ,
2139
2179
.pre_link = gs101_ufs_pre_link ,
2140
2180
.post_link = gs101_ufs_post_link ,
2141
2181
.pre_pwr_change = gs101_ufs_pre_pwr_change ,
2182
+ .suspend = gs101_ufs_suspend ,
2142
2183
};
2143
2184
2144
2185
static const struct of_device_id exynos_ufs_of_match [] = {
0 commit comments