Lines Matching defs:ice
22 #include <soc/qcom/ice.h>
102 static bool qcom_ice_check_supported(struct qcom_ice *ice)
104 u32 regval = qcom_ice_readl(ice, QCOM_ICE_REG_VERSION);
105 struct device *dev = ice->dev;
121 regval = qcom_ice_readl(ice, QCOM_ICE_REG_FUSE_SETTING);
149 ice->use_hwkm = true;
161 static void qcom_ice_low_power_mode_enable(struct qcom_ice *ice)
165 regval = qcom_ice_readl(ice, QCOM_ICE_REG_ADVANCED_CONTROL);
169 qcom_ice_writel(ice, regval, QCOM_ICE_REG_ADVANCED_CONTROL);
172 static void qcom_ice_optimization_enable(struct qcom_ice *ice)
177 regval = qcom_ice_readl(ice, QCOM_ICE_REG_ADVANCED_CONTROL);
181 qcom_ice_writel(ice, regval, QCOM_ICE_REG_ADVANCED_CONTROL);
197 static int qcom_ice_wait_bist_status(struct qcom_ice *ice)
202 err = readl_poll_timeout(ice->base + QCOM_ICE_REG_BIST_STATUS,
206 dev_err(ice->dev, "Timed out waiting for ICE self-test to complete\n");
210 if (ice->use_hwkm &&
211 qcom_ice_readl(ice, QCOM_ICE_REG_HWKM_TZ_KM_STATUS) !=
217 dev_err(ice->dev, "HWKM self-test error!\n");
226 static void qcom_ice_hwkm_init(struct qcom_ice *ice)
230 if (!ice->use_hwkm)
241 regval = qcom_ice_readl(ice, QCOM_ICE_REG_CONTROL);
243 qcom_ice_writel(ice, regval, QCOM_ICE_REG_CONTROL);
246 qcom_ice_writel(ice, QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL,
253 qcom_ice_writel(ice, GENMASK(31, 0), QCOM_ICE_REG_HWKM_BANK0_BBAC_0);
254 qcom_ice_writel(ice, GENMASK(31, 0), QCOM_ICE_REG_HWKM_BANK0_BBAC_1);
255 qcom_ice_writel(ice, GENMASK(31, 0), QCOM_ICE_REG_HWKM_BANK0_BBAC_2);
256 qcom_ice_writel(ice, GENMASK(31, 0), QCOM_ICE_REG_HWKM_BANK0_BBAC_3);
257 qcom_ice_writel(ice, GENMASK(31, 0), QCOM_ICE_REG_HWKM_BANK0_BBAC_4);
260 qcom_ice_writel(ice, QCOM_ICE_HWKM_RSP_FIFO_CLEAR_VAL,
262 ice->hwkm_init_complete = true;
265 int qcom_ice_enable(struct qcom_ice *ice)
267 qcom_ice_low_power_mode_enable(ice);
268 qcom_ice_optimization_enable(ice);
269 qcom_ice_hwkm_init(ice);
270 return qcom_ice_wait_bist_status(ice);
274 int qcom_ice_resume(struct qcom_ice *ice)
276 struct device *dev = ice->dev;
279 err = clk_prepare_enable(ice->core_clk);
285 qcom_ice_hwkm_init(ice);
286 return qcom_ice_wait_bist_status(ice);
290 int qcom_ice_suspend(struct qcom_ice *ice)
292 clk_disable_unprepare(ice->core_clk);
293 ice->hwkm_init_complete = false;
299 static unsigned int translate_hwkm_slot(struct qcom_ice *ice, unsigned int slot)
304 static int qcom_ice_program_wrapped_key(struct qcom_ice *ice, unsigned int slot,
307 struct device *dev = ice->dev;
315 if (!ice->use_hwkm) {
319 if (!ice->hwkm_init_complete) {
325 qcom_ice_writel(ice, 0x0, QCOM_ICE_REG_CRYPTOCFG(slot));
328 err = qcom_scm_ice_set_key(translate_hwkm_slot(ice, slot), bkey->bytes,
338 qcom_ice_writel(ice, le32_to_cpu(cfg.regval),
343 int qcom_ice_program_key(struct qcom_ice *ice, unsigned int slot,
346 struct device *dev = ice->dev;
363 return qcom_ice_program_wrapped_key(ice, slot, blk_key);
365 if (ice->use_hwkm) {
390 int qcom_ice_evict_key(struct qcom_ice *ice, int slot)
392 if (ice->hwkm_init_complete)
393 slot = translate_hwkm_slot(ice, slot);
400 * @ice: ICE driver data
406 enum blk_crypto_key_type qcom_ice_get_supported_key_type(struct qcom_ice *ice)
408 if (ice->use_hwkm)
416 * @ice: ICE driver data
427 int qcom_ice_derive_sw_secret(struct qcom_ice *ice,
442 * @ice: ICE driver data
449 int qcom_ice_generate_key(struct qcom_ice *ice,
464 * @ice: ICE driver data
474 int qcom_ice_prepare_key(struct qcom_ice *ice,
493 * @ice: ICE driver data
502 int qcom_ice_import_key(struct qcom_ice *ice,
546 engine->core_clk = devm_clk_get_optional_enabled(dev, "ice");
565 * consumer device if its DT node provides the 'ice' reg range and the 'ice'
567 * phandle via 'qcom,ice' property to an ICE DT, the ICE instance will already
576 struct qcom_ice *ice;
587 * range called 'ice' it provides.
589 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice");
600 * If the consumer node does not provider an 'ice' reg range
605 "qcom,ice", 0);
615 ice = platform_get_drvdata(pdev);
616 if (!ice) {
617 dev_err(dev, "Cannot get ice instance from %s\n",
629 ice = ERR_PTR(-EINVAL);
632 return ice;
635 static void qcom_ice_put(const struct qcom_ice *ice)
637 struct platform_device *pdev = to_platform_device(ice->dev);
639 if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice"))
654 * consumer device if its DT node provides the 'ice' reg range and the 'ice'
656 * phandle via 'qcom,ice' property to an ICE DT, the ICE instance will already
664 struct qcom_ice *ice, **dr;
670 ice = of_qcom_ice_get(dev);
671 if (!IS_ERR_OR_NULL(ice)) {
672 *dr = ice;
678 return ice;
711 .name = "qcom-ice",