From patchwork Tue Jun 19 09:54:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 139106 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4997236lji; Tue, 19 Jun 2018 02:55:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLLhWSsDrMuHfOSIJV5UmJ3ZOq2JUWv0iBD/Qsp6LE8VTqmd9zfElMLOe4lRH2HPJJH/rbV X-Received: by 2002:a65:5c42:: with SMTP id v2-v6mr14425256pgr.224.1529402133870; Tue, 19 Jun 2018 02:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529402133; cv=none; d=google.com; s=arc-20160816; b=C7Os2bJnQ4tLGGoZlemWY4Lp3SAynDZVDrkkv8vMLEoKHHurhiETgVreAusJmqTx78 h0GJ/ulhXVKcMzhqHyce753koNM4FdJzSR3JcOgQ4jFW5FoCxJp6KzTPKUdBR54t2ET6 mV78/GIAXYbKSNQ2WipivLGbX4ZN/+ZMXAkuAooTTi6oVWS9truJRNFrLNIO538ri26I yDmRq+mKs2+t6/56OPRfz0B4IRaNO3k0VDaYfzjpU5+YwqpnaYYnH5RkfQL7e9XUg6Gg 7G6GO6cLw6F5a3+a4RFWN6w++W9/jO4MyRkbCEgBRN8n5hx0bWJc+9KIbkBKnzLw42G9 PDbQ== 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=SvxzFx5lR7oWAmcesNlMhyn68C9L3dvoVz2STn24eco=; b=cK9uKDtj8wI+d1M13qCNmTBhwvWHriAScFB8QIk1346RwB5XL7r3OE9WKWd2un3Bie c7W8c8mcLO78cmc8nlZlN2smGqhtmBEoLrUs48sYmaEQZrGJa3oK1DfqjyJM3yuz0Ryw pIQn4r9RUiWPQnC4CwSFTHTr1ZYeoTUJ/Wif0MCZJLw2Hc+rWnobFboigbPyTsz/+AUS RF3vp+dsM/f24D2Jl9UQE2rK4Qb7pRdXIVsYgG1DBS2v5wHzxC+OWoNISx4ovnPQBL00 oGgN4rlYU2IbzlFZXXUDPPlHBay2aY1vXQ/KJPJVKICMdpu0C4z3VGadiN9NpQKhuFi9 4FjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRp+Z6fb; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21-v6si4664025pfn.99.2018.06.19.02.55.33; Tue, 19 Jun 2018 02:55:33 -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=@linaro.org header.s=google header.b=HRp+Z6fb; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937562AbeFSJzc (ORCPT + 30 others); Tue, 19 Jun 2018 05:55:32 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:46665 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756933AbeFSJzN (ORCPT ); Tue, 19 Jun 2018 05:55:13 -0400 Received: by mail-pl0-f66.google.com with SMTP id 30-v6so10658797pld.13 for ; Tue, 19 Jun 2018 02:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SvxzFx5lR7oWAmcesNlMhyn68C9L3dvoVz2STn24eco=; b=HRp+Z6fbFzlbVCOGd+pJiG/RzypXJripitLnflqgBQ+nsq/FV4Jt4Bi/VahX/Ra2fk fAzI5SWlHg/8Adsb2y1Kl/Jv0d6gQOWsfJr5x8D0HmyiJcFbD10ZnqKXaNu5PBG2sE0P /AdeUZQnXTFRLwEhbgVmg+n4/HDdpeQOsCTW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SvxzFx5lR7oWAmcesNlMhyn68C9L3dvoVz2STn24eco=; b=M6lYTMdQU7GyLsx7SdXXS1Wq4Hmm99szokg2wFwCqkNTgF4sp6LWByfIM/KkRkI0AW DwYJq+e/OopFDd1glwSns3Hd71EtZ1TfoN9hCMj57Yy/fLz4Eq5pxV2PqsXayWC8CbhF vQlbPWnjbpX38MPQ3BHqoJxU9GMKLmncWHElBS8WZ6QUtjRwq3dNSyifMbwSgheKXwDV jh68vrx3oFTu5QcU3H2c7HSfHWUQITuAj/TUVPJtgj1rUzTqNZDSSbu6Ra51b/9X0SLE 4Ru6vFM66Pq1JwHWXlQeO2EscKbSW8VzvbXi2iF7AdlYSVxi2oM19B/yQFtrV7EMt217 zzAw== X-Gm-Message-State: APt69E2tpX9efpITcqBQIoDCbKb0ScFgcpoNoCDh69xILUVYQisuq38G 18Wh7zKF7iqNq8CpKIX5holm/sGojjQ= X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr18062984plb.74.1529402113129; Tue, 19 Jun 2018 02:55:13 -0700 (PDT) Received: from localhost.localdomain ([106.200.222.147]) by smtp.gmail.com with ESMTPSA id c17-v6sm21182034pgw.11.2018.06.19.02.55.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jun 2018 02:55:12 -0700 (PDT) From: Vinod Koul X-Google-Original-From: Vinod Koul To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matt Mackall , Herbert Xu , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Stephen Boyd , vinod.koul@linaro.org, Vinod Koul Subject: [PATCH v2 2/2] hwrng: msm - Add support for prng v2 Date: Tue, 19 Jun 2018 15:24:30 +0530 Message-Id: <20180619095430.26358-3-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180619095430.26358-1-vkoul@kernel.org> References: <20180619095430.26358-1-vkoul@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Qcom 8996 and later chips support prng v2 which requires to implement only .read callback for hwrng. This version of chip has multiple Execution Environments (EE) and secure world is typically responsible for configuring the prng. Add driver data for qcom,prng as 0 and qcom,prng-v2 as 1 and use that to skip initialization and cleanup routines. Signed-off-by: Vinod Koul --- drivers/char/hw_random/msm-rng.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.14.4 diff --git a/drivers/char/hw_random/msm-rng.c b/drivers/char/hw_random/msm-rng.c index 841fee845ec9..4676520e1f16 100644 --- a/drivers/char/hw_random/msm-rng.c +++ b/drivers/char/hw_random/msm-rng.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* Device specific register offsets */ @@ -131,6 +132,7 @@ static int msm_rng_probe(struct platform_device *pdev) { struct resource *res; struct msm_rng *rng; + unsigned int skip_init; int ret; rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); @@ -149,9 +151,12 @@ static int msm_rng_probe(struct platform_device *pdev) return PTR_ERR(rng->clk); rng->hwrng.name = KBUILD_MODNAME, - rng->hwrng.init = msm_rng_init, - rng->hwrng.cleanup = msm_rng_cleanup, - rng->hwrng.read = msm_rng_read, + rng->hwrng.read = msm_rng_read; + skip_init = (unsigned long)of_device_get_match_data(&pdev->dev); + if (!skip_init) { + rng->hwrng.init = msm_rng_init; + rng->hwrng.cleanup = msm_rng_cleanup; + } ret = devm_hwrng_register(&pdev->dev, &rng->hwrng); if (ret) { @@ -163,7 +168,8 @@ static int msm_rng_probe(struct platform_device *pdev) } static const struct of_device_id msm_rng_of_match[] = { - { .compatible = "qcom,prng", }, + { .compatible = "qcom,prng", .data = (void *)0}, + { .compatible = "qcom,prng-v2", .data = (void *)1}, {} }; MODULE_DEVICE_TABLE(of, msm_rng_of_match);