summaryrefslogtreecommitdiff
path: root/drivers/base/regmap
AgeCommit message (Collapse)AuthorFilesLines
2022-12-12regmap: Merge fix for where we get the number of registers fromMark Brown1-4/+11
This didn't get sent for 6.1 since we should do a better fix but that didn't happen in time.
2022-12-09regmap-irq: Add handle_mask_sync() callbackWilliam Breathitt Gray1-13/+31
Provide a public callback handle_mask_sync() that drivers can use when they have more complex IRQ masking logic. The default implementation is regmap_irq_handle_mask_sync(), used if the chip doesn't provide its own callback. Cc: Mark Brown <broonie@kernel.org> Signed-off-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/e083474b3d467a86e6cb53da8072de4515bd6276.1669100542.git.william.gray@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-26fsi: Add regmap and refactor sbefifoMark Brown3-1/+237
Merge series from Eddie James <eajames@linux.ibm.com>: The SBEFIFO hardware can now be attached over a new I2C endpoint interface called the I2C Responder (I2CR). In order to use the existing SBEFIFO driver, add a regmap driver for the FSI bus and an endpoint driver for the I2CR. Then, refactor the SBEFIFO and OCC drivers to clean up and use the new regmap driver or the I2CR interface. This branch just has the regmap change so it can be shared with the FSI code.
2022-11-25regmap: Add FSI bus supportEddie James3-1/+237
Add regmap support for the FSI bus. Signed-off-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20221102205148.1334459-2-eajames@linux.ibm.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-22regmap: add regmap_might_sleep()Michael Walle1-0/+13
With the dawn of MMIO gpio-regmap users, it is desirable to let gpio-regmap ask the regmap if it might sleep during an access so it can pass that information to gpiochip. Add a new regmap_might_sleep() to query the regmap. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20221121150843.1562603-1-michael@walle.cc Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-09regmap-irq: Use the new num_config_regs property in regmap_add_irq_chip_fwnodeYassine Oudjana1-4/+11
Commit faa87ce9196d ("regmap-irq: Introduce config registers for irq types") added the num_config_regs, then commit 9edd4f5aee84 ("regmap-irq: Deprecate type registers and virtual registers") suggested to replace num_type_reg with it. However, regmap_add_irq_chip_fwnode wasn't modified to use the new property. Later on, commit 255a03bb1bb3 ("ASoC: wcd9335: Convert irq chip to config regs") removed the old num_type_reg property from the WCD9335 driver's struct regmap_irq_chip, causing a null pointer dereference in regmap_irq_set_type when it tried to index d->type_buf as it was never allocated in regmap_add_irq_chip_fwnode: [ 39.199374] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [ 39.200006] Call trace: [ 39.200014] regmap_irq_set_type+0x84/0x1c0 [ 39.200026] __irq_set_trigger+0x60/0x1c0 [ 39.200040] __setup_irq+0x2f4/0x78c [ 39.200051] request_threaded_irq+0xe8/0x1a0 Use num_config_regs in regmap_add_irq_chip_fwnode instead of num_type_reg, and fall back to it if num_config_regs isn't defined to maintain backward compatibility. Fixes: faa87ce9196d ("regmap-irq: Introduce config registers for irq types") Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com> Link: https://lore.kernel.org/r/20221107202114.823975-1-y.oudjana@protonmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-05Merge tag 'regmap-v6.1' of ↵Linus Torvalds4-103/+428
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap Pull regmap updates from Mark Brown: "This has been a busy release for regmap with one thing and other, there's been an especially large interest in MMIO regmaps for some reason. The bulk of the changes are cleanups but there are several user visible changes too: - Support for I/O ports in regmap-mmio - Support for accelerated noinc operations in regmap-mmio - Support for tracing the register values in bulk operations" * tag 'regmap-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: mmio: replace return 0 with break in switch statement regmap: spi-avmm: Use swabXX_array() helpers regmap: mmio: Use swabXX_array() helpers swab: Add array operations regmap: trace: Remove unneeded blank lines regmap: trace: Remove explicit castings regmap: trace: Remove useless check for NULL for bulk ops regmap: mmio: Fix rebase error regmap: check right noinc bounds in debug print regmap: introduce value tracing for regmap bulk operations regmap/hexagon: Properly fix the generic IO helpers regmap: mmio: Support accelerared noinc operations regmap: Support accelerated noinc operations regmap: Make use of get_unaligned_be24(), put_unaligned_be24() regmap: mmio: Fix MMIO accessors to avoid talking to IO port regmap: mmio: Introduce IO accessors that can talk to IO port regmap: mmio: Get rid of broken 64-bit IO regmap: mmio: Remove mmio_relaxed member from context
2022-09-22regmap: mmio: replace return 0 with break in switch statementColin Ian King1-1/+1
Variable min_stride is assigned a value that is never read, fix this by replacing the return 0 with a break statement. This also makes the case statement consistent with the other cases in the switch statement. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Link: https://lore.kernel.org/r/20220922080445.818020-1-colin.i.king@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-07regmap: spi-avmm: Use swabXX_array() helpersAndy Shevchenko1-10/+4
Since we have a few helpers to swab elements of a given size in an array use them instead of open coded variants. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220831212744.56435-3-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-07regmap: mmio: Use swabXX_array() helpersAndy Shevchenko1-16/+4
Since we have a few helpers to swab elements of a given size in an array use them instead of open coded variants. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220831212744.56435-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-05regmap: trace: Remove unneeded blank linesAndy Shevchenko1-8/+0
There is a few unneeded blank lines in some of event definitions, remove them in order to make those definitions consistent with the rest. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220901132336.33234-3-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-05regmap: trace: Remove explicit castingsAndy Shevchenko1-12/+5
There is no need to have explicit castings to the same type the variables are of. Remove the explicit castings. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Link: https://lore.kernel.org/r/20220901132336.33234-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-05regmap: trace: Remove useless check for NULL for bulk opsAndy Shevchenko1-2/+1
If the buffer pointer is NULL we already are in troubles since regmap bulk API expects caller to provide valid parameters, it dereferences that without any checks before we call for traces. Moreover, the current code will print garbage in the case of buffer is NULL and length is not 0. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220901132336.33234-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-01regmap: mmio: Fix rebase errorLinus Walleij1-3/+0
A dangling pointless "ret 0" was left in and some unneeded whitespace can go too. Fixes: 81c0386c1376 ("regmap: mmio: Support accelerared noinc operations") Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220831141303.501548-1-linus.walleij@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-23regmap: check right noinc bounds in debug printLinus Walleij1-2/+2
We were using the wrong bound in the debug prints: this needs to be the number of elements, not the number of bytes, since we're indexing into an element-size typed array. Fixes: c20cc099b30a ("regmap: Support accelerated noinc operations") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220823135700.265019-1-linus.walleij@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-23regmap: introduce value tracing for regmap bulk operationsDmitry Rokosov2-0/+50
Currently, only one-register io operations support tracepoints with value logging. For the regmap bulk operations developer can view hw_start/hw_done tracepoints with starting reg number and registers count to be reading or writing. This patch injects tracepoints with dumping registers values in the hex format to regmap bulk reading and writing. Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru> Link: https://lore.kernel.org/r/20220816181451.5628-1-ddrokosov@sberdevices.ru Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-18regmap: spi: Reserve space for register address/paddingCristian Ciocaltea1-0/+8
Currently the max_raw_read and max_raw_write limits in regmap_spi struct do not take into account the additional size of the transmitted register address and padding. This may result in exceeding the maximum permitted SPI message size, which could cause undefined behaviour, e.g. data corruption. Fix regmap_get_spi_bus() to properly adjust the above mentioned limits by reserving space for the register address/padding as set in the regmap configuration. Fixes: f231ff38b7b2 ("regmap: spi: Set regmap max raw r/w from max_transfer_size") Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Reviewed-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220818104851.429479-1-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-17regmap: mmio: Support accelerared noinc operationsLinus Walleij1-0/+162
Use the newly added callback for accelerated noinc MMIO to provide writesb, writesw, writesl, writesq, readsb, readsw, readsl and readsq. A special quirk is needed to deal with big endian regmaps: there are no accelerated operations defined for big endian, so fall back to calling the big endian operations itereatively for this case. The Hexagon architecture turns out to have an incomplete <asm/io.h>: writesb() is not implemented. Fix this by doing what other architectures do: include <asm-generic/io.h> into the <asm/io.h> file. Cc: Brian Cain <bcain@quicinc.com> Cc: linux-hexagon@vger.kernel.org Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220816204832.265837-2-linus.walleij@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-17regmap: Support accelerated noinc operationsLinus Walleij1-3/+120
Several architectures have accelerated operations for MMIO operations writing to a single register, such as writesb, writesw, writesl, writesq, readsb, readsw, readsl and readsq but regmap currently cannot use them because we have no hooks for providing an accelerated noinc back-end for MMIO. Solve this by providing reg_[read/write]_noinc callbacks for the bus abstraction, so that the regmap-mmio bus can use this. Currently I do not see a need to support this for custom regmaps so it is only added to the bus. Callbacks are passed a void * with the array of values and a count which is the number of items of the byte chunk size for the specific register width. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220816204832.265837-1-linus.walleij@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15regmap: mmio: Extending to support IO portsMark Brown1-52/+88
Merge series from Andy Shevchenko <andriy.shevchenko@linux.intel.com>: Currently regmap MMIO doesn't support IO ports, while being inconsistent in used IO accessors. Fix the latter and extend framework with the former.
2022-08-15regmap: Make use of get_unaligned_be24(), put_unaligned_be24()Andy Shevchenko1-20/+17
Since we have a proper endianness converters for BE 24-bit data use them. While at it, format the code using switch-cases as it's done for the rest of the endianness handlers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220726151213.71712-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15regmap: mmio: Fix MMIO accessors to avoid talking to IO portAndy Shevchenko1-4/+4
Currently regmap MMIO is inconsistent with IO accessors. I.e. the Big Endian counterparts are using ioreadXXbe() / iowriteXXbe() which are not clean implementations of readXXbe(). That said, reimplement current Big Endian MMIO accessors by replacing ioread()/iowrite() with respective read()/write() and swab() calls. Note, there are no current in-kernel users that may utilize the functionality of the IO ports on Big Endian hardware. All drivers that use regmap MMIO either Little Endian, or they don't map IO ports in a way that ioreadXX()/iowriteXX() may be utilized. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20220808203401.35153-5-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15regmap: mmio: Introduce IO accessors that can talk to IO portAndy Shevchenko1-9/+96
Some users may use regmap MMIO for IO ports, and this can be done by assigning ioreadXX()/iowriteXX() and their Big Endian counterparts to the regmap context. Add IO port support with a corresponding flag added. While doing that, make sure that user won't select relaxed MMIO access along with IO port because the latter have no relaxed variants. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20220808203401.35153-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15regmap: mmio: Get rid of broken 64-bit IOAndy Shevchenko1-49/+0
The current implementation, besides having no active users, is broken by design of regmap. For 64-bit IO we need to supply 64-bit value, otherwise there is no way to handle upper 32 bits in 64-bit register. Hence, remove the broken IO accessors for good and wait for real user that can fix entire regmap API for that. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20220808203401.35153-3-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15regmap: mmio: Remove mmio_relaxed member from contextAndy Shevchenko1-6/+4
There is no need to keep mmio_relaxed member in the context, it's onetime used during generation of the context. Remove it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20220808203401.35153-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-18regmap: permit to set reg_update_bits with bulk implementationChristian Marangi1-0/+2
A regmap may still require to set a custom reg_update_bits instead of relying to the regmap_bus_read/write general function. Permit to set it in the map if provided by the regmap config. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Link: https://lore.kernel.org/r/20220715201032.19507-1-ansuelsmth@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init()Matt Ranostay1-0/+3
In regmap_field_init() when a invalid mask is provided it still initializes with any warnings. An example of this is when the LSB is greater than MSB a mask of zero is produced. WARN_ONCE() is not ideal for this but requires less changes to core regmap code. Cc: Mark Brown <broonie@kernel.org> Cc: Nishanth Menon <nm@ti.com> Signed-off-by: Matt Ranostay <mranostay@ti.com> Link: https://lore.kernel.org/r/20220708013125.313892-1-mranostay@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-05regmap-irq: Fix bug in regmap_irq_get_irq_reg_linear()Aidan MacDonald1-1/+1
irq_reg_stride in struct regmap_irq_chip is often 0, but that actually means to use the default stride of 1. The effective stride is stored in struct regmap_irq_chip_data->irq_reg_stride and will get the corrected default value. The default ->get_irq_reg() callback was using the stride from the chip definition, which is wrong; fix it to use the effective stride from the chip data instead. Link: https://lore.kernel.org/lkml/acaaf77f-3282-8544-dd3c-7915fc1a6a4f@samsung.com/ Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220704112847.23844-1-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-30regmap-irq cleanups and refactoringMark Brown1-137/+295
Merge series from Aidan MacDonald <aidanmacdonald.0x0@gmail.com>: This series is an attempt at cleaning up the regmap-irq API in order to simplify things and consolidate existing features, while at the same time generalizing it to support a wider range of hardware. There is a new system for IRQ type configuration, some tweaks to unmask registers so they're more intuitive and useful, and a new callback for calculating register addresses. There's also a few minor code cleanups in here. In v2 I've taken the approach of adding new features and deprecating existing ones rather than removing them aggressively. Warnings will be issued for any drivers that use deprecated features, but they'll otherwise continue to function normally. One important caveat: not all of these changes are tested beyond compile testing, since I don't have hardware to exercise all of the features.
2022-06-30regmap: cache: Add extra parameter check in regcache_initSchspa Shi1-0/+6
When num_reg_defaults > 0 but reg_defaults is NULL, there will be a NULL pointer exception. Current code has no such usage, but as additional hardening, also check this to prevent any chance of crashing. Signed-off-by: Schspa Shi <schspa@gmail.com> Link: https://lore.kernel.org/r/20220629130951.63040-1-schspa@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Deprecate the not_fixed_stride flagAidan MacDonald1-0/+2
This flag is a bit of a hack and the same thing can be accomplished using a custom ->get_irq_reg() callback. Add a warning to catch any use of the flag. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-13-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Add get_irq_reg() callbackAidan MacDonald1-46/+80
Replace the internal sub_irq_reg() function with a public callback that drivers can use when they have more complex register layouts. The default implementation is regmap_irq_get_irq_reg_linear(), used if the chip doesn't provide its own callback. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-12-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Fix inverted handling of unmask registersAidan MacDonald1-45/+69
To me "unmask" suggests that we write 1s to the register when an interrupt is enabled. This also makes sense because it's the opposite of what the "mask" register does (write 1s to disable an interrupt). But regmap-irq does the opposite: for a disabled interrupt, it writes 1s to "unmask" and 0s to "mask". This is surprising and deviates from the usual way mask registers are handled. Additionally, mask_invert didn't interact with unmask registers properly -- it caused them to be ignored entirely. Fix this by making mask and unmask registers orthogonal, using the following behavior: * Mask registers are written with 1s for disabled interrupts. * Unmask registers are written with 1s for enabled interrupts. This behavior supports both normal or inverted mask registers and separate set/clear registers via different combinations of mask_base/unmask_base. The old unmask register behavior is deprecated. Drivers need to opt-in to the new behavior by setting mask_unmask_non_inverted. Warnings are issued if the driver relies on deprecated behavior. Chips that only set one of mask_base/unmask_base don't have to use the mask_unmask_non_inverted flag because that use case was previously not supported. The mask_invert flag is also deprecated in favor of describing inverted mask registers as unmask registers. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-11-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Deprecate type registers and virtual registersAidan MacDonald1-0/+6
Config registers can be used to replace both type and virtual registers, so mark both features are deprecated and issue a warning if they're used. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-10-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Introduce config registers for irq typesAidan MacDonald1-5/+110
Config registers provide a more uniform approach to handling irq type registers. They are essentially an extension of the virtual registers used by the qcom-pm8008 driver. Config registers can be represented as a 2D array: config_base[0] reg0,0 reg0,1 reg0,2 reg0,3 config_base[1] reg1,0 reg1,1 reg1,2 reg1,3 config_base[2] reg2,0 reg2,1 reg2,2 reg2,3 There are 'num_config_bases' base registers, each of which is used to address 'num_config_regs' registers. The addresses are calculated in the same way as for other bases. It is assumed that an irq's type is controlled by one column of registers; that column is identified by the irq's 'type_reg_offset'. The set_type_config() callback is responsible for updating the config register contents. It receives an array of buffers (each represents a row of registers) and the index of the column to update, along with the 'struct regmap_irq' description and requested irq type. Buffered values are written to registers in regmap_irq_sync_unlock(). Note that the entire register contents are overwritten, which is a minor change in behavior from type registers via 'type_base'. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-9-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Refactor checks for status bulk read supportAidan MacDonald1-4/+10
There are several conditions that must be satisfied to support bulk read of status registers. Move the check into a function to avoid duplicating it in two places. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-8-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Remove mask_writeonly and regmap_irq_update_bits()Aidan MacDonald1-17/+7
Commit a71411dbf6c8 ("regmap: irq: add chip option mask_writeonly") introduced the mask_writeonly option, but it isn't used now and it appears it's never been used by any in-tree drivers. The motivation for the option is mentioned in the commit message, Some irq controllers have writeonly/multipurpose register layouts. In those cases we read invalid data back. [...] The option causes mask register updates to use regmap_write_bits() instead of regmap_update_bits(). However, regmap_write_bits() doesn't solve the reading invalid data problem. It's still a read-modify-write op like regmap_update_bits(). The difference is that 'update bits' will only write the new value if it is different from the current value, while 'write bits' will write the new value unconditionally, even if it's the same as the current value. This seems like a bit of a specialized use case and probably isn't that useful for regmap-irq, so let's just remove the option and go back to using an 'update bits' op for the mask registers. We can always add the option back if some driver ends up needing it in the future. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-7-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Remove inappropriate uses of regmap_irq_update_bits()Aidan MacDonald1-6/+6
regmap_irq_update_bits() is misnamed and should only be used for updating mask registers, since it checks the mask_writeonly flag. However, it was also used for updating wake and type registers. It's safe to replace these uses with regmap_update_bits() because there are no users of the mask_writeonly flag. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-6-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Remove an unnecessary restriction on type_in_maskAidan MacDonald1-11/+8
Check types_supported instead of checking type_rising/falling_val when using type_in_mask interrupts. This makes the intent clearer and allows a type_in_mask irq to support level or edge triggers, rather than only edge triggers. Update the documentation and comments to reflect the new behavior. This shouldn't affect existing drivers, because if they didn't set types_supported properly the type buffer wouldn't be updated. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-5-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Cleanup sizeof(...) use in memory allocationAidan MacDonald1-8/+8
Instead of mentioning unsigned int directly, use a sizeof(...) involving the buffer we're allocating to ensure the types don't get out of sync. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-4-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Remove unused type_reg_stride fieldAidan MacDonald1-6/+0
It appears that no chip ever required a nonzero type_reg_stride and commit 1066cfbdfa3f ("regmap-irq: Extend sub-irq to support non-fixed reg strides") broke support. Just remove the field. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-3-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap-irq: Convert bool bitfields to unsigned intAidan MacDonald1-1/+1
Use 'unsigned int' for bitfields for consistency with most other kernel code. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220623211420.918875-2-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29regmap: Merge up fixesMark Brown2-10/+13
Needed for the regmap-irq rework.
2022-06-27regmap: Don't warn about cache only mode for devices with no cacheMark Brown1-1/+2
For devices with no cache it can make sense to use cache only mode as a mechanism for trapping writes to hardware which is inaccessible but since no cache is equivalent to cache bypass we force such devices into bypass mode. This means that our check that bypass and cache only mode aren't both enabled simultanously is less sensible for devices without a cache so relax it. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220622171723.1235749-1-broonie@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-22regmap-irq: Fix offset/index mismatch in read_sub_irq_data()Aidan MacDonald1-1/+2
We need to divide the sub-irq status register offset by register stride to get an index for the status buffer to avoid an out of bounds write when the register stride is greater than 1. Fixes: a2d21848d921 ("regmap: regmap-irq: Add main status register support") Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220620200644.1961936-3-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-22regmap-irq: Fix a bug in regmap_irq_enable() for type_in_mask chipsAidan MacDonald1-2/+3
When enabling a type_in_mask irq, the type_buf contents must be AND'd with the mask of the IRQ we're enabling to avoid enabling other IRQs by accident, which can happen if several type_in_mask irqs share a mask register. Fixes: bc998a730367 ("regmap: irq: handle HW using separate rising/falling edge interrupts") Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Link: https://lore.kernel.org/r/20220620200644.1961936-2-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-20regmap: Wire up regmap_config provided bulk write in missed functionsJavier Martinez Canillas1-6/+4
There are some functions that were missed by commit d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config") when support to define bulk read/write callbacks in regmap_config was introduced. The regmap_bulk_write() and regmap_noinc_write() functions weren't changed to use the added map->write instead of the map->bus->write handler. Also, the regmap_can_raw_write() was not modified to take map->write into account. So will only return true if a bus with a .write callback is set. Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config") Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20220616073435.1988219-4-javierm@redhat.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-20regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't setJavier Martinez Canillas1-0/+3
Before adding support to define bulk read/write callbacks in regmap_config by the commit d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config"), the regmap_noinc_read() function returned an errno early a map->bus->read callback wasn't set. But that commit dropped the check and now a call to _regmap_raw_read() is attempted even when bulk read operations are not supported. That function checks for map->read anyways but there's no point to continue if the read can't succeed. Also is a fragile assumption to make so is better to make it fail earlier. Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config") Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20220616073435.1988219-3-javierm@redhat.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-20regmap: Re-introduce bulk read support check in regmap_bulk_read()Javier Martinez Canillas1-1/+1
Support for drivers to define bulk read/write callbacks in regmap_config was introduced by the commit d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config"), but this commit wrongly dropped a check in regmap_bulk_read() to determine whether bulk reads can be done or not. Before that commit, it was checked if map->bus was set. Now has to check if a map->read callback has been set. Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config") Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20220616073435.1988219-2-javierm@redhat.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-15Merge tag 'regmap-field-bit-helpers' of ↵Mark Brown1-0/+22
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-5.20 regmap: Add regmap_field helpers for simple bit operations Add simple bit operations for setting, clearing and testing specific bits with regmap_field.