From patchwork Mon May 2 15:22:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 67036 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp104065qge; Mon, 2 May 2016 08:23:42 -0700 (PDT) X-Received: by 10.98.36.132 with SMTP id k4mr42629132pfk.95.1462202621514; Mon, 02 May 2016 08:23:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dy1si19663238pab.117.2016.05.02.08.23.41; Mon, 02 May 2016 08:23:41 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754200AbcEBPXd (ORCPT + 29 others); Mon, 2 May 2016 11:23:33 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37554 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754160AbcEBPXV (ORCPT ); Mon, 2 May 2016 11:23:21 -0400 Received: by mail-wm0-f47.google.com with SMTP id a17so148280189wme.0 for ; Mon, 02 May 2016 08:23:20 -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=tiOWZlmMlSdz8/HRB3QuxtSNIQ4vACs9O8LnvFQ173Y=; b=RLkRfI53x/fXfsRQLqAtnJtJlDraQxAT9F5IEt+eBINvP1dq/2rplTLRulK8ATIOTB T1vdDdrZ5KlqCTNPJ/0fgu/JTsSLY+/m0cb1NI0tWX6SyQjLRQ99FHpeU4F4hIfM3/sT aTk2n4eqW3JqHmL7oVoU1CXkH+udVwTTCm5UU= 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=tiOWZlmMlSdz8/HRB3QuxtSNIQ4vACs9O8LnvFQ173Y=; b=CAX7ayDFjj893TpwzKaXj/1BMr2En/Ud5LqHPPAfrks3Tv69eba4Fak/86qfrX1xjc BUxUDJAI5/JANWzpUpzqfsq0tY9WL72TySm9J0jVWblC5CTu1ADg2ypb/z/zRiHXFfIG 3S92FzMM+sALkwi9e7gcucvWwlCmaSEnzWy9JCZ8hjSyzNzuCnFhpULMJ0rDvl9tdo73 r9X+yBnSk2aBUxR+9oUjMsqseA8PmzAvghYTKWeCI2RZf452qHgbVTFbtXqBDgR8el2p SrqHzmC5O3IbD8vhiyTXwbKKkMzGKWkwebCXtVHTcbFNz+WMB3LyDn9VI1HTX3fk+MSd 5nYg== X-Gm-Message-State: AOPr4FU9PK8JwDt2dkr1HQrTPN8HqzFtgqdiq7YJSmD7GiJgHFUxJeLRHLOAibLdDsg3s7Lr X-Received: by 10.194.2.210 with SMTP id 18mr40333215wjw.55.1462202599800; Mon, 02 May 2016 08:23:19 -0700 (PDT) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id f135sm19399539wmf.22.2016.05.02.08.23.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 May 2016 08:23:19 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-mediatek@lists.infradead.org, Srinivas Kandagatla , Maxime Ripard , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, stefan.wahren@i2se.com Subject: [PATCH v2 1/2] nvmem: mtk-efuse: remove nvmem regmap dependency Date: Mon, 2 May 2016 16:22:57 +0100 Message-Id: <1462202578-15433-2-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462202578-15433-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1462202578-15433-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 This patch moves to nvmem support in the driver to use callback instead of regmap. Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 1 - drivers/nvmem/mtk-efuse.c | 47 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 16 deletions(-) -- 2.5.0 diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 3041d48..5ff2189 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -50,7 +50,6 @@ config MTK_EFUSE tristate "Mediatek SoCs EFUSE support" depends on ARCH_MEDIATEK || COMPILE_TEST depends on HAS_IOMEM - select REGMAP_MMIO help This is a driver to access hardware related data like sensor calibration, HDMI impedance etc. diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c index 9c49369..32fd572 100644 --- a/drivers/nvmem/mtk-efuse.c +++ b/drivers/nvmem/mtk-efuse.c @@ -14,15 +14,35 @@ #include #include +#include #include #include -#include -static struct regmap_config mtk_regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, -}; +static int mtk_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; + + while (words--) + *val++ = readl(base + reg + (i++ * 4)); + + return 0; +} + +static int mtk_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 mtk_efuse_probe(struct platform_device *pdev) { @@ -30,7 +50,6 @@ static int mtk_efuse_probe(struct platform_device *pdev) struct resource *res; struct nvmem_device *nvmem; struct nvmem_config *econfig; - struct regmap *regmap; void __iomem *base; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -42,14 +61,12 @@ static int mtk_efuse_probe(struct platform_device *pdev) if (!econfig) return -ENOMEM; - mtk_regmap_config.max_register = resource_size(res) - 1; - - regmap = devm_regmap_init_mmio(dev, base, &mtk_regmap_config); - if (IS_ERR(regmap)) { - dev_err(dev, "regmap init failed\n"); - return PTR_ERR(regmap); - } - + econfig->stride = 4; + econfig->word_size = 4; + econfig->reg_read = mtk_reg_read; + econfig->reg_write = mtk_reg_write; + econfig->size = resource_size(res); + econfig->priv = base; econfig->dev = dev; econfig->owner = THIS_MODULE; nvmem = nvmem_register(econfig);