summaryrefslogtreecommitdiffstats
path: root/include/asm-generic
Commit message (Collapse)AuthorAgeFilesLines
* asm-generic: include bitio.h from io.hAhmad Fatoum2021-08-231-0/+2
| | | | | | | | | | | | | | This is currently used on ARM and sandbox, but it's relevant for other platforms like x86 as well if driver code wants to make use of the functions defined within. MIPS and PowerPC already defines the symbols, but that's ok because <bitio.h> doesn't override existing macros. This works for MIPS, but not PowerPC, where those aren't macros. Fix that up. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210812121944.4419-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: add initial barebox deep-probe supportMarco Felsch2021-06-251-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The barebox 'deep probe' or 'probe on demand' mechanism is the answer of unwanted -EPROBE_DEFER failures. The EPROBE_DEFER error code was introduced by commit ab3da15bc14c ("base: Introduce deferred probing") and since then it causes a few problems. The error is returned if either the device is not yet present or the driver is not yet registered. This makes sense on linux systems where modules and hot-plug devices are used very often but not for barebox. The module support is rarely used and devices aren't hot pluggable. The current barebox behaviour populates all devices before the drivers are registered so all devices are present during the driver registration. So the driver probe() function gets called immediately after the driver registration and causes the -EPROBE_DEFER error if this driver depends on an other not yet registered driver. To get rid of the EPROBE_DEFER error code we need to reorder the device population and the driver registration. All drivers must be registered first. In an ideal world all driver can be registered by the same initcall level. Then devices are getting populated which causes calling the driver probe() function but this time resources/devices are created on demand if not yet available. Dependencies between devices are normally expressed as references to other device nodes. With deep probe barebox provides helper functions which take a device node and probe the device behind that node if necessary. This means instead of returning -EPROBE_DEFER, we can now make the desired resources available once we need them. If the resource can't be created we are returning -ENODEV since we are not supporting hot-plugging. Dropping EPROBE_DEFER is the long-term goal, avoid initcall shifting is the short-term goal. Call it deep-probe since the on-demand device creation can create very deep stacks. This commit adds the initial support for: spi, i2c, reset, regulator, gpio and clk resource on-demand creation. The deep-probe mechanism must be enabled for each board to avoid breaking changes using deep_probe_enable(). This can be changed later after all boards are converted to the new mechanism. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-8-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-10-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* initcall: add of_populate_initcallMarco Felsch2021-06-251-0/+1
| | | | | | | | | | | Add dedicated initcall for of_probe() which is required for the following device-on-demand/deep-probe mechanism. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-7-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-9-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/asm-io'Sascha Hauer2021-02-221-0/+55
|\
| * asm-generic: define fallback memcpy and memset for device I/OAhmad Fatoum2021-02-041-0/+55
| | | | | | | | | | | | | | | | | | The Atmel quadspi driver makes use of the memcpy_(to|from)io, but we don't define them on all platforms. Fix this to allow for easier porting of kernel code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | include: asm-generic: don't do 64-bit soft division on 64-bit platformsAhmad Fatoum2021-02-191-1/+215
|/ | | | | | | | | | | | | barebox implements do_div() as soft division unconditionally, even on 64-bit platforms that could use hardware 64-bit division directly. Import the whole Linux asm-generic/div64.h header to avoid this. This also has potential positive effect on 32-bit platforms: 64-bit division with constant divisors can now be optimized into multiplications and shifts at compile time. 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>
* Merge branch 'for-next/net' into masterSascha Hauer2020-09-251-0/+13
|\
| * 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>
* | Add constructor supportSascha Hauer2020-09-182-0/+15
|/ | | | | | | Call constructors (gcc-generated initcall-like functions) during barebox start. Constructors are e.g. used for kasan initialization. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* module: Implement HAVE_MOD_ARCH_SPECIFICDavid Dgien2020-07-011-0/+49
| | | | | | | | | | Implement HAVE_MOD_ARCH_SPECIFIC Kconfig and module_frob_arch_sections() function prototype from Linux module subsystem. module_frob_arch_sections() should be implemented by any architecture that selects HAVE_MOD_ARCH_SPECIFIC, and is called from load_module() Signed-off-by: David Dgien <dgienda125@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: bitops: fix dead increment in fls() and ffs()Ahmad Fatoum2020-06-032-6/+2
| | | | | | | | Static analyzers trip over this dead increment. It arguably doesn't improve readability, so just drop the dead code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: <asm-generic/atomic.h>: remove stub IRQ save/restoreAhmad Fatoum2020-06-031-26/+0
| | | | | | | | | | For an architecture to use <asm-generic/atomic.h>, it must define local_irq_save() and local_irq_restore(). Instead of having every platform define duplicate their stub definition, just drop them altogether, so <asm-generic/atomic.h> can be used freestanding. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: atomic.h: move generic implementation to asm-genericAhmad Fatoum2020-06-031-0/+99
| | | | | | | | | For easier code-sharing, the UBIFS code still uses the Linux atomic accessors. Make porting it to sandbox easier, by providing these functions for all platforms. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all archsAhmad Fatoum2020-06-031-0/+145
| | | | | | | | | These U-Boot style bitwise operations macros will be needed for COMPILE_TEST-compiled drivers on platforms except for ARM. Add fallback definitions there, based on the ARM ones. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common.h: move the generic IOMEM definition to asm-generic/io.hMasahiro Yamada2020-05-051-0/+4
| | | | | | | | | | | arch/mips/include/asm/io.h defines arch-specific IOMEM(). The generic definition of IOMEM() should go to asm-generic/io.h because it is a collection of fallback defaults when there is no specific definition in <asm/io.h>. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: add optee early loading functionRouven Czerwinski2020-01-301-2/+2
| | | | | | | | | | | | | | | | | | | Add a OP-TEE early loading function which expects a pointer to a valid tee binary and the device tree. OP-TEE will then be started and barebox will continue to run in normal mode. The function start_optee_early should be used in a boards lowlevel.c file. Ensure that barebox has been relocated and a proper c environment has been setup beforehand. Depending on the OP-TEE configuration, the fdt will be modified. If the internal barebox device tree is passed, OP-TEE will overwrite barebox PBL memory during this modification. Copy the fdt to a save memory location beforehand to avoid a corruption of barebox PBL memory. This also moves the OP-TEE Kconfig symbols into a separate menu. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: align RO_DATA_SECTION membersLucas Stach2019-12-201-0/+11
| | | | | | | | | | | | When using the RO_DATA_SECTION macro, all the individual components are put into the rodata section. As they now end up in the same section there is no alignment enforced between them anymore. This leads to unaligned start pointers when any of the components have a unaligned size. Enforce some alignment between them. Fixes: c5d38e920101 (lds: Add and use RO_DATA_SECTION macro) Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: zynq: move header generation to zynq_mkimageLucas Stach2019-11-111-2/+1
| | | | | | | | | | Instead of generating a suitable image header with linker magic, move all of this into zynq_mkimage. The configuration file format and parsing is based on imx-image. This gets us one step further on the road to proper multi-image support. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rsa: Allow to directly compile in rsa public keysSascha Hauer2019-10-151-0/+6
| | | | | | | | | | | | | So far we relied on the U-Boot mkimage tool to generate us device tree snippets containing rsa public keys which we then compiled into barebox. Make this easier and allow to directly specify a filename or PKCS#11 URI in Kconfig. With this we no longer need the U-Boot mkimage tool here and no more external steps to prepare device tree snippets. With this rsa public keys can be directly compiled as C structs into barebox which is much more direct than putting it into the device tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: Add and use RO_DATA_SECTION macroSascha Hauer2019-10-141-0/+11
| | | | | | | | | We have many different pointer arrays which we put into linker sections and each time there's one added we have to adjust all linker scripts. This adds a common RO_DATA_SECTION define and uses it for all architectures. This makes it easier to add a new linker array. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: remove more unnecessary alignmentsSascha Hauer2019-10-141-2/+0
| | | | | | | | The alignment in the DTB and clk_of_table shouldn't be needed. Remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* lds: create and use BAREBOX_PCI_FIXUP macroSascha Hauer2019-10-141-0/+15
| | | | | | | No need to repeat the pci fixup sections in each linker script. Add a define for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: Move start/end address variables into definesSascha Hauer2019-10-141-12/+28
| | | | | | | | | | | For the older section defines we specify the start and end addresses outside the macro which means we have to repeat them in each linker script. Make the start/end addresses part of the define to simplify things. While at it, add a BAREBOX_ prefix to the INITCALLS and EXITCALLS macros for consistency to the other defines. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* barebox.lds: Remove unnecessary bracesSascha Hauer2019-10-141-2/+2
| | | | | | | The BAREBOX_CLK_TABLE and BAREBOX_DTB macros are defines that do not take a parameter, so we can remove the braces. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sections: fix macro for barebox_pbl_sizeRouven Czerwinski2019-08-071-2/+2
| | | | | | | | | On ARM64 this did not contain the expected barebox_pbl size. Rework this to be a substraction between __piggydata_start and __image_start, which should cover the whole PBL. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Initial OP-TEE supportSascha Hauer2019-06-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | This adds initial support for OP-TEE, see https://www.op-tee.org/ barebox starts in secure mode as usual. When booting a kernel the bootm code also loads the optee_os binary. Instead of jumping into the kernel barebox jumps into the optee_os binary and puts the kernel execution address into the lr register. OP-TEE then jumps into the kernel in nonsecure mode. The optee_os binary is passed with the -t option to bootm or with global.bootm.tee. Optionally OP-TEE can be compiled into barebox using the builtin firmware feature. Enable the Kconfig option and place or link your tee binary as optee.bin into the firmware directory. The amount of SDRAM which is kept free for OP-TEE is configurable. This patch was tested on a i.MX6 Nitrogen6x board. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: implement generic command supportAleksander Morgado2018-03-011-0/+2
| | | | | | | | | | | | | | | | | | | The RATP implementation now allows executing generic commands with a binary interface: binary requests are received and binary responses are returned. Each command can define its own RATP request contents (e.g. to specify command-specific options) as well as its own RATP response contents (if any data is to be returned). Each command is associated with a pair of numeric unique request and response IDs, and for easy reference these IDs are maintained in the common ratp_bb header. Modules may override generic implemented commands or include their own new ones (as long as the numeric IDs introduced are unique). Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* asm-generic: partially sync io.h with linux kernelOleksij Rempel2017-09-081-28/+217
| | | | | Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: start: Fix image size calculationSascha Hauer2017-02-081-1/+2
| | | | | | | | | | In barebox_non_pbl_start() we do not run at the address we are linked at, so we must read linker variables using ld_var(). Since ld_var() current is not available on arm64 we create two zero sized arrays, one at the begin of the image and one at the end. The difference between both is the image size we are looking for. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubifs'Sascha Hauer2016-04-081-0/+260
|\
| * ARM: Add atomic.h from u-boot v2016.03Alexander Stein2016-04-081-0/+260
| | | | | | | | | | | | | | | | atomic-long.h: * Replace __UBOOT__ with __BAREBOX__ Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: i.MX: remove unused imx-flash-header.hSascha Hauer2016-04-011-6/+1
|/ | | | | | | All i.MX images are nowadays built with the imx-image tool, so we do not need the header files and Kconfig options anymore. Remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: add RSA supportSascha Hauer2016-01-261-0/+5
| | | | | | | Taken from U-Boot and adopted to barebox with little changes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* gpio: Drop asm-generic/gpio.hSascha Hauer2015-08-201-9/+0
| | | | | | | | | | Since we no longer have custom gpio function prototypes we can drop the prototypes from asm-generic/gpio.h can add them to include/gpio.h instead. While at it add static inline dummy wrappers for !CONFIG_GENERIC_GPIO so that code using gpios can compile without gpio support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: Add exitcall infrastructureHerve Codina2015-07-131-0/+9
| | | | | | | | exitcall infrastructure is based on initcall infrastructure. It allows to have and use exit call hooks on barebox shutdown. Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* clk: of: fix clk_of_table generationSascha Hauer2015-06-111-1/+2
| | | | | | | | | | | | | | We used to collect all sections beginning with __clk_of_table_ in a single section in the linker using KEEP(*(.__clk_of_table_*)). That the sentinel entry ended up as the last entry was pure luck, but not always the case. Instead of putting all entries in different sections we now put all entries in the same section. Only the sentinel entry gets its own section and is collected by the linker separately. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Andreas Willig <andreas.willig@rafi.de> Tested-by: Andreas Willig <andreas.willig@rafi.de>
* Merge branch 'for-next/posix_types'Sascha Hauer2015-06-093-23/+91
|\
| * introduce generic posix_types.hSascha Hauer2015-06-031-0/+90
| | | | | | | | | | | | | | | | | | Most types defined in posix_types.h are architecture independent, so instead of repeating this for each architecture add a generic file that can be used by architecture code. To use it an architecture must define BITS_PER_LONG properly in asm/bitsperlong.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drop __BITS_PER_LONGSascha Hauer2015-05-222-23/+1
| | | | | | | | | | | | | | | | | | The kernel has __BITS_PER_LONG and BITS_PER_LONG. The formaer is needed for architectures which support 32bit userspace on a 64bit kernel. This is not relevant for barebox, so drop __BITS_PER_LONG and use BITS_PER_LONG only. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | startup: introduce postenvironment_initcallSascha Hauer2015-05-151-1/+3
|/ | | | | | | | To allow init code that depends on the environment being loaded. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* base: Introduce deferred probingSebastian Hesselbarth2015-04-171-0/+1
| | | | | | | | | As expected, we would need deferred probing sooner or later. This is a first approach to allow devices to return -EPROBE_DEFER and get sorted into a list of deferred devices that will be re-probed later. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: hmac: move register to hmacJean-Christophe PLAGNIOL-VILLARD2015-03-271-1/+2
| | | | | | | | | | As we will use the best sha algo at runtime Add a new init level crypto_initcall to ensure that all the sha present before hmac Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* asm-generic/bug.h: move BUG(), BUG_ON(), WARN(), WARN_ON() macrosMasahiro Yamada2015-01-291-0/+37
| | | | | | | | In Linux, these macros are defined in include/asm-generic/bug.h. To tidy up common.h, move BUG(), BUG_ON(), WARN(), WARN_ON() there. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpio: move gpio_is_valid to include/gpio.hSascha Hauer2014-11-281-11/+0
| | | | | | | | No architectue implements its own gpio_is_valid() function, so move the only existing implementation to include/gpio.h where it's available for all users. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2014-08-071-0/+15
|\ | | | | | | | | Conflicts: lib/Makefile
| * include: update bitop functions from kernelSascha Hauer2014-07-171-0/+15
| | | | | | | | | | | | Updates the bitop functions from v3.16-rc4 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Add support for metadata in barebox imagesSascha Hauer2014-08-071-0/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's often useful to get some information about a barebox image before starting or flashing it. This patch introduces barebox Image MetaData (IMD). When enabled a barebox image will contain a list of tags containing the desired information. We have tags for: - the barebox release (2014.07.0-00160-g035de50-dirty) - the build timestamp (#741 Mon Jul 28 15:08:54 CEST 2014) - the board model the image is intended for - the device tree toplevel compatible property Also there is an additional generic key-value store which stores parameters for which no dedicated tag exists. In this patch it is used for the memory size an image supports. Since there is no fixed offset in a barebox image which can be used for storing the information, the metadata is stored somewhere in the image and found by iterating over the image. This works for most image types, but obviously not for SoC images which are encoded or encrypted in some way. There is a 'imd' tool compiled from the same sources for barebox, for the compile host and for the target, so the metadata information is available whereever needed. For device tree boards the model and of_compatible tags are automatically generated. Example output of the imd tool for a Phytec phyFLEX image: build: #889 Wed Jul 30 16:08:54 CEST 2014 release: 2014.07.0-00167-g6b2070d-dirty parameter: memsize=1024 of_compatible: phytec,imx6x-pbab01 phytec,imx6dl-pfla02 fsl,imx6dl model: Phytec phyFLEX-i.MX6 Duallite Carrier-Board Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* asm-generic: add IO memory accessorsFranck Jullien2014-05-141-0/+12
| | | | | Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Load PBL into SRAMDavid Vincent2014-02-091-0/+13
| | | | | | | | | | This allows to load all the lowlevel init code, including the uncompressor, inside SRAM and not just the bare init part. This is useful when pbl is used as a first-stage bootloader but is loaded by an external firmware. Signed-off-by: David Vincent <freesilicon@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>