From patchwork Sun Oct 8 22:41:17 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: 9992059 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 E04F460364 for ; Sun, 8 Oct 2017 22:43:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFFC62863B for ; Sun, 8 Oct 2017 22:43:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C119C28639; Sun, 8 Oct 2017 22:43:18 +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 26A2328639 for ; Sun, 8 Oct 2017 22:43:18 +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=Jl8mp9sO9wEPvDx8/G7p4WYkiq ZdvMmN3O34Dfs/2+cyQ3HwmM7KEGHxyOA9ZD/OSayFfDN9g83VIQih4/MTJ2sqe3pa92bCTAzBsV0 wW2LsQDq1woAEA8yQm4L8H5tFdnff7KJm8QT4jxWAZKnfIBAYxpc2wHAbxXH6fN2mhBxQxSvUhiTb HBxFsZaSd9kbNkAbyq4aLVrhuyI6ubVzO3B1EQ/1y1vEIgUyRvYkzy9jLInLBpjKHXLG2IWVPuPID H1PJ3uVSC32J4DIrM+1aeO4AuWbyemN1txYiOqzHZl7B/QVXfZDMXPFu6rmHtlFwAO1/CC7JTJe8K J6+TXDAQ==; 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 1e1KI1-00057G-8V; Sun, 08 Oct 2017 22:43:17 +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 1e1KGa-0003kR-Pe for linux-arm-kernel@lists.infradead.org; Sun, 08 Oct 2017 22:41:52 +0000 Received: by mail-wm0-x22f.google.com with SMTP id m72so9216205wmc.0 for ; Sun, 08 Oct 2017 15:41:28 -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=oumR0zuuNVUjJl+d/JR3y2Vmr4DzlTL+Yvfiibh4y48UNCG6ZxO+8OKc6CWNA2/Pue bnqo8vF0QfqJsv+7I3FKO0jJesov/+APGtgZN/+dwtL910q5V9ltP97PkRm6Ll6BtQVN f8ruHeO4hqpqy/PvvNuxvrJMG8q9npcJQIsF8HMcPrSAm2ZCXoGsf8rB9uqoc8/U/12/ 4rMpQQvjU4giBCbH3IAsbUgCVeaMNTw7evqLxNNfGEmxaMjt0si3tMU5U5osq1AjNDcv WGTfnpIiQgiHUeOdndgTfh8UZSiUX/OomoYZ35EwkQikIJRMFuDSsI/WagDsUf9EaioF UbRA== 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=HXoxW0WUVTsYjty5gpkxtLkxuo49BnXz0Q6dVzrfFsyQr02/smFxOelEjVPhr3RZa6 l3puOdKGA9nGy3bEQbVJEbvzKnF91qu1/r6zKfnKVJs4vJ7Bs+q7ahyLIAok4y5Cfmly vcAJAY8BzztShAskf31WB655S8dTPiXkMI7TdDQY/AkaWW6W3PmsQ5v9xecwOXVtRNLa 3cepIhZiVhC7U7/9MgDJCTJ1sKPYxlX45FXNUZJiY2KQhDHVj29JzD7WfrfldMEE1eM4 CUjeCPUki23Ibm8w/KS4/8gc3kmiOg99jixIGDUO3hNhKcj5eYpRR1SatOTKb3aa9FXO PCfw== X-Gm-Message-State: AMCzsaWl0MOfbR8I+pS+QJuM0Ng3E1kMO6h+5IISEiyiNx9H/HlK0oh5 8gKCmZrRa1lgcXh4cyiMLiuhaQ== X-Google-Smtp-Source: AOwi7QATW+M3MADdnyJEPzgTW1YGNauI+jn+4lZmghmZOEv69jfQnNqTwYrV5ZZF7o7n+FrQ4BJm/A== X-Received: by 10.80.177.205 with SMTP id n13mr5116401edd.148.1507502486194; Sun, 08 Oct 2017 15:41:26 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id g45sm432909eda.19.2017.10.08.15.41.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Oct 2017 15:41:25 -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 v2 2/7] nvmem: imx-ocotp: Pass parameters via a struct Date: Sun, 8 Oct 2017 23:41:17 +0100 Message-Id: <1507502482-22518-3-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507502482-22518-1-git-send-email-pure.logic@nexus-software.ie> References: <1507502482-22518-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-20171008_154148_983779_555FA9D1 X-CRM114-Status: GOOD ( 12.92 ) 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 --- 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;