From patchwork Wed Jul 4 11:44:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141557 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp707357ljj; Wed, 4 Jul 2018 04:47:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfdNfbHdnmY55tv8YdF1ToJYFYPUDHvAUccaNu/2Z6MDFwdy5drRwxGQmFeif+W9xmFaVd3 X-Received: by 2002:a63:1d22:: with SMTP id d34-v6mr1609218pgd.133.1530704840323; Wed, 04 Jul 2018 04:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704840; cv=none; d=google.com; s=arc-20160816; b=o/FLkqq+jfuQB8FpUml1qOxrs7N8a2tYJu1u8TdfXw4BlWakRk+6Drn2Oy4JXHtOwD N5WqrWOOu1nlLYLuXTKfNvJOlD6imeXiFh3wDa5gJ1p6bdt9Tj0FY8P6BODREoi/wvAA yZiisYnIcrDFV4kms7rkWqWrzA1cdwAxuNgobLV9lelwFvaz7bvSa1ucFuT1WgBzC93r 8ppf1ZslzE2rDlOomM6okbT+D+rMrzLyLMw/JHnoweq2Qman8Z7LcsZQMpCPsaTF89vl lz0CaXQj/IQ8yi13Wk/UGFPpc4tWlzXifNCIn/tzJTh5bKYZib1NVxS7hSPBYIDTjzT8 Qx+g== 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=db9f9O1wO+am4O7AFImkIndAS5qn159aD76FgQKTrWA=; b=Jw3eeecz24FbbvzVg4iXkzxtNsNLCaA+D3FmwujMuXSPRxOgGpAX9fcmxiNW9szeqT AHwM36NNGkLHwwPRr1o1RwXwUVPuczdSWGBcuXxR8c5TYx9ZinUC8urxmHQIYcfZ0Cjz ntJmm4b7kyxXSRA+GfEgUGs5Cous8JjsHo36Fs+Zsg2YmpHM29JvhtekKABU6v+YPjIX w1RUh9WjybLZec/+B4/fgK1HgNs51zIJUuML2H/0uPxAuWQ7KPEmBMwmEwi6yG3F1cE1 NZnXiBGMMu7tpET2i73jwR5IaNQfndqgFgO67X97k/oAnYHVf94fDyksKC+xcVpfY7NQ JL3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rMIgd6C1; 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 u1-v6si3299711pga.71.2018.07.04.04.47.20; Wed, 04 Jul 2018 04:47:20 -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=rMIgd6C1; 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 S934532AbeGDLrS (ORCPT + 31 others); Wed, 4 Jul 2018 07:47:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:38572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933942AbeGDLpI (ORCPT ); Wed, 4 Jul 2018 07:45:08 -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 AD5CF20841; Wed, 4 Jul 2018 11:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530704708; bh=QHlfFWkyv68lLcDSRc/A3DiLWtGSclMye8C9IV2typY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rMIgd6C1mfNug4mxGDaXFWt6O4t4+6/elIcl3LeKqRdGWhVOvTmb5qxf+WrIAfPDH dKp7diWSWNVd8XG9i+QupQf7kYejKt9JB7/TWZN/Widm8joBmk4TSZqcHs8wR/qxK3 d68TITvkzSG2JxgOxiVWeaef8oodztx1OsAFpwC4= 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 1/6] hwrng: remove msm hw_random driver Date: Wed, 4 Jul 2018 17:14:22 +0530 Message-Id: <20180704114427.29953-2-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 This driver is for a pseudo-rng so should not be added in hwrng. Remove it so that it's replacement can be added. Signed-off-by: Vinod Koul --- drivers/char/hw_random/Kconfig | 13 --- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/msm-rng.c | 183 --------------------------------------- 3 files changed, 197 deletions(-) delete mode 100644 drivers/char/hw_random/msm-rng.c -- 2.14.4 diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index c34b257d852d..dac895dc01b9 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -307,19 +307,6 @@ config HW_RANDOM_HISI If unsure, say Y. -config HW_RANDOM_MSM - tristate "Qualcomm SoCs Random Number Generator support" - depends on HW_RANDOM && ARCH_QCOM - default HW_RANDOM - ---help--- - This driver provides kernel-side support for the Random Number - Generator hardware found on Qualcomm SoCs. - - To compile this driver as a module, choose M here. the - module will be called msm-rng. - - If unsure, say Y. - config HW_RANDOM_ST tristate "ST Microelectronics HW Random Number Generator support" depends on HW_RANDOM && ARCH_STI diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 533e913c93d1..e35ec3ce3a20 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -29,7 +29,6 @@ obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o obj-$(CONFIG_HW_RANDOM_HISI) += hisi-rng.o obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o -obj-$(CONFIG_HW_RANDOM_MSM) += msm-rng.o obj-$(CONFIG_HW_RANDOM_ST) += st-rng.o obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o obj-$(CONFIG_HW_RANDOM_STM32) += stm32-rng.o diff --git a/drivers/char/hw_random/msm-rng.c b/drivers/char/hw_random/msm-rng.c deleted file mode 100644 index 841fee845ec9..000000000000 --- a/drivers/char/hw_random/msm-rng.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#include -#include -#include -#include -#include -#include -#include - -/* Device specific register offsets */ -#define PRNG_DATA_OUT 0x0000 -#define PRNG_STATUS 0x0004 -#define PRNG_LFSR_CFG 0x0100 -#define PRNG_CONFIG 0x0104 - -/* Device specific register masks and config values */ -#define PRNG_LFSR_CFG_MASK 0x0000ffff -#define PRNG_LFSR_CFG_CLOCKS 0x0000dddd -#define PRNG_CONFIG_HW_ENABLE BIT(1) -#define PRNG_STATUS_DATA_AVAIL BIT(0) - -#define MAX_HW_FIFO_DEPTH 16 -#define MAX_HW_FIFO_SIZE (MAX_HW_FIFO_DEPTH * 4) -#define WORD_SZ 4 - -struct msm_rng { - void __iomem *base; - struct clk *clk; - struct hwrng hwrng; -}; - -#define to_msm_rng(p) container_of(p, struct msm_rng, hwrng) - -static int msm_rng_enable(struct hwrng *hwrng, int enable) -{ - struct msm_rng *rng = to_msm_rng(hwrng); - u32 val; - int ret; - - ret = clk_prepare_enable(rng->clk); - if (ret) - return ret; - - if (enable) { - /* Enable PRNG only if it is not already enabled */ - val = readl_relaxed(rng->base + PRNG_CONFIG); - if (val & PRNG_CONFIG_HW_ENABLE) - goto already_enabled; - - val = readl_relaxed(rng->base + PRNG_LFSR_CFG); - val &= ~PRNG_LFSR_CFG_MASK; - val |= PRNG_LFSR_CFG_CLOCKS; - writel(val, rng->base + PRNG_LFSR_CFG); - - val = readl_relaxed(rng->base + PRNG_CONFIG); - val |= PRNG_CONFIG_HW_ENABLE; - writel(val, rng->base + PRNG_CONFIG); - } else { - val = readl_relaxed(rng->base + PRNG_CONFIG); - val &= ~PRNG_CONFIG_HW_ENABLE; - writel(val, rng->base + PRNG_CONFIG); - } - -already_enabled: - clk_disable_unprepare(rng->clk); - return 0; -} - -static int msm_rng_read(struct hwrng *hwrng, void *data, size_t max, bool wait) -{ - struct msm_rng *rng = to_msm_rng(hwrng); - size_t currsize = 0; - u32 *retdata = data; - size_t maxsize; - int ret; - u32 val; - - /* calculate max size bytes to transfer back to caller */ - maxsize = min_t(size_t, MAX_HW_FIFO_SIZE, max); - - ret = clk_prepare_enable(rng->clk); - if (ret) - return ret; - - /* read random data from hardware */ - do { - val = readl_relaxed(rng->base + PRNG_STATUS); - if (!(val & PRNG_STATUS_DATA_AVAIL)) - break; - - val = readl_relaxed(rng->base + PRNG_DATA_OUT); - if (!val) - break; - - *retdata++ = val; - currsize += WORD_SZ; - - /* make sure we stay on 32bit boundary */ - if ((maxsize - currsize) < WORD_SZ) - break; - } while (currsize < maxsize); - - clk_disable_unprepare(rng->clk); - - return currsize; -} - -static int msm_rng_init(struct hwrng *hwrng) -{ - return msm_rng_enable(hwrng, 1); -} - -static void msm_rng_cleanup(struct hwrng *hwrng) -{ - msm_rng_enable(hwrng, 0); -} - -static int msm_rng_probe(struct platform_device *pdev) -{ - struct resource *res; - struct msm_rng *rng; - int ret; - - rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); - if (!rng) - return -ENOMEM; - - platform_set_drvdata(pdev, rng); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - rng->base = devm_ioremap_resource(&pdev->dev, res); - 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->hwrng.name = KBUILD_MODNAME, - rng->hwrng.init = msm_rng_init, - rng->hwrng.cleanup = msm_rng_cleanup, - rng->hwrng.read = msm_rng_read, - - ret = devm_hwrng_register(&pdev->dev, &rng->hwrng); - if (ret) { - dev_err(&pdev->dev, "failed to register hwrng\n"); - return ret; - } - - return 0; -} - -static const struct of_device_id msm_rng_of_match[] = { - { .compatible = "qcom,prng", }, - {} -}; -MODULE_DEVICE_TABLE(of, msm_rng_of_match); - -static struct platform_driver msm_rng_driver = { - .probe = msm_rng_probe, - .driver = { - .name = KBUILD_MODNAME, - .of_match_table = of_match_ptr(msm_rng_of_match), - } -}; -module_platform_driver(msm_rng_driver); - -MODULE_ALIAS("platform:" KBUILD_MODNAME); -MODULE_AUTHOR("The Linux Foundation"); -MODULE_DESCRIPTION("Qualcomm MSM random number generator driver"); -MODULE_LICENSE("GPL v2"); From patchwork Wed Jul 4 11:44:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141561 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp705668ljj; Wed, 4 Jul 2018 04:45:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc/BDeTldxjx1wH9LCkZ4tOqOKhQEYQRY3Fqj87rdiHPW4pH9Eeji/DxuXh6+4CFQmSdT3i X-Received: by 2002:a17:902:26:: with SMTP id 35-v6mr1791156pla.276.1530704719693; Wed, 04 Jul 2018 04:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704719; cv=none; d=google.com; s=arc-20160816; b=vnXM5XJoITswza8J+OyxTlXPpV3D8CtO+tdp+fb1LAykEG5pMla6gQHUlE09RYxdeO y6gttKn7rjvmDVdAqgsu7I48I/TM210KCTEidv2N+0v7rQBH8V/BUAoSF6mYqt9Dp2/W LU3kpiv1Xc9yXHyJnrJoeoewBaQ06eTJ0jFuEibpgo4r275d/FL3aSuTVNK7RPKbFtMX UtyeV3PIcVCjntby3G2OGpUnw0G7YPuOAo12HdDKy7La24vSB1JkezyVgu4QaN9dSwr2 Vzw22QvNbDyFuBt7NyB9x8jozm/zUqzaJVQJYbjFbgKeKU17mhd55rALZ6rqIGNPL1c6 Aalg== 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=dA/j/tFoxxP3yrRqCRqNVjBBipgMx8wg3552GT0Mq4M=; b=ho6OY9vtXxy+mWIE57o2TwXWWWI3e/qnn+Y+Q2Z5LONHWdRHlTxD8zmo4zp6PVzRAs Vfu38WQtrrfLniNbsNp2jM/msSWenoAAE6kI+6IKyvd/YdiFgk7r/P1oPozhkiyyHLbj EjuWJSUEyhMVbE89kUT7Hrj+OvnWbi40tE1Al3DVZiYVjdzwkl+umZupjCpS0UrsUGA4 XZaY4O9cOoEyYFhqHBjffx88KKWH1E3bbFzwxm6yUG507wVWDKT3wrMTDFKNBHv+DfpM bR0CikCE3xA+gNO0vJ+BB9m1geDowgS63c/+Z/NhZmnDMjxUWSsijkKacsWwrIplKAw4 aGlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="x/j/75hQ"; 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 e189-v6si3477789pfe.80.2018.07.04.04.45.19; Wed, 04 Jul 2018 04:45:19 -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="x/j/75hQ"; 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 S934211AbeGDLpQ (ORCPT + 31 others); Wed, 4 Jul 2018 07:45:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933296AbeGDLpM (ORCPT ); Wed, 4 Jul 2018 07:45:12 -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 BE0BB21456; Wed, 4 Jul 2018 11:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530704712; bh=Y6e/3n+guSDc62R6uIPH9agVkOQjWphtXjwR8dgS8bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x/j/75hQqkC3KIACIHtCdbE4LvwS04VBDIW5etGas0uPLmJNX/Mmtk9i9nzIIqjXd lQJGjSAIZUsTGp7nbFQsCyAJP1WRdYWkIhqpZLhBGVH4kEbOZNA/rH39iwpS4AWF7X kT5Jip62XoNm7VjHwEXw6kIZuMImuIh1RctvCICw= 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 2/6] dt-bindings: crypto: Move prng binding to crypto Date: Wed, 4 Jul 2018 17:14:23 +0530 Message-Id: <20180704114427.29953-3-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 Now that we are adding new driver for prng in crypto, move the binding as well. Signed-off-by: Vinod Koul --- Documentation/devicetree/bindings/{rng => crypto}/qcom,prng.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Documentation/devicetree/bindings/{rng => crypto}/qcom,prng.txt (100%) -- 2.14.4 diff --git a/Documentation/devicetree/bindings/rng/qcom,prng.txt b/Documentation/devicetree/bindings/crypto/qcom,prng.txt similarity index 100% rename from Documentation/devicetree/bindings/rng/qcom,prng.txt rename to Documentation/devicetree/bindings/crypto/qcom,prng.txt From patchwork Wed Jul 4 11:44:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141560 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp705725ljj; Wed, 4 Jul 2018 04:45:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdYU6tjEVQ5PTG6fpDxfGFJJsOgG+rJ42TcQc5H6Rk5PysVaCtv6ZdOL25EY2DdjJ3wjv/O X-Received: by 2002:a62:2281:: with SMTP id p1-v6mr1844655pfj.53.1530704722773; Wed, 04 Jul 2018 04:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704722; cv=none; d=google.com; s=arc-20160816; b=O5mntnCA23IZuvELa/Rx6CZ1LgpDOfvnt6u3jDyxOL7YbTljYRFr4+6VuaD2wOtLId PE0wU044InCI2IkV1xm8p83EdyCcWNM2ff7pF+hlJJFXr2lY3FW0ZR/hr8wv/PLquEDo WiWzM6s50dxOVkkh7eC1v89oNTt3aGrznIAjst9yA5tf+0uFrOH0C+rt2c8IgxBPHf+T sRH/lp7g6l+QAOGGIMl2YGtPddTjIUCKTeC6bpLF1FdPMbMITxnitjbsJOUOMGPGi4h9 37jvkl3kWEW2vnWYWlb/sZgWgsllsL228bfdAUrLwoRPEwA7xieRb38hdfUXAEbhwEQ/ daQQ== 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=ctivs5GSeDyx7l3Q1QcBekkffufQ52yew2B67+sWGpY=; b=tOuAAHeleIQz04Z20cI1+0Cni0EUNUNyWHm2A6lEKWmb0dyyLt+98rwkgTY2yHUrzX SAeazb7YgWadruXcmW4r4bJthhAYpBKzeG99bXdtPkJcCIcm1M4jCDPYmqr4Naa7m/fi x3pOsxs2yYUfq4xy/3AbWhXsT+jpjm8BthgxjhApWgj4/5bq60jxRjPhmnXnpDp1RpbM cyRPtvfIDZ+A1dP4Hf8m7+Vr8XLcjxbRdC6hy3pS6FhusjRV8HuPHH8VPBkz8yxP6OR6 RNyBB06HyNLWzwRJl7nGQ1ocFxy1mIhozqCePqp9CmThjyafmyPnuJKezexxZL2MR/rP lDTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FhwrB8tN; 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 e189-v6si3477789pfe.80.2018.07.04.04.45.22; Wed, 04 Jul 2018 04:45:22 -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=FhwrB8tN; 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 S934340AbeGDLpT (ORCPT + 31 others); Wed, 4 Jul 2018 07:45:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:38668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934165AbeGDLpQ (ORCPT ); Wed, 4 Jul 2018 07:45:16 -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 8826A242EF; Wed, 4 Jul 2018 11:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530704715; bh=hbXEjmygzjPBSVObJiIro+7rf/uoG9UZvmd8cbLXrSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FhwrB8tNv985pLVaZYTQ+nDwNAuCB8qYvgRM8lwm7Xp4iamU+SsTTFYEbW6h51UTC LgWITRGKp3Wzxd+jECXR3E1PI1rUeGqMFPwQE2k/O81VKoRezdK2ymt61yJy1femZz qOG9uRrQ0F8z7ZW8/83lW423VkbmtIIn9/pR/GVo= 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 3/6] crypto: Add Qcom prng driver Date: Wed, 4 Jul 2018 17:14:24 +0530 Message-Id: <20180704114427.29953-4-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 This ports the Qcom prng from older hw_random driver. No change of functionality and move from hw_random to crypto APIs is done. Signed-off-by: Vinod Koul --- drivers/crypto/Kconfig | 11 +++ drivers/crypto/Makefile | 1 + drivers/crypto/qcom-rng.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 drivers/crypto/qcom-rng.c -- 2.14.4 diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 43cccf6aff61..b8d9e71e550a 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -585,6 +585,17 @@ config CRYPTO_DEV_QCE hardware. To compile this driver as a module, choose M here. The module will be called qcrypto. +config CRYPTO_DEV_QCOM_RNG + tristate "Qualcomm Randon Number Generator Driver" + depends on ARCH_QCOM || COMPILE_TEST + select CRYPTO_RNG + help + This driver provides support for the Random Number + Generator hardware found on Qualcomm SoCs. + + To compile this driver as a module, choose M here. the + module will be called qcom-rng. If unsure, say N. + config CRYPTO_DEV_VMX bool "Support for VMX cryptographic acceleration instructions" depends on PPC64 && VSX diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index 7ae87b4f6c8d..3602875c4f80 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_CRYPTO_DEV_PICOXCELL) += picoxcell_crypto.o obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/ obj-$(CONFIG_CRYPTO_DEV_QAT) += qat/ obj-$(CONFIG_CRYPTO_DEV_QCE) += qce/ +obj-$(CONFIG_CRYPTO_DEV_QCOM_RNG) += qcom-rng.o obj-$(CONFIG_CRYPTO_DEV_ROCKCHIP) += rockchip/ obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c new file mode 100644 index 000000000000..53e1d276e05e --- /dev/null +++ b/drivers/crypto/qcom-rng.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017-18 Linaro Limited +// +// Based on msm-rng.c and downstream driver + +#include +#include +#include +#include +#include +#include + +/* Device specific register offsets */ +#define PRNG_DATA_OUT 0x0000 +#define PRNG_STATUS 0x0004 +#define PRNG_LFSR_CFG 0x0100 +#define PRNG_CONFIG 0x0104 + +/* Device specific register masks and config values */ +#define PRNG_LFSR_CFG_MASK 0x0000ffff +#define PRNG_LFSR_CFG_CLOCKS 0x0000dddd +#define PRNG_CONFIG_HW_ENABLE BIT(1) +#define PRNG_STATUS_DATA_AVAIL BIT(0) + +#define WORD_SZ 4 + +struct qcom_rng { + struct mutex lock; + void __iomem *base; + struct clk *clk; +}; + +struct qcom_rng_ctx { + struct qcom_rng *rng; +}; + +static struct qcom_rng *qcom_rng_dev; + +static int qcom_rng_read(struct qcom_rng *rng, u8 *data, unsigned int max) +{ + unsigned int currsize = 0; + u32 val; + + /* read random data from hardware */ + do { + val = readl_relaxed(rng->base + PRNG_STATUS); + if (!(val & PRNG_STATUS_DATA_AVAIL)) + break; + + val = readl_relaxed(rng->base + PRNG_DATA_OUT); + if (!val) + break; + + if ((max - currsize) >= WORD_SZ) { + memcpy(data, &val, WORD_SZ); + data += WORD_SZ; + currsize += WORD_SZ; + } else { + /* copy only remaining bytes */ + memcpy(data, &val, max - currsize); + break; + } + } while (currsize < max); + + return currsize; +} + +static int qcom_rng_generate(struct crypto_rng *tfm, + const u8 *src, unsigned int slen, + u8 *dstn, unsigned int dlen) +{ + struct qcom_rng_ctx *ctx = crypto_rng_ctx(tfm); + struct qcom_rng *rng = ctx->rng; + int ret; + + ret = clk_prepare_enable(rng->clk); + if (ret) + return ret; + + mutex_lock(&rng->lock); + + ret = qcom_rng_read(rng, dstn, dlen); + + mutex_unlock(&rng->lock); + clk_disable_unprepare(rng->clk); + + return 0; +} + +static int qcom_rng_seed(struct crypto_rng *tfm, const u8 *seed, + unsigned int slen) +{ + return 0; +} + +static int qcom_rng_enable(struct qcom_rng *rng) +{ + u32 val; + int ret; + + ret = clk_prepare_enable(rng->clk); + if (ret) + return ret; + + /* Enable PRNG only if it is not already enabled */ + val = readl_relaxed(rng->base + PRNG_CONFIG); + if (val & PRNG_CONFIG_HW_ENABLE) + goto already_enabled; + + val = readl_relaxed(rng->base + PRNG_LFSR_CFG); + val &= ~PRNG_LFSR_CFG_MASK; + val |= PRNG_LFSR_CFG_CLOCKS; + writel(val, rng->base + PRNG_LFSR_CFG); + + val = readl_relaxed(rng->base + PRNG_CONFIG); + val |= PRNG_CONFIG_HW_ENABLE; + writel(val, rng->base + PRNG_CONFIG); + +already_enabled: + clk_disable_unprepare(rng->clk); + + return 0; +} + +static int qcom_rng_init(struct crypto_tfm *tfm) +{ + struct qcom_rng_ctx *ctx = crypto_tfm_ctx(tfm); + + ctx->rng = qcom_rng_dev; + + return qcom_rng_enable(ctx->rng); +} + +static struct rng_alg qcom_rng_alg = { + .generate = qcom_rng_generate, + .seed = qcom_rng_seed, + .seedsize = 0, + .base = { + .cra_name = "stdrng", + .cra_driver_name = "qcom-rng", + .cra_flags = CRYPTO_ALG_TYPE_RNG, + .cra_priority = 300, + .cra_ctxsize = sizeof(struct qcom_rng_ctx), + .cra_module = THIS_MODULE, + .cra_init = qcom_rng_init, + } +}; + +static int qcom_rng_probe(struct platform_device *pdev) +{ + struct resource *res; + struct qcom_rng *rng; + int ret; + + rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); + if (!rng) + return -ENOMEM; + + platform_set_drvdata(pdev, rng); + mutex_init(&rng->lock); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + rng->base = devm_ioremap_resource(&pdev->dev, res); + 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); + + qcom_rng_dev = rng; + ret = crypto_register_rng(&qcom_rng_alg); + if (ret) { + dev_err(&pdev->dev, "Register crypto rng failed: %d\n", ret); + qcom_rng_dev = NULL; + } + + return ret; +} + +static int qcom_rng_remove(struct platform_device *pdev) +{ + crypto_unregister_rng(&qcom_rng_alg); + + qcom_rng_dev = NULL; + + return 0; +} + +static const struct of_device_id qcom_rng_of_match[] = { + { .compatible = "qcom,prng" }, + {} +}; +MODULE_DEVICE_TABLE(of, qcom_rng_of_match); + +static struct platform_driver qcom_rng_driver = { + .probe = qcom_rng_probe, + .remove = qcom_rng_remove, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = of_match_ptr(qcom_rng_of_match), + } +}; +module_platform_driver(qcom_rng_driver); + +MODULE_ALIAS("platform:" KBUILD_MODNAME); +MODULE_DESCRIPTION("Qualcomm random number generator driver"); +MODULE_LICENSE("GPL v2"); From patchwork Wed Jul 4 11:44:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141559 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp705740ljj; Wed, 4 Jul 2018 04:45:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeNmcHhlAGrxFL/owqwIf5Ki3H2XrgvuqaOkI7AMrqnxeHMr07mazCHTHp2jAm4FtMd/1Ms X-Received: by 2002:a17:902:d711:: with SMTP id w17-v6mr1762472ply.200.1530704724373; Wed, 04 Jul 2018 04:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704724; cv=none; d=google.com; s=arc-20160816; b=VB/Ayj0a6fNiCSSJMnmZxTEAJoOgjlzGLGeZbBn7NHZqVSW3CLJVbFV0c1ezfA7tmf 1KlJpzlHg5fokiIzczFeT+EOGLOdZYaW0fggaKQips1nmYqLe0EYyLE3yJ/sCxWixTy6 fj74harytS57t5HBQh927VzLNVtp6S1Fs1+AzOIJSOFvUyjMlRt3JBpIPXJpt2HYbcsJ 7exTRADYoi3LDSf4TynifqkLLuC6lLDNGE9MPTnKv6uWHClkBiagVaXNqkn5/ipBh/Hx 45ePq/Qybs1uJvaoyDiE1ok5Ztaukh3qB7BRmWuintZgp530eOKGn8GI9aUuqFAIKuBw dC3g== 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=Qg81S8m1J82gexUC4qnavmNvYCCZ6/crtLtvN/hLcQg=; b=UK5ep8JiF9m/7QPrxO54mGHC3lrwb9jhEem79DlnOQrIKpzxOXfhh84YNtq9d+DhfV 1Lqx0fw+fYil4mry7tUHEVP8D68e+HoOjyfYW8Bzs5U2RBZA6vf8kydWERAzv5PhprMw SR5zkIREzuEeQniuzP4+7Gt6JHa0fxPcDO7D/Cev/DoevHi2jHU7Tbf+8oYGPmCU/y4Q TZorPWLo3AEonPrPl2i6SEFpY5mLj9pFw8t8yRuYjgctITAYRf67Uj/y3bVM9n1LDMdM AKclXU4+pto3eWkLbkM7+KTJ6TymZC8PCv1PfdnsP0UM63aSjrMr/HqVkqrcT1A8vBdp 4ziQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EE53yBX5; 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 e189-v6si3477789pfe.80.2018.07.04.04.45.24; Wed, 04 Jul 2018 04:45:24 -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=EE53yBX5; 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 S934427AbeGDLpW (ORCPT + 31 others); Wed, 4 Jul 2018 07:45:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:38688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934330AbeGDLpU (ORCPT ); Wed, 4 Jul 2018 07:45:20 -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 5D53220841; Wed, 4 Jul 2018 11:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530704719; bh=vqVofvapwrG8ciliKflyyjljd3etyLgYjITOT4LK8ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EE53yBX5sI3x3DwMj6YhGreT+qBFDzqnCp7gHVewO4/HUGAbqfcaKgP8RPoSi1ZCb YFaRV/GL7tRyPW9+OCbZF68LrXst8U6auAW0QjXdXUPJ1rrKAUmhlQ72FDzSPNSKl0 Yq0HpUPTqCD8cfHLh5r8A4bA2GYn+tCe0NoFpHU4= 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 4/6] dt-bindings: crypto: Add new compatible qcom, prng-ee Date: Wed, 4 Jul 2018 17:14:25 +0530 Message-Id: <20180704114427.29953-5-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 Later qcom chips support v2 of the prng, which exposes an EE (Execution Environment) for OS to use so add new compatible qcom,prng-ee for this. Signed-off-by: Vinod Koul --- Documentation/devicetree/bindings/crypto/qcom,prng.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.14.4 diff --git a/Documentation/devicetree/bindings/crypto/qcom,prng.txt b/Documentation/devicetree/bindings/crypto/qcom,prng.txt index 8e5853c2879b..7ee0e9eac973 100644 --- a/Documentation/devicetree/bindings/crypto/qcom,prng.txt +++ b/Documentation/devicetree/bindings/crypto/qcom,prng.txt @@ -2,7 +2,9 @@ Qualcomm MSM pseudo random number generator. Required properties: -- compatible : should be "qcom,prng" +- compatible : should be "qcom,prng" for 8916 etc + : should be "qcom,prng-ee" for 8996 and later using EE + (Execution Environment) slice of prng - reg : specifies base physical address and size of the registers map - clocks : phandle to clock-controller plus clock-specifier pair - clock-names : "core" clocks all registers, FIFO and circuits in PRNG IP block From patchwork Wed Jul 4 11:44:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141540 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp705889ljj; Wed, 4 Jul 2018 04:45:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2uTXE1MCxA7qKWiZcRIpkCBAQiEyyY9jQzzUk3i6Ti9jXONXHZ8jzpb25RUI2NniyPUPd X-Received: by 2002:a62:e00a:: with SMTP id f10-v6mr1862018pfh.208.1530704732804; Wed, 04 Jul 2018 04:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704732; cv=none; d=google.com; s=arc-20160816; b=MRceRum7/lrxE4Gs5GF6ZH8NSwrMoqemEt+lPs2Tajwt9OQACdYexCFzZ4gJC2KWFM yu6flLybxoEXhTMFYoHXGM3Ea4VT7vFh/XM/T41z+PV24KCZMAGSWj+KZttfXM3dcHKv CZtW84GjMCWgEF7L5KS1kTorA0g5qHuKH3ni8e4yHH42Tt62fPLDF9RQAwwPrfIzBTwM 7XDPF3Kr4fRb7wl/agiiULoQZl6LGm1I6pC3hN30lnrrA45bswC7SsU9FhqYqLDWEJYt ri1+OFFvFUUeXy/QNqFZ5RYP1nKJo4sBVz3wayBVNpysIKWspwt8YN+rRK7UYsP3FqBo xpVw== 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 k5-v6si3259606plt.178.2018.07.04.04.45.32; Wed, 04 Jul 2018 04:45:32 -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 S934546AbeGDLpa (ORCPT + 31 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(-) -- 2.14.4 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);