Lines Matching full:ice
3 * Qualcomm ICE (Inline Crypto Engine) support.
21 #include <soc/qcom/ice.h>
25 /* QCOM ICE registers */
51 static bool qcom_ice_check_supported(struct qcom_ice *ice) in qcom_ice_check_supported() argument
53 u32 regval = qcom_ice_readl(ice, QCOM_ICE_REG_VERSION); in qcom_ice_check_supported()
54 struct device *dev = ice->dev; in qcom_ice_check_supported()
59 /* For now this driver only supports ICE version 3 and 4. */ in qcom_ice_check_supported()
61 dev_warn(dev, "Unsupported ICE version: v%d.%d.%d\n", in qcom_ice_check_supported()
66 dev_info(dev, "Found QC Inline Crypto Engine (ICE) v%d.%d.%d\n", in qcom_ice_check_supported()
69 /* If fuses are blown, ICE might not work in the standard way. */ in qcom_ice_check_supported()
70 regval = qcom_ice_readl(ice, QCOM_ICE_REG_FUSE_SETTING); in qcom_ice_check_supported()
74 dev_warn(dev, "Fuses are blown; ICE is unusable!\n"); in qcom_ice_check_supported()
81 static void qcom_ice_low_power_mode_enable(struct qcom_ice *ice) in qcom_ice_low_power_mode_enable() argument
85 regval = qcom_ice_readl(ice, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_low_power_mode_enable()
89 qcom_ice_writel(ice, regval, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_low_power_mode_enable()
92 static void qcom_ice_optimization_enable(struct qcom_ice *ice) in qcom_ice_optimization_enable() argument
96 /* ICE Optimizations Enable Sequence */ in qcom_ice_optimization_enable()
97 regval = qcom_ice_readl(ice, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_optimization_enable()
99 /* ICE HPG requires delay before writing */ in qcom_ice_optimization_enable()
101 qcom_ice_writel(ice, regval, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_optimization_enable()
106 * Wait until the ICE BIST (built-in self-test) has completed.
108 * This may be necessary before ICE can be used.
112 * practice, (b) ICE is documented to reject crypto requests if the BIST
117 static int qcom_ice_wait_bist_status(struct qcom_ice *ice) in qcom_ice_wait_bist_status() argument
122 err = readl_poll_timeout(ice->base + QCOM_ICE_REG_BIST_STATUS, in qcom_ice_wait_bist_status()
126 dev_err(ice->dev, "Timed out waiting for ICE self-test to complete\n"); in qcom_ice_wait_bist_status()
131 int qcom_ice_enable(struct qcom_ice *ice) in qcom_ice_enable() argument
133 qcom_ice_low_power_mode_enable(ice); in qcom_ice_enable()
134 qcom_ice_optimization_enable(ice); in qcom_ice_enable()
136 return qcom_ice_wait_bist_status(ice); in qcom_ice_enable()
140 int qcom_ice_resume(struct qcom_ice *ice) in qcom_ice_resume() argument
142 struct device *dev = ice->dev; in qcom_ice_resume()
145 err = clk_prepare_enable(ice->core_clk); in qcom_ice_resume()
152 return qcom_ice_wait_bist_status(ice); in qcom_ice_resume()
156 int qcom_ice_suspend(struct qcom_ice *ice) in qcom_ice_suspend() argument
158 clk_disable_unprepare(ice->core_clk); in qcom_ice_suspend()
164 int qcom_ice_program_key(struct qcom_ice *ice, in qcom_ice_program_key() argument
169 struct device *dev = ice->dev; in qcom_ice_program_key()
202 int qcom_ice_evict_key(struct qcom_ice *ice, int slot) in qcom_ice_evict_key() argument
217 dev_warn(dev, "ICE SCM interface not found\n"); in qcom_ice_create()
237 engine->core_clk = devm_clk_get_optional_enabled(dev, "ice"); in qcom_ice_create()
252 * of_qcom_ice_get() - get an ICE instance from a DT node
255 * This function will provide an ICE instance either by creating one for the
256 * consumer device if its DT node provides the 'ice' reg range and the 'ice'
258 * phandle via 'qcom,ice' property to an ICE DT, the ICE instance will already
261 * Return: ICE pointer on success, NULL if there is no ICE data provided by the
267 struct qcom_ice *ice; in of_qcom_ice_get() local
277 * to create the ICE instance using the consumer device and the reg in of_qcom_ice_get()
278 * range called 'ice' it provides. in of_qcom_ice_get()
280 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice"); in of_qcom_ice_get()
286 /* create ICE instance using consumer dev */ in of_qcom_ice_get()
291 * If the consumer node does not provider an 'ice' reg range in of_qcom_ice_get()
293 * to the ICE devicetree node, otherwise ICE is not supported. in of_qcom_ice_get()
296 "qcom,ice", 0); in of_qcom_ice_get()
306 ice = platform_get_drvdata(pdev); in of_qcom_ice_get()
307 if (!ice) { in of_qcom_ice_get()
308 dev_err(dev, "Cannot get ice instance from %s\n", in of_qcom_ice_get()
320 ice = ERR_PTR(-EINVAL); in of_qcom_ice_get()
323 return ice; in of_qcom_ice_get()
334 dev_warn(&pdev->dev, "ICE registers not found\n"); in qcom_ice_probe()
356 .name = "qcom-ice",