9
0
Fork 0
Commit Graph

3685 Commits

Author SHA1 Message Date
Sascha Hauer 79fdb84a6b net: phy: Add fixed link support
Some network devices, especially when connected to a switch, are
connected via a fixed link. This patch adds support for a fixed phy
configured through device tree.
TODO: Add support for the "speed" and "full-duplex" properties.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>
2016-05-09 08:30:28 +02:00
Sascha Hauer f66990af3c bootm: Optionally add a root= option to Kernel command line
It becomes a common case that the Kernel is loaded from the filesystem
which later becomes the rootfs. This adds a possibility to let bootm
automatically append the root= option to the kernel command line. This
is done when global.bootm.appendroot is true.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-04 11:58:46 +02:00
Sascha Hauer 22b8e9415d string: Introduce strtobool
We have at least two places which convert a string to a boolean type,
so create a common function for this. strtobool treats

- any positive (nonzero) number as true
- "0" as false
- "true" (case insensitive) as true
- "false" (case insensitive) as false

Every other value results in an error and the input *val is not
modified. The caller is expected to initialize *val with the correct
default before calling strtobool.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-29 11:29:25 +02:00
Sascha Hauer 941056dad1 globalvar: Allow to remove globalvars
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-29 11:29:25 +02:00
Andrey Smirnov 015ec0a528 PCI: imx6: Add proper i.MX6+ reset sequence
I.MX6+ version of the silicon exposed PCIe core's reset signal as a bit
in one of the control registers. As a result using old, pre-i.MX6+,
reset sequence on i.MX6+ leads to Barebox hanging during startup. Using
exposed reset bit instead solves the problem.

This commit is based on portions of commit

c34068d48273e24d392d9a49a38be807954420ed

in http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:10 +02:00
Andrey Smirnov bd55401e97 OF: Port of_match_device() and of_device_get_match_data()
Port of_match_device() and of_device_get_match_data() from Linux kernel
code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:04 +02:00
Sascha Hauer 893228f66c commands: ubiformat: move code to common/
This is the final step to separate the ubiformat code from the
command. With this the ubiformat code gains a C API.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-26 08:08:25 +02:00
Du Huanpeng fe03b34fbe whole tree: remove trailing whitespaces
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-21 15:17:52 +02:00
Sascha Hauer cb8cf33ce8 fix erasing/protecting flashes with unspecified size
fixes: 81737c1 mtd: Fix erasing of devices >4GiB

Several places erased a complete flash partition passing ~0 as count to
erase(). With the above commit count to erase was changed from an unsigned
type to a signed type, so the (count > f->size - offset) check in
erase() no longer triggers and the ~0 count is no longer adjusted to the whole
device size. Among other things this results in saveenv failures on NOR
flashes.
This patch fixes this by introducing an explicit macro for erasing the
whole device which is tested for in erase(). All other negative values
are rejected.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Giorgio <giorgio.nicole@arcor.de>
2016-04-19 08:26:51 +02:00
Sascha Hauer 158279def1 stdio: Whitespace cleanup
Replace the tabs with spaces before the function names.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:46 +02:00
Sascha Hauer 5559bfd271 stdio: Replace FILE functions with filedescriptor functions
We have defined stdin, stdout and stderr as integer file descriptors,
but normally they should be FILE *. Also fprintf, fputc and fputs take
file descriptors instead of FILE *. As FILE * are inconvenient in the
barebox environment replace the f* functions with the corresponding d*
functions. dprintf is POSIX conform whereas dputc and dputs are barebox
specific, but do not conflict with any stdc function. fgetc is unused
and can be removed without replacing it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:46 +02:00
Sascha Hauer 473d6f8a7a stdio: replace fprintf(stderr,...) with eprintf
We have a shortcut for fprintf(stderr, so use it. This is done to
be able to remove fprintf in the next step.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:46 +02:00
Sascha Hauer 01f8f60cf0 stdio: rename getc to getchar
The function we have implemented as getc has the semantics of the
standard function getchar, so rename it accorgingly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:46 +02:00
Sascha Hauer 70bbeea7b2 fs: move libc function prototypes to their correct locations
This moves the function prototypes in include/fs.h which also exist
in the libc to the locations they would have in libc.

With this it becomes easier to share code between barebox and userspace
since the usual libc include files will exist. Also users of the libc
functions no longer have to include the barebox internal fs.h header.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer e1385b3399 move unlink_recursive declaration to libfile.h
unlink_recursive is a file utility function, so move the prototype to
libfile.h

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer 69858c74b2 move make_directory declaration to libfile.h
As a utility function for file handling make_directory() is well
suited for libfile. Move it there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer 947fb5adf8 string: Fix (v)asprintf prototypes
Our asprintf and vasprintf have different prototypes than the glibc
functions. This causes trouble when we want to share barebox code
with userspace code. Change the prototypes for (v)asprintf to match
the glibc prototypes. Since the current (v)asprintf are convenient
to use change the existing functions to b(v)asprintf.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer 4f17444ecc libfile: move open_and_lseek() to libfile
libfile is a collection of helpers for handling files. open_and_lseek()
is a perfect match for this, so move it there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer db33f32842 include: move crc specific stuff to crc.h
We have a crc.h, so move our crc function prototypes there to further
cleanup common.h.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer 4e9f324d37 include: move shell prototypes to shell.h
We have a shell,h, so move shell specific prototypes there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer 086d0026a0 include/common.h: remove unused struct memarea_info
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer ea5aeb986c include: move run_command prototype to command.h
run_command fits much better into command.h, move it there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer dd8244a422 include: Move ide platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer a45ab7100c include: Move smc911x eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer 044058fe90 include: Move dm9000 eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer 041155f11c include: Move ns16550 serial platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer 51b03f4844 include: Move fec eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer 4fc192f6be include: Move davinci emac platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer 423204c619 include: Move designware eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer a1c43792a5 include: Move smc91111 eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer 472e36c752 include: Move ep93xx eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Du Huanpeng 556459f022 wchar_t: wchar_t should go to stddef.h
according to C99 standard, the definition of wchar_t
should go stddef.h
this patch also remove wchar_t local definition and
use stddef.h instead.

Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-14 08:07:13 +02:00
Du Huanpeng b86834423f NULL: keep NULL definition in stddef.h only
remove other local definition of NULL, use
  #include <linux/stddef.h>
instead.
I use this command to search NULL definition,
  grep -R "define\s*\<NULL\>"
hope there are no more definition of NULL.

from ISO/IEC 9899:TC3:
The macros are
	NULL
which expands to an implementation-defined null pointer constant;

Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-14 08:00:26 +02:00
Sascha Hauer 45ad47a301 Merge branch 'for-next/ubifs' 2016-04-08 13:37:28 +02:00
Sascha Hauer 5a43795272 Merge branch 'for-next/ubiformat' 2016-04-08 13:37:28 +02:00
Sascha Hauer 660fc0ad87 Merge branch 'for-next/mtd-imx-nand' 2016-04-08 13:37:28 +02:00
Sascha Hauer fd50a8d758 Merge branch 'for-next/imx-bbu-nand-fcb' 2016-04-08 13:37:28 +02:00
Sascha Hauer 0d3f88a6db Merge branch 'for-next/imx' 2016-04-08 13:37:28 +02:00
Sascha Hauer 3abbbbd7c3 mtd: nand: export nand_check_erased_buf
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:35:32 +02:00
Sascha Hauer fa61152d97 bbu: Allow to refresh/repair images
Some SoCs allow to store multiple boot images on a device in order to
improve robustness. This adds a -r option to barebox_update to indicate
we do not want to make an update but instead repair/refresh an existing
image. Handlers which want to support this feature must set the
BBU_HANDLER_CAN_REFRESH flag during registration.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:35:32 +02:00
Sascha Hauer 05be903622 mtd: ubi: Add function to get ubi number from mtd device
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:34:45 +02:00
Sascha Hauer ae147875bc mtd: ubi: make ubi_detach_mtd_dev ubi internal
We want to extend the functionality of the ubi detach function,
but we don't want to change the original detach function to make
UBI updates easier. This adds a barebox specific detach function
which encapsulates the original UBI function. Also this makes the
original ubi detach function internal to ubi.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:34:45 +02:00
Markus Pargmann 38eae8b2ca fs: umount based on device path and mount path
umount on Linux can be used on a mount pathes and device pathes. This
patch adds this functionality to barebox.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
2016-04-08 13:34:45 +02:00
Markus Pargmann 0a3795dd0e fs: Add for_each_fs_device_safe()
We need to be able to umount specific filesystems while iterating all of
them. This helper gives us a safe macro to do so.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
2016-04-08 13:34:45 +02:00
Alexander Stein a63059d753 ubifs: update implementation from u-boot v2016.03
This updated code supports recovering from unclean unmounts when write
buffer size is larger than 8. Linux uses takes information into
consideration when checking for writes.
The following list shows the changes for each file done compared to
u-boot v2016.03 code.

Makefile
* Add gc.o, do not include header as in u-boot

budget.c:
* Replace __UBOOT__ with __BAREBOX__

debug.c:
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Replace current->pid with 0

debug.h
* Replace __UBOOT__ with __BAREBOX__
* Add "0 &&" to ubifs_assert condition check
  U-Boot essentially disabled pr_crit output and dump_stack() is defined
  to do { } while (0), so ubifs_assert does nothing despite condition.

gc.c:
* Replace __UBOOT__ with __BAREBOX__

io.c:
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>

key.h:
* No changes

log.c:
* No changes

lprops.c:
* Replace __UBOOT__ with __BAREBOX__

lpt.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Remove #include <ubi_uboot.h>

lpt_commit.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>

master.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Remove #include <ubi_uboot.h>

misc.h
* Replace __UBOOT__ with __BAREBOX__
* Add #ifndef __BAREBOX__ around unneeded ubifs_current_time

orphan.c
* No changes

recovery.c
* Replace __UBOOT__ with __BAREBOX__

replay.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>

sb.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Remove #include <ubi_uboot.h>
* rp_uid and rp_gid are still uid_t, not kuid_t, so remove .val

scan.c
* Replace __UBOOT__ with __BAREBOX__

super.c:
* Replaced current->pid with 0
* Replaced __UBOOT__ with __BAREBOX__
* Removed #include <ubi_uboot.h>
* Removed #include <memalign.h>
* Added #include <init.h>
* Replaced malloc_cache_aligned with kzalloc
* Replaced I_LOCK with I_SYNC
* i_uid and i_gid are still uid_t, not kuid_t, so remove .val
* Replaced string "U-Boot" with "Barebox"
* Add #ifndef __BAREBOX__ around open_ubi, sb_test, sb_set, ubifs_mount,
  kill_ubifs_super, ubifs_fs_type
* Do not call ubi_open_volume or ubi_close_volume in ubifs_fill_super
  Those will already be handled in ubifs_probe
* Replaced uboot_ubifs_mount with new ubifs_get_super implementation using
  existing functions alloc_super, alloc_ubifs_info

tnc.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>

tnc_misc.c
* Replace __UBOOT__ with __BAREBOX__

ubifs-media.h
* Replace __UBOOT__ with __BAREBOX__

ubifs.c:
* Replaced __UBOOT__ with __BAREBOX__
* Adjusted header includes
* Removed DECLARE_GLOBAL_DATA_PTR
* Add static struct z_stream_s variable
* Add struct ubifs_priv delcaration
* Replaced zunzip with deflate_decompress call
* Add ifdef for disabling ZLIB and/or LZO support
* Replaced malloc_cache_aligned with kzalloc
* Added #ifndef __BAREBOX__ around filldir, ubifs_printdir,
  ubifs_set_blk_dev, ubifs_ls, ubifs_exists, ubifs_size, do_readpage,
  ubifs_read, ubifs_close, ubifs_load
* Make parameter filename const char* in ubifs_findfile
* Add UBIFS fs_driver_d implementation
* Add zlib_decomp_init, ubifs_init

ubifs.h:
* Replaced __UBOOT__ with __BAREBOX__
* Adjusted header includes
* Added old #define crc32
* Added helper around kmem*
* Added XATTR_LIST_MAX define
* Added #ifndef __BAREBOX__ around current_fs_time struct inode,
  struct super_block, file_system_type, dentry and friends which barebox
  already has
* Added #ifndef __BAREBOX__ around write_inode in super_operations to avoid
  declaration of writeback_control
* Change rp_uid and rp_gid to uid_t and gui_t
* Added struct device_d to struct ubifs_info
* Added forward declaration of ubifs_get_super

linux/fs.h:
* Make struct inode's i_nlink a union containing a non-const int __i_nlink
  while making i_nlink a const int

linux/fs.h:
* Add s_remove_count

linux/fs.h:
* Convert struct super_block.s_instances and
  struct file_system_type.fs_supers to hlist_head

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein 84abb49171 barebox-wrapper: Add kcalloc and __vmalloc
They call xzalloc and malloc respectively.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein ee87c0e70c barebox-wrapper: Implement kfree and vfree as static inline functions
If kfree/vfree is called where free is a already variable name, code will
not compile.
Also both take a const* in Linux kernel code.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein 5273fb0dd5 Move GFP_NOFS to barebox-wrapper
This will also be used by upcoming UBIFS update.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein 013f33ac3a ARM: Add atomic.h from u-boot v2016.03
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>
2016-04-08 13:33:18 +02:00
Alexander Stein caed8a92bc module.h: Add THIS_MODULE
This is required by upcoming UBIFS update.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein 1b58a97172 compiler*.h: include/linux/compiler*.h with Linux 4.5
Include <linux/types.h> instead of uapi/linux/types.h.

This is required for READ_ONCE and WRITE_ONCE for upcoming atomic_t.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein 0fcefdd936 printk: Add pr_cont
This is needed by upcoming UBIFS update.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein f01ed88aac Add list_sort from u-boot v2016.03
This is required by UBIFS update.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein 97cef90843 printk: Add printk_once
This is needed by upcoming list_sort implementation.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Alexander Stein eb36388c15 rbtree: Update to u-boot v2016.03
This adds (among others) rbtree_postorder_for_each_entry_safe which is
required by the upcoming UBIFS update.
Changes to u-boot source:
* Adding include <module.h> for EXPORT_SYMBOL*

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Sascha Hauer 3bafe5eac5 decompressors: Use malloc/free wrappers
The decompressors are used both in a regular image and also for image
decompression. Both need different malloc implementations. Using
malloc/free directly in the decompressor code easily leads to include
file conflicts, so use MALLOC/FREE which can be defined correctly for
the two different usecases.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:33:18 +02:00
Sascha Hauer 0e4f92570e bbu: print and evaluate image Metadata
With imd we can store metadata in barebox images. Let's use this
information to further verify that the image that is to be flashed
is the correct one. This patch extracts the device tree compatible
from the image and compares it with the one from the currently
running barebox. If it doesn't match the update is aborted with a
warning.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-06 15:41:15 +02:00
Sascha Hauer 1e6955fdb8 commands: Create nand_bitflip command
This adds a command to flip bits in a Nand flash. This is useful for
testing purposes to check if flipped bits are corrected and if the
driver returns the correct number of bitflips.

The command writes a configurable number of bitflips to a single Nand
page. If the -r option is not given the results are reproducible, so
calling the same command twice will revert the bitflips.

The command uses the raw read/write Nand operations which are probably
less tested than the regular read/write operations, so the command may
produce surprising results.

As of writing the command has been tested with the GPMI Nand driver and
the imx-nand driver with fixes posted.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-06 10:17:53 +02:00
Sascha Hauer 81b52d93cb remove now unused libmtd
The only user of libmtd was ubiformat which now uses the mtd-peb API,
so remove the now unused libmtd.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-06 10:17:52 +02:00
Sascha Hauer 1d88c66977 ubiformat: Use mtd-peb API
This changes ubiformat from the libmtd API to the mtd-peb API. This
makes the libmtd API unnecessary and it can be removed in the next
step.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-06 10:17:52 +02:00
Sascha Hauer eef520a32b mtd: Introduce mtd-peb API
Code which properly wants to handle Nand flash has to work
in a block based way since blocks are the entities that are erased or
may become bad. The regular mtd API works based on offsets in the device
which introduces unhandy 64bit arithmetics and the requirement to align
buffers to blocks.
This introduces the mtd peb API (PEB for physical Erase Block) which
allows the users to work in a block oriented way. The API is heavily
inspired by the UBI IO layer and in fact can replace parts thereof
later.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-06 10:17:51 +02:00
Sascha Hauer bf1e795d14 ARM: i.MX: remove unused imx-flash-header.h
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>
2016-04-01 14:06:35 +02:00
Sascha Hauer 7f73e64e8b imd: Add function to read parameters
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-01 10:38:55 +02:00
Sascha Hauer b8837986a0 imd: export functions
To make the image metadata API usable for external users export
some functions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-01 10:38:55 +02:00
Sascha Hauer 9499f30f5e mtd: remove unused debug defines
MTD_DEBUG was only used by the i.MX Nand driver and is now unused.
Remove the mtd specific debug defines.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-17 12:05:48 +01:00
Sascha Hauer fdac29be62 mtd: Introduce mtd_check_pattern
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-15 11:29:27 +01:00
Sascha Hauer 30750ef990 mtd: rename mtd_all_ff -> mtd_buf_all_ff
To make clear this function checks a given buffer and not data on a mtd
device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-15 11:29:27 +01:00
Sascha Hauer 1eee78b580 mtd: Introduce function to get mtd type string
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-15 11:29:26 +01:00
Sascha Hauer 172af2a30c mtd: Add support for marking blocks as good
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-15 08:56:53 +01:00
Sascha Hauer a0fa6e1d2b Merge branch 'for-next/squashfs' 2016-03-11 10:49:50 +01:00
Sascha Hauer 251ae23e9f Merge branch 'for-next/mtd' 2016-03-11 10:49:50 +01:00
Sascha Hauer 034d4ddcb6 Merge branch 'for-next/misc' 2016-03-11 10:49:50 +01:00
Sascha Hauer 690ec1804c Merge branch 'for-next/driver' 2016-03-11 10:49:48 +01:00
Sascha Hauer c41f840f4b Merge branch 'for-next/caam' 2016-03-11 10:49:35 +01:00
Sascha Hauer 330dc0a6b7 Merge branch 'for-next/bbu' 2016-03-11 10:49:35 +01:00
Markus Pargmann 0240fd3f84 fastboot: Add a ARM Barebox filetype handler
This will automatically call barebox_update for the transfered file if
it is an ARM Barebox image and the destination file is defined by some
update handler.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-11 08:06:05 +01:00
Sascha Hauer 568e345d5a mtd: mtd_[read|write|erase]: check for valid input data
mtd_[read|write|erase] are input functions to the mtd subsystem, so
check for valid input data here rather than relying on the drivers doing
this. The checks are copied from the Kernel as of 4.5-rc5

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-04 08:23:06 +01:00
Yegor Yefremov 237abe7bb8 linux/fs.h: add types and routines needed for SquashFS
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-02 19:14:57 +01:00
Yegor Yefremov 196dccdfcf linux/types.h: add sector_t and blkcnt_t types
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-02 19:14:57 +01:00
Teresa Remmet 153c34b347 common: oftree: Add function to register set status fixup
Added a function to register a fixup to enable or disable
device tree nodes.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-01 08:25:42 +01:00
Sascha Hauer 246266c205 serial: imx: Support DTE mode
Based on Kernel commit 20ff2fe60a: serial: imx: add support for DTE mode

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-26 07:54:15 +01:00
Alexander Kurz a7932a35da EP93xx eth: allow passing of phy config via platform data
Passing phy configuration to the ep93xx_eth driver was not supported yet
and will be added with this patch. When no pdata is passed, the probably
broken default of phy_addr = 0 will be used to maintain compatibility
with the previous implementation.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-25 09:42:29 +01:00
Sascha Hauer fe7855bb4f driver: Introduce dev_request_mem_resource
dev_request_mem_region returns a void * which shall be checked with
IS_ERR(), but in some cases the valid pointer returned clashes with
error values. This is especially the case on some Atmel SoCs.

This introduces dev_request_mem_resource which returns a struct resource
instead which in any case can be checked with IS_ERR(). It's the drivers
responsibility then to get the IOMEM pointer from the resource.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-23 08:15:57 +01:00
Markus Pargmann 7290110f1a bbu: Add function to check if an update handler exists
This adds a function to check for the existence of an update handler
based on the supplied bbu_data.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-18 16:10:11 +01:00
Steffen Trumtrar acf6849208 include: linux: add circular buffers
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-12 15:55:55 +01:00
Sascha Hauer 0f1c0c4d30 regmap: Add missing prototype for regmap_exit()
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-12 15:36:54 +01:00
Sascha Hauer 81737c1d43 mtd: Fix erasing of devices >4GiB
When a device >4GiB is erased, not only the offset can be bigger
than 4GiB, but also the size. This happens with the simplest command
to erase a device: erase /dev/nand0. Make the size argument a 64bit
type to make this work.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-09 09:32:29 +01:00
Sascha Hauer 1e009bf266 mtd: Make erase_info structs 64bit where necessary
Make the userspace structs 64bit where necessary. Since we do not have
separated kernel/userspace in barebox we can just modifiy the original
structs instead of adding separate 64bit structs.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-09 09:28:55 +01:00
Sascha Hauer 7482ab4de1 Merge branch 'for-next/regmap' 2016-02-08 08:27:03 +01:00
Sascha Hauer c073534880 Merge branch 'for-next/ratp' 2016-02-08 08:27:01 +01:00
Sascha Hauer a22f59c178 Merge branch 'for-next/net' 2016-02-08 08:26:45 +01:00
Sascha Hauer 1379a5ef1e Merge branch 'for-next/misc' 2016-02-08 08:26:43 +01:00
Sascha Hauer 79606b51ed Merge branch 'for-next/linux-headers' 2016-02-08 08:26:36 +01:00
Sascha Hauer 05261801e9 Merge branch 'for-next/input' 2016-02-08 08:26:35 +01:00
Sascha Hauer 6435fb09d8 Merge branch 'for-next/hab' 2016-02-08 08:26:35 +01:00
Sascha Hauer 7a53e162de Add initial regmap support
This adds initial regmap support. Function prototypes are from
the Kernel, the implemention is mostly rewritten. Currently the
regmap support is limited to the bare minimum to get started.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-05 14:32:16 +01:00
Sascha Hauer 48d74b1ca4 imx: hab: Make hab status functions SoC specific
The HABv4 functions need access a part of the ROM which is
located in the zero page. This must be done early, before the
MMU has been configured and the zero page has been set to faulting.
The HAB functions currently use cpu_is_imxxy(). At the stage where
HAB is called the i.MX CPU type variable is not yet initialized,
so this code only works when only one i.MX type is enabled and
cpu_is_imxxy() are compile time constants.

To fix HAB support when more than one i.MX type is enabled make the
HAB status function SoC specific so that we can drop the use of
cpu_is_imxxy().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-04 14:38:33 +01:00
Andrey Smirnov ae2fb9b918 miitool: Add code to register a PHY
This commit changes the behaviour of the 'miitool'. Now in order to show
PHY's link information 'miitool' should be invoked as such:

miitool -s [PHY]

Also, implment code to allow to register a dummy PHY device in order to
be able to perform raw MDIO bus access.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-04 08:10:39 +01:00
Steffen Trumtrar 7ffff00dfd bitops: Fix shift overflow in GENMASK macros
Based on the original patch for linux:

	commit 00b4d9a14125f1e51874def2b9de6092e007412d
	Author: Maxime COQUELIN <maxime.coquelin@st.com>
	Date:   Thu Nov 6 10:54:19 2014

	On some 32 bits architectures, including x86, GENMASK(31, 0) returns 0
	instead of the expected ~0UL.

	This is the same on some 64 bits architectures with GENMASK_ULL(63, 0).

	This is due to an overflow in the shift operand, 1 << 32 for GENMASK,
	1 << 64 for GENMASK_ULL.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
2016-02-03 17:14:10 +01:00
Andrey Smirnov 109543cf88 mdio_bus: Add mdiobus_get_bus() function
Add mdiobus_get_bus() -- a function to get a MDIO bus by its number

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:58:28 +01:00
Andrey Gusakov 09c56012a4 net: Port bitbanged MDIO code from Linux kernel
Port bitbanged MDIO framework and gpiolib MDIO bus driver that uses it
from Linux kernel.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:58:28 +01:00
Andrey Gusakov 6f1d5dbff0 include/linux/phy.h: Add MII_ADDR_C45
Add MII_ADDR_C45 used by bitbanged MDIO

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:58:28 +01:00
Yegor Yefremov f0c2924100 dcache: add missing linux/list.h include
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:57:36 +01:00
Yegor Yefremov c8b37d4983 fs: import magic.h from Linux kernel
include/linux/magic.h provides MAGIC numbers for various
file systems.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:57:36 +01:00
Yegor Yefremov 0123e9f633 Introduce include/linux/rwsem.h
Move semaphore related definitions to its original place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:57:36 +01:00
Yegor Yefremov 6b8cf28e0c Introduce include/linux/wait.h
Move Linux wait queue related definitions to its original place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:57:36 +01:00
Yegor Yefremov 7814ae61ab Introduce include/linux/mutex.h
Move mutex related defines to its original place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-03 07:57:32 +01:00
Sascha Hauer 8aabf498e1 hab: Add HABv3 status report function
Status reporting for HABv3 is different from HABv4. Add a status
report function for HABv3.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-02 15:41:04 +01:00
Sascha Hauer 2ff23512d9 imx: hab: rename driver dir to hab/
There's not only HABv4 but also HABv3. No need to put the corresponding
code in separate directories, so rename the habv4 directory to hab.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-02 15:41:04 +01:00
Yegor Yefremov baa7fe1d15 Introduce include/linux/spinlock.h
Move spinlock related definitions to its original place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov 7a583dfb4f Introduce include/linux/sched.h
Move cond_resched() from barebox-wrapper.h to its original
place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov 6f332972ef fs: ubifs: move file and file_system_type definitions to linux/fs.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov d20f839037 fs: ubifs: move path definition to include/linux/path.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov 3243c0d236 fs: ubifs: move vfsmount definition to include/linux/mount.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov b456308c4c fs: ubifs: move dcache related definitions to include/linux/dcache.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov 838ca724e7 fs: move pgoff_t definition to include/linux/types.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov 00dd903055 fs: use linux/fs.h for file system related definitions
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
Yegor Yefremov 3b4740b2c1 fs: move PAGE_CACHE definitions to include/linux/pagemap.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-29 08:04:27 +01:00
Yegor Yefremov 489c8ba906 fs: introduce include/linux/fs.h
Move Linux file system structs from UBIFS to central place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-29 08:04:06 +01:00
Yegor Yefremov fa75e4ea25 fs: move struct timespec to include/linux/time.h
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-29 08:04:00 +01:00
Jan Luebbe ac55adb321 bootm: add initial FIT support
This implementation is inspired by U-Boot's FIT support. Instead of
using libfdt (which does not exist in barebox), configuration signatures
are verified by using a simplified DT parser based on barebox's own
code.

Currently, only signed configurations with hashed images are supported,
as the other variants are less useful for verified boot. Compatible FIT
images can be created using U-Boot's mkimage tool.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:42 +01:00
Sascha Hauer ebb1160cdd bootm: make verifying/hashing configurable
So long struct bootm_data.verify is a bool which enables CRC checking
(hashing). Extend this to a enum and add support for signature checking
in the same option. This also adds the corresponding globalvar and a
-s option to bootm.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:42 +01:00
Sascha Hauer 6e686491a5 crypto: add RSA support
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>
2016-01-26 22:45:41 +01:00
Sascha Hauer fedba5aaef crypto: add digest_alloc_by_algo()
In barebox the function digest_alloc() allocates a digest based on a string.
When a subsystem already uses an integer value to identify a digest it makes no
sense to create a string and pass it to digest_alloc(), where it is parsed
again. This patch adds the possibility to get a digest by an enum.

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>
2016-01-26 22:45:41 +01:00
Sascha Hauer bc94fb379a bootm: Initialize bootm_data defaults in single place
Both the bootm and the boot code initialize the struct bootm_data
with defaults from the bootm global variables. Create a common
function for doing this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:40 +01:00
Sascha Hauer aded35ece4 bootm: move initrd code together
The initrd code is distributed in several places in the bootm code.
Move it all together in bootm_load_initrd().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:40 +01:00
Sascha Hauer 0a37e22d63 bootm: use names instead of numbers for image parts
The uImage format uses numbers for to identify the different
parts of a image, but the FIT image format uses names. To better
integrate the FIT image format into bootm always use names and
convert them to numbers when necessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-22 08:15:15 +01:00
Sascha Hauer 0bb6e4c533 bootm: introduce bootm_get_os_size
ARM do_bootm_linux is not only called with uImages but also with
raw images, so we can't use uimage_get_size() here. Introduce
bootm_get_os_size() which handles the different image types.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-22 08:15:15 +01:00
Sascha Hauer 2660573374 barebox remote control
This adds the ability to control barebox over serial lines. The regular
console is designed for human input and is unsuitable for controlling
barebox from scripts since characters can be lost on both ends, the data
stream contains escape sequences and the prompt cannot be easily matched
upon.
This approach is based on the RATP protocol. RATP packages start with a
binary 0x01 which does not occur in normal console data. Whenever a
0x01 character is detected in the console barebox goes into RATP mode.
The RATP packets contain a simple structure with a command/respone
type and data for that type. Currently defined types are:

BB_RATP_TYPE_COMMAND (host->barebox):
	Execute a command in the shell
BB_RATP_TYPE_COMMAND_RETURN (barebox->host)
	Sends return value of the command back to the host, also means
	barebox is ready for the next command
BB_RATP_TYPE_CONSOLEMSG (barebox->host)
	Console message from barebox

Planned but not yet implemented are:

BB_RATP_TYPE_PING (host->barebox)
BB_RATP_TYPE_PONG (barebox->host)
	For testing purposes
BB_RATP_TYPE_GETENV (host->barebox)
BB_RATP_TYPE_GETENV_RETURN (barebox->host)
	Get values of environment variables

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
2016-01-18 09:25:09 +01:00
Sascha Hauer bbdbda0a74 Add Reliable Asynchronous Transfer Protocol
This patch adds support for Reliable Asynchronous Transfer Protocol (RATP)
as described in RFC916.

Communication over RS232 is often unreliable as characters are lost or
misinterpreted. This protocol allows for a reliable packet based communication
over serial lines.

The implementation simply follows the state machine described in the RFC
text with one exception. RFC916 uses a plain checksum for the
transferred data. We decided to use CRC16 for greater robustness. Since
this is the only RFC916 implementation we currently know of interoperability
with other implementations should not matter.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
2016-01-18 09:25:04 +01:00
Sascha Hauer e2306ada3e Convert users of PRINTF_CONVERSION_RESOURCE to %pa
printf now supports printing resource_size_t directly, convert
all users of the previously used PRINTF_CONVERSION_RESOURCE over
to %pa.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-15 15:33:59 +01:00
Sascha Hauer 5ac4b013a3 input: Add device tree parsing support for matrix keymap
Add support for parsing the "linux,keymap" property.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-13 16:28:07 +01:00
Sascha Hauer 6639c98acc input: move matrix_keypad_build_keymap() to C file
Future additions will make the function too big to live as a static
inline function. Move to a C file and while at it, move matrix_keypad.h
to include/input/ where it belongs to.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-13 16:28:06 +01:00
Sascha Hauer 224a08df5d input: Add input core
Currently all input driver register themselves as consoles. Consoles are
fine for typing text, but they do not allow to ask for the current
pressed state of buttons or keypads. They also do not support non
printable keys like the function keys.

This patch adds a simple input core. On the driver side it supports
input_report_key_event() to report events (button presses and releases).
On the consumer side it allows getting the current button status via
input_key_get_status(). Also an event driven interface is available
which calls a callback whenever an input event is received.
The input core also registers a console for all registered input
devices which handles passing events to the console and stuff like key
repetition, so this can be removed from the drivers once they are
converted to the input core.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-13 16:26:05 +01:00
Sascha Hauer cfe4e61df1 keymap: Add keymap for keys with shift pressed
When converting keys to ascii for the console we also need the
keymap with shift pressed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-13 16:23:22 +01:00
Sascha Hauer efd9601e15 poller: Fix async poller
The async poller does not work as expected since it can happen that
the async poller is removed from the list of pollers while we are
iterating over the list. Even list_for_each_entry_safe does not help
here since we may remove the next list element, but
list_for_each_entry_safe only allows to remove the current list element.

Rework the async poller so that it is registered with the poller
framework on registration and then is only marked as active with
poller_call_async(). This way we do not have to do list manipulations
while running the pollers.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-13 15:55:23 +01:00
Sascha Hauer 1b59b573e4 Merge branch 'for-next/rtc' 2016-01-11 13:11:08 +01:00
Sascha Hauer 70ef1cef5c Merge branch 'for-next/pstore' 2016-01-11 13:11:07 +01:00
Sascha Hauer e64f16cf34 Merge branch 'for-next/net' 2016-01-11 13:11:07 +01:00
Sascha Hauer 2881f2df35 Merge branch 'for-next/mtd' 2016-01-11 13:11:07 +01:00
Sascha Hauer b9a2512aaa Merge branch 'for-next/misc' 2016-01-11 13:11:06 +01:00
Sascha Hauer a7964180e1 Merge branch 'for-next/gcc5' 2016-01-11 13:11:06 +01:00
Trent Piepho d5f9415b04 of: Add of_property_for_each_phandle() iterator
This is like of_property_for_each_{string,u32} but loops over a list
of phandles instead of strings or ints.

Returns the node the handle points to as that's generally more useful
than the handle value itself.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:56 +01:00
Trent Piepho 3a51749e2e of: Add for_each_compatible_node_from iterator
The existing iterator for_each_compatible_node() searches for each
compatible node starting from the root of the loaded device tree.
This means it only works on the barebox device tree and not the tree
to be passed to the Linux kernel, which is what an of_fixup would
probably want to use.

This adds for_each_compatible_node_from(), which takes an additional
parameter of a root to search from.  This could be the device tree to
be used for the kernel.  It could also be used to search just a
subtree.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:56 +01:00
Sascha Hauer 8a35fddf57 devfs: Add symlink support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:55 +01:00
Trent Piepho a3544b162e bootstrap: constify strings
Various parameters for device names, etc.  should be const strings.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:55 +01:00
Alexander Aring 7e613c84cf led: add missing includes
The led header use some parts which are missing when include the this
header. This patch adds them.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-07 12:35:25 +01:00
Sascha Hauer f98b02365f net: Add SNTP support
This adds support for retrieving the time via Simple Network Time
Protocol (SNTP). No fancy features are supported, only plainly getting
the current time.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-07 08:46:09 +01:00
Sascha Hauer 6eb5d78419 hwclock command: use format like the Linux tool does
Print three-letter abbreviations of the days and months.

With a fixup by Andrey Smirnov:
| common/date.c: Fix off-by-one error
|
| As per http://pubs.opengroup.org/onlinepubs/007908775/xsh/time.h.html
| 'tm_wday' is zero indexed with zero representing Sunday, this is also
| corroborated by the code in rtc_time_to_tm() which used 4 to represent
| Thursday.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-07 08:45:12 +01:00
Markus Pargmann 142963e9d5 mtd: nand: Add erased page bitflip check helper functions
This adds the bitflip check helper functions from the kernel. They are
used to check for bitflips in erased pages and correct them in the
buffer so that UBI can work with it. Unfortunately most nand controllers
do not have ECC for erased pages and don't do this on their own.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-04 10:43:31 +01:00
Sascha Hauer 39698df6f7 net: resolv: Make argument const
resolv() is not allowed to change the hostname argument, make it const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:40:50 +01:00
Trent Piepho 1d31baf145 bootstrap: Boot barebox with kernel calling convention
In commit 8e3ddc13eb the bootm code was
changed to boot barebox using the same calling convention as the
kernel.  Which on ARM is to pass three arguments which are zero, an
architecture code, and a params pointer.

A 2nd stage barebox can be booted using lib/bootstrap, which is
different code from bootm.  This code just leaves garbage in the first
three parameters and so doesn't follow the convention.

Change it to be compatible with the ARM kernel booting convention.
This just sends a zero for the architecture, since the code for
architectures depends on boot[zmu] and something using bootstrap
wouldn't have those too.  And it just passes NULL for the params since
we don't have a way to pass a device tree from the preloader.

All users of bootstrap are ARM based, but the code is in lib so a
non-ARM board might someday make use of it.  If the current code would
work for them, then the change here will be ok too.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:13:32 +01:00
Sascha Hauer f256280006 linux/barebox-wrapper: Silence gcc5 warning
gcc5 warns about using flags uninitialized in spin_lock_irqsave,
although it could look into the static inline spin_lock_irqsave
implementation and see it's not used at all. An empty define instead
of the static inline wrapper would lead to a "unused variable" warning.
Let's create a macro and fake some usage of the flags variable. This
probably helps until gcc6 is out.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 11:05:07 +01:00
Markus Pargmann 160d2ed0ba fs: Add pstore filesystem
pstore is a persistent storage filesystem used for RAMOOPS. It is used
to store console logs, panics, ftrace and other information in case of a
crash/panic/oops/reboot.

pstore is implemented for barebox as a read-only filesystem at the
moment. It may be extended later on. The idea is to provide a way to
extract essential data from the last running kernel.

Most of the code is copied from the kernel. However this is only a
lightweight implementation without real write support yet.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 08:49:52 +01:00
Markus Pargmann 899b3822d2 lib: Import reed solomon code from kernel
reed solomon code is used by RAMOOPS to check and fix data stored in
volatile memory.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 08:49:52 +01:00
Markus Pargmann 647fba8ee3 vsprintf: Add scnprintf from kernel
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 08:49:52 +01:00
Markus Pargmann 45885266f9 printk: Add missing include/declaration
There are functions or structs used that do need these.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 08:49:52 +01:00
Markus Pargmann 6f42da2fc8 log2: Add missing __rounddown_pow_of_two()
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 08:49:52 +01:00
Andrey Smirnov ba624ae97e i2c: Port two utility functions from Linux kernel
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-08 08:38:31 +01:00
Sascha Hauer 2ae9bbba07 Merge branch 'for-next/state' 2015-12-08 08:29:02 +01:00
Sascha Hauer 3c40bc8c26 Merge branch 'for-next/reset' 2015-12-08 08:28:49 +01:00
Sascha Hauer d10a05b410 Merge branch 'for-next/mtd' 2015-12-08 08:28:27 +01:00
Sascha Hauer 4b1430b653 Merge branch 'for-next/mmc' 2015-12-08 08:28:20 +01:00
Sascha Hauer 29ac6ac467 Merge branch 'for-next/imx' 2015-12-08 08:27:47 +01:00
Sascha Hauer a2b318fe21 Merge branch 'for-next/i2c' 2015-12-08 08:27:37 +01:00
Sascha Hauer a59ae014e1 Merge branch 'for-next/fb' 2015-12-08 08:27:29 +01:00
Sascha Hauer fe68ba4526 Merge branch 'for-next/arm' 2015-12-08 08:27:08 +01:00
Trent Piepho a2b3a25417 ARM: Remove do_execute and thumb2_execute
In commit 104a6a7ccf support was added
for Thumb2.  It added do_execute() as a way to provide arch dependent
calling veneers for use in "go" and thumb2_execute() as the thumb2 to
arm veneer.

But thumb2_execute() isn't necessary as gcc generates a proper calling
sequence from a standard function pointer call.  Thumb2 barebox is
compiled with the AAPCS ABI which requires this.

It also had a bug and didn't pass the arguments properly, but code
execute via "go" rarely uses arguments so this wasn't very noticeable.

Since thumb2 was always the only user of do_execute(), go ahead and
delete that too.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-07 10:44:45 +01:00
Sascha Hauer 412a0e1750 spi: i.MX: optimize transfers for ECSPI v2.3
Instead of writing one word to the txfifo and then wait until
one is received in the rxfifo we can write while the txfifos
are not full and read as long the rxfifos contain data. This
makes transfers for the m25p80 driver around 7 times faster
here.

Unlike the last version this time we only optimize the common
case with 8 bits per word and SPI_LSB_FIRST cleared. The other
cases would require more bit shuffling of the data.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-30 08:22:31 +01:00
Marc Kleine-Budde cd04ed3120 crypto: add simple keystore
This patch adds a simple keystore to barebox. The keystore implements a simple
key-value store to hold arbitrary values.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-27 08:26:40 +01:00
Enrico Jorns 446f3d07dd state: disable load command
Explicitly loading environment is not required as it will be loaded if
available during device probing

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-27 08:26:40 +01:00
Marc Kleine-Budde 21aea1d9ff of_path: add of_find_path_by_node()
This patch adds the function of_find_path_by_node(), which is similar to
of_find_path(), but it translates a device tree node into a barebox device path
directly.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-27 08:26:40 +01:00
Trent Piepho f9c9550b8d eeprom: Add support for 24c1025 EEPROM
This is the Microchip version of the Atmel 24c1024, which is already
supported.  The key difference between them is that the I2C address
bit used to select between the two banks is bit 2 for the 1025 and not
bit 0 as in the 1024.

Add a flag to describe this difference.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-26 09:05:59 +01:00
Sascha Hauer d9ba9c92b7 reset: Add gpio reset support
If a device has the reset-gpios property we can support this through
the reset controller API, so drivers do not have to open code the
support for this property each time themselves as done a few dozen times
in the kernel.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-23 10:23:38 +01:00
Sascha Hauer 97a92f0d86 reset: Remove unused *_optional functions
Since we now have dummy reset controllers we no longer need the
*_optional functions. These have been unused anyway, so just remove
them.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-23 09:57:50 +01:00
Du Huanpeng ea682776db font: fbconsole: add custom font supports
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-23 08:21:08 +01:00
Sebastian Hesselbarth 7cde58cc9d of: mtd: Import of_get_nand_ecc_{step_size, strength} from Linux
This imports DT helpers for MTD ECC step size and strength from
Linux kernel.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-23 08:00:09 +01:00
Jan Remmet b9170a1bde net: eth: Remove ethaddr_param
commit d00db554 introduce ethaddr_param. But it is not initialized, so
devinfo fails to show the mac. Remove it and use edev->ethaddr.

Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-20 08:23:07 +01:00
Antony Pavlov 4aa3a0347c i2c: add pca954x bus multiplexer driver
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-19 08:58:26 +01:00
Antony Pavlov c3859ce93c i2c: import multiplexed I2C bus core support from linux kernel
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-19 08:58:26 +01:00
Sascha Hauer 901b13e243 i2c: Create for_each_i2c_adapter()
This can be used by the i2c_probe command to iterate over i2c adapters.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-19 08:58:25 +01:00
Trent Piepho 9e45df8ebb mci: dw_mmc: Delete devname in platform_data
Nothing used it.

Also delete the local mci alias pointer to host->mci in
dw_mmc_probe().  It only saved a few characters and all the references
but one are using host->mci.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-19 08:52:10 +01:00
Trent Piepho 5537d653d2 mci: dw_mmc: socfpga: Supply bus-width in platform_data
Since there is no OF support in the xloader on socfpga it uses the
platform_data system.  There needs to be a way to supply the
equivalent of the DT property bus-width this way to support devices
that need to use a smaller bus.

So that we don't need to put every flag that might get added to the
MMC_CAP list into platform_data, just put the bus width ones into
platform_data.

The socfpga dts sources specify a bus-width of 4 so use that in the
platform_data for socfpga.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-19 08:52:10 +01:00
Trent Piepho e11f5908d7 mci: core: bus-width property should override driver default
The OF code for parsing bus-width would only add the specified width
to those the driver might have already set capability flags for.

Because of this, if the driver had set 8 or 4 bit width, it wasn't
possible for the DT to specify that fewer pins were used on the board
and a smaller width was necessary.

Change this so the width in the DT overrides whatever widths the
driver says it supports.  There is no reason to have an incorrect
device tree and it makes far more sense for the DT to override the
driver default than for the driver default to override the DT.

The widths the driver puts in host_caps before calling mci_of_parse()
are considered the default if the DT doesn't specify bus-width.  This
should cause the least amount of change to existing boards, as despite
a comment that no bus-width meant to use 1 bit, using the driver
default is what was really happening.

Unfortunately, half of existing drivers default to the largest width
they support while the other half default to the smallest.  Boards
should just stick the width in the device tree.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-19 08:52:10 +01:00
Sascha Hauer 314b5402d9 fbconsole: register fonts dynamically
Instead of having a fixed array of fonts register the fonts dynamically.
This allows easier adding of fonts to the tree since only one file per
font has to be added and no other files modified.

Currently we have to register the fonts very early before the first
framebuffer is registered. This is because of our limited
dev_add_param_enum() which wants to know the number of elements when
called, so we can't add elements once after we've called
dev_add_param_enum(). Maybe a dev_add_param_array() has to be created
whithout this limitation, but that's left for a future exercise.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-13 09:14:48 +01:00
Sascha Hauer b97ac6bd41 Merge branch 'for-next/usb' 2015-11-06 16:10:44 +01:00
Sascha Hauer 1d9295b344 Merge branch 'for-next/misc' 2015-11-06 16:10:42 +01:00
Sascha Hauer 3cdd30342b Merge branch 'for-next/memtest' 2015-11-06 16:10:37 +01:00
Sascha Hauer ed395e4df1 fcntl: Fix O_CREAT clashing with O_RWSIZE_8
O_CREAT and O_RWSIZE_8 are both defined as 0100. Fix this by moving the
O_RWSIZE_* flags to unused bits.

This bug leads to incomplete writes when the destination file is created
and mem_write is involved, for example with the memcpy command:

memcpy -s /some/file -d /dev/ram0 0 0 10

In this case only 8 bytes will be copied and it will be done using 8
byte accesses which may not work properly if the destination is not
sufficiently aligned, i.e.:

memcpy -s /some/file -d /dev/ram0 0 1 8

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2015-11-04 09:31:02 +01:00
Sascha Hauer 8f2549abb7 memtest: By default only test biggest region
Often enough the biggest free region spans most free RAM, so
it doesn't add much value to test the remaining free regions. This
patch changes the default behaviour to only test the biggest free
region and adds the -t option to test all regions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-04 08:03:43 +01:00
Sascha Hauer e96b1713ea memtest: split tests in separate functions
The memtest does a bus integrity check and a moving inversions test.
Split the tests into two separate functions so that the can be called
separately.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-03 07:27:47 +01:00
Sascha Hauer b792124a7d rework remap_range
remap_range is for remapping regions with different cache attributes.
It is implemented for ARM and PowerPC only, the other architectures only
provide stubs.
Currently the new cache attributes are passed in an architecture specific
way and the attributes have to be retrieved by calls to
mmu_get_pte_cached_flags() and mmu_get_pte_uncached_flags().
Make this simpler by providing architecture independent flags which can
be directly passed to remap_range()
Also provide a MAP_ARCH_DEFAULT flag and a arch_can_remap() function.
The MAP_ARCH_DEFAULT defaults to whatever caching type the architecture
has as default. the arch_can_remap() function returns true if the
architecture can change the cache attributes, false otherwise. This
allows the memtest code to better find out what it has to do.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-03 07:27:44 +01:00
Sascha Hauer 6b127d4f18 memtest: move request/release regions to common/
Normally code providing a feature should be implemented in common/ which
is then called from the command code. Follow this rule and move some more
of the memtest code to common/.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-27 08:22:45 +01:00
Antony Pavlov d70cb35e44 clock.h: include <types.h> under guard macro
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-22 09:33:58 +02:00
Peter Mamonov e1d67aa40f usb: core: return -EAGAIN on usb_* functions reentrance
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-14 15:35:30 +02:00
Sascha Hauer 54bf386650 Merge branch 'for-next/usb' 2015-10-07 08:23:51 +02:00
Sascha Hauer dd4da6d328 Merge branch 'for-next/omap' 2015-10-07 08:23:45 +02:00
Sascha Hauer 181bb315d0 Merge branch 'for-next/mtd' 2015-10-07 08:23:45 +02:00
Sascha Hauer c8fa7eed66 Merge branch 'for-next/misc' 2015-10-07 08:23:45 +02:00
Sascha Hauer 8a83eca779 Merge branch 'for-next/mci' 2015-10-07 01:01:06 +02:00