summaryrefslogtreecommitdiffstats
path: root/drivers/base
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/hwrng'Sascha Hauer2024-03-151-0/+19
|\
| * driver: implement dev_platform_get_and_ioremap_resourceAhmad Fatoum2024-03-151-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | To simplify porting of Linux drivers that make use of this function, add an implementation to barebox. This was so far not done, because AT91 has I/O memory regions that conflict with the error pointers. Therefore, we emit a warning if we run into such a conflict. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240313105631.686778-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: make struct bus_type::probe optionalAhmad Fatoum2024-02-291-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Newly introduce soc_bus_type doesn't define .probe, which would crash once a driver is registered on that bus. Do as Linux does and defer to the driver probe function if there's no bus probe function and treat non-existence of either as a successful probe. This has the added benefit that it will allow us to drop very simple bus probe functions that just call the driver probe and do nothing else. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240228160518.1589193-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: make struct bus_type::match optionalAhmad Fatoum2024-02-291-1/+1
|/ | | | | | | | | | | | Newly introduce soc_bus_type doesn't define .match, which would crash once a driver is registered on that bus. Do as Linux does and treat a non-existent match callback as meaning that all drivers should be matched and that the probe function should indicate via -ENODEV/-ENXIO whether a device is indeed suitable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240228160518.1589193-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2024-02-212-43/+52
|\
| * deep-probe: treat any probe deferral as permanentAhmad Fatoum2024-02-201-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As the comment notes, "-EPROBE_DEFER should never appear on a deep-probe machine so inform the user immediately.". Yet, we still add the device to the deferred probe list to try it again later, which should only make a difference if there's a bug with the deep probe mechanism itself. Therefore, never use the deferred probe list on deep probe system and directly report any probe deferral as permanent. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240219172925.3798024-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * driver: refactor probe return value handling into switch statementAhmad Fatoum2024-02-201-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The return values of the bus probe function called inside device_probe() are classified into 4 categories and they are checked by if statement distributed across device_probe(). For clarity and easier changes, collect all of them into a switch statement and while at it, use helpers to make use of %pe, list_move and list_del_init instead of opencoding them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240219172925.3798024-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drivers: drop simple bus remove in favor of common implementationAhmad Fatoum2024-02-161-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that driver core will call dev->driver->remove if dev->bus->remove is NULL, we cann remove all bus_type::remove functions that do the same. This has the welcome side effect that devices that device_remove will return false when called on a device the neither has a bus remove or driver remove function and thus we can skip tracing these calls when CONFIG_DEBUG_PROBES is enabled. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240215103353.2799723-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * driver: make CONFIG_DEBUG_PROBES more useful for removalAhmad Fatoum2024-02-161-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_DEBUG_PROBES is enabled, barebox will print a message on every device probe and removal. Unfortunately, the removal prints are not very useful, because the removal happens in the bus remove function, which is often a no-op, but that's not known to driver core. To make this a bit more useful, let's allow skipping bus remove functions like Linux does and only print that a remove is happening if either a bus or driver remove function is available. At present, this doesn't change much, but the follow-up commit will drop bus remove functions that only call the driver remove function, which will shorten the CONFIG_DEBUG_PROBES output on shutdown a fair bit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240215103353.2799723-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Port SoC framework from LinuxMarco Felsch2024-01-293-0/+127
|/ | | | | | | | | | | | | | This adds the initial support for the Linux soc framework which can be used to register all SoC relevant informations. The framework can be used by driver to check for errata for an specific soc(-revision) in the future since this require porting the matching function. For now it gathers all required SoC information and provide a standard interface to query the data via device params. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20240125133856.3792552-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx-hsio-blk-ctrl'Sascha Hauer2024-01-232-20/+191
|\
| * driver: have dev_request_mem_region_err_null warn if resource starts at 0Ahmad Fatoum2024-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region_err_null() is used very scarcely, because it doesn't allow differentiating between NULL and a MMIO region at address 0. Using it in the latter case is always a bug, so add a WARN_ON that warns about this. This should make it safe to use at more places, which will come in handy to implement Linux API that uses NULL as error value. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-14-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: implement pm_genpd_remove/of_genpd_del_provider for cleanupAhmad Fatoum2024-01-221-0/+31
| | | | | | | | | | | | | | | | | | We already have pm_genpd_init/of_genpd_add_provider, but lack functions to deregister them. Port the deregisteration functions over from Linux. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: add support for enabling power domains later onAhmad Fatoum2024-01-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a single power domain is specified platform driver probe takes care to enable the power domain. When there are multiple power domains however, each Linux driver must itself enable power domains in the correct sequence. In Linux, this is handled by runtime PM. We don't have that in barebox, so we add the enable function with a _genpd suffix to alert users to this fact. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: implement dev_pm_domain_attach_by_id/nameAhmad Fatoum2024-01-221-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Linux, dev_pm_domain_attach() enables a device's sole power domain, but dev_pm_domain_attach_by_id/name(), attaches the power domain to a virtual device and returns it for use with runtime PM API. Import these two functions into barebox, so drivers can use them to implement more elaborate power up sequences. The power up operation itself follows in a follow-up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: drop superfluous parameter to __genpd_dev_pm_attachAhmad Fatoum2024-01-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | The Linux prototype of __genpd_dev_pm_attach has the base device as second argument and retrieves the of_node pointer via the device in the first argument. As the function isn't exported, we don't have to follow the Linux API, but we also don't need to keep arguments we don't use, thus drop the device pointer. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: push have_genpd_providers check into __genpd_dev_pm_attachAhmad Fatoum2024-01-221-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | genpd_activate() makes power domains opt-in per platform by considering power domain attachment a success until gepd_activate() is called the first time. We currently do that in genpd_dev_pm_attach(), but a follow up commit will introduce more callers for __genpd_dev_pm_attach, which likewise should have the same behavior regarding genpd_activate(). Thus push the check into __genpd_dev_pm_attach(). No function change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: associate devices with their power domainAhmad Fatoum2024-01-221-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Linux, there is no public consumer API to enable or disable a struct generic_pm_domain. Operations are instead performed on regular struct device, each of which has a reference to a single attached power domain. Power domain consumer API in barebox was so far limited to automatically attaching a single power domain and powering it on prior to function probe, which is never detached and thus no further consumer API is needed. To support more complex power domain setups, we adopt here the kernel API of attaching power domains to devices to enable using struct device as handles for additional power domain operations. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * pmdomain: power: drop unused parameters for internal functionsAhmad Fatoum2024-01-221-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't do latency measurements for power domain operations in barebox, so the timed parameter to indicate whether time measurements should be done or not is unused. We also don't need locking for the powerdomains, so maintaining the depth for lockdep is also unnecessary. Drop both unused function parameters as we are not likely to ever use them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240119162610.1014870-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/cdev'Sascha Hauer2024-01-231-1/+1
|\ \ | |/ |/|
| * cdev: export and use cdevfs_del_partitionAhmad Fatoum2024-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | Like what's the case with cdevfs_add_partition, a couple of users already have a cdev, so it's wasteful to get its name and do a lookup only to arrive at the same cdev. Export a cdevfs_del_partition that directly works on the cdev and start using it instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240103101629.2629497-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | regmap: fix calculation of regmap size when reg_stride != 1Ahmad Fatoum2024-01-081-2/+26
|/ | | | | | | | | | | | | | struct regmap::max_register is in units of struct regmap::reg_stride. To get the total number or registers, we need to divide by reg_stride before adding one, but we ended up adding one before division. regmap_size_bytes() is currently only used for sizing the cdev and rendered the last element of the cdev inaccessible. Fixes: 7a53e162de2a ("Add initial regmap support") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: don't clear unrelated struct device_node::device on unregisterAhmad Fatoum2023-12-051-2/+5
| | | | | | | | | | | | | | | Device nodes have a pointer to the device that was instantiated for it. In some cases, we have both a platform device and a virtual device as child instantiated from it with both pointing at the same device node. So far, when unregistering the virtual device, we would clear the device member, even if it happens to point at another device. Fix this by only clearing it if the device it points at is the one that's actually is being removed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231127063559.2205776-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pm_domain: Add onecell supportSascha Hauer2023-11-031-0/+76
| | | | | | | | | So far we only have simple translation support. Add support for onecell translation taken straight from Linux. This is needed for upcoming TI K3 support. Link: https://lore.barebox.org/20230803105003.4088205-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: switch regmap.h include to linux/regmap.hAhmad Fatoum2023-10-264-4/+4
| | | | | | | | | | | | | | | 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-232-17/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* regmap: add support for bulk 64-bit reads and writesAhmad Fatoum2023-10-231-0/+14
| | | | | | | | | The Linux implementation of regmap_bulk_read and regmap_bulk_write supports 64-bit accesses. Have the barebox implementation follow suit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: add support for device aliasesAhmad Fatoum2023-09-251-0/+46
| | | | | | | | | | | | | | | | | | | | Device names can get quite long, which makes them cumbersome to use on the shell, e.g. firmware:zynqmp-firmware:clock-controller.of. In addition, the names are prone to change when the device tree nodes are renamed. One way we work around this is using aliases, but that is partially at odds with upstream binding. This commit adds an alternative way of allowing drivers and board code to set an alias that affects only device_param_complete. This provides an easy way of defining device names that should be stable for use in shell scripts. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230913132456.2211919-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-031-4/+3
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/state'Sascha Hauer2023-06-221-1/+1
|\
| * driver: add new cdev_is_partition helperAhmad Fatoum2023-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Partitions will have cdev->master != NULL, so often code will just do if (cdev->master) to check if a cdev is a partition. This is suboptimal as it may be misinterpreted by readers as meaning that the cdev is the master device, while it's the other way round. Let's define cdev_is_partition instead and use it everywhere, where cdev->master is only checked, but not dereferenced. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | regmap-mmio: fix use-after-freeAhmad Fatoum2023-06-131-3/+7
|/ | | | | | | | | Once we free ctx, dereferencing it to return ERR_CAST(ctx->clk) is forbidden. Fix this by using an intermediary variable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125331.1085059-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: hostfile: add feature controller supportAhmad Fatoum2023-05-021-1/+1
| | | | | | | | | | | | | | | Keeping the tradition of making the sandbox more complex than it needs to in order to exercise more parts of barebox, let's allow hostfiles to be feature controllers: This allows specifying optional hostfiles in the DT: If the hostfile is unavailable, the nodes pointing at the hostfile can be gated by it, so they behave as if they were disabled. This is useful for the stickypage, which results in a number of ugly errors whenever it's unavailable. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230424121805.150434-7-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* featctrl: drop useless NULL checkAhmad Fatoum2023-05-021-3/+0
| | | | | | | | | | | | | The only instance of calling featctrl_get_from_provider looks like this: featctrl = featctrl_get_from_provider(&featctrl_args, &gateid); Given that the function is static, there's no need to protect against either argument being NULL, so drop the check. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230424121805.150434-6-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: be explicit about supported #feature-cellsAhmad Fatoum2023-05-021-1/+4
| | | | | | | | | | | | A feature controller may control the activation of multiple devices. This is represented by a single index argument in the API. Thus any value higher than #feature-cells = <1>; is unsupported, so let's be explicit about that. #feature-cells = <0>; specs will just be interpreted as if the argument was a 0. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230424121805.150434-5-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2023-04-191-0/+17
|\
| * driver: Add unregister_driver()Sascha Hauer2023-03-211-0/+17
| | | | | | | | | | | | | | Registering drivers is one thing, getting rid of them another. Add unregister_driver() which is used in the coming USB gadget update. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: dwc3: populate parent of xHCI devAhmad Fatoum2023-04-171-2/+4
|/ | | | | | | | | | Reparent xHCIs instantiated from DWC3 controllers to their parents instead of them being direct children of the bus. Apart from improving devinfo/drvinfo output, this should introduce no functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230414145259.3644816-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pm_domains: Enable explicitly when we have power-domain providersSascha Hauer2023-03-071-0/+10
| | | | | | | | | | | | | | | | | | Many SoCs provide power-domains in their device trees. In barebox we most of the time do not have drivers for the power-domains. This is no problem for most of the time as the necessary power domains are either default on or enabled during early SoC init. With multi-arch support it can happen that we compile in SoCs for which we do not have power-domain drivers and other SoCs where we need a power-domain driver. The example I stumbled upon is the i.MX7 on the one hand which has a driver and OMAP on the other hand which has power-domains described in the device tree for which we do not have (and do not currently need) a driver. To be able to handle both situations let's enable pm_domain support explicitly on SoCs we know we have a driver for. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Rename remaining struct device_d -> deviceSascha Hauer2023-02-232-4/+4
| | | | | | | struct device_d was renamed to struct device. Rename the remaining occurences of device_d. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc-struct-rename'Sascha Hauer2023-01-209-39/+853
|\
| * regmap: i2c: use formatted I/OAhmad Fatoum2023-01-122-15/+36
| | | | | | | | | | | | | | | | | | Switching to formatted I/O will enable consumers to customize access sizes, which we'll need to support KSZ switch I2C communication. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drivers: base: regmap: introduce REGMAP_I2CAhmad Fatoum2023-01-122-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | regmap_init_i2c is quite limited right now and only supports 8-bit registers and values. In future, we may want to expand this further, but that would require us to format the regmap_config appropriately, pulling in more code that's not required in the general case, where reg_read and reg_write can be used directly. Add a new Kconfig symbol and select it where appropriate to allow us to split formatted regmap handling from the more basic handling we currently have. We intentionally don't provide a stub function, so out-of-tree users without the select fail to link and can be fixed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: dsa: ksz9477: create regmap cdev for switch registersAhmad Fatoum2023-01-122-0/+105
| | | | | | | | | | | | | | | | | | | | | | | | Now that we use regmap for the KSZ9477 driver, we can make the register map available for introspection as a device file. As the KSZ driver has a separate regmap for each of the three access sizes, we add a new regmap_multi_register_cdev abstraction that multiplexes device file access to the regmap with the best matching alignment. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * regmap: factor out regmap cdev size calculationAhmad Fatoum2023-01-121-2/+7
| | | | | | | | | | | | | | | | | | We will add a new user of this calculate in a follow-up commit, so make it available as a global function. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * regmap: port regmap_init_spiAhmad Fatoum2023-01-123-0/+48
| | | | | | | | | | | | | | | | | | We already have regmap_init_i2c, so add regmap_init_spi as well. Unlike regmap_init_i2c, this one makes full use of the formatted regmap API. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * regmap: support formatted read and writeAhmad Fatoum2023-01-126-2/+637
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Regmap support in barebox compared to Linux is quite primitive. For incoming SPI regmap support, we will want users of the API to just populate their regmap config appropriately and have the core do the heavy lifting of formatting register and value into the buffer correctly. For this, import the formatted read/write functionality of Linux into a new regmap-fmt.c file. Unlike Linux, we keep this functionally gated behind a Kconfig option, so it's only selected when needed, e.g. via REGMAP_SPI in a follow-up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * regmap: consolidate reg/val format into regmap_formatAhmad Fatoum2023-01-122-19/+15
| | | | | | | | | | | | | | | | | | | | | | To reduce difference to Linux v5.19 state of regmap, add a regmap_format with identically named members and make use of this where appropriate. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: implement dev_request_resourceAhmad Fatoum2023-01-161-4/+15
|/ | | | | | | | | dev_request_resource is useful for porting kernel drivers that use devm_request_source on a resource retrieved via <linux/of_address.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-103-9/+9
| | | | | | | | | | | 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>