From patchwork Mon Oct 23 14:34:45 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: 10022623 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 E3884601E8 for ; Mon, 23 Oct 2017 14:38:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF60B27F97 for ; Mon, 23 Oct 2017 14:38:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A425B288AE; Mon, 23 Oct 2017 14:38:32 +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 2142927F97 for ; Mon, 23 Oct 2017 14:38:32 +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=Lc7m2fxQ3c5rdF57qAsc+87un/kUyKgO/qz0M7hAtFg=; b=dZRXSG5tJPsYuvMch2YBWOGmm9 SGXc+wsAx7W3Zp3Ryl3oOWXNgnmzq3nEMGXhKIqYjt+idRf8aShle+EADcppxglVq75D9muT9yN/j FUbs1hHGCRW9cs0qSLUzA+z+YvH0AAjX8P1mR0LFEXtwkCNi+8ECdguQHhFjSnDelWLNdn1vQVFHE e0+5ro/dGyvBCfoTUrF/cDofEikIoXmlfSxrbY2CQtm7ESSfZXxkju8QV3oxEWu0JHAtWgd8zfqSO u+ZsdaC2gPIA4s1AdQqGhF5YiPo7SUucpkQoqbG7BcARuARyIx9peN1oyqDhOWm1vn03iJJxHnd60 M1rM18JQ==; 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 1e6ds3-0000OF-Eg; Mon, 23 Oct 2017 14:38:27 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e6doy-0005OQ-9o for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2017 14:35:26 +0000 Received: by mail-wm0-x244.google.com with SMTP id 78so7419998wmb.1 for ; Mon, 23 Oct 2017 07:34:55 -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=O05e4ETzXnOsrhUtgDq/Fqrl8miiHnEDlu90+fCiVE4=; b=pgAIthGagoigdocfwsQ8I/y573cGnt+STT39F6FOnqJGUr5YZYJl40Xr86o2VtyVYw 5rHJ0ExSHT1KVHxYjqi5fWUWAHHOu87N/tRc1DVwmaEcsFPaCezaBSrCdhwiUoxCfmRB +RzF+1iT55lGzIj414R6BJh4Epx3Dx1ImqJmTnmOWzLhWnUaZ/JxhhMtjl4dNRbaodIZ Q82r3l2a7KXCsC8+RW36BC3l52L9BOgFJ7eB0hWevsUx7QEUMfYEo3lW9cuda3PxvupD CDumWXp0Jg6c0XlYnzXSr6fzucNHN6o0tYWv23xpzGL6X2gXmTg8H7KPTbvSk9mPp5Ar zruQ== 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=O05e4ETzXnOsrhUtgDq/Fqrl8miiHnEDlu90+fCiVE4=; b=XMy/GJxJJDqdWJ2xu4FUDK3oFDZbk0xJ9xrmBgS1GWmZIw4FrlgW82Bx8mP5gIOYSJ FXjYqtKnz5RCgZ3rebJ98SCM2vaBnTvUWrzdxat0RD3DNhDcKcEwNaXdNR4A/FidOe5S s6WHxa5w3FCbMJwer+1DpIljgR9FRSpqn3WKltlo3/XAo/W3HnVoFSRLG47Od4qp3u2m 5rtqp2w0E/oUNa2ckFk+Sh/QsL1fsNVeOKJLcn6yFl0e1Z+9aOUXgK6wspFCXT7XJ2IP MhOlVfeVqrEuO9A1LOrF0KePDpDzxFSQ5pic6GrqZTIts2HLgMWIJeeK6H9GHgtbWzMZ gBQA== X-Gm-Message-State: AMCzsaWuL+B+CeNL9U52AsDs1+j+QUtMoIJ/vdGDAqIMcCOsLcjrz/6d +8XzzR0XUkIAQRmpZy2XI8rmRA== X-Google-Smtp-Source: ABhQp+R5OpmApJoSxO8R8opBLO2mR2wNbCwckb7S75xvYhk0nSq2LGUGRmpEviwY4z8bGFge61fVKQ== X-Received: by 10.80.194.146 with SMTP id o18mr16421093edf.19.1508769294509; Mon, 23 Oct 2017 07:34:54 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id w51sm7098180edd.60.2017.10.23.07.34.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 07:34:53 -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 v4 2/7] nvmem: imx-ocotp: Pass parameters via a struct Date: Mon, 23 Oct 2017 15:34:45 +0100 Message-Id: <1508769290-2646-3-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508769290-2646-1-git-send-email-pure.logic@nexus-software.ie> References: <1508769290-2646-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-20171023_073516_605298_5915E918 X-CRM114-Status: GOOD ( 12.55 ) 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 Reviewed-by: Philipp Zabel --- drivers/nvmem/imx-ocotp.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 17d160f..b035e47 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,32 @@ static struct nvmem_config imx_ocotp_nvmem_config = { .reg_write = imx_ocotp_write, }; +static const struct ocotp_params imx6q_params = { + .nregs = 128, +}; + +static const struct ocotp_params imx6sl_params = { + .nregs = 64, +}; + +static const struct ocotp_params imx6sx_params = { + .nregs = 128, +}; + +static const struct ocotp_params imx6ul_params = { + .nregs = 128, +}; + +static const struct ocotp_params imx7d_params = { + .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 = &imx6q_params }, + { .compatible = "fsl,imx6sl-ocotp", .data = &imx6sl_params }, + { .compatible = "fsl,imx6sx-ocotp", .data = &imx6sx_params }, + { .compatible = "fsl,imx6ul-ocotp", .data = &imx6ul_params }, + { .compatible = "fsl,imx7d-ocotp", .data = &imx7d_params }, { }, }; MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); @@ -342,8 +366,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;