From 0427b9c52578b2bb0dc1a3058d732899d107f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 16 Oct 2016 17:13:55 +0200 Subject: cmd/tpm_test: Fix misleading code indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 6.2 reasonably complains about the current code: ../cmd/tpm_test.c: In function ‘do_tpmtest’: ../cmd/tpm_test.c:540:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] for (i = 0; i < argc; i++) ^~~ ../cmd/tpm_test.c:542:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’ printf("\n------\n"); ^~~~~~ Signed-off-by: Stefan Brüns Reviewed-by: Simon Glass Updated to remove C99 variable decl: Signed-off-by: Simon Glass diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c index 65332d1..3306405 100644 --- a/cmd/tpm_test.c +++ b/cmd/tpm_test.c @@ -532,15 +532,15 @@ static cmd_tbl_t cmd_cros_tpm_sub[] = { static int do_tpmtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *c; + int i; printf("argc = %d, argv = ", argc); - do { - int i = 0; - for (i = 0; i < argc; i++) - printf(" %s", argv[i]); - printf("\n------\n"); - } while (0); + for (i = 0; i < argc; i++) + printf(" %s", argv[i]); + + printf("\n------\n"); + argc--; argv++; c = find_cmd_tbl(argv[0], cmd_cros_tpm_sub, -- cgit v0.10.2 From a982b6f5149387d931442837f598c9589bbd12bf Mon Sep 17 00:00:00 2001 From: George McCollister Date: Mon, 17 Oct 2016 09:24:32 -0500 Subject: tpm: tpm_tis_lpc: Add support for AT97SC3204 The Atmel AT97SC3204 is also TIS compliant. Modify the tpm_tis_lpc driver to check for the vid/did used by the Atmel AT97SC3204 and report an appropriate description. Signed-off-by: George McCollister Reviewed-by: Simon Glass diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c index b4efbb5..d2b3783 100644 --- a/drivers/tpm/tpm_tis_lpc.c +++ b/drivers/tpm/tpm_tis_lpc.c @@ -21,6 +21,21 @@ #define PREFIX "lpc_tpm: " +enum i2c_chip_type { + SLB9635, + AT97SC3204, +}; + +static const char * const chip_name[] = { + [SLB9635] = "Infineon SLB9635 TT 1.2", + [AT97SC3204] = "Atmel AT97SC3204", +}; + +static const u32 chip_didvid[] = { + [SLB9635] = 0xb15d1, + [AT97SC3204] = 0x32041114, +}; + struct tpm_locality { u32 access; u8 padding0[4]; @@ -146,9 +161,9 @@ static int tis_wait_reg(struct tpm_tis_lpc_priv *priv, u32 *reg, u8 mask, static int tpm_tis_lpc_probe(struct udevice *dev) { struct tpm_tis_lpc_priv *priv = dev_get_priv(dev); - u32 vid, did; fdt_addr_t addr; u32 didvid; + ulong chip_type = dev_get_driver_data(dev); addr = dev_get_addr(dev); if (addr == FDT_ADDR_T_NONE) @@ -156,14 +171,15 @@ static int tpm_tis_lpc_probe(struct udevice *dev) priv->regs = map_sysmem(addr, 0); didvid = tpm_read_word(priv, &priv->regs[0].did_vid); - vid = didvid & 0xffff; - did = (didvid >> 16) & 0xffff; - if (vid != 0x15d1 || did != 0xb) { + if (didvid != chip_didvid[chip_type]) { + u32 vid, did; + vid = didvid & 0xffff; + did = (didvid >> 16) & 0xffff; debug("Invalid vendor/device ID %04x/%04x\n", vid, did); - return -ENOSYS; + return -ENODEV; } - debug("Found TPM %s by %s\n", "SLB9635 TT 1.2", "Infineon"); + debug("Found TPM: %s\n", chip_name[chip_type]); return 0; } @@ -421,11 +437,13 @@ static int tpm_tis_lpc_close(struct udevice *dev) static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size) { + ulong chip_type = dev_get_driver_data(dev); + if (size < 50) return -ENOSPC; - return snprintf(buf, size, "1.2 TPM (vendor %s, chip %s)", - "Infineon", "SLB9635 TT 1.2"); + return snprintf(buf, size, "1.2 TPM (%s)", + chip_name[chip_type]); } @@ -438,7 +456,8 @@ static const struct tpm_ops tpm_tis_lpc_ops = { }; static const struct udevice_id tpm_tis_lpc_ids[] = { - { .compatible = "infineon,slb9635lpc" }, + { .compatible = "infineon,slb9635lpc", .data = SLB9635 }, + { .compatible = "atmel,at97sc3204", .data = AT97SC3204 }, { } }; -- cgit v0.10.2 From 0317724e6c5db6229dbdc03dd9c9b68a559973fe Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 17 Oct 2016 21:09:32 -0400 Subject: sandboxfs: Fix resource leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that we free resources in sandbox_fs_ls Coverity is letting us know that in some cases we might leak. So in case of error we should still let os_dirent_free free anything that was allocated. Fixes: 86167089b71c ("sandbox/fs: Free memory allocated by os_dirent_ls") Reported-by: Coverity (CID: 153450) Cc: Stefan Brüns Cc: Simon Glass Signed-off-by: Tom Rini Reviewed-by: Simon Glass diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c index cd10fd6..ca80261 100644 --- a/fs/sandbox/sandboxfs.c +++ b/fs/sandbox/sandboxfs.c @@ -88,15 +88,16 @@ int sandbox_fs_ls(const char *dirname) ret = os_dirent_ls(dirname, &head); if (ret) - return ret; + goto out; for (node = head; node; node = node->next) { printf("%s %10lu %s\n", os_dirent_get_typename(node->type), node->size, node->name); } +out: os_dirent_free(head); - return 0; + return ret; } int sandbox_fs_exists(const char *filename) -- cgit v0.10.2 From 1bd876301b1b6a2046cd1415fff71f5e8a30e6b4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 13 Nov 2016 14:25:50 -0700 Subject: Makefile: Add a target to create the .cfg files A common requirement when converting CONFIG options to Kconfig is to check that the effective configuration has not changed due to the conversion. Add a target which creates this configuration (in the form of u-boot.cfg) but does not build U-Boot. This speeds up the checking. Signed-off-by: Simon Glass diff --git a/Makefile b/Makefile index 96ddc59..153e076 100644 --- a/Makefile +++ b/Makefile @@ -821,6 +821,8 @@ append = cat $(filter-out $< $(PHONY), $^) >> $@ quiet_cmd_pad_cat = CAT $@ cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@ +cfg: u-boot.cfg + all: $(ALL-y) ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y) @echo "===================== WARNING ======================" @@ -1527,6 +1529,7 @@ help: @echo ' cscope - Generate cscope index' @echo ' ubootrelease - Output the release version string (use with make -s)' @echo ' ubootversion - Output the version stored in Makefile (use with make -s)' + @echo " cfg - Don't build, just create the .cfg files" @echo '' @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' -- cgit v0.10.2 From b50113f373a95d28cf001eb20adc6ef56f8ba14c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 13 Nov 2016 14:25:51 -0700 Subject: buildman: Add an option to just create the config Normally buildman does a full build of a board. This includes creating the u-boot.cfg file which contains all the configuration options. Buildman uses this file with the -K option, to show differences in effective configuration for each commit. Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful. Add a -D option which causes buildman to only create the configuration. This is enough to support use of -K and can be done much more quickly (typically 5-10 times faster). Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index e27a285..d834d31 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -207,7 +207,8 @@ class Builder: def __init__(self, toolchains, base_dir, git_dir, num_threads, num_jobs, gnu_make='make', checkout=True, show_unknown=True, step=1, no_subdirs=False, full_path=False, verbose_build=False, - incremental=False, per_board_out_dir=False): + incremental=False, per_board_out_dir=False, + config_only=False): """Create a new Builder object Args: @@ -230,6 +231,7 @@ class Builder: mrproper when configuring per_board_out_dir: Build in a separate persistent directory per board rather than a thread-specific directory + config_only: Only configure each build, don't build it """ self.toolchains = toolchains self.base_dir = base_dir @@ -257,6 +259,7 @@ class Builder: self.no_subdirs = no_subdirs self.full_path = full_path self.verbose_build = verbose_build + self.config_only = config_only self.col = terminal.Color() diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 8974351..926f267 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -110,8 +110,8 @@ class BuilderThread(threading.Thread): return self.builder.do_make(commit, brd, stage, cwd, *args, **kwargs) - def RunCommit(self, commit_upto, brd, work_dir, do_config, force_build, - force_build_failures): + def RunCommit(self, commit_upto, brd, work_dir, do_config, do_build, + force_build, force_build_failures): """Build a particular commit. If the build is already done, and we are not forcing a build, we skip @@ -122,6 +122,7 @@ class BuilderThread(threading.Thread): brd: Board object to build work_dir: Directory to which the source will be checked out do_config: True to run a make _defconfig on the source + do_build: Try to build the source force_build: Force a build even if one was previously done force_build_failures: Force a bulid if the previous result showed failure @@ -231,6 +232,8 @@ class BuilderThread(threading.Thread): config_out += result.combined do_config = False # No need to configure next time if result.return_code == 0: + if not do_build: + args.append('cfg') result = self.Make(commit, brd, 'build', cwd, *args, env=env) result.stderr = result.stderr.replace(src_dir + '/', '') @@ -401,7 +404,7 @@ class BuilderThread(threading.Thread): force_build = False for commit_upto in range(0, len(job.commits), job.step): result, request_config = self.RunCommit(commit_upto, brd, - work_dir, do_config, + work_dir, do_config, not self.builder.config_only, force_build or self.builder.force_build, self.builder.force_build_failures) failed = result.return_code or result.stderr @@ -411,7 +414,7 @@ class BuilderThread(threading.Thread): # with a reconfig. if self.builder.force_config_on_failure: result, request_config = self.RunCommit(commit_upto, - brd, work_dir, True, True, False) + brd, work_dir, True, False, True, False) did_config = True if not self.builder.force_reconfig: do_config = request_config @@ -455,7 +458,8 @@ class BuilderThread(threading.Thread): else: # Just build the currently checked-out build result, request_config = self.RunCommit(None, brd, work_dir, True, - True, self.builder.force_build_failures) + not self.builder.config_only, True, + self.builder.force_build_failures) result.commit_upto = 0 self._WriteResult(result, job.keep_outputs) self.builder.out_queue.put(result) diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 3e3bd63..bd3776a 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -28,6 +28,8 @@ def ParseArgs(): parser.add_option('-d', '--detail', dest='show_detail', action='store_true', default=False, help='Show detailed information for each board in summary') + parser.add_option('-D', '--config-only', action='store_true', default=False, + help="Don't build, just configure each commit") parser.add_option('-e', '--show_errors', action='store_true', default=False, help='Show errors and warnings') parser.add_option('-f', '--force-build', dest='force_build', diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 0b6ab03..0b3ba94 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -258,7 +258,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, no_subdirs=options.no_subdirs, full_path=options.full_path, verbose_build=options.verbose_build, incremental=options.incremental, - per_board_out_dir=options.per_board_out_dir,) + per_board_out_dir=options.per_board_out_dir, + config_only=options.config_only) builder.force_config_on_failure = not options.quick if make_func: builder.do_make = make_func -- cgit v0.10.2 From 94d2ebe5bcbbbd15e879ee2204e037f321d66b68 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 13 Nov 2016 14:25:52 -0700 Subject: buildman: Add documentation for CONFIG checking The -K option is not mentioned in the README at present. Add some notes to describe how this is used. Signed-off-by: Simon Glass diff --git a/tools/buildman/README b/tools/buildman/README index 514bebc..89df94d 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -968,6 +968,43 @@ of the source tree, thus allowing rapid tested evolution of the code. SOURCE_DATE_EPOCH=0 ./tools/buildman/buildman -I -P tegra +Checking configuration +====================== + +A common requirement when converting CONFIG options to Kconfig is to check +that the effective configuration has not changed due to the conversion. +Buildman supports this with the -K option, used after a build. This shows +differences in effective configuration between one commit and the next. + +For example: + + $ buildman -b kc4 -sK + ... + 43: Convert CONFIG_SPL_USBETH_SUPPORT to Kconfig + arm: + + u-boot.cfg: CONFIG_SPL_ENV_SUPPORT=1 CONFIG_SPL_NET_SUPPORT=1 + + u-boot-spl.cfg: CONFIG_SPL_MMC_SUPPORT=1 CONFIG_SPL_NAND_SUPPORT=1 + + all: CONFIG_SPL_ENV_SUPPORT=1 CONFIG_SPL_MMC_SUPPORT=1 CONFIG_SPL_NAND_SUPPORT=1 CONFIG_SPL_NET_SUPPORT=1 + am335x_evm_usbspl : + + u-boot.cfg: CONFIG_SPL_ENV_SUPPORT=1 CONFIG_SPL_NET_SUPPORT=1 + + u-boot-spl.cfg: CONFIG_SPL_MMC_SUPPORT=1 CONFIG_SPL_NAND_SUPPORT=1 + + all: CONFIG_SPL_ENV_SUPPORT=1 CONFIG_SPL_MMC_SUPPORT=1 CONFIG_SPL_NAND_SUPPORT=1 CONFIG_SPL_NET_SUPPORT=1 + 44: Convert CONFIG_SPL_USB_HOST_SUPPORT to Kconfig + ... + +This shows that commit 44 enabled three new options for the board +am335x_evm_usbspl which were not enabled in commit 43. There is also a +summary for 'arm' showing all the changes detected for that architecture. +In this case there is only one board with changes, so 'arm' output is the +same as 'am335x_evm_usbspl'/ + +The -K option uses the u-boot.cfg, spl/u-boot-spl.cfg and tpl/u-boot-tpl.cfg +files which are produced by a build. If all you want is to check the +configuration you can in fact avoid doing a full build, using -D. This tells +buildman to configuration U-Boot and create the .cfg files, but not actually +build the source. This is 5-10 times faster than doing a full build. + + Other options ============= -- cgit v0.10.2 From b464f8e7ded33dc3f3c26dd905e1fa9807dd7526 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 13 Nov 2016 14:25:53 -0700 Subject: buildman: Squash useless output from -K When using #define CONFIG_SOME_OPTION, the value it set to '1'. When using defconfig (i.e. CONFIG_SOME_OPTION=y) the value is set to 'y'. This results in differences showing up with -K. These differences are seldom useful. Adjust buildman to suppress these differences by default. Signed-off-by: Simon Glass diff --git a/tools/buildman/README b/tools/buildman/README index 89df94d..62ab7b7 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1004,6 +1004,18 @@ configuration you can in fact avoid doing a full build, using -D. This tells buildman to configuration U-Boot and create the .cfg files, but not actually build the source. This is 5-10 times faster than doing a full build. +By default buildman considers the follow two configuration methods +equivalent: + + #define CONFIG_SOME_OPTION + + CONFIG_SOME_OPTION=y + +The former would appear in a header filer and the latter in a defconfig +file. The achieve this, buildman considers 'y' to be '1' in configuration +variables. This avoids lots of useless output when converting a CONFIG +option to Kconfig. To disable this behaviour, use --squash-config-y. + Other options ============= diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index d834d31..6905ed9 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -98,19 +98,22 @@ OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR, OUTCOME_UNKNOWN = range(4) # Translate a commit subject into a valid filename trans_valid_chars = string.maketrans("/: ", "---") -CONFIG_FILENAMES = [ +BASE_CONFIG_FILENAMES = [ + 'u-boot.cfg', 'u-boot-spl.cfg', 'u-boot-tpl.cfg' +] + +EXTRA_CONFIG_FILENAMES = [ '.config', '.config-spl', '.config-tpl', 'autoconf.mk', 'autoconf-spl.mk', 'autoconf-tpl.mk', 'autoconf.h', 'autoconf-spl.h','autoconf-tpl.h', - 'u-boot.cfg', 'u-boot-spl.cfg', 'u-boot-tpl.cfg' ] class Config: """Holds information about configuration settings for a board.""" - def __init__(self, target): + def __init__(self, config_filename, target): self.target = target self.config = {} - for fname in CONFIG_FILENAMES: + for fname in config_filename: self.config[fname] = {} def Add(self, fname, key, value): @@ -208,7 +211,7 @@ class Builder: gnu_make='make', checkout=True, show_unknown=True, step=1, no_subdirs=False, full_path=False, verbose_build=False, incremental=False, per_board_out_dir=False, - config_only=False): + config_only=False, squash_config_y=False): """Create a new Builder object Args: @@ -232,6 +235,7 @@ class Builder: per_board_out_dir: Build in a separate persistent directory per board rather than a thread-specific directory config_only: Only configure each build, don't build it + squash_config_y: Convert CONFIG options with the value 'y' to '1' """ self.toolchains = toolchains self.base_dir = base_dir @@ -260,6 +264,10 @@ class Builder: self.full_path = full_path self.verbose_build = verbose_build self.config_only = config_only + self.squash_config_y = squash_config_y + self.config_filenames = BASE_CONFIG_FILENAMES + if not self.squash_config_y: + self.config_filenames += EXTRA_CONFIG_FILENAMES self.col = terminal.Color() @@ -586,13 +594,15 @@ class Builder: key, value = values else: key = values[0] - value = '' + value = '1' if self.squash_config_y else '' if not key.startswith('CONFIG_'): continue elif not line or line[0] in ['#', '*', '/']: continue else: key, value = line.split('=', 1) + if self.squash_config_y and value == 'y': + value = '1' config[key] = value return config @@ -659,7 +669,7 @@ class Builder: if read_config: output_dir = self.GetBuildDir(commit_upto, target) - for name in CONFIG_FILENAMES: + for name in self.config_filenames: fname = os.path.join(output_dir, name) config[name] = self._ProcessConfig(fname) @@ -736,8 +746,8 @@ class Builder: line, board) last_was_warning = is_warning last_func = None - tconfig = Config(board.target) - for fname in CONFIG_FILENAMES: + tconfig = Config(self.config_filenames, board.target) + for fname in self.config_filenames: if outcome.config: for key, value in outcome.config[fname].iteritems(): tconfig.Add(fname, key, value) @@ -1193,7 +1203,7 @@ class Builder: arch_config_plus[arch] = {} arch_config_minus[arch] = {} arch_config_change[arch] = {} - for name in CONFIG_FILENAMES: + for name in self.config_filenames: arch_config_plus[arch][name] = {} arch_config_minus[arch][name] = {} arch_config_change[arch][name] = {} @@ -1210,7 +1220,7 @@ class Builder: tbase = self._base_config[target] tconfig = config[target] lines = [] - for name in CONFIG_FILENAMES: + for name in self.config_filenames: if not tconfig.config[name]: continue config_plus = {} @@ -1254,7 +1264,7 @@ class Builder: all_plus = {} all_minus = {} all_change = {} - for name in CONFIG_FILENAMES: + for name in self.config_filenames: all_plus.update(arch_config_plus[arch][name]) all_minus.update(arch_config_minus[arch][name]) all_change.update(arch_config_change[arch][name]) diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index bd3776a..0060e03 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -59,6 +59,8 @@ def ParseArgs(): default=False, help='Keep all build output files (e.g. binaries)') parser.add_option('-K', '--show-config', action='store_true', default=False, help='Show configuration changes in summary (both board config files and Kconfig)') + parser.add_option('--preserve-config-y', action='store_true', + default=False, help="Don't convert y to 1 in configs") parser.add_option('-l', '--list-error-boards', action='store_true', default=False, help='Show a list of boards next to each error/warning') parser.add_option('--list-tool-chains', action='store_true', default=False, diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 0b3ba94..545c2cb 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -259,7 +259,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, verbose_build=options.verbose_build, incremental=options.incremental, per_board_out_dir=options.per_board_out_dir, - config_only=options.config_only) + config_only=options.config_only, + squash_config_y=not options.preserve_config_y) builder.force_config_on_failure = not options.quick if make_func: builder.do_make = make_func -- cgit v0.10.2 From 960421ecb3db9220609b6f1dbcb9f972dbca9975 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 15 Nov 2016 15:32:59 -0700 Subject: buildman: Clean up odd characters on the terminal At present buildman leaves behind a few characters during its progress updates, which looks odd. Fix it. Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 6905ed9..236e061 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -443,7 +443,7 @@ class Builder: name += target Print(line + name, newline=False) - length = 14 + len(name) + length = 16 + len(name) self.ClearLine(length) def _GetOutputDir(self, commit_upto): -- cgit v0.10.2 From a9401b2bc93a750d1566174b18d23bcdc2a45b7b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Nov 2016 14:09:25 -0700 Subject: buildman: Rename do_build to config_only This variable name is needlessly confusion. Adjust it to use a 'positive' name instead. Signed-off-by: Simon Glass diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 926f267..f2b2acd 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -110,7 +110,7 @@ class BuilderThread(threading.Thread): return self.builder.do_make(commit, brd, stage, cwd, *args, **kwargs) - def RunCommit(self, commit_upto, brd, work_dir, do_config, do_build, + def RunCommit(self, commit_upto, brd, work_dir, do_config, config_only, force_build, force_build_failures): """Build a particular commit. @@ -122,7 +122,7 @@ class BuilderThread(threading.Thread): brd: Board object to build work_dir: Directory to which the source will be checked out do_config: True to run a make _defconfig on the source - do_build: Try to build the source + config_only: Only configure the source, do not build it force_build: Force a build even if one was previously done force_build_failures: Force a bulid if the previous result showed failure @@ -232,7 +232,7 @@ class BuilderThread(threading.Thread): config_out += result.combined do_config = False # No need to configure next time if result.return_code == 0: - if not do_build: + if config_only: args.append('cfg') result = self.Make(commit, brd, 'build', cwd, *args, env=env) @@ -404,7 +404,7 @@ class BuilderThread(threading.Thread): force_build = False for commit_upto in range(0, len(job.commits), job.step): result, request_config = self.RunCommit(commit_upto, brd, - work_dir, do_config, not self.builder.config_only, + work_dir, do_config, self.builder.config_only, force_build or self.builder.force_build, self.builder.force_build_failures) failed = result.return_code or result.stderr @@ -458,7 +458,7 @@ class BuilderThread(threading.Thread): else: # Just build the currently checked-out build result, request_config = self.RunCommit(None, brd, work_dir, True, - not self.builder.config_only, True, + self.builder.config_only, True, self.builder.force_build_failures) result.commit_upto = 0 self._WriteResult(result, job.keep_outputs) -- cgit v0.10.2 From 2f11cd9121658b65a1d0789b37f290b207993a34 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 13 Nov 2016 14:21:58 -0700 Subject: dm: core: Handle global_data moving in SPL When CONFIG_SPL_STACK_R is enabled, and spl_init() is called before board_init_r(), spl_relocate_stack_gd() will move global_data to a new place in memory. This affects driver model since it uses a list for the uclasses. Unless this is updated the list will become invalid. When looking for a non-existent uclass, such as when adding a new one, the loop in uclass_find() may continue forever, thus causing a hang. Add a function to correct this rather obscure bug. Signed-off-by: Simon Glass diff --git a/common/spl/spl.c b/common/spl/spl.c index 32b9f1e..9bcbd09 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -513,6 +513,9 @@ ulong spl_relocate_stack_gd(void) ptr = CONFIG_SPL_STACK_R_ADDR - roundup(sizeof(gd_t),16); new_gd = (gd_t *)ptr; memcpy(new_gd, (void *)gd, sizeof(gd_t)); +#if CONFIG_IS_ENABLED(DM) + dm_fixup_for_gd_move(new_gd); +#endif #if !defined(CONFIG_ARM) gd = new_gd; #endif diff --git a/drivers/core/root.c b/drivers/core/root.c index 33dc9c0..9edfc1e 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -41,6 +41,13 @@ struct udevice *dm_root(void) return gd->dm_root; } +void dm_fixup_for_gd_move(struct global_data *new_gd) +{ + /* The sentinel node has moved, so update things that point to it */ + new_gd->uclass_root.next->prev = &new_gd->uclass_root; + new_gd->uclass_root.prev->next = &new_gd->uclass_root; +} + fdt_addr_t dm_get_translation_offset(void) { struct udevice *root = dm_root(); diff --git a/include/dm/root.h b/include/dm/root.h index c7f0c1d..3cf730d 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -21,6 +21,16 @@ struct udevice; */ struct udevice *dm_root(void); +struct global_data; +/** + * dm_fixup_for_gd_move() - Handle global_data moving to a new place + * + * The uclass list is part of global_data. Due to the way lists work, moving + * the list will cause it to become invalid. This function fixes that up so + * that the uclass list will work correctly. + */ +void dm_fixup_for_gd_move(struct global_data *new_gd); + /** * dm_scan_platdata() - Scan all platform data and bind drivers * -- cgit v0.10.2 From 4408f6f445acc242efc8dcf3c346ca3f3a9bc9f0 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 16 Nov 2016 17:37:42 +0100 Subject: dm: blk: Fix get_desc to return block device descriptor Current get_desc() implementation is not able to succesfully finish and return pointer to block device descriptor. Also function always return non zero value even device is found. The patch fills block device descriptor and return 0 if device is found. Signed-off-by: Michal Simek Reviewed-by: Simon Glass diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 6ba1026..2e041c2 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -156,6 +156,8 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp) if (ret) return ret; + *descp = desc; + return 0; } else if (desc->devnum > devnum) { found_more = true; } -- cgit v0.10.2 From 17b4f308cd3571e209e141b039aafb957f3096a5 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Fri, 18 Nov 2016 10:49:13 +0530 Subject: drivers: usb: gadget: ether: access network_started using local variable network_started of struct eth_dev can be accessed using local variable dev and no reason to access it with the global struct. Signed-off-by: Mugunthan V N Reviewed-by: Simon Glass Acked-by: Joe Hershberger diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 497b981..1873c13 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -1135,7 +1135,7 @@ static void eth_status_complete(struct usb_ep *ep, struct usb_request *req) event->bNotificationType, value); if (event->bNotificationType == USB_CDC_NOTIFY_SPEED_CHANGE) { - l_ethdev.network_started = 1; + dev->network_started = 1; printf("USB network up!\n"); } } @@ -1323,7 +1323,7 @@ eth_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) * that network is working. So we signalize it * here. */ - l_ethdev.network_started = 1; + dev->network_started = 1; debug("USB network up!\n"); goto done_set_intf; } @@ -1823,10 +1823,10 @@ static void rndis_control_ack_complete(struct usb_ep *ep, debug("rndis control ack complete --> %d, %d/%d\n", req->status, req->actual, req->length); - if (!l_ethdev.network_started) { + if (!dev->network_started) { if (rndis_get_state(dev->rndis_config) == RNDIS_DATA_INITIALIZED) { - l_ethdev.network_started = 1; + dev->network_started = 1; printf("USB RNDIS network up!\n"); } } @@ -2357,7 +2357,7 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) timeout = simple_strtoul(getenv("cdc_connect_timeout"), NULL, 10) * CONFIG_SYS_HZ; ts = get_timer(0); - while (!l_ethdev.network_started) { + while (!dev->network_started) { /* Handle control-c and timeouts */ if (ctrlc() || (get_timer(ts) > timeout)) { error("The remote end did not respond in time."); -- cgit v0.10.2 From d4345aee539e5c09559f64404f85593acd7e6ee6 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Fri, 18 Nov 2016 10:49:12 +0530 Subject: drivers: usb: gadget: ether: adopt to usb driver model Convert usb ether gadget to adopt usb driver model Signed-off-by: Mugunthan V N Reviewed-by: Simon Glass Acked-by: Joe Hershberger diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 1873c13..71d9252 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -24,6 +24,10 @@ #include "gadget_chips.h" #include "rndis.h" +#include +#include +#include + #define USB_NET_NAME "usb_ether" #define atomic_read @@ -101,6 +105,9 @@ struct eth_dev { struct usb_gadget *gadget; struct usb_request *req; /* for control responses */ struct usb_request *stat_req; /* for cdc & rndis status */ +#ifdef CONFIG_DM_USB + struct udevice *usb_udev; +#endif u8 config; struct usb_ep *in_ep, *out_ep, *status_ep; @@ -2303,6 +2310,24 @@ fail: /*-------------------------------------------------------------------------*/ +#ifdef CONFIG_DM_USB +int dm_usb_init(struct eth_dev *e_dev) +{ + struct udevice *dev = NULL; + int ret; + + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev); + if (!dev || ret) { + error("No USB device found\n"); + return -ENODEV; + } + + e_dev->usb_udev = dev; + + return ret; +} +#endif + static int usb_eth_init(struct eth_device *netdev, bd_t *bd) { struct eth_dev *dev = &l_ethdev; @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) goto fail; } +#ifdef CONFIG_DM_USB + if (dm_usb_init(dev)) { + error("USB ether not found\n"); + return -ENODEV; + } +#else board_usb_init(0, USB_INIT_DEVICE); +#endif /* Configure default mac-addresses for the USB ethernet device */ #ifdef CONFIG_USBNET_DEV_ADDR @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev) } usb_gadget_unregister_driver(ð_driver); +#ifdef CONFIG_DM_USB + device_remove(dev->usb_udev); +#else board_usb_cleanup(0, USB_INIT_DEVICE); +#endif } static struct usb_gadget_driver eth_driver = { -- cgit v0.10.2 From 5cb3b9d7c7cf2ab2bffaeaddef49378b28ccea5d Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Fri, 18 Nov 2016 11:06:13 +0530 Subject: drivers: usb: gadget: ether: consolidate global devices to single struct Consolidate the net device, usb eth device and gadget device struct to single struct and a single global variable so that the same can be passed as priv of ethernet driver. Signed-off-by: Mugunthan V N Reviewed-by: Simon Glass Acked-by: Joe Hershberger diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 71d9252..16edeea 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -141,9 +141,14 @@ struct eth_dev { */ /*-------------------------------------------------------------------------*/ -static struct eth_dev l_ethdev; -static struct eth_device l_netdev; -static struct usb_gadget_driver eth_driver; +struct ether_priv { + struct eth_dev ethdev; + struct eth_device netdev; + struct usb_gadget_driver eth_driver; +}; + +struct ether_priv eth_priv; +struct ether_priv *l_priv = ð_priv; /*-------------------------------------------------------------------------*/ @@ -1848,7 +1853,7 @@ static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32)))); static int rndis_control_ack(struct eth_device *net) { - struct eth_dev *dev = &l_ethdev; + struct eth_dev *dev = &l_priv->ethdev; int length; struct usb_request *resp = dev->stat_req; @@ -1989,7 +1994,7 @@ static int get_ether_addr(const char *str, u8 *dev_addr) static int eth_bind(struct usb_gadget *gadget) { - struct eth_dev *dev = &l_ethdev; + struct eth_dev *dev = &l_priv->ethdev; u8 cdc = 1, zlp = 1, rndis = 1; struct usb_ep *in_ep, *out_ep, *status_ep = NULL; int status = -ENOMEM; @@ -2182,7 +2187,7 @@ autoconf_fail: /* network device setup */ - dev->net = &l_netdev; + dev->net = &l_priv->netdev; dev->cdc = cdc; dev->zlp = zlp; @@ -2330,7 +2335,7 @@ int dm_usb_init(struct eth_dev *e_dev) static int usb_eth_init(struct eth_device *netdev, bd_t *bd) { - struct eth_dev *dev = &l_ethdev; + struct eth_dev *dev = &l_priv->ethdev; struct usb_gadget *gadget; unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT; @@ -2374,7 +2379,15 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) goto fail; } - if (usb_gadget_register_driver(ð_driver) < 0) + l_priv->eth_driver.speed = DEVSPEED; + l_priv->eth_driver.bind = eth_bind; + l_priv->eth_driver.unbind = eth_unbind; + l_priv->eth_driver.setup = eth_setup; + l_priv->eth_driver.reset = eth_disconnect; + l_priv->eth_driver.disconnect = eth_disconnect; + l_priv->eth_driver.suspend = eth_suspend; + l_priv->eth_driver.resume = eth_resume; + if (usb_gadget_register_driver(&l_priv->eth_driver) < 0) goto fail; dev->network_started = 0; @@ -2409,7 +2422,7 @@ static int usb_eth_send(struct eth_device *netdev, void *packet, int length) { int retval; void *rndis_pkt = NULL; - struct eth_dev *dev = &l_ethdev; + struct eth_dev *dev = &l_priv->ethdev; struct usb_request *req = dev->tx_req; unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT; @@ -2476,7 +2489,7 @@ drop: static int usb_eth_recv(struct eth_device *netdev) { - struct eth_dev *dev = &l_ethdev; + struct eth_dev *dev = &l_priv->ethdev; usb_gadget_handle_interrupts(0); @@ -2496,7 +2509,7 @@ static int usb_eth_recv(struct eth_device *netdev) void usb_eth_halt(struct eth_device *netdev) { - struct eth_dev *dev = &l_ethdev; + struct eth_dev *dev = &l_priv->ethdev; if (!netdev) { error("received NULL ptr"); @@ -2528,7 +2541,7 @@ void usb_eth_halt(struct eth_device *netdev) dev->network_started = 0; } - usb_gadget_unregister_driver(ð_driver); + usb_gadget_unregister_driver(&l_priv->eth_driver); #ifdef CONFIG_DM_USB device_remove(dev->usb_udev); #else @@ -2536,23 +2549,9 @@ void usb_eth_halt(struct eth_device *netdev) #endif } -static struct usb_gadget_driver eth_driver = { - .speed = DEVSPEED, - - .bind = eth_bind, - .unbind = eth_unbind, - - .setup = eth_setup, - .reset = eth_disconnect, - .disconnect = eth_disconnect, - - .suspend = eth_suspend, - .resume = eth_resume, -}; - int usb_eth_initialize(bd_t *bi) { - struct eth_device *netdev = &l_netdev; + struct eth_device *netdev = &l_priv->netdev; strlcpy(netdev->name, USB_NET_NAME, sizeof(netdev->name)); -- cgit v0.10.2 From ae70100c1f92845386526e6cf62fe043a872f396 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Fri, 18 Nov 2016 11:07:18 +0530 Subject: drivers: usb: gadget: ether: use net device priv to pass usb ether priv Use net device priv to pass usb ether priv and use it in net device ops callback. Signed-off-by: Mugunthan V N Reviewed-by: Simon Glass Acked-by: Joe Hershberger diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 16edeea..54b8b59 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -1853,7 +1853,8 @@ static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32)))); static int rndis_control_ack(struct eth_device *net) { - struct eth_dev *dev = &l_priv->ethdev; + struct ether_priv *priv = (struct ether_priv *)net->priv; + struct eth_dev *dev = &priv->ethdev; int length; struct usb_request *resp = dev->stat_req; @@ -2335,16 +2336,12 @@ int dm_usb_init(struct eth_dev *e_dev) static int usb_eth_init(struct eth_device *netdev, bd_t *bd) { - struct eth_dev *dev = &l_priv->ethdev; + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + struct eth_dev *dev = &priv->ethdev; struct usb_gadget *gadget; unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT; - if (!netdev) { - error("received NULL ptr"); - goto fail; - } - #ifdef CONFIG_DM_USB if (dm_usb_init(dev)) { error("USB ether not found\n"); @@ -2379,15 +2376,15 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) goto fail; } - l_priv->eth_driver.speed = DEVSPEED; - l_priv->eth_driver.bind = eth_bind; - l_priv->eth_driver.unbind = eth_unbind; - l_priv->eth_driver.setup = eth_setup; - l_priv->eth_driver.reset = eth_disconnect; - l_priv->eth_driver.disconnect = eth_disconnect; - l_priv->eth_driver.suspend = eth_suspend; - l_priv->eth_driver.resume = eth_resume; - if (usb_gadget_register_driver(&l_priv->eth_driver) < 0) + priv->eth_driver.speed = DEVSPEED; + priv->eth_driver.bind = eth_bind; + priv->eth_driver.unbind = eth_unbind; + priv->eth_driver.setup = eth_setup; + priv->eth_driver.reset = eth_disconnect; + priv->eth_driver.disconnect = eth_disconnect; + priv->eth_driver.suspend = eth_suspend; + priv->eth_driver.resume = eth_resume; + if (usb_gadget_register_driver(&priv->eth_driver) < 0) goto fail; dev->network_started = 0; @@ -2422,7 +2419,8 @@ static int usb_eth_send(struct eth_device *netdev, void *packet, int length) { int retval; void *rndis_pkt = NULL; - struct eth_dev *dev = &l_priv->ethdev; + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + struct eth_dev *dev = &priv->ethdev; struct usb_request *req = dev->tx_req; unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT; @@ -2489,7 +2487,8 @@ drop: static int usb_eth_recv(struct eth_device *netdev) { - struct eth_dev *dev = &l_priv->ethdev; + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + struct eth_dev *dev = &priv->ethdev; usb_gadget_handle_interrupts(0); @@ -2509,12 +2508,8 @@ static int usb_eth_recv(struct eth_device *netdev) void usb_eth_halt(struct eth_device *netdev) { - struct eth_dev *dev = &l_priv->ethdev; - - if (!netdev) { - error("received NULL ptr"); - return; - } + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + struct eth_dev *dev = &priv->ethdev; /* If the gadget not registered, simple return */ if (!dev->gadget) @@ -2541,7 +2536,7 @@ void usb_eth_halt(struct eth_device *netdev) dev->network_started = 0; } - usb_gadget_unregister_driver(&l_priv->eth_driver); + usb_gadget_unregister_driver(&priv->eth_driver); #ifdef CONFIG_DM_USB device_remove(dev->usb_udev); #else @@ -2559,6 +2554,7 @@ int usb_eth_initialize(bd_t *bi) netdev->send = usb_eth_send; netdev->recv = usb_eth_recv; netdev->halt = usb_eth_halt; + netdev->priv = l_priv; #ifdef CONFIG_MCAST_TFTP #error not supported -- cgit v0.10.2 From 8269ee4f969fc66564e6e4d2744654db5f5b11ad Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Fri, 18 Nov 2016 11:08:27 +0530 Subject: drivers: usb: gadget: ether: prepare driver for driver model migration prepare driver for driver model migration Signed-off-by: Mugunthan V N Acked-by: Joe Hershberger diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 54b8b59..046ad8c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -2334,9 +2334,8 @@ int dm_usb_init(struct eth_dev *e_dev) } #endif -static int usb_eth_init(struct eth_device *netdev, bd_t *bd) +static int _usb_eth_init(struct ether_priv *priv) { - struct ether_priv *priv = (struct ether_priv *)netdev->priv; struct eth_dev *dev = &priv->ethdev; struct usb_gadget *gadget; unsigned long ts; @@ -2415,11 +2414,10 @@ fail: return -1; } -static int usb_eth_send(struct eth_device *netdev, void *packet, int length) +static int _usb_eth_send(struct ether_priv *priv, void *packet, int length) { int retval; void *rndis_pkt = NULL; - struct ether_priv *priv = (struct ether_priv *)netdev->priv; struct eth_dev *dev = &priv->ethdev; struct usb_request *req = dev->tx_req; unsigned long ts; @@ -2485,30 +2483,15 @@ drop: return -ENOMEM; } -static int usb_eth_recv(struct eth_device *netdev) +static int _usb_eth_recv(struct ether_priv *priv) { - struct ether_priv *priv = (struct ether_priv *)netdev->priv; - struct eth_dev *dev = &priv->ethdev; - usb_gadget_handle_interrupts(0); - if (packet_received) { - debug("%s: packet received\n", __func__); - if (dev->rx_req) { - net_process_received_packet(net_rx_packets[0], - dev->rx_req->length); - packet_received = 0; - - rx_submit(dev, dev->rx_req, 0); - } else - error("dev->rx_req invalid"); - } return 0; } -void usb_eth_halt(struct eth_device *netdev) +void _usb_eth_halt(struct ether_priv *priv) { - struct ether_priv *priv = (struct ether_priv *)netdev->priv; struct eth_dev *dev = &priv->ethdev; /* If the gadget not registered, simple return */ @@ -2544,6 +2527,54 @@ void usb_eth_halt(struct eth_device *netdev) #endif } +static int usb_eth_init(struct eth_device *netdev, bd_t *bd) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + + return _usb_eth_init(priv); +} + +static int usb_eth_send(struct eth_device *netdev, void *packet, int length) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + + return _usb_eth_send(priv, packet, length); +} + +static int usb_eth_recv(struct eth_device *netdev) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + struct eth_dev *dev = &priv->ethdev; + int ret; + + ret = _usb_eth_recv(priv); + if (ret) { + error("error packet receive\n"); + return ret; + } + + if (!packet_received) + return 0; + + if (dev->rx_req) { + net_process_received_packet(net_rx_packets[0], + dev->rx_req->length); + } else { + error("dev->rx_req invalid"); + } + packet_received = 0; + rx_submit(dev, dev->rx_req, 0); + + return 0; +} + +void usb_eth_halt(struct eth_device *netdev) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + + _usb_eth_halt(priv); +} + int usb_eth_initialize(bd_t *bi) { struct eth_device *netdev = &l_priv->netdev; -- cgit v0.10.2 From f7f191ee41c0590917f4a969b569af0a01106380 Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Thu, 24 Nov 2016 15:02:18 +0100 Subject: cmd/fdt: fix uncallable systemsetup command The function that is processing the 'fdt' parameters is one big if-else if. In order to be able to type command faster only the first few letter are checked to know which block of code to execute. For systemsetup, the block of code that was executed was always the wrong one and ended up in a failure. } else if (argv[1][0] == 's') { process "fdt set" command } else if (strncmp(argv[1], "sys", 3) == 0) { process "fdt systemsetup" command. } When typing "fdt systemsetup", the code that was executed was the code for "fdt set". This commit fix this issue by moving the "else if" for systemsetup before the else if for "fdt set". This allow us to keep compatibility with any script that make use of "fdt s" to set node values. Signed-off-by: Fabien Parent Acked-by: Simon Glass diff --git a/cmd/fdt.c b/cmd/fdt.c index b503357..8bd345a 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -206,7 +206,17 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } working_fdt = newaddr; +#ifdef CONFIG_OF_SYSTEM_SETUP + /* Call the board-specific fixup routine */ + } else if (strncmp(argv[1], "sys", 3) == 0) { + int err = ft_system_setup(working_fdt, gd->bd); + if (err) { + printf("Failed to add system information to FDT: %s\n", + fdt_strerror(err)); + return CMD_RET_FAILURE; + } +#endif /* * Make a new node */ @@ -577,18 +587,6 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } } #endif -#ifdef CONFIG_OF_SYSTEM_SETUP - /* Call the board-specific fixup routine */ - else if (strncmp(argv[1], "sys", 3) == 0) { - int err = ft_system_setup(working_fdt, gd->bd); - - if (err) { - printf("Failed to add system information to FDT: %s\n", - fdt_strerror(err)); - return CMD_RET_FAILURE; - } - } -#endif /* Create a chosen node */ else if (strncmp(argv[1], "cho", 3) == 0) { unsigned long initrd_start = 0, initrd_end = 0; -- cgit v0.10.2 From 63c0941726e44f31c42de744a57f528fee2df88f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 26 Nov 2016 11:02:10 +0900 Subject: libfdt: replace ARCH_FIXUP_FDT with ARCH_FIXUP_FDT_MEMORY Commit e2f88dfd2d96 ("libfdt: Introduce new ARCH_FIXUP_FDT option") allows us to skip memory setup of DTB, but a problem for ARM is that spin_table_update_dt() and psci_update_dt() are skipped as well if CONFIG_ARCH_FIXUP_FDT is disabled. This commit allows us to skip only fdt_fixup_memory_banks() instead of the whole of arch_fixup_fdt(). It will be useful when we want to use a memory node from a kernel DTB as is, but need some fixups for Spin-Table/PSCI. Signed-off-by: Masahiro Yamada Acked-by: Alexey Brodkin Acked-by: Simon Glass Fixed build error for x86: Signed-off-by: Simon Glass diff --git a/Kconfig b/Kconfig index 529858a..58a9d9b 100644 --- a/Kconfig +++ b/Kconfig @@ -298,9 +298,8 @@ config SYS_CLK_FREQ help TODO: Move CONFIG_SYS_CLK_FREQ for all the architecture -config ARCH_FIXUP_FDT - bool "Enable arch_fixup_fdt() call" - depends on ARM || MIPS +config ARCH_FIXUP_FDT_MEMORY + bool "Enable arch_fixup_memory_banks() call" default y help Enable FDT memory map syncup before OS boot. This feature can be diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c index 04d9d9c..5798149 100644 --- a/arch/arc/lib/bootm.c +++ b/arch/arc/lib/bootm.c @@ -37,6 +37,11 @@ void arch_lmb_reserve(struct lmb *lmb) lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp)); } +int arch_fixup_fdt(void *blob) +{ + return 0; +} + static int cleanup_before_linux(void) { disable_interrupts(); diff --git a/arch/arm/lib/bootm-fdt.c b/arch/arm/lib/bootm-fdt.c index a517550..4481f9e 100644 --- a/arch/arm/lib/bootm-fdt.c +++ b/arch/arm/lib/bootm-fdt.c @@ -25,7 +25,6 @@ DECLARE_GLOBAL_DATA_PTR; -#ifdef CONFIG_ARCH_FIXUP_FDT int arch_fixup_fdt(void *blob) { bd_t *bd = gd->bd; @@ -61,4 +60,3 @@ int arch_fixup_fdt(void *blob) return 0; } -#endif diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 35e6b06..4eee13a 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -414,10 +414,8 @@ void boot_prep_vxworks(bootm_headers_t *images) if (images->ft_addr) { off = fdt_path_offset(images->ft_addr, "/memory"); if (off < 0) { -#ifdef CONFIG_ARCH_FIXUP_FDT if (arch_fixup_fdt(images->ft_addr)) puts("## WARNING: fixup memory failed!\n"); -#endif } } #endif diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index 3eb3440..2732203 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -17,6 +17,11 @@ DECLARE_GLOBAL_DATA_PTR; +int arch_fixup_fdt(void *blob) +{ + return 0; +} + int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 9fec4ad..be87762 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -253,7 +253,6 @@ static int boot_reloc_fdt(bootm_headers_t *images) #endif } -#ifdef CONFIG_ARCH_FIXUP_FDT int arch_fixup_fdt(void *blob) { #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT) @@ -265,7 +264,6 @@ int arch_fixup_fdt(void *blob) return 0; #endif } -#endif static int boot_setup_fdt(bootm_headers_t *images) { diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index ef15e7a..17c5ed1 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -38,6 +38,11 @@ static void set_clocks_in_mhz (bd_t *kbd); #define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE (768*1024*1024) #endif +int arch_fixup_fdt(void *blob) +{ + return 0; +} + static void boot_jump_linux(bootm_headers_t *images) { void (*kernel)(bd_t *, ulong r4, ulong r5, ulong r6, diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c index 0c9a797..4cdd18f 100644 --- a/arch/sandbox/lib/bootm.c +++ b/arch/sandbox/lib/bootm.c @@ -50,6 +50,11 @@ int bootz_setup(ulong image, ulong *start, ulong *end) return ret; } +int arch_fixup_fdt(void *blob) +{ + return 0; +} + int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) { diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 80fadef..e5e63f6 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -26,6 +26,11 @@ DECLARE_GLOBAL_DATA_PTR; #define COMMAND_LINE_OFFSET 0x9000 +int arch_fixup_fdt(void *blob) +{ + return 0; +} + __weak void board_quiesce_devices(void) { } diff --git a/common/fdt_support.c b/common/fdt_support.c index 0609470..c9f7019 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -381,6 +381,7 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat, do_fixup_by_compat(fdt, compat, prop, &tmp, 4, create); } +#ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY /* * fdt_pack_reg - pack address and size array into the "reg"-suitable stream */ @@ -459,6 +460,7 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks) } return 0; } +#endif int fdt_fixup_memory(void *blob, u64 start, u64 size) { diff --git a/common/image-fdt.c b/common/image-fdt.c index 5454227..e7540be 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -474,12 +474,10 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob, printf("ERROR: /chosen node create failed\n"); goto err; } -#ifdef CONFIG_ARCH_FIXUP_FDT if (arch_fixup_fdt(blob) < 0) { printf("ERROR: arch-specific fdt fixup failed\n"); goto err; } -#endif if (IMAGE_OF_BOARD_SETUP) { fdt_ret = ft_board_setup(blob, gd->bd); if (fdt_ret) { diff --git a/include/fdt_support.h b/include/fdt_support.h index 506bc5a..955c121 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -93,7 +93,15 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size); * property will be left untouched. * @return 0 if ok, or -1 or -FDT_ERR_... on error */ +#ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks); +#else +static inline int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], + int banks) +{ + return 0; +} +#endif void fdt_fixup_ethernet(void *fdt); int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, -- cgit v0.10.2 From 13f3fcac533ae7d86083ed9eefb36f78ee851f10 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 30 Nov 2016 07:24:47 +0100 Subject: dm: core: Add dev_get_addr_size_index() to retrieve addr and size The currently available functions accessing the 'reg' property of a device only retrieve the address. Sometimes its also necessary to retrieve the size described by the 'reg' property. This patch adds the new function dev_get_addr_size_index() which retrieves both, the address and the size described by the 'reg' property. Signed-off-by: Stefan Roese Cc: Simon Glass Acked-by: Simon Glass diff --git a/drivers/core/device.c b/drivers/core/device.c index dcf5d9d..ed553d7 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -693,6 +693,28 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) #endif } +fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index, + fdt_size_t *size) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) + /* + * Only get the size in this first call. We'll get the addr in the + * next call to the exisiting dev_get_xxx function which handles + * all config options. + */ + fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset, + "reg", index, size, false); + + /* + * Get the base address via the existing function which handles + * all Kconfig cases + */ + return dev_get_addr_index(dev, index); +#else + return FDT_ADDR_T_NONE; +#endif +} + fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name) { #if CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/include/dm/device.h b/include/dm/device.h index babf8ac..9948bd4 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -497,6 +497,22 @@ void *dev_map_physmem(struct udevice *dev, unsigned long size); fdt_addr_t dev_get_addr_index(struct udevice *dev, int index); /** + * dev_get_addr_size_index() - Get the indexed reg property of a device + * + * Returns the address and size specified in the 'reg' property of a device. + * + * @dev: Pointer to a device + * @index: the 'reg' property can hold a list of pairs + * and @index is used to select which one is required + * @size: Pointer to size varible - this function returns the size + * specified in the 'reg' property here + * + * @return addr + */ +fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index, + fdt_size_t *size); + +/** * dev_get_addr_name() - Get the reg property of a device, indexed by name * * @dev: Pointer to a device -- cgit v0.10.2 From 8f3a8428c96cb8424afea68f86df83a4e07d63ff Mon Sep 17 00:00:00 2001 From: Meng Yi Date: Wed, 30 Nov 2016 15:47:31 +0800 Subject: rtc: Add RTC chip pcf2127 support This driver compatible with pcf2127 and pcf2129 Signed-off-by: Meng Yi Reviewed-by: Simon Glass diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index b5d9048..57af1b5 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -13,4 +13,10 @@ config DM_RTC drivers to perform the actual functions. See rtc.h for a description of the API. +config RTC_PCF2127 + bool "Enable PCF2127 driver" + depends on DM_RTC + help + Enable pcf2127 driver which provides rtc get and set function + endmenu diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index fc38a3f..c919427 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_RTC_MV) += mvrtc.o obj-$(CONFIG_RTC_MX27) += mx27rtc.o obj-$(CONFIG_RTC_MXS) += mxsrtc.o obj-$(CONFIG_RTC_PCF8563) += pcf8563.o +obj-$(CONFIG_RTC_PCF2127) += pcf2127.o obj-$(CONFIG_RTC_PL031) += pl031.o obj-$(CONFIG_RTC_PT7C4338) += pt7c4338.o obj-$(CONFIG_RTC_RS5C372A) += rs5c372.o diff --git a/drivers/rtc/pcf2127.c b/drivers/rtc/pcf2127.c new file mode 100644 index 0000000..bc59c6c --- /dev/null +++ b/drivers/rtc/pcf2127.c @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2016 by NXP Semiconductors Inc. + * Date & Time support for PCF2127 RTC + */ + +/* #define DEBUG */ + +#include +#include +#include +#include +#include + +#define PCF2127_REG_CTRL1 (0x00) +#define PCF2127_REG_CTRL2 (0x01) +#define PCF2127_REG_CTRL3 (0x02) +#define PCF2127_REG_SC (0x03) /* datetime */ +#define PCF2127_REG_MN (0x04) +#define PCF2127_REG_HR (0x05) +#define PCF2127_REG_DM (0x06) +#define PCF2127_REG_DW (0x07) +#define PCF2127_REG_MO (0x08) +#define PCF2127_REG_YR (0x09) + +static int pcf2127_rtc_set(struct udevice *dev, const struct rtc_time *tm) +{ + uchar buf[8]; + int i = 0; + + /* start register address */ + buf[i++] = PCF2127_REG_SC; + + /* hours, minutes and seconds */ + buf[i++] = bin2bcd(tm->tm_sec); + buf[i++] = bin2bcd(tm->tm_min); + buf[i++] = bin2bcd(tm->tm_hour); + buf[i++] = bin2bcd(tm->tm_mday); + buf[i++] = tm->tm_wday & 0x07; + + /* month, 1 - 12 */ + buf[i++] = bin2bcd(tm->tm_mon + 1); + + /* year */ + buf[i++] = bin2bcd(tm->tm_year % 100); + + /* write register's data */ + if (dm_i2c_write(dev, PCF2127_REG_CTRL1, buf, sizeof(buf)) < 0) + return -1; + + return 0; +} + +static int pcf2127_rtc_get(struct udevice *dev, struct rtc_time *tm) +{ + int rel = 0; + uchar buf[10] = { PCF2127_REG_CTRL1 }; + + if (dm_i2c_write(dev, PCF2127_REG_CTRL1, buf, 1) < 0) + return -1; + if (dm_i2c_read(dev, PCF2127_REG_CTRL1, buf, sizeof(buf)) < 0) + return -1; + + if (buf[PCF2127_REG_CTRL3] & 0x04) + puts("### Warning: RTC Low Voltage - date/time not reliable\n"); + + tm->tm_sec = bcd2bin(buf[PCF2127_REG_SC] & 0x7F); + tm->tm_min = bcd2bin(buf[PCF2127_REG_MN] & 0x7F); + tm->tm_hour = bcd2bin(buf[PCF2127_REG_HR] & 0x3F); + tm->tm_mday = bcd2bin(buf[PCF2127_REG_DM] & 0x3F); + tm->tm_mon = bcd2bin(buf[PCF2127_REG_MO] & 0x1F) - 1; + tm->tm_year = bcd2bin(buf[PCF2127_REG_YR]) + 1900; + if (tm->tm_year < 1970) + tm->tm_year += 100; /* assume we are in 1970...2069 */ + tm->tm_wday = buf[PCF2127_REG_DW] & 0x07; + tm->tm_yday = 0; + tm->tm_isdst = 0; + + debug("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + + return rel; +} + +static int pcf2127_rtc_reset(struct udevice *dev) +{ + /*Doing nothing here*/ + return 0; +} + +static const struct rtc_ops pcf2127_rtc_ops = { + .get = pcf2127_rtc_get, + .set = pcf2127_rtc_set, + .reset = pcf2127_rtc_reset, +}; + +static const struct udevice_id pcf2127_rtc_ids[] = { + { .compatible = "pcf2127-rtc" }, + { } +}; + +U_BOOT_DRIVER(rtc_pcf2127) = { + .name = "rtc-pcf2127", + .id = UCLASS_RTC, + .of_match = pcf2127_rtc_ids, + .ops = &pcf2127_rtc_ops, +}; -- cgit v0.10.2 From 4623f974a585b59bd07fb60a326a096290aa4c53 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 17 Nov 2016 14:38:06 +0530 Subject: configs: am335x: usb: do not define CONFIG_DM_USB for spl Since OMAP's spl doesn't support DM currently, do not define CONFIG_DM_USB for spl build. Signed-off-by: Mugunthan V N Reviewed-by: Tom Rini diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 8fa8e39..7d9dfde 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -316,6 +316,7 @@ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC #undef CONFIG_TIMER +#undef CONFIG_DM_USB #endif #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT) -- cgit v0.10.2 From 195702217d713a0731c9a79f5b3196b08ac400cb Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 17 Nov 2016 14:38:07 +0530 Subject: am33xx: board: do not register usb devices when CONFIG_DM_USB is defined Do not register usb devices when CONFIG_DM_USB is define. Signed-off-by: Mugunthan V N Reviewed-by: Tom Rini diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index 5ebeac0..80b729a 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -120,7 +120,8 @@ int cpu_mmc_init(bd_t *bis) /* AM33XX has two MUSB controllers which can be host or gadget */ #if (defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)) && \ - (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) + (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) && \ + (!defined(CONFIG_DM_USB)) static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; /* USB 2.0 PHY Control */ @@ -187,6 +188,7 @@ static struct musb_hdrc_platform_data otg1_plat = { int arch_misc_init(void) { +#ifndef CONFIG_DM_USB #ifdef CONFIG_AM335X_USB0 musb_register(&otg0_plat, &otg0_board_data, (void *)USB0_OTG_BASE); @@ -195,6 +197,7 @@ int arch_misc_init(void) musb_register(&otg1_plat, &otg1_board_data, (void *)USB1_OTG_BASE); #endif +#endif return 0; } -- cgit v0.10.2 From 28b8d5fd2b73b83ff1f759eadfed64740fd89494 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 17 Nov 2016 14:38:08 +0530 Subject: drivers: usb: musb: add ti musb misc driver for wrapper Add a misc driver for MUSB wrapper, so that based on dr_mode the USB devices can bind to USB host or USB device drivers. Signed-off-by: Mugunthan V N Reviewed-by: Tom Rini diff --git a/drivers/usb/musb-new/Kconfig b/drivers/usb/musb-new/Kconfig index c264859..caba42c 100644 --- a/drivers/usb/musb-new/Kconfig +++ b/drivers/usb/musb-new/Kconfig @@ -14,6 +14,15 @@ config USB_MUSB_GADGET help Enables the MUSB USB dual-role controller in gadget mode. +config USB_MUSB_TI + bool "Enable TI OTG USB controller" + depends on DM_USB + default n + help + Say y here to enable support for the dual role high + speed USB controller based on the Mentor Graphics + silicon IP. + if USB_MUSB_HOST || USB_MUSB_GADGET config USB_MUSB_PIC32 diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index df1c3c8..296f230 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o obj-$(CONFIG_USB_MUSB_PIC32) += pic32.o obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o +obj-$(CONFIG_USB_MUSB_TI) += ti-musb.o ccflags-y := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c new file mode 100644 index 0000000..cf0e296 --- /dev/null +++ b/drivers/usb/musb-new/ti-musb.c @@ -0,0 +1,64 @@ +/* + * MISC driver for TI MUSB Glue. + * + * (C) Copyright 2016 + * Texas Instruments Incorporated, + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#ifdef CONFIG_DM_USB + +static int ti_musb_wrapper_bind(struct udevice *parent) +{ + const void *fdt = gd->fdt_blob; + int node; + int ret; + + for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0; + node = fdt_next_subnode(fdt, node)) { + struct udevice *dev; + const char *name = fdt_get_name(fdt, node, NULL); + enum usb_dr_mode dr_mode; + struct driver *drv; + + if (strncmp(name, "usb@", 4)) + continue; + + dr_mode = usb_get_dr_mode(node); + switch (dr_mode) { + case USB_DR_MODE_PERIPHERAL: + /* Bind MUSB device */ + break; + case USB_DR_MODE_HOST: + /* Bind MUSB host */ + break; + default: + break; + }; + } + return 0; +} + +static const struct udevice_id ti_musb_ids[] = { + { .compatible = "ti,am33xx-usb" }, + { } +}; + +U_BOOT_DRIVER(ti_musb_wrapper) = { + .name = "ti-musb-wrapper", + .id = UCLASS_MISC, + .of_match = ti_musb_ids, + .bind = ti_musb_wrapper_bind, +}; + +#endif /* CONFIG_DM_USB */ -- cgit v0.10.2 From 3aec2648698d9be14ab8b3eeb7d4d7d3783379ac Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 17 Nov 2016 14:38:09 +0530 Subject: am33xx: board: probe misc drivers to register musb devices MUSB wrapper driver is bound as MISC device and underlying usb devices are bind to usb drivers based on dr_mode, so probing the MISC wrapper driver to register musb devices. Signed-off-by: Mugunthan V N Reviewed-by: Tom Rini diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index 80b729a..2ce7790 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -197,6 +197,13 @@ int arch_misc_init(void) musb_register(&otg1_plat, &otg1_board_data, (void *)USB1_OTG_BASE); #endif +#else + struct udevice *dev; + int ret; + + ret = uclass_first_device(UCLASS_MISC, &dev); + if (ret || !dev) + return ret; #endif return 0; } -- cgit v0.10.2 From 1cac34ce161ae010d3f9ffd3f664e70206638ebc Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 17 Nov 2016 14:38:10 +0530 Subject: drivers: usb: musb: adopt musb backend driver to driver model Currently all backend driver ops uses hard coded physical address, so to adopt the driver to DM, add device pointer to ops call backs so that drivers can get physical addresses from the usb driver priv/plat data. Signed-off-by: Mugunthan V N Reviewed-by: Tom Rini diff --git a/arch/arm/include/asm/arch-omap3/musb.h b/arch/arm/include/asm/arch-omap3/musb.h index cee4ed3..d06a758 100644 --- a/arch/arm/include/asm/arch-omap3/musb.h +++ b/arch/arm/include/asm/arch-omap3/musb.h @@ -7,7 +7,7 @@ #ifndef __ASM_ARCH_OMAP3_MUSB_H #define __ASM_ARCH_OMAP3_MUSB_H -extern void am35x_musb_reset(void); -extern void am35x_musb_phy_power(u8 on); -extern void am35x_musb_clear_irq(void); +void am35x_musb_reset(struct udevice *dev); +void am35x_musb_phy_power(struct udevice *dev, u8 on); +void am35x_musb_clear_irq(struct udevice *dev); #endif diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 8b9cb0e..7c5fb40 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -15,9 +15,10 @@ extern const struct musb_platform_ops omap2430_ops; struct omap_musb_board_data { u8 interface_type; - void (*set_phy_power)(u8 on); - void (*clear_irq)(void); - void (*reset)(void); + struct udevice *dev; + void (*set_phy_power)(struct udevice *dev, u8 on); + void (*clear_irq)(struct udevice *dev); + void (*reset)(struct udevice *dev); }; enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index 2ce7790..581c0ab 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -148,7 +148,7 @@ static struct musb_hdrc_config musb_config = { }; #ifdef CONFIG_AM335X_USB0 -static void am33xx_otg0_set_phy_power(u8 on) +static void am33xx_otg0_set_phy_power(struct udevice *dev, u8 on) { am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0); } @@ -167,7 +167,7 @@ static struct musb_hdrc_platform_data otg0_plat = { #endif #ifdef CONFIG_AM335X_USB1 -static void am33xx_otg1_set_phy_power(u8 on) +static void am33xx_otg1_set_phy_power(struct udevice *dev, u8 on) { am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1); } diff --git a/arch/arm/mach-omap2/omap3/am35x_musb.c b/arch/arm/mach-omap2/omap3/am35x_musb.c index 74dd105..d542699 100644 --- a/arch/arm/mach-omap2/omap3/am35x_musb.c +++ b/arch/arm/mach-omap2/omap3/am35x_musb.c @@ -13,7 +13,7 @@ #include #include -void am35x_musb_reset(void) +void am35x_musb_reset(struct udevice *dev) { /* Reset the musb interface */ clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset, @@ -22,7 +22,7 @@ void am35x_musb_reset(void) USBOTGSS_SW_RST, 0); } -void am35x_musb_phy_power(u8 on) +void am35x_musb_phy_power(struct udevice *dev, u8 on) { unsigned long start = get_timer(0); @@ -53,7 +53,7 @@ void am35x_musb_phy_power(u8 on) } } -void am35x_musb_clear_irq(void) +void am35x_musb_clear_irq(struct udevice *dev) { clrsetbits_le32(&am35x_scm_general_regs->lvl_intr_clr, 0, USBOTGSS_INT_CLR); diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c index b8791dd..0167ea7 100644 --- a/drivers/usb/musb-new/am35x.c +++ b/drivers/usb/musb-new/am35x.c @@ -336,7 +336,7 @@ eoi: if (ret == IRQ_HANDLED || epintr || usbintr) { /* clear level interrupt */ if (data->clear_irq) - data->clear_irq(); + data->clear_irq(data->dev); /* write EOI */ musb_writel(reg_base, USB_END_OF_INTR_REG, 0); } @@ -401,14 +401,14 @@ static int am35x_musb_init(struct musb *musb) /* Reset the musb */ if (data->reset) - data->reset(); + data->reset(data->dev); /* Reset the controller */ musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK); /* Start the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(1); + data->set_phy_power(data->dev, 1); msleep(5); @@ -416,7 +416,7 @@ static int am35x_musb_init(struct musb *musb) /* clear level interrupt */ if (data->clear_irq) - data->clear_irq(); + data->clear_irq(data->dev); return 0; } @@ -439,7 +439,7 @@ static int am35x_musb_exit(struct musb *musb) /* Shutdown the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(0); + data->set_phy_power(data->dev, 0); #ifndef __UBOOT__ usb_put_phy(musb->xceiv); @@ -630,7 +630,7 @@ static int am35x_suspend(struct device *dev) /* Shutdown the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(0); + data->set_phy_power(data->dev, 0); clk_disable(glue->phy_clk); clk_disable(glue->clk); @@ -647,7 +647,7 @@ static int am35x_resume(struct device *dev) /* Start the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(1); + data->set_phy_power(data->dev, 1); ret = clk_enable(glue->phy_clk); if (ret) { diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c index a71db76..399b85b 100644 --- a/drivers/usb/musb-new/musb_dsps.c +++ b/drivers/usb/musb-new/musb_dsps.c @@ -452,7 +452,7 @@ static int dsps_musb_init(struct musb *musb) /* Start the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(1); + data->set_phy_power(data->dev, 1); musb->isr = dsps_interrupt; @@ -493,7 +493,7 @@ static int dsps_musb_exit(struct musb *musb) /* Shutdown the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(0); + data->set_phy_power(data->dev, 0); #ifndef __UBOOT__ /* NOP driver needs change if supporting dual instance */ @@ -693,7 +693,7 @@ static int dsps_suspend(struct device *dev) /* Shutdown the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(0); + data->set_phy_power(data->dev, 0); return 0; } @@ -705,7 +705,7 @@ static int dsps_resume(struct device *dev) /* Start the on-chip PHY and its PLL. */ if (data->set_phy_power) - data->set_phy_power(1); + data->set_phy_power(data->dev, 1); return 0; } -- cgit v0.10.2 From ae6acf9fe2c83370159724855b7fdbb350ae99b9 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 17 Nov 2016 14:38:11 +0530 Subject: drivers: usb: musb: add ti musb host driver with driver model support Add a TI MUSB host driver with driver model support and the driver will be bound by the MUSB wrapper driver based on the dr_mode device tree entry. Signed-off-by: Mugunthan V N Reviewed-by: Tom Rini diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index cf0e296..1c15aa2 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -14,10 +14,195 @@ #include #include +#include +#include +#include "musb_uboot.h" + DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_DM_USB +/* USB 2.0 PHY Control */ +#define CM_PHY_PWRDN (1 << 0) +#define CM_PHY_OTG_PWRDN (1 << 1) +#define OTGVDET_EN (1 << 19) +#define OTGSESSENDEN (1 << 20) + +#define AM335X_USB1_CTRL 0x8 + +struct ti_musb_platdata { + void *base; + void *ctrl_mod_base; + struct musb_hdrc_platform_data plat; + struct musb_hdrc_config musb_config; + struct omap_musb_board_data otg_board_data; +}; + +static int ti_musb_get_usb_index(int node) +{ + const void *fdt = gd->fdt_blob; + int i = 0; + char path[64]; + const char *alias_path; + char alias[16]; + + fdt_get_path(fdt, node, path, sizeof(path)); + + do { + snprintf(alias, sizeof(alias), "usb%d", i); + alias_path = fdt_get_alias(fdt, alias); + if (alias_path == NULL) { + debug("USB index not found\n"); + return -ENOENT; + } + + if (!strcmp(path, alias_path)) + return i; + + i++; + } while (alias_path); + + return -ENOENT; +} + +static void ti_musb_set_phy_power(struct udevice *dev, u8 on) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + + if (on) { + clrsetbits_le32(platdata->ctrl_mod_base, + CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, + OTGVDET_EN | OTGSESSENDEN); + } else { + clrsetbits_le32(platdata->ctrl_mod_base, 0, + CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } +} + +static int ti_musb_ofdata_to_platdata(struct udevice *dev) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + const void *fdt = gd->fdt_blob; + int node = dev->of_offset; + int phys; + int ctrl_mod; + int usb_index; + + platdata->base = (void *)dev_get_addr_index(dev, 1); + + phys = fdtdec_lookup_phandle(fdt, node, "phys"); + ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod"); + platdata->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg"); + usb_index = ti_musb_get_usb_index(node); + switch (usb_index) { + case 1: + platdata->ctrl_mod_base += AM335X_USB1_CTRL; + case 0: + default: + break; + } + + platdata->musb_config.multipoint = fdtdec_get_int(fdt, node, + "mentor,multipoint", + -1); + if (platdata->musb_config.multipoint < 0) { + error("MUSB multipoint DT entry missing\n"); + return -ENOENT; + } + + platdata->musb_config.dyn_fifo = 1; + + platdata->musb_config.num_eps = fdtdec_get_int(fdt, node, + "mentor,num-eps", -1); + if (platdata->musb_config.num_eps < 0) { + error("MUSB num-eps DT entry missing\n"); + return -ENOENT; + } + + platdata->musb_config.ram_bits = fdtdec_get_int(fdt, node, + "mentor,ram-bits", -1); + if (platdata->musb_config.ram_bits < 0) { + error("MUSB ram-bits DT entry missing\n"); + return -ENOENT; + } + + platdata->otg_board_data.set_phy_power = ti_musb_set_phy_power; + platdata->otg_board_data.dev = dev; + platdata->plat.config = &platdata->musb_config; + + platdata->plat.power = fdtdec_get_int(fdt, node, "mentor,power", -1); + if (platdata->plat.power < 0) { + error("MUSB mentor,power DT entry missing\n"); + return -ENOENT; + } + + platdata->plat.platform_ops = &musb_dsps_ops; + platdata->plat.board_data = &platdata->otg_board_data; + + return 0; +} + +static int ti_musb_host_probe(struct udevice *dev) +{ + struct musb_host_data *host = dev_get_priv(dev); + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct usb_bus_priv *priv = dev_get_uclass_priv(dev); + struct omap_musb_board_data *otg_board_data; + int ret; + + priv->desc_before_addr = true; + + otg_board_data = &platdata->otg_board_data; + + host->host = musb_init_controller(&platdata->plat, + (struct device *)otg_board_data, + platdata->base); + if (!host->host) + return -EIO; + + ret = musb_lowlevel_init(host); + + return ret; +} + +static int ti_musb_host_remove(struct udevice *dev) +{ + struct musb_host_data *host = dev_get_priv(dev); + + musb_stop(host->host); + + return 0; +} + +static int ti_musb_host_ofdata_to_platdata(struct udevice *dev) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + const void *fdt = gd->fdt_blob; + int node = dev->of_offset; + int ret; + + ret = ti_musb_ofdata_to_platdata(dev); + if (ret) { + error("platdata dt parse error\n"); + return ret; + } + + platdata->plat.mode = MUSB_HOST; + + return 0; +} + +U_BOOT_DRIVER(ti_musb_host) = { + .name = "ti-musb-host", + .id = UCLASS_USB, + .ofdata_to_platdata = ti_musb_host_ofdata_to_platdata, + .probe = ti_musb_host_probe, + .remove = ti_musb_host_remove, + .ops = &musb_usb_ops, + .platdata_auto_alloc_size = sizeof(struct ti_musb_platdata), + .priv_auto_alloc_size = sizeof(struct musb_host_data), +}; + static int ti_musb_wrapper_bind(struct udevice *parent) { const void *fdt = gd->fdt_blob; @@ -41,6 +226,12 @@ static int ti_musb_wrapper_bind(struct udevice *parent) break; case USB_DR_MODE_HOST: /* Bind MUSB host */ + ret = device_bind_driver_to_node(parent, "ti-musb-host", + name, node, &dev); + if (ret) { + error("musb - not able to bind usb host node\n"); + return ret; + } break; default: break; -- cgit v0.10.2 From a2558e8729831e0bcef634ea2440e60425ef0ff6 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Thu, 3 Nov 2016 08:53:52 -0600 Subject: cmd: crosec: Move cros_ec_decode_region helper to cmd/cros_ec.c The cros_ec_decode_region() function is only used in combination with the crosec cmds. Move the function to the correct place. Signed-off-by: Moritz Fischer Cc: Simon Glass Cc: Masahiro Yamada Cc: u-boot@lists.denx.de Acked-by: Simon Glass diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c index abf11f0..9d42f87 100644 --- a/cmd/cros_ec.c +++ b/cmd/cros_ec.c @@ -20,6 +20,29 @@ static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"}; DECLARE_GLOBAL_DATA_PTR; /** + * Decode a flash region parameter + * + * @param argc Number of params remaining + * @param argv List of remaining parameters + * @return flash region (EC_FLASH_REGION_...) or -1 on error + */ +static int cros_ec_decode_region(int argc, char * const argv[]) +{ + if (argc > 0) { + if (0 == strcmp(*argv, "rw")) + return EC_FLASH_REGION_RW; + else if (0 == strcmp(*argv, "ro")) + return EC_FLASH_REGION_RO; + + debug("%s: Invalid region '%s'\n", __func__, *argv); + } else { + debug("%s: Missing region parameter\n", __func__); + } + + return -1; +} + +/** * Perform a flash read or write command * * @param dev CROS-EC device to read/write diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 8073730..759bb46 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1024,22 +1024,6 @@ int cros_ec_register(struct udevice *dev) return 0; } -int cros_ec_decode_region(int argc, char * const argv[]) -{ - if (argc > 0) { - if (0 == strcmp(*argv, "rw")) - return EC_FLASH_REGION_RW; - else if (0 == strcmp(*argv, "ro")) - return EC_FLASH_REGION_RO; - - debug("%s: Invalid region '%s'\n", __func__, *argv); - } else { - debug("%s: Missing region parameter\n", __func__); - } - - return -1; -} - int cros_ec_decode_ec_flash(const void *blob, int node, struct fdt_cros_ec *config) { diff --git a/include/cros_ec.h b/include/cros_ec.h index ec7517c..0271f2b 100644 --- a/include/cros_ec.h +++ b/include/cros_ec.h @@ -250,15 +250,6 @@ void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len); */ int cros_ec_calc_checksum(const uint8_t *data, int size); -/** - * Decode a flash region parameter - * - * @param argc Number of params remaining - * @param argv List of remaining parameters - * @return flash region (EC_FLASH_REGION_...) or -1 on error - */ -int cros_ec_decode_region(int argc, char * const argv[]); - int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size); -- cgit v0.10.2