mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-11 16:29:05 +00:00
nvmem: sunxi-sid: remove nvmem regmap dependency
This patch moves to nvmem support in the driver to use callback instead of regmap. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2c0235c604
commit
9c7b16eb35
@ -83,7 +83,6 @@ config ROCKCHIP_EFUSE
|
|||||||
config NVMEM_SUNXI_SID
|
config NVMEM_SUNXI_SID
|
||||||
tristate "Allwinner SoCs SID support"
|
tristate "Allwinner SoCs SID support"
|
||||||
depends on ARCH_SUNXI
|
depends on ARCH_SUNXI
|
||||||
select REGMAP_MMIO
|
|
||||||
help
|
help
|
||||||
This is a driver for the 'security ID' available on various Allwinner
|
This is a driver for the 'security ID' available on various Allwinner
|
||||||
devices.
|
devices.
|
||||||
|
@ -21,13 +21,14 @@
|
|||||||
#include <linux/nvmem-provider.h>
|
#include <linux/nvmem-provider.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
|
|
||||||
static struct nvmem_config econfig = {
|
static struct nvmem_config econfig = {
|
||||||
.name = "sunxi-sid",
|
.name = "sunxi-sid",
|
||||||
.read_only = true,
|
.read_only = true,
|
||||||
|
.stride = 4,
|
||||||
|
.word_size = 1,
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,54 +52,23 @@ static u8 sunxi_sid_read_byte(const struct sunxi_sid *sid,
|
|||||||
return sid_key; /* Only return the last byte */
|
return sid_key; /* Only return the last byte */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sunxi_sid_read(void *context,
|
static int sunxi_sid_read(void *context, unsigned int offset,
|
||||||
const void *reg, size_t reg_size,
|
void *val, size_t bytes)
|
||||||
void *val, size_t val_size)
|
|
||||||
{
|
{
|
||||||
struct sunxi_sid *sid = context;
|
struct sunxi_sid *sid = context;
|
||||||
unsigned int offset = *(u32 *)reg;
|
|
||||||
u8 *buf = val;
|
u8 *buf = val;
|
||||||
|
|
||||||
while (val_size) {
|
while (bytes--)
|
||||||
*buf++ = sunxi_sid_read_byte(sid, offset);
|
*buf++ = sunxi_sid_read_byte(sid, offset++);
|
||||||
val_size--;
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sunxi_sid_write(void *context, const void *data, size_t count)
|
|
||||||
{
|
|
||||||
/* Unimplemented, dummy to keep regmap core happy */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct regmap_bus sunxi_sid_bus = {
|
|
||||||
.read = sunxi_sid_read,
|
|
||||||
.write = sunxi_sid_write,
|
|
||||||
.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
|
|
||||||
.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool sunxi_sid_writeable_reg(struct device *dev, unsigned int reg)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct regmap_config sunxi_sid_regmap_config = {
|
|
||||||
.reg_bits = 32,
|
|
||||||
.val_bits = 8,
|
|
||||||
.reg_stride = 1,
|
|
||||||
.writeable_reg = sunxi_sid_writeable_reg,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int sunxi_sid_probe(struct platform_device *pdev)
|
static int sunxi_sid_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct nvmem_device *nvmem;
|
struct nvmem_device *nvmem;
|
||||||
struct regmap *regmap;
|
|
||||||
struct sunxi_sid *sid;
|
struct sunxi_sid *sid;
|
||||||
int ret, i, size;
|
int ret, i, size;
|
||||||
char *randomness;
|
char *randomness;
|
||||||
@ -113,16 +83,10 @@ static int sunxi_sid_probe(struct platform_device *pdev)
|
|||||||
return PTR_ERR(sid->base);
|
return PTR_ERR(sid->base);
|
||||||
|
|
||||||
size = resource_size(res) - 1;
|
size = resource_size(res) - 1;
|
||||||
sunxi_sid_regmap_config.max_register = size;
|
econfig.size = resource_size(res);
|
||||||
|
|
||||||
regmap = devm_regmap_init(dev, &sunxi_sid_bus, sid,
|
|
||||||
&sunxi_sid_regmap_config);
|
|
||||||
if (IS_ERR(regmap)) {
|
|
||||||
dev_err(dev, "regmap init failed\n");
|
|
||||||
return PTR_ERR(regmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
econfig.dev = dev;
|
econfig.dev = dev;
|
||||||
|
econfig.reg_read = sunxi_sid_read;
|
||||||
|
econfig.priv = sid;
|
||||||
nvmem = nvmem_register(&econfig);
|
nvmem = nvmem_register(&econfig);
|
||||||
if (IS_ERR(nvmem))
|
if (IS_ERR(nvmem))
|
||||||
return PTR_ERR(nvmem);
|
return PTR_ERR(nvmem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user