Lines Matching full:ice
3 * Qualcomm ICE (Inline Crypto Engine) support.
22 #include <soc/qcom/ice.h>
26 /* QCOM ICE registers */
52 static bool qcom_ice_check_supported(struct qcom_ice *ice) in qcom_ice_check_supported() argument
54 u32 regval = qcom_ice_readl(ice, QCOM_ICE_REG_VERSION); in qcom_ice_check_supported()
55 struct device *dev = ice->dev; in qcom_ice_check_supported()
60 /* For now this driver only supports ICE version 3 and 4. */ in qcom_ice_check_supported()
62 dev_warn(dev, "Unsupported ICE version: v%d.%d.%d\n", in qcom_ice_check_supported()
67 dev_info(dev, "Found QC Inline Crypto Engine (ICE) v%d.%d.%d\n", in qcom_ice_check_supported()
70 /* If fuses are blown, ICE might not work in the standard way. */ in qcom_ice_check_supported()
71 regval = qcom_ice_readl(ice, QCOM_ICE_REG_FUSE_SETTING); in qcom_ice_check_supported()
75 dev_warn(dev, "Fuses are blown; ICE is unusable!\n"); in qcom_ice_check_supported()
82 static void qcom_ice_low_power_mode_enable(struct qcom_ice *ice) in qcom_ice_low_power_mode_enable() argument
86 regval = qcom_ice_readl(ice, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_low_power_mode_enable()
90 qcom_ice_writel(ice, regval, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_low_power_mode_enable()
93 static void qcom_ice_optimization_enable(struct qcom_ice *ice) in qcom_ice_optimization_enable() argument
97 /* ICE Optimizations Enable Sequence */ in qcom_ice_optimization_enable()
98 regval = qcom_ice_readl(ice, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_optimization_enable()
100 /* ICE HPG requires delay before writing */ in qcom_ice_optimization_enable()
102 qcom_ice_writel(ice, regval, QCOM_ICE_REG_ADVANCED_CONTROL); in qcom_ice_optimization_enable()
107 * Wait until the ICE BIST (built-in self-test) has completed.
109 * This may be necessary before ICE can be used.
113 * practice, (b) ICE is documented to reject crypto requests if the BIST
118 static int qcom_ice_wait_bist_status(struct qcom_ice *ice) in qcom_ice_wait_bist_status() argument
123 err = readl_poll_timeout(ice->base + QCOM_ICE_REG_BIST_STATUS, in qcom_ice_wait_bist_status()
127 dev_err(ice->dev, "Timed out waiting for ICE self-test to complete\n"); in qcom_ice_wait_bist_status()
132 int qcom_ice_enable(struct qcom_ice *ice) in qcom_ice_enable() argument
134 qcom_ice_low_power_mode_enable(ice); in qcom_ice_enable()
135 qcom_ice_optimization_enable(ice); in qcom_ice_enable()
137 return qcom_ice_wait_bist_status(ice); in qcom_ice_enable()
141 int qcom_ice_resume(struct qcom_ice *ice) in qcom_ice_resume() argument
143 struct device *dev = ice->dev; in qcom_ice_resume()
146 err = clk_prepare_enable(ice->core_clk); in qcom_ice_resume()
153 return qcom_ice_wait_bist_status(ice); in qcom_ice_resume()
157 int qcom_ice_suspend(struct qcom_ice *ice) in qcom_ice_suspend() argument
159 clk_disable_unprepare(ice->core_clk); in qcom_ice_suspend()
165 int qcom_ice_program_key(struct qcom_ice *ice, in qcom_ice_program_key() argument
170 struct device *dev = ice->dev; in qcom_ice_program_key()
203 int qcom_ice_evict_key(struct qcom_ice *ice, int slot) in qcom_ice_evict_key() argument
218 dev_warn(dev, "ICE SCM interface not found\n"); in qcom_ice_create()
238 engine->core_clk = devm_clk_get_optional_enabled(dev, "ice"); in qcom_ice_create()
253 * of_qcom_ice_get() - get an ICE instance from a DT node
256 * This function will provide an ICE instance either by creating one for the
257 * consumer device if its DT node provides the 'ice' reg range and the 'ice'
259 * phandle via 'qcom,ice' property to an ICE DT, the ICE instance will already
262 * Return: ICE pointer on success, NULL if there is no ICE data provided by the
268 struct qcom_ice *ice; in of_qcom_ice_get() local
278 * to create the ICE instance using the consumer device and the reg in of_qcom_ice_get()
279 * range called 'ice' it provides. in of_qcom_ice_get()
281 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice"); in of_qcom_ice_get()
287 /* create ICE instance using consumer dev */ in of_qcom_ice_get()
292 * If the consumer node does not provider an 'ice' reg range in of_qcom_ice_get()
294 * to the ICE devicetree node, otherwise ICE is not supported. in of_qcom_ice_get()
297 "qcom,ice", 0); in of_qcom_ice_get()
307 ice = platform_get_drvdata(pdev); in of_qcom_ice_get()
308 if (!ice) { in of_qcom_ice_get()
309 dev_err(dev, "Cannot get ice instance from %s\n", in of_qcom_ice_get()
321 ice = ERR_PTR(-EINVAL); in of_qcom_ice_get()
324 return ice; in of_qcom_ice_get()
327 static void qcom_ice_put(const struct qcom_ice *ice) in qcom_ice_put() argument
329 struct platform_device *pdev = to_platform_device(ice->dev); in qcom_ice_put()
331 if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice")) in qcom_ice_put()
341 * devm_of_qcom_ice_get() - Devres managed helper to get an ICE instance from
345 * This function will provide an ICE instance either by creating one for the
346 * consumer device if its DT node provides the 'ice' reg range and the 'ice'
348 * phandle via 'qcom,ice' property to an ICE DT, the ICE instance will already
351 * Return: ICE pointer on success, NULL if there is no ICE data provided by the
356 struct qcom_ice *ice, **dr; in devm_of_qcom_ice_get() local
362 ice = of_qcom_ice_get(dev); in devm_of_qcom_ice_get()
363 if (!IS_ERR_OR_NULL(ice)) { in devm_of_qcom_ice_get()
364 *dr = ice; in devm_of_qcom_ice_get()
370 return ice; in devm_of_qcom_ice_get()
381 dev_warn(&pdev->dev, "ICE registers not found\n"); in qcom_ice_probe()
403 .name = "qcom-ice",