mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 08:48:48 +00:00
nvmem: mxs-ocotp: remove nvmem regmap dependency
Regmap raw accessors are bus specific implementations, using regmap raw apis in nvmem breaks nvmem providers based on regmap mmio. This patch moves to nvmem support in the driver to use callback instead of regmap, which is what the nvmem core supports now. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ba360fd040
commit
7d8867d71f
@ -25,7 +25,6 @@
|
|||||||
#include <linux/nvmem-provider.h>
|
#include <linux/nvmem-provider.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.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/stmp_device.h>
|
#include <linux/stmp_device.h>
|
||||||
|
|
||||||
@ -66,11 +65,10 @@ static int mxs_ocotp_wait(struct mxs_ocotp *otp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size,
|
static int mxs_ocotp_read(void *context, unsigned int offset,
|
||||||
void *val, size_t val_size)
|
void *val, size_t bytes)
|
||||||
{
|
{
|
||||||
struct mxs_ocotp *otp = context;
|
struct mxs_ocotp *otp = context;
|
||||||
unsigned int offset = *(u32 *)reg;
|
|
||||||
u32 *buf = val;
|
u32 *buf = val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -94,17 +92,16 @@ static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size,
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto close_banks;
|
goto close_banks;
|
||||||
|
|
||||||
while (val_size >= reg_size) {
|
while (bytes) {
|
||||||
if ((offset < OCOTP_DATA_OFFSET) || (offset % 16)) {
|
if ((offset < OCOTP_DATA_OFFSET) || (offset % 16)) {
|
||||||
/* fill up non-data register */
|
/* fill up non-data register */
|
||||||
*buf = 0;
|
*buf++ = 0;
|
||||||
} else {
|
} else {
|
||||||
*buf = readl(otp->base + offset);
|
*buf++ = readl(otp->base + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf++;
|
bytes -= 4;
|
||||||
val_size -= reg_size;
|
offset += 4;
|
||||||
offset += reg_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close_banks:
|
close_banks:
|
||||||
@ -117,57 +114,29 @@ disable_clk:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mxs_ocotp_write(void *context, const void *data, size_t count)
|
|
||||||
{
|
|
||||||
/* We don't want to support writing */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool mxs_ocotp_writeable_reg(struct device *dev, unsigned int reg)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct nvmem_config ocotp_config = {
|
static struct nvmem_config ocotp_config = {
|
||||||
.name = "mxs-ocotp",
|
.name = "mxs-ocotp",
|
||||||
|
.stride = 16,
|
||||||
|
.word_size = 4,
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
.reg_read = mxs_ocotp_read,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct regmap_range imx23_ranges[] = {
|
struct mxs_data {
|
||||||
regmap_reg_range(OCOTP_DATA_OFFSET, 0x210),
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct regmap_access_table imx23_access = {
|
static const struct mxs_data imx23_data = {
|
||||||
.yes_ranges = imx23_ranges,
|
.size = 0x220,
|
||||||
.n_yes_ranges = ARRAY_SIZE(imx23_ranges),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct regmap_range imx28_ranges[] = {
|
static const struct mxs_data imx28_data = {
|
||||||
regmap_reg_range(OCOTP_DATA_OFFSET, 0x290),
|
.size = 0x2a0,
|
||||||
};
|
|
||||||
|
|
||||||
static const struct regmap_access_table imx28_access = {
|
|
||||||
.yes_ranges = imx28_ranges,
|
|
||||||
.n_yes_ranges = ARRAY_SIZE(imx28_ranges),
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct regmap_bus mxs_ocotp_bus = {
|
|
||||||
.read = mxs_ocotp_read,
|
|
||||||
.write = mxs_ocotp_write, /* make regmap_init() happy */
|
|
||||||
.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
|
|
||||||
.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct regmap_config mxs_ocotp_config = {
|
|
||||||
.reg_bits = 32,
|
|
||||||
.val_bits = 32,
|
|
||||||
.reg_stride = 16,
|
|
||||||
.writeable_reg = mxs_ocotp_writeable_reg,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct of_device_id mxs_ocotp_match[] = {
|
static const struct of_device_id mxs_ocotp_match[] = {
|
||||||
{ .compatible = "fsl,imx23-ocotp", .data = &imx23_access },
|
{ .compatible = "fsl,imx23-ocotp", .data = &imx23_data },
|
||||||
{ .compatible = "fsl,imx28-ocotp", .data = &imx28_access },
|
{ .compatible = "fsl,imx28-ocotp", .data = &imx28_data },
|
||||||
{ /* sentinel */},
|
{ /* sentinel */},
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, mxs_ocotp_match);
|
MODULE_DEVICE_TABLE(of, mxs_ocotp_match);
|
||||||
@ -175,11 +144,10 @@ MODULE_DEVICE_TABLE(of, mxs_ocotp_match);
|
|||||||
static int mxs_ocotp_probe(struct platform_device *pdev)
|
static int mxs_ocotp_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
const struct mxs_data *data;
|
||||||
struct mxs_ocotp *otp;
|
struct mxs_ocotp *otp;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
struct regmap *regmap;
|
|
||||||
const struct regmap_access_table *access;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
match = of_match_device(dev->driver->of_match_table, dev);
|
match = of_match_device(dev->driver->of_match_table, dev);
|
||||||
@ -205,17 +173,10 @@ static int mxs_ocotp_probe(struct platform_device *pdev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
access = match->data;
|
data = match->data;
|
||||||
mxs_ocotp_config.rd_table = access;
|
|
||||||
mxs_ocotp_config.max_register = access->yes_ranges[0].range_max;
|
|
||||||
|
|
||||||
regmap = devm_regmap_init(dev, &mxs_ocotp_bus, otp, &mxs_ocotp_config);
|
|
||||||
if (IS_ERR(regmap)) {
|
|
||||||
dev_err(dev, "regmap init failed\n");
|
|
||||||
ret = PTR_ERR(regmap);
|
|
||||||
goto err_clk;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ocotp_config.size = data->size;
|
||||||
|
ocotp_config.priv = otp;
|
||||||
ocotp_config.dev = dev;
|
ocotp_config.dev = dev;
|
||||||
otp->nvmem = nvmem_register(&ocotp_config);
|
otp->nvmem = nvmem_register(&ocotp_config);
|
||||||
if (IS_ERR(otp->nvmem)) {
|
if (IS_ERR(otp->nvmem)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user