summaryrefslogtreecommitdiffstats
path: root/drivers
Commit message (Collapse)AuthorAgeFilesLines
* video: add simplefb driverAhmad Fatoum2021-03-014-2/+158
| | | | | | | | | | | | barebox has support to fix up a framebuffer it has set up as simplefb into the device tree of a kernel it boots. Add the counterpart to this, so barebox itself can reuse an already set up frame buffer. This is done to support the framebuffer device on the tinyemu RISC-V machine. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: fix mismatching argument to printf format specifierAhmad Fatoum2021-03-012-2/+2
| | | | | | | | | | | %pad prints a DMA address out of a pointer to dma_addr_t. Casting the dma_addr_t itself to void *, will lead to printf dereferencing it and printing the first sizeof(dma_addr_t). The dwc2 driver is the only one using %pad. Fix it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: cfi-flash: fail gracefully instead of crashing on NULL pageAhmad Fatoum2021-03-011-0/+4
| | | | | | | | | Until this is fixed, add a comment and have the driver return with an error instead of crashing on null pointer dereference if it's mapped to zero. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: fdt: Add root name checks during unflatteningSascha Hauer2021-02-231-2/+13
| | | | | | | | In a valid dtb the root node must have an empty name. Also, every other node name must be non empty. Add additional checks for this for better protection against invalid dtbs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/virtio'Sascha Hauer2021-02-2218-1/+1659
|\
| * block: add VirtIO block device driverAhmad Fatoum2021-02-224-0/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this driver enabled, -device virtio-blk-device can now be passed to Qemu for barebox to detect a VirtIO block device mapping a host file or block device. If barebox is passed as argument to the Qemu -kernel option, no device tree changes are necessary. Example: $ qemu-system-arm -m 256M -M virt -nographic \ -kernel build/images/barebox-dt-2nd.img \ -device virtio-rng-device \ -drive if=none,file=/tmp/first.hdimg,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -drive if=none,file=/tmp/second.hdimg,format=raw,id=hd1 \ -device virtio-blk-device,drive=hd1 Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * serial: add basic VirtIO console driverAhmad Fatoum2021-02-223-0/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this driver enabled, -device virtio-serial-device can now be passed to Qemu for barebox to detect a VirtIO console device. If barebox is passed as argument to the Qemu -kernel option, no device tree changes are necessary. Example: $ qemu-system-arm -m 256M -M virt -nographic \ -kernel build/images/barebox-dt-2nd.img \ -device virtio-serial-device \ -chardev socket,path=/tmp/foo,server,nowait,id=foo \ -device virtconsole,chardev=foo,name=console.foo Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hw_random: add VirtIO RNG driverAhmad Fatoum2021-02-223-0/+128
| | | | | | | | | | | | | | | | | | | | With this driver enabled, -device virtio-rng-device can now be passed to Qemu for barebox to detect a VirtIO RNG device. If barebox is passed as argument to the Qemu -kernel option, no device tree changes are necessary. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drivers: add support for memory-mapped VirtIO paravirtualizationAhmad Fatoum2021-02-227-0/+1210
| | | | | | | | | | | | | | | | | | | | | | Sandbox is only useful to test barebox in isolation. For interaction between barebox and firmware/OS, Qemu is the better choice. Qemu supports specifying VirtIO devices on the command line, which it automatically fixes up into the device tree. This is nice. Add support for that. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * driver: Don't throw an error on probes that didn't find the deviceAhmad Fatoum2021-02-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | As the name suggests, determining that a device doesn't match is a valid thing for probe to do. Unlike Linux, we throw an error in that case. This will becomes annoying if we start probing virtio-mmio devices, because Qemu registers a bunch and only assigns functions on demand. Thus don't print an error message for ENXIO and ENODEV like Linux does. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/usb'Sascha Hauer2021-02-228-60/+25
|\ \
| * | usb: imx: add overcurrent polarity handling on i.MX6Michael Grzeschik2021-02-041-1/+8
| | | | | | | | | | | | | | | Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: imx: fix overcurrent polarity handling on i.MX7Michael Grzeschik2021-02-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | The reference manual says the overcurrent polarity is changed to low with the bit set. We fix that according to the description. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: remove duplicated usb_host_detect() callsAhmad Fatoum2021-02-016-56/+0
| | | | | | | | | | | | | | | | | | | | | | | | With the last patch adding a fallback detect, we no longer need the duplication in the host controller drivers. Drop them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: add fallback ->detect method for USB host driversAhmad Fatoum2021-02-011-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already maintain a list of USB host controllers, so we can use that to implement a generic detect callback. Currently, all drivers define their own, which uses driver-specific means to arrive at the struct usb_host and then call usb_host_detect(). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/sound'Sascha Hauer2021-02-2211-14/+521
|\ \ \
| * | | sound: add gpio-beeper supportAhmad Fatoum2021-02-083-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for simple gpio-beepers. Note that unlike with PWM buzzers, GPIO buzzers can't be controlled in frequency and thus it doesn't make much sense to use the multiple argument version of beep with them. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | sound: add PWM beeper supportAhmad Fatoum2021-02-083-0/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver can be used to drive a piezo-buzzer attached to a PWM. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | sound: add SDL 2.0 sound driverAhmad Fatoum2021-02-083-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SDL 2.0.4 features SDL_QueueAudio, which we could use to just queue buffers for audio playback. Use it to implement the new sound API for the sandbox architecture. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | sound: add basic synthesizers for PCM beeper useAhmad Fatoum2021-02-083-1/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For beeping on PCM sound cards, barebox will need to synthesize samples. Add basic sine and square wave synthesizers to achieve this. Client code can either call __synth_F to explicitly select synth F or synth_F, which depending on CONFIG_SYNTH_SQUARES may expand to either __synth_F or a gain-adjusted __synth_generate_square. The latter is mainly useful for slow systems that can't synthesize enough sine samples in a poller without impacting boot performance. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | drivers: add sound card driver supportAhmad Fatoum2021-02-085-0/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add driver core boilerplate for sound support in barebox. Using the provided API in <sound.h>, consumers can play beeps for a fixed duration of time. Playing beeps is not blocking and new beeps can be enqueued while one is already playing. They will be played in succession by a poller, which will also turn off the sound card when the beep tune is over. API is also available for blocking until all beeps are played and for cancelling an underway beep tune. The API could be later extended for arbitrary PCM audio, should the need arise. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | sandbox: migrate to SDL 2.0Ahmad Fatoum2021-02-082-14/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SDL 2.0 has been released more than 7 years ago and should be available everywhere. Replace barebox's SDL 1.2 with SDL 2.0 instead: - better maintained - At least on Debian, you can't install x86_64 and i386 libsdl-dev at the same time, which makes a quick use of CONFIG_SANDBOX_LINUX_I386 harder as the user needs to reinstall libraries. With SDL 2.0, it works - SDL 2.0 has easier audio API, which will be used in a later commit - Wayland support for sandbox video driver Port to SDL 2.0 and as we touch everything anyway, rename the sdl_ functions to start with sdl_video_ to differentiate from upcoming sdl_sound_. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/nvmem'Sascha Hauer2021-02-221-9/+4
|\ \ \ \
| * | | | nvmem: make id optional for of_nvmem_device_get()Marco Felsch2021-01-191-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Port upstream linux commit 8<---------------------------------------------------------------------- commit d4e7fef1a9a5d2bf3f859ba9f50f4d5409a09ab0 Author: Alban Bedel <albeu@free.fr> Date: Mon Jan 28 15:55:03 2019 +0000 nvmem: core: Properly handle connection ID in of_nvmem_device_get() of_nvmem_device_get() would crash if NULL was passed as a connection ID. Rework this to use the usual sementic of assuming the first connection when no connection ID is given. Furthermore of_nvmem_device_get() would return -EINVAL when it failed to resolve the connection, making it impossible to properly implement an optional connection. Return -ENOENT instead to let the caller know that the connection doesn't exists. Signed-off-by: Alban Bedel <albeu@free.fr> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 8<---------------------------------------------------------------------- Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | nvmem: make nvmem_device_write/read publicMarco Felsch2021-01-191-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Those functions already export their symbols so make it public available. Compared to the nvmem_device_cell_read/write() APIs these functions are a bit easier to use. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | Merge branch 'for-next/mtd'Sascha Hauer2021-02-221-2/+4
|\ \ \ \ \
| * | | | | mtd: nand: Fix BBT update issueYoshio Furuyama2021-02-171-2/+4
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue of manages BBT (Bad Block Table). It didn't mark correctly when a specific block was bad block. This issue occurs when the bad block mark (3-bit chunk) is crosses over 32 bit (e.g. Block10, Block21...) unit. Signed-off-by: Yoshio Furuyama <ytc-mb-yfuruyama7@kioxia.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | Merge branch 'for-next/misc'Sascha Hauer2021-02-223-23/+80
|\ \ \ \ \
| * | | | | usb: otg: Add support to register more than one otg devJules Maselbas2021-02-181-20/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allow each otg controller to register one otg device for host/peripheral mode switch. The first otg device registered "otg0" will also be aliased by "otg" for compatibility. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | watchdog: Print seconds to expireSascha Hauer2021-02-161-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a parameter to the watchdog devices that shows what we think when the watchdog expires. The watchdog should reset the system once the counter hits zero. When the system resets earlier or the counter shows negative values then there might be problems with the watchdog. Useful for debugging watchdog related problems. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | of: overlay: split debug messages for of_overlay_apply_symbolsMarco Felsch2021-01-191-3/+8
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Overlays don't need to have __symbols__ therefore it shouldn't be printed on info level. Move it to debug so interested users can print it still. I also fixed a minor alignment issue while on it. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | Merge branch 'for-next/imx'Sascha Hauer2021-02-221-1/+1
|\ \ \ \ \
| * | | | | drivers: smc911x fix inverted wait_on_timeoutMike Nawrocki2021-02-011-1/+1
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The smc911x driver probe routine polls the READY bit using wait_on_timeout, which returns 0 on success. The error check following the wait_on_timeout invocation in the probe routine interprets a returned 0 as failure. This patch correctly interprets the return value of wait_on_timeout. Signed-off-by: Mike Nawrocki <michael.nawrocki@gtri.gatech.edu> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | Merge branch 'for-next/ext4'Sascha Hauer2021-02-228-65/+66
|\ \ \ \ \
| * | | | | usb: storage: support USB disks up to 2TiB of sizeAhmad Fatoum2021-02-181-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SCSI Read Capacity (10) only supports up to 0xFFFF_FFFF sectors at most, which at 512 bytes per sector equals a disk size of 2 TiB. Due to barebox block layer limits, however, the barebox mass storage driver doesn't address sectors that need more than 31 bits to describe. These block layer limits were removed in a previous commit, so make the USB driver use the full 32 bit to support 512-byte sector USB disks up to 2 TiB of size. Disks that are larger than that must either implement SCSI Read Capacity (16) to support up to 16 Exabytes or increase the sector size beyond 512 bytes. This commit doesn't do that as I don't have the suitable hardware to test. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | block: use 64-bit types for sector offset and count on all platformsAhmad Fatoum2021-02-188-62/+62
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox' use of int for the sector offset puts an upper bound of 1TB on the size of supported block devices, which is already exceeded by common place USB mass storage. Increasing the sizes involved to 64 bit like Linux does won't magically add missing driver support, but it gives us at least a fighting chance. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | Merge branch 'for-next/dfu'Sascha Hauer2021-02-221-135/+253
|\ \ \ \ \
| * | | | | usb: gadget: dfu: Wrap fs operation in workqueueJules Maselbas2021-02-161-129/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | File system operation shouldn't be executed in a poller. Use a workqueue to delay filesystem operation to command context. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | usb: gadget: dfu: Rework print messagesJules Maselbas2021-02-161-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace printf with pr_err and debug with pr_debug. Defines "dfu :" as a prefix for formatted prints. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | usb: gadget: dfu: Use func_to_dfuJules Maselbas2021-02-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the uses of container_of with func_to_dfu when available. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | | Merge branch 'for-next/asm-io'Sascha Hauer2021-02-224-23/+16
|\ \ \ \ \ \
| * | | | | | printk: port over Linux print_hex_dump_bytes/print_hex_dump_debugAhmad Fatoum2021-02-044-23/+16
| | |_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | print_hex_dump in barebox always prints a hex dump. Most users use it for debugging though, so import Linux helpers to do so to cut down on the #ifdef DEBUG. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | | Merge branch 'for-next/asm-generic'Sascha Hauer2021-02-2239-39/+39
|\ \ \ \ \ \
| * | | | | | drivers: replaces references to <asm-generic/*.h>Ahmad Fatoum2021-02-193-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With <linux/math64.h> included for do_div instead of <asm-generic/div.h>, there remains only 3 references to asm-generic headers in drivers/. Fix them up. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | | treewide: include <linux/math64.h> wrapper instead of <asm-generic/div64.h>Ahmad Fatoum2021-02-1936-36/+36
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <asm-generic/div64.h> isn't meant for direct usage as <asm/div64.h> may override this on a per-architecture basis. We don't do that currently, but in the future we might. Include the <linux/math64.h> instead. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | | | Merge branch 'for-next/aiodev'Sascha Hauer2021-02-2210-0/+930
|\ \ \ \ \ \ | |/ / / / / |/| | | | |
| * | | | | aiodev: add support for STM32 ADCAhmad Fatoum2021-02-105-0/+645
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver supports simple one-shot readings rather than continuous sampling with DMA, etc. ADC channels should be configured via device tree, using the kernel bindings. Code is based on the stm32-adc drivers of Linux v5.11-rc1 and U-Boot v2021.01-rc4. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | regulator: add driver for stm32-vrefbufAhmad Fatoum2021-02-104-0/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver supports STMicroelectronics STM32 VREFBUF (voltage reference buffer) which can be used as voltage reference for internal ADCs, DACs and also for external components through dedicated Vref+ pin. Ported from Linux v5.11-rc1. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | regulator: add support for struct regulator_desc::off_on_delayAhmad Fatoum2021-02-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already honour the enable time in the device tree, read it out of a new regulator_desc::off_on_delay as well, same as Linux does. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | | | regulator: add regulator_get_voltage() to APIAhmad Fatoum2021-02-101-0/+27
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ADC drivers need to query their reference regulator's voltage to format their raw readings. Provide regulator_get_voltage() so ADC drivers need not hardcode a reference voltage. Regulator drivers that don't support this (i.e. nearly everything in-tree) will have the function return with -EINVAL. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>