From patchwork Wed Oct 4 22:25:16 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: 9985781 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 9501E602B8 for ; Wed, 4 Oct 2017 22:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85AFF28C2B for ; Wed, 4 Oct 2017 22:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A9F028C35; Wed, 4 Oct 2017 22:27:28 +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 E4FF328C2B for ; Wed, 4 Oct 2017 22:27:27 +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=daJrswz8hvLpKw3MN7wvDzGXf4VVGibI0+eUyVDhTIA=; b=gjSKntkfZV2hLms8X5uU4cKAPk +T7bNrVzNiOJ+Xa50GiAYu5fTu3kzriQEGrtFJOBAdfrHW6LiHogYXK2XgPtWPn0PiXT3LzAQCHRX 5X8in+QsKplNWBdB42WjqUDsQkXTOs0rlphr9HvA65bvi6NnLiH8+Sy7c1Pwg3/TKOb8+IPd6eRni ktKX2Y3KB79ujlavo5rN3rEILP8ToP5voOt3rT/EpErY1c0eM/zUx3MhvMisxPjnwNAssa8a35ZAe yKcEAIAPOjRHOH/Mb4hzJgM88g3KHlMJzywQpY59EhIA1TmR9H20qmJOVFlLQPjk9el2W/GNVqtmU 4lJo9urQ==; 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 1dzs8Q-0006gV-9p; Wed, 04 Oct 2017 22:27:22 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzs6t-0005YR-5Y for linux-arm-kernel@lists.infradead.org; Wed, 04 Oct 2017 22:25:51 +0000 Received: by mail-wm0-x233.google.com with SMTP id l68so12059612wmd.5 for ; Wed, 04 Oct 2017 15:25:26 -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=MxcW6cSMOHVR81Lq5Ga/9ffx6TILAcKJgLf69hPqDiM=; b=rhdEjluE8T6b4mL45gKXk6Wq4t0btc9XwFBaohqfS1F+mrI+TMfaYujX7yFC23KAXK c/vDQTCgwuNDdTViKShTs1F8Ifacso9Z3u4nUg3feVfmiqJrJboytFBmxUooenkvrdoC 3AbX44BIS7G3b6TTXVSHcYlLJq1kZt2VKIo2IunJ1SmeJYZ9wCgXH1o8fDz1qSSItZN/ 1s/gGFnd/Gxj5jN7Y7ulr6CIaGUI0FMGAMqnyxAFXlEH/K57HfPQ2KWSuFidrSDOQCu+ oGNC7RABoaQk0UP7CckizSpRr1XPSE+zkVMA3Ez/0hjTmEE4LADTzvI5wXw6usbRz3/p p6Zw== 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=MxcW6cSMOHVR81Lq5Ga/9ffx6TILAcKJgLf69hPqDiM=; b=c9kfbtgZvO3Tw5ydE2wcSfFALwR+w5dL+Du4rnahDf/a+NPAodf3p5CSA3eel9CH6E LtV7QDopMPeyQJXNV5uwpwF8c4nsVNCDIgKXYh3KenTWNVbnjCb4Xm9OJVt4xp9Nau1w hF0bZ7z6KJRvMEJF0JerzJ2wkcpPdrZ3lnXUiH/vJQFCx9X43jmu7D63Bt+/IDdbHgLF 2wAlfDJP2UyXR+nMdHx3V+XW+hWnKgkbf59h0ndOIY1RtikvzCI78nhShaDM8PDB+qkp IKIOEk82OpqlmQt4n213mv3zYbdP+DZIUKaI1tk/CWu9IuTPrULsv3YavQZR8SFBNPnG uQWw== X-Gm-Message-State: AMCzsaWX8I0CUDQtF3LwMjTcAkMzGM4rvYi6vUY04vNpjVyWO4MY62Qs lpLMoF9LAQZHb8ZTuBrUflA8Og== X-Google-Smtp-Source: AOwi7QB+mfxejdizr1BG8IElvfo67fztocC2Y06W2dmVHH7WrZqcgP/v4GUTlTRPzQO0OOUP91aljw== X-Received: by 10.80.214.202 with SMTP id l10mr98794edj.58.1507155924702; Wed, 04 Oct 2017 15:25:24 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id i6sm12459022edk.3.2017.10.04.15.25.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Oct 2017 15:25:24 -0700 (PDT) From: Bryan O'Donoghue To: 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, p.zabel@pengutronix.de Subject: [RESEND][PATCH 2/7] nvmem: imx-ocotp: Pass parameters via a struct Date: Wed, 4 Oct 2017 23:25:16 +0100 Message-Id: <1507155921-824-3-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507155921-824-1-git-send-email-pure.logic@nexus-software.ie> References: <1507155921-824-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-20171004_152547_442259_B5569871 X-CRM114-Status: GOOD ( 12.78 ) 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: pure.logic@nexus-software.ie, 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 --- 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..fed76a4 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -53,11 +53,15 @@ static DEFINE_MUTEX(ocotp_mutex); +struct octp_params { + unsigned int nregs; +}; + struct ocotp_priv { struct device *dev; struct clk *clk; void __iomem *base; - unsigned int nregs; + struct octp_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 octp_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", (void *)¶ms[0] }, + { .compatible = "fsl,imx6sl-ocotp", (void *)¶ms[1] }, + { .compatible = "fsl,imx6sx-ocotp", (void *)¶ms[2] }, + { .compatible = "fsl,imx6ul-ocotp", (void *)¶ms[3] }, + { .compatible = "fsl,imx7d-ocotp", (void *)¶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 = (struct octp_params *)of_id->data; + 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;