summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* power: reset: reboot-mode: fix up node into boot device treeAhmad Fatoum2020-09-292-0/+44
| | | | | | | | | | | | | 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>
* power: reset: reboot-mode: port syscon-reboot-mode supportAhmad Fatoum2020-09-294-0/+108
| | | | | | | | | | Reboot modes are one-shot information that should be valid for only a single reset. Syscons that survive a warm reset are one way to implement this. This is used by many BootROMs to allow falling into a recovery mode on the next boot. This ports the Linux syscon-reboot-mode support. 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-2910-0/+320
| | | | | | | | | | | 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>
* usbgadget: autostart: support delayed usbgadget.autostart=1Ahmad Fatoum2020-09-291-3/+3
| | | | | | | | | | | | | So far, global.usbgadget.autostart=1 from the shell was without effect, because the variable is only evaluated once at postenvironment_initcall. Use the new globalvar_add_bool() to allow acting on the variable being true at any time. This is necessary for scripts that want to enable the usbgadget autostart functionality selectively without themselves hardcoding the particularities of what is exported. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: kasan: migrate Kconfig option to Debugging menuAhmad Fatoum2020-09-292-2/+1
| | | | | | | | UBSAN and ASAN as well as other debugging aids are all in the Debugging menu. Relocate KASAN to be there as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* KASan: Add missing test codeSascha Hauer2020-09-281-0/+478
| | | | | | | Add missing test code. Fixes: 6cd9d2d600 ("Add KASan support") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/protonic' into masterSascha Hauer2020-09-2516-36/+1282
|\
| * ARM: dts: protonic: lanmcu: add uart-has-rtscts to enable rs485 functionalityOleksij Rempel2020-08-241-0/+2
| | | | | | | | | | | | | | | | Without this flag the kernel was ignoring linux,rs485-enabled-at-boot-time property. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: dts: protonic: properly define PHY nodes on lanmcu and plym2m boardsOleksij Rempel2020-08-242-2/+28
| | | | | | | | | | Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: dts: protonic: lanmcu: use UART_CTS instead of GPIO based CTSOleksij Rempel2020-08-241-4/+2
| | | | | | | | | | | | | | | | Sync it with Protonic PLYBAS board to have same, reproducible behavior on all boards. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: dts: protonic: add fixed clock for the FEC nodeOleksij Rempel2020-08-242-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add fixed clock for the FEC nodes to workaround HW TX checksum issues in case a PHY is used as the clock source for RMII connection. By default the FEC node is using 3 clock sources, one of which is named "ptp" clock. If ptp clock has same source as "enet_ref" clock, then the ENET_REF_CLK input will become output. See [1]. The default configuration will work only if iMX is the clock provider for the PHY chip. In case PHY has own XTAL, then the PHY should be used as clock provider for the iMX/FEC. In case "ptp" clock is removed, the PHY clock will be used and most of communication will work as expected. But will trigger other issue - the HW generated checksums for UDP and TCP packets will be zero. It is kernel specific issue, not reproducible on barebox. Since, currently, most of PHY drivers are not defined as clock provider, we should define dummy fixed clock and use it. This workaround is used in some other devicetrees [2]. But it may imply the next hidden issue - the PHY can be suspended, reseted or reconfigured any time and this may add clock glitches on the ENET_REF_CLK line and put FEC in undefined state. [1] https://elixir.bootlin.com/linux/latest/source/arch/arm/mach-imx/mach-imx6q.c#L164 [2] https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/imx6dl-eckelmann-ci4x10.dts#L300 Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: dts: protonic: lanmcu: add eMMC partition tableOleksij Rempel2020-08-241-3/+13
| | | | | | | | | | | | | | | | | | Since this board do not including imx6qdl-prti6q.dtsi, it will not get partition table which was added for other Protonic boards. So, add it separately. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: dts: imx6q-prti6q: add pstore/ramoops nodeOleksij Rempel2020-08-241-0/+11
| | | | | | | | | | Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: dts: unify barebox and barebox, env partitions for all Protonic boardsOleksij Rempel2020-08-246-23/+83
| | | | | | | | | | Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: protonic-imx6: port Protonic specific board codeOleksij Rempel2020-08-242-0/+1035
| | | | | | | | | | Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: of_device_get_match_compatible() helperOleksij Rempel2020-08-242-0/+18
| | | | | | | | | | | | | | | | | | 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-242-0/+19
| | | | | | | | | | | | | | 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-242-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * of: base: register DT root as deviceOleksij Rempel2020-08-241-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A usual board file contains at least one of_machine_is_compatible(). Some of the have a rather long list with complicated version logic. To avoid own implementation for driver management, register the root node of device tree as platform device. So, the main platform bus can attach proper board driver. After this patch a typical board.c file can reuse existing driver infrastructure. After this patch, you will be able to see all registered board drivers with drvinfo as fallow: ... board-embest-riot board-protonic-imx6 machine ... With devinfo, you'll be able to get some board specific information, if this is implemented: barebox@Protonic PRTI6Q board:/ devinfo machine Driver: board-protonic-imx6 Bus: platform Parameters: boardid: 0 (type: uint32) boardrev: 1 (type: uint32) Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/powerpc' into masterSascha Hauer2020-09-2525-119/+59
|\ \
| * | powerpc: Add function prototypes for exception handlersSascha Hauer2020-09-151-0/+8
| | | | | | | | | | | | | | | | | | | | | The exception handlers lead to -Wmissing-prototypes warnings. Add prototypes for them to avoid these warnings. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | powerpc: Remove unused functionsSascha Hauer2020-09-154-90/+0
| | | | | | | | | | | | | | | | | | | | | Some functions are unused in the code base and do not have a prototype in any header file. Remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | powerpc: Add prototypes for functions called from assemblySascha Hauer2020-09-154-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | Some functions are called from assembly only. There's no prototype for them so this leads to -Wmissing-prototypes warnings. Add a prototype right aboce the functions to avoid these warnings. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | powerpc: Make locally used functions staticSascha Hauer2020-09-159-19/+20
| | | | | | | | | | | | | | | | | | | | | Make only locally used functions static to avoid -Wmissing-prototypes warnings. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | powerpc: Add missing includesSascha Hauer2020-09-157-0/+9
| | | | | | | | | | | | | | | | | | Add missing includes to avoid -Wmissing-prototypes warnings. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | powerpc: Add prototypes to header fileSascha Hauer2020-09-154-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds prototypes of the board specific functions fsl_ddr_board_options() and fsl_ddr_board_info() to a header file. Including this header file from the board files reveals that the prototypes are different across the different implementations, so harmonize them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/net' into masterSascha Hauer2020-09-2537-92/+1797
|\ \ \
| * | | workqueues: Add support for delayed workSascha Hauer2020-09-142-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | | Documentation: Add document about background execution in bareboxSascha Hauer2020-08-193-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With pollers, slices and now workqueues it's time to add some documentation how these things work and how they all play together. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fs: Warn when filesystem operations are called from a pollerSascha Hauer2020-08-193-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | | usb: fastboot: execute commands in command contextSascha Hauer2020-08-191-7/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Long lived commands which also use other resources shouldn't be executed in a poller. Use a workqeue to delay the work to command context. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot net: implement fastboot over UDPEdmund Henniges2020-08-196-0/+612
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: init list head in commonSascha Hauer2020-08-192-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The list of variables can be initialized in common code, no need to do the in the different implementations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot: Add fastboot_abort()Sascha Hauer2020-08-192-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | Add fastboot_abort() to allow aborting the current session. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot: Warn when cb_download is called with file still openSascha Hauer2020-08-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Warn when we are about to open a new download file without having closed the old one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | fastboot: rename usbgadget.fastboot_* variables to fastboot.*Daniel Glöckner2020-08-195-21/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-192-2/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | | net: reply to ping requestsSascha Hauer2020-08-191-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have the network receive function running in a poller we can reasonably well answer to ping requests. Implement this feature. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | usbnet: shorten timeout when polling for receive packetsSascha Hauer2020-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When no packets are coming in we have to wait for usb_bulk_message() to timeout. Since we call net_poll() from a poller we have to wait for this timeout every 10ms when no packets are coming in. Decrease this timeout to not unnecessarily slow down barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | net: Call net_poll() in a pollerSascha Hauer2020-08-193-5/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds calling of net_poll() in a poller. With this we can react to incoming packets like ping requests or fastboot requests. We could change to call net_poll() from a poller exclusively, but this would significantly slow down USB network controllers. As described in the patch these take a long time in the packet receive path. To work around this we keep the networking users call net_poll() at a high rate when they are waiting for incoming packets and only every 10ms we call net_poll() from a poller to get incoming traffic when no networking protocol is actively calling net_poll(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | usbnet: Add sliceSascha Hauer2020-08-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Both the ethernet device and the mdio bus of a USB network controller need the USB bus. Add dependencies to it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | usb: Add a slice to usb host controllersSascha Hauer2020-08-192-6/+14
| | | | | | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | net: mdiobus: Add sliceSascha Hauer2020-08-192-23/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-192-2/+82
| | | | | | | | | | | | | | | | | | | | | | | | Add ethernet code safe for being called from a poller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | net: eth: rename __eth_rx()Sascha Hauer2020-08-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __eth_rx() not only receives packets but also checks the carrier. In the next steps it will also send the queued packets, so rename the function to eth_do_work(). Also return void as the only caller can't do anything with the return value. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | ratp: Switch to workqueuesSascha Hauer2020-08-133-20/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-138-0/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-134-0/+343
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-258-27/+136
|\ \ \ \