Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp712621imm; Wed, 4 Jul 2018 04:47:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdEy+vFXOmFKpk1P8WjOzXkMsCGn/eSJbLL7XDIo3cAh7eN57QRZWo9mUlPbb6hTEnsugDa X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr1777833plg.135.1530704867714; Wed, 04 Jul 2018 04:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704867; cv=none; d=google.com; s=arc-20160816; b=Ul+0m1EicJbJwQQjhwGUwkqW7iFhFJ/5Up4XFfv/9CY8AkkC5CkfpvqzZ2/PU8CICo kxdm3pAQQaB4keSEegYWjojZJ74MfASnuG5E62R7pDlvZj0smQyXr+qS1vv9tCEF3Hpk eyVrHv2tlxC7TRyEwaUzgGN/ECKHmU2Y97XBD8PxAgOdHUVUaxu7udxMTNTCyJnVV1f+ G/FDwAq1hkgmlThqjBCUT50etjZBu0dgLiNs6KxE4Qwkrq9aS+eljQgtJGs04lxEKuDW Z8d0/ew1Nl7nBxRxozszYC/yalKVxzOGthao70rmGQPlnkljVI9obFJ8ggMopG1ou5kA b7Zg== 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=x2ycIlTlsBd27VfGpmcx9fZqXSq8El4Jm4Rc3+rYSMw=; b=djdjaSecHd0rJBXgLGXbEOxLFkrbvfnHrCbjHhZQEYwBwpTLqnX+dgdZg1hK/fKp4j ATy3fhXOI19XuQ/5bEIHDpiNUp58M7x7LVAgVL7C164RizmLhdQ3YdxrVe7PMhqAGzJE +mKpSWavGfl7gZABBxFu8HIF1tM6Bx3XsVnn9a6N7IolFW2c4DW9uHzOBJqrE2f9DGJs IdVYJxlG3gCkkKLQgfdc/vCfyvOafRXmwM4aVaGaZADzBdrJgMnTBjGv7+wprlpbrZb0 nbtX/Z0E024Ty8I4I8rJ+JqcglOazKJr3fbiXMxLByeFJ81N292836SD9LPuoHT/2QVE N64A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfMGiwnh; 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 w4-v6si2976119pgr.549.2018.07.04.04.47.32; Wed, 04 Jul 2018 04:47:47 -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=sfMGiwnh; 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 S934533AbeGDLpa (ORCPT + 99 others); Wed, 4 Jul 2018 07:45:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933071AbeGDLp1 (ORCPT ); Wed, 4 Jul 2018 07:45:27 -0400 Received: from localhost.localdomain (unknown [122.167.70.177]) (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 D675220841; Wed, 4 Jul 2018 11:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530704727; bh=NugPpvYkEUG8AtCvb5riLANuH/rmqyB7rHwo2Xy1DV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfMGiwnh+qS852UVOyhjUUgTdAKaeKHW2n0oM+va5N5roDHDHkcEeGqcg63tzXRxK BXG/EtH8npQwB5mTq9z2iesOOQwIfW6NtBEjGhHTNK0oO4Jowwy21gc33+fxM32dDF YIO8v9KFTYQl99oRCZdStupLHOohRl5YIVHHMX5U= 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 v4 6/6] crypto: qcom: Add ACPI support Date: Wed, 4 Jul 2018 17:14:27 +0530 Message-Id: <20180704114427.29953-7-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180704114427.29953-1-vkoul@kernel.org> References: <20180704114427.29953-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 | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c index f1bd86acaf9d..385352e200db 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 @@ -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); -- 2.14.4