From patchwork Sun Apr 24 19:28:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 66543 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp696913qge; Sun, 24 Apr 2016 12:30:55 -0700 (PDT) X-Received: by 10.66.136.235 with SMTP id qd11mr43124030pab.140.1461526255197; Sun, 24 Apr 2016 12:30:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g62si1689683pfj.213.2016.04.24.12.30.54; Sun, 24 Apr 2016 12:30:55 -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 S1753384AbcDXTal (ORCPT + 29 others); Sun, 24 Apr 2016 15:30:41 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:38033 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753228AbcDXT2n (ORCPT ); Sun, 24 Apr 2016 15:28:43 -0400 Received: by mail-wm0-f43.google.com with SMTP id u206so97599805wme.1 for ; Sun, 24 Apr 2016 12:28:42 -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=7Fb/JZCtdQ0qTMwIgmZWVY7knmDI1KBXBFhlKDmrLmc=; b=FG5kNGVEK257RImVkz70LIKXrvYo+4jr7+bK8lDT+ErgUkAzxo254cb30bHt1wBoPI WKbnMBK3ivA/3dm1hN9BaJsXcHtG1kDjG6TxqGQahU+0lij5N/mxnKi3mN0o1eNqzwHY eYRf2PDhfnRTQXwx90ApaumEnM/HluwEYbwWs= 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=7Fb/JZCtdQ0qTMwIgmZWVY7knmDI1KBXBFhlKDmrLmc=; b=WozAkl9lF+hyxFtQtylhsckOl35jM+GaMF1Xh1HVP70kLCXQF9RNzTWBpoC7Vfkklk uN/XNkY8GuqtO799CxI1rml4bzbDX/MlHqxBE4tLBcRW3EQknu2X0bfI0VMiQmxDPNpj 7LWFKYwPCiTHKuX6TFs9kENkrdJvj3d+jHn8tWWs4Ex9w8pnsEnkFCS/FO5j46iMBoRf ZesZpbUabEtfAdvNesvhuoJ/uLzldgjM7MBM9xtfZwEtLwROksUM5eYHKsT269YBT5cQ CDIR4AN35HBvw7LmqKUbutCQ0aWwdXF1VbQXwfIFkBQTF3JQchYQ5geBAHS1pOkz1BA0 NCjw== X-Gm-Message-State: AOPr4FXpGYOw2pIJy4+fyNxOk/fYc0B1muwOUDub6qXDkuYlyJBs4wXXGEnOKPVCpQkZUDLC X-Received: by 10.28.26.78 with SMTP id a75mr3488336wma.59.1461526121905; Sun, 24 Apr 2016 12:28:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 12:28:41 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: Wolfram Sang , Srinivas Kandagatla , Maxime Ripard , Joachim Eastwood , Matthias Brugger , Heiko Stuebner , Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, Mark Brown , andrew@lunn.ch Subject: [PATCH 07/12] nvmem: rockchip-efuse: remove nvmem regmap dependency Date: Sun, 24 Apr 2016 20:28:11 +0100 Message-Id: <1461526096-29584-8-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> 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/rockchip-efuse.c | 49 ++++++++---------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) -- 2.5.0 diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c index a009795..4d3f391 100644 --- a/drivers/nvmem/rockchip-efuse.c +++ b/drivers/nvmem/rockchip-efuse.c @@ -23,7 +23,6 @@ #include #include #include -#include #define EFUSE_A_SHIFT 6 #define EFUSE_A_MASK 0x3ff @@ -41,17 +40,9 @@ struct rockchip_efuse_chip { struct clk *clk; }; -static int rockchip_efuse_write(void *context, const void *data, size_t count) +static int rockchip_efuse_read(void *context, unsigned int offset, + void *val, size_t bytes) { - /* Nothing TBD, Read-Only */ - return 0; -} - -static int rockchip_efuse_read(void *context, - const void *reg, size_t reg_size, - void *val, size_t val_size) -{ - unsigned int offset = *(u32 *)reg; struct rockchip_efuse_chip *efuse = context; u8 *buf = val; int ret; @@ -64,12 +55,12 @@ static int rockchip_efuse_read(void *context, writel(EFUSE_LOAD | EFUSE_PGENB, efuse->base + REG_EFUSE_CTRL); udelay(1); - while (val_size) { + while (bytes--) { writel(readl(efuse->base + REG_EFUSE_CTRL) & (~(EFUSE_A_MASK << EFUSE_A_SHIFT)), efuse->base + REG_EFUSE_CTRL); writel(readl(efuse->base + REG_EFUSE_CTRL) | - ((offset & EFUSE_A_MASK) << EFUSE_A_SHIFT), + ((offset++ & EFUSE_A_MASK) << EFUSE_A_SHIFT), efuse->base + REG_EFUSE_CTRL); udelay(1); writel(readl(efuse->base + REG_EFUSE_CTRL) | @@ -79,9 +70,6 @@ static int rockchip_efuse_read(void *context, writel(readl(efuse->base + REG_EFUSE_CTRL) & (~EFUSE_STROBE), efuse->base + REG_EFUSE_CTRL); udelay(1); - - val_size -= 1; - offset += 1; } /* Switch to standby mode */ @@ -92,22 +80,11 @@ static int rockchip_efuse_read(void *context, return 0; } -static struct regmap_bus rockchip_efuse_bus = { - .read = rockchip_efuse_read, - .write = rockchip_efuse_write, - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, -}; - -static struct regmap_config rockchip_efuse_regmap_config = { - .reg_bits = 32, - .reg_stride = 1, - .val_bits = 8, -}; - static struct nvmem_config econfig = { .name = "rockchip-efuse", .owner = THIS_MODULE, + .stride = 1, + .word_size = 1, .read_only = true, }; @@ -121,7 +98,6 @@ static int rockchip_efuse_probe(struct platform_device *pdev) { struct resource *res; struct nvmem_device *nvmem; - struct regmap *regmap; struct rockchip_efuse_chip *efuse; efuse = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_efuse_chip), @@ -139,16 +115,9 @@ static int rockchip_efuse_probe(struct platform_device *pdev) return PTR_ERR(efuse->clk); efuse->dev = &pdev->dev; - - rockchip_efuse_regmap_config.max_register = resource_size(res) - 1; - - regmap = devm_regmap_init(efuse->dev, &rockchip_efuse_bus, - efuse, &rockchip_efuse_regmap_config); - if (IS_ERR(regmap)) { - dev_err(efuse->dev, "regmap init failed\n"); - return PTR_ERR(regmap); - } - + econfig.size = resource_size(res); + econfig.reg_read = rockchip_efuse_read; + econfig.priv = efuse; econfig.dev = efuse->dev; nvmem = nvmem_register(&econfig); if (IS_ERR(nvmem))