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: 8921221 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 717D49F6CD for ; Sun, 24 Apr 2016 19:47:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC5FB2024F for ; Sun, 24 Apr 2016 19:47:52 +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 5E32C201EC for ; Sun, 24 Apr 2016 19:47:51 +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 1auQ0V-0001oZ-3A; Sun, 24 Apr 2016 19:47:51 +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-0001Sc-UT for linux-mediatek@bombadil.infradead.org; Sun, 24 Apr 2016 19:47:25 +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-0005yZ-TI for linux-mediatek@lists.infradead.org; Sun, 24 Apr 2016 19:29:07 +0000 Received: by mail-wm0-x234.google.com with SMTP id v188so75427122wme.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=SCsRluxd6jvCSSMn2bJqs7Q6h1PHqPIKXkVIqRG3mHP1SwH80PCQXpznTBL6nNxHVh 0MPfz36D50imCcaOj8fy6QuxtvDQ9FLrBsLoFipfbYcbtQFkYDV1zi6bhQxCYzdmVcFc Y0TdGO8/vhpobkvABlTaPvINhmnfyfkzP2idXiGePo7+2K6jo+u4DjhHDOHKefG7XQMy LMcwDPG3gs5/fPGyXY6+XB2htT5JDRNUvoNdiZQBlkMxQro00EoDA2gRWTP9nok9IecG T1jBQNPeZv32zFsOKV9E+fDrSHbkWV/7M1BHPfldgqFP3qZk33/Lt19r8NHpxYsQSxGc BSVA== X-Gm-Message-State: AOPr4FXDYYGHRLHRJPvdMOrwBYAtSXyBgr4w86eNGmjAuVigSJySZhXMclK3RioKgPoDDXVP 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160424_202903_987897_FC45286C X-CRM114-Status: GOOD ( 17.02 ) 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 --- drivers/nvmem/rockchip-efuse.c | 49 ++++++++---------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) 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))