From patchwork Sun Apr 24 19:28:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 8921231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B5A419F441 for ; Sun, 24 Apr 2016 19:49:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEDF8201BB for ; Sun, 24 Apr 2016 19:49:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB483200CA for ; Sun, 24 Apr 2016 19:49:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auQ04-0001aK-JJ; Sun, 24 Apr 2016 19:47:24 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auQ01-0001Sa-Pk for linux-arm-kernel@bombadil.infradead.org; Sun, 24 Apr 2016 19:47:21 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by casper.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1auPiM-0005yb-NA for linux-arm-kernel@lists.infradead.org; Sun, 24 Apr 2016 19:29:10 +0000 Received: by mail-wm0-x22a.google.com with SMTP id n3so97910464wmn.0 for ; Sun, 24 Apr 2016 12:28:45 -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=lxOQx9XcygzQIdKHzZaCtzRfp1SU7nNhKSwuizF7x4Y=; b=QY8puruNmNK6eOQISw2k2o2RHrCh12OwSAeQk50BzUoabXAToelLGupuJm0xejnvRR oY72+N4a8lTV7jqGoUnUx5f7AChPrA9SV1YKmP16LDynKNsd8m6ACwPxHTrwCLVtqIj0 kUxF3zatmeaPZOmQZqHSgQ0tl+jj9ezOM3QH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lxOQx9XcygzQIdKHzZaCtzRfp1SU7nNhKSwuizF7x4Y=; b=a9IIvYfz04LN/Za2fFMwaBcZ5p8GyZKizsjJEC5GX4fvPWWw6cJubEW98xv5cXfCQT 5UyEOPPZ+4+NKFvtkeafvIvPJy2iD+CxFPtdtPGCGWZeJpJC6JQZ3ut9McmP8jZuWrVf tdVxEBXqfuDweUsVtzAyko1AXBkvpCKvtU/N2Il6ZsS1zaOPki0n8A4n7Hsuxe2upeH3 /1ePGuuyNuqTbtQhWaAd7Q8Kul4ZUzgnTjBeUsOIQl5jW9SRQmJAZ58fWb7nqt25Kf/0 LbU7b+TGQzIzhfOzBoOS3hBouZ0/nrCHc8VhiaUzS0aHW4uRtL8AGDgzpqBYTDjxvpgu LbQA== X-Gm-Message-State: AOPr4FVKdzTjE8+c3dtDsthd5zezGrmnXOtijmdXnHd1aq1EIXHx9QTZ7laGAZ3cRDynH6Rd X-Received: by 10.194.124.243 with SMTP id ml19mr34588841wjb.80.1461526124522; Sun, 24 Apr 2016 12:28:44 -0700 (PDT) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id q127sm15007708wmd.13.2016.04.24.12.28.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 12:28:43 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Subject: [PATCH 09/12] nvmem: imx-ocotp: remove nvmem regmap dependency Date: Sun, 24 Apr 2016 20:28:13 +0100 Message-Id: <1461526096-29584-10-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461526096-29584-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1461526096-29584-1-git-send-email-srinivas.kandagatla@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160424_202906_824521_6F619EAE X-CRM114-Status: GOOD ( 19.09 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, Heiko Stuebner , Wolfram Sang , Joachim Eastwood , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Mark Brown , Srinivas Kandagatla , linux-i2c@vger.kernel.org, Matthias Brugger , linux-mediatek@lists.infradead.org, Maxime Ripard , 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-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch moves to nvmem support in the driver to use callback instead of regmap. Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/imx-ocotp.c | 55 ++++++++++------------------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index d7796eb..75e66ef 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -22,7 +22,6 @@ #include #include #include -#include #include struct ocotp_priv { @@ -31,59 +30,34 @@ struct ocotp_priv { unsigned int nregs; }; -static int imx_ocotp_read(void *context, const void *reg, size_t reg_size, - void *val, size_t val_size) +static int imx_ocotp_read(void *context, unsigned int offset, + void *val, size_t bytes) { struct ocotp_priv *priv = context; - unsigned int offset = *(u32 *)reg; unsigned int count; + u32 *buf = val; int i; u32 index; index = offset >> 2; - count = val_size >> 2; + count = bytes >> 2; if (count > (priv->nregs - index)) count = priv->nregs - index; - for (i = index; i < (index + count); i++) { - *(u32 *)val = readl(priv->base + 0x400 + i * 0x10); - val += 4; - } + for (i = index; i < (index + count); i++) + *buf++ = readl(priv->base + 0x400 + i * 0x10); return 0; } -static int imx_ocotp_write(void *context, const void *data, size_t count) -{ - /* Not implemented */ - return 0; -} - -static struct regmap_bus imx_ocotp_bus = { - .read = imx_ocotp_read, - .write = imx_ocotp_write, - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, -}; - -static bool imx_ocotp_writeable_reg(struct device *dev, unsigned int reg) -{ - return false; -} - -static struct regmap_config imx_ocotp_regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, - .writeable_reg = imx_ocotp_writeable_reg, - .name = "imx-ocotp", -}; - static struct nvmem_config imx_ocotp_nvmem_config = { .name = "imx-ocotp", .read_only = true, + .word_size = 4, + .stride = 4, .owner = THIS_MODULE, + .reg_read = imx_ocotp_read, }; static const struct of_device_id imx_ocotp_dt_ids[] = { @@ -99,7 +73,6 @@ static int imx_ocotp_probe(struct platform_device *pdev) const struct of_device_id *of_id; struct device *dev = &pdev->dev; struct resource *res; - struct regmap *regmap; struct ocotp_priv *priv; struct nvmem_device *nvmem; @@ -114,15 +87,9 @@ static int imx_ocotp_probe(struct platform_device *pdev) of_id = of_match_device(imx_ocotp_dt_ids, dev); priv->nregs = (unsigned int)of_id->data; - imx_ocotp_regmap_config.max_register = 4 * priv->nregs - 4; - - regmap = devm_regmap_init(dev, &imx_ocotp_bus, priv, - &imx_ocotp_regmap_config); - if (IS_ERR(regmap)) { - dev_err(dev, "regmap init failed\n"); - return PTR_ERR(regmap); - } + imx_ocotp_nvmem_config.size = 4 * priv->nregs; imx_ocotp_nvmem_config.dev = dev; + imx_ocotp_nvmem_config.priv = priv; nvmem = nvmem_register(&imx_ocotp_nvmem_config); if (IS_ERR(nvmem)) return PTR_ERR(nvmem);