Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: qcom-rng - Add ACPI support

Add support for probing on ACPI systems, with ACPI HID QCOM8160.

On ACPI systems, clocks are always enabled, the PRNG should
already be enabled, and the register region is read-only.
The driver only verifies that the hardware is already
enabled never tries to disable or configure it.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Jeffrey Hugo <jhugo@codeaurora.org>
[port to crypto API]
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Timur Tabi and committed by
Herbert Xu
d96542ac ba3ab637

+17 -3
+17 -3
drivers/crypto/qcom-rng.c
··· 4 4 // Based on msm-rng.c and downstream driver 5 5 6 6 #include <crypto/internal/rng.h> 7 + #include <linux/acpi.h> 7 8 #include <linux/clk.h> 8 9 #include <linux/crypto.h> 9 10 #include <linux/module.h> ··· 169 168 if (IS_ERR(rng->base)) 170 169 return PTR_ERR(rng->base); 171 170 172 - rng->clk = devm_clk_get(&pdev->dev, "core"); 173 - if (IS_ERR(rng->clk)) 174 - return PTR_ERR(rng->clk); 171 + /* ACPI systems have clk already on, so skip clk_get */ 172 + if (!has_acpi_companion(&pdev->dev)) { 173 + rng->clk = devm_clk_get(&pdev->dev, "core"); 174 + if (IS_ERR(rng->clk)) 175 + return PTR_ERR(rng->clk); 176 + } 177 + 175 178 176 179 rng->skip_init = (unsigned long)device_get_match_data(&pdev->dev); 177 180 ··· 198 193 return 0; 199 194 } 200 195 196 + #if IS_ENABLED(CONFIG_ACPI) 197 + static const struct acpi_device_id qcom_rng_acpi_match[] = { 198 + { .id = "QCOM8160", .driver_data = 1 }, 199 + {} 200 + }; 201 + MODULE_DEVICE_TABLE(acpi, qcom_rng_acpi_match); 202 + #endif 203 + 201 204 static const struct of_device_id qcom_rng_of_match[] = { 202 205 { .compatible = "qcom,prng", .data = (void *)0}, 203 206 { .compatible = "qcom,prng-ee", .data = (void *)1}, ··· 219 206 .driver = { 220 207 .name = KBUILD_MODNAME, 221 208 .of_match_table = of_match_ptr(qcom_rng_of_match), 209 + .acpi_match_table = ACPI_PTR(qcom_rng_acpi_match), 222 210 } 223 211 }; 224 212 module_platform_driver(qcom_rng_driver);