diff options
33 files changed, 298 insertions, 539 deletions
diff --git a/commands/of_dump.c b/commands/of_dump.c index 6792af3afc..2089c07ef7 100644 --- a/commands/of_dump.c +++ b/commands/of_dump.c @@ -36,9 +36,9 @@ static int do_of_dump(int argc, char *argv[]) char *dtbfile = NULL; size_t size; const char *nodename; - int names_only = 0; + int names_only = 0, properties_only = 0; - while ((opt = getopt(argc, argv, "Ff:n")) > 0) { + while ((opt = getopt(argc, argv, "Ff:np")) > 0) { switch (opt) { case 'f': dtbfile = optarg; @@ -49,6 +49,9 @@ static int do_of_dump(int argc, char *argv[]) case 'n': names_only = 1; break; + case 'p': + properties_only = 1; + break; default: return COMMAND_ERROR_USAGE; } @@ -111,8 +114,10 @@ static int do_of_dump(int argc, char *argv[]) goto out; } - if (names_only) + if (names_only && !properties_only) of_print_nodenames(node); + else if (properties_only && !names_only) + of_print_properties(node); else of_print_nodes(node, 0); @@ -128,12 +133,13 @@ BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree") BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree") BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties") +BAREBOX_CMD_HELP_OPT ("-p", "Print properties only, no child nodes") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_dump) .cmd = do_of_dump, BAREBOX_CMD_DESC("dump devicetree nodes") - BAREBOX_CMD_OPTS("[-fFn] [NODE]") + BAREBOX_CMD_OPTS("[-fFnp] [NODE]") BAREBOX_CMD_GROUP(CMD_GRP_MISC) BAREBOX_CMD_COMPLETE(devicetree_file_complete) BAREBOX_CMD_HELP(cmd_of_dump_help) diff --git a/common/boot.c b/common/boot.c index 07b67734d8..8220b8d3fb 100644 --- a/common/boot.c +++ b/common/boot.c @@ -138,7 +138,7 @@ int boot_entry(struct bootentry *be, int verbose, int dryrun) { int ret; - printf("Booting entry '%s'\n", be->title); + pr_info("Booting entry '%s'\n", be->title); if (IS_ENABLED(CONFIG_WATCHDOG) && boot_watchdog_timeout) { boot_enabled_watchdog = watchdog_get_default(); @@ -319,7 +319,7 @@ void bootsources_menu(struct bootentries *bootentries, int timeout) struct menu_entry *back_entry; if (!IS_ENABLED(CONFIG_MENU)) { - printf("no menu support available\n"); + pr_warn("no menu support available\n"); return; } diff --git a/common/bootm.c b/common/bootm.c index 092116beb9..644443a021 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -12,6 +12,7 @@ #include <environment.h> #include <linux/stat.h> #include <magicvar.h> +#include <uncompress.h> static LIST_HEAD(handler_list); @@ -111,7 +112,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address) data->os_res = request_sdram_region("kernel", load_address, kernel_size); if (!data->os_res) { - printf("unable to request SDRAM region for kernel at" + pr_err("unable to request SDRAM region for kernel at" "0x%08llx-0x%08llx\n", (unsigned long long)load_address, (unsigned long long)load_address + kernel_size - 1); @@ -175,7 +176,7 @@ static int bootm_open_initrd_uimage(struct image_data *data) if (bootm_get_verify_mode() > BOOTM_VERIFY_NONE) { ret = uimage_verify(data->initrd); if (ret) { - printf("Checking data crc failed with %s\n", + pr_err("Checking data crc failed with %s\n", strerror(-ret)); return ret; } @@ -231,21 +232,21 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address) load_address, initrd_size); if (!data->initrd_res) { - printf("unable to request SDRAM region for initrd at" + pr_err("unable to request SDRAM region for initrd at" "0x%08llx-0x%08llx\n", (unsigned long long)load_address, (unsigned long long)load_address + initrd_size - 1); return -ENOMEM; } memcpy((void *)load_address, initrd, initrd_size); - printf("Loaded initrd from FIT image\n"); + pr_info("Loaded initrd from FIT image\n"); goto done1; } type = file_name_detect_type(data->initrd_file); if ((int)type < 0) { - printf("could not open %s: %s\n", data->initrd_file, + pr_err("could not open %s: %s\n", data->initrd_file, strerror(-type)); return (int)type; } @@ -254,8 +255,8 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address) int num; ret = bootm_open_initrd_uimage(data); if (ret) { - printf("loading initrd failed with %s\n", - strerror(-ret)); + pr_err("loading initrd failed with %s\n", + strerror(-ret)); return ret; } @@ -275,13 +276,13 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address) done: - printf("Loaded initrd %s '%s'", file_type_to_string(type), + pr_info("Loaded initrd %s '%s'", file_type_to_string(type), data->initrd_file); if (type == filetype_uimage && data->initrd->header.ih_type == IH_TYPE_MULTI) - printf(", multifile image %s", data->initrd_part); - printf("\n"); + pr_info(", multifile image %s", data->initrd_part); + pr_info("\n"); done1: - printf("initrd is at %pa-%pa\n", + pr_info("initrd is at %pa-%pa\n", &data->initrd_res->start, &data->initrd_res->end); @@ -297,7 +298,7 @@ static int bootm_open_oftree_uimage(struct image_data *data, size_t *size, struct uimage_handle *of_handle; int release = 0; - printf("Loading devicetree from '%s'@%d\n", oftree, num); + pr_info("Loading devicetree from '%s'@%d\n", oftree, num); if (!IS_ENABLED(CONFIG_BOOTM_OFTREE_UIMAGE)) return -EINVAL; @@ -321,7 +322,7 @@ static int bootm_open_oftree_uimage(struct image_data *data, size_t *size, ft = file_detect_type(*fdt, *size); if (ft != filetype_oftree) { - printf("%s is not an oftree but %s\n", + pr_err("%s is not an oftree but %s\n", data->oftree_file, file_type_to_string(ft)); free(*fdt); return -EINVAL; @@ -367,8 +368,8 @@ void *bootm_get_devicetree(struct image_data *data) type = file_name_detect_type(data->oftree_file); if ((int)type < 0) { - printf("could not open %s: %s\n", data->oftree_file, - strerror(-type)); + pr_err("could not open %s: %s\n", data->oftree_file, + strerror(-type)); return ERR_PTR((int)type); } @@ -377,7 +378,7 @@ void *bootm_get_devicetree(struct image_data *data) ret = bootm_open_oftree_uimage(data, &size, &oftree); break; case filetype_oftree: - printf("Loading devicetree from '%s'\n", data->oftree_file); + pr_info("Loading devicetree from '%s'\n", data->oftree_file); ret = read_file_2(data->oftree_file, &size, (void *)&oftree, FILESIZE_MAX); break; @@ -448,7 +449,7 @@ int bootm_load_devicetree(struct image_data *data, void *fdt, data->oftree_res = request_sdram_region("oftree", load_address, fdt_size); if (!data->oftree_res) { - printf("unable to request SDRAM region for device tree at" + pr_err("unable to request SDRAM region for device tree at" "0x%08llx-0x%08llx\n", (unsigned long long)load_address, (unsigned long long)load_address + fdt_size - 1); @@ -497,7 +498,7 @@ static int bootm_open_os_uimage(struct image_data *data) if (bootm_get_verify_mode() > BOOTM_VERIFY_NONE) { ret = uimage_verify(data->os); if (ret) { - printf("Checking data crc failed with %s\n", + pr_err("Checking data crc failed with %s\n", strerror(-ret)); return ret; } @@ -506,7 +507,7 @@ static int bootm_open_os_uimage(struct image_data *data) uimage_print_contents(data->os); if (IH_ARCH == IH_ARCH_INVALID || data->os->header.ih_arch != IH_ARCH) { - printf("Unsupported Architecture 0x%x\n", + pr_err("Unsupported Architecture 0x%x\n", data->os->header.ih_arch); return -EINVAL; } @@ -526,7 +527,7 @@ static int bootm_open_elf(struct image_data *data) if (IS_ERR(data->elf)) return PTR_ERR(data->elf); - printf("Entry Point: %08llx\n", data->elf->entry); + pr_info("Entry Point: %08llx\n", data->elf->entry); data->os_address = data->elf->entry; @@ -578,7 +579,7 @@ int bootm_boot(struct bootm_data *bootm_data) size_t size; if (!bootm_data->os_file) { - printf("no image given\n"); + pr_err("no image given\n"); return -ENOENT; } @@ -599,7 +600,7 @@ int bootm_boot(struct bootm_data *bootm_data) ret = read_file_2(data->os_file, &size, &data->os_header, PAGE_SIZE); if (ret < 0 && ret != -EFBIG) { - printf("could not open %s: %s\n", data->os_file, + pr_err("could not open %s: %s\n", data->os_file, strerror(-ret)); goto err_out; } @@ -609,7 +610,7 @@ int bootm_boot(struct bootm_data *bootm_data) os_type = file_detect_type(data->os_header, PAGE_SIZE); if (!data->force && os_type == filetype_unknown) { - printf("Unknown OS filetype (try -f)\n"); + pr_err("Unknown OS filetype (try -f)\n"); ret = -EINVAL; goto err_out; } @@ -625,7 +626,7 @@ int bootm_boot(struct bootm_data *bootm_data) data->initrd_file = NULL; data->tee_file = NULL; if (os_type != filetype_oftree) { - printf("Signed boot and image is no FIT image, aborting\n"); + pr_err("Signed boot and image is no FIT image, aborting\n"); ret = -EINVAL; goto err_out; } @@ -637,7 +638,7 @@ int bootm_boot(struct bootm_data *bootm_data) fit = fit_open(data->os_file, data->verbose, data->verify); if (IS_ERR(fit)) { - printf("Loading FIT image %s failed with: %pe\n", data->os_file, fit); + pr_err("Loading FIT image %s failed with: %pe\n", data->os_file, fit); ret = PTR_ERR(fit); goto err_out; } @@ -647,7 +648,7 @@ int bootm_boot(struct bootm_data *bootm_data) data->fit_config = fit_open_configuration(data->os_fit, data->os_part); if (IS_ERR(data->fit_config)) { - printf("Cannot open FIT image configuration '%s'\n", + pr_err("Cannot open FIT image configuration '%s'\n", data->os_part ? data->os_part : "default"); ret = PTR_ERR(data->fit_config); goto err_out; @@ -663,8 +664,8 @@ int bootm_boot(struct bootm_data *bootm_data) kernel_img, "load", &data->os_address); if (!ret) - printf("Load address from FIT '%s': 0x%lx\n", - kernel_img, data->os_address); + pr_info("Load address from FIT '%s': 0x%lx\n", + kernel_img, data->os_address); /* Note: Error case uses default value. */ } if (data->os_entry == UIMAGE_SOME_ADDRESS) { @@ -675,8 +676,8 @@ int bootm_boot(struct bootm_data *bootm_data) "entry", &entry); if (!ret) { data->os_entry = entry - data->os_address; - printf("Entry address from FIT '%s': 0x%lx\n", - kernel_img, entry); + pr_info("Entry address from FIT '%s': 0x%lx\n", + kernel_img, entry); } /* Note: Error case uses default value. */ } @@ -685,8 +686,8 @@ int bootm_boot(struct bootm_data *bootm_data) if (os_type == filetype_uimage) { ret = bootm_open_os_uimage(data); if (ret) { - printf("Loading OS image failed with: %s\n", - strerror(-ret)); + pr_err("Loading OS image failed with: %s\n", + strerror(-ret)); goto err_out; } } @@ -694,8 +695,8 @@ int bootm_boot(struct bootm_data *bootm_data) if (os_type == filetype_elf) { ret = bootm_open_elf(data); if (ret) { - printf("Loading ELF image failed with: %s\n", - strerror(-ret)); + pr_err("Loading ELF image failed with: %s\n", + strerror(-ret)); data->elf = NULL; goto err_out; } @@ -724,7 +725,7 @@ int bootm_boot(struct bootm_data *bootm_data) rootarg = path_get_linux_rootarg(data->os_file); } if (!IS_ERR(rootarg)) { - printf("Adding \"%s\" to Kernel commandline\n", rootarg); + pr_info("Adding \"%s\" to Kernel commandline\n", rootarg); globalvar_add_simple("linux.bootargs.bootm.appendroot", rootarg); free(rootarg); @@ -736,7 +737,7 @@ int bootm_boot(struct bootm_data *bootm_data) char *machine_id_bootarg; if (!machine_id) { - printf("Providing machine id is enabled but no machine id set\n"); + pr_err("Providing machine id is enabled but no machine id set\n"); ret = -EINVAL; goto err_out; } @@ -746,12 +747,12 @@ int bootm_boot(struct bootm_data *bootm_data) free(machine_id_bootarg); } - printf("\nLoading %s '%s'", file_type_to_string(os_type), - data->os_file); + pr_info("\nLoading %s '%s'", file_type_to_string(os_type), + data->os_file); if (os_type == filetype_uimage && data->os->header.ih_type == IH_TYPE_MULTI) - printf(", multifile image %d", uimage_part_num(data->os_part)); - printf("\n"); + pr_info(", multifile image %d", uimage_part_num(data->os_part)); + pr_info("\n"); if (data->os_address == UIMAGE_SOME_ADDRESS) data->os_address = UIMAGE_INVALID_ADDRESS; @@ -760,10 +761,10 @@ int bootm_boot(struct bootm_data *bootm_data) handler = bootm_find_handler(os_type, data); if (!handler) { - printf("no image handler found for image type %s\n", - file_type_to_string(os_type)); + pr_err("no image handler found for image type %s\n", + file_type_to_string(os_type)); if (os_type == filetype_uimage) - printf("and OS type: %d\n", data->os->header.ih_os); + pr_err("and OS type: %d\n", data->os->header.ih_os); ret = -ENODEV; goto err_out; } @@ -775,7 +776,7 @@ int bootm_boot(struct bootm_data *bootm_data) ret = handler->bootm(data); if (data->dryrun) - printf("Dryrun. Aborted\n"); + pr_info("Dryrun. Aborted\n"); err_out: if (data->os_res) @@ -808,6 +809,86 @@ err_out: return ret; } +static int do_bootm_compressed(struct image_data *img_data) +{ + struct bootm_data bootm_data = { + .oftree_file = img_data->oftree_file, + .initrd_file = img_data->initrd_file, + .tee_file = img_data->tee_file, + .verbose = img_data->verbose, + .verify = img_data->verify, + .force = img_data->force, + .dryrun = img_data->dryrun, + .initrd_address = img_data->initrd_address, + .os_address = img_data->os_address, + .os_entry = img_data->os_entry, + }; + int from, to, ret; + char *dstpath; + + from = open(img_data->os_file, O_RDONLY); + if (from < 0) + return -ENODEV; + + dstpath = make_temp("bootm-compressed"); + if (!dstpath) { + ret = -ENOMEM; + goto fail_from; + } + + to = open(dstpath, O_CREAT | O_WRONLY); + if (to < 0) { + ret = -ENODEV; + goto fail_make_temp; + } + + ret = uncompress_fd_to_fd(from, to, uncompress_err_stdout); + if (ret) + goto fail_to; + + bootm_data.os_file = dstpath; + ret = bootm_boot(&bootm_data); + +fail_to: + close(to); + unlink(dstpath); +fail_make_temp: + free(dstpath); +fail_from: + close(from); + return ret; +} + +static struct image_handler bzip2_bootm_handler = { + .name = "BZIP2 compressed file", + .bootm = do_bootm_compressed, + .filetype = filetype_bzip2, +}; + +static struct image_handler gzip_bootm_handler = { + .name = "GZIP compressed file", + .bootm = do_bootm_compressed, + .filetype = filetype_gzip, +}; + +static struct image_handler lzo_bootm_handler = { + .name = "LZO compressed file", + .bootm = do_bootm_compressed, + .filetype = filetype_lzo_compressed, +}; + +static struct image_handler lz4_bootm_handler = { + .name = "LZ4 compressed file", + .bootm = do_bootm_compressed, + .filetype = filetype_lz4_compressed, +}; + +static struct image_handler xz_bootm_handler = { + .name = "XZ compressed file", + .bootm = do_bootm_compressed, + .filetype = filetype_xz_compressed, +}; + static int bootm_init(void) { globalvar_add_simple("bootm.image", NULL); @@ -830,6 +911,18 @@ static int bootm_init(void) globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode, bootm_verify_names, ARRAY_SIZE(bootm_verify_names)); + + if (IS_ENABLED(CONFIG_BZLIB)) + register_image_handler(&bzip2_bootm_handler); + if (IS_ENABLED(CONFIG_ZLIB)) + register_image_handler(&gzip_bootm_handler); + if (IS_ENABLED(CONFIG_LZO_DECOMPRESS)) + register_image_handler(&lzo_bootm_handler); + if (IS_ENABLED(CONFIG_LZ4_DECOMPRESS)) + register_image_handler(&lz4_bootm_handler); + if (IS_ENABLED(CONFIG_XZ_DECOMPRESS)) + register_image_handler(&xz_bootm_handler); + return 0; } late_initcall(bootm_init); diff --git a/common/oftree.c b/common/oftree.c index 60d4327155..5eaa63ad7e 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -16,6 +16,7 @@ #include <reset_source.h> #include <watchdog.h> #include <globalvar.h> +#include <magicvar.h> #define MAX_LEVEL 32 /* how deeply nested we will go */ @@ -115,7 +116,7 @@ void of_print_cmdline(struct device_node *root) cmdline = of_get_property(node, "bootargs", NULL); - printf("commandline: %s\n", cmdline); + pr_info("commandline: %s\n", cmdline); } static int of_fixup_bootargs_bootsource(struct device_node *root, @@ -161,16 +162,17 @@ static void watchdog_build_bootargs(struct watchdog *watchdog, struct device_nod free(buf); } -static int of_fixup_bootargs(struct device_node *root, void *unused) +static int bootargs_append = 0; +BAREBOX_MAGICVAR(global.linux.bootargs_append, "append to original oftree bootargs"); + +static int of_write_bootargs(struct device_node *node) { - struct device_node *node; const char *str; - int err; - int instance = reset_source_get_instance(); - struct device_d *dev; + char *buf = NULL; + int ret; if (IS_ENABLED(CONFIG_SYSTEMD_OF_WATCHDOG)) - watchdog_build_bootargs(boot_get_enabled_watchdog(), root); + watchdog_build_bootargs(boot_get_enabled_watchdog(), of_get_parent(node)); str = linux_bootargs_get(); if (!str) @@ -180,13 +182,36 @@ static int of_fixup_bootargs(struct device_node *root, void *unused) if (strlen(str) == 0) return 0; + if (bootargs_append) { + const char *oldstr; + + ret = of_property_read_string(node, "bootargs", &oldstr); + if (!ret) { + str = buf = basprintf("%s %s", oldstr, str); + if (!buf) + return -ENOMEM; + } + } + + ret = of_property_write_string(node, "bootargs", str); + free(buf); + return ret; +} + +static int of_fixup_bootargs(struct device_node *root, void *unused) +{ + struct device_node *node; + int err; + int instance = reset_source_get_instance(); + struct device_d *dev; + node = of_create_node(root, "/chosen"); if (!node) return -ENOMEM; of_property_write_string(node, "barebox-version", release_string); - err = of_property_write_string(node, "bootargs", str); + err = of_write_bootargs(node); if (err) return err; @@ -212,6 +237,7 @@ static int of_fixup_bootargs(struct device_node *root, void *unused) static int of_register_bootargs_fixup(void) { + globalvar_add_simple_bool("linux.bootargs_append", &bootargs_append); return of_register_fixup(of_fixup_bootargs, NULL); } late_initcall(of_register_bootargs_fixup); diff --git a/common/partitions/efi.c b/common/partitions/efi.c index 437c3d64f8..135b08901a 100644 --- a/common/partitions/efi.c +++ b/common/partitions/efi.c @@ -446,7 +446,14 @@ static void efi_partition(void *buf, struct block_device *blk, } nb_part = le32_to_cpu(gpt->num_partition_entries); - for (i = 0; i < MAX_PARTITION && i < nb_part; i++) { + + if (nb_part > MAX_PARTITION) { + dev_warn(blk->dev, "GPT has more partitions than we support (%d) > max partition number (%d)\n", + nb_part, MAX_PARTITION); + nb_part = MAX_PARTITION; + } + + for (i = 0; i < nb_part; i++) { if (!is_pte_valid(&ptes[i], last_lba(blk))) { dev_dbg(blk->dev, "Invalid pte %d\n", i); return; @@ -460,10 +467,6 @@ static void efi_partition(void *buf, struct block_device *blk, snprintf(pentry->partuuid, sizeof(pentry->partuuid), "%pUl", &ptes[i].unique_partition_guid); pd->used_entries++; } - - if (i > MAX_PARTITION) - dev_warn(blk->dev, "num_partition_entries (%d) > max partition number (%d)\n", - nb_part, MAX_PARTITION); } static struct partition_parser efi_partition_parser = { diff --git a/common/partitions/parser.h b/common/partitions/parser.h index 8ad134a9aa..69508932b3 100644 --- a/common/partitions/parser.h +++ b/common/partitions/parser.h @@ -11,7 +11,7 @@ #include <filetype.h> #include <linux/list.h> -#define MAX_PARTITION 8 +#define MAX_PARTITION 128 #define MAX_PARTITION_NAME 38 struct partition { diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 1038d20a12..aac5b69f34 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -75,7 +75,7 @@ int device_match_of_modalias(struct device_d *dev, struct driver_d *drv) { const struct platform_device_id *id = drv->id_table; const char *of_modalias = NULL, *p; - int cplen; + const struct property *prop; const char *compat; if (!device_match(dev, drv)) @@ -84,25 +84,16 @@ int device_match_of_modalias(struct device_d *dev, struct driver_d *drv) if (!id || !IS_ENABLED(CONFIG_OFDEVICE) || !dev->device_node) return -1; - compat = of_get_property(dev->device_node, "compatible", &cplen); - if (!compat) - return -1; - - p = strchr(compat, ','); - of_modalias = p ? p + 1 : compat; - - while (id->name) { - if (!strcmp(id->name, dev->name)) { - dev->id_entry = id; - return 0; - } + of_property_for_each_string(dev->device_node, "compatible", prop, compat) { + p = strchr(compat, ','); + of_modalias = p ? p + 1 : compat; - if (of_modalias && !strcmp(id->name, of_modalias)) { - dev->id_entry = id; - return 0; + for (id = drv->id_table; id->name; id++) { + if (!strcmp(id->name, dev->name) || !strcmp(id->name, of_modalias)) { + dev->id_entry = id; + return 0; + } } - - id++; } return -1; diff --git a/drivers/base/driver.c b/drivers/base/driver.c index f60533c59e..1fa3f6c6fa 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -480,9 +480,7 @@ int dev_set_name(struct device_d *dev, const char *fmt, ...) */ free(oldname); - WARN_ON(err < 0); - - return err; + return WARN_ON(err < 0) ? err : 0; } EXPORT_SYMBOL_GPL(dev_set_name); diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c index bb9a0b7c4a..8508fac717 100644 --- a/drivers/i2c/busses/i2c-designware.c +++ b/drivers/i2c/busses/i2c-designware.c @@ -274,7 +274,7 @@ static void i2c_dw_setup_timings(struct dw_i2c_dev *dw) if (!(dw->sda_hold_time & DW_IC_SDA_HOLD_RX_MASK)) dw->sda_hold_time |= 1 << DW_IC_SDA_HOLD_RX_SHIFT; - dev_dbg(&dw->adapter.dev, "adjust SDA hold time.\n"); + dev_dbg(dw->adapter.dev.parent, "adjust SDA hold time.\n"); writel(dw->sda_hold_time, dw->base + DW_IC_SDA_HOLD); } } @@ -547,9 +547,7 @@ static int i2c_dw_probe(struct device_d *pdev) ic_comp_type_value = readl(dw->base + DW_IC_COMP_TYPE); if (ic_comp_type_value != DW_IC_COMP_TYPE_VALUE) { - dev_err(pdev, - "unknown DesignWare IP block 0x%08x", - ic_comp_type_value); + dev_err(pdev, "unknown DesignWare IP block 0x%08x\n", ic_comp_type_value); ret = -ENODEV; goto fail; } @@ -574,7 +572,7 @@ static int i2c_dw_probe(struct device_d *pdev) ic_con = DW_IC_CON_SPEED_FAST; break; default: - dev_warn(pdev, "requested bitrate (%d) is not supported." + dev_warn(pdev, "requested bitrate (%d) is not supported.\n" " Falling back to 100kHz", bitrate); case 100000: /* FALLTHROUGH */ ic_con = DW_IC_CON_SPEED_STD; diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 4e46370241..ea193c84a7 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -28,13 +28,16 @@ #define KSZPHY_OMSO_MII_OVERRIDE BIT(0) /* general PHY control reg in vendor specific block. */ -#define MII_KSZPHY_CTRL 0x1F +#define MII_KSZPHY_CTRL 0x1F /* bitmap of PHY register to set interrupt mode */ #define KSZPHY_CTRL_INT_ACTIVE_HIGH BIT(9) #define KSZ9021_CTRL_INT_ACTIVE_HIGH BIT(14) #define KS8737_CTRL_INT_ACTIVE_HIGH BIT(14) #define KSZ8051_RMII_50MHZ_CLK BIT(7) +/* PHY Control 1 */ +#define MII_KSZPHY_CTRL_1 0x1e + /* Write/read to/from extended registers */ #define MII_KSZPHY_EXTREG 0x0b #define KSZPHY_EXTREG_WRITE 0x8000 @@ -63,18 +66,35 @@ static int kszphy_extended_read(struct phy_device *phydev, return phy_read(phydev, MII_KSZPHY_EXTREG_READ); } +/* Handle LED mode, shift = position of first led mode bit, usually 4 or 14 */ +static int kszphy_led_mode(struct phy_device *phydev, int reg, int shift) +{ + const struct device_d *dev = &phydev->dev; + const struct device_node *of_node = dev->device_node ? : dev->parent->device_node; + u32 val; + + if (!of_property_read_u32(of_node, "micrel,led-mode", &val)) { + if (val > 0x03) { + dev_err(dev, "led-mode 0x%02x out of range\n", val); + return -1; + } + return phy_modify(phydev, reg, 0x03 << shift, val << shift); + } + return 0; +} + static int kszphy_config_init(struct phy_device *phydev) { + kszphy_led_mode(phydev, MII_KSZPHY_CTRL_1, 14); + return 0; } static int ksz8021_config_init(struct phy_device *phydev) { - u16 val; + phy_set_bits(phydev, MII_KSZPHY_OMSO, KSZPHY_OMSO_B_CAST_OFF); - val = phy_read(phydev, MII_KSZPHY_OMSO); - val |= KSZPHY_OMSO_B_CAST_OFF; - phy_write(phydev, MII_KSZPHY_OMSO, val); + kszphy_led_mode(phydev, MII_KSZPHY_CTRL, 4); return 0; } @@ -89,6 +109,8 @@ static int ks8051_config_init(struct phy_device *phydev) phy_write(phydev, MII_KSZPHY_CTRL, regval); } + kszphy_led_mode(phydev, MII_KSZPHY_CTRL, 4); + return 0; } @@ -143,6 +165,8 @@ static int ksz9021_config_init(struct phy_device *phydev) ksz9021_load_values_from_of(phydev, of_node, MII_KSZPHY_TX_DATA_PAD_SKEW, tx_pad_skew_names); + + kszphy_led_mode(phydev, 0x11, 6); } return 0; diff --git a/drivers/of/base.c b/drivers/of/base.c index 6fe02649ee..0e8750efec 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1048,7 +1048,7 @@ int of_property_match_string(struct device_node *np, const char *propname, } EXPORT_SYMBOL_GPL(of_property_match_string); -const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, +const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur, u32 *pu) { const void *curv = cur; @@ -1074,7 +1074,7 @@ out_val: } EXPORT_SYMBOL_GPL(of_prop_next_u32); -const char *of_prop_next_string(struct property *prop, const char *cur) +const char *of_prop_next_string(const struct property *prop, const char *cur) { const void *curv = cur; const void *value; @@ -2002,6 +2002,14 @@ static void __of_print_property(struct property *p, int indent) printf(";\n"); } +void of_print_properties(struct device_node *node) +{ + struct property *prop; + + list_for_each_entry(prop, &node->properties, list) + __of_print_property(prop, 0); +} + static int __of_print_parents(struct device_node *node) { int indent, i; diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 3e8caa8710..c536a82c43 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -9,145 +9,6 @@ #include <common.h> #include <of.h> #include <linux/regulator/of_regulator.h> -#include <linux/regulator/machine.h> - -static int of_get_regulation_constraints(struct device_d *dev, - struct device_node *np, - struct regulator_init_data **init_data, - const struct regulator_desc *desc) -{ - struct regulation_constraints *constraints = &(*init_data)->constraints; - int ret; - u32 pval; - - constraints->name = of_get_property(np, "regulator-name", NULL); - - if (!of_property_read_u32(np, "regulator-min-microvolt", &pval)) - constraints->min_uV = pval; - - if (!of_property_read_u32(np, "regulator-max-microvolt", &pval)) - constraints->max_uV = pval; - - /* Voltage change possible? */ - if (constraints->min_uV != constraints->max_uV) - constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; - - /* Do we have a voltage range, if so try to apply it? */ - if (constraints->min_uV && constraints->max_uV) - constraints->apply_uV = true; - - if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval)) - constraints->uV_offset = pval; - if (!of_property_read_u32(np, "regulator-min-microamp", &pval)) - constraints->min_uA = pval; - if (!of_property_read_u32(np, "regulator-max-microamp", &pval)) - constraints->max_uA = pval; - - if (!of_property_read_u32(np, "regulator-input-current-limit-microamp", - &pval)) - constraints->ilim_uA = pval; - - /* Current change possible? */ - if (constraints->min_uA != constraints->max_uA) - constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; - - constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); - constraints->always_on = of_property_read_bool(np, "regulator-always-on"); - if (!constraints->always_on) /* status change should be possible. */ - constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; - - constraints->pull_down = of_property_read_bool(np, "regulator-pull-down"); - - if (of_property_read_bool(np, "regulator-allow-bypass")) - constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; - - if (of_property_read_bool(np, "regulator-allow-set-load")) - constraints->valid_ops_mask |= REGULATOR_CHANGE_DRMS; - - ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); - if (!ret) { - if (pval) - constraints->ramp_delay = pval; - else - constraints->ramp_disable = true; - } - - ret = of_property_read_u32(np, "regulator-settling-time-us", &pval); - if (!ret) - constraints->settling_time = pval; - - ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval); - if (!ret) - constraints->settling_time_up = pval; - if (constraints->settling_time_up && constraints->settling_time) { - pr_warn("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us'\n", - np); - constraints->settling_time_up = 0; - } - - ret = of_property_read_u32(np, "regulator-settling-time-down-us", - &pval); - if (!ret) - constraints->settling_time_down = pval; - if (constraints->settling_time_down && constraints->settling_time) { - pr_warn("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n", - np); - constraints->settling_time_down = 0; - } - - ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); - if (!ret) - constraints->enable_time = pval; - - constraints->soft_start = of_property_read_bool(np, - "regulator-soft-start"); - ret = of_property_read_u32(np, "regulator-active-discharge", &pval); - if (!ret) { - constraints->active_discharge = - (pval) ? REGULATOR_ACTIVE_DISCHARGE_ENABLE : - REGULATOR_ACTIVE_DISCHARGE_DISABLE; - } - - if (!of_property_read_u32(np, "regulator-system-load", &pval)) - constraints->system_load = pval; - - if (!of_property_read_u32(np, "regulator-max-step-microvolt", - &pval)) - constraints->max_uV_step = pval; - - constraints->over_current_protection = of_property_read_bool(np, - "regulator-over-current-protection"); - - return 0; -} - -/** - * of_get_regulator_init_data - extract regulator_init_data structure info - * @dev: device requesting for regulator_init_data - * @node: regulator device node - * @desc: regulator description - * - * Populates regulator_init_data structure by extracting data from device - * tree node, returns a pointer to the populated structure or NULL if memory - * alloc fails. - */ -struct regulator_init_data *of_get_regulator_init_data(struct device_d *dev, - struct device_node *node, - const struct regulator_desc *desc) -{ - struct regulator_init_data *init_data; - - if (!node) - return NULL; - - init_data = xzalloc(sizeof(*init_data)); - - if (of_get_regulation_constraints(dev, node, &init_data, desc)) - return NULL; - - return init_data; -} -EXPORT_SYMBOL_GPL(of_get_regulator_init_data); struct devm_of_regulator_matches { struct of_regulator_match *matches; @@ -192,7 +53,6 @@ int of_regulator_match(struct device_d *dev, struct device_node *node, for (i = 0; i < num_matches; i++) { struct of_regulator_match *match = &matches[i]; - match->init_data = NULL; match->of_node = NULL; } @@ -210,14 +70,6 @@ int of_regulator_match(struct device_d *dev, struct device_node *node, if (strcmp(match->name, name)) continue; - match->init_data = of_get_regulator_init_data(dev, child, - match->desc); - if (!match->init_data) { - dev_err(dev, - "failed to parse DT for regulator %pOFn\n", - child); - return -EINVAL; - } match->of_node = child; count++; break; diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 2516676f86..bd3404f9cf 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c @@ -46,61 +46,6 @@ static LIST_HEAD(udc_list); /* ------------------------------------------------------------------------- */ -#ifdef CONFIG_KERNEL_HAS_DMA - -int usb_gadget_map_request(struct usb_gadget *gadget, - struct usb_request *req, int is_in) -{ - if (req->length == 0) - return 0; - - if (req->num_sgs) { - int mapped; - - mapped = dma_map_sg(&gadget->dev, req->sg, req->num_sgs, - is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - if (mapped == 0) { - dev_err(&gadget->dev, "failed to map SGs\n"); - return -EFAULT; - } - - req->num_mapped_sgs = mapped; - } else { - req->dma = dma_map_single(&gadget->dev, req->buf, req->length, - is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - - if (dma_mapping_error(&gadget->dev, req->dma)) { - dev_err(&gadget->dev, "failed to map buffer\n"); - return -EFAULT; - } - } - - return 0; -} -EXPORT_SYMBOL_GPL(usb_gadget_map_request); - -void usb_gadget_unmap_request(struct usb_gadget *gadget, - struct usb_request *req, int is_in) -{ - if (req->length == 0) - return; - - if (req->num_mapped_sgs) { - dma_unmap_sg(&gadget->dev, req->sg, req->num_mapped_sgs, - is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - - req->num_mapped_sgs = 0; - } else { - dma_unmap_single(&gadget->dev, req->dma, req->length, - is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - } -} -EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); - -#endif /* CONFIG_HAS_DMA */ - -/* ------------------------------------------------------------------------- */ - void usb_gadget_set_state(struct usb_gadget *gadget, enum usb_device_state state) { diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c index 7b87f302a9..aa27941c8c 100644 --- a/drivers/usb/imx/chipidea-imx.c +++ b/drivers/usb/imx/chipidea-imx.c @@ -256,8 +256,11 @@ static int imx_chipidea_probe(struct device_d *dev) } ci->vbus = regulator_get(dev, "vbus"); - if (IS_ERR(ci->vbus)) + if (IS_ERR(ci->vbus)) { + dev_warn(dev, "Cannot get vbus regulator: %pe (ignoring)\n", + ci->vbus); ci->vbus = NULL; + } /* * Some devices have more than one clock, in this case they are enabled diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c index daabfe92d2..e7e420d38f 100644 --- a/drivers/video/atmel_lcdfb_core.c +++ b/drivers/video/atmel_lcdfb_core.c @@ -489,6 +489,7 @@ int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data) sinfo->dma_desc = dma_alloc_coherent(data->dma_desc_size, DMA_ADDRESS_BROKEN); + info->dev.parent = dev; ret = register_framebuffer(info); if (ret != 0) { dev_err(dev, "Failed to register framebuffer\n"); diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c index 3d52f8b6b8..d808bc5c9f 100644 --- a/drivers/video/bcm2835.c +++ b/drivers/video/bcm2835.c @@ -118,6 +118,7 @@ static int bcm2835fb_probe(struct device_d *dev) info->fbi.mode->xres = info->fbi.xres; info->fbi.mode->yres = info->fbi.yres; + info->fbi.dev.parent = dev; ret = register_framebuffer(&info->fbi); if (ret) { free(info); diff --git a/drivers/video/bochs/bochs_hw.c b/drivers/video/bochs/bochs_hw.c index 252350aebb..debdd36941 100644 --- a/drivers/video/bochs/bochs_hw.c +++ b/drivers/video/bochs/bochs_hw.c @@ -201,5 +201,6 @@ int bochs_hw_probe(struct device_d *dev, void __iomem *fb_map, void __iomem *mmi fb->priv = bochs; fb->fbops = &bochs_fb_ops; + fb->dev.parent = dev; return register_framebuffer(fb); } diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c index a3f195373b..f39b74676c 100644 --- a/drivers/video/imx-ipu-fb.c +++ b/drivers/video/imx-ipu-fb.c @@ -969,6 +969,7 @@ static int sdc_fb_register_overlay(struct ipu_fb_info *fbi, void *fb) sdc_enable_channel(fbi, overlay->screen_base, IDMAC_SDC_1); + fbi->overlay.dev.parent = &fbi->info.dev; ret = register_framebuffer(&fbi->overlay); if (ret < 0) { dev_err(fbi->dev, "failed to register framebuffer\n"); @@ -1039,6 +1040,7 @@ static int imxfb_probe(struct device_d *dev) sdc_enable_channel(fbi, info->screen_base, IDMAC_SDC_0); + fbi->info.dev.parent = dev; ret = register_framebuffer(&fbi->info); if (ret < 0) { dev_err(dev, "failed to register framebuffer\n"); diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c index 0b53916434..68e87ff3fb 100644 --- a/drivers/video/imx-ipu-v3/ipufb.c +++ b/drivers/video/imx-ipu-v3/ipufb.c @@ -336,6 +336,7 @@ static int ipufb_probe(struct device_d *dev) if (ret) dev_dbg(fbi->dev, "failed to get modes: %s\n", strerror(-ret)); + info->dev.parent = dev; ret = register_framebuffer(info); if (ret < 0) { dev_err(fbi->dev, "failed to register framebuffer\n"); diff --git a/drivers/video/imx.c b/drivers/video/imx.c index e93859775a..f4f58b3ce3 100644 --- a/drivers/video/imx.c +++ b/drivers/video/imx.c @@ -514,6 +514,7 @@ static int imxfb_register_overlay(struct imxfb_info *fbi, void *fb) overlay->blue = rgb->blue; overlay->transp = rgb->transp; + overlay->dev.parent = &fbi->info.dev; ret = register_framebuffer(overlay); if (ret < 0) { dev_err(fbi->dev, "failed to register framebuffer\n"); @@ -592,6 +593,7 @@ static int imxfb_probe(struct device_d *dev) imxfb_activate_var(&fbi->info); + fbi->info.dev.parent = dev; ret = register_framebuffer(&fbi->info); if (ret < 0) { dev_err(dev, "failed to register framebuffer\n"); diff --git a/drivers/video/omap.c b/drivers/video/omap.c index 009626fefc..52a68ef627 100644 --- a/drivers/video/omap.c +++ b/drivers/video/omap.c @@ -493,6 +493,7 @@ static int omapfb_probe(struct device_d *dev) goto out; } + info->dev.parent = dev; rc = register_framebuffer(info); if (rc < 0) { dev_err(dev, "failed to register framebuffer: %d\n", rc); diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c index a2ff4bce2a..45efa6b71d 100644 --- a/drivers/video/pxa.c +++ b/drivers/video/pxa.c @@ -533,6 +533,7 @@ static int pxafb_probe(struct device_d *dev) pxafb_activate_var(fbi); + fbi->info.dev.parent = dev; ret = register_framebuffer(&fbi->info); if (ret < 0) { dev_err(dev, "failed to register framebuffer\n"); diff --git a/drivers/video/s3c24xx.c b/drivers/video/s3c24xx.c index 84ed0aee39..eb784162db 100644 --- a/drivers/video/s3c24xx.c +++ b/drivers/video/s3c24xx.c @@ -395,6 +395,7 @@ static int s3cfb_probe(struct device_d *hw_dev) if (IS_ENABLED(CONFIG_DRIVER_VIDEO_S3C_VERBOSE)) hw_dev->info = s3cfb_info; + fbi.info.dev.parent = hw_dev; ret = register_framebuffer(&fbi.info); if (ret != 0) { dev_err(hw_dev, "Failed to register framebuffer\n"); diff --git a/drivers/video/simplefb-client.c b/drivers/video/simplefb-client.c index 2d0495f616..1f26ac5067 100644 --- a/drivers/video/simplefb-client.c +++ b/drivers/video/simplefb-client.c @@ -121,6 +121,7 @@ static int simplefb_probe(struct device_d *dev) info->xres, info->yres, info->bits_per_pixel, info->line_length); + info->dev.parent = dev; ret = register_framebuffer(info); if (ret < 0) { dev_err(dev, "Unable to register simplefb: %d\n", ret); diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c index 994f43dc5c..af5d6086e1 100644 --- a/drivers/video/ssd1307fb.c +++ b/drivers/video/ssd1307fb.c @@ -543,6 +543,7 @@ static int ssd1307fb_probe(struct device_d *dev) if (ret) goto reset_oled_error; + info->dev.parent = dev; ret = register_framebuffer(info); if (ret) { dev_err(&client->dev, "Couldn't register the framebuffer\n"); diff --git a/drivers/video/stm.c b/drivers/video/stm.c index d4a618fe50..28ddc649f8 100644 --- a/drivers/video/stm.c +++ b/drivers/video/stm.c @@ -571,6 +571,7 @@ static int stmfb_probe(struct device_d *hw_dev) fb_of_reserve_add_fixup(&fbi.info); + fbi.info.dev.parent = hw_dev; ret = register_framebuffer(&fbi.info); if (ret != 0) { dev_err(hw_dev, "Failed to register framebuffer\n"); diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index 4b0ee31d5b..2e2814a8f2 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -18,6 +18,7 @@ #include <errno.h> #include <linux/ctype.h> #include <watchdog.h> +#include <restart.h> static LIST_HEAD(watchdog_list); @@ -177,6 +178,24 @@ static int seconds_to_expire_get(struct param_d *p, void *priv) return 0; } +static void __noreturn watchdog_restart_handle(struct restart_handler *this) +{ + struct watchdog *wd = watchdog_get_default(); + int ret = -ENODEV; + + if (wd) + ret = watchdog_set_timeout(wd, 1); + + BUG_ON(ret); + mdelay(2000); + __builtin_unreachable(); +} + +static struct restart_handler restart_handler = { + .restart = watchdog_restart_handle, + .name = "watchdog-restart", +}; + int watchdog_register(struct watchdog *wd) { struct param_d *p; @@ -247,6 +266,13 @@ int watchdog_register(struct watchdog *wd) goto error_unregister; } + if (!restart_handler.priority) { + restart_handler.priority = 10; /* don't override others */ + ret = restart_handler_register(&restart_handler); + if (ret) + dev_warn(&wd->dev, "failed to register restart handler\n"); + } + list_add_tail(&wd->list, &watchdog_list); pr_debug("registering watchdog %s with priority %d\n", watchdog_name(wd), @@ -119,8 +119,8 @@ struct rpc_reply { uint32_t data[0]; }; -#define NFS_TIMEOUT (2 * SECOND) -#define NFS_MAX_RESEND 5 +#define NFS_TIMEOUT (100 * MSECOND) +#define NFS_MAX_RESEND 100 struct nfs_fh { unsigned short size; diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h deleted file mode 100644 index bb8bc7c4e0..0000000000 --- a/include/linux/regulator/machine.h +++ /dev/null @@ -1,207 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * machine.h -- SoC Regulator support, machine/board driver API. - * - * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. - * - * Author: Liam Girdwood <lrg@slimlogic.co.uk> - * - * Regulator Machine/Board Interface. - */ - -#ifndef __LINUX_REGULATOR_MACHINE_H_ -#define __LINUX_REGULATOR_MACHINE_H_ - -#include <regulator.h> - -struct regulator; - -/* - * Regulator operation constraint flags. These flags are used to enable - * certain regulator operations and can be OR'ed together. - * - * VOLTAGE: Regulator output voltage can be changed by software on this - * board/machine. - * CURRENT: Regulator output current can be changed by software on this - * board/machine. - * MODE: Regulator operating mode can be changed by software on this - * board/machine. - * STATUS: Regulator can be enabled and disabled. - * DRMS: Dynamic Regulator Mode Switching is enabled for this regulator. - * BYPASS: Regulator can be put into bypass mode - */ - -#define REGULATOR_CHANGE_VOLTAGE 0x1 -#define REGULATOR_CHANGE_CURRENT 0x2 -#define REGULATOR_CHANGE_MODE 0x4 -#define REGULATOR_CHANGE_STATUS 0x8 -#define REGULATOR_CHANGE_DRMS 0x10 -#define REGULATOR_CHANGE_BYPASS 0x20 - -/* Regulator active discharge flags */ -enum regulator_active_discharge { - REGULATOR_ACTIVE_DISCHARGE_DEFAULT, - REGULATOR_ACTIVE_DISCHARGE_DISABLE, - REGULATOR_ACTIVE_DISCHARGE_ENABLE, -}; - -/** - * struct regulation_constraints - regulator operating constraints. - * - * This struct describes regulator and board/machine specific constraints. - * - * @name: Descriptive name for the constraints, used for display purposes. - * - * @min_uV: Smallest voltage consumers may set. - * @max_uV: Largest voltage consumers may set. - * @uV_offset: Offset applied to voltages from consumer to compensate for - * voltage drops. - * - * @min_uA: Smallest current consumers may set. - * @max_uA: Largest current consumers may set. - * @ilim_uA: Maximum input current. - * @system_load: Load that isn't captured by any consumer requests. - * - * @max_spread: Max possible spread between coupled regulators - * @valid_modes_mask: Mask of modes which may be configured by consumers. - * @valid_ops_mask: Operations which may be performed by consumers. - * - * @always_on: Set if the regulator should never be disabled. - * @boot_on: Set if the regulator is enabled when the system is initially - * started. If the regulator is not enabled by the hardware or - * bootloader then it will be enabled when the constraints are - * applied. - * @apply_uV: Apply the voltage constraint when initialising. - * @ramp_disable: Disable ramp delay when initialising or when setting voltage. - * @soft_start: Enable soft start so that voltage ramps slowly. - * @pull_down: Enable pull down when regulator is disabled. - * @over_current_protection: Auto disable on over current event. - * - * @input_uV: Input voltage for regulator when supplied by another regulator. - * - * @initial_mode: Mode to set at startup. - * @ramp_delay: Time to settle down after voltage change (unit: uV/us) - * @settling_time: Time to settle down after voltage change when voltage - * change is non-linear (unit: microseconds). - * @settling_time_up: Time to settle down after voltage increase when voltage - * change is non-linear (unit: microseconds). - * @settling_time_down : Time to settle down after voltage decrease when - * voltage change is non-linear (unit: microseconds). - * @active_discharge: Enable/disable active discharge. The enum - * regulator_active_discharge values are used for - * initialisation. - * @enable_time: Turn-on time of the rails (unit: microseconds) - */ -struct regulation_constraints { - - const char *name; - - /* voltage output range (inclusive) - for voltage control */ - int min_uV; - int max_uV; - - int uV_offset; - - /* current output range (inclusive) - for current control */ - int min_uA; - int max_uA; - int ilim_uA; - - int system_load; - - /* used for coupled regulators */ - u32 *max_spread; - - /* used for changing voltage in steps */ - int max_uV_step; - - /* valid regulator operating modes for this machine */ - unsigned int valid_modes_mask; - - /* valid operations for regulator on this machine */ - unsigned int valid_ops_mask; - - /* regulator input voltage - only if supply is another regulator */ - int input_uV; - - /* mode to set on startup */ - unsigned int initial_mode; - - unsigned int ramp_delay; - unsigned int settling_time; - unsigned int settling_time_up; - unsigned int settling_time_down; - unsigned int enable_time; - - unsigned int active_discharge; - - /* constraint flags */ - unsigned always_on:1; /* regulator never off when system is on */ - unsigned boot_on:1; /* bootloader/firmware enabled regulator */ - unsigned apply_uV:1; /* apply uV constraint if min == max */ - unsigned ramp_disable:1; /* disable ramp delay */ - unsigned soft_start:1; /* ramp voltage slowly */ - unsigned pull_down:1; /* pull down resistor when regulator off */ - unsigned over_current_protection:1; /* auto disable on over current */ -}; - -/** - * struct regulator_consumer_supply - supply -> device mapping - * - * This maps a supply name to a device. Use of dev_name allows support for - * buses which make struct device available late such as I2C. - * - * @dev_name: Result of dev_name() for the consumer. - * @supply: Name for the supply. - */ -struct regulator_consumer_supply { - const char *dev_name; /* dev_name() for consumer */ - const char *supply; /* consumer supply - e.g. "vcc" */ -}; - -/* Initialize struct regulator_consumer_supply */ -#define REGULATOR_SUPPLY(_name, _dev_name) \ -{ \ - .supply = _name, \ - .dev_name = _dev_name, \ -} - -/** - * struct regulator_init_data - regulator platform initialisation data. - * - * Initialisation constraints, our supply and consumers supplies. - * - * @supply_regulator: Parent regulator. Specified using the regulator name - * as it appears in the name field in sysfs, which can - * be explicitly set using the constraints field 'name'. - * - * @constraints: Constraints. These must be specified for the regulator to - * be usable. - * @num_consumer_supplies: Number of consumer device supplies. - * @consumer_supplies: Consumer device supply configuration. - * - * @regulator_init: Callback invoked when the regulator has been registered. - * @driver_data: Data passed to regulator_init. - */ -struct regulator_init_data { - const char *supply_regulator; /* or NULL for system supply */ - - struct regulation_constraints constraints; - - int num_consumer_supplies; - struct regulator_consumer_supply *consumer_supplies; - - /* optional regulator machine specific init */ - int (*regulator_init)(void *driver_data); - void *driver_data; /* core does not touch this */ -}; - -#ifdef CONFIG_REGULATOR -void regulator_has_full_constraints(void); -#else -static inline void regulator_has_full_constraints(void) -{ -} -#endif - -#endif diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index 265b98d1ee..de6d053e26 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h @@ -14,28 +14,15 @@ struct regulator_desc; struct of_regulator_match { const char *name; void *driver_data; - struct regulator_init_data *init_data; struct device_node *of_node; const struct regulator_desc *desc; }; #if defined(CONFIG_OFDEVICE) -extern struct regulator_init_data - *of_get_regulator_init_data(struct device_d *dev, - struct device_node *node, - const struct regulator_desc *desc); extern int of_regulator_match(struct device_d *dev, struct device_node *node, struct of_regulator_match *matches, unsigned int num_matches); #else -static inline struct regulator_init_data - *of_get_regulator_init_data(struct device_d *dev, - struct device_node *node, - const struct regulator_desc *desc) -{ - return NULL; -} - static inline int of_regulator_match(struct device_d *dev, struct device_node *node, struct of_regulator_match *matches, diff --git a/include/of.h b/include/of.h index 645f429bde..ef2640e9eb 100644 --- a/include/of.h +++ b/include/of.h @@ -95,7 +95,7 @@ static inline void of_write_number(void *__cell, u64 val, int size) } } -static inline const void *of_property_get_value(struct property *pp) +static inline const void *of_property_get_value(const struct property *pp) { return pp->value ? pp->value : pp->value_const; } @@ -105,6 +105,7 @@ void of_print_property(const void *data, int len); void of_print_cmdline(struct device_node *root); void of_print_nodes(struct device_node *node, int indent); +void of_print_properties(struct device_node *node); void of_diff(struct device_node *a, struct device_node *b, int indent); int of_probe(void); int of_parse_dtb(struct fdt_header *fdt); @@ -216,9 +217,9 @@ extern int of_property_read_string_helper(const struct device_node *np, const char *propname, const char **out_strs, size_t sz, int index); -extern const __be32 *of_prop_next_u32(struct property *prop, +extern const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur, u32 *pu); -extern const char *of_prop_next_string(struct property *prop, const char *cur); +extern const char *of_prop_next_string(const struct property *prop, const char *cur); extern int of_property_write_bool(struct device_node *np, const char *propname, const bool value); @@ -520,13 +521,13 @@ static inline int of_property_read_string_helper(const struct device_node *np, return -ENOSYS; } -static inline const __be32 *of_prop_next_u32(struct property *prop, +static inline const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur, u32 *pu) { return 0; } -static inline const char *of_prop_next_string(struct property *prop, +static inline const char *of_prop_next_string(const struct property *prop, const char *cur) { return NULL; diff --git a/include/usb/gadget.h b/include/usb/gadget.h index 3e1d7153dc..431f316c46 100644 --- a/include/usb/gadget.h +++ b/include/usb/gadget.h @@ -1002,16 +1002,6 @@ void usb_free_all_descriptors(struct usb_function *f); /*-------------------------------------------------------------------------*/ -/* utility to simplify map/unmap of usb_requests to/from DMA */ - -extern int usb_gadget_map_request(struct usb_gadget *gadget, - struct usb_request *req, int is_in); - -extern void usb_gadget_unmap_request(struct usb_gadget *gadget, - struct usb_request *req, int is_in); - -/*-------------------------------------------------------------------------*/ - /* utility to set gadget state properly */ extern void usb_gadget_set_state(struct usb_gadget *gadget, diff --git a/lib/uncompress.c b/lib/uncompress.c index c47d319dbb..5c0d1e9f4d 100644 --- a/lib/uncompress.c +++ b/lib/uncompress.c @@ -24,6 +24,7 @@ #include <filetype.h> #include <malloc.h> #include <fs.h> +#include <libfile.h> static void *uncompress_buf; static unsigned int uncompress_size; @@ -142,7 +143,7 @@ static int uncompress_infd, uncompress_outfd; static int fill_fd(void *buf, unsigned int len) { - return read(uncompress_infd, buf, len); + return read_full(uncompress_infd, buf, len); } static int flush_fd(void *buf, unsigned int len) |