From patchwork Mon Oct 9 14:11:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 9993547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 87565602D7 for ; Mon, 9 Oct 2017 14:12:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 787402852E for ; Mon, 9 Oct 2017 14:12:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D782287F8; Mon, 9 Oct 2017 14:12:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A86E2852E for ; Mon, 9 Oct 2017 14:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rnmNzyoklAjJxgqIVb60vX8ZvVR7DkH9MhjyCLJ1DXs=; b=TAMv3GoBg7RSg5SiNWaqzzgIj0 iZ6pm+jViVYBiNYZJYkYzneZpfZDkD+kA6X4nz7IfUI71QL+K0KQJWiIosYZI+R9pQrI0bOP8hEVV 315QciSwGnH61ZOCEdSkWDLqwtW5UuZPS2fMwXGoK0kuWSaiS2hUB0FBKLdVhJpjFHvWOXUI44xz6 ErTF8jIA/0f5OZcq9skr9+GG5CreS2P4BFI4esxOzmu0Qu06S3WRo2WF4mkDmBwAA/fmJD9NGgBGq x+JVNuJ3xP/TYF9Yomil+7dpfG/4br1qF+NOvnmWB00+wNQLHB8gFA/Qq2PgCmUDGe56fGb/RkeKf 84Kv1SdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e1YnO-0007Ot-4B; Mon, 09 Oct 2017 14:12:38 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e1Yn5-00077W-Bn for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2017 14:12:21 +0000 Received: by mail-wm0-x22f.google.com with SMTP id u138so23949368wmu.4 for ; Mon, 09 Oct 2017 07:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B7XOl7JIeprtGN1cVMlWgqkOvD8Ed6jVBaOURanNhHw=; b=u0C2o6vu7g4ejprTarp9jkorl0yIWh2lthTCuPCM7wHa3EhfxYwdgVH8rb8Mo1pLbs aUYqORARESGdej/sulIMMUKgn5wpMXILGI1rafzsqCmykGeZ/k72wweZZnPSXHgae7YT 7ffwmnTqidrVujN79MMXH7Pdnp8c7zf/b3Jm3ha61ulNQcUcGbPOla7avtTkrVN06pV1 LfWW4EusuQzTBcaAR7lf12pkBsGBMq/Vm1fzUl+ic5biCLIJRNdoyPOkQanOWbeaOFhk ZSWE0r+pC40EQ3s6tSya7j4VlxtOxyGULR06s4LuB3bKdYs03NKNDtrm5H0fwJTBMtBq bUCw== 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=B7XOl7JIeprtGN1cVMlWgqkOvD8Ed6jVBaOURanNhHw=; b=r+BlpMMSIyw/+nlKh+a4M6+1rjuGSr4LTqZ0SHS2mP+lIeo1erQZY33+DXvyia7+92 joyxvNMlUNG+KBNCM/XPfT8vLDYVU2sQQ1rxgsuQm1ZrO0L8qd8lYptI7vWajXm3+LU6 AF9dHZ4uIM/3tJgovv8ZQns2sgLNwGlKVtNbq/0COkBuulnL2w3o69goLBOwSrOkK/Qg wl+RajxbEW/PgraioDB0/A1tpXnPj0m62GCo82AsxIAUS2fBJaodABh5C8kY7Kugjl3u kpQVVIYktXnjzGVVnFT9FHfhbcnve7QXneDgbA4U3eW/EOmVge552NpnsPgAdohufpCL O1BA== X-Gm-Message-State: AMCzsaWC8VM4d/VZMgrcS7/VAF8fPNoDFrAOOEWCuhL+um1h1LUV2kbJ rGs9/lXkVTmzPB3HvFwDUStvkg== X-Google-Smtp-Source: AOwi7QBfuvCmSKKnp3spnAKa5gOczNZ3WlIUD72qbcZpNE7RZLTTNdjbVyBi7dv1uU+DXlogXbA/Ug== X-Received: by 10.80.163.140 with SMTP id s12mr4002489edb.22.1507558317631; Mon, 09 Oct 2017 07:11:57 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id g49sm451117edc.31.2017.10.09.07.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 07:11:57 -0700 (PDT) From: Bryan O'Donoghue To: p.zabel@pengutronix.de, richard.leitner@skidata.com, srinivas.kandagatla@linaro.org, axel.lin@ingics.com, ping.bai@nxp.com, d.schultz@phytec.de, peng.fan@nxp.com, van.freenix@gmail.com Subject: [PATCH v3 2/7] nvmem: imx-ocotp: Pass parameters via a struct Date: Mon, 9 Oct 2017 15:11:47 +0100 Message-Id: <1507558312-20580-3-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507558312-20580-1-git-send-email-pure.logic@nexus-software.ie> References: <1507558312-20580-1-git-send-email-pure.logic@nexus-software.ie> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171009_071219_560398_69858014 X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bryan O'Donoghue , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It will be useful in later patches to know the register access mode and bit-shift to apply to a given input offset. Fixes: 0642bac7da42 ("nvmem: imx-ocotp: add write support") Signed-off-by: Bryan O'Donoghue Reviewed-by: Philipp Zabel --- drivers/nvmem/imx-ocotp.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 17d160f..7798571 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -53,11 +53,15 @@ static DEFINE_MUTEX(ocotp_mutex); +struct ocotp_params { + unsigned int nregs; +}; + struct ocotp_priv { struct device *dev; struct clk *clk; void __iomem *base; - unsigned int nregs; + const struct ocotp_params *params; struct nvmem_config *config; }; @@ -121,8 +125,8 @@ static int imx_ocotp_read(void *context, unsigned int offset, index = offset >> 2; count = bytes >> 2; - if (count > (priv->nregs - index)) - count = priv->nregs - index; + if (count > (priv->params->nregs - index)) + count = priv->params->nregs - index; mutex_lock(&ocotp_mutex); @@ -308,12 +312,20 @@ static struct nvmem_config imx_ocotp_nvmem_config = { .reg_write = imx_ocotp_write, }; +static const struct ocotp_params params[] = { + { .nregs = 128 }, + { .nregs = 64 }, + { .nregs = 128 }, + { .nregs = 128 }, + { .nregs = 64 }, +}; + static const struct of_device_id imx_ocotp_dt_ids[] = { - { .compatible = "fsl,imx6q-ocotp", (void *)128 }, - { .compatible = "fsl,imx6sl-ocotp", (void *)64 }, - { .compatible = "fsl,imx6sx-ocotp", (void *)128 }, - { .compatible = "fsl,imx6ul-ocotp", (void *)128 }, - { .compatible = "fsl,imx7d-ocotp", (void *)64 }, + { .compatible = "fsl,imx6q-ocotp", .data = ¶ms[0] }, + { .compatible = "fsl,imx6sl-ocotp", .data = ¶ms[1] }, + { .compatible = "fsl,imx6sx-ocotp", .data = ¶ms[2] }, + { .compatible = "fsl,imx6ul-ocotp", .data = ¶ms[3] }, + { .compatible = "fsl,imx7d-ocotp", .data = ¶ms[4] }, { }, }; MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); @@ -342,8 +354,8 @@ static int imx_ocotp_probe(struct platform_device *pdev) return PTR_ERR(priv->clk); of_id = of_match_device(imx_ocotp_dt_ids, dev); - priv->nregs = (unsigned long)of_id->data; - imx_ocotp_nvmem_config.size = 4 * priv->nregs; + priv->params = of_device_get_match_data(&pdev->dev); + imx_ocotp_nvmem_config.size = 4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv; priv->config = &imx_ocotp_nvmem_config;