From patchwork Sun Apr 24 19:28:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 8921181 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 189A3BF29F for ; Sun, 24 Apr 2016 19:47:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45D4F201E4 for ; Sun, 24 Apr 2016 19:47:51 +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 5F9ED201BB for ; Sun, 24 Apr 2016 19:47:50 +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 1auQ0U-0001nC-2A; Sun, 24 Apr 2016 19:47:50 +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 1auQ04-0001Qb-8e for linux-mediatek@bombadil.infradead.org; Sun, 24 Apr 2016 19:47:24 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by casper.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1auPiJ-0005ya-TG for linux-mediatek@lists.infradead.org; Sun, 24 Apr 2016 19:29:08 +0000 Received: by mail-wm0-x234.google.com with SMTP id v188so75427435wme.1 for ; Sun, 24 Apr 2016 12:28:44 -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=RYlaPRn9Hc/Qkv9K2kP+YtzjL2ttq/5eveFPDbYdX5o=; b=L5brmO/urTHuVs9WQkalxQvu+zDhaOB0uSdGQY/0K+fd89s7uO9JQKApOJWxuwKHBZ 3ShEc46S4t+H3r7RycN/YNd0zuPGEKsWTItwDN6u4IScQbPuVxMO8PlW3zg+aXWUm/vN PaQ4Q5V2P0M2fCwA8oqR1ceEu3G0JFL9EVsIw= 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=RYlaPRn9Hc/Qkv9K2kP+YtzjL2ttq/5eveFPDbYdX5o=; b=Rg8XXkpatM2M2M1bO7Ibb9qnrydEjGe7kw8oaQ25fKwOQbC0q9nTpdWApjR7ileR9D SW4zRh16GuCpEjPk683fYQzb/UB8O5do3sbUFokSgkGDuIhRWoLUlI4WUymFeWTK/nI/ sz+7vz4bTwQ1NYtolk2DfEUOIV5xEGdHbg1gwoDfSNWoo6PBGZe0oWibXug1ShUQa8tg Uu01wWze4QYTubYlNm2YcINDtvmgo80GpnZbPMYl1fj5+ByH+SvMer2yJj5UELj4BSP+ be1UqGcHyvA2B3wCkbKeH64QgEJV6c5B9Oc9N5FSK34Mh9W8vLFV0YuZZ4H8WPN66fTT AJkA== X-Gm-Message-State: AOPr4FWler1puOWC+m8tXCpGSRQgh8+bs4LPySIKmCJ+V4hzwp1U7y5N3ylV4o7aSe2z2YL8 X-Received: by 10.194.113.3 with SMTP id iu3mr35239297wjb.149.1461526123121; Sun, 24 Apr 2016 12:28:43 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 12:28:42 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Subject: [PATCH 08/12] nvmem: mtk-efuse: remove nvmem regmap dependency Date: Sun, 24 Apr 2016 20:28:12 +0100 Message-Id: <1461526096-29584-9-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_202903_967139_2DB3B1C2 X-CRM114-Status: GOOD ( 15.34 ) 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. Signed-off-by: Srinivas Kandagatla Acked-by: Andrew-CT Chen --- drivers/nvmem/Kconfig | 1 - drivers/nvmem/mtk-efuse.c | 47 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 377bc21..c158712 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -48,7 +48,6 @@ config NVMEM_MXS_OCOTP config MTK_EFUSE tristate "Mediatek SoCs EFUSE support" depends on ARCH_MEDIATEK || COMPILE_TEST - 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);