@@ -310,13 +310,22 @@ static int eip197_load_firmwares(struct safexcel_crypto_priv *priv)
310
310
static int safexcel_hw_setup_cdesc_rings (struct safexcel_crypto_priv * priv )
311
311
{
312
312
u32 hdw , cd_size_rnd , val ;
313
- int i ;
313
+ int i , cd_fetch_cnt ;
314
314
315
- hdw = readl (EIP197_HIA_AIC_G (priv ) + EIP197_HIA_OPTIONS );
316
- hdw &= GENMASK (27 , 25 );
317
- hdw >>= 25 ;
318
-
319
- cd_size_rnd = (priv -> config .cd_size + (BIT (hdw ) - 1 )) >> hdw ;
315
+ cd_size_rnd = (priv -> config .cd_size +
316
+ (BIT (priv -> hwconfig .hwdataw ) - 1 )) >>
317
+ priv -> hwconfig .hwdataw ;
318
+ /* determine number of CD's we can fetch into the CD FIFO as 1 block */
319
+ if (priv -> flags & SAFEXCEL_HW_EIP197 ) {
320
+ /* EIP197: try to fetch enough in 1 go to keep all pipes busy */
321
+ cd_fetch_cnt = (1 << priv -> hwconfig .hwcfsize ) / cd_size_rnd ;
322
+ cd_fetch_cnt = min_t (uint , cd_fetch_cnt ,
323
+ (priv -> config .pes * EIP197_FETCH_DEPTH ));
324
+ } else {
325
+ /* for the EIP97, just fetch all that fits minus 1 */
326
+ cd_fetch_cnt = ((1 << priv -> hwconfig .hwcfsize ) /
327
+ cd_size_rnd ) - 1 ;
328
+ }
320
329
321
330
for (i = 0 ; i < priv -> config .rings ; i ++ ) {
322
331
/* ring base address */
@@ -328,8 +337,8 @@ static int safexcel_hw_setup_cdesc_rings(struct safexcel_crypto_priv *priv)
328
337
writel (EIP197_xDR_DESC_MODE_64BIT | (priv -> config .cd_offset << 16 ) |
329
338
priv -> config .cd_size ,
330
339
EIP197_HIA_CDR (priv , i ) + EIP197_HIA_xDR_DESC_SIZE );
331
- writel (((EIP197_FETCH_COUNT * (cd_size_rnd << hdw )) << 16 ) |
332
- (EIP197_FETCH_COUNT * priv -> config .cd_offset ),
340
+ writel (((cd_fetch_cnt * (cd_size_rnd << hdw )) << 16 ) |
341
+ (cd_fetch_cnt * priv -> config .cd_offset ),
333
342
EIP197_HIA_CDR (priv , i ) + EIP197_HIA_xDR_CFG );
334
343
335
344
/* Configure DMA tx control */
@@ -1142,7 +1151,7 @@ static int safexcel_probe_generic(void *pdev,
1142
1151
int is_pci_dev )
1143
1152
{
1144
1153
struct device * dev = priv -> dev ;
1145
- u32 peid , version , mask , val ;
1154
+ u32 peid , version , mask , val , hiaopt ;
1146
1155
int i , ret , hwctg ;
1147
1156
1148
1157
priv -> context_pool = dmam_pool_create ("safexcel-context" , dev ,
@@ -1226,13 +1235,31 @@ static int safexcel_probe_generic(void *pdev,
1226
1235
}
1227
1236
priv -> hwconfig .pever = EIP197_VERSION_MASK (version );
1228
1237
1238
+ hiaopt = readl (EIP197_HIA_AIC (priv ) + EIP197_HIA_OPTIONS );
1239
+
1240
+ if (priv -> flags & SAFEXCEL_HW_EIP197 ) {
1241
+ /* EIP197 */
1242
+ priv -> hwconfig .hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET ) &
1243
+ EIP197_HWDATAW_MASK ;
1244
+ priv -> hwconfig .hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET ) &
1245
+ EIP197_CFSIZE_MASK ) +
1246
+ EIP197_CFSIZE_ADJUST ;
1247
+ } else {
1248
+ /* EIP97 */
1249
+ priv -> hwconfig .hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET ) &
1250
+ EIP97_HWDATAW_MASK ;
1251
+ priv -> hwconfig .hwcfsize = (hiaopt >> EIP97_CFSIZE_OFFSET ) &
1252
+ EIP97_CFSIZE_MASK ;
1253
+ }
1254
+
1229
1255
/* Get supported algorithms from EIP96 transform engine */
1230
1256
priv -> hwconfig .algo_flags = readl (EIP197_PE (priv ) +
1231
1257
EIP197_PE_EIP96_OPTIONS (0 ));
1232
1258
1233
1259
/* Print single info line describing what we just detected */
1234
- dev_info (priv -> dev , "EIP%d:%x(%d)-HIA:%x,PE:%x,alg:%08x\n" , peid ,
1260
+ dev_info (priv -> dev , "EIP%d:%x(%d)-HIA:%x(%d,%d) ,PE:%x,alg:%08x\n" , peid ,
1235
1261
priv -> hwconfig .hwver , hwctg , priv -> hwconfig .hiaver ,
1262
+ priv -> hwconfig .hwdataw , priv -> hwconfig .hwcfsize ,
1236
1263
priv -> hwconfig .pever , priv -> hwconfig .algo_flags );
1237
1264
1238
1265
safexcel_configure (priv );
0 commit comments