summaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/imx'Sascha Hauer2024-03-152-1/+41
|\
| * nvmem: imx-ocotp-ele: implement permanent write supportSascha Hauer2024-03-131-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | This implements write support to imx-ocotp-ele. By default only the shadow values are written which is harmless and nearly useless (as the ROM doesn't seem use these values). Real write support is enabled by setting imx_ocotp0.permanent_write_enable to true. A big warning is printed and the next write access to /dev/imx_ocotp will then really burn fuses. Link: https://lore.barebox.org/20240311102152.360762-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: add nvmem_device_get_device()Sascha Hauer2024-03-131-0/+6
| | | | | | | | | | | | | | | | | | We'll want to add a device parameter to the imx_ocotp0 device in the next step, but the device is private to the nvmem core. Add a getter function for it. Link: https://lore.barebox.org/20240311102152.360762-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/arm-efi-prepare'Sascha Hauer2024-03-151-1/+1
|\ \ | |/ |/|
| * cdev: implement setter/getter for cdev device nodeAhmad Fatoum2024-03-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | A cdev has two device tree node pointers, one directly at struct cdev.device_node and another indirectly via cdev.dev->device_node. We may want to remove cdev::device_node in future, but till then to avoid users having to guess, which device_node is the correct one, add a helper to set and get the device tree node. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-19-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: imx-ocotp-ele: fix fuse types on i.MX93Sascha Hauer2024-03-131-2/+1
|/ | | | | | | | | | Sync the imx93_entries[] with the current kernel as of Linux-6.8. The first 52 fuse words can be read from shadow registers. I don't know anymore where I copied the wrong values from, the Kernel had correct values from the start. Link: https://lore.barebox.org/20240313090335.975366-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: ocotp: mark data as constMarc Kleine-Budde2024-02-131-12/+12
| | | | | | | | Mark values obtained from "priv->data->ctrl" as const. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Link: https://lore.barebox.org/20240212132901.1641599-4-mkl@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: ocotp: use tab for indention onlyMarc Kleine-Budde2024-02-131-27/+29
| | | | | | | | | Replace space+tabs by tabs only for indention. Fixes: 1c2d1d4e5985 ("ARM: i.MX8MP: enhance support for ocotp driver") Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Link: https://lore.barebox.org/20240212132901.1641599-3-mkl@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: imx-ocotp-ele: provide machine_idSascha Hauer2024-02-081-1/+21
| | | | | | | | The i.MX93 fusemap has a unique machine id. Use that for providing a machine_id. Link: https://lore.barebox.org/20240205135642.2906131-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx'Sascha Hauer2024-01-231-51/+119
|\
| * soc: imx: featctrl: finalize support for i.MX8MPAhmad Fatoum2024-01-221-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We only had preliminary feature controller support for i.MX8MP and support for detecting missing VPU, DSP, NPU, LVDS and CPUs was missing. Add support for them, so barebox may fix up the kernel device tree to disable these nodes. This is especially important for the VPU and NPU as the kernel's blk-ctrl power domain driver may try to power them down as they are unused, which would make the SoC hang. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119224522.1399213-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: ocotp: prepare adding tester3 supportAhmad Fatoum2024-01-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | The tester fuses are written to the OCOTP by NXP during production. So far, we only evaluated tester4 to determine which peripherals are missing from the SoC. On the i.MX8MP, VPU and CPUs existence is instead encoded into the tester3 fuse word. In preparation for adding support for tester4, rename the existing masks to be tester4-specific. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119224522.1399213-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: i.MX8MP: enhance support for ocotp driverStefan Kerkmann2024-01-191-42/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The OTP memory address space found in the i.MX8MP extends to 0x17F[1] instead of the usual 0xFF[2]. Hence, the ADDR field in the HW_OCOTP_CTRL register was extended to hold 9 bits, shifting all subsequent fields up by one bit. As the access patterns are otherwise identical we inject the correct bitmaps for the CTRL register access via the newly introduced `ocotp_ctrl_reg` and keep the driver generic. One additional bug were missing `set_timing`, `efuse_blow` and `efuse_read` function pointers - resulting in a null reference exception when programming the fuses e.g. burning the SRK hashes for HAB boot. As the peripheral is identical to the other SOCs found in the i.MX family the standard implementation was simply added. [1]: see Figure 6-25 OTP Memory Footprint, i.MX8MP RM Rev. 1 [2]: see Figure 6-28 OTP Memory Footprint, i.MX8MM RM Rev. 3 Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Link: https://lore.barebox.org/20240116-feature-imx8mp-octop-driver-v1-1-5143a215f657@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: regmap: Fix nvmem sizeRobin van der Gracht2024-01-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We should add 1 to the max_register index since counting is zero based. i.e. the stm32mp151 bsec has registers 0 - 95 with reg_stride 4. Size should be (95 + 1) * 4 = 384 bytes otherwise we can't access bsec register 95 (last one). regmap_size_bytes() does take the +1 into account so we can use that. Fixes: b4abbd8a6cbb ("nvmem: add nvmem_regmap_register helper") Signed-off-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: ocotp: align OCOTP bank count with LinuxAhmad Fatoum2024-01-081-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | Now that struct imx_ocotp_data::nregs is equivalent to the Linux driver's struct ocotp_params::nregs, the differences between the Linux driver and barebox are easy to spot. Some of the differences were only quite recently added to Linux in v6.7-rc1 (i.MX6UL, i.MX6ULL), but others have been that way since they were first added to the Linux driver. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: ocotp: correct regmap's max_registerAhmad Fatoum2024-01-081-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Fuse words of the i.MX are 32-bit wide each and their number vary by SoC. For the i.MX, there are 128 fuse words, which if linearized, are a total 512 bytes in size. The barebox driver calls the total size num_regs, which is misleading and then sets the max_register to be the total_size - 1, which is wrong as it's supposed to be e a multiple of the register stride, which is not the case for (512 / 4) - 1 == 127. Instead, we should be setting 508. Fix the calculation to do this and while at it, rename the driver data member to its Linux counterpart. Fixes: 2ee6bb35043d ("ARM: i.MX: ocotp: Switch to regmap support") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: imx-ocotp-ele: correct regmap's max_registerAhmad Fatoum2024-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | The max_register must be a multiple of the register stride, which is not the case for 2048 - 1 == 2047. Instead, we should be setting 2044, so fix the calculation to do this. Fixes: e75746d53cca ("nvmem: Add support for i.MX ELE ocotp") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: startfive-otp: correct regmap's max_registerAhmad Fatoum2024-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | The max_register must be a multiple of the register stride, which is not the case for 0x200 - 1 == 0x1ff. Instead, we should be setting (0x1ff * 4), so fix the calculation to do this. Fixes: 88f3d13bafc6 ("nvmem: add StarFive OTP support") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: bsec: correct regmap's max_registerAhmad Fatoum2024-01-081-1/+1
|/ | | | | | | | | | | | The max_register must be a multiple of the register stride, which is not the case for (384 / 4) - 1 == 95. Instead, we should be setting 380, so fix the calculation to do this. Fixes: 094ce0ee7cdf ("nvmem: bsec: correct regmap's max_register") Reported-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: bsec: add support for STM32 bsec pseudo TAAhmad Fatoum2023-12-055-21/+502
| | | | | | | | | | | While OP-TEE on STM32MP15 still implements the old SMC based API to access the OTP, on STM32MP13, communication with the pseudo TA is mandatory. Therefore add a driver that probes for OP-TEE and talks to it to read and write the OTP. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231127064034.2206788-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: Add support for i.MX ELE ocotpSascha Hauer2023-11-203-0/+196
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/regmap'Sascha Hauer2023-10-275-13/+23
|\
| * treewide: switch regmap.h include to linux/regmap.hAhmad Fatoum2023-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that there are no longer any users of regmap.h in headers, let's switch all users in the source files to linux/regmap.h. That way, the only users of regmap.h whether directly or indirectly will be out-of-tree code, which will fail with an error if they are dependent on the old semantics of regmap_bulk_read and regmap_bulk_write. After a transitory period, we can then drop regmap.h. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * regmap: align regmap_bulk_read/write API with LinuxAhmad Fatoum2023-10-234-11/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since its inception in 2016, barebox regmap_bulk_read and regmap_bulk_write expected the last argument to be the total length of data to access in bytes. Its namesake Linux version has the same prototype, but interprets the last argument as number of elements to write, i.e. bytes / regmap_get_val_bytes(map). This went unnoticed so far, because barebox users are either using 1-byte regmaps, the code was written specifically for barebox or the code is yet unused such as the KSZ switch 64-bit accessors. Avoid nasty future surprises by switching implementation and users to the Linux interpretation of the last argument. As courtesy for out-of-tree board code, we poison the symbol when regmap.h is included, so out of tree code doesn't silently run into the inverse issue. Files with regmap.h replaced by linux/regmap.h added and no other changes are already compatible with the new definitions. All other files are adapted to the new definition through division by the value size in bytes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: regmap: do not use regmap_bulk_readAhmad Fatoum2023-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | nvmem_regmap_read is only ever called with stride_size == value_size, so reading one stride's worth with barebox' variant of regmap_bulk_read is identical to just calling regmap_read a single time, so let's just do that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: Add Rockchip OTP controller driverAlexander Shiyan2023-10-063-0/+456
|/ | | | | | | | | This adds a simple driver to dump specified values of Rockchip SoC from otp, such as cpu-leakage, id etc. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20231006054812.4343-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: ocotp: handle too early calls into ocotp driver gracefullyAhmad Fatoum2023-07-281-2/+39
| | | | | | | | | | | | | HAB code calls into OCOTP driver by relying on a global imx_ocotp variable that's populated on driver probe. For board code that calls a HAB function to early, this may end up dereferencing a NULL pointer, so let's return -EPROBE_DEFER in that case or if deep probe is enabled, just probe the OCOTP directly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230726192718.911735-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-031-2/+1
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpio: have gpiod_ functions return and accept pointersAhmad Fatoum2023-06-231-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The gpiod_ (GPIO descriptor) API used with Linux differs from barebox' normal GPIO API: - gpiod handles are opaque pointers and not an integer, which users have an expectation of stability for - gpiod API uses logic levels by default with separate raw API for physical level instead of physical level by default and separate API taking active level into account. The barebox gpiod_ API mimics the latter point, but still uses integers requiring ugly and arguably error prone conversions when porting kernel code. Let's improve upon that by just encoding the integer into a pointer variable for API compatibility. Later commits will switch barebox GPIO support to use actual GPIO descriptors without consulting the numeric indices, but we do this temporary switch here, so we can split up provider and consumer changes. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230622072329.1339317-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-06-228-49/+28
|\
| * nvmem: retire struct nvmem_bus for better Linux compatibilityAhmad Fatoum2023-06-138-49/+28
| | | | | | | | | | | | | | | | | | | | nvmem_bus is arguably a confusing name and serves no real purpose over just embedding its two members directly. That's what Linux currently does, so follow suit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125711.1086786-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-138-0/+8
|/ | | | | | | | | | | | | | | | Syncing device trees with Linux upstream can lead to breakage, when the device trees are switched to newer bindings, which are not yet supported in barebox. To make it easier to spot such issues, we want to start applying some heuristics to flag possibly problematic DT changes. One step towards being able to do that is to know what nodes barebox actually consumes. Most of the nodes have a compatible entry, which is matched by an array of of_device_id, so let's have MODULE_DEVICE_TABLE point at it for future extraction. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125908.1087340-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix includes missed by multiarch supportAhmad Fatoum2023-04-111-2/+2
| | | | | | | | | | | Found by manual inspection of the results of: rg '#include\s*<mach/[^/]+>' | rg -v 'arch/(powerpc|sandbox|mips|x86|kvx)' Fixes: 68b778c24314 ("ARM: Drop mach dir include path") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230411071436.1630752-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: stm32mp: Move mach header files to include/mach/stm32mpSascha Hauer2023-03-061-1/+1
| | | | | | | | | | Currently arch specific headers can be included with longer possible as there won't be a single mach anymore. Move all stm32mp specific header files to include/mach/stm32mp/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: Move mach header files to include/mach/imxSascha Hauer2023-03-061-1/+6
| | | | | | | | | | | Currently arch specific headers can be included with #include <mach/xxx.h>. With upcoming multi-arch support this is no longer possible as there won't be a single mach anymore. Move all i.MX specific header files to include/mach/imx/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nvmem'Sascha Hauer2023-02-233-30/+38
|\
| * nvmem: ocotp: add post processing for MAC cellsLucas Stach2023-02-061-1/+17
| | | | | | | | | | | | | | | | | | Add a nvmem post process callback to swap the MAC address as required when read via nvmem. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20230202173312.504493-4-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: regmap: allow to register with post processingLucas Stach2023-02-061-1/+9
| | | | | | | | | | | | | | | | | | Add a new registration function that allows to fill the cell_post_process function pointer. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20230202173312.504493-3-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: ocotp: switch to nvmem_regmap_registerLucas Stach2023-02-061-29/+1
| | | | | | | | | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20230202173312.504493-2-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: add support for post processingLucas Stach2023-02-061-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a port of the Linux commit 5008062f1c3f ("nvmem: core: add nvmem cell post processing callback"). It looks a little different, as Linux switched to create nvmem cells at registration time, effectively deduplicating the cells, but then needed to introduce nvmem_cells_entry to be able to store the lookup name, which is used by the post-processing. As Barebox simply created a nvmem cell per lookup, as Linux did before e888d445ac33 ("nvmem: resolve cells from DT at registration time"), we can simply store the lookup name in the cell. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20230202173312.504493-1-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: ocotp: add support for second MAC address on i.MX8MPLucas Stach2023-01-271-3/+5
|/ | | | | | | | | | | i.MX8MP has the same quirk as the i.MX6UL: the MAC address for the second ethernet interface is stored at an unaligned location and thus needs to be handled by skipping the first 2 bytes from the OCOTP register. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20230111182157.1702865-1-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-108-8/+8
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-109-18/+19
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-107-18/+18
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: ocotp: decouple featctrl from barebox,provide-mac-addressAhmad Fatoum2023-01-101-3/+1
| | | | | | | | | | | | imx_ocotp_init_dt() does both barebox,provide-mac-address and barebox,feature-controller parsing, but it erroneously exited early when the former was not available. Change this so no early exit happens. Fixes: 4adc4e12ac95 ("nvmem: ocotp: add i.MX8M[MN] feature controller support") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230110085159.3440210-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: core: don't fail on positive callback value returnAhmad Fatoum2022-12-091-10/+10
| | | | | | | | | | | | | | | | | | A sizable number of barebox NVMEM drivers returns a positive value of number of bytes read on success, while others return 0 unless an error occurred. When we used to check for errors with IS_ERR_VALUE, both cases worked, because it wouldn't evaluate to true for positive numbers. Now with IS_ERR_VALUE removed, we need to explicitly check for negative values to determinte errors. Otherwise nvmem_cell_read becomes a death trap that returns values like (void *)2, which IS_ERR() won't catch and best case kfree() will crash on. Fixes: eb05a8e1d2b4 ("nvmem: remove IS_ERR_VALUE abuses") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221207184634.140081-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: remove IS_ERR_VALUE abusesSascha Hauer2022-11-081-12/+10
| | | | | | | | | | | | | | | | | >From Kernel commit 287980e49ffc ("remove lots of IS_ERR_VALUE abuses"): | Most users of IS_ERR_VALUE() in the kernel are wrong, as they | pass an 'int' into a function that takes an 'unsigned long' | argument. This happens to work because the type is sign-extended | on 64-bit architectures before it gets converted into an | unsigned type. Based on the Kernel commit remove usage of IS_ERR_VALUE() from the nvmem core. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20221107100727.2510346-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX8MP: add feature controller support for PlusAhmad Fatoum2022-10-181-0/+9
| | | | | | | | | | | | | | Plus has lots of peripherals that need be disabled, depending on fusebox settings. Some of these are already described in the upstream device tree, so reference them in the barebox DT and add the necessary glue for disabling them like we already do on i.MX8MM/N. We omit CPU fusing for now. These are handled by tester3 and would need a bit more rework. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221017134929.622022-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2022-09-142-8/+87
|\
| * nvmem: ocotp: add i.MX8M[MN] feature controller supportAhmad Fatoum2022-09-011-8/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | Devices with a feature-controller property can be specified as provider in a barebox,feature-gates property to announce that the bus should consult them before instantiating or probing devices. Check for this property in the OCOTP driver and register a feature controller for the i.MX8MM and i.MX8MN. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220818051955.2088238-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>