Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2130889rwb; Thu, 29 Sep 2022 06:39:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4t0lZRs85nCDeiAsz3k1w+MNVGu4Td++t3RY1svtMgEOnAkK6L8WBLm8g0b4AT6VFku99u X-Received: by 2002:a17:902:f60b:b0:178:6a49:d4e3 with SMTP id n11-20020a170902f60b00b001786a49d4e3mr3631952plg.75.1664458777479; Thu, 29 Sep 2022 06:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664458777; cv=none; d=google.com; s=arc-20160816; b=GyMiOlfME90vx/srp1abWNGxpC/itu1bLHQzVhDZcBU8777DZoAilIaDPSnU5FT/1n mHfWb25m6+B8HR+UrAU7YM3PokV6Kxkn43NtyNMhRhuTv+vNS1swJx3+1spN0XJkHoJq xB20bQZhfE/gxX1yX3HpZkOO4ns2AVpQX86CDntB0Ot0tPqeMbtvGcVHdZWpMCgbsLPd 6jrAMTQkjvs2GyPb94DlseV1FrGr6Ax6V1KOELKzfIeIcr6RZ6U4OLdTZHDR3SzR0efv vk9reIGGDcjDN/qpQ4rOl56c8oi9i+eyw67qhxtJkLt+M7H/LPDe9vwE5XDwtO4Uw2U1 cyYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/eUklbHm2uuitflnFpeD3bLJTi9oFcjATWhPKPO2wUQ=; b=wJgEOKLwF16b5MjvZ8xdC5RZeNuPsph1OIX6hjSz6IrSnuOTr2Eq5cCralGhVA4bqE mAiOCzbSmye8kWO6utw58RqThxRimL9m8s/8ycCQXgG+pY6xk+a9oBhLoB47Q8zfHosa wWRw5fJS+zLanIyjS2jTUrdeg15M0g3hVda25YMgkv0LSLTxTOH8qMCiCzHQ7Y1sz7vA E2Xg+jhOaduuIoWZe42kdiKrQtO3KyakIEB70Ppi9CchZ0XtmWALx3GExJ1rds9xwwW7 BcLwoSZhh1mwO7I9U9P/ZpO1CPRMk9l6nGX74N5/AgzZmCfjwM7sppNRGz5h5WCBQmTx 9hyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a63d949000000b004386d70cf15si8283526pgj.206.2022.09.29.06.39.10; Thu, 29 Sep 2022 06:39:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234284AbiI2Nbd (ORCPT + 99 others); Thu, 29 Sep 2022 09:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234920AbiI2Nbc (ORCPT ); Thu, 29 Sep 2022 09:31:32 -0400 Received: from maillog.nuvoton.com (maillog.nuvoton.com [202.39.227.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0857213746B; Thu, 29 Sep 2022 06:31:27 -0700 (PDT) Received: from NTHCCAS01.nuvoton.com (NTHCCAS01.nuvoton.com [10.1.8.28]) by maillog.nuvoton.com (Postfix) with ESMTP id 458B51C8121D; Thu, 29 Sep 2022 21:31:27 +0800 (CST) Received: from NTHCCAS03.nuvoton.com (10.1.20.28) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Thu, 29 Sep 2022 21:31:27 +0800 Received: from NTHCCAS04.nuvoton.com (10.1.8.29) by NTHCCAS03.nuvoton.com (10.1.20.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1847.3; Thu, 29 Sep 2022 21:31:26 +0800 Received: from taln60.nuvoton.co.il (10.191.1.180) by NTHCCAS04.nuvoton.com (10.1.12.25) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Thu, 29 Sep 2022 21:31:26 +0800 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id 0DAF163A20; Thu, 29 Sep 2022 16:31:25 +0300 (IDT) From: Tomer Maimon To: , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v2 2/2] hwrng: npcm: Add NPCM8XX support Date: Thu, 29 Sep 2022 16:31:11 +0300 Message-ID: <20220929133111.73897-3-tmaimon77@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220929133111.73897-1-tmaimon77@gmail.com> References: <20220929133111.73897-1-tmaimon77@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Adding RNG NPCM8XX support to NPCM RNG driver. RNG NPCM8XX uses a different clock prescaler. As part of adding NPCM8XX support: - Add NPCM8XX specific compatible string. - Add data to handle architecture specific clock prescaler. Signed-off-by: Tomer Maimon --- drivers/char/hw_random/npcm-rng.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c index 1ec5f267a656..5bf7f370f985 100644 --- a/drivers/char/hw_random/npcm-rng.c +++ b/drivers/char/hw_random/npcm-rng.c @@ -13,11 +13,13 @@ #include #include #include +#include #define NPCM_RNGCS_REG 0x00 /* Control and status register */ #define NPCM_RNGD_REG 0x04 /* Data register */ #define NPCM_RNGMODE_REG 0x08 /* Mode register */ +#define NPCM_RNG_CLK_SET_62_5MHZ BIT(2) /* 60-80 MHz */ #define NPCM_RNG_CLK_SET_25MHZ GENMASK(4, 3) /* 20-25 MHz */ #define NPCM_RNG_DATA_VALID BIT(1) #define NPCM_RNG_ENABLE BIT(0) @@ -31,14 +33,14 @@ struct npcm_rng { void __iomem *base; struct hwrng rng; + u32 clkp; }; static int npcm_rng_init(struct hwrng *rng) { struct npcm_rng *priv = to_npcm_rng(rng); - writel(NPCM_RNG_CLK_SET_25MHZ | NPCM_RNG_ENABLE, - priv->base + NPCM_RNGCS_REG); + writel(priv->clkp | NPCM_RNG_ENABLE, priv->base + NPCM_RNGCS_REG); return 0; } @@ -47,7 +49,7 @@ static void npcm_rng_cleanup(struct hwrng *rng) { struct npcm_rng *priv = to_npcm_rng(rng); - writel(NPCM_RNG_CLK_SET_25MHZ, priv->base + NPCM_RNGCS_REG); + writel(priv->clkp, priv->base + NPCM_RNGCS_REG); } static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) @@ -110,6 +112,7 @@ static int npcm_rng_probe(struct platform_device *pdev) priv->rng.read = npcm_rng_read; priv->rng.priv = (unsigned long)&pdev->dev; priv->rng.quality = 1000; + priv->clkp = (u32)(uintptr_t)of_device_get_match_data(&pdev->dev); writel(NPCM_RNG_M1ROSEL, priv->base + NPCM_RNGMODE_REG); @@ -162,7 +165,10 @@ static const struct dev_pm_ops npcm_rng_pm_ops = { }; static const struct of_device_id rng_dt_id[] __maybe_unused = { - { .compatible = "nuvoton,npcm750-rng", }, + { .compatible = "nuvoton,npcm750-rng", + .data = (void *)NPCM_RNG_CLK_SET_25MHZ }, + { .compatible = "nuvoton,npcm845-rng", + .data = (void *)NPCM_RNG_CLK_SET_62_5MHZ }, {}, }; MODULE_DEVICE_TABLE(of, rng_dt_id); -- 2.33.0