[PATCH 09/11] rockchip: efuse: Add support for RK3036

Kever Yang kever.yang at rock-chips.com
Wed Feb 22 09:56:42 CET 2023


On 2023/2/16 07:49, Jonas Karlman wrote:
> Add support for rk3036 compatible.
>
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/misc/rockchip-efuse.c | 39 +++++++++++++++++++++++++++++++++++
>   1 file changed, 39 insertions(+)
>
> diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
> index 897e79bcc60f..177c96983ed8 100644
> --- a/drivers/misc/rockchip-efuse.c
> +++ b/drivers/misc/rockchip-efuse.c
> @@ -18,6 +18,9 @@
>   #include <misc.h>
>   
>   #define EFUSE_CTRL		0x0000
> +#define RK3036_A_SHIFT		8
> +#define RK3036_A_MASK		GENMASK(15, 8)
> +#define RK3036_ADDR(n)		((n) << RK3036_A_SHIFT)
>   #define RK3128_A_SHIFT		7
>   #define RK3128_A_MASK		GENMASK(15, 7)
>   #define RK3128_ADDR(n)		((n) << RK3128_A_SHIFT)
> @@ -86,6 +89,33 @@ U_BOOT_CMD(
>   );
>   #endif
>   
> +static int rockchip_rk3036_efuse_read(struct udevice *dev, int offset,
> +				      void *buf, int size)
> +{
> +	struct rockchip_efuse_plat *efuse = dev_get_plat(dev);
> +	u8 *buffer = buf;
> +
> +	/* Switch to read mode */
> +	writel(EFUSE_LOAD, efuse->base + EFUSE_CTRL);
> +	udelay(2);
> +
> +	while (size--) {
> +		clrsetbits_le32(efuse->base + EFUSE_CTRL, RK3036_A_MASK,
> +				RK3036_ADDR(offset++));
> +		udelay(2);
> +		setbits_le32(efuse->base + EFUSE_CTRL, EFUSE_STROBE);
> +		udelay(2);
> +		*buffer++ = readb(efuse->base + EFUSE_DOUT);
> +		clrbits_le32(efuse->base + EFUSE_CTRL, EFUSE_STROBE);
> +		udelay(2);
> +	}
> +
> +	/* Switch to inactive mode */
> +	writel(0x0, efuse->base + EFUSE_CTRL);
> +
> +	return 0;
> +}
> +
>   static int rockchip_rk3128_efuse_read(struct udevice *dev, int offset,
>   				      void *buf, int size)
>   {
> @@ -241,6 +271,11 @@ static int rockchip_efuse_of_to_plat(struct udevice *dev)
>   	return 0;
>   }
>   
> +static const struct rockchip_efuse_data rk3036_data = {
> +	.read = rockchip_rk3036_efuse_read,
> +	.size = 0x20,
> +};
> +
>   static const struct rockchip_efuse_data rk3128_data = {
>   	.read = rockchip_rk3128_efuse_read,
>   	.size = 0x40,
> @@ -265,6 +300,10 @@ static const struct rockchip_efuse_data rk3399_data = {
>   };
>   
>   static const struct udevice_id rockchip_efuse_ids[] = {
> +	{
> +		.compatible = "rockchip,rk3036-efuse",
> +		.data = (ulong)&rk3036_data,
> +	},
>   	{
>   		.compatible = "rockchip,rk3066a-efuse",
>   		.data = (ulong)&rk3288_data,


More information about the U-Boot mailing list