@@ -4,6 +4,7 @@
// Based on msm-rng.c and downstream driver
#include <crypto/internal/rng.h>
+#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/crypto.h>
#include <linux/module.h>
@@ -168,11 +169,21 @@ static int qcom_rng_probe(struct platform_device *pdev)
if (IS_ERR(rng->base))
return PTR_ERR(rng->base);
- rng->clk = devm_clk_get(&pdev->dev, "core");
- if (IS_ERR(rng->clk))
- return PTR_ERR(rng->clk);
- rng->skip_init = (unsigned long)of_device_get_match_data(&pdev->dev);
+ /*
+ * ACPI systems have v2 hardware. The clocks are always enabled,
+ * and we should skip init
+ */
+ if (has_acpi_companion(&pdev->dev)) {
+ rng->skip_init = 1;
+ } else {
+ rng->clk = devm_clk_get(&pdev->dev, "core");
+ if (IS_ERR(rng->clk))
+ return PTR_ERR(rng->clk);
+
+ rng->skip_init =
+ (unsigned long)of_device_get_match_data(&pdev->dev);
+ }
qcom_rng_dev = rng;
ret = crypto_register_rng(&qcom_rng_alg);
@@ -193,6 +204,16 @@ static int qcom_rng_remove(struct platform_device *pdev)
return 0;
}
+#if IS_ENABLED(CONFIG_ACPI)
+static const struct acpi_device_id qcom_rng_acpi_match[] = {
+ {
+ .id = "QCOM8160",
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, qcom_rng_acpi_match);
+#endif
+
static const struct of_device_id qcom_rng_of_match[] = {
{ .compatible = "qcom,prng", .data = (void *)0},
{ .compatible = "qcom,prng-ee", .data = (void *)1},
@@ -206,6 +227,7 @@ static struct platform_driver qcom_rng_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = of_match_ptr(qcom_rng_of_match),
+ .acpi_match_table = ACPI_PTR(qcom_rng_acpi_match),
}
};
module_platform_driver(qcom_rng_driver);