@@ -1043,7 +1043,8 @@ static void dw_mci_push_data16(struct dw_mci *host, void *buf, int cnt)
10431043 buf += len ;
10441044 cnt -= len ;
10451045 if (!sg_next (host -> sg ) || host -> part_buf_count == 2 ) {
1046- mci_writew (host , DATA , host -> part_buf16 );
1046+ mci_writew (host , DATA (host -> data_offset ),
1047+ host -> part_buf16 );
10471048 host -> part_buf_count = 0 ;
10481049 }
10491050 }
@@ -1060,21 +1061,23 @@ static void dw_mci_push_data16(struct dw_mci *host, void *buf, int cnt)
10601061 cnt -= len ;
10611062 /* push data from aligned buffer into fifo */
10621063 for (i = 0 ; i < items ; ++ i )
1063- mci_writew (host , DATA , aligned_buf [i ]);
1064+ mci_writew (host , DATA (host -> data_offset ),
1065+ aligned_buf [i ]);
10641066 }
10651067 } else
10661068#endif
10671069 {
10681070 u16 * pdata = buf ;
10691071 for (; cnt >= 2 ; cnt -= 2 )
1070- mci_writew (host , DATA , * pdata ++ );
1072+ mci_writew (host , DATA ( host -> data_offset ) , * pdata ++ );
10711073 buf = pdata ;
10721074 }
10731075 /* put anything remaining in the part_buf */
10741076 if (cnt ) {
10751077 dw_mci_set_part_bytes (host , buf , cnt );
10761078 if (!sg_next (host -> sg ))
1077- mci_writew (host , DATA , host -> part_buf16 );
1079+ mci_writew (host , DATA (host -> data_offset ),
1080+ host -> part_buf16 );
10781081 }
10791082}
10801083
@@ -1089,7 +1092,8 @@ static void dw_mci_pull_data16(struct dw_mci *host, void *buf, int cnt)
10891092 int items = len >> 1 ;
10901093 int i ;
10911094 for (i = 0 ; i < items ; ++ i )
1092- aligned_buf [i ] = mci_readw (host , DATA );
1095+ aligned_buf [i ] = mci_readw (host ,
1096+ DATA (host -> data_offset ));
10931097 /* memcpy from aligned buffer into output buffer */
10941098 memcpy (buf , aligned_buf , len );
10951099 buf += len ;
@@ -1100,11 +1104,11 @@ static void dw_mci_pull_data16(struct dw_mci *host, void *buf, int cnt)
11001104 {
11011105 u16 * pdata = buf ;
11021106 for (; cnt >= 2 ; cnt -= 2 )
1103- * pdata ++ = mci_readw (host , DATA );
1107+ * pdata ++ = mci_readw (host , DATA ( host -> data_offset ) );
11041108 buf = pdata ;
11051109 }
11061110 if (cnt ) {
1107- host -> part_buf16 = mci_readw (host , DATA );
1111+ host -> part_buf16 = mci_readw (host , DATA ( host -> data_offset ) );
11081112 dw_mci_pull_final_bytes (host , buf , cnt );
11091113 }
11101114}
@@ -1117,7 +1121,8 @@ static void dw_mci_push_data32(struct dw_mci *host, void *buf, int cnt)
11171121 buf += len ;
11181122 cnt -= len ;
11191123 if (!sg_next (host -> sg ) || host -> part_buf_count == 4 ) {
1120- mci_writel (host , DATA , host -> part_buf32 );
1124+ mci_writel (host , DATA (host -> data_offset ),
1125+ host -> part_buf32 );
11211126 host -> part_buf_count = 0 ;
11221127 }
11231128 }
@@ -1134,21 +1139,23 @@ static void dw_mci_push_data32(struct dw_mci *host, void *buf, int cnt)
11341139 cnt -= len ;
11351140 /* push data from aligned buffer into fifo */
11361141 for (i = 0 ; i < items ; ++ i )
1137- mci_writel (host , DATA , aligned_buf [i ]);
1142+ mci_writel (host , DATA (host -> data_offset ),
1143+ aligned_buf [i ]);
11381144 }
11391145 } else
11401146#endif
11411147 {
11421148 u32 * pdata = buf ;
11431149 for (; cnt >= 4 ; cnt -= 4 )
1144- mci_writel (host , DATA , * pdata ++ );
1150+ mci_writel (host , DATA ( host -> data_offset ) , * pdata ++ );
11451151 buf = pdata ;
11461152 }
11471153 /* put anything remaining in the part_buf */
11481154 if (cnt ) {
11491155 dw_mci_set_part_bytes (host , buf , cnt );
11501156 if (!sg_next (host -> sg ))
1151- mci_writel (host , DATA , host -> part_buf32 );
1157+ mci_writel (host , DATA (host -> data_offset ),
1158+ host -> part_buf32 );
11521159 }
11531160}
11541161
@@ -1163,7 +1170,8 @@ static void dw_mci_pull_data32(struct dw_mci *host, void *buf, int cnt)
11631170 int items = len >> 2 ;
11641171 int i ;
11651172 for (i = 0 ; i < items ; ++ i )
1166- aligned_buf [i ] = mci_readl (host , DATA );
1173+ aligned_buf [i ] = mci_readl (host ,
1174+ DATA (host -> data_offset ));
11671175 /* memcpy from aligned buffer into output buffer */
11681176 memcpy (buf , aligned_buf , len );
11691177 buf += len ;
@@ -1174,11 +1182,11 @@ static void dw_mci_pull_data32(struct dw_mci *host, void *buf, int cnt)
11741182 {
11751183 u32 * pdata = buf ;
11761184 for (; cnt >= 4 ; cnt -= 4 )
1177- * pdata ++ = mci_readl (host , DATA );
1185+ * pdata ++ = mci_readl (host , DATA ( host -> data_offset ) );
11781186 buf = pdata ;
11791187 }
11801188 if (cnt ) {
1181- host -> part_buf32 = mci_readl (host , DATA );
1189+ host -> part_buf32 = mci_readl (host , DATA ( host -> data_offset ) );
11821190 dw_mci_pull_final_bytes (host , buf , cnt );
11831191 }
11841192}
@@ -1191,7 +1199,8 @@ static void dw_mci_push_data64(struct dw_mci *host, void *buf, int cnt)
11911199 buf += len ;
11921200 cnt -= len ;
11931201 if (!sg_next (host -> sg ) || host -> part_buf_count == 8 ) {
1194- mci_writew (host , DATA , host -> part_buf );
1202+ mci_writew (host , DATA (host -> data_offset ),
1203+ host -> part_buf );
11951204 host -> part_buf_count = 0 ;
11961205 }
11971206 }
@@ -1208,21 +1217,23 @@ static void dw_mci_push_data64(struct dw_mci *host, void *buf, int cnt)
12081217 cnt -= len ;
12091218 /* push data from aligned buffer into fifo */
12101219 for (i = 0 ; i < items ; ++ i )
1211- mci_writeq (host , DATA , aligned_buf [i ]);
1220+ mci_writeq (host , DATA (host -> data_offset ),
1221+ aligned_buf [i ]);
12121222 }
12131223 } else
12141224#endif
12151225 {
12161226 u64 * pdata = buf ;
12171227 for (; cnt >= 8 ; cnt -= 8 )
1218- mci_writeq (host , DATA , * pdata ++ );
1228+ mci_writeq (host , DATA ( host -> data_offset ) , * pdata ++ );
12191229 buf = pdata ;
12201230 }
12211231 /* put anything remaining in the part_buf */
12221232 if (cnt ) {
12231233 dw_mci_set_part_bytes (host , buf , cnt );
12241234 if (!sg_next (host -> sg ))
1225- mci_writeq (host , DATA , host -> part_buf );
1235+ mci_writeq (host , DATA (host -> data_offset ),
1236+ host -> part_buf );
12261237 }
12271238}
12281239
@@ -1237,7 +1248,8 @@ static void dw_mci_pull_data64(struct dw_mci *host, void *buf, int cnt)
12371248 int items = len >> 3 ;
12381249 int i ;
12391250 for (i = 0 ; i < items ; ++ i )
1240- aligned_buf [i ] = mci_readq (host , DATA );
1251+ aligned_buf [i ] = mci_readq (host ,
1252+ DATA (host -> data_offset ));
12411253 /* memcpy from aligned buffer into output buffer */
12421254 memcpy (buf , aligned_buf , len );
12431255 buf += len ;
@@ -1248,11 +1260,11 @@ static void dw_mci_pull_data64(struct dw_mci *host, void *buf, int cnt)
12481260 {
12491261 u64 * pdata = buf ;
12501262 for (; cnt >= 8 ; cnt -= 8 )
1251- * pdata ++ = mci_readq (host , DATA );
1263+ * pdata ++ = mci_readq (host , DATA ( host -> data_offset ) );
12521264 buf = pdata ;
12531265 }
12541266 if (cnt ) {
1255- host -> part_buf = mci_readq (host , DATA );
1267+ host -> part_buf = mci_readq (host , DATA ( host -> data_offset ) );
12561268 dw_mci_pull_final_bytes (host , buf , cnt );
12571269 }
12581270}
@@ -1951,6 +1963,18 @@ static int dw_mci_probe(struct platform_device *pdev)
19511963 }
19521964 }
19531965
1966+ /*
1967+ * In 2.40a spec, Data offset is changed.
1968+ * Need to check the version-id and set data-offset for DATA register.
1969+ */
1970+ host -> verid = SDMMC_GET_VERID (mci_readl (host , VERID ));
1971+ dev_info (& pdev -> dev , "Version ID is %04x\n" , host -> verid );
1972+
1973+ if (host -> verid < DW_MMC_240A )
1974+ host -> data_offset = DATA_OFFSET ;
1975+ else
1976+ host -> data_offset = DATA_240A_OFFSET ;
1977+
19541978 /*
19551979 * Enable interrupts for command done, data over, data empty, card det,
19561980 * receive ready and error such as transmit, receive timeout, crc error
0 commit comments