v2019.03.0
Hi All, barebox-2019.03.0 is out. No new shiny generic features around this time, but some SoC specific improvements. The Rasperry Pi port now supports the miniuart, so we do not need any hacks in the dt anymore. The i.MX PCI support has been extended to i.MX7 and i.MX8M. Also, the AT91 devicetree port now support the new PMC bindings which means barebox now works properly again with the kernel provided dts files. As usual, many fixes and cleanups went in, see below. Sascha Ahmad Fatoum (2): regmap: Implement syscon_regmap_lookup_by_compatible() clk: at91: add dt-compat to PMC bindings Alexander Shiyan (14): ARN: Remove duplicate includes ARN: boards: Remove duplicate includes ARN: boards: Remove duplicate includes treewide: Remove trailing whitespaces and tabs ARM: qemu-virt64: Remove orphan Kconfig ARM: omap: Remove reference to non-existent HAVE_DEFAULT_ENVIRONMENT_NEW symbol ARM: mvebu: delete unused mach/kirkwood.h ARM: omap: delete unused mach/am33xx-devices.h ARM: imx: delete unused mach/clock-imx1.h ARM: mvebu: delete unused mach/dove.h PPC: delete unused asm/e300.h PPC: delete unused asm/mc146818rtc.h ARM: at91: delete unused mach/sama5d3_matrix.h ARM: netx: delete unused netx-devices.h Andrey Smirnov (115): treewide: Introduce MAP_FAILED and replace ad-hoc constants with it crypto: digest: Remove unused variable crypto: digest: Replace 4096 with PAGE_SIZE crypto: digest: Split memory vs. file code into separate functions commands: digest: Use MAX_LFS_FILESIZE instead of ~0 crypto: digest: Change the signature of digest_file_window() PCI: Switch to using %pa to print memory addresses PCI: Replace magic number in setup_device() PCI: Remove superfluous parens in setup_device() PCI: Simplify resource setup code in setup_device() PCI: Store and reuse BAR offsets PCI: Remove unused variables/code PCI: Make pci_scan_bus static PCI: Drop "slots" from struct pci_bus PCI: Drop "resources" from struct pci_bus PCI: Drop "name" from struct pci_bus PCI: Drop "ops" from struct pci_bus PCI: Drop "rom_address" from struct pci_dev PCI: Simplify alloc_pci_dev() PCI: Assume 1:1 mapping if .res_start callback is NULL PCI: Convert ->res_start() to return resource_size_t PCI: Consify pci_ops in struct pci_controller crypto: digest: Return -errno if open() fails crypto: digest: Return -errno if lseek() fails crypto: digest: Return -errno if stat() fails regulator: Convert drivers to use struct regulator_desc regulator: Port basic regmap regulator functions regulator: Add support for setting regulator's voltage base: driver: Drop redundant list_empty() check regulator: Assume probe deferral instead of missing regulator regulator: Port ANATOP driver from Linux drivers: base: Port power management code from Linux soc: imx: Add GPCv2 power gating driver reset: Add i.MX7 SRC reset driver reset: Mark local functions as static PCI: imx6: Add code to support i.MX7D PCI: imx6: Allow probe deferral by reset GPIO PCI: imx6: Do not wait for speed change on i.MX7 PCI: imx6: Do not switch speed if Gen2 is disabled PCI: imx6: Fix spelling mistake: "contol" -> "control" PCI: imx6: Drop unnecessary root_bus_nr setting PCI: imx6: Port imx6_pcie_ltssm_enable() block: Alias block_op_close() to block_op_flush() block: Replace debug() with dev_dbg() ARM: mmu: Drop custom virt_to_phys/phys_to_virt ARM: mmu: Simplify the use of dma_inv_range() ARM: mmu: Share code for dma_(un)map_single() lib: strtox: Use plumbing from kstrtox.c ARM64: mmu: Use arch_remap_range() internally ARM64: mmu: Merge create_sections() and map_region() together ARM: mmu: Share code for dma_free_coherent() ARM64: mmu: Invalidate memory before remapping as DMA coherent ARM: mmu: Share code for dma_alloc_coherent() ARM: mmu: Share code for dma_sync_single_for_cpu() ARM: mmu: Share sanity checking code in mmu_init() ARM: mmu: Share code for arm_mmu_not_initialized_error() ARM: mmu: Make sure DMA coherent memory is zeroed out block: Do not write past block device boundary during a flush block: Move shared code in get_chunk() out of if statement ls: Adjust amount of space allocated for filesize unlink_recursive: Drop struct data lib: image-sparse: Mark sparse_seek() as static commands: Move mem_parse_options() to lib/misc.c commands: Get rid of mem_rw_buf commands: Move /dev/mem driver to drivers/misc nvmem: Do not use DEVFS_IS_CHARACTER_DEV common: firmware: Don't use FILE_SIZE_STREAM directly devfs: Fix incorr
[PATCH 11/17] uimage: Fix lseek error check in uimage_load_to_buf()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. Signed-off-by: Andrey Smirnov --- common/uimage.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/common/uimage.c b/common/uimage.c index 12c7e9e2c..35bfb10b0 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -457,6 +457,7 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no, { u32 size; int ret; + loff_t off; struct uimage_handle_data *ihd; char ftbuf[128]; enum filetype ft; @@ -467,9 +468,8 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no, ihd = &handle->ihd[image_no]; - ret = lseek(handle->fd, ihd->offset + handle->data_offset, - SEEK_SET); - if (ret < 0) + off = ihd->offset + handle->data_offset; + if (lseek(handle->fd, off, SEEK_SET) != off) return NULL; if (handle->header.ih_comp == IH_COMP_NONE) { @@ -497,10 +497,8 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no, if (ft != filetype_gzip) return NULL; - ret = lseek(handle->fd, ihd->offset + handle->data_offset + - ihd->len - 4, - SEEK_SET); - if (ret < 0) + off = ihd->offset + handle->data_offset + ihd->len - 4; + if (lseek(handle->fd, off, SEEK_SET) != off) return NULL; ret = read(handle->fd, &size, 4); @@ -509,9 +507,8 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no, size = le32_to_cpu(size); - ret = lseek(handle->fd, ihd->offset + handle->data_offset, - SEEK_SET); - if (ret < 0) + off = ihd->offset + handle->data_offset; + if (lseek(handle->fd, off, SEEK_SET) != off) return NULL; buf = malloc(size); -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 17/17] commands: loadb: Make use of open_and_lseek()
Save a bit of extra code by replacing explict calls to open() and lseek() with a single call to open_and_lseek(). Signed-off-by: Andrey Smirnov --- commands/loadb.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/commands/loadb.c b/commands/loadb.c index 8c3906ca4..a1f6e63ec 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -661,21 +661,11 @@ static int do_load_serial_bin(int argc, char *argv[]) output_file = DEF_FILE; /* File should exist */ - ofd = open(output_file, O_WRONLY | O_CREAT); + ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset); if (ofd < 0) { perror(argv[0]); return 3; } - /* Seek to the right offset */ - if (offset) { - int seek = lseek(ofd, offset, SEEK_SET); - if (seek != offset) { - close(ofd); - ofd = 0; - perror(argv[0]); - return 4; - } - } printf("## Ready for binary (kermit) download " "to 0x%08lX offset on %s device at %d bps...\n", offset, -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 08/17] bpkfs: Fix lseek error check in bpkfs_probe()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- fs/bpkfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/bpkfs.c b/fs/bpkfs.c index 655cde09b..90d3a6bf1 100644 --- a/fs/bpkfs.c +++ b/fs/bpkfs.c @@ -455,9 +455,9 @@ static int bpkfs_probe(struct device_d *dev) list_add_tail(&d->list, &h->list_data); priv->nb_data_entries++; - ret = lseek(fd, d->size, SEEK_CUR); - if (ret < 0) { + if (lseek(fd, d->size, SEEK_CUR) != d->size) { dev_err(dev, "could not seek: %s\n", errno_str()); + ret = -errno; goto err; } -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 13/17] state: Fix lseek error check in state_backend_bucket_direct_write()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- common/state/backend_bucket_direct.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c index 152431214..95ddb9310 100644 --- a/common/state/backend_bucket_direct.c +++ b/common/state/backend_bucket_direct.c @@ -113,10 +113,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket if (len > direct->max_size - sizeof(meta)) return -E2BIG; - ret = lseek(direct->fd, direct->offset, SEEK_SET); - if (ret < 0) { - dev_err(direct->dev, "Failed to seek file, %d\n", ret); - return ret; + if (lseek(direct->fd, direct->offset, SEEK_SET) != direct->offset) { + dev_err(direct->dev, "Failed to seek file, %d\n", -errno); + return -errno; } /* write the meta data only if there is head room */ -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 14/17] state: Fix lseek error check in state_mtd_peb_read()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- common/state/backend_bucket_circular.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index da7c8421a..791f39b9b 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -162,11 +162,10 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ offset += (off_t)circ->eraseblock * circ->mtd->erasesize; - ret = lseek(circ->fd, offset, SEEK_SET); - if (ret < 0) { + if (lseek(circ->fd, offset, SEEK_SET) != offset) { dev_err(circ->dev, "Failed to set circular read position to %lld, %d\n", - (long long) offset, ret); - return ret; + (long long) offset, -errno); + return -errno; } dev_dbg(circ->dev, "Read state from %lld length %d\n", (long long) offset, -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 15/17] state: Fix lseek error check in state_mtd_peb_write()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- common/state/backend_bucket_circular.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 791f39b9b..4676730d0 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -190,11 +190,10 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir offset += circ->eraseblock * circ->mtd->erasesize; - ret = lseek(circ->fd, offset, SEEK_SET); - if (ret < 0) { + if (lseek(circ->fd, offset, SEEK_SET) != offset) { dev_err(circ->dev, "Failed to set position for circular write %lld, %d\n", - (long long) offset, ret); - return ret; + (long long) offset, -errno); + return -errno; } ret = write_full(circ->fd, buf, len); -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 16/17] commands: loadxy: Make use of open_and_lseek()
Save a bit of extra code by replacing explict calls to open() and lseek() with a single call to open_and_lseek(). Signed-off-by: Andrey Smirnov --- commands/loadxy.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/commands/loadxy.c b/commands/loadxy.c index 2bfe482fc..85efad67c 100644 --- a/commands/loadxy.c +++ b/commands/loadxy.c @@ -37,6 +37,7 @@ #include #include #include +#include #define DEF_FILE "image.bin" @@ -176,21 +177,11 @@ static int do_loadx(int argc, char *argv[]) output_file = DEF_FILE; /* File should exist */ - ofd = open(output_file, O_WRONLY | O_CREAT); + ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset); if (ofd < 0) { perror(argv[0]); return 3; } - /* Seek to the right offset */ - if (offset) { - int seek = lseek(ofd, offset, SEEK_SET); - if (seek != offset) { - close(ofd); - ofd = 0; - perror(argv[0]); - return 4; - } - } current_baudrate = console_get_baudrate(cdev); -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 10/17] uimage: Fix lseek error check in uimage_load()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- common/uimage.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/uimage.c b/common/uimage.c index 72b668e89..12c7e9e2c 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -308,6 +308,7 @@ int uimage_load(struct uimage_handle *handle, unsigned int image_no, image_header_t *hdr = &handle->header; struct uimage_handle_data *iha; int ret; + loff_t off; int (*uncompress_fn)(unsigned char *inbuf, int len, int(*fill)(void*, unsigned int), int(*flush)(void*, unsigned int), @@ -320,10 +321,9 @@ int uimage_load(struct uimage_handle *handle, unsigned int image_no, iha = &handle->ihd[image_no]; - ret = lseek(handle->fd, iha->offset + handle->data_offset, - SEEK_SET); - if (ret < 0) - return ret; + off = iha->offset + handle->data_offset; + if (lseek(handle->fd, off, SEEK_SET) != off) + return -errno; /* if ramdisk U-Boot expect to ignore the compression type */ if (hdr->ih_comp == IH_COMP_NONE || hdr->ih_type == IH_TYPE_RAMDISK) -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 12/17] state: Fix lseek error check in state_backend_bucket_direct_read()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- common/state/backend_bucket_direct.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c index 1f00b0fb2..152431214 100644 --- a/common/state/backend_bucket_direct.c +++ b/common/state/backend_bucket_direct.c @@ -56,10 +56,9 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket void *buf; int ret; - ret = lseek(direct->fd, direct->offset, SEEK_SET); - if (ret < 0) { - dev_err(direct->dev, "Failed to seek file, %d\n", ret); - return ret; + if (lseek(direct->fd, direct->offset, SEEK_SET) != direct->offset) { + dev_err(direct->dev, "Failed to seek file, %d\n", -errno); + return -errno; } ret = read_full(direct->fd, &meta, sizeof(meta)); if (ret < 0) { @@ -77,10 +76,11 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket return -EINVAL; } read_len = direct->max_size; - ret = lseek(direct->fd, direct->offset, SEEK_SET); - if (ret < 0) { - dev_err(direct->dev, "Failed to seek file, %d\n", ret); - return ret; + if (lseek(direct->fd, direct->offset, SEEK_SET) != + direct->offset) { + dev_err(direct->dev, "Failed to seek file, %d\n", + -errno); + return -errno; } } -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 09/17] uimage: Fix lseek error check in uimage_verify()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- common/uimage.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/uimage.c b/common/uimage.c index 3273bc187..72b668e89 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -265,11 +265,12 @@ int uimage_verify(struct uimage_handle *handle) { u32 crc = 0; int len, ret; + loff_t off; void *buf; - ret = lseek(handle->fd, sizeof(struct image_header), SEEK_SET); - if (ret < 0) - return ret; + off = sizeof(struct image_header); + if (lseek(handle->fd, off, SEEK_SET) != off) + return -errno; buf = xmalloc(PAGE_SIZE); -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 07/17] ARM: i.MX: bbu: Fix variable type in imx_bbu_internal_v2_write_nand_dbbt()
MEMGETBADBLOCK returns loff_t, so that's the type we should use to store its result. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index 1104303ff..a563b3bc2 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -207,7 +207,7 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler * int size_available, size_need; int ret; uint32_t *ptr, *num_bb, *bb; - uint64_t offset; + loff_t offset; int block = 0, len, now, blocksize; int dbbt_start_page = 4; int firmware_start_page = 12; -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 05/17] ARM: i.MX: bbu: Fix lseek error check in imx_bbu_external_nand_update()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-external-nand.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-external-nand.c b/arch/arm/mach-imx/imx-bbu-external-nand.c index 440785ab7..fa43d2e8d 100644 --- a/arch/arm/mach-imx/imx-bbu-external-nand.c +++ b/arch/arm/mach-imx/imx-bbu-external-nand.c @@ -147,10 +147,12 @@ static int imx_bbu_external_nand_update(struct bbu_handler *handler, struct bbu_ goto out; if (ret) { - ret = lseek(fd, offset + blocksize, SEEK_SET); - if (ret < 0) - goto out; offset += blocksize; + if (lseek(fd, offset, SEEK_SET) != offset) { + ret = -errno; + goto out; + } + continue; } -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 06/17] ARM: i.MX: bbu: Fix lseek error check in imx_bbu_internal_v2_write_nand_dbbt()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index 188369fe3..1104303ff 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -330,10 +330,12 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler * goto out; if (ret) { - ret = lseek(fd, offset + blocksize, SEEK_SET); - if (ret < 0) - goto out; offset += blocksize; + if (lseek(fd, offset, SEEK_SET) != offset) { + ret = -errno; + goto out; + } + continue; } -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 04/17] ARM: i.MX: bbu: Fix variable type in imx_bbu_external_nand_update()
MEMGETBADBLOCK returns loff_t, so that's the type we should use to store its result. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-external-nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/imx-bbu-external-nand.c b/arch/arm/mach-imx/imx-bbu-external-nand.c index 52622ac4c..440785ab7 100644 --- a/arch/arm/mach-imx/imx-bbu-external-nand.c +++ b/arch/arm/mach-imx/imx-bbu-external-nand.c @@ -40,7 +40,7 @@ static int imx_bbu_external_nand_update(struct bbu_handler *handler, struct bbu_ int size_available, size_need; int ret; uint32_t num_bb = 0, bbt = 0; - uint64_t offset = 0; + loff_t offset = 0; int block = 0, len, now, blocksize; void *image = data->image; -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 01/17] libfile: Make failure path of open_and_lseek() consistent
Change the code of open_and_lseek() to make sure that opened file is closed in every failure path as well. While at it make sure we don't mix returning function return code and returning errno by opting to always return the former. Signed-off-by: Andrey Smirnov --- lib/libfile.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/libfile.c b/lib/libfile.c index 9a223d232..089749253 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -522,12 +522,12 @@ err_out1: * @mode: The file open mode * @pos: The position to lseek to * - * Return: If successful this function returns a positive filedescriptor - * number, otherwise a negative error code is returned + * Return: If successful this function returns a positive + * filedescriptor number, otherwise -1 is returned */ int open_and_lseek(const char *filename, int mode, loff_t pos) { - int fd, ret; + int fd; fd = open(filename, mode); if (fd < 0) { @@ -541,28 +541,26 @@ int open_and_lseek(const char *filename, int mode, loff_t pos) if (mode & (O_WRONLY | O_RDWR)) { struct stat s; - ret = fstat(fd, &s); - if (ret) { + if (fstat(fd, &s)) { perror("fstat"); - return ret; + goto out; } - if (s.st_size < pos) { - ret = ftruncate(fd, pos); - if (ret) { - perror("ftruncate"); - return ret; - } + if (s.st_size < pos && ftruncate(fd, pos)) { + perror("ftruncate"); + goto out; } } if (lseek(fd, pos, SEEK_SET) != pos) { perror("lseek"); - close(fd); - return -errno; + goto out; } return fd; +out: + close(fd); + return -1; } /** -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 03/17] MIPS: ath79: Use errno to get error code from open_and_lseek()
Open_and_lseek() return actual error code via errno, so change the code to use it instead of return value. Signed-off-by: Andrey Smirnov --- arch/mips/mach-ath79/art.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/mach-ath79/art.c b/arch/mips/mach-ath79/art.c index 984d08736..2a2099e9f 100644 --- a/arch/mips/mach-ath79/art.c +++ b/arch/mips/mach-ath79/art.c @@ -44,8 +44,8 @@ static int art_read_mac(struct device_d *dev, const char *file) fd = open_and_lseek(file, O_RDONLY, AR93000_EPPROM_OFFSET); if (fd < 0) { dev_err(dev, "Failed to open eeprom path %s %d\n", - file, fd); - return fd; + file, -errno); + return -errno; } rbytes = read_full(fd, &eeprom, sizeof(eeprom)); -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 00/17] lseek related fixes
Everyone: As a follow up to lseek() related fixes that went in recently, I went throught all of the calls to it in the codebase I could find and fixed a number of type problems as well as some other minor issue. This series is the result. Hopefuly all of the patches are self-explanatory. Feedback is welcome! Thanks, Andrey Smirnov Andrey Smirnov (17): libfile: Make failure path of open_and_lseek() consistent common: Always return enum filetype in file_name_detect_type_offset() MIPS: ath79: Use errno to get error code from open_and_lseek() ARM: i.MX: bbu: Fix variable type in imx_bbu_external_nand_update() ARM: i.MX: bbu: Fix lseek error check in imx_bbu_external_nand_update() ARM: i.MX: bbu: Fix lseek error check in imx_bbu_internal_v2_write_nand_dbbt() ARM: i.MX: bbu: Fix variable type in imx_bbu_internal_v2_write_nand_dbbt() bpkfs: Fix lseek error check in bpkfs_probe() uimage: Fix lseek error check in uimage_verify() uimage: Fix lseek error check in uimage_load() uimage: Fix lseek error check in uimage_load_to_buf() state: Fix lseek error check in state_backend_bucket_direct_read() state: Fix lseek error check in state_backend_bucket_direct_write() state: Fix lseek error check in state_mtd_peb_read() state: Fix lseek error check in state_mtd_peb_write() commands: loadxy: Make use of open_and_lseek() commands: loadb: Make use of open_and_lseek() arch/arm/mach-imx/imx-bbu-external-nand.c | 10 --- arch/arm/mach-imx/imx-bbu-internal.c | 10 --- arch/mips/mach-ath79/art.c| 4 +-- commands/loadb.c | 12 + commands/loadxy.c | 13 ++--- common/filetype.c | 4 +-- common/state/backend_bucket_circular.c| 14 +- common/state/backend_bucket_direct.c | 23 common/uimage.c | 32 +++ fs/bpkfs.c| 4 +-- lib/libfile.c | 26 +- 11 files changed, 65 insertions(+), 87 deletions(-) -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 02/17] common: Always return enum filetype in file_name_detect_type_offset()
None of the callers of file_name_detect_type_offset() are prepared to deal with negative error code. Change the code to return filetype_unknown if open_and_lseek() fails. Signed-off-by: Andrey Smirnov --- common/filetype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/filetype.c b/common/filetype.c index f8b6bc895..fb029a773 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -383,7 +383,7 @@ enum filetype file_name_detect_type_offset(const char *filename, loff_t pos) fd = open_and_lseek(filename, O_RDONLY, pos); if (fd < 0) - return fd; + goto out; buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE); @@ -396,7 +396,7 @@ enum filetype file_name_detect_type_offset(const char *filename, loff_t pos) err_out: close(fd); free(buf); - +out: return type; } -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] usb: dwc3: Toggle GCTL.CORESOFTRESET as a first step
Toggle GCTL.CORESOFTRESET before trying to access any of the block's registers. Without this additional step, first read of DWC3_GHWPARAMS* that follows results in assertion of GSTS.CSRTIMEOUT and IP block stuck in a non-functional state. Note that all above has only been observed on i.MX8MQ (ZII Zest board) for USB1 controller. USB2 doesn't seem to be affected by this. Signed-off-by: Andrey Smirnov --- drivers/usb/dwc3/core.c | 17 + 1 file changed, 17 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 2e7031a34..1fc24a441 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -663,6 +663,21 @@ static void dwc3_check_params(struct dwc3 *dwc) } } +static void dwc3_coresoft_reset(struct dwc3 *dwc) +{ + u32 reg; + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg |= DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); + + mdelay(100); + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg &= ~DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); +} + static int dwc3_probe(struct device_d *dev) { struct dwc3 *dwc; @@ -695,6 +710,8 @@ static int dwc3_probe(struct device_d *dev) if (ret) return ret; + dwc3_coresoft_reset(dwc); + dwc3_cache_hwparams(dwc); ret = dwc3_core_init(dwc); -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] images: pbl: verify CONFIG_BAREBOX_MAX_IMAGE_SIZE is not exceeded
On Mon, Mar 04, 2019 at 03:16:51PM +0100, Ahmad Fatoum wrote: > Hello, > > On 19/2/19 13:10, Ahmad Fatoum wrote: > > For platforms such as the at91, the boot ROM imposes an upper limit > > on barebox file size. Prior to 5a1a5ed253 ("ARM: images: use piggydata"), > > BAREBOX_MAX_PBLX_SIZE seems to have been the way to go for limiting > > the size of the final barebox binary when using the PBL. > > With pblx removed, this variable is of no use, so have the existing > > BAREBOX_MAX_IMAGE_SIZE replace its functionality. > > > > Currently BAREBOX_MAX_IMAGE_SIZE is only checked against in the non-PBL > > case, so add a check in the PBL case as well. > > > > Signed-off-by: Ahmad Fatoum > > --- > > arch/arm/configs/am335x_mlo_defconfig | 2 +- > > common/Kconfig| 10 -- > > images/Makefile | 1 + > > 3 files changed, 2 insertions(+), 11 deletions(-) > > > > any news on these two patches? I applied the first one as I think it does nothing wrong. I am always hesitating to apply such patches because I think we need to do this better. For example when doing multi image builds different ROMs with different size limitations might be involved, so putting the limitation in Kconfig is wrong. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] ARM: i.MX6UL: liteSOM: depend on DDR controller settings
On Wed, Feb 27, 2019 at 11:04:18AM +0100, Marcin Niestrój wrote: > > Sascha Hauer writes: > > > On Tue, Feb 26, 2019 at 02:05:29PM +0100, Marcin Niestroj wrote: > >> Initially we depended on DDR controller settings for liteSOM and > >> liteboard. With > >> 33fdc89d4cbd ("dts: update to v5.0-rc1") a `device_type = "memory";` > >> property > >> was added to imx6ul-litesom.dtsi file, which causes "ram0" to be added with > >> 512MB size (value in dtsi) instead of the real 256MB size that is > >> configured in > >> barebox-grinn-liteboard-256mb.img. As a result Linux kernel fails to boot. > >> > >> Lets depend on DDR controller settings, by removing whole `/memory` node > >> from > >> device tree. This makes barebox-grinn-liteboard-256mb.img able to boot > >> Linux > >> kernel once again. > > > > This issue should also be fixed by: > > > > | commit 8a29e7b493c8c2aa57174c9e79c14b93c9807a4b > > | Author: Marco Felsch > > | Date: Tue Feb 12 16:10:41 2019 +0100 > > | > > | memory: of_fixup: adapt to new memory layout > > | > > | Since kernel 4.16 the memory nodes got a @ suffix so the fixup > > | won't work correctly anymore, because instead of adapting the > > extisting > > | one the fixup creates a new node and keeps the old (maybe incorrect) > > | node. > > | > > | To be compatible with the old and new layout delete the found memory > > | node and create a new one. The new node follows the new @ style. > > | > > | The patch also renames the node parameter to make it clearer. > > | > > | Signed-off-by: Marco Felsch > > | Signed-off-by: Sascha Hauer > > > > I would prefer this patch as it solves the issue for all boards. > > We need this patch as well. The problem that I want to solve with > liteboard is configuring memory banks, which is done much earlier. In > current master branch a single memory bank is added from device-tree > (of_probe -> ... -> of_add_memory_bank). In case of liteboard this is > configured to 512MB. Then a imx6_mmdc_add_mem() is executed, which tries > to add 256MB memory bank (in case of barebox-grinn-liteboard-256mb.img). > This fails inside barebox_add_memory_bank(), because we get -EBUSY from > request_iomem_region() there. This makes no problem in Barebox > yet. However, when booting Linux kernel of_memory_fixup() function gets > called. It sets 512MB in fdt once again, which results in boot failure > when jumping into kernel. > > I agree, that it is better to solve this kind of issues for all > boards. In order to achieve that we need to either: > 1) "overwrite" in imx6_mmdc_add_mem() what we have set in >of_add_memory_bank(), > 2) make sure imx6_mmdc_add_mem() gets called earlier than >of_add_memory_bank(). Ok, I applied it now. Thanks Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3] ARM: dts: imx6*phytec*: switch to new partitioning scheme
On Tue, Feb 19, 2019 at 02:03:02PM +0100, Uwe Kleine-König wrote: > Both Linux and barebox support this new scheme and it's the actually > the recommended one. > > Signed-off-by: Uwe Kleine-König > --- Applied, thanks Sascha > Hello, > > On Tue, Feb 19, 2019 at 11:54:07AM +0100, Stefan Riedmüller wrote: > > On 19.02.19 11:28, Uwe Kleine-König wrote: > > > Both Linux and barebox support this new scheme and it's the actually > > > the recommended one. > > > > > > Signed-off-by: Uwe Kleine-König > > > --- > > > On Tue, Feb 19, 2019 at 11:08:56AM +0100, Stefan Riedmüller wrote: > > > > thanks for the patch. > > > > > > > > In arch/arm/dts/imx6qdl-phytec-pfla02.dtsi and > > > > arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi are additional gpmi > > > > partitions. > > > > Did you leave them out for a reason. I think they can be matched to the > > > > new > > > > scheme too. > > > I didn't skip something on purpose. I just didn't notice there are two > > > partitioned devices. Fixed here in v2. > > > > Sorry to bother you again, but it seems the gpmi partitions on the > > arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi were missed again. > > On rereading your mail I was really surprised you wrote about two device > trees. I only noticed one, and so I only fixed one. So it's not you who > need to be sorry ... :-| > > Best regards > Uwe > > .../dts/imx6dl-phytec-phycore-som-emmc.dts| 21 +++--- > .../dts/imx6dl-phytec-phycore-som-nand.dts| 21 +++--- > arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi| 30 > .../arm/dts/imx6q-phytec-phycore-som-emmc.dts | 21 +++--- > .../arm/dts/imx6q-phytec-phycore-som-nand.dts | 25 --- > arch/arm/dts/imx6qdl-phytec-pfla02.dtsi | 74 +- > arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi | 75 ++- > .../dts/imx6qp-phytec-phycore-som-nand.dts| 21 +++--- > arch/arm/dts/imx6ul-phytec-phycore-som.dtsi | 29 +++ > 9 files changed, 176 insertions(+), 141 deletions(-) > > diff --git a/arch/arm/dts/imx6dl-phytec-phycore-som-emmc.dts > b/arch/arm/dts/imx6dl-phytec-phycore-som-emmc.dts > index 7e4a5aba2a77..e602b77e9940 100644 > --- a/arch/arm/dts/imx6dl-phytec-phycore-som-emmc.dts > +++ b/arch/arm/dts/imx6dl-phytec-phycore-som-emmc.dts > @@ -52,17 +52,20 @@ > &usdhc1 { > status = "okay"; > > - #address-cells = <1>; > - #size-cells = <1>; > + partitions { > + compatible = "fixed-partitions"; > + #address-cells = <1>; > + #size-cells = <1>; > > - partition@0 { > - label = "barebox"; > - reg = <0x0 0xe>; > - }; > + partition@0 { > + label = "barebox"; > + reg = <0x0 0xe>; > + }; > > - partition@e { > - label = "barebox-environment"; > - reg = <0xe 0x2>; > + partition@e { > + label = "barebox-environment"; > + reg = <0xe 0x2>; > + }; > }; > }; > > diff --git a/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts > b/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts > index ffcbdc213471..77f143438b50 100644 > --- a/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts > +++ b/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts > @@ -47,16 +47,19 @@ > &usdhc1 { > status = "okay"; > > - #address-cells = <1>; > - #size-cells = <1>; > + partitions { > + compatible = "fixed-partitions"; > + #address-cells = <1>; > + #size-cells = <1>; > > - partition@0 { > - label = "barebox"; > - reg = <0x0 0xe>; > - }; > + partition@0 { > + label = "barebox"; > + reg = <0x0 0xe>; > + }; > > - partition@e { > - label = "barebox-environment"; > - reg = <0xe 0x2>; > + partition@e { > + label = "barebox-environment"; > + reg = <0xe 0x2>; > + }; > }; > }; > diff --git a/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi > b/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi > index 63dd966b8746..66b547ad8eef 100644 > --- a/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi > +++ b/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi > @@ -131,22 +131,26 @@ > pinctrl-0 = <&pinctrl_gpmi_nand>; > nand-on-flash-bbt; > status = "okay"; > - #address-cells = <1>; > - #size-cells = <1>; > > - partition@0 { > - label = "barebox"; > - reg = <0x0 0x40>; > - }; > + partitions { > + compatible = "fixed-partitions"; > + #address-cells = <1>; > + #size-cells = <1>; > > - environment_nand: partition@40 { > - label = "barebox-environment"; > - reg = <0x40 0x2>; > - }; > + partition@0 { > +
Re: [PATCH] fix zbarebox linking with new ld
On Wed, Mar 06, 2019 at 07:12:13PM +0800, 张忠山 wrote: > Signed-off-by: 张忠山 > --- > arch/arm/pbl/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks Sascha > > diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile > index 347df6424..f897166e5 100644 > --- a/arch/arm/pbl/Makefile > +++ b/arch/arm/pbl/Makefile > @@ -31,7 +31,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE > $(call if_changed,disasm) > > PBL_CPPFLAGS += -fdata-sections -ffunction-sections > -LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map --gc-sections > +LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map --gc-sections > --no-dynamic-linker > ifdef CONFIG_PBL_RELOCATABLE > LDFLAGS_zbarebox += -pie > else > -- > 2.20.1 > > > -- > Best Regards, > zzs > ___ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] PCI: dwc: tune down link up messages
On Tue, Mar 05, 2019 at 10:45:15AM +0100, Lucas Stach wrote: > This function may be called repeatedly while establishing the link, > so printing a message each time a working link is found can add quite > a bit of noise. Tune those messages down to the debug level. > > Signed-off-by: Lucas Stach > --- > drivers/pci/pcie-designware.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks Sascha > > diff --git a/drivers/pci/pcie-designware.c b/drivers/pci/pcie-designware.c > index aaea316e9095..c6d19559f437 100644 > --- a/drivers/pci/pcie-designware.c > +++ b/drivers/pci/pcie-designware.c > @@ -195,7 +195,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci) > /* Check if the link is up or not */ > for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { > if (dw_pcie_link_up(pci)) { > - dev_info(pci->dev, "Link up\n"); > + dev_dbg(pci->dev, "Link up\n"); > return 0; > } > udelay(LINK_WAIT_USLEEP_MAX); > -- > 2.20.1 > > > ___ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] fix zbarebox linking with new ld
Signed-off-by: 张忠山 --- arch/arm/pbl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index 347df6424..f897166e5 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -31,7 +31,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE $(call if_changed,disasm) PBL_CPPFLAGS += -fdata-sections -ffunction-sections -LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map --gc-sections +LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map --gc-sections --no-dynamic-linker ifdef CONFIG_PBL_RELOCATABLE LDFLAGS_zbarebox += -pie else -- 2.20.1 -- Best Regards, zzs ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] ARM: rpi: refactor debug UART Kconfig settings.
Hi Tomaž, On Tue, Mar 05, 2019 at 10:13:04AM +0100, Tomaž Šolc wrote: > On 4. 03. 19 09:04, Sascha Hauer wrote: > > So that said, even with a debug UART enabled for Rpi1 we should still > > allow to build for Rpi2/3 although we know it won't work there. > > > > The reason is you might get failures only when multiple SoCs are > > selected. In that case you only want to enable early debugging support > > (for the SoC you are currently testing on) without changing other things > > in the config which might make your errors disappear. > > Thanks for the clarification. I've sent another patch series that removes > the restriction for board builds and adds the help text. > > On the topic of the debug UART, I've also noticed that it's a bit tricky to > get it running on Raspberry Pi 3. The problem is that the debug UART is > using PL011 hardware, but the console is now using miniuart. > > In addition to enabling it in menuconfig, I have to reverse the commit > ab76f9d0 (switch to miniuart for stdout in the device tree) and keep > "dtoverlay=pi3-miniuart-bt" in "config.txt" (instruction for this was > removed in f1330536). I just sent a series based on your patches adding mini UART support for the rpi3. I need the basic ns16550 early debugging code for Layerscape anyway, so it's a win-win ;) Tested on Layerscape, but not on rpi3, so I would be glad if you could test it. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 3/5] debug_ll: Add ns16550 early debugging functions
Signed-off-by: Sascha Hauer --- include/debug_ll/ns16550.h | 56 ++ 1 file changed, 56 insertions(+) create mode 100644 include/debug_ll/ns16550.h diff --git a/include/debug_ll/ns16550.h b/include/debug_ll/ns16550.h new file mode 100644 index 00..7e4dbeb453 --- /dev/null +++ b/include/debug_ll/ns16550.h @@ -0,0 +1,56 @@ +#ifndef __DEBUG_LL_NS16550_H +#define __DEBUG_LL_NS16550_H + +/* + * Early debugging functions for the NS16550 + * This file needs register access functions declared as: + * + * uint8_t debug_ll_read_reg(int reg); + * void debug_ll_write_reg(int reg, uint8_t val); + */ +#define NS16550_THR0x0 +#define NS16550_RBR0x0 +#define NS16550_DLL0x0 +#define NS16550_IER0x1 +#define NS16550_DLM0x1 +#define NS16550_FCR0x2 +#define NS16550_LCR0x3 +#define NS16550_MCR0x4 +#define NS16550_LSR0x5 + +#define NS16550_LCR_VAL0x3 /* 8 data, 1 stop, no parity */ +#define NS16550_MCR_VAL0x3 /* RTS/DTR */ +#define NS16550_FCR_VAL0x7 /* Clear & enable FIFOs */ + +#define NS16550_LSR_DR 0x01 /* UART received data present */ +#define NS16550_LSR_THRE 0x20 /* Xmit holding register empty */ + +#define NS16550_LCR_BKSE 0x80 /* Bank select enable */ + +static inline void PUTC_LL(char ch) +{ +while (!(debug_ll_read_reg(NS16550_LSR) & NS16550_LSR_THRE)) +; + +debug_ll_write_reg(NS16550_THR, ch); +} + +static inline uint16_t debug_ll_ns16550_calc_divisor(unsigned long clk) +{ + return clk / (115200 * 16); +} + +static inline void debug_ll_ns16550_init(uint16_t divisor) +{ + debug_ll_write_reg(NS16550_LCR, 0x0); /* select ier reg */ +debug_ll_write_reg(0x00, NS16550_IER); + + debug_ll_write_reg(NS16550_LCR, NS16550_LCR_BKSE); + debug_ll_write_reg(NS16550_DLL, divisor & 0xff); + debug_ll_write_reg(NS16550_DLM, (divisor >> 8) & 0xff); + debug_ll_write_reg(NS16550_LCR, NS16550_LCR_VAL); + debug_ll_write_reg(NS16550_MCR, NS16550_MCR_VAL); + debug_ll_write_reg(NS16550_FCR, NS16550_FCR_VAL); +} + +#endif -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 1/5] ARM: rpi: Move UART base address definitions to header file
Move defines to header file to make them reusable. Signed-off-by: Sascha Hauer --- arch/arm/boards/raspberry-pi/rpi-common.c | 5 + arch/arm/mach-bcm283x/include/mach/platform.h | 4 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c index 9d334cde12..60cea7f8e9 100644 --- a/arch/arm/boards/raspberry-pi/rpi-common.c +++ b/arch/arm/boards/raspberry-pi/rpi-common.c @@ -34,6 +34,7 @@ #include #include +#include #include "rpi.h" #include "lowlevel.h" @@ -320,10 +321,6 @@ static int rpi_clock_init(void) } postconsole_initcall(rpi_clock_init); -#define BCM2835_PL011_BASE 0x20201000 -#define BCM2836_PL011_BASE 0x3f201000 -#define BCM2836_MINIUART_BASE 0x3f215040 - static int rpi_console_clock_init(void) { struct clk *clk; diff --git a/arch/arm/mach-bcm283x/include/mach/platform.h b/arch/arm/mach-bcm283x/include/mach/platform.h index 80b529a46f..d8561c1610 100644 --- a/arch/arm/mach-bcm283x/include/mach/platform.h +++ b/arch/arm/mach-bcm283x/include/mach/platform.h @@ -30,6 +30,10 @@ #define BCM2835_CACHELINE_SIZE 64 +#define BCM2835_PL011_BASE 0x20201000 +#define BCM2836_PL011_BASE 0x3f201000 +#define BCM2836_MINIUART_BASE 0x3f215040 + #endif /* END */ -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 5/5] ARM: rpi: Add mini UART debug_ll support
The raspberry pi 3 comes up with the mini UART as default, so allow to use it for debug_ll output. Signed-off-by: Sascha Hauer --- arch/arm/mach-bcm283x/include/mach/debug_ll.h | 37 +++ common/Kconfig| 6 +++ 2 files changed, 43 insertions(+) diff --git a/arch/arm/mach-bcm283x/include/mach/debug_ll.h b/arch/arm/mach-bcm283x/include/mach/debug_ll.h index 2d2103e338..99c59d011b 100644 --- a/arch/arm/mach-bcm283x/include/mach/debug_ll.h +++ b/arch/arm/mach-bcm283x/include/mach/debug_ll.h @@ -22,14 +22,51 @@ #ifdef CONFIG_DEBUG_RPI1_UART +static inline void debug_ll_init(void) +{ + /* Configured by ROM */ +} + #define DEBUG_LL_UART_ADDR BCM2835_PL011_BASE #include #elif defined CONFIG_DEBUG_RPI2_3_UART +static inline void debug_ll_init(void) +{ + /* Configured by ROM */ +} + #define DEBUG_LL_UART_ADDR BCM2836_PL011_BASE #include +#elif defined CONFIG_DEBUG_RPI3_MINI_UART + +static inline uint8_t debug_ll_read_reg(int reg) +{ + return readb(BCM2836_MINIUART_BASE + (reg << 2)); +} + +static inline void debug_ll_write_reg(int reg, uint8_t val) +{ + writeb(val, BCM2836_MINIUART_BASE + (reg << 2)); +} + +#define BCM2836_AUX_CLOCK_ENB 0x3f215004 /* BCM2835 AUX Clock enable register */ +#define BCM2836_AUX_CLOCK_EN_UART BIT(0) /* Bit 0 enables the Miniuart */ + +#include + +static inline void debug_ll_init(void) +{ + uint16_t divisor; + + writeb(BCM2836_AUX_CLOCK_EN_UART, BCM2836_AUX_CLOCK_ENB); + + divisor = debug_ll_ns16550_calc_divisor(25000 * 2); + debug_ll_ns16550_init(divisor); +} + #endif #endif /* __MACH_BCM2835_DEBUG_LL_H__ */ diff --git a/common/Kconfig b/common/Kconfig index 563cf15fb1..0c6acfcddb 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1173,6 +1173,12 @@ config DEBUG_RPI2_UART Say Y here if you want low-level debugging support on RaspberryPi 2 and 3 boards. +config DEBUG_RPI3_MINI_UART + bool "RaspberryPi 3 mini UART + depends on ARCH_BCM283X + help + Say Y here if you want low-level debugging support on + RaspberryPi 3 board mini UART. endchoice config DEBUG_IMX_UART_PORT -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 4/5] ARM: rpi: move debug UART Kconfig settings
In contrast to other architectures, R.Pi debug UART config was placed under the "System Type" menu, not under the "Debugging -> low-level debugging port". This made this setting easy to miss when enabling low level debug mesages. While at it use the existing base address defines rather than defining them again in Kconfig. Signed-off-by: Sascha Hauer --- arch/arm/mach-bcm283x/Kconfig | 20 --- arch/arm/mach-bcm283x/include/mach/debug_ll.h | 12 +++ common/Kconfig| 13 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig index bb5f75dc90..9d6a7b2ec2 100644 --- a/arch/arm/mach-bcm283x/Kconfig +++ b/arch/arm/mach-bcm283x/Kconfig @@ -33,24 +33,4 @@ config MACH_RPI_CM3 endmenu -config MACH_RPI_DEBUG_UART_BASE - hex - default 0x20201000 if MACH_RPI_DEBUG_UART_RPI - default 0x3f201000 if MACH_RPI_DEBUG_UART_RPI2 - -if DEBUG_LL - -choice - prompt "Lowlevel debug UART" - -config MACH_RPI_DEBUG_UART_RPI - bool "use RaspberryPi 1 compatible base" - -config MACH_RPI_DEBUG_UART_RPI2 - bool "use RaspberryPi 2 and 3 compatible base" - -endchoice - -endif - endif diff --git a/arch/arm/mach-bcm283x/include/mach/debug_ll.h b/arch/arm/mach-bcm283x/include/mach/debug_ll.h index 2e95bf8320..2d2103e338 100644 --- a/arch/arm/mach-bcm283x/include/mach/debug_ll.h +++ b/arch/arm/mach-bcm283x/include/mach/debug_ll.h @@ -20,12 +20,16 @@ #include -#ifndef CONFIG_MACH_RPI_DEBUG_UART_BASE -#define CONFIG_MACH_RPI_DEBUG_UART_BASE 0 -#endif +#ifdef CONFIG_DEBUG_RPI1_UART + +#define DEBUG_LL_UART_ADDR BCM2835_PL011_BASE +#include -#define DEBUG_LL_UART_ADDR CONFIG_MACH_RPI_DEBUG_UART_BASE +#elif defined CONFIG_DEBUG_RPI2_3_UART +#define DEBUG_LL_UART_ADDR BCM2836_PL011_BASE #include +#endif + #endif /* __MACH_BCM2835_DEBUG_LL_H__ */ diff --git a/common/Kconfig b/common/Kconfig index 21b33f06f7..563cf15fb1 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1159,6 +1159,19 @@ config DEBUG_SOCFPGA_UART1 Say Y here if you want kernel low-level debugging support on SOCFPGA(Arria 10) based platforms. +config DEBUG_RPI1_UART + bool "RaspberryPi 1 debug UART" + depends on ARCH_BCM283X + help + Say Y here if you want low-level debugging support on + RaspberryPi 1 boards. + +config DEBUG_RPI2_UART + bool "RaspberryPi 2/3 debug UART" + depends on ARCH_BCM283X + help + Say Y here if you want low-level debugging support on + RaspberryPi 2 and 3 boards. endchoice -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 2/5] debug_ll: Move pl011 header file to architecture independent place
Signed-off-by: Sascha Hauer --- arch/arm/mach-bcm283x/include/mach/debug_ll.h | 2 +- arch/arm/mach-highbank/include/mach/debug_ll.h | 2 +- arch/arm/mach-qemu/include/mach/debug_ll.h | 2 +- arch/arm/mach-versatile/include/mach/debug_ll.h | 2 +- arch/arm/mach-vexpress/include/mach/debug_ll.h | 2 +- .../include/asm/debug_ll_pl011.h => include/debug_ll/pl011.h| 0 6 files changed, 5 insertions(+), 5 deletions(-) rename arch/arm/include/asm/debug_ll_pl011.h => include/debug_ll/pl011.h (100%) diff --git a/arch/arm/mach-bcm283x/include/mach/debug_ll.h b/arch/arm/mach-bcm283x/include/mach/debug_ll.h index a625a8bdb7..2e95bf8320 100644 --- a/arch/arm/mach-bcm283x/include/mach/debug_ll.h +++ b/arch/arm/mach-bcm283x/include/mach/debug_ll.h @@ -26,6 +26,6 @@ #define DEBUG_LL_UART_ADDR CONFIG_MACH_RPI_DEBUG_UART_BASE -#include +#include #endif /* __MACH_BCM2835_DEBUG_LL_H__ */ diff --git a/arch/arm/mach-highbank/include/mach/debug_ll.h b/arch/arm/mach-highbank/include/mach/debug_ll.h index 1820eb1d13..5d0fae80e7 100644 --- a/arch/arm/mach-highbank/include/mach/debug_ll.h +++ b/arch/arm/mach-highbank/include/mach/debug_ll.h @@ -9,6 +9,6 @@ #define DEBUG_LL_UART_ADDR 0xfff36000 -#include +#include #endif diff --git a/arch/arm/mach-qemu/include/mach/debug_ll.h b/arch/arm/mach-qemu/include/mach/debug_ll.h index 89b06923ad..d59f68ea19 100644 --- a/arch/arm/mach-qemu/include/mach/debug_ll.h +++ b/arch/arm/mach-qemu/include/mach/debug_ll.h @@ -19,6 +19,6 @@ #define DEBUG_LL_UART_ADDR DEBUG_LL_PHYS_BASE_RS1 #endif -#include +#include #endif diff --git a/arch/arm/mach-versatile/include/mach/debug_ll.h b/arch/arm/mach-versatile/include/mach/debug_ll.h index e6ee877a54..073402c51a 100644 --- a/arch/arm/mach-versatile/include/mach/debug_ll.h +++ b/arch/arm/mach-versatile/include/mach/debug_ll.h @@ -18,6 +18,6 @@ #define DEBUG_LL_UART_ADDR 0x101F1000 -#include +#include #endif diff --git a/arch/arm/mach-vexpress/include/mach/debug_ll.h b/arch/arm/mach-vexpress/include/mach/debug_ll.h index 89b06923ad..d59f68ea19 100644 --- a/arch/arm/mach-vexpress/include/mach/debug_ll.h +++ b/arch/arm/mach-vexpress/include/mach/debug_ll.h @@ -19,6 +19,6 @@ #define DEBUG_LL_UART_ADDR DEBUG_LL_PHYS_BASE_RS1 #endif -#include +#include #endif diff --git a/arch/arm/include/asm/debug_ll_pl011.h b/include/debug_ll/pl011.h similarity index 100% rename from arch/arm/include/asm/debug_ll_pl011.h rename to include/debug_ll/pl011.h -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 0/5] ARM: rpi: refactor debug_ll
This picks up the series from Tomaž and also adds mini UART early debugging support useful for the rpi3 which comes up with this UART by default. The ns16550 early debugging support is done in a generic way which I tested on Layerscape. I don't have any raspberry pies here, so totally untested on these boards. Sascha Sascha Hauer (5): ARM: rpi: Move UART base address definitions to header file debug_ll: Move pl011 header file to architecture independent place debug_ll: Add ns16550 early debugging functions ARM: rpi: move debug UART Kconfig settings ARM: rpi: Add mini UART debug_ll support arch/arm/boards/raspberry-pi/rpi-common.c | 5 +- arch/arm/mach-bcm283x/Kconfig | 20 --- arch/arm/mach-bcm283x/include/mach/debug_ll.h | 51 +++-- arch/arm/mach-bcm283x/include/mach/platform.h | 4 ++ .../arm/mach-highbank/include/mach/debug_ll.h | 2 +- arch/arm/mach-qemu/include/mach/debug_ll.h| 2 +- .../mach-versatile/include/mach/debug_ll.h| 2 +- .../arm/mach-vexpress/include/mach/debug_ll.h | 2 +- common/Kconfig| 19 +++ include/debug_ll/ns16550.h| 56 +++ .../debug_ll/pl011.h | 0 11 files changed, 130 insertions(+), 33 deletions(-) create mode 100644 include/debug_ll/ns16550.h rename arch/arm/include/asm/debug_ll_pl011.h => include/debug_ll/pl011.h (100%) -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox