misc: otp: realize otp interface layer function
Realize otp read & write functions for application layer calling. Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com> Change-Id: Ic8f698b36fce4c1c6cd7a2848afd370567b43448
This commit is contained in:
parent
f9519410b1
commit
6a8fa29e04
|
|
@ -56,4 +56,4 @@ obj-$(CONFIG_ROCKCHIP_OTP) += rockchip-otp.o
|
|||
obj-$(CONFIG_$(SPL_TPL_)ROCKCHIP_SECURE_OTP) += rockchip-secure-otp.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)ROCKCHIP_SECURE_OTP_V2) += rockchip-secure-otp-v2.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)ROCKCHIP_HW_DECOMPRESS) += rockchip_decompress.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)ROCKCHIP_HW_DECOMPRESS) += misc_decompress.o
|
||||
obj-$(CONFIG_$(SPL_TPL_)MISC) += misc_decompress.o misc_otp.o
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2020 Rockchip Electronics Co., Ltd
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <dm/uclass.h>
|
||||
#include <misc.h>
|
||||
|
||||
struct udevice *misc_otp_get_device(u32 capability)
|
||||
{
|
||||
const struct misc_ops *ops;
|
||||
struct udevice *dev;
|
||||
struct uclass *uc;
|
||||
int ret;
|
||||
u32 cap;
|
||||
|
||||
ret = uclass_get(UCLASS_MISC, &uc);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
for (uclass_first_device(UCLASS_MISC, &dev);
|
||||
dev;
|
||||
uclass_next_device(&dev)) {
|
||||
ops = device_get_ops(dev);
|
||||
if (!ops || !ops->ioctl)
|
||||
continue;
|
||||
|
||||
cap = ops->ioctl(dev, IOCTL_REQ_CAPABILITY, NULL);
|
||||
if ((cap & capability) == capability)
|
||||
return dev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int misc_otp_read(struct udevice *dev, int offset, void *buf, int size)
|
||||
{
|
||||
return misc_read(dev, offset, buf, size);
|
||||
}
|
||||
|
||||
int misc_otp_write(struct udevice *dev, int offset, const void *buf, int size)
|
||||
{
|
||||
return misc_write(dev, offset, (void *)buf, size);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2020 Rockchip Electronics Co., Ltd
|
||||
*/
|
||||
|
||||
#ifndef __MISC_OTP_H__
|
||||
#define __MISC_OTP_H__
|
||||
|
||||
struct udevice *misc_otp_get_device(u32 capability);
|
||||
int misc_otp_read(struct udevice *dev, int offset, void *buf, int size);
|
||||
int misc_otp_write(struct udevice *dev, int offset, const void *buf, int size);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue