linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: "Andreas Färber" <afaerber@suse.de>,
	linux-realtek-soc@lists.infradead.org
Cc: "Stanley Chang [昌育德]" <stanley_chang@realtek.com>,
	"James Tai [戴志峰]" <james.tai@realtek.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	"Edgar Lee" <cylee12@realtek.com>
Subject: Re: [PATCH v2 18/29] nvmem: Add Realtek DHC eFuse driver
Date: Mon, 20 Jul 2020 10:31:17 +0100	[thread overview]
Message-ID: <c49384c1-2a48-7ae8-67f0-08543c41fc69@linaro.org> (raw)
In-Reply-To: <20200623025106.31273-19-afaerber@suse.de>



On 23/06/2020 03:50, Andreas Färber wrote:
> Implement enough of a read-only nvmem driver to easily read efuse cells.
> 
> Cc: Cheng-Yu Lee <cylee12@realtek.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

If you are expecting this to be applied, then please resend this patch 
splitting the MAINTAINER File changes separately!

--srini
> ---
>   v2: New
>   
>   MAINTAINERS                   |  1 +
>   drivers/nvmem/Kconfig         |  9 ++++
>   drivers/nvmem/Makefile        |  2 +
>   drivers/nvmem/rtk-dhc-efuse.c | 86 +++++++++++++++++++++++++++++++++++
>   4 files changed, 98 insertions(+)
>   create mode 100644 drivers/nvmem/rtk-dhc-efuse.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1d0d6ab20451..02117fbf0e57 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2312,6 +2312,7 @@ F:	Documentation/devicetree/bindings/soc/realtek/
>   F:	arch/arm/boot/dts/rtd*
>   F:	arch/arm/mach-realtek/
>   F:	arch/arm64/boot/dts/realtek/
> +F:	drivers/nvmem/rtk-dhc-efuse.c
>   F:	drivers/soc/realtek/
>   
>   ARM/RENESAS ARM64 ARCHITECTURE
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index d7b7f6d688e7..75cf43b16cf9 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -129,6 +129,15 @@ config NVMEM_SPMI_SDAM
>   	  Qualcomm Technologies, Inc. PMICs. It provides the clients
>   	  an interface to read/write to the SDAM module's shared memory.
>   
> +config REALTEK_DHC_EFUSE
> +	tristate "Realtek DHC eFuse Support"
> +	depends on ARCH_REALTEK || COMPILE_TEST
> +	depends on HAS_IOMEM
> +	help
> +	  Say y here to enable read-only access to the Realtek Digital Home
> +	  This driver can also be built as a module. If so, the module
> +	  will be called nvmem-rtk-dhc-efuse.
> +
>   config ROCKCHIP_EFUSE
>   	tristate "Rockchip eFuse Support"
>   	depends on ARCH_ROCKCHIP || COMPILE_TEST
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index a7c377218341..67cefdfa44e6 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -33,6 +33,8 @@ obj-$(CONFIG_ROCKCHIP_EFUSE)	+= nvmem_rockchip_efuse.o
>   nvmem_rockchip_efuse-y		:= rockchip-efuse.o
>   obj-$(CONFIG_ROCKCHIP_OTP)	+= nvmem-rockchip-otp.o
>   nvmem-rockchip-otp-y		:= rockchip-otp.o
> +obj-$(CONFIG_REALTEK_DHC_EFUSE)	+= nvmem-rtk-dhc-efuse.o
> +nvmem-rtk-dhc-efuse-y		:= rtk-dhc-efuse.o
>   obj-$(CONFIG_NVMEM_SUNXI_SID)	+= nvmem_sunxi_sid.o
>   nvmem_stm32_romem-y 		:= stm32-romem.o
>   obj-$(CONFIG_NVMEM_STM32_ROMEM) += nvmem_stm32_romem.o
> diff --git a/drivers/nvmem/rtk-dhc-efuse.c b/drivers/nvmem/rtk-dhc-efuse.c
> new file mode 100644
> index 000000000000..4672db2c2619
> --- /dev/null
> +++ b/drivers/nvmem/rtk-dhc-efuse.c
> @@ -0,0 +1,86 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Realtek Digital Home Center eFuse
> + *
> + * Copyright (c) 2020 Andreas Färber
> + */
> +
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/nvmem-provider.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +
> +struct dhc_efuse {
> +	struct device *dev;
> +	void __iomem *base;
> +	struct nvmem_device *nvmem;
> +};
> +
> +static int dhc_efuse_reg_read(void *priv, unsigned int offset, void *val,
> +	size_t bytes)
> +{
> +	struct dhc_efuse *efuse = priv;
> +	u8 *buf = val;
> +
> +	while (bytes--)
> +		*buf++ = readb_relaxed(efuse->base + offset++);
> +
> +	return 0;
> +}
> +
> +static int dhc_efuse_probe(struct platform_device *pdev)
> +{
> +	struct dhc_efuse *efuse;
> +	struct nvmem_config config = {};
> +	struct resource *res;
> +
> +	efuse = devm_kzalloc(&pdev->dev, sizeof(*efuse), GFP_KERNEL);
> +	if (!efuse)
> +		return -ENOMEM;
> +
> +	efuse->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> +	if (IS_ERR(efuse->base))
> +		return PTR_ERR(efuse->base);
> +
> +	efuse->dev = &pdev->dev;
> +
> +	config.dev = &pdev->dev;
> +	config.name = "dhc-efuse";
> +	config.owner = THIS_MODULE;
> +	config.type = NVMEM_TYPE_OTP;
> +	config.read_only = true,
> +	config.word_size = 4;
> +	config.stride = 1;
> +	config.size = resource_size(res);
> +	config.reg_read = dhc_efuse_reg_read;
> +	config.priv = efuse;
> +
> +	efuse->nvmem = devm_nvmem_register(&pdev->dev, &config);
> +	if (IS_ERR(efuse->nvmem)) {
> +		dev_err(&pdev->dev, "failed to register nvmem (%ld)\n",
> +			PTR_ERR(efuse->nvmem));
> +		return PTR_ERR(efuse->nvmem);
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id dhc_efuse_dt_ids[] = {
> +	 { .compatible = "realtek,rtd1195-efuse" },
> +	 { }
> +};
> +
> +static struct platform_driver dhc_efuse_driver = {
> +	.probe = dhc_efuse_probe,
> +	.driver = {
> +		.name = "rtk-dhc-efuse",
> +		.of_match_table	= dhc_efuse_dt_ids,
> +	},
> +};
> +module_platform_driver(dhc_efuse_driver);
> +
> +MODULE_DESCRIPTION("Realtek DHC eFuse driver");
> +MODULE_LICENSE("GPL");
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2020-07-20  9:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200623025106.31273-1-afaerber@suse.de>
     [not found] ` <20200623025106.31273-3-afaerber@suse.de>
2020-07-10  7:55   ` [PATCH v2 02/29] soc: Add Realtek DHC chip info driver for RTD1195 and RTD1295 Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-4-afaerber@suse.de>
2020-07-10  7:56   ` [PATCH v2 03/29] arm64: dts: realtek: rtd129x: Add chip info node Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-5-afaerber@suse.de>
2020-07-10  7:57   ` [PATCH v2 04/29] ARM: dts: rtd1195: " Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-7-afaerber@suse.de>
2020-07-10  7:58   ` [PATCH v2 06/29] soc: realtek: chip: Detect RTD1296 Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-8-afaerber@suse.de>
2020-07-10  7:59   ` [PATCH v2 07/29] arm64: dts: realtek: rtd129x: Extend chip-info reg with CHIP_INFO1 Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-10-afaerber@suse.de>
2020-07-10  8:01   ` [PATCH v2 09/29] soc: realtek: chip: Add RTD1395 info Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-12-afaerber@suse.de>
2020-07-10  8:02   ` [PATCH v2 11/29] soc: realtek: chip: Add RTD1619 info Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-13-afaerber@suse.de>
2020-07-10  8:02   ` [PATCH v2 12/29] arm64: dts: realtek: rtd16xx: Add chip info node Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-11-afaerber@suse.de>
2020-07-10  8:03   ` [PATCH v2 10/29] arm64: dts: realtek: rtd139x: " Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-14-afaerber@suse.de>
2020-07-10  8:04   ` [PATCH v2 13/29] soc: realtek: chip: Add RTD1319 info Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-15-afaerber@suse.de>
2020-07-10  8:04   ` [PATCH v2 14/29] soc: realtek: chip: Add RTD1319 revisions Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-17-afaerber@suse.de>
2020-07-10  8:05   ` [PATCH v2 16/29] soc: realtek: chip: Detect RTD1392 Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-16-afaerber@suse.de>
2020-07-10  8:06   ` [PATCH v2 15/29] arm64: dts: realtek: rtd13xx: Add chip info node Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-27-afaerber@suse.de>
2020-07-10  8:07   ` [PATCH v2 26/29] soc: realtek: chip: Detect RTD1294 Stanley Chang[昌育德]
     [not found] ` <20200623025106.31273-2-afaerber@suse.de>
2020-07-14  2:13   ` [PATCH v2 01/29] dt-bindings: soc: Add Realtek RTD1195 chip info binding Rob Herring
     [not found] ` <20200623025106.31273-6-afaerber@suse.de>
2020-07-14  2:13   ` [PATCH v2 05/29] dt-bindings: soc: realtek: rtd1195-chip: Add iso-syscon property Rob Herring
     [not found] ` <20200623025106.31273-18-afaerber@suse.de>
2020-07-14  2:15   ` [PATCH v2 17/29] dt-bindings: nvmem: Add Realtek RTD1195 eFuse Rob Herring
     [not found] ` <20200623025106.31273-25-afaerber@suse.de>
2020-07-14  2:15   ` [PATCH v2 24/29] dt-bindings: soc: realtek: rtd1195-chip: Allow nvmem-cells property Rob Herring
     [not found] ` <20200623025106.31273-19-afaerber@suse.de>
2020-07-20  9:31   ` Srinivas Kandagatla [this message]

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=c49384c1-2a48-7ae8-67f0-08543c41fc69@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=afaerber@suse.de \
    --cc=cylee12@realtek.com \
    --cc=james.tai@realtek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-realtek-soc@lists.infradead.org \
    --cc=stanley_chang@realtek.com \
    /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).