linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: andrew-ct chen <andrew-ct.chen@mediatek.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	andrew@lunn.ch, Heiko Stuebner <heiko@sntech.de>,
	Wolfram Sang <wsa@the-dreams.de>,
	Joachim Eastwood <manabian@gmail.com>,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	Chen-Yu Tsai <wens@csie.org>, Mark Brown <broonie@kernel.org>,
	linux-i2c@vger.kernel.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-mediatek@lists.infradead.org,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 08/12] nvmem: mtk-efuse: remove nvmem regmap dependency
Date: Wed, 27 Apr 2016 14:30:13 +0800	[thread overview]
Message-ID: <1461738613.12466.8.camel@mtksdaap41> (raw)
In-Reply-To: <1461526096-29584-9-git-send-email-srinivas.kandagatla@linaro.org>

Hi Srinivas,

On Sun, 2016-04-24 at 20:28 +0100, Srinivas Kandagatla wrote:
> This patch moves to nvmem support in the driver to use callback
> instead of regmap.
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---

Thanks for the patch. It works on our platform. This driver doesn't
support "efuse write". I will send another patch for fixing this.

Acked-by: Andrew-CT Chen <andrew-ct.chen@mediatek.com>

Andrew

>  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 <linux/device.h>
>  #include <linux/module.h>
> +#include <linux/io.h>
>  #include <linux/nvmem-provider.h>
>  #include <linux/platform_device.h>
> -#include <linux/regmap.h>
>  
> -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);

  reply	other threads:[~2016-04-27  6:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 19:28 [PATCH 00/12] nvmem: remove regmap dependency Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 01/12] nvmem: core: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 02/12] eeprom: at24: remove nvmem " Srinivas Kandagatla
2016-05-02  7:32   ` Wolfram Sang
2016-05-04  1:32     ` Andrew Lunn
     [not found] ` <1461526096-29584-1-git-send-email-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-24 19:28   ` [PATCH 03/12] eeprom: at25: " Srinivas Kandagatla
2016-04-24 19:28   ` [PATCH 04/12] nvmem: qfprom: " Srinivas Kandagatla
2016-04-24 19:28   ` [PATCH 05/12] nvmem: vif610-ocotp: " Srinivas Kandagatla
2016-04-27  5:36     ` maitysanchayan
2016-04-24 19:28   ` [PATCH 06/12] nvmem: sunxi-sid: " Srinivas Kandagatla
2016-04-24 19:28   ` [PATCH 07/12] nvmem: rockchip-efuse: " Srinivas Kandagatla
2016-04-24 19:28   ` [PATCH 08/12] nvmem: mtk-efuse: " Srinivas Kandagatla
2016-04-27  6:30     ` andrew-ct chen [this message]
2016-05-01 21:01     ` Greg Kroah-Hartman
2016-04-24 19:28 ` [PATCH 09/12] nvmem: imx-ocotp: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 10/12] nvmem: lpc18xx-eeprom: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 11/12] nvmem: mxs-ocotp: " Srinivas Kandagatla
     [not found]   ` <1461526096-29584-12-git-send-email-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-28  6:50     ` Stefan Wahren
2016-04-24 19:28 ` [PATCH 12/12] nvmem: 93xx46: " Srinivas Kandagatla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461738613.12466.8.camel@mtksdaap41 \
    --to=andrew-ct.chen@mediatek.com \
    --cc=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=manabian@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=wens@csie.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).