@@ -484,6 +484,14 @@ static int safexcel_hw_setup_cdesc_rings(struct safexcel_crypto_priv *priv)
484484 cd_fetch_cnt = ((1 << priv -> hwconfig .hwcfsize ) /
485485 cd_size_rnd ) - 1 ;
486486 }
487+ /*
488+ * Since we're using command desc's way larger than formally specified,
489+ * we need to check whether we can fit even 1 for low-end EIP196's!
490+ */
491+ if (!cd_fetch_cnt ) {
492+ dev_err (priv -> dev , "Unable to fit even 1 command desc!\n" );
493+ return - ENODEV ;
494+ }
487495
488496 for (i = 0 ; i < priv -> config .rings ; i ++ ) {
489497 /* ring base address */
@@ -608,8 +616,8 @@ static int safexcel_hw_init(struct safexcel_crypto_priv *priv)
608616 writel (EIP197_DxE_THR_CTRL_RESET_PE ,
609617 EIP197_HIA_DFE_THR (priv ) + EIP197_HIA_DFE_THR_CTRL (pe ));
610618
611- if (priv -> flags & SAFEXCEL_HW_EIP197 )
612- /* Reset HIA input interface arbiter (EIP197 only ) */
619+ if (priv -> flags & EIP197_PE_ARB )
620+ /* Reset HIA input interface arbiter (if present ) */
613621 writel (EIP197_HIA_RA_PE_CTRL_RESET ,
614622 EIP197_HIA_AIC (priv ) + EIP197_HIA_RA_PE_CTRL (pe ));
615623
@@ -756,22 +764,28 @@ static int safexcel_hw_init(struct safexcel_crypto_priv *priv)
756764 /* Clear any HIA interrupt */
757765 writel (GENMASK (30 , 20 ), EIP197_HIA_AIC_G (priv ) + EIP197_HIA_AIC_G_ACK );
758766
759- if (priv -> flags & SAFEXCEL_HW_EIP197 ) {
767+ if (priv -> flags & EIP197_SIMPLE_TRC ) {
768+ writel (EIP197_STRC_CONFIG_INIT |
769+ EIP197_STRC_CONFIG_LARGE_REC (EIP197_CS_TRC_REC_WC ) |
770+ EIP197_STRC_CONFIG_SMALL_REC (EIP197_CS_TRC_REC_WC ),
771+ priv -> base + EIP197_STRC_CONFIG );
772+ writel (EIP197_PE_EIP96_TOKEN_CTRL2_CTX_DONE ,
773+ EIP197_PE (priv ) + EIP197_PE_EIP96_TOKEN_CTRL2 (0 ));
774+ } else if (priv -> flags & SAFEXCEL_HW_EIP197 ) {
760775 ret = eip197_trc_cache_init (priv );
761776 if (ret )
762777 return ret ;
778+ }
763779
764- priv -> flags |= EIP197_TRC_CACHE ;
765-
780+ if (priv -> flags & EIP197_ICE ) {
766781 ret = eip197_load_firmwares (priv );
767782 if (ret )
768783 return ret ;
769784 }
770785
771- safexcel_hw_setup_cdesc_rings (priv );
772- safexcel_hw_setup_rdesc_rings (priv );
773-
774- return 0 ;
786+ return safexcel_hw_setup_cdesc_rings (priv ) ?:
787+ safexcel_hw_setup_rdesc_rings (priv ) ?:
788+ 0 ;
775789}
776790
777791/* Called with ring's lock taken */
@@ -1371,7 +1385,7 @@ static int safexcel_probe_generic(void *pdev,
13711385 int is_pci_dev )
13721386{
13731387 struct device * dev = priv -> dev ;
1374- u32 peid , version , mask , val , hiaopt ;
1388+ u32 peid , version , mask , val , hiaopt , hwopt , peopt ;
13751389 int i , ret , hwctg ;
13761390
13771391 priv -> context_pool = dmam_pool_create ("safexcel-context" , dev ,
@@ -1433,20 +1447,31 @@ static int safexcel_probe_generic(void *pdev,
14331447 */
14341448 version = readl (EIP197_GLOBAL (priv ) + EIP197_VERSION );
14351449 if (((priv -> flags & SAFEXCEL_HW_EIP197 ) &&
1436- (EIP197_REG_LO16 (version ) != EIP197_VERSION_LE )) ||
1450+ (EIP197_REG_LO16 (version ) != EIP197_VERSION_LE ) &&
1451+ (EIP197_REG_LO16 (version ) != EIP196_VERSION_LE )) ||
14371452 ((!(priv -> flags & SAFEXCEL_HW_EIP197 ) &&
14381453 (EIP197_REG_LO16 (version ) != EIP97_VERSION_LE )))) {
14391454 /*
14401455 * We did not find the device that matched our initial probing
14411456 * (or our initial probing failed) Report appropriate error.
14421457 */
1458+ dev_err (priv -> dev , "Probing for EIP97/EIP19x failed - no such device (read %08x)\n" ,
1459+ version );
14431460 return - ENODEV ;
14441461 }
14451462
14461463 priv -> hwconfig .hwver = EIP197_VERSION_MASK (version );
14471464 hwctg = version >> 28 ;
14481465 peid = version & 255 ;
14491466
1467+ /* Detect EIP206 processing pipe */
1468+ version = readl (EIP197_PE (priv ) + + EIP197_PE_VERSION (0 ));
1469+ if (EIP197_REG_LO16 (version ) != EIP206_VERSION_LE ) {
1470+ dev_err (priv -> dev , "EIP%d: EIP206 not detected\n" , peid );
1471+ return - ENODEV ;
1472+ }
1473+ priv -> hwconfig .ppver = EIP197_VERSION_MASK (version );
1474+
14501475 /* Detect EIP96 packet engine and version */
14511476 version = readl (EIP197_PE (priv ) + EIP197_PE_EIP96_VERSION (0 ));
14521477 if (EIP197_REG_LO16 (version ) != EIP96_VERSION_LE ) {
@@ -1455,10 +1480,13 @@ static int safexcel_probe_generic(void *pdev,
14551480 }
14561481 priv -> hwconfig .pever = EIP197_VERSION_MASK (version );
14571482
1483+ hwopt = readl (EIP197_GLOBAL (priv ) + EIP197_OPTIONS );
14581484 hiaopt = readl (EIP197_HIA_AIC (priv ) + EIP197_HIA_OPTIONS );
14591485
14601486 if (priv -> flags & SAFEXCEL_HW_EIP197 ) {
14611487 /* EIP197 */
1488+ peopt = readl (EIP197_PE (priv ) + EIP197_PE_OPTIONS (0 ));
1489+
14621490 priv -> hwconfig .hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET ) &
14631491 EIP197_HWDATAW_MASK ;
14641492 priv -> hwconfig .hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET ) &
@@ -1471,6 +1499,15 @@ static int safexcel_probe_generic(void *pdev,
14711499 EIP197_N_PES_MASK ;
14721500 priv -> hwconfig .hwnumrings = (hiaopt >> EIP197_N_RINGS_OFFSET ) &
14731501 EIP197_N_RINGS_MASK ;
1502+ if (hiaopt & EIP197_HIA_OPT_HAS_PE_ARB )
1503+ priv -> flags |= EIP197_PE_ARB ;
1504+ if (EIP206_OPT_ICE_TYPE (peopt ) == 1 )
1505+ priv -> flags |= EIP197_ICE ;
1506+ /* If not a full TRC, then assume simple TRC */
1507+ if (!(hwopt & EIP197_OPT_HAS_TRC ))
1508+ priv -> flags |= EIP197_SIMPLE_TRC ;
1509+ /* EIP197 always has SOME form of TRC */
1510+ priv -> flags |= EIP197_TRC_CACHE ;
14741511 } else {
14751512 /* EIP97 */
14761513 priv -> hwconfig .hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET ) &
@@ -1492,18 +1529,24 @@ static int safexcel_probe_generic(void *pdev,
14921529 break ;
14931530 }
14941531 priv -> hwconfig .hwnumraic = i ;
1532+ /* Low-end EIP196 may not have any ring AIC's ... */
1533+ if (!priv -> hwconfig .hwnumraic ) {
1534+ dev_err (priv -> dev , "No ring interrupt controller present!\n" );
1535+ return - ENODEV ;
1536+ }
14951537
14961538 /* Get supported algorithms from EIP96 transform engine */
14971539 priv -> hwconfig .algo_flags = readl (EIP197_PE (priv ) +
14981540 EIP197_PE_EIP96_OPTIONS (0 ));
14991541
15001542 /* Print single info line describing what we just detected */
1501- dev_info (priv -> dev , "EIP%d:%x(%d,%d,%d,%d)-HIA:%x(%d,%d,%d),PE:%x,alg:%08x\n" ,
1543+ dev_info (priv -> dev , "EIP%d:%x(%d,%d,%d,%d)-HIA:%x(%d,%d,%d),PE:%x/%x ,alg:%08x\n" ,
15021544 peid , priv -> hwconfig .hwver , hwctg , priv -> hwconfig .hwnumpes ,
15031545 priv -> hwconfig .hwnumrings , priv -> hwconfig .hwnumraic ,
15041546 priv -> hwconfig .hiaver , priv -> hwconfig .hwdataw ,
15051547 priv -> hwconfig .hwcfsize , priv -> hwconfig .hwrfsize ,
1506- priv -> hwconfig .pever , priv -> hwconfig .algo_flags );
1548+ priv -> hwconfig .ppver , priv -> hwconfig .pever ,
1549+ priv -> hwconfig .algo_flags );
15071550
15081551 safexcel_configure (priv );
15091552
0 commit comments