From patchwork Tue Oct 24 09:54:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 116921 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp405585edm; Tue, 24 Oct 2017 02:56:59 -0700 (PDT) X-Received: by 10.98.212.70 with SMTP id u6mr15836478pfl.321.1508839019533; Tue, 24 Oct 2017 02:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508839019; cv=none; d=google.com; s=arc-20160816; b=e0lZy9n5F3qVPA17tQHUXLkiOJiNKFXDty0c3PdxQ90DczSAFGxCPMZIyFBATqhgLv AkYuP8VSGwWmvWPLYU5eDROxJ85+pW9r5l+o00U0XxeSTlr9YJ887ic3czgSawx4C/R7 Uql1xR/Aro/QMGBDMkZLWgvBoNLExEsNbfxSZcrge6GLX8aNDy+vtlJ4L3eXc0t4z0xo ImmBQ2zfz4y7mYNFU6I+m79WeJxyu9MvDkwH8DIh20hsXyLzg2isWpLfT2zROzoToGAi bt38/RbyQkp6xWxhw6AVIOtVLgrEQPRLFdU350hAzM/RXnXz8W4ULxmIevpGEbSSylFC nBNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=TRr0R1g+nYlJp3DBCbBmgdEC43OzhBh6Ri+pVSBX+FI=; b=0MHG2aj1ObzImAH2G9o0qyCvHMRyUceAq/kA1eq7I0O59JE5wfLQwwH+63G0oZLaUH 40vVuDUvQCnzRzavKcEwvs6nWICwAV3AfEnKMsegEL6Eru3Ac5cMBUmWIdZCmIVva77G eGW629VTHLFMisP8avkfFxdSxq5w0nwmrQK7gUt+x873PZFdBAK0YFSbA4bDvfYnBiRP RLEgAVIwXS+3eFG+4fvnBBd6bhqITtgkL6+7EyGEKfPwIiGpdpbeDafTlur6CnYomU+1 1WgJLZ58JxHcgn9IJIrcAqo4yNNC+kBk60dLTUOlVGKOQIeJWLcGDE7raNi2AP3X5KUH 81Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ipurFw2n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43si5195171plb.774.2017.10.24.02.56.59; Tue, 24 Oct 2017 02:56:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@linaro.org header.s=google header.b=ipurFw2n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932409AbdJXJ45 (ORCPT + 27 others); Tue, 24 Oct 2017 05:56:57 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:48803 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752036AbdJXJ4t (ORCPT ); Tue, 24 Oct 2017 05:56:49 -0400 Received: by mail-wm0-f66.google.com with SMTP id p75so14534735wmg.3 for ; Tue, 24 Oct 2017 02:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TRr0R1g+nYlJp3DBCbBmgdEC43OzhBh6Ri+pVSBX+FI=; b=ipurFw2nfjq/ViR3fY0u7oZmGoq+SQySWp0ckWcA9nxunNkWSk2sNSmuZcHgkf+5ns Hk19WI5gbV9B6z4IpwyovnIdYgK0cYqQQniJiaZTUb+HXgGvPq5IL54i4Zs3hHrp4Q4u RtGsqKoZfK4YE4Sv/BRphC57qaEDMpC77+Rb8= 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=TRr0R1g+nYlJp3DBCbBmgdEC43OzhBh6Ri+pVSBX+FI=; b=JeL+BmhlzCdrbiMBc6FMsTSufYcFAbFnuf7D6fgyIhKtzqHarzKbXZcZWG8qmUVmfU SIE6NnRzhIIFfxPt9HMOdsqAo7KK0OrP54PNONIs/h+ctZV7c9bAIm1Jr+bh3XZZ6E+u uN8CWWrAobe7UylwXbKEhG9vU63ozLazX1LoKpNKQCXc45BH8ov5QQDl6RRpqmTw1vr9 MXMe8CU13PYmF759CkIq+Z6Oibks9XZAAE5V4K6/9b+oh6nfvTySB+gWI+UAyeF9uI1x 5aJWCjmrQHg5Bzq+1EHBfKF8cV1JRJqFjuoxxeWKJ0tO8KHbgRAuqJ98iBqDh6rS7Njp KIqA== X-Gm-Message-State: AMCzsaW6ZbwsQxZYnzSO5aqB6/jgYo7Ya7fv7pPBONpVuHmtSCXVNoFO 7TbbTEm2UoVDzBR6uRHuKl8xqU0q+Rs= X-Google-Smtp-Source: ABhQp+THGbeEONCIiK4sv0+qJyBYkJRBF5+pxBh3te05x6C/xqUQrhwO1jtBdGpA0t5S3iY66knjKg== X-Received: by 10.28.156.67 with SMTP id f64mr7191702wme.42.1508839008512; Tue, 24 Oct 2017 02:56:48 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id 29sm9666451wrz.77.2017.10.24.02.56.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 02:56:48 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Bryan O'Donoghue , Srinivas Kandagatla Subject: [PATCH 04/10] nvmem: imx-ocotp: Pass parameters via a struct Date: Tue, 24 Oct 2017 10:54:28 +0100 Message-Id: <1508838874-32252-5-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508838874-32252-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1508838874-32252-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bryan O'Donoghue 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 Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/imx-ocotp.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) -- 1.9.1 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 int imx_ocotp_write(void *context, unsigned int offset, void *val, .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;