27 Nov, 2020
3 commits
-
When offset is not 4 bytes aligned, directly shift righty by 2 bits
will cause reading out wrong data. Since imx ocotp only supports
4 bytes reading once, we need handle offset is not 4 bytes aligned
and enlarge the bytes to 4 bytes aligned. After reading finished,
copy the needed data from buffer to caller and free buffer.Signed-off-by: Peng Fan
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20201127102837.19366-6-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Some fuse ranges are protected by the XPU such that the AP cannot
access them. Attempting to do so causes an SError. Use the newly
introduced per-soc compatible string, and the newly introduced
nvmem keepout support to attach the set of regions
we should not access.Reviewed-by: Douglas Anderson
Signed-off-by: Evan Green
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20201127102837.19366-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Introduce support into the nvmem core for arrays of register ranges
that should not result in actual device access. For these regions a
constant byte (repeated) is returned instead on read, and writes are
quietly ignored and returned as successful.This is useful for instance if certain efuse regions are protected
from access by Linux because they contain secret info to another part
of the system (like an integrated modem).Signed-off-by: Evan Green
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20201127102837.19366-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
27 Sep, 2020
1 commit
-
Fix missing 'kfree_const(cell->name)' when call to
nvmem_cell_info_to_nvmem_cell() in several places:* after nvmem_cell_info_to_nvmem_cell() failed during
nvmem_add_cells()* during nvmem_device_cell_{read,write} when cell->name is
kstrdup'ed() without calling kfree_const() at the end, but
really there is no reason to do that 'dup, because the cell
instance is allocated on the stack for some short period to be
read/write without exposing it to the caller.So the new nvmem_cell_info_to_nvmem_cell_nodup() helper is introduced
which is used to convert cell_info -> cell without name duplication as
a lighweight version of nvmem_cell_info_to_nvmem_cell().Fixes: e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.")
Reviewed-by: Srinivas Kandagatla
Acked-by: Srinivas Kandagatla
Signed-off-by: Vadym Kochan
Link: https://lore.kernel.org/r/20200923204456.14032-1-vadym.kochan@plvision.eu
Signed-off-by: Greg Kroah-Hartman
18 Sep, 2020
4 commits
-
of_parse_phandle() returns device_node with incremented ref count
which needs to be decremented by of_node_put() when device_node
is not used.Fixes: e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.")
Signed-off-by: Vadym Kochan
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200917134437.16637-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
We don't need to specify any ranges when allocating IDs so we can switch
to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.ida_simple_get(ida, 0, 0, gfp) is equivalent to
ida_alloc_range(ida, 0, UINT_MAX, gfp) which is equivalent to
ida_alloc(ida, gfp). Note: IDR will never actually allocate an ID
larger than INT_MAX.Signed-off-by: Bartosz Golaszewski
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200917134437.16637-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Use kobj_to_dev() instead of container_of()
Signed-off-by: Tian Tao
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200917134437.16637-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
This patch is to remove function "mtk_reg_write" since
Mediatek EFUSE hardware only supports read functionality
for NVMEM consumers.Fixes: ba360fd040e3 ("nvmem: mtk-efuse: remove nvmem regmap dependency")
Acked-by: Andrew-CT Chen
Signed-off-by: Chih-En Hsu
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200917134437.16637-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
29 Jul, 2020
10 commits
-
Using pdev->id as the nvmem's config ID (which, by default, is
NVMEM_DEVID_NONE) prevents multiple instances of this driver from
probing because of the following error:sysfs: cannot create duplicate filename '/bus/nvmem/devices/spmi_sdam'
Use NVMEM_DEVID_AUTO as the NVMEM config ID to fix the issue.
Signed-off-by: Guru Das Srinagesh
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-15-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
nvmem can't be built as module anymore, update its Kconfig description.
Fixes: 2a37ce25d9f2 ("nvmem: disallow modular CONFIG_NVMEM")
Signed-off-by: Matteo Croce
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-13-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
This patch adds support for blowing fuses to the qfprom driver if the
required properties are defined in the device tree.[Srini: Fixed merge conflict with AUTO ID]
Signed-off-by: Ravi Kumar Bokka
Signed-off-by: Douglas Anderson
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-12-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
There could be multiple qfprom devices on some SoCs. For example, on
MSM8939, qfprom@58000 holds efuse bits for Core Power Reduction (CPR),
and qfprom@5c000 holds bits for TSENS. Registering multiple nvmem
devices with the same id results in the following failure on the second
device.[ 1.682731] sysfs: cannot create duplicate filename /bus/nvmem/devices/qfprom0
[ 1.685889] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.107-00567-g11c887ce2838-dirty #334
[ 1.693191] Hardware name: Square, Inc. T2 Devkit (DT)
[ 1.701610] Call trace:
[ 1.706673] dump_backtrace+0x0/0x158
[ 1.708987] show_stack+0x14/0x20
[ 1.712810] dump_stack+0x98/0xbc
[ 1.716114] sysfs_warn_dup+0x60/0x78
[ 1.719401] sysfs_do_create_link_sd.isra.0+0xdc/0xe8
[ 1.723047] sysfs_create_link+0x20/0x40
[ 1.728088] bus_add_device+0x68/0x130
[ 1.732083] device_add+0x3f8/0x628
[ 1.735639] nvmem_register.part.4+0x150/0x348
[ 1.739018] devm_nvmem_register+0x4c/0xa8
[ 1.743532] qfprom_probe+0x94/0xb8
[ 1.747615] platform_drv_probe+0x50/0xa0
[ 1.750998] really_probe+0x1b8/0x298
[ 1.755164] driver_probe_device+0x58/0x100
[ 1.758810] __driver_attach+0xe0/0xe8
[ 1.762802] bus_for_each_dev+0x74/0xc8
[ 1.766622] driver_attach+0x20/0x28
[ 1.770354] bus_add_driver+0x1ac/0x218
[ 1.774175] driver_register+0x60/0x110
[ 1.777734] __platform_driver_register+0x40/0x48
[ 1.781570] qfprom_driver_init+0x18/0x20
[ 1.786416] do_one_initcall+0x5c/0x178
[ 1.790418] kernel_init_freeable+0x198/0x244
[ 1.794062] kernel_init+0x10/0x108
[ 1.798567] ret_from_fork+0x10/0x18
[ 1.802084] qcom,qfprom: probe of 5c000.qfprom failed with error -17Fix this issue by using NVMEM_DEVID_AUTO.
Reported-by: Shawn Guo
Signed-off-by: Srinivas Kandagatla
Tested-by: Shawn Guo
Link: https://lore.kernel.org/r/20200722100705.7772-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
For nvmem providers which have multiple instances, it is required
to suffix the provider name with proper id, so that they do not
confict for the same name. Currently the core does not handle
this case properly eventhough core already has logic to generate the id.This patch add new devid type NVMEM_DEVID_AUTO for providers to be
able to allow core to assign id and append it to provier name.Reported-by: Shawn Guo
Signed-off-by: Srinivas Kandagatla
Tested-by: Shawn Guo
Link: https://lore.kernel.org/r/20200722100705.7772-8-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Complement the u16, u32 and u64 helpers with a u8 variant to ease
accessing byte-sized values.This helper will be useful for Realtek Digital Home Center platforms,
which store some byte and sub-byte sized values in non-volatile memory.Signed-off-by: Andreas Färber
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-7-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
It's "an unsigned" but "a U".
Similarly, "an entry" but "a binary entry".While at it, also drop superfluous articles for negative and zero.
Signed-off-by: Andreas Färber
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-6-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Add support to the new efuse IP which is integrated in the SC2730
which includes multiple blocks in a single chip.Signed-off-by: Freeman Liu
Signed-off-by: Chunyan Zhang
Reviewed-by: Baolin Wang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
The 'struct nvmem_config' has a stride attribute that specifies the
needed alignment for accesses into the nvmem. This is used in
nvmem_cell_info_to_nvmem_cell() but not in the sysfs read/write
functions. If the alignment is important in one place it's important
everywhere, so let's add enforcement.For now we'll consider it totally invalid to access with the wrong
alignment. We could relax this in the read case where we could just
read some extra bytes and throw them away. Relaxing it in the write
case seems harder (and less safe?) since we'd have to read some data
first and then write it back. To keep it symmetric we'll just
disallow it in both cases.Reported-by: Ravi Kumar Bokka
Signed-off-by: Douglas Anderson
Reviewed-by: Ravi Kumar Bokka
Tested-by: Ravi Kumar Bokka
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
When call function devm_platform_ioremap_resource(), we should use IS_ERR()
to check the return value and return PTR_ERR() if failed.Fixes: 096030e7f449 ("nvmem: sprd: Add Spreadtrum SoCs eFuse support")
Signed-off-by: Tiezhu Yang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200722100705.7772-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
27 May, 2020
1 commit
-
qfprom has different address spaces for read and write. Reads are
always done from corrected address space, where as writes are done
on raw address space.
Writing to corrected address space is invalid and ignored, so it
does not make sense to have this support in the driver which only
supports corrected address space regions at the moment.Fixes: 4ab11996b489 ("nvmem: qfprom: Add Qualcomm QFPROM support.")
Signed-off-by: Srinivas Kandagatla
Reviewed-by: Douglas Anderson
Cc: stable
Link: https://lore.kernel.org/r/20200522113341.7728-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
15 May, 2020
3 commits
-
Fixes coccicheck warning:
drivers/nvmem/jz4780-efuse.c:214:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Reported-by: Hulk Robot
Signed-off-by: Samuel Zou
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200511145042.31223-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Commit 2a127da461a9 ("nvmem: add support for the write-protect pin")
added support for handling write-protect pins to the nvmem core, and
Commit 1c89074bf850 ("eeprom: at24: remove the write-protect pin support")
retrofitted the at24 driver to use this support.These changes broke write() on the nvmem sysfs attribute for eeproms
which utilize a write-protect pin, as the write callback invokes the
nvmem device's reg_write callback directly which no longer handles
changing the state of the write-protect pin.Change the read and write callbacks for the sysfs attribute to invoke
nvmme_reg_read/nvmem_reg_write helpers which handle this, rather than
calling reg_read/reg_write directly.Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Signed-off-by: Michael Auchter
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200511145042.31223-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Several logic improvements to save many code lines:
- no need to use goto;
- no need to assign return value;
- combine different conditions of return value into one line.Signed-off-by: Anson Huang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200511145042.31223-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
28 Apr, 2020
2 commits
-
Use direct function call instead of eemi ops for get_chipid.
Signed-off-by: Rajan Vaja
Signed-off-by: Jolly Shah
Link: https://lore.kernel.org/r/1587761887-4279-3-git-send-email-jolly.shah@xilinx.com
Signed-off-by: Greg Kroah-Hartman -
file permission are derived based on various configs for
default nvmem sysfs file, reuse it to create the eeprom
compat file too.Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200417121306.23121-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
26 Mar, 2020
3 commits
-
Now that we are using is_bin_visible callback, we do not need
nvmem_sysfs_get_groups() anymore so move all the relevant data-structures
and code to core.cSigned-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200325131951.31887-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
By using is_bin_visible callback to set permissions will remove a
large list of attribute groups. These group permissions can be
dynamically derived in the callback.Also add checks for read/write callbacks and set permissions accordingly.
Suggested-by: Greg KH
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200325131951.31887-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
use device_register/unregister instead of spliting them with no use.
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200324171600.15606-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
25 Mar, 2020
1 commit
-
As we are planning to move to use sysfs is_bin_visible callback,
having root_only as part of nvmem_device will help decide correct
permissions.Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200325122116.15096-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
24 Mar, 2020
4 commits
-
Use devm_add_action_or_reset() for cleanup to call clk_unprepare(),
which can simplify the error handling in .probe, and .remove callback
can be dropped.Signed-off-by: Anson Huang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200323150007.7487-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
We've saved the double data flag in the device data, so we should
use it when programming a block.Signed-off-by: Baolin Wang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200323150007.7487-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
We have some cases that will programme the eFuse block partially multiple
times, so we should allow the block to be programmed again if it was
programmed partially. But we should lock the block if the whole block
was programmed. Thus add a condition to validate if we need lock the
block or not.Moreover we only enable the auto-check function when locking the block.
Signed-off-by: Freeman Liu
Signed-off-by: Baolin Wang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200323150007.7487-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
According to the Spreadtrum eFuse specification, we should write 0 to
the block to trigger the lock operation.Fixes: 096030e7f449 ("nvmem: sprd: Add Spreadtrum SoCs eFuse support")
Cc: stable
Signed-off-by: Freeman Liu
Signed-off-by: Baolin Wang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200323150007.7487-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman
19 Mar, 2020
8 commits
-
kbuild-robot did find a type error in the min(a, b)
function used by this driver if built for x86_64 or riscv.Althought it is very unlikely that this driver is built
for those platforms it could be used as a template
for something else and therefore should be correct.The problem is that we implicitly cast a size_t to
unsigned int inside the implementation of the min() function.Since size_t may differ on different compilers and
plaforms there may be warnings or not.So let's use only size_t variables on all platforms.
Reported-by: kbuild test robot
Reported-by: Stephen Rothwell
Cc: srinivas.kandagatla@linaro.org
Cc: prasannatsmkumar@gmail.com
Cc: malat@debian.org
Cc: paul@crapouillou.net
Signed-off-by: H. Nikolaus Schaller
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-15-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
This patch brings support for the JZ4780 efuse. Currently it only exposes
a read only access to the entire 8K bits efuse memory and nvmem cells.To fetch for example the MAC address:
dd if=/sys/devices/platform/134100d0.efuse/jz4780-efuse0/nvmem bs=1 skip=34 count=6 status=none | xxd
Tested-by: Mathieu Malaterre
Signed-off-by: PrasannaKumar Muralidharan
Signed-off-by: Mathieu Malaterre
Signed-off-by: H. Nikolaus Schaller
Signed-off-by: Paul Cercueil
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-13-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Drop unnecessary initialization of variable 'clk_rate' and 'timing'.
Signed-off-by: Anson Huang
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-11-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Return -EPERM if reg_read is NULL in bin_attr_nvmem_read() or if
reg_write is NULL in bin_attr_nvmem_write().This prevents NULL dereferences such as the one described in
03cd45d2e219 ("thunderbolt: Prevent crash if non-active NVMem file is
read")Signed-off-by: Nicholas Johnson
Cc: stable
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-10-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
nvmem provider has to provide either reg_read/write, add a check
to enforce this.Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Put the write-protect GPIO descriptor in nvmem_release() so that it can
be automatically released when the associated device's reference count
drops to 0.Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Reported-by: Geert Uytterhoeven
Signed-off-by: Khouloud Touil
Cc: stable
[Bartosz: tweak the commit message]
Signed-off-by: Bartosz Golaszewski
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-8-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
We need to free the ida mapping and nvmem struct if the write-protect
GPIO lookup fails.Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Signed-off-by: Bartosz Golaszewski
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-7-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman -
Visibly separate the GPIO request from the previous operation in the
code with a newline.Signed-off-by: Bartosz Golaszewski
Signed-off-by: Srinivas Kandagatla
Link: https://lore.kernel.org/r/20200310132257.23358-6-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman