From patchwork Sun Apr 24 19:28:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 8920721 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F11DBF29F for ; Sun, 24 Apr 2016 19:29:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5231220219 for ; Sun, 24 Apr 2016 19:29:01 +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 422F820155 for ; Sun, 24 Apr 2016 19:29:00 +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 1auPiE-00050x-EF; Sun, 24 Apr 2016 19:28:58 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auPiB-0004wx-7u for linux-mediatek@lists.infradead.org; Sun, 24 Apr 2016 19:28:56 +0000 Received: by mail-wm0-x231.google.com with SMTP id v188so75426096wme.1 for ; Sun, 24 Apr 2016 12:28:39 -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=nslTc8ro1kARUVb3biH6Mc8mD3YVNLySbLRYpSAzPeU=; b=kGmoK+jmTHp8mFVCbY5Ygfr9sMvw8nIo0RADyLsfJ6ej6Jy16Zh1bTnuE816ZvmsVK 1eLCV5ZHZdITVslSXxm+WDW78D7CEFfcKHj20JthLu66oAJEi3YBJpHbLl/8yCT1n8nU vH0CYBavLJXWUs+Hq6QL9uDbGYeixZLxbOB70= 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=nslTc8ro1kARUVb3biH6Mc8mD3YVNLySbLRYpSAzPeU=; b=EapEsfG++qkdtIokazOPxRU914RLgsdSThtsYDsEN2p1sLb1ANpKY+/mqXByjiywe+ ogh11pB7Z864seGgkzDbWzwIKxdE2MZyqXBgdhu+EPCwfmjeuq4DFIdR4WhsTtTr+NI2 vmx/fb18nxLJf3CqXAWSFTrg467OLYd6U2j2UZJyPigqbXYoxWN6SnK0SSMTSde+WQzG zjTbHkg57yMFmdPMl9uT78JKQc5rq0XHlB3RpWIwKlr7G0uGaeVxO/IEuZ1kE3i0PZCe ZZwG3duec/pG5q9rzCkzWfIrlnMAZAbzMJS+ylrhdeu6Nga0oTzEseWeEZh+cSNOqcVV YKiA== X-Gm-Message-State: AOPr4FV5yD1RsgEbrrarN6GcZwzDYBRUsxlFv9FVc5Mby7BjSJR92ozAcL5E3Tvn+4qtyLg3 X-Received: by 10.28.145.67 with SMTP id t64mr8545344wmd.56.1461526117929; Sun, 24 Apr 2016 12:28:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 12:28:37 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Subject: [PATCH 04/12] nvmem: qfprom: remove nvmem regmap dependency Date: Sun, 24 Apr 2016 20:28:08 +0100 Message-Id: <1461526096-29584-5-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_122855_453430_A19587CD X-CRM114-Status: GOOD ( 15.77 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=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. Reported-by: Rajendra Nayak Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 1 - drivers/nvmem/qfprom.c | 56 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 36f4f4b..a87273b 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -60,7 +60,6 @@ config QCOM_QFPROM tristate "QCOM QFPROM Support" depends on ARCH_QCOM || COMPILE_TEST depends on HAS_IOMEM - select REGMAP_MMIO help Say y here to enable QFPROM support. The QFPROM provides access functions for QFPROM data to rest of the drivers via nvmem interface. diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c index 3829e5f..b5305f0 100644 --- a/drivers/nvmem/qfprom.c +++ b/drivers/nvmem/qfprom.c @@ -13,21 +13,35 @@ #include #include +#include #include #include -#include -static struct regmap_config qfprom_regmap_config = { - .reg_bits = 32, - .val_bits = 8, - .reg_stride = 1, - .val_format_endian = REGMAP_ENDIAN_LITTLE, -}; +static int qfprom_reg_read(void *context, + unsigned int reg, void *_val, size_t bytes) +{ + void __iomem *base = context; + u32 *val = _val; + int i = 0, words = bytes / 4; -static struct nvmem_config econfig = { - .name = "qfprom", - .owner = THIS_MODULE, -}; + while (words--) + *val++ = readl(base + reg + (i++ * 4)); + + return 0; +} + +static int qfprom_reg_write(void *context, + unsigned int reg, void *_val, size_t bytes) +{ + void __iomem *base = context; + u32 *val = _val; + int i = 0, words = bytes / 4; + + while (words--) + writel(*val++, base + reg + (i++ * 4)); + + return 0; +} static int qfprom_remove(struct platform_device *pdev) { @@ -36,12 +50,20 @@ static int qfprom_remove(struct platform_device *pdev) return nvmem_unregister(nvmem); } +static struct nvmem_config econfig = { + .name = "qfprom", + .owner = THIS_MODULE, + .stride = 4, + .word_size = 1, + .reg_read = qfprom_reg_read, + .reg_write = qfprom_reg_write, +}; + static int qfprom_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; struct nvmem_device *nvmem; - struct regmap *regmap; void __iomem *base; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -49,14 +71,10 @@ static int qfprom_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - qfprom_regmap_config.max_register = resource_size(res) - 1; - - regmap = devm_regmap_init_mmio(dev, base, &qfprom_regmap_config); - if (IS_ERR(regmap)) { - dev_err(dev, "regmap init failed\n"); - return PTR_ERR(regmap); - } + econfig.size = resource_size(res); econfig.dev = dev; + econfig.priv = base; + nvmem = nvmem_register(&econfig); if (IS_ERR(nvmem)) return PTR_ERR(nvmem);