Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp777854imm; Mon, 2 Jul 2018 23:06:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmRDrCa9YRoc7rczflfRWb8brhedsdAYWYAw/3ga9CnU6nY2v2//B63TVQjxwY0FNvJ+5C X-Received: by 2002:a65:64c8:: with SMTP id t8-v6mr15784210pgv.110.1530597994459; Mon, 02 Jul 2018 23:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530597994; cv=none; d=google.com; s=arc-20160816; b=Dv7Z0ohkSBV6A7v5EH5C0jvteatwzGNrhZ0lTCfZiRz/PFStJbRcTQZhE1QWSvL3uQ TpngFK6/jfREESccthZ0zkT8laLy9Fu3jwIBymBkzE3wT9Lqax8Xgxw4H4lbyOBZYkPG LUPytkvr1WJoX36a2YaaKVHUC3uJ67MhyPn5BF1Ag3QBNl2XSaWUdIKRHwpKu8WHy0sp jfpxQsshMSWfxGvNqQvJ4DsJE6/eLTKArJbeoZ3u0oLx4mKhpw61sugiXPP3jmN4VNoX fOcT8WwhSa9MMCOi+JBXdDJPi2Iz56u9FazwLQWa1Mwx7PNI1O41ZEwriicUsFSynwWD N4ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=e4OmM8lymTlj+yw9dX2hmqXRV2oI84DEHfuTDsTtwQg=; b=S0w2mKCR8meTHG05n8EVNkRIVx6ASO3pnmVuxmB1IW2g/rii7MZSx+cpNiER9/tp+h 7wtDqCZP97EBSdYumGe7JUQivqfbeOXaxAVhqZxWfgcWTj+769o4zOnHncXlRkWgZ9Ar Buug6lRx+QHdj26dezzsqKQaDQKAaFAJCRMl+Z2ZgBR7ub6IsPI2aD3hOZ2sGzY7jPfX 8r57PFPycMU6fAK5D6aV4In0E0uvPR7iPA2eGMYZv0q05cICdAoXS3OStTjUGU5EU3QU nH2C21c+T097tK0YMTutWGmSnjDJKvOfPpQrl/Yssdad7cWYk6FPgVCI5o2v+VDwNVyT m9Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EbSsGKxs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2-v6si378532pge.64.2018.07.02.23.06.17; Mon, 02 Jul 2018 23:06:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EbSsGKxs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754428AbeGCGFb (ORCPT + 99 others); Tue, 3 Jul 2018 02:05:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:48904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754330AbeGCGF3 (ORCPT ); Tue, 3 Jul 2018 02:05:29 -0400 Received: from localhost.localdomain (unknown [171.61.87.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1ACB2246B; Tue, 3 Jul 2018 06:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530597928; bh=aF3rf44giV/wvjQxhP5XV8IvH31YiGS4j2a0DW/7JAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EbSsGKxsjEznU5RWPLr8Vfrqh0JKLVCtiqZEeEx7zS5RCcOsq6+8iWqsnfM9SAu8k Dh5s0dXhLOFU18Tv2HkofI5nIBVEqiEH2EiFAibmIVw0kKYJyh2FHlr4/mi5AWb0xh zS6eVxXTeN0hZx+WpseXo08f9keQQuIotUODGSuQ= From: Vinod Koul To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bjorn Andersson , Matt Mackall , Herbert Xu , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Stephen Boyd , Timur Tabi , Vinod Koul Subject: [PATCH v3 6/6] crypto: qcom: Add ACPI support Date: Tue, 3 Jul 2018 11:34:34 +0530 Message-Id: <20180703060434.19293-7-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180703060434.19293-1-vkoul@kernel.org> References: <20180703060434.19293-1-vkoul@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Timur Tabi 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 [port to crypto API] Signed-off-by: Vinod Koul --- drivers/crypto/qcom-rng.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c index fdbbcac7bcb8..bc0131d130d6 100644 --- a/drivers/crypto/qcom-rng.c +++ b/drivers/crypto/qcom-rng.c @@ -4,6 +4,7 @@ // Based on msm-rng.c and downstream driver #include +#include #include #include #include @@ -154,6 +155,7 @@ static int qcom_rng_probe(struct platform_device *pdev) { struct resource *res; struct qcom_rng *rng; + u32 val; int ret; rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); @@ -168,11 +170,27 @@ 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, + * the PRNG register space is read-only and the PRNG should + * already be enabled. + */ + if (has_acpi_companion(&pdev->dev)) { + val = readl(rng->base + PRNG_CONFIG); + if (!(val & PRNG_CONFIG_HW_ENABLE)) { + dev_err(&pdev->dev, "device is not enabled\n"); + return -ENODEV; + } + 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 +211,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, msm_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 +234,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); -- 2.14.4