Guru Das Srinagesh
8f042191d4
nvmem: qcom-spmi-sdam: Enable multiple devices
...
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 <gurus@codeaurora.org >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-15-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:09 +02:00
Matteo Croce
b7194ba1e1
nvmem: update Kconfig description
...
nvmem can't be built as module anymore, update its Kconfig description.
Fixes: 2a37ce25d9 ("nvmem: disallow modular CONFIG_NVMEM")
Signed-off-by: Matteo Croce <mcroce@microsoft.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-13-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:09 +02:00
Ravi Kumar Bokka
93b4e49f8c
nvmem: qfprom: Add fuse blowing support
...
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 <rbokka@codeaurora.org >
Signed-off-by: Douglas Anderson <dianders@chromium.org >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-12-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:09 +02:00
Srinivas Kandagatla
3f07c65833
nvmem: qfprom: use NVMEM_DEVID_AUTO for multiple instances
...
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 -17
Fix this issue by using NVMEM_DEVID_AUTO.
Reported-by: Shawn Guo <shawn.guo@linaro.org >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Tested-by: Shawn Guo <shawn.guo@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Srinivas Kandagatla
731aa3fae8
nvmem: core: add support to auto devid
...
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 <shawn.guo@linaro.org >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Tested-by: Shawn Guo <shawn.guo@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-8-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Andreas Färber
5037d368b2
nvmem: core: Add nvmem_cell_read_u8()
...
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 <afaerber@suse.de >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-7-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Andreas Färber
3a7580710b
nvmem: core: Grammar fixes for help text
...
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 <afaerber@suse.de >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-6-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Freeman Liu
2eef018efb
nvmem: sc27xx: add sc2730 efuse support
...
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 <freeman.liu@unisoc.com >
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com >
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Douglas Anderson
8356671574
nvmem: Enforce nvmem stride in the sysfs interface
...
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 <rbokka@codeaurora.org >
Signed-off-by: Douglas Anderson <dianders@chromium.org >
Reviewed-by: Ravi Kumar Bokka <rbokka@codeaurora.org >
Tested-by: Ravi Kumar Bokka <rbokka@codeaurora.org >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Tiezhu Yang
bcd14bb7a6
nvmem: sprd: Fix return value of sprd_efuse_probe()
...
When call function devm_platform_ioremap_resource(), we should use IS_ERR()
to check the return value and return PTR_ERR() if failed.
Fixes: 096030e7f4 ("nvmem: sprd: Add Spreadtrum SoCs eFuse support")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200722100705.7772-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-29 17:12:08 +02:00
Srinivas Kandagatla
8d9eb0d6d5
nvmem: qfprom: remove incorrect write support
...
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: 4ab11996b4 ("nvmem: qfprom: Add Qualcomm QFPROM support.")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Reviewed-by: Douglas Anderson <dianders@chromium.org >
Cc: stable <stable@vger.kernel.org >
Link: https://lore.kernel.org/r/20200522113341.7728-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-05-27 11:09:26 +02:00
Samuel Zou
e270df39f7
nvmem: jz4780-efuse: Use PTR_ERR_OR_ZERO() to simplify code
...
Fixes coccicheck warning:
drivers/nvmem/jz4780-efuse.c:214:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Reported-by: Hulk Robot <hulkci@huawei.com >
Signed-off-by: Samuel Zou <zou_wei@huawei.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200511145042.31223-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-05-15 16:20:02 +02:00
Michael Auchter
b96fc5416b
nvmem: ensure sysfs writes handle write-protect pin
...
Commit 2a127da461 ("nvmem: add support for the write-protect pin")
added support for handling write-protect pins to the nvmem core, and
Commit 1c89074bf8 ("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: 2a127da461 ("nvmem: add support for the write-protect pin")
Signed-off-by: Michael Auchter <michael.auchter@ni.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200511145042.31223-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-05-15 16:20:02 +02:00
Anson Huang
0e2abffdf9
nvmem: imx-ocotp: Improve logic to save many code lines
...
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 <Anson.Huang@nxp.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200511145042.31223-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-05-15 16:20:02 +02:00
Rajan Vaja
21cd93bab9
firmware: xilinx: Remove eemi ops for get_chipid
...
Use direct function call instead of eemi ops for get_chipid.
Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com >
Signed-off-by: Jolly Shah <jolly.shah@xilinx.com >
Link: https://lore.kernel.org/r/1587761887-4279-3-git-send-email-jolly.shah@xilinx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-04-28 15:45:06 +02:00
Srinivas Kandagatla
2a4542e55f
nvmem: core: cleanup old eeprom compat entry attributes
...
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 <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200417121306.23121-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-04-28 15:02:48 +02:00
Srinivas Kandagatla
8440030527
nvmem: core: remove nvmem_sysfs_get_groups()
...
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.c
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200325131951.31887-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-25 19:23:49 +01:00
Srinivas Kandagatla
664f054938
nvmem: core: use is_bin_visible for permissions
...
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 <gregkh@linuxfoundation.org >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200325131951.31887-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-25 19:23:48 +01:00
Srinivas Kandagatla
f60442ddc4
nvmem: core: use device_register and device_unregister
...
use device_register/unregister instead of spliting them with no use.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200324171600.15606-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-25 18:56:38 +01:00
Srinivas Kandagatla
e6de179d7a
nvmem: core: add root_only member to nvmem device struct
...
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 <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200325122116.15096-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-25 13:45:09 +01:00
Anson Huang
bbde5709ee
nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup
...
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 <Anson.Huang@nxp.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200323150007.7487-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-23 20:05:23 +01:00
Baolin Wang
4bd5a15d93
nvmem: sprd: Determine double data programming from device data
...
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 <baolin.wang7@gmail.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200323150007.7487-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-23 20:05:23 +01:00
Freeman Liu
5af25388ba
nvmem: sprd: Optimize the block lock operation
...
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 <freeman.liu@unisoc.com >
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200323150007.7487-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-23 20:05:23 +01:00
Freeman Liu
c66ebde4d9
nvmem: sprd: Fix the block lock operation
...
According to the Spreadtrum eFuse specification, we should write 0 to
the block to trigger the lock operation.
Fixes: 096030e7f4 ("nvmem: sprd: Add Spreadtrum SoCs eFuse support")
Cc: stable <stable@vger.kernel.org >
Signed-off-by: Freeman Liu <freeman.liu@unisoc.com >
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200323150007.7487-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-23 20:05:23 +01:00
H. Nikolaus Schaller
ba2bb5f789
nvmem: jz4780-efuse: fix build warnings on ARCH=x86_64 or riscv
...
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 <lkp@intel.com >
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au >
Cc: srinivas.kandagatla@linaro.org
Cc: prasannatsmkumar@gmail.com
Cc: malat@debian.org
Cc: paul@crapouillou.net
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com >
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org >
Link: https://lore.kernel.org/r/20200310132257.23358-15-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-03-19 07:41:03 +01:00