From patchwork Mon May 2 18:36:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 67040 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp193057qge; Mon, 2 May 2016 11:37:06 -0700 (PDT) X-Received: by 10.98.48.71 with SMTP id w68mr53206475pfw.18.1462214226146; Mon, 02 May 2016 11:37:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id td3si43032014pac.24.2016.05.02.11.37.05; Mon, 02 May 2016 11:37:06 -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 S932090AbcEBSgv (ORCPT + 29 others); Mon, 2 May 2016 14:36:51 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:38062 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754983AbcEBSgX (ORCPT ); Mon, 2 May 2016 14:36:23 -0400 Received: by mail-wm0-f42.google.com with SMTP id g17so459551wme.1 for ; Mon, 02 May 2016 11:36:23 -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=bg/GNsqYb+smEaCMIfUHyjWz5LvjPSQIZyXpoYqCBj8=; b=QceK7zmC+jU+6eDAueG4QK93g+wv0+JHZY4aRa4D8TqvnIyekx8RnxgpczuCsgUAxe Rvsz48+4MWx6wIQx23Dz6d93qF9ECILgQV3HqUYrNAxh98FHOA7cD+dgj3r53IE5ugJ1 fbums6N5x2QvLlsWmCW3hQFE6ESyLKKkJOQnY= 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=bg/GNsqYb+smEaCMIfUHyjWz5LvjPSQIZyXpoYqCBj8=; b=LzOQEyLFgaMIV4bMMzsEN7sImhXQRi6v14U2phW8yMVHTTgCeEa3Bly96Y8s1B/ltC 2/KU3Ndr8Ud3FnyDyICOTMWxT7B7ful/YdGU2ATOelDPkyIojAbKtEuf56gOMwR7T0Tr injkuX/a1N39BShZJYtE7o+WUcXisH/rYh1kbJ1QSiMbXGJCWtlxDfrQ1Ugm6eJyvpBR 3NXgIuk3Fk3cZk4PGhcw8DXeHZKWvh9FOLIHyxd4fx2P922BDi9m1WRb28SzreOK9jVQ G6Yv8qCHE/m6P1D2rG8VCaR8qpTARP5/TtlTB60ckMwpMd6sC/yHQUceq24S6WCKk+pw cdBA== X-Gm-Message-State: AOPr4FUsYOFRTiLEvmwmKqEESQUQhzs0gWPpuAFNnXUiTjojtaZDqZxVLx/f9DodvRIK7Yto X-Received: by 10.28.6.138 with SMTP id 132mr19841236wmg.60.1462214181660; Mon, 02 May 2016 11:36:21 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 May 2016 11:36:20 -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 v3 2/2] nvmem: mxs-ocotp: remove nvmem regmap dependency Date: Mon, 2 May 2016 19:36:14 +0100 Message-Id: <1462214174-469-3-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/mxs-ocotp.c | 83 +++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 61 deletions(-) -- 2.5.0 diff --git a/drivers/nvmem/mxs-ocotp.c b/drivers/nvmem/mxs-ocotp.c index 2bb3c57..d26dd03 100644 --- a/drivers/nvmem/mxs-ocotp.c +++ b/drivers/nvmem/mxs-ocotp.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -66,11 +65,10 @@ static int mxs_ocotp_wait(struct mxs_ocotp *otp) return 0; } -static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size, - void *val, size_t val_size) +static int mxs_ocotp_read(void *context, unsigned int offset, + void *val, size_t bytes) { struct mxs_ocotp *otp = context; - unsigned int offset = *(u32 *)reg; u32 *buf = val; int ret; @@ -94,17 +92,16 @@ static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size, if (ret) goto close_banks; - while (val_size >= reg_size) { + while (bytes) { if ((offset < OCOTP_DATA_OFFSET) || (offset % 16)) { /* fill up non-data register */ - *buf = 0; + *buf++ = 0; } else { - *buf = readl(otp->base + offset); + *buf++ = readl(otp->base + offset); } - buf++; - val_size -= reg_size; - offset += reg_size; + bytes -= 4; + offset += 4; } close_banks: @@ -117,57 +114,29 @@ disable_clk: return ret; } -static int mxs_ocotp_write(void *context, const void *data, size_t count) -{ - /* We don't want to support writing */ - return 0; -} - -static bool mxs_ocotp_writeable_reg(struct device *dev, unsigned int reg) -{ - return false; -} - static struct nvmem_config ocotp_config = { .name = "mxs-ocotp", + .stride = 16, + .word_size = 4, .owner = THIS_MODULE, + .reg_read = mxs_ocotp_read, }; -static const struct regmap_range imx23_ranges[] = { - regmap_reg_range(OCOTP_DATA_OFFSET, 0x210), -}; - -static const struct regmap_access_table imx23_access = { - .yes_ranges = imx23_ranges, - .n_yes_ranges = ARRAY_SIZE(imx23_ranges), -}; - -static const struct regmap_range imx28_ranges[] = { - regmap_reg_range(OCOTP_DATA_OFFSET, 0x290), -}; - -static const struct regmap_access_table imx28_access = { - .yes_ranges = imx28_ranges, - .n_yes_ranges = ARRAY_SIZE(imx28_ranges), +struct mxs_data { + int size; }; -static struct regmap_bus mxs_ocotp_bus = { - .read = mxs_ocotp_read, - .write = mxs_ocotp_write, /* make regmap_init() happy */ - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, +static const struct mxs_data imx23_data = { + .size = 0x220, }; -static struct regmap_config mxs_ocotp_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 16, - .writeable_reg = mxs_ocotp_writeable_reg, +static const struct mxs_data imx28_data = { + .size = 0x2a0, }; static const struct of_device_id mxs_ocotp_match[] = { - { .compatible = "fsl,imx23-ocotp", .data = &imx23_access }, - { .compatible = "fsl,imx28-ocotp", .data = &imx28_access }, + { .compatible = "fsl,imx23-ocotp", .data = &imx23_data }, + { .compatible = "fsl,imx28-ocotp", .data = &imx28_data }, { /* sentinel */}, }; MODULE_DEVICE_TABLE(of, mxs_ocotp_match); @@ -175,11 +144,10 @@ MODULE_DEVICE_TABLE(of, mxs_ocotp_match); static int mxs_ocotp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct mxs_data *data; struct mxs_ocotp *otp; struct resource *res; const struct of_device_id *match; - struct regmap *regmap; - const struct regmap_access_table *access; int ret; match = of_match_device(dev->driver->of_match_table, dev); @@ -205,17 +173,10 @@ static int mxs_ocotp_probe(struct platform_device *pdev) return ret; } - access = match->data; - mxs_ocotp_config.rd_table = access; - mxs_ocotp_config.max_register = access->yes_ranges[0].range_max; - - regmap = devm_regmap_init(dev, &mxs_ocotp_bus, otp, &mxs_ocotp_config); - if (IS_ERR(regmap)) { - dev_err(dev, "regmap init failed\n"); - ret = PTR_ERR(regmap); - goto err_clk; - } + data = match->data; + ocotp_config.size = data->size; + ocotp_config.priv = otp; ocotp_config.dev = dev; otp->nvmem = nvmem_register(&ocotp_config); if (IS_ERR(otp->nvmem)) {