summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | of: Add common device tree register functionSascha Hauer2020-10-121-0/+2
| | |/ | |/| | | | | | | | | | | | | | | | | | | The different architectures duplicate some code around unflattening and registering the device tree. Add common functions to reduce this duplication. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/reboot-mode' into masterSascha Hauer2020-10-142-0/+40
|\ \ \
| * \ \ Merge branch 'for-next/magicvar-unique-id' into for-next/reboot-modeSascha Hauer2020-10-071-6/+4
| |\ \ \
| * | | | power: reset: reboot-mode: support multi-word magicAhmad Fatoum2020-09-291-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream binding and driver implementation only supports reboot modes of 32-bit length. This is insufficient for cases where multiple registers need to be written for the reboot mode to become active. The i.MX6 is an example for this, the BootROM expects a second 32-bit register to indicate whether the reboot mode in the first is valid. In preparation for adding support for this to the syscon-reboot-mode driver. Migrate the reboot-mode core to support this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | power: reset: reboot-mode: fix up node into boot device treeAhmad Fatoum2020-09-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of relying that the kernel and barebox device trees are in sync, just enforce it by having barebox fix up the device tree node it probed into the kernel device tree. We usually want that, but some reboot mode drivers might want to inhibit the fixup, e.g. because they implement a non-upstream binding or because they communicate with the BootROM, while the kernel shouldn't. For those the fixup is made optional via a struct reboot_mode_driver::no_fixup member. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | drivers: add reboot-mode infrastructureAhmad Fatoum2020-09-292-0/+38
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reboot modes provide a well-defined way to exchange information between different stage of the boot process. When configured, users can type `reboot bootloader` in the OS and barebox can read it out a device parameter. Likewise barebox can write a reboot mode for the BootROM to evaluate and then reset to fall into a serial recovery mode for example. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/percent_pe' into masterSascha Hauer2020-10-141-5/+0
|\ \ \ \
| * | | | vsprintf: retire strerrorp in favor of %peAhmad Fatoum2020-09-291-5/+0
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strerrorp() is only used along with printf. We now have a format specifier for printing error pointers directly, so use that and remove strerrorp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/misc' into masterSascha Hauer2020-10-146-3/+9
|\ \ \ \
| * | | | of: implement of_property_write_strings for multiple stringsAhmad Fatoum2020-10-022-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current way to set a property with multiple values (e.g. compatible strings) is to have char properties[] = "st,stm32mp157c-dk2\0st,stm32mp157"; of_set_property(np, "compatible", properties, sizeof(properties), 1); Add a new helper to make this easier at the cost of one runtime reallocation: of_property_write_strings(np, "compatible, "st,stm32mp157c-dk2", "st,stm32mp157", NULL); Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | include: string: migrate barebox function from <linux/string.h>Ahmad Fatoum2020-10-022-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <linux/string.h> was imported from Linux. In order to keep changes to a minimum, add prototypes for new barebox functions to <string.h> instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | include: asm-generic: bitio.h don't include <asm-generic/io.h> directlyAhmad Fatoum2020-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <asm-generic/io.h> is not meant for direct inclusion. It provides defaults for each arch's <asm/io.h> to fall back to. Use <asm/io.h> instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | include: regulator.h: forward declare struct device_dAhmad Fatoum2020-09-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We so far depended on include order for struct device_d to be declared before <regulator.h> inclusion. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | aiodev: Name channels with device instance nameTrent Piepho2020-09-291-1/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When dynamically assigning device names, an aiodev's name will be "aiodev" and an index, not part of the name string itself, will be allocated dynamically. These are combined to register a device with a name like "aiodev0" or "aiodev1". The shell environment variables use the device name, so one might use "${aiodev0.in_value0_mV}" and "${aiodev1.in_value0_mV}". However, the channel names that are used with aiochannel_get_by_name() just use the aiodev's name and channel name. So channel 0 of the 1st aiodev would be "aiodev.in_value0_mV" and the 2nd aiodev would use the same name. Change the channel naming to use the device instance name, e.g. "aiodev0", rather than the aiodev's base name. This makes the names used aiochannel_get_by_name() match the environment variable names and also avoids duplicate names with more than one dynamically allocated aiodev. Rename aiochannel_get_by_name() to aiochannel_by_name() so that any out of tree boards that use it will fail to compile, since they now need to pass in a different name. Signed-off-by: Trent Piepho <trent.piepho@synapse.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/magicvar-unique-id' into masterSascha Hauer2020-10-141-6/+4
|\ \ \ \ | | |/ / | |/| |
| * | | magicvar: retire BAREBOX_MAGICVAR_NAMEDSascha Hauer2020-10-021-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | BAREBOX_MAGICVAR_NAMED is no longer used, drop it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | magicvar: Use __UNIQUE_ID to generate nameSascha Hauer2020-10-021-5/+7
| |/ / | | | | | | | | | | | | | | | | | | | | | BAREBOX_MAGICVAR_NAME only exists to generate a unique identifier. We can generate that using __UNIQUE_ID. With this we can convert users from BAREBOX_MAGICVAR_NAME to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/driver-macro' into masterSascha Hauer2020-10-142-0/+26
|\ \ \
| * | | net: phy: Add and use driver register macroSascha Hauer2020-10-011-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add driver registration macros for phy drivers similar to the existing platform device macros. This also changes the initcall level from fs_initcall to device_initcall for the phy drivers. It is not clear why the phy driver have been at fs_initcall in the first place, changing it shouldn't be a problem. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | treewide: Use driver macroSascha Hauer2020-09-291-0/+6
| |/ / | | | | | | | | | | | | | | | | | | We have several macros for a oneline driver registration. Add some missing and use them consistently where possible througout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/dev-drvdata' into masterSascha Hauer2020-10-141-0/+18
|\ \ \
| * | | driver: introduce less error-prone dev_get_drvdata alternativeAhmad Fatoum2020-10-091-0/+18
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use dev_get_drvdata to get the driver match data associated with a device. This has two shortcomings: - Linux has dev_get_drvdata too, which returns a private pointer for driver specific info to associate with a device. We use dev->priv (or more often container_of) for that in barebox instead - It nearly always involves a cast to a double pointer, which is error-prone as size and alignment match need to be ensured on the programmer's part and can easily be gotten wrong: enum dev_type type; dev_get_drvdata(dev, (const void **)&type); // UB! Add a new function that instead of using a double pointer argument, returns the pointer directly: - For normal pointer driver data, no cast is necessary - For integer driver data casted to a pointer for storage, the cast is still necessary, but it's only a single pointer this way Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/deep-probe-prepare' into masterSascha Hauer2020-10-141-0/+2
|\ \ \
| * | | regulator: add device reference to regulator_devMarco Felsch2020-09-291-0/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | It is useful to know the physical device a regulator_dev belongs to. This is at least needed for the new deep-probe mechanism. It is also useful for a few regulator drivers to drop their own device_d reference. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | imd: add buildsystem version to metadataSteffen Trumtrar2020-09-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | To have information about the exact state of a barebox binary from userspace, add the buildsystem version to the IMD. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | common: print buildsystem version in barebox bannerSteffen Trumtrar2020-09-251-0/+1
|/ / | | | | | | | | | | | | | | | | When the barebox banner is enabled and printed during startup, also show information about the buildsystem version: the exact state of the barebox binary and its config. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/protonic' into masterSascha Hauer2020-09-253-0/+12
|\ \
| * | of: of_device_get_match_compatible() helperOleksij Rempel2020-08-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some times we need to know, against which compatible did the driver was registered. So, instead of coding it in the driver, add generic helper for all drivers. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: console_common: add of_console_get_by_alias() helperOleksij Rempel2020-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | | Add helper function to get console device by devicetree alias Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | gpiolib: add gpio_array_to_id helper to get ID out of GPIO arrayOleksij Rempel2020-08-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some boards provide a board version and/or ID coded by pull-up/down resistors connected to the gpio pins (or pins which can be multiplexed at some point as gpio). In this case every one implements own gpio id reader function. To avoid it, provide the common helper function to extract a value out of provided gpio array. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/net' into masterSascha Hauer2020-09-2510-25/+170
|\ \ \
| * | | workqueues: Add support for delayed workSascha Hauer2020-09-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes it's necessary to do some work after a delay. Add support for this case. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fs: Warn when filesystem operations are called from a pollerSascha Hauer2020-08-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Filesystem operations possibly call into arbitrary devices, so shouldn't be used from a poller. This patch sprinkles some WARN_ONCE() when this happens. One exception is when the file which is accessed is on ramfs which doesn't have any dependencies to devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | Add WARN_ONCE() macroSascha Hauer2020-08-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds WARN_ONCE from the Linux Kernel. It is useful to warn only once when we would otherwise spam the log. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot net: implement fastboot over UDPEdmund Henniges2020-08-192-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the UDP variant of the fastboot protocol. The only way to start the service for now is to compile with CONFIG_FASTBOOT_NET_ON_BOOT. The service will bind to the network interface that provides the IPv4 gateway. Sending an OKAY packet before performing a restart is necessary since contrary to USB the host will not notice when a UDP server disappears. Signed-off-by: Edmund Henniges <eh@emlix.com> Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot: Add fastboot_abort()Sascha Hauer2020-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Add fastboot_abort() to allow aborting the current session. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot: rename usbgadget.fastboot_* variables to fastboot.*Daniel Glöckner2020-08-191-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is nothing USB-specific in the defined usbgadget.fastboot_* variables. Rename them to be usable also for the UDP fastboot transport. The usbgadget.fastboot_function variable is used to define the files and devices accessible with the erase and flash commands. Since "function" is a term from the USB specification and the Fastboot specification uses the term "partition", we rename that variable to "fastboot.partitions". Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | globalvar: Add helper for deprecated variable namesSascha Hauer2020-08-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When globalvars are renamed across releases it's not nice when variables in the persistent environment loose their meaning. This adds a helper function which adds an alias for the old names. When the persistent variables still use the old names then their values are automatically written to variables with the new names. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | usb: Add a slice to usb host controllersSascha Hauer2020-08-191-1/+7
| | | | | | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | net: mdiobus: Add sliceSascha Hauer2020-08-191-23/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | By adding a slice to the mdio bus we make the mdio code safe for being called in a poller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | net: Add a slice to struct eth_deviceSascha Hauer2020-08-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Add ethernet code safe for being called from a poller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | ratp: Switch to workqueuesSascha Hauer2020-08-131-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This switches running barebox commands in ratp to a context where it's safe to do so: In a work queue. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | Add workqueuesSascha Hauer2020-08-132-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some code wants to run arbitrary code in the background, examples are fastboot and ratp. Currently this is implemented in pollers. The problem with this is that pollers are executed whenever is_timeout() is called which may happen anywhere in the code. With this we can never tell which resources are currently in use when the poller is executed. This adds a work queue interface which is specifically designed to trigger doing work in a context where it's safe to run arbitrary commands. Code in pollers can attach work to a work queue which is at that time only queued up. A new slice, the command slice, is added which by default is acquired. It is only released at places where the shell waits for input. When during this time pollers are executed the queued up works are done before running the registered pollers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | Introduce slicesSascha Hauer2020-08-131-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | slices, the barebox idea of locking barebox has pollers which execute code in the background whenever one of the delay functions (udelay, mdelay, ...) or is_timeout() are called. This introduces resource problems when some device triggers a poller by calling a delay function and then the poller code calls into the same device again. As an example consider a I2C GPIO expander which drives a LED which shall be used as a heartbeat LED: poller -> LED on/off -> GPIO high/low -> I2C transfer The I2C controller has a timeout loop using is_timeout() and thus can trigger a poller run. With this the following can happen during an unrelated I2C transfer: I2C transfer -> is_timeout() -> poller -> LED on/off -> GPIO high/low -> I2C transfer We end up with issuing an I2C transfer during another I2C transfer and things go downhill. Due to the lack of interrupts we can't do real locking in barebox. We use a mechanism called slices instead. A slice describes a resource to which other slices can be attached. Whenever a slice is needed it must be acquired. Acquiring a slice never fails, it just increases the acquired counter of the slice and its dependent slices. when a slice shall be used inside a poller it must first be tested if the slice is already in use. If it is, we can't do the operation on the slice now and must return and hope that we have more luck in the next poller call. slices can be attached other slices as dependencies. In the example above LED driver would add a dependency to the GPIO controller and the GPIO driver would add a dependency to the I2C bus: GPIO driver probe: slice_add(&gpio->slice, i2c_device_slice(i2cdev)); LED driver probe: slice_add(&led->slice, gpio_slice(gpio)); The GPIO code would call slice_acquire(&gpio->slice) before doing any operation on the GPIO chip providing this GPIO, likewise the I2C core would call slice_acquire(&i2cbus->slice) before doing an operation on this I2C bus. The heartbeat poller code would call slice_acquired(led_slice(led)) and only continue when the slice is not acquired. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/mmc' into masterSascha Hauer2020-09-252-1/+3
|\ \ \ \
| * | | | globalvar: add globalvar_set functionRouven Czerwinski2020-09-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of overwriting the whole hierarchy beneath a globalvar, the globalvar_set function only sets the specific globalvar. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | mci: fix wrong sd/mmc/emmc card size computation for arch where char is signedYann Sionneau2020-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | char type can be either signed or unsigned according to C standard. If your arch has signed char, this kind of computation will end up wrong because of sign extension: https://git.pengutronix.de/cgit/barebox/tree/drivers/mci/mci-core.c#n869 mci->capacity = mci->ext_csd[EXT_CSD_SEC_COUNT] << 0 | mci->ext_csd[EXT_CSD_SEC_COUNT + 1] << 8 | mci->ext_csd[EXT_CSD_SEC_COUNT + 2] << 16 | mci->ext_csd[EXT_CSD_SEC_COUNT + 3] << 24; Turning the ext_csd field into u8 * fixes the issue. Signed-off-by: Yann Sionneau <ysionneau@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | mci: mci-core: add GPP supportJuergen Borleis2020-09-141-0/+1
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | General Purpose Partitions (GPP) are hardware partitions like the boot partitions. And like the boot partitions they are limited to MMCs only. Most applications running an eMMC do not use GPPs, so this feature can be disabled. Signed-off-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/misc' into masterSascha Hauer2020-09-258-8/+72
|\ \ \ \
| * | | | clk: Add clk_bulk_[get|put]_all()Sascha Hauer2020-09-241-0/+46
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>