From patchwork Mon May 2 18:36: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: 8994251 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 58646BF29F for ; Mon, 2 May 2016 18:36:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FEF0201BB for ; Mon, 2 May 2016 18:36:47 +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 7EB1C201C7 for ; Mon, 2 May 2016 18:36:46 +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 1axIi6-0003Bf-6x; Mon, 02 May 2016 18:36:46 +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 1axIi3-000389-DE for linux-mediatek@lists.infradead.org; Mon, 02 May 2016 18:36:44 +0000 Received: by mail-wm0-x231.google.com with SMTP id v200so24144171wmv.1 for ; Mon, 02 May 2016 11:36:21 -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=ktDyja9RksSU55uuiHPhtq1NmRt6KTBfKfQ5OpgfxF0=; b=etQnd28THU8qLpsC27jsy8xVMSkhVUIEz4e0AxPOSnvfEpeese5oYCXemCO7KZZ9gK assJTtrTNJWVJiJPnD3l95Avt4ZASSAyUNU6GxAXwREWamL8XunhbUChsnSx3aXiZq2e lY0DQ/zrfehMiJJ9OGO7do3z3NRWlQ4pjNtXQ= 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=ktDyja9RksSU55uuiHPhtq1NmRt6KTBfKfQ5OpgfxF0=; b=E7K4SwEbX3kSLgjZq8anrzU56p4rx8w5KwW8+P/MVYk8VoTwPNP/0/BDD2/L5yzUh5 EGyjlU8w6Re/y8wQE3UqSXkotVsBEZ7nLlwphKFTLTA7ky6vKzmC/su97FTbepEP/8on m7ns2+D1ikT8DXP9bgbF1+KTn/L4m2ziIMJqTl9pZ6krD1BSTEXKsFsX2Wk3DNUcAWj0 t/IitYMjvb+YwnMPGtAaH5xtbc9CvYidQGZBtWqG5h8NQ+ZUxUZrj6tTDccql8RY7yXH fiBA2YV4nVrVIY2U9OjCC6xx5FUAnbYRwbGcw1IJ/j0n+AWaGWajGJodyY7pAl5ovwZT FZrA== X-Gm-Message-State: AOPr4FWyeuZDo6NR6XJhlyS+71escuIJvaH64HAIQpMPsB9cmLWiKishdPXajzGIVpCn42fi X-Received: by 10.28.102.8 with SMTP id a8mr20884045wmc.54.1462214180379; Mon, 02 May 2016 11:36:20 -0700 (PDT) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id i4sm31557261wjj.49.2016.05.02.11.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 May 2016 11:36:19 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Subject: [PATCH v3 1/2] nvmem: mtk-efuse: remove nvmem regmap dependency Date: Mon, 2 May 2016 19:36:13 +0100 Message-Id: <1462214174-469-2-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462214174-469-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1462214174-469-1-git-send-email-srinivas.kandagatla@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160502_113643_596991_04AAD001 X-CRM114-Status: GOOD ( 15.15 ) 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: stefan.wahren@i2se.com, linux-kernel@vger.kernel.org, Srinivas Kandagatla , 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=ham 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 Regmap raw accessors are bus specific implementations, using regmap raw apis in nvmem breaks nvmem providers based on regmap mmio. This patch moves to nvmem support in the driver to use callback instead of regmap, which is what the nvmem core supports now. Signed-off-by: Srinivas Kandagatla --- 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 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);