Lines Matching +full:inside +full:- +full:secure
1 // SPDX-License-Identifier: GPL-2.0
5 * Antoine Tenart <antoine.tenart@free-electrons.com>
10 #include <linux/dma-mapping.h>
45 writel(0, priv->base + EIP197_FLUE_IFC_LUT(i)); in eip197_trc_cache_setupvirt()
51 for (i = 0; i < priv->config.rings; i++) { in eip197_trc_cache_setupvirt()
52 writel(0, priv->base + EIP197_FLUE_CACHEBASE_LO(i)); in eip197_trc_cache_setupvirt()
53 writel(0, priv->base + EIP197_FLUE_CACHEBASE_HI(i)); in eip197_trc_cache_setupvirt()
55 priv->base + EIP197_FLUE_CONFIG(i)); in eip197_trc_cache_setupvirt()
57 writel(0, priv->base + EIP197_FLUE_OFFSETS); in eip197_trc_cache_setupvirt()
58 writel(0, priv->base + EIP197_FLUE_ARC4_OFFSET); in eip197_trc_cache_setupvirt()
69 val = readl(priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_banksel()
72 writel(val, priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_banksel()
89 actbank = min(maxbanks - 1, 0); in eip197_trc_cache_probe()
90 while ((addrhi - addrlo) > stride) { in eip197_trc_cache_probe()
96 priv->base + EIP197_CLASSIFICATION_RAMS + in eip197_trc_cache_probe()
102 addralias = addrmid - delta; in eip197_trc_cache_probe()
105 priv->base + EIP197_CLASSIFICATION_RAMS + in eip197_trc_cache_probe()
112 val = readl(priv->base + EIP197_CLASSIFICATION_RAMS + in eip197_trc_cache_probe()
137 priv->base + offset); in eip197_trc_cache_clear()
139 val = EIP197_CS_RC_NEXT(i + 1) | EIP197_CS_RC_PREV(i - 1); in eip197_trc_cache_clear()
142 else if (i == cs_rc_max - 1) in eip197_trc_cache_clear()
144 writel(val, priv->base + offset + 4); in eip197_trc_cache_clear()
146 writel(0, priv->base + offset + 8); in eip197_trc_cache_clear()
147 writel(0, priv->base + offset + 12); in eip197_trc_cache_clear()
154 priv->base + EIP197_CLASSIFICATION_RAMS + in eip197_trc_cache_clear()
172 val = readl(priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_init()
175 writel(val, priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_init()
176 val = readl(priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_init()
180 writel(0, priv->base + EIP197_TRC_ECCCTRL); in eip197_trc_cache_init()
186 val = readl(priv->base + EIP197_TRC_PARAMS); in eip197_trc_cache_init()
188 writel(val, priv->base + EIP197_TRC_PARAMS); in eip197_trc_cache_init()
198 val = readl(priv->base + EIP197_TRC_PARAMS); in eip197_trc_cache_init()
201 writel(val, priv->base + EIP197_TRC_PARAMS); in eip197_trc_cache_init()
207 writel(0, priv->base + EIP197_TRC_ECCCTRL); in eip197_trc_cache_init()
211 dev_err(priv->dev, "Record cache probing failed (%d,%d).", in eip197_trc_cache_init()
213 return -ENODEV; in eip197_trc_cache_init()
234 cs_ht_sz = __fls(asize - cs_rc_max) - 2; in eip197_trc_cache_init()
238 cs_rc_max = min_t(uint, cs_rc_abs_max, asize - (cs_ht_wc >> 2)); in eip197_trc_cache_init()
244 val = readl(priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_init()
246 writel(val, priv->base + EIP197_CS_RAM_CTRL); in eip197_trc_cache_init()
250 EIP197_TRC_FREECHAIN_TAIL_PTR(cs_rc_max - 1); in eip197_trc_cache_init()
251 writel(val, priv->base + EIP197_TRC_FREECHAIN); in eip197_trc_cache_init()
256 writel(val, priv->base + EIP197_TRC_PARAMS2); in eip197_trc_cache_init()
262 writel(val, priv->base + EIP197_TRC_PARAMS); in eip197_trc_cache_init()
264 dev_info(priv->dev, "TRC init: %dd,%da (%dr,%dh)\n", in eip197_trc_cache_init()
274 for (pe = 0; pe < priv->config.pes; pe++) { in eip197_init_firmware()
309 if (priv->flags & EIP197_OCE) in eip197_init_firmware()
319 const __be32 *data = (const __be32 *)fw->data; in eip197_write_firmware()
323 for (i = 0; i < fw->size / sizeof(u32); i++) in eip197_write_firmware()
325 priv->base + EIP197_CLASSIFICATION_RAMS + in eip197_write_firmware()
329 return i - EIP197_FW_TERMINAL_NOPS; in eip197_write_firmware()
346 for (pe = 0; pe < priv->config.pes; pe++) { in poll_fw_ready()
352 pollcnt--; in poll_fw_ready()
355 dev_err(priv->dev, "FW(%d) for PE %d failed to start\n", in poll_fw_ready()
369 for (pe = 0; pe < priv->config.pes; pe++) { in eip197_start_firmware()
377 val = EIP197_PE_ICE_UENG_START_OFFSET((ifppsz - 1) & in eip197_start_firmware()
386 val = EIP197_PE_ICE_UENG_START_OFFSET((ipuesz - 1) & in eip197_start_firmware()
413 if (priv->version == EIP197D_MRVL) in eip197_load_firmwares()
415 else if (priv->version == EIP197B_MRVL || in eip197_load_firmwares()
416 priv->version == EIP197_DEVBRD) in eip197_load_firmwares()
419 return -ENODEV; in eip197_load_firmwares()
423 snprintf(fw_path, 37, "inside-secure/%s/%s", dir, fw_name[i]); in eip197_load_firmwares()
424 ret = firmware_request_nowarn(&fw[i], fw_path, priv->dev); in eip197_load_firmwares()
426 if (minifw || priv->version != EIP197B_MRVL) in eip197_load_firmwares()
433 priv->dev); in eip197_load_firmwares()
444 for (pe = 0; pe < priv->config.pes; pe++) in eip197_load_firmwares()
451 dev_dbg(priv->dev, "Firmware loaded successfully\n"); in eip197_load_firmwares()
455 ret = -ENODEV; in eip197_load_firmwares()
463 …dev_dbg(priv->dev, "Firmware set not (fully) present or init failed, falling back to BCLA mode\n"); in eip197_load_firmwares()
469 dev_dbg(priv->dev, "Firmware load failed.\n"); in eip197_load_firmwares()
479 cd_size_rnd = (priv->config.cd_size + in safexcel_hw_setup_cdesc_rings()
480 (BIT(priv->hwconfig.hwdataw) - 1)) >> in safexcel_hw_setup_cdesc_rings()
481 priv->hwconfig.hwdataw; in safexcel_hw_setup_cdesc_rings()
483 if (priv->flags & SAFEXCEL_HW_EIP197) { in safexcel_hw_setup_cdesc_rings()
485 cd_fetch_cnt = (1 << priv->hwconfig.hwcfsize) / cd_size_rnd; in safexcel_hw_setup_cdesc_rings()
487 (priv->config.pes * EIP197_FETCH_DEPTH)); in safexcel_hw_setup_cdesc_rings()
490 cd_fetch_cnt = ((1 << priv->hwconfig.hwcfsize) / in safexcel_hw_setup_cdesc_rings()
491 cd_size_rnd) - 1; in safexcel_hw_setup_cdesc_rings()
495 * we need to check whether we can fit even 1 for low-end EIP196's! in safexcel_hw_setup_cdesc_rings()
498 dev_err(priv->dev, "Unable to fit even 1 command desc!\n"); in safexcel_hw_setup_cdesc_rings()
499 return -ENODEV; in safexcel_hw_setup_cdesc_rings()
502 for (i = 0; i < priv->config.rings; i++) { in safexcel_hw_setup_cdesc_rings()
504 writel(lower_32_bits(priv->ring[i].cdr.base_dma), in safexcel_hw_setup_cdesc_rings()
506 writel(upper_32_bits(priv->ring[i].cdr.base_dma), in safexcel_hw_setup_cdesc_rings()
510 (priv->config.cd_offset << 14) | priv->config.cd_size, in safexcel_hw_setup_cdesc_rings()
513 (cd_size_rnd << priv->hwconfig.hwdataw)) << 16) | in safexcel_hw_setup_cdesc_rings()
514 (cd_fetch_cnt * (priv->config.cd_offset / sizeof(u32))), in safexcel_hw_setup_cdesc_rings()
537 (BIT(priv->hwconfig.hwdataw) - 1)) >> in safexcel_hw_setup_rdesc_rings()
538 priv->hwconfig.hwdataw; in safexcel_hw_setup_rdesc_rings()
539 if (priv->flags & SAFEXCEL_HW_EIP197) { in safexcel_hw_setup_rdesc_rings()
541 rd_fetch_cnt = (1 << priv->hwconfig.hwrfsize) / rd_size_rnd; in safexcel_hw_setup_rdesc_rings()
543 (priv->config.pes * EIP197_FETCH_DEPTH)); in safexcel_hw_setup_rdesc_rings()
546 rd_fetch_cnt = ((1 << priv->hwconfig.hwrfsize) / in safexcel_hw_setup_rdesc_rings()
547 rd_size_rnd) - 1; in safexcel_hw_setup_rdesc_rings()
550 for (i = 0; i < priv->config.rings; i++) { in safexcel_hw_setup_rdesc_rings()
552 writel(lower_32_bits(priv->ring[i].rdr.base_dma), in safexcel_hw_setup_rdesc_rings()
554 writel(upper_32_bits(priv->ring[i].rdr.base_dma), in safexcel_hw_setup_rdesc_rings()
557 writel(EIP197_xDR_DESC_MODE_64BIT | (priv->config.rd_offset << 14) | in safexcel_hw_setup_rdesc_rings()
558 priv->config.rd_size, in safexcel_hw_setup_rdesc_rings()
562 (rd_size_rnd << priv->hwconfig.hwdataw)) << 16) | in safexcel_hw_setup_rdesc_rings()
563 (rd_fetch_cnt * (priv->config.rd_offset / sizeof(u32))), in safexcel_hw_setup_rdesc_rings()
591 dev_dbg(priv->dev, "HW init: using %d pipe(s) and %d ring(s)\n", in safexcel_hw_init()
592 priv->config.pes, priv->config.rings); in safexcel_hw_init()
598 if (priv->flags & SAFEXCEL_HW_EIP197) { in safexcel_hw_init()
618 for (pe = 0; pe < priv->config.pes; pe++) { in safexcel_hw_init()
625 if (priv->flags & EIP197_PE_ARB) in safexcel_hw_init()
651 if (priv->flags & SAFEXCEL_HW_EIP197) in safexcel_hw_init()
654 GENMASK(priv->config.rings - 1, 0), in safexcel_hw_init()
669 if (priv->hwconfig.hwnumpes > 4) { in safexcel_hw_init()
684 if (priv->flags & SAFEXCEL_HW_EIP197) in safexcel_hw_init()
712 for (i = 0; i < priv->config.rings; i++) { in safexcel_hw_init()
733 writel((EIP197_DEFAULT_RING_SIZE * priv->config.cd_offset), in safexcel_hw_init()
738 for (i = 0; i < priv->config.rings; i++) { in safexcel_hw_init()
756 writel((EIP197_DEFAULT_RING_SIZE * priv->config.rd_offset), in safexcel_hw_init()
760 for (pe = 0; pe < priv->config.pes; pe++) { in safexcel_hw_init()
762 writel(EIP197_DxE_THR_CTRL_EN | GENMASK(priv->config.rings - 1, 0), in safexcel_hw_init()
766 writel(EIP197_DxE_THR_CTRL_EN | GENMASK(priv->config.rings - 1, 0), in safexcel_hw_init()
773 if (priv->flags & EIP197_SIMPLE_TRC) { in safexcel_hw_init()
777 priv->base + EIP197_STRC_CONFIG); in safexcel_hw_init()
780 } else if (priv->flags & SAFEXCEL_HW_EIP197) { in safexcel_hw_init()
786 if (priv->flags & EIP197_ICE) { in safexcel_hw_init()
801 int coal = min_t(int, priv->ring[ring].requests, EIP197_MAX_BATCH_SZ); in safexcel_try_push_requests()
821 req = priv->ring[ring].req; in safexcel_dequeue()
822 backlog = priv->ring[ring].backlog; in safexcel_dequeue()
827 spin_lock_bh(&priv->ring[ring].queue_lock); in safexcel_dequeue()
828 backlog = crypto_get_backlog(&priv->ring[ring].queue); in safexcel_dequeue()
829 req = crypto_dequeue_request(&priv->ring[ring].queue); in safexcel_dequeue()
830 spin_unlock_bh(&priv->ring[ring].queue_lock); in safexcel_dequeue()
833 priv->ring[ring].req = NULL; in safexcel_dequeue()
834 priv->ring[ring].backlog = NULL; in safexcel_dequeue()
839 ctx = crypto_tfm_ctx(req->tfm); in safexcel_dequeue()
840 ret = ctx->send(req, ring, &commands, &results); in safexcel_dequeue()
845 backlog->complete(backlog, -EINPROGRESS); in safexcel_dequeue()
861 * the request and the backlog for the next dequeue call (per-ring). in safexcel_dequeue()
863 priv->ring[ring].req = req; in safexcel_dequeue()
864 priv->ring[ring].backlog = backlog; in safexcel_dequeue()
870 spin_lock_bh(&priv->ring[ring].lock); in safexcel_dequeue()
872 priv->ring[ring].requests += nreq; in safexcel_dequeue()
874 if (!priv->ring[ring].busy) { in safexcel_dequeue()
876 priv->ring[ring].busy = true; in safexcel_dequeue()
879 spin_unlock_bh(&priv->ring[ring].lock); in safexcel_dequeue()
882 writel((rdesc * priv->config.rd_offset), in safexcel_dequeue()
886 writel((cdesc * priv->config.cd_offset), in safexcel_dequeue()
894 struct result_data_desc *result_data = rdp + priv->config.res_offset; in safexcel_rdesc_check_errors()
896 if (likely((!rdesc->last_seg) || /* Rest only valid if last seg! */ in safexcel_rdesc_check_errors()
897 ((!rdesc->descriptor_overflow) && in safexcel_rdesc_check_errors()
898 (!rdesc->buffer_overflow) && in safexcel_rdesc_check_errors()
899 (!result_data->error_code)))) in safexcel_rdesc_check_errors()
902 if (rdesc->descriptor_overflow) in safexcel_rdesc_check_errors()
903 dev_err(priv->dev, "Descriptor overflow detected"); in safexcel_rdesc_check_errors()
905 if (rdesc->buffer_overflow) in safexcel_rdesc_check_errors()
906 dev_err(priv->dev, "Buffer overflow detected"); in safexcel_rdesc_check_errors()
908 if (result_data->error_code & 0x4066) { in safexcel_rdesc_check_errors()
910 dev_err(priv->dev, in safexcel_rdesc_check_errors()
912 result_data->error_code); in safexcel_rdesc_check_errors()
914 return -EIO; in safexcel_rdesc_check_errors()
915 } else if (result_data->error_code & in safexcel_rdesc_check_errors()
922 return -EINVAL; in safexcel_rdesc_check_errors()
923 } else if (result_data->error_code & BIT(9)) { in safexcel_rdesc_check_errors()
925 return -EBADMSG; in safexcel_rdesc_check_errors()
928 /* All other non-fatal errors */ in safexcel_rdesc_check_errors()
929 return -EINVAL; in safexcel_rdesc_check_errors()
939 priv->ring[ring].rdr_req[i] = req; in safexcel_rdr_req_set()
947 return priv->ring[ring].rdr_req[i]; in safexcel_rdr_req_get()
956 cdesc = safexcel_ring_next_rptr(priv, &priv->ring[ring].cdr); in safexcel_complete()
958 dev_err(priv->dev, in safexcel_complete()
962 } while (!cdesc->last_seg); in safexcel_complete()
967 struct safexcel_inv_result *result = req->data; in safexcel_inv_complete()
969 if (error == -EINPROGRESS) in safexcel_inv_complete()
972 result->error = error; in safexcel_inv_complete()
973 complete(&result->completion); in safexcel_inv_complete()
991 cdesc->control_data.type = EIP197_TYPE_EXTENDED; in safexcel_invalidate_cache()
992 cdesc->control_data.options = 0; in safexcel_invalidate_cache()
993 cdesc->control_data.context_lo &= ~EIP197_CONTEXT_SIZE_MASK; in safexcel_invalidate_cache()
994 cdesc->control_data.control0 = CONTEXT_CONTROL_INV_TR; in safexcel_invalidate_cache()
1009 safexcel_ring_rollback_wptr(priv, &priv->ring[ring].cdr); in safexcel_invalidate_cache()
1034 ctx = crypto_tfm_ctx(req->tfm); in safexcel_handle_result_descriptor()
1035 ndesc = ctx->handle_result(priv, ring, req, in safexcel_handle_result_descriptor()
1038 dev_err(priv->dev, "failed to handle result (%d)\n", in safexcel_handle_result_descriptor()
1045 req->complete(req, ret); in safexcel_handle_result_descriptor()
1056 (tot_descs * priv->config.rd_offset), in safexcel_handle_result_descriptor()
1066 spin_lock_bh(&priv->ring[ring].lock); in safexcel_handle_result_descriptor()
1068 priv->ring[ring].requests -= handled; in safexcel_handle_result_descriptor()
1071 if (!priv->ring[ring].requests) in safexcel_handle_result_descriptor()
1072 priv->ring[ring].busy = false; in safexcel_handle_result_descriptor()
1074 spin_unlock_bh(&priv->ring[ring].lock); in safexcel_handle_result_descriptor()
1082 safexcel_dequeue(data->priv, data->ring); in safexcel_dequeue_work()
1093 struct safexcel_crypto_priv *priv = irq_data->priv; in safexcel_irq_ring()
1094 int ring = irq_data->ring, rc = IRQ_NONE; in safexcel_irq_ring()
1111 dev_err(priv->dev, "RDR: fatal error.\n"); in safexcel_irq_ring()
1130 struct safexcel_crypto_priv *priv = irq_data->priv; in safexcel_irq_ring_thread()
1131 int ring = irq_data->ring; in safexcel_irq_ring_thread()
1135 queue_work(priv->ring[ring].workqueue, in safexcel_irq_ring_thread()
1136 &priv->ring[ring].work_data.work); in safexcel_irq_ring_thread()
1154 dev = &pci_pdev->dev; in safexcel_request_ring_irq()
1166 dev = &plf_pdev->dev; in safexcel_request_ring_irq()
1172 return -ENXIO; in safexcel_request_ring_irq()
1271 safexcel_algs[i]->priv = priv; in safexcel_register_algorithms()
1274 if ((safexcel_algs[i]->algo_mask & priv->hwconfig.algo_flags) != in safexcel_register_algorithms()
1275 safexcel_algs[i]->algo_mask) in safexcel_register_algorithms()
1279 if (safexcel_algs[i]->type == SAFEXCEL_ALG_TYPE_SKCIPHER) in safexcel_register_algorithms()
1280 ret = crypto_register_skcipher(&safexcel_algs[i]->alg.skcipher); in safexcel_register_algorithms()
1281 else if (safexcel_algs[i]->type == SAFEXCEL_ALG_TYPE_AEAD) in safexcel_register_algorithms()
1282 ret = crypto_register_aead(&safexcel_algs[i]->alg.aead); in safexcel_register_algorithms()
1284 ret = crypto_register_ahash(&safexcel_algs[i]->alg.ahash); in safexcel_register_algorithms()
1295 if ((safexcel_algs[j]->algo_mask & priv->hwconfig.algo_flags) != in safexcel_register_algorithms()
1296 safexcel_algs[j]->algo_mask) in safexcel_register_algorithms()
1300 if (safexcel_algs[j]->type == SAFEXCEL_ALG_TYPE_SKCIPHER) in safexcel_register_algorithms()
1301 crypto_unregister_skcipher(&safexcel_algs[j]->alg.skcipher); in safexcel_register_algorithms()
1302 else if (safexcel_algs[j]->type == SAFEXCEL_ALG_TYPE_AEAD) in safexcel_register_algorithms()
1303 crypto_unregister_aead(&safexcel_algs[j]->alg.aead); in safexcel_register_algorithms()
1305 crypto_unregister_ahash(&safexcel_algs[j]->alg.ahash); in safexcel_register_algorithms()
1317 if ((safexcel_algs[i]->algo_mask & priv->hwconfig.algo_flags) != in safexcel_unregister_algorithms()
1318 safexcel_algs[i]->algo_mask) in safexcel_unregister_algorithms()
1322 if (safexcel_algs[i]->type == SAFEXCEL_ALG_TYPE_SKCIPHER) in safexcel_unregister_algorithms()
1323 crypto_unregister_skcipher(&safexcel_algs[i]->alg.skcipher); in safexcel_unregister_algorithms()
1324 else if (safexcel_algs[i]->type == SAFEXCEL_ALG_TYPE_AEAD) in safexcel_unregister_algorithms()
1325 crypto_unregister_aead(&safexcel_algs[i]->alg.aead); in safexcel_unregister_algorithms()
1327 crypto_unregister_ahash(&safexcel_algs[i]->alg.ahash); in safexcel_unregister_algorithms()
1333 u32 mask = BIT(priv->hwconfig.hwdataw) - 1; in safexcel_configure()
1335 priv->config.pes = priv->hwconfig.hwnumpes; in safexcel_configure()
1336 priv->config.rings = min_t(u32, priv->hwconfig.hwnumrings, max_rings); in safexcel_configure()
1338 priv->config.rings = min_t(u32, priv->config.rings, in safexcel_configure()
1339 priv->hwconfig.hwnumraic); in safexcel_configure()
1341 priv->config.cd_size = EIP197_CD64_FETCH_SIZE; in safexcel_configure()
1342 priv->config.cd_offset = (priv->config.cd_size + mask) & ~mask; in safexcel_configure()
1343 priv->config.cdsh_offset = (EIP197_MAX_TOKENS + mask) & ~mask; in safexcel_configure()
1346 priv->config.res_offset = (EIP197_RD64_FETCH_SIZE + mask) & ~mask; in safexcel_configure()
1348 priv->config.rd_size = priv->config.res_offset + in safexcel_configure()
1350 priv->config.rd_offset = (priv->config.rd_size + mask) & ~mask; in safexcel_configure()
1353 priv->config.cd_offset *= sizeof(u32); in safexcel_configure()
1354 priv->config.cdsh_offset *= sizeof(u32); in safexcel_configure()
1355 priv->config.rd_offset *= sizeof(u32); in safexcel_configure()
1356 priv->config.res_offset *= sizeof(u32); in safexcel_configure()
1361 struct safexcel_register_offsets *offsets = &priv->offsets; in safexcel_init_register_offsets()
1363 if (priv->flags & SAFEXCEL_HW_EIP197) { in safexcel_init_register_offsets()
1364 offsets->hia_aic = EIP197_HIA_AIC_BASE; in safexcel_init_register_offsets()
1365 offsets->hia_aic_g = EIP197_HIA_AIC_G_BASE; in safexcel_init_register_offsets()
1366 offsets->hia_aic_r = EIP197_HIA_AIC_R_BASE; in safexcel_init_register_offsets()
1367 offsets->hia_aic_xdr = EIP197_HIA_AIC_xDR_BASE; in safexcel_init_register_offsets()
1368 offsets->hia_dfe = EIP197_HIA_DFE_BASE; in safexcel_init_register_offsets()
1369 offsets->hia_dfe_thr = EIP197_HIA_DFE_THR_BASE; in safexcel_init_register_offsets()
1370 offsets->hia_dse = EIP197_HIA_DSE_BASE; in safexcel_init_register_offsets()
1371 offsets->hia_dse_thr = EIP197_HIA_DSE_THR_BASE; in safexcel_init_register_offsets()
1372 offsets->hia_gen_cfg = EIP197_HIA_GEN_CFG_BASE; in safexcel_init_register_offsets()
1373 offsets->pe = EIP197_PE_BASE; in safexcel_init_register_offsets()
1374 offsets->global = EIP197_GLOBAL_BASE; in safexcel_init_register_offsets()
1376 offsets->hia_aic = EIP97_HIA_AIC_BASE; in safexcel_init_register_offsets()
1377 offsets->hia_aic_g = EIP97_HIA_AIC_G_BASE; in safexcel_init_register_offsets()
1378 offsets->hia_aic_r = EIP97_HIA_AIC_R_BASE; in safexcel_init_register_offsets()
1379 offsets->hia_aic_xdr = EIP97_HIA_AIC_xDR_BASE; in safexcel_init_register_offsets()
1380 offsets->hia_dfe = EIP97_HIA_DFE_BASE; in safexcel_init_register_offsets()
1381 offsets->hia_dfe_thr = EIP97_HIA_DFE_THR_BASE; in safexcel_init_register_offsets()
1382 offsets->hia_dse = EIP97_HIA_DSE_BASE; in safexcel_init_register_offsets()
1383 offsets->hia_dse_thr = EIP97_HIA_DSE_THR_BASE; in safexcel_init_register_offsets()
1384 offsets->hia_gen_cfg = EIP97_HIA_GEN_CFG_BASE; in safexcel_init_register_offsets()
1385 offsets->pe = EIP97_PE_BASE; in safexcel_init_register_offsets()
1386 offsets->global = EIP97_GLOBAL_BASE; in safexcel_init_register_offsets()
1401 struct device *dev = priv->dev; in safexcel_probe_generic()
1405 priv->context_pool = dmam_pool_create("safexcel-context", dev, in safexcel_probe_generic()
1408 if (!priv->context_pool) in safexcel_probe_generic()
1409 return -ENOMEM; in safexcel_probe_generic()
1416 version = readl(priv->base + EIP97_HIA_AIC_BASE + EIP197_HIA_VERSION); in safexcel_probe_generic()
1420 priv->hwconfig.hiaver = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1422 /* read back byte-swapped, so complement byte swap bits */ in safexcel_probe_generic()
1424 priv->hwconfig.hiaver = EIP197_VERSION_SWAP(version); in safexcel_probe_generic()
1427 version = readl(priv->base + EIP197_HIA_AIC_BASE + in safexcel_probe_generic()
1430 priv->hwconfig.hiaver = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1431 priv->flags |= SAFEXCEL_HW_EIP197; in safexcel_probe_generic()
1434 /* read back byte-swapped, so complement swap bits */ in safexcel_probe_generic()
1436 priv->hwconfig.hiaver = EIP197_VERSION_SWAP(version); in safexcel_probe_generic()
1437 priv->flags |= SAFEXCEL_HW_EIP197; in safexcel_probe_generic()
1439 return -ENODEV; in safexcel_probe_generic()
1447 * If the version was read byte-swapped, we need to flip the device in safexcel_probe_generic()
1449 * byte-swapped ... in safexcel_probe_generic()
1463 if (((priv->flags & SAFEXCEL_HW_EIP197) && in safexcel_probe_generic()
1466 ((!(priv->flags & SAFEXCEL_HW_EIP197) && in safexcel_probe_generic()
1472 dev_err(priv->dev, "Probing for EIP97/EIP19x failed - no such device (read %08x)\n", in safexcel_probe_generic()
1474 return -ENODEV; in safexcel_probe_generic()
1477 priv->hwconfig.hwver = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1484 dev_err(priv->dev, "EIP%d: EIP206 not detected\n", peid); in safexcel_probe_generic()
1485 return -ENODEV; in safexcel_probe_generic()
1487 priv->hwconfig.ppver = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1493 return -ENODEV; in safexcel_probe_generic()
1495 priv->hwconfig.pever = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1500 priv->hwconfig.icever = 0; in safexcel_probe_generic()
1501 priv->hwconfig.ocever = 0; in safexcel_probe_generic()
1502 priv->hwconfig.psever = 0; in safexcel_probe_generic()
1503 if (priv->flags & SAFEXCEL_HW_EIP197) { in safexcel_probe_generic()
1507 priv->hwconfig.hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET) & in safexcel_probe_generic()
1509 priv->hwconfig.hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET) & in safexcel_probe_generic()
1512 priv->hwconfig.hwrfsize = ((hiaopt >> EIP197_RFSIZE_OFFSET) & in safexcel_probe_generic()
1515 priv->hwconfig.hwnumpes = (hiaopt >> EIP197_N_PES_OFFSET) & in safexcel_probe_generic()
1517 priv->hwconfig.hwnumrings = (hiaopt >> EIP197_N_RINGS_OFFSET) & in safexcel_probe_generic()
1520 priv->flags |= EIP197_PE_ARB; in safexcel_probe_generic()
1522 priv->flags |= EIP197_ICE; in safexcel_probe_generic()
1529 return -ENODEV; in safexcel_probe_generic()
1531 priv->hwconfig.icever = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1534 priv->flags |= EIP197_OCE; in safexcel_probe_generic()
1539 return -ENODEV; in safexcel_probe_generic()
1541 priv->hwconfig.psever = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1548 return -ENODEV; in safexcel_probe_generic()
1550 priv->hwconfig.ocever = EIP197_VERSION_MASK(version); in safexcel_probe_generic()
1554 priv->flags |= EIP197_SIMPLE_TRC; in safexcel_probe_generic()
1556 priv->flags |= EIP197_TRC_CACHE; in safexcel_probe_generic()
1559 priv->hwconfig.hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET) & in safexcel_probe_generic()
1561 priv->hwconfig.hwcfsize = (hiaopt >> EIP97_CFSIZE_OFFSET) & in safexcel_probe_generic()
1563 priv->hwconfig.hwrfsize = (hiaopt >> EIP97_RFSIZE_OFFSET) & in safexcel_probe_generic()
1565 priv->hwconfig.hwnumpes = 1; /* by definition */ in safexcel_probe_generic()
1566 priv->hwconfig.hwnumrings = (hiaopt >> EIP197_N_RINGS_OFFSET) & in safexcel_probe_generic()
1577 priv->hwconfig.hwnumraic = i; in safexcel_probe_generic()
1578 /* Low-end EIP196 may not have any ring AIC's ... */ in safexcel_probe_generic()
1579 if (!priv->hwconfig.hwnumraic) { in safexcel_probe_generic()
1580 dev_err(priv->dev, "No ring interrupt controller present!\n"); in safexcel_probe_generic()
1581 return -ENODEV; in safexcel_probe_generic()
1585 priv->hwconfig.algo_flags = readl(EIP197_PE(priv) + in safexcel_probe_generic()
1589 dev_info(priv->dev, "EIP%d:%x(%d,%d,%d,%d)-HIA:%x(%d,%d,%d),PE:%x/%x(alg:%08x)/%x/%x/%x\n", in safexcel_probe_generic()
1590 peid, priv->hwconfig.hwver, hwctg, priv->hwconfig.hwnumpes, in safexcel_probe_generic()
1591 priv->hwconfig.hwnumrings, priv->hwconfig.hwnumraic, in safexcel_probe_generic()
1592 priv->hwconfig.hiaver, priv->hwconfig.hwdataw, in safexcel_probe_generic()
1593 priv->hwconfig.hwcfsize, priv->hwconfig.hwrfsize, in safexcel_probe_generic()
1594 priv->hwconfig.ppver, priv->hwconfig.pever, in safexcel_probe_generic()
1595 priv->hwconfig.algo_flags, priv->hwconfig.icever, in safexcel_probe_generic()
1596 priv->hwconfig.ocever, priv->hwconfig.psever); in safexcel_probe_generic()
1600 if (IS_ENABLED(CONFIG_PCI) && priv->version == EIP197_DEVBRD) { in safexcel_probe_generic()
1602 * Request MSI vectors for global + 1 per ring - in safexcel_probe_generic()
1608 priv->config.rings + 1, in safexcel_probe_generic()
1609 priv->config.rings + 1, in safexcel_probe_generic()
1618 priv->ring = devm_kcalloc(dev, priv->config.rings, in safexcel_probe_generic()
1619 sizeof(*priv->ring), in safexcel_probe_generic()
1621 if (!priv->ring) in safexcel_probe_generic()
1622 return -ENOMEM; in safexcel_probe_generic()
1624 for (i = 0; i < priv->config.rings; i++) { in safexcel_probe_generic()
1630 &priv->ring[i].cdr, in safexcel_probe_generic()
1631 &priv->ring[i].rdr); in safexcel_probe_generic()
1637 priv->ring[i].rdr_req = devm_kcalloc(dev, in safexcel_probe_generic()
1639 sizeof(*priv->ring[i].rdr_req), in safexcel_probe_generic()
1641 if (!priv->ring[i].rdr_req) in safexcel_probe_generic()
1642 return -ENOMEM; in safexcel_probe_generic()
1646 return -ENOMEM; in safexcel_probe_generic()
1648 ring_irq->priv = priv; in safexcel_probe_generic()
1649 ring_irq->ring = i; in safexcel_probe_generic()
1663 priv->ring[i].irq = irq; in safexcel_probe_generic()
1664 priv->ring[i].work_data.priv = priv; in safexcel_probe_generic()
1665 priv->ring[i].work_data.ring = i; in safexcel_probe_generic()
1666 INIT_WORK(&priv->ring[i].work_data.work, in safexcel_probe_generic()
1670 priv->ring[i].workqueue = in safexcel_probe_generic()
1672 if (!priv->ring[i].workqueue) in safexcel_probe_generic()
1673 return -ENOMEM; in safexcel_probe_generic()
1675 priv->ring[i].requests = 0; in safexcel_probe_generic()
1676 priv->ring[i].busy = false; in safexcel_probe_generic()
1678 crypto_init_queue(&priv->ring[i].queue, in safexcel_probe_generic()
1681 spin_lock_init(&priv->ring[i].lock); in safexcel_probe_generic()
1682 spin_lock_init(&priv->ring[i].queue_lock); in safexcel_probe_generic()
1685 atomic_set(&priv->ring_used, 0); in safexcel_probe_generic()
1706 for (i = 0; i < priv->config.rings; i++) { in safexcel_hw_reset_rings()
1725 struct device *dev = &pdev->dev; in safexcel_probe()
1731 return -ENOMEM; in safexcel_probe()
1733 priv->dev = dev; in safexcel_probe()
1734 priv->version = (enum safexcel_eip_version)of_device_get_match_data(dev); in safexcel_probe()
1738 priv->base = devm_platform_ioremap_resource(pdev, 0); in safexcel_probe()
1739 if (IS_ERR(priv->base)) { in safexcel_probe()
1741 return PTR_ERR(priv->base); in safexcel_probe()
1744 priv->clk = devm_clk_get(&pdev->dev, NULL); in safexcel_probe()
1745 ret = PTR_ERR_OR_ZERO(priv->clk); in safexcel_probe()
1747 if (ret != -ENOENT) { in safexcel_probe()
1751 ret = clk_prepare_enable(priv->clk); in safexcel_probe()
1758 priv->reg_clk = devm_clk_get(&pdev->dev, "reg"); in safexcel_probe()
1759 ret = PTR_ERR_OR_ZERO(priv->reg_clk); in safexcel_probe()
1761 if (ret != -ENOENT) { in safexcel_probe()
1765 ret = clk_prepare_enable(priv->reg_clk); in safexcel_probe()
1784 clk_disable_unprepare(priv->reg_clk); in safexcel_probe()
1786 clk_disable_unprepare(priv->clk); in safexcel_probe()
1798 clk_disable_unprepare(priv->reg_clk); in safexcel_remove()
1799 clk_disable_unprepare(priv->clk); in safexcel_remove()
1801 for (i = 0; i < priv->config.rings; i++) { in safexcel_remove()
1802 irq_set_affinity_hint(priv->ring[i].irq, NULL); in safexcel_remove()
1803 destroy_workqueue(priv->ring[i].workqueue); in safexcel_remove()
1811 .compatible = "inside-secure,safexcel-eip97ies",
1815 .compatible = "inside-secure,safexcel-eip197b",
1819 .compatible = "inside-secure,safexcel-eip197d",
1824 .compatible = "inside-secure,safexcel-eip97",
1828 .compatible = "inside-secure,safexcel-eip197",
1840 .name = "crypto-safexcel",
1845 /* PCIE devices - i.e. Inside Secure development boards */
1850 struct device *dev = &pdev->dev; in safexcel_pci_probe()
1857 ent->vendor, ent->device, ent->subvendor, in safexcel_pci_probe()
1858 ent->subdevice, ent->driver_data); in safexcel_pci_probe()
1862 return -ENOMEM; in safexcel_pci_probe()
1864 priv->dev = dev; in safexcel_pci_probe()
1865 priv->version = (enum safexcel_eip_version)ent->driver_data; in safexcel_pci_probe()
1882 priv->base = pcim_iomap_table(pdev)[0]; in safexcel_pci_probe()
1884 if (priv->version == EIP197_DEVBRD) { in safexcel_pci_probe()
1885 dev_dbg(dev, "Device identified as FPGA based development board - applying HW reset\n"); in safexcel_pci_probe()
1915 return -ENODEV; in safexcel_pci_probe()
1920 writel(1, priv->base + EIP197_XLX_GPIO_BASE); in safexcel_pci_probe()
1923 writel(0, priv->base + EIP197_XLX_GPIO_BASE); in safexcel_pci_probe()
1942 for (i = 0; i < priv->config.rings; i++) in safexcel_pci_remove()
1943 destroy_workqueue(priv->ring[i].workqueue); in safexcel_pci_remove()
1960 .name = "crypto-safexcel",
1996 MODULE_AUTHOR("Antoine Tenart <antoine.tenart@free-electrons.com>");
2005 MODULE_FIRMWARE("inside-secure/eip197b/ifpp.bin");
2006 MODULE_FIRMWARE("inside-secure/eip197b/ipue.bin");
2007 MODULE_FIRMWARE("inside-secure/eip197d/ifpp.bin");
2008 MODULE_FIRMWARE("inside-secure/eip197d/ipue.bin");
2009 MODULE_FIRMWARE("inside-secure/eip197_minifw/ifpp.bin");
2010 MODULE_FIRMWARE("inside-secure/eip197_minifw/ipue.bin");