Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6234925ybv; Wed, 12 Feb 2020 08:24:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzNqWWr3MGGQbKv2n8iPt2KsJea/ZQjGOoRP9bAt7bRUeOPTkTI2j0RPDsnGv1smhExP1iq X-Received: by 2002:a9d:6653:: with SMTP id q19mr10066621otm.94.1581524684668; Wed, 12 Feb 2020 08:24:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581524684; cv=none; d=google.com; s=arc-20160816; b=o6qTrkXYGk/3Qsb1pOUwWA3+wapN2wcLJ1UQkQLpHmkEEb71TWD8iGM+gFgHtXzSli NJxhnW3IFBCAUoIqVa6y7bK81czZrPATOEPqvGDPxzUbStZkyeCTnLi95S9hnDIlfMTG /AuAeq/pHSZXxqy6VtSSbJjFAP9CBE3ebzYbinVQH7yOslcxST+WbEd2T34FPpOAy155 W5jN/NUQ63NaJAnle/sxjdarOVgpfV0fkB4mJB/MUtvEl5UmP0vsZr1nzDkNtd+BXoqr YH6WhvGD4nc/jxdi3qCizRXvGUxdwNOpwzFrsLz+Ekt0p5tgwftX/KpTyzTBBWXnoEcQ P8iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yuS3UA1IgBJUj+Wpff0h1v7oXXukTf3YUcZ7+4lm5Pc=; b=uI1MeU16zCVUmWmNnBv2bZQV1WmzaACv3cKOqHeR9JJMW86Dgddhv4Zqjai/cWZ79m 8vtA36zL6Wz6McMWFeXDlaw3wr9WMEtvkM91eOQ7ugONe1UUCsnL5Vz/rLxgM9ZREYxS LqOSQO4TNjeFKxRdvkzu3mgB8CMY7NF7Keexeuj4/1izw+rxeqWCR/ZrgEIAbKUUWuKG KQ+Fl346e9PQDQ3oTN1zwuGffEzBxM0F/7nq7ZXkf1wuHMhTt8GfxtkjsNTRkTBqWcYd lVqtbjERRn0c26pvJ8ikqYEz7LlEiIpoDOvdKAlVf9wa0LYsF6UFIAjzwGdF0SCeUmCD 3k5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZBz6nbVg; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j25si3476121oij.242.2020.02.12.08.24.32; Wed, 12 Feb 2020 08:24:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@gmail.com header.s=20161025 header.b=ZBz6nbVg; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728757AbgBLQXV (ORCPT + 99 others); Wed, 12 Feb 2020 11:23:21 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33940 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbgBLQXV (ORCPT ); Wed, 12 Feb 2020 11:23:21 -0500 Received: by mail-pl1-f194.google.com with SMTP id j7so1152008plt.1; Wed, 12 Feb 2020 08:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yuS3UA1IgBJUj+Wpff0h1v7oXXukTf3YUcZ7+4lm5Pc=; b=ZBz6nbVg0BvKO4Kpp4xvT89r/oVFpqbGIv6DR+w3SZFiDgfpiCsa6srQmCI7ILhPsg ftsBjyXrlU+BY6jaNV2yB9qcscoalG03jvehW6GwpDD7HLsYyyPpMnkh9zMVvo8bT9OV WY7wem6cbcoBfg1yjGFvHS+IbXfECEzMnhhsTxFINGSMv+utJY7AyzknnwDbd/gzNGjh 7yWTVzwMm78qnN7L7BeNToUPFxxslox45BOqW3slHHfw1nIyKT/Wl+WvOE3oXoQnKHb+ Do/jOgYPgDl55OtppFGbDAmiQ+TnOUerZWMq/6crZdwYG6W+rF1Q3FCiXMfFtNqdNEtp ODgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yuS3UA1IgBJUj+Wpff0h1v7oXXukTf3YUcZ7+4lm5Pc=; b=Git5yNlMuwbZhJmZKkCQyphCFxle8rkhieJlvvNQfj0ACx79U1j47S1fSfAhe8VfpJ jwANpOrig2bCBa6QgdXVmmf5jMN/nE8MHo7LKwXMGf+WIbinT6v2GE9+s0hI6vwAjJaY s86DhuC4+aeUoSyMfD7PmLgfy68mE8q/8+dya+VKZABgkmYzNiYvwhnhVDgGmHxLMurP dTZnHEOJF/Pd3gnjmK43Ab+NwfglRxIetiKlGjUtactG7BekRWbq7W9dJtRV+ThJZnaH s4HazdbSDca+eVXXKYsixDZ91tXuGE7KMsbytG6GonIfxSldYwwNy27gjE4UxucV8ZJ2 6Npw== X-Gm-Message-State: APjAAAVd+ICO1NrqGNhU4tws5aWcmYGWczAOMZ4k8f2AB+QxIdvjTb8w sTHp92Ga6kbfdFUKnxyy2zI9xPRyktstOHNSQvc= X-Received: by 2002:a17:902:9342:: with SMTP id g2mr8825074plp.339.1581524600442; Wed, 12 Feb 2020 08:23:20 -0800 (PST) MIME-Version: 1.0 References: <20200128110102.11522-1-martin@kaiser.cx> <20200128110102.11522-6-martin@kaiser.cx> In-Reply-To: <20200128110102.11522-6-martin@kaiser.cx> From: PrasannaKumar Muralidharan Date: Wed, 12 Feb 2020 21:53:09 +0530 Message-ID: Subject: Re: [PATCH 5/6] hwrng: imx-rngc - check the rng type To: Martin Kaiser Cc: Herbert Xu , NXP Linux Team , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , linux-arm-kernel@lists.infradead.org, open list Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, 28 Jan 2020 at 16:31, Martin Kaiser wrote: > > Read the rng type and hardware revision during probe. Fail the probe > operation if the type is not one of rngc or rngb. > (There's also an rnga type, which needs a different driver.) > > Display the type and revision in a debug print if probe was successful. > > Signed-off-by: Martin Kaiser > --- > drivers/char/hw_random/imx-rngc.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c > index 8222055b9e9b..27d85fced30b 100644 > --- a/drivers/char/hw_random/imx-rngc.c > +++ b/drivers/char/hw_random/imx-rngc.c > @@ -18,12 +18,22 @@ > #include > #include > > +#define RNGC_VER_ID 0x0000 > #define RNGC_COMMAND 0x0004 > #define RNGC_CONTROL 0x0008 > #define RNGC_STATUS 0x000C > #define RNGC_ERROR 0x0010 > #define RNGC_FIFO 0x0014 > > +/* the fields in the ver id register */ > +#define RNGC_TYPE_SHIFT 28 > +#define RNGC_VER_MAJ_SHIFT 8 > + > +/* the rng_type field */ > +#define RNGC_TYPE_RNGB 0x1 > +#define RNGC_TYPE_RNGC 0x2 > + > + > #define RNGC_CMD_CLR_ERR 0x00000020 > #define RNGC_CMD_CLR_INT 0x00000010 > #define RNGC_CMD_SEED 0x00000002 > @@ -212,6 +222,8 @@ static int imx_rngc_probe(struct platform_device *pdev) > struct imx_rngc *rngc; > int ret; > int irq; > + u32 ver_id; > + u8 rng_type; > > rngc = devm_kzalloc(&pdev->dev, sizeof(*rngc), GFP_KERNEL); > if (!rngc) > @@ -237,6 +249,17 @@ static int imx_rngc_probe(struct platform_device *pdev) > if (ret) > return ret; > > + ver_id = readl(rngc->base + RNGC_VER_ID); > + rng_type = ver_id >> RNGC_TYPE_SHIFT; > + /* > + * This driver supports only RNGC and RNGB. (There's a different > + * driver for RNGA.) > + */ > + if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB) { > + ret = -ENODEV; > + goto err; > + } > + > ret = devm_request_irq(&pdev->dev, > irq, imx_rngc_irq, 0, pdev->name, (void *)rngc); > if (ret) { > @@ -269,7 +292,10 @@ static int imx_rngc_probe(struct platform_device *pdev) > goto err; > } > > - dev_info(&pdev->dev, "Freescale RNGC registered.\n"); > + dev_info(&pdev->dev, > + "Freescale RNG%c registered (HW revision %d.%02d)\n", > + rng_type == RNGC_TYPE_RNGB ? 'B' : 'C', > + (ver_id >> RNGC_VER_MAJ_SHIFT) & 0xff, ver_id & 0xff); > return 0; > > err: > -- > 2.20.1 > Reviewed-by: PrasannaKumar Muralidharan