18 Dec, 2020

1 commit


14 Dec, 2020

2 commits

  • There might be chance that after we calculate timing based on the ipg_clk,
    but ipg_clk was changed by busfreq which cause fuse prog and shadow
    reload not work stable. So let request high bus to let the ipg clk fixed
    during the stage programming and reloading.

    Reviewed-by: Jacky Bai
    Signed-off-by: Peng Fan

    Peng Fan
     
  • 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 finished reading,
    copy the needed data from buffer to caller and free buffer.

    Signed-off-by: Peng Fan
    Signed-off-by: Fugang Duan

    Peng Fan
     

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

    Vadym Kochan
     

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

    Vadym Kochan
     
  • 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

    Bartosz Golaszewski
     
  • 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

    Tian Tao
     
  • 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

    Chih-En Hsu
     

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

    Guru Das Srinagesh
     
  • 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

    Matteo Croce
     
  • 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

    Ravi Kumar Bokka
     
  • 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
    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

    Srinivas Kandagatla
     
  • 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

    Srinivas Kandagatla
     
  • 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

    Andreas Färber
     
  • 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

    Andreas Färber
     
  • 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

    Freeman Liu
     
  • 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

    Douglas Anderson
     
  • 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

    Tiezhu Yang
     

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

    Srinivas Kandagatla
     

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

    Samuel Zou
     
  • 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

    Michael Auchter
     
  • 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

    Anson Huang
     

28 Apr, 2020

2 commits


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.c

    Signed-off-by: Srinivas Kandagatla
    Link: https://lore.kernel.org/r/20200325131951.31887-3-srinivas.kandagatla@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Srinivas Kandagatla
     
  • 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

    Srinivas Kandagatla
     
  • 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

    Srinivas Kandagatla
     

25 Mar, 2020

1 commit


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

    Anson Huang
     
  • 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

    Baolin Wang
     
  • 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

    Freeman Liu
     
  • 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

    Freeman Liu
     

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

    H. Nikolaus Schaller
     
  • 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

    PrasannaKumar Muralidharan
     
  • 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

    Anson Huang
     
  • 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

    Nicholas Johnson
     
  • 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

    Srinivas Kandagatla
     
  • 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

    Khouloud Touil
     
  • 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

    Bartosz Golaszewski
     
  • 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

    Bartosz Golaszewski