Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of version 2 of the gnu general public license as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 64 file(s). Change-Id: Ic7cca08bbba3c38e0d53d3374c43ee8bf1e24172 Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190529141901.894819585@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Naveen <133593113+elohim-etz@users.noreply.github.com>
86 lines
1.8 KiB
C
86 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Amlogic eFuse Driver
|
|
*
|
|
* Copyright (c) 2016 Endless Computers, Inc.
|
|
* Author: Carlo Caione <carlo@endlessm.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/nvmem-provider.h>
|
|
#include <linux/of.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/firmware/meson/meson_sm.h>
|
|
|
|
static int meson_efuse_read(void *context, unsigned int offset,
|
|
void *val, size_t bytes)
|
|
{
|
|
u8 *buf = val;
|
|
int ret;
|
|
|
|
ret = meson_sm_call_read(buf, bytes, SM_EFUSE_READ, offset,
|
|
bytes, 0, 0, 0);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct nvmem_config econfig = {
|
|
.name = "meson-efuse",
|
|
.owner = THIS_MODULE,
|
|
.stride = 1,
|
|
.word_size = 1,
|
|
.read_only = true,
|
|
};
|
|
|
|
static const struct of_device_id meson_efuse_match[] = {
|
|
{ .compatible = "amlogic,meson-gxbb-efuse", },
|
|
{ /* sentinel */ },
|
|
};
|
|
MODULE_DEVICE_TABLE(of, meson_efuse_match);
|
|
|
|
static int meson_efuse_probe(struct platform_device *pdev)
|
|
{
|
|
struct nvmem_device *nvmem;
|
|
unsigned int size;
|
|
|
|
if (meson_sm_call(SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0)
|
|
return -EINVAL;
|
|
|
|
econfig.dev = &pdev->dev;
|
|
econfig.reg_read = meson_efuse_read;
|
|
econfig.size = size;
|
|
|
|
nvmem = nvmem_register(&econfig);
|
|
if (IS_ERR(nvmem))
|
|
return PTR_ERR(nvmem);
|
|
|
|
platform_set_drvdata(pdev, nvmem);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int meson_efuse_remove(struct platform_device *pdev)
|
|
{
|
|
struct nvmem_device *nvmem = platform_get_drvdata(pdev);
|
|
|
|
return nvmem_unregister(nvmem);
|
|
}
|
|
|
|
static struct platform_driver meson_efuse_driver = {
|
|
.probe = meson_efuse_probe,
|
|
.remove = meson_efuse_remove,
|
|
.driver = {
|
|
.name = "meson-efuse",
|
|
.of_match_table = meson_efuse_match,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(meson_efuse_driver);
|
|
|
|
MODULE_AUTHOR("Carlo Caione <carlo@endlessm.com>");
|
|
MODULE_DESCRIPTION("Amlogic Meson NVMEM driver");
|
|
MODULE_LICENSE("GPL v2");
|