Re: [PATCH 2/2] nvmem: add Rockchip eFuse support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 14, 2022 at 09:50:46AM +0100, Ahmad Fatoum wrote:
> The driver allows read-only support to e.g. the Hardware UID, which
> could in future be used to derive a MAC like U-Boot does.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
>  drivers/nvmem/Kconfig          |   8 +
>  drivers/nvmem/Makefile         |   1 +
>  drivers/nvmem/rockchip-efuse.c | 299 +++++++++++++++++++++++++++++++++
>  3 files changed, 308 insertions(+)
>  create mode 100644 drivers/nvmem/rockchip-efuse.c
> 
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index 7b1ebe1d689d..ea1156918a34 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -84,4 +84,12 @@ config STARFIVE_OTP
>  	  This adds support for the StarFive OTP controller. Only reading
>  	  is currently supported.
>  
> +config ROCKCHIP_EFUSE
> +	tristate "Rockchip eFuse Support"
> +	depends on ARCH_ROCKCHIP || COMPILE_TEST
> +	depends on OFDEVICE
> +	help
> +	  This is a simple drive to dump specified values of Rockchip SoC
> +	  from eFuse, such as CPU ID.
> +
>  endif
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index 586591961215..2261816c189c 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -25,3 +25,4 @@ obj-$(CONFIG_STM32_BSEC)	+= nvmem_bsec.o
>  nvmem_bsec-y			:= bsec.o
>  
>  obj-$(CONFIG_STARFIVE_OTP)	+= starfive-otp.o
> +obj-$(CONFIG_ROCKCHIP_EFUSE)	+= rockchip-efuse.o
> diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
> new file mode 100644
> index 000000000000..24e7de0aa9ce
> --- /dev/null
> +++ b/drivers/nvmem/rockchip-efuse.c
> @@ -0,0 +1,299 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Rockchip eFuse Driver
> + *
> + * Copyright (c) 2015 Rockchip Electronics Co. Ltd.
> + * Author: Caesar Wang <wxt@xxxxxxxxxxxxxx>
> + */
> +
> +#include <common.h>
> +#include <linux/clk.h>
> +#include <linux/overflow.h>
> +#include <clock.h>
> +#include <driver.h>
> +#include <io.h>
> +#include <linux/nvmem-provider.h>
> +#include <of.h>
> +#include <init.h>
> +
> +#define clk_prepare_enable clk_enable
> +#define clk_disable_unprepare clk_disable

Please use the functions directly.

> +static int rockchip_efuse_probe(struct device_d *dev)
> +{
> +	struct resource *res;
> +	struct nvmem_device *nvmem;
> +	struct rockchip_efuse_chip *efuse;
> +	const void *data;
> +
> +	data = device_get_match_data(dev);
> +	if (!data) {
> +		dev_err(dev, "failed to get match data\n");
> +		return -EINVAL;
> +	}
> +
> +	efuse = kzalloc(sizeof(struct rockchip_efuse_chip), GFP_KERNEL);
> +	if (!efuse)
> +		return -ENOMEM;
> +
> +	res = dev_request_mem_resource(dev, 0);
> +	if (IS_ERR(res))
> +		return PTR_ERR(res);
> +
> +	efuse->base = IOMEM(res->start);
> +
> +	efuse->clk = clk_get(dev, "pclk_efuse");
> +	if (IS_ERR(efuse->clk))
> +		return PTR_ERR(efuse->clk);
> +
> +	efuse->dev = dev;
> +	if (of_property_read_u32(dev->device_node, "rockchip,efuse-size",
> +				 &econfig.size))
> +		econfig.size = resource_size(res);

resource_size(res) is the size of the register space which has nothing
to do with the size of the provided nvmem space.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux