From patchwork Mon Jun 18 14:12:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 138955 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4004964lji; Mon, 18 Jun 2018 07:13:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJFtajZ+QLN66ldYsCbIuqUncj6KA9Ms5TG/oUHNqMGDky0NHR4JMK/AFfw6t06JSrMY0y+ X-Received: by 2002:a63:7b03:: with SMTP id w3-v6mr11437332pgc.52.1529331217993; Mon, 18 Jun 2018 07:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529331217; cv=none; d=google.com; s=arc-20160816; b=vdIUwrxErsFVWjdu3rxiNWsq1uvYCvKBVx8hY3HD5fnA896DB6eir3nCFN0tuQyjTu bDbKmZrjHUyySsVTDLuoyRDt4ZFVEK+xKa+KgM1FZdRHkeQvP3iCQnQmnseZd0C8JJbH 2F8RyrNyGhaReRFW5ZQPn+M+u8Y/yqkIm8g66aLpZSfTmDQ1D3lsl6qvBVf1d1iQMOpG ML4IyBalGOrVjQaJ8OWr7IwxWK/u+hxoxKyzNQqQqZmn8KqaOJdkZtniDBWXmu1RgEsK JRz3zuLoE9UrxgnvEU4MAPSPKpzXBFEWlBOSWv7MtuXZZ/1Et2IzkZUZq2fo1RtCnmdm mPUA== 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=UUJzwfgpvKs1LpNf7zUfObyZZsWD9zUmBur3t7sFcAo=; b=F+L/VxA1YB3DFwA4WqFXMfO/i0kSaPiaoZy0bj55SKooJGw5UNpbjzer43nFMm+OaG 8PzTooqebk/Xh4v+4v5zGRxNN6uRAzCkWbmICmtm+zq6KCC1mKz+aInp7PshnMvOiy3Y mWvIh6VfjmccoAgjj4RSWxqepyCQ0ha1aXUwPh0FRW+FbZwK6x6ScK+8oTKp4nXV/+X3 EDjRxQDWx+CZuoGwku8+Y+1faYH4XV5KYfszgFqTT8lvmk80nZ2bFSk2xWDSTiZPDDaO hlg3ZiVp3ks7UVNoJhAD+U5XpbFGI0W4JDYg0B9DnwZUNuJn10vKfYaFzTnaH3wxKGN+ anZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KFYwkS0F; 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 o3-v6si15178605pld.50.2018.06.18.07.13.37; Mon, 18 Jun 2018 07:13:37 -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=KFYwkS0F; 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 S934888AbeFRONf (ORCPT + 30 others); Mon, 18 Jun 2018 10:13:35 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:39456 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934733AbeFRONb (ORCPT ); Mon, 18 Jun 2018 10:13:31 -0400 Received: by mail-pf0-f195.google.com with SMTP id r11-v6so8242266pfl.6 for ; Mon, 18 Jun 2018 07:13:31 -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=UUJzwfgpvKs1LpNf7zUfObyZZsWD9zUmBur3t7sFcAo=; b=KFYwkS0FV/wf8gCkPEVCMxGpBZ0srhTzLP4tAb4AqBl05Yw1otuuJK7WmbAQZKdTul gu47WCGk7DrNEyYKFrecjRhyohbJhA3yaG1a54MXC3H2lCvOh6lgwsrwZdodRMK7XDWO 7EZwbPQZQs7w/hWsaEkEDZjmUIZWXYaf+8gqM= 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=UUJzwfgpvKs1LpNf7zUfObyZZsWD9zUmBur3t7sFcAo=; b=Psg5vsguO3ov3m1poaKDb8XGIq9Dg9uXNpmFQfGc+vmEo1tGzzqmeD52oHYgdPWT5H uQXGLDCOuioXnAPHCu5e6TPvRWD87HEv8vUZc2oXHAY33IUxGxsV9j4BdoRaI1xp+zNC aGFHYZHe3GCNJ7JQoSMMRVRCcmHZEOksROUZRu1ENILhSNAbD1nGXfgK/lOv0ltbXy6p a8BEGadNFvfnwOCNkgLXrlaEznYXCNBozw5yC2DvPab69Cl9/VYDNApbLqfuyA6irjG2 l1KJSVIPwvV1wXjmAYcAvWny3kScJHfOSXZ03p41W1Oy3XdGjKBmdprg1YsTi9daVp1u gXiw== X-Gm-Message-State: APt69E341Ect88P2iIRhMqRX7nLdIaM0Xi0Mr2LU3bI6Vmz81HiTMUoA OY8SsJLvwSeop1GcfgHHaLSzqQ== X-Received: by 2002:a62:d09:: with SMTP id v9-v6mr13565715pfi.163.1529331211173; Mon, 18 Jun 2018 07:13:31 -0700 (PDT) Received: from localhost.localdomain ([27.59.118.133]) by smtp.gmail.com with ESMTPSA id t17-v6sm25813339pfj.75.2018.06.18.07.13.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 07:13:30 -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, Vinod Koul Subject: [PATCH 3/3] hwrng: msm - Add support for prng v2 Date: Mon, 18 Jun 2018 19:42:59 +0530 Message-Id: <20180618141259.23141-4-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180618141259.23141-1-vkoul@kernel.org> References: <20180618141259.23141-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 where we need to only implement .read callback for hwrng. Add a new table for v2 which supports this and get version required for driver data. Signed-off-by: Vinod Koul --- drivers/char/hw_random/msm-rng.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.14.4 diff --git a/drivers/char/hw_random/msm-rng.c b/drivers/char/hw_random/msm-rng.c index 7644474035e5..3f509072a6c6 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 */ @@ -132,10 +133,16 @@ static struct hwrng msm_rng = { .read = msm_rng_read, }; +static struct hwrng msm_rng_v2 = { + .name = KBUILD_MODNAME, + .read = msm_rng_read, +}; + static int msm_rng_probe(struct platform_device *pdev) { struct resource *res; struct msm_rng *rng; + unsigned int version; int ret; rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); @@ -154,6 +161,9 @@ static int msm_rng_probe(struct platform_device *pdev) return PTR_ERR(rng->clk); rng->hwrng = &msm_rng; + version = (unsigned long)of_device_get_match_data(&pdev->dev); + if (version) + rng->hwrng = &msm_rng_v2; rng->hwrng->priv = (unsigned long)rng; ret = devm_hwrng_register(&pdev->dev, rng->hwrng); @@ -166,7 +176,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);