From 8b4919ed29f51075e85a7358db75b66a226d5b1e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:30 -0600 Subject: patman: Flush output when there is no newline Output which does not include a newline will not be displayed unless flushed. Add a flush to ensure that it becomes visible. Signed-off-by: Simon Glass diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py index e78a7c1..af3593e 100644 --- a/tools/patman/terminal.py +++ b/tools/patman/terminal.py @@ -55,6 +55,8 @@ def Print(text='', newline=True, colour=None): print text, if newline: print + else: + sys.stdout.flush() def SetPrintTestMode(): """Go into test mode, where all printing is recorded""" -- cgit v0.10.2 From 21f0eb332faddeb88a0f3e9788f83b6f9c22071c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:31 -0600 Subject: buildman: Tidy up the 'cloning' message On a machine with a lot of CPUs this prints a lot of useless lines of the form: Cloning repo for thread Adjust the output so that these all appear on one line, and disappear when the cloning is complete. Note: This cloning is actually unnecessary and very wasteful on disk space (about 3.5GB each time). It would be better to create symlinks. Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 8ec3551..4a24f74 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1366,8 +1366,10 @@ class Builder: if os.path.exists(git_dir): gitutil.Fetch(git_dir, thread_dir) else: - Print('Cloning repo for thread %d' % thread_num) + Print('\rCloning repo for thread %d' % thread_num, + newline=False) gitutil.Clone(src_dir, thread_dir) + Print('\r%s\r' % (' ' * 30), newline=False) def _PrepareWorkingSpace(self, max_threads, setup_git): """Prepare the working directory for use. -- cgit v0.10.2 From b222abe736e4ea61e7c61dee412fb80d840b5111 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:32 -0600 Subject: buildman: Print a message when removing old directories When buildman starts, it prepares its output directory by removing any old build directories which will not be used this time. This can happen if a previous build left directories around for commit hashes which are no-longer part of the branch. This can take quite a while, so print a message to indicate what is going on. Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 4a24f74..da2a0a1 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1397,8 +1397,14 @@ class Builder: for commit_upto in range(self.commit_count): dir_list.append(self._GetOutputDir(commit_upto)) + to_remove = [] for dirname in glob.glob(os.path.join(self.base_dir, '*')): if dirname not in dir_list: + to_remove.append(dirname) + if to_remove: + Print('Removing %d old build directories' % len(to_remove), + newline=False) + for dirname in to_remove: shutil.rmtree(dirname) def BuildBoards(self, commits, board_selected, keep_outputs, verbose): -- cgit v0.10.2 From 745b395aefcd7e4718f6f51167c0e462931842b6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:33 -0600 Subject: buildman: Print a message indicating the build is starting Make it clear when buildman actually starts building. This happens when it has prepared the threads, working directory and output directories. Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index da2a0a1..384f053 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1430,6 +1430,7 @@ class Builder: self._PrepareWorkingSpace(min(self.num_threads, len(board_selected)), commits is not None) self._PrepareOutputSpace() + Print('\rStarting build...', newline=False) self.SetupBuild(board_selected, commits) self.ProcessResult(None) diff --git a/tools/buildman/test.py b/tools/buildman/test.py index d8f3c81..ed2a3a8 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -198,9 +198,9 @@ class TestBuild(unittest.TestCase): if line.text.strip(): count += 1 - # We should get one starting message, then an update for every commit + # We should get two starting messages, then an update for every commit # built. - self.assertEqual(count, len(commits) * len(boards) + 1) + self.assertEqual(count, len(commits) * len(boards) + 2) build.SetDisplayOptions(show_errors=True); build.ShowSummary(self.commits, board_selected) #terminal.EchoPrintTestLines() -- cgit v0.10.2 From a556eeebaada39d0d53941b4d18e5b6ea338c2cf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:34 -0600 Subject: buildman: Put our local libraries first in the path If patman is installed on the machine (e.g. in the standard dist-packages directory), it will find libraries from there in preference to our local libraries. Adjust the order of the path to ensure that local libraries are found first. Signed-off-by: Simon Glass diff --git a/tools/buildman/buildman.py b/tools/buildman/buildman.py index d0afeda..607429d 100755 --- a/tools/buildman/buildman.py +++ b/tools/buildman/buildman.py @@ -15,7 +15,7 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(our_path, '../patman')) +sys.path.insert(1, os.path.join(our_path, '../patman')) # Our modules import board -- cgit v0.10.2 From d436e38189a26227274a3014d3d838eb3f183488 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:35 -0600 Subject: buildman: Allow builds to terminate cleanly It is annoying that buildman does not respond cleanly to Ctrl-C or SIGINT, particularly on machines with lots of CPUS. Unfortunately queue.join() blocks the main thread and does not allow it to see the signal. Use a separate thread instead, Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 384f053..44d1cfa 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -14,6 +14,7 @@ import Queue import shutil import string import sys +import threading import time import builderthread @@ -1443,8 +1444,11 @@ class Builder: job.step = self._step self.queue.put(job) - # Wait until all jobs are started - self.queue.join() + term = threading.Thread(target=self.queue.join) + term.setDaemon(True) + term.start() + while term.isAlive(): + term.join(100) # Wait until we have processed all output self.out_queue.join() -- cgit v0.10.2 From 63781bd65e70719dbab9f2f5bbe8aac7b8e0f13e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:36 -0600 Subject: buildman: Drop the 'active' flag in the builder This serves no real purpose, since when we are not active, we exit. Drop it. Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 44d1cfa..5addbca 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -127,7 +127,6 @@ class Builder: """Class for building U-Boot for a particular commit. Public members: (many should ->private) - active: True if the builder is active and has not been stopped already_done: Number of builds already completed base_dir: Base directory to use for builder checkout: True to check out source, False to skip that step. @@ -235,7 +234,6 @@ class Builder: self.base_dir = base_dir self._working_dir = os.path.join(base_dir, '.bm-work') self.threads = [] - self.active = True self.do_make = self.Make self.gnu_make = gnu_make self.checkout = checkout @@ -390,11 +388,6 @@ class Builder: if result: target = result.brd.target - if result.return_code < 0: - self.active = False - command.StopAll() - return - self.upto += 1 if result.return_code != 0: self.fail += 1 diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index c512d3b..af4d15a 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -473,14 +473,6 @@ class BuilderThread(threading.Thread): alive = True while True: job = self.builder.queue.get() - if self.builder.active and alive: + if alive: self.RunJob(job) - ''' - try: - if self.builder.active and alive: - self.RunJob(job) - except Exception as err: - alive = False - print err - ''' self.builder.queue.task_done() -- cgit v0.10.2 From 2f2566482fc5c24557126043394ce82088f60262 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:37 -0600 Subject: buildman: Don't show a stacktrace on Ctrl-C When Ctrl-C is pressed, just exited quietly. There is no sense in displaying a stack trace since buildman will always be in the same place: waiting for threads to complete building all the jobs on the queue. Signed-off-by: Simon Glass diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 5addbca..e27a285 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -12,6 +12,7 @@ import os import re import Queue import shutil +import signal import string import sys import threading @@ -282,11 +283,17 @@ class Builder: ignore_lines = ['(make.*Waiting for unfinished)', '(Segmentation fault)'] self.re_make_err = re.compile('|'.join(ignore_lines)) + # Handle existing graceful with SIGINT / Ctrl-C + signal.signal(signal.SIGINT, self.signal_handler) + def __del__(self): """Get rid of all threads created by the builder""" for t in self.threads: del t + def signal_handler(self, signal, frame): + sys.exit(1) + def SetDisplayOptions(self, show_errors=False, show_sizes=False, show_detail=False, show_bloat=False, list_error_boards=False, show_config=False): -- cgit v0.10.2 From 2880e6b5e231690bbc64816d696322b06d41b2ee Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:38 -0600 Subject: buildman: Drop the 'alive' flag in BuilderThread This is not used, so drop it. Signed-off-by: Simon Glass diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index af4d15a..c4fe219 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -470,9 +470,7 @@ class BuilderThread(threading.Thread): This thread picks a job from the queue, runs it, and then goes to the next job. """ - alive = True while True: job = self.builder.queue.get() - if alive: - self.RunJob(job) + self.RunJob(job) self.builder.queue.task_done() -- cgit v0.10.2 From 281ca88fab7f6b66a18d494c05a1f1fa39f11075 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 13 Sep 2016 14:44:48 -0700 Subject: cros_ec: Add function to read back flash parameters Add support for reading back flash parameters as reported by the ec. Signed-off-by: Moritz Fischer Cc: Simon Glass Cc: u-boot@lists.denx.de Acked-by: Simon Glass diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 5225cdb..bb6e8fe 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -790,6 +790,27 @@ static int cros_ec_data_is_erased(const uint32_t *data, int size) return 1; } +/** + * Read back flash parameters + * + * This function reads back parameters of the flash as reported by the EC + * + * @param dev Pointer to device + * @param info Pointer to output flash info struct + */ +int cros_ec_read_flashinfo(struct cros_ec_dev *dev, + struct ec_response_flash_info *info) +{ + int ret; + + ret = ec_command(dev, EC_CMD_FLASH_INFO, 0, + NULL, 0, info, sizeof(*info)); + if (ret < 0) + return ret; + + return ret < sizeof(*info) ? -1 : 0; +} + int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data, uint32_t offset, uint32_t size) { -- cgit v0.10.2 From 7a71e4891d6fab9f9d54cee72e6012727ef45d82 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 13 Sep 2016 14:44:49 -0700 Subject: cros_ec: Add crosec flashinfo command Add command to print out the flash info as reported by the ec. The data read back includes size, write block size, erase block size. Signed-off-by: Moritz Fischer Cc: Simon Glass Cc: u-boot@lists.denx.de Acked-by: Simon Glass diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index bb6e8fe..05f1f60 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1364,6 +1364,15 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("Offset: %x\n", offset); printf("Size: %x\n", size); } + } else if (0 == strcmp("flashinfo", cmd)) { + struct ec_response_flash_info p; + + ret = cros_ec_read_flashinfo(dev, &p); + if (!ret) { + printf("Flash size: %u\n", p.flash_size); + printf("Write block size: %u\n", p.write_block_size); + printf("Erase block size: %u\n", p.erase_block_size); + } } else if (0 == strcmp("vbnvcontext", cmd)) { uint8_t block[EC_VBNV_BLOCK_SIZE]; char buf[3]; @@ -1483,6 +1492,7 @@ U_BOOT_CMD( "crosec events Read CROS-EC host events\n" "crosec clrevents [mask] Clear CROS-EC host events\n" "crosec regioninfo Read image info\n" + "crosec flashinfo Read flash info\n" "crosec erase Erase EC image\n" "crosec read [] Read EC image\n" "crosec write [] Write EC image\n" -- cgit v0.10.2 From bae5b97e8ec0fedb50350a14e76648714bc51c99 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Mon, 12 Sep 2016 12:57:52 -0700 Subject: cros_ec: Fix issue with cros_ec_flash_write command This commit fixes an issue where data is written to an invalid memory location. The issue has been introduced in commit (88364387 cros: add cros_ec_driver) Cc: Simon Glass Cc: u-boot@lists.denx.de Signed-off-by: Moritz Fischer Reviewed-by: Simon Glass diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 05f1f60..1e5bcb0 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -750,15 +750,24 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size) static int cros_ec_flash_write_block(struct cros_ec_dev *dev, const uint8_t *data, uint32_t offset, uint32_t size) { - struct ec_params_flash_write p; + struct ec_params_flash_write *p; + int ret; - p.offset = offset; - p.size = size; - assert(data && p.size <= EC_FLASH_WRITE_VER0_SIZE); - memcpy(&p + 1, data, p.size); + p = malloc(sizeof(*p) + size); + if (!p) + return -ENOMEM; + + p->offset = offset; + p->size = size; + assert(data && p->size <= EC_FLASH_WRITE_VER0_SIZE); + memcpy(p + 1, data, p->size); - return ec_command_inptr(dev, EC_CMD_FLASH_WRITE, 0, - &p, sizeof(p), NULL, 0) >= 0 ? 0 : -1; + ret = ec_command_inptr(dev, EC_CMD_FLASH_WRITE, 0, + p, sizeof(*p) + size, NULL, 0) >= 0 ? 0 : -1; + + free(p); + + return ret; } /** -- cgit v0.10.2 From 0734b70c9cb59f030a8293b08b947aa793baaa74 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 25 Sep 2016 15:52:17 -0600 Subject: dtoc: Fix bug in GetProp() This does not actually call fdtget correctly when requesting a particular type. Fix it. Signed-off-by: Simon Glass diff --git a/tools/dtoc/fdt_fallback.py b/tools/dtoc/fdt_fallback.py index 0c0ebbc..7d52da7 100644 --- a/tools/dtoc/fdt_fallback.py +++ b/tools/dtoc/fdt_fallback.py @@ -160,7 +160,7 @@ class FdtFallback(Fdt): if default is not None: args += ['-d', str(default)] if typespec is not None: - args += ['-t%s' % typespec] + args += ['-t', typespec] out = command.Output('fdtget', *args) return out.strip() -- cgit v0.10.2 From 8828254cae24abfc5de9f84d79c570fb8edde354 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 25 Sep 2016 15:52:18 -0600 Subject: dtoc: Adjust GetProps() in fdt_normal to use the node path There is no need to pass a node path separately. Instead we should use the path for the node provided. Correct this. Signed-off-by: Simon Glass diff --git a/tools/dtoc/fdt_normal.py b/tools/dtoc/fdt_normal.py index aae258e..cce5c06 100644 --- a/tools/dtoc/fdt_normal.py +++ b/tools/dtoc/fdt_normal.py @@ -81,7 +81,7 @@ class Node(NodeBase): This fills in the props and subnodes properties, recursively searching into subnodes so that the entire tree is built. """ - self.props = self._fdt.GetProps(self, self.path) + self.props = self._fdt.GetProps(self) offset = libfdt.fdt_first_subnode(self._fdt.GetFdt(), self.Offset()) while offset >= 0: @@ -159,7 +159,7 @@ class FdtNormal(Fdt): fdt_len = libfdt.fdt_totalsize(self._fdt) del self._fdt[fdt_len:] - def GetProps(self, node, path): + def GetProps(self, node): """Get all properties from a node. Args: @@ -172,11 +172,8 @@ class FdtNormal(Fdt): Raises: ValueError: if the node does not exist. """ - offset = libfdt.fdt_path_offset(self._fdt, path) - if offset < 0: - libfdt.Raise(offset) props_dict = {} - poffset = libfdt.fdt_first_property_offset(self._fdt, offset) + poffset = libfdt.fdt_first_property_offset(self._fdt, node._offset) while poffset >= 0: dprop, plen = libfdt.fdt_get_property_by_offset(self._fdt, poffset) prop = Prop(node, poffset, libfdt.String(self._fdt, dprop.nameoff), -- cgit v0.10.2 From 3cb44ba80c0379eb7d0eadd1b9b58e66fe2da03e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 25 Sep 2016 15:52:19 -0600 Subject: dtoc: Add a way for tests to request the fallback library We need to test both the normal (Python libfdt module) and fallback (fdtget) implementations of the Fdt class. Add a way to select which implementation to use. Signed-off-by: Simon Glass diff --git a/tools/dtoc/fdt_select.py b/tools/dtoc/fdt_select.py index 18a36d8..ea78c52 100644 --- a/tools/dtoc/fdt_select.py +++ b/tools/dtoc/fdt_select.py @@ -6,6 +6,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +import fdt_fallback + # Bring in either the normal fdt library (which relies on libfdt) or the # fallback one (which uses fdtget and is slower). Both provide the same # interface for this file to use. @@ -14,13 +16,21 @@ try: have_libfdt = True except ImportError: have_libfdt = False - import fdt_fallback -def FdtScan(fname): +force_fallback = False + +def FdtScan(fname, _force_fallback=False): """Returns a new Fdt object from the implementation we are using""" - if have_libfdt: + if have_libfdt and not force_fallback and not _force_fallback: dtb = fdt_normal.FdtNormal(fname) else: dtb = fdt_fallback.FdtFallback(fname) dtb.Scan() return dtb + +def UseFallback(fallback): + global force_fallback + + old_val = force_fallback + force_fallback = fallback + return old_val -- cgit v0.10.2 From 12e5476df33a24ff781e6f78404792e4b8596c28 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:49 +0100 Subject: patman: Replace tabs with spaces In preparation for running on python 3.x, which will refuse to run scripts which mix tabs & spaces for indentation, replace 2 tab characters present in series.py with spaces. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/patman/series.py b/tools/patman/series.py index cc6f80b..1ce30c6 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -225,7 +225,7 @@ class Series(dict): raise_on_error=raise_on_error) list += gitutil.BuildEmailList(commit.cc_list, raise_on_error=raise_on_error) - if add_maintainers: + if add_maintainers: list += get_maintainer.GetMaintainer(commit.patch) all_ccs += list print >>fd, commit.patch, ', '.join(set(list)) @@ -259,7 +259,7 @@ class Series(dict): """ git_prefix = gitutil.GetDefaultSubjectPrefix() if git_prefix: - git_prefix = '%s][' % git_prefix + git_prefix = '%s][' % git_prefix else: git_prefix = '' -- cgit v0.10.2 From a920a17b2f418535870788ae81234dc6b8aa6661 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:50 +0100 Subject: patman: Make print statements python 3.x safe In python 3.x, print must be used as a function call. Convert all print statements to the function call style, importing from __future__ where we print with no trailing newline or print to a file object. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 3eef6de..be78fc5 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -83,7 +83,7 @@ def CheckPatch(fname, verbose=False): for line in result.stdout.splitlines(): if verbose: - print line + print(line) # A blank line indicates the end of a message if not line and item: @@ -151,17 +151,17 @@ def CheckPatches(verbose, args): error_count += result.errors warning_count += result.warnings check_count += result.checks - print '%d errors, %d warnings, %d checks for %s:' % (result.errors, - result.warnings, result.checks, col.Color(col.BLUE, fname)) + print('%d errors, %d warnings, %d checks for %s:' % (result.errors, + result.warnings, result.checks, col.Color(col.BLUE, fname))) if (len(result.problems) != result.errors + result.warnings + result.checks): - print "Internal error: some problems lost" + print("Internal error: some problems lost") for item in result.problems: - print GetWarningMsg(col, item.get('type', ''), + print(GetWarningMsg(col, item.get('type', ''), item.get('file', ''), - item.get('line', 0), item.get('msg', 'message')) + item.get('line', 0), item.get('msg', 'message'))) print - #print stdout + #print(stdout) if error_count or warning_count or check_count: str = 'checkpatch.pl found %d error(s), %d warning(s), %d checks(s)' color = col.GREEN @@ -169,6 +169,6 @@ def CheckPatches(verbose, args): color = col.YELLOW if error_count: color = col.RED - print col.Color(color, str % (error_count, warning_count, check_count)) + print(col.Color(color, str % (error_count, warning_count, check_count))) return False return True diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py index 00b4939..2deb5db 100644 --- a/tools/patman/get_maintainer.py +++ b/tools/patman/get_maintainer.py @@ -40,7 +40,7 @@ def GetMaintainer(fname, verbose=False): get_maintainer = FindGetMaintainer() if not get_maintainer: if verbose: - print "WARNING: Couldn't find get_maintainer.pl" + print("WARNING: Couldn't find get_maintainer.pl") return [] stdout = command.Output(get_maintainer, '--norolestats', fname) diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index bb7c9e0..c0fe093 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -491,7 +491,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0): if raise_on_error: raise OSError, msg else: - print col.Color(col.RED, msg) + print(col.Color(col.RED, msg)) return out_list if lookup_name: @@ -500,7 +500,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0): if raise_on_error: raise ValueError, msg else: - print col.Color(col.RED, msg) + print(col.Color(col.RED, msg)) return out_list for item in alias[lookup_name]: todo = LookupEmail(item, alias, raise_on_error, level + 1) @@ -508,7 +508,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0): if not new_item in out_list: out_list.append(new_item) - #print "No match for alias '%s'" % lookup_name + #print("No match for alias '%s'" % lookup_name) return out_list def GetTopLevel(): diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 69d5cfb..cd4667f 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -480,12 +480,12 @@ def FixPatches(series, fnames): commit.patch = fname result = FixPatch(backup_dir, fname, series, commit) if result: - print '%d warnings for %s:' % (len(result), fname) + print('%d warnings for %s:' % (len(result), fname)) for warn in result: - print '\t', warn + print('\t', warn) print count += 1 - print 'Cleaned %d patches' % count + print('Cleaned %d patches' % count) return series def InsertCoverLetter(fname, series, count): diff --git a/tools/patman/patman.py b/tools/patman/patman.py index fe50eb4..fdbee67 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -93,11 +93,11 @@ elif options.test: suite.run(result) # TODO: Surely we can just 'print' result? - print result + print(result) for test, err in result.errors: - print err + print(err) for test, err in result.failures: - print err + print(err) # Called from git with a patch filename as argument # Printout a list of additional CC recipients for this patch @@ -110,7 +110,7 @@ elif options.cc_cmd: for cc in match.group(2).split(', '): cc = cc.strip() if cc: - print cc + print(cc) fd.close() elif options.full_help: @@ -166,12 +166,12 @@ else: options.dry_run, not options.ignore_bad_tags, cc_file, in_reply_to=options.in_reply_to, thread=options.thread) else: - print col.Color(col.RED, "Not sending emails due to errors/warnings") + print(col.Color(col.RED, "Not sending emails due to errors/warnings")) # For a dry run, just show our actions as a sanity check if options.dry_run: series.ShowActions(args, cmd, options.process_tags) if not its_a_go: - print col.Color(col.RED, "Email would not be sent") + print(col.Color(col.RED, "Email would not be sent")) os.remove(cc_file) diff --git a/tools/patman/series.py b/tools/patman/series.py index 1ce30c6..38a452e 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -3,6 +3,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +from __future__ import print_function + import itertools import os @@ -101,38 +103,38 @@ class Series(dict): cc_set = set(gitutil.BuildEmailList(self.cc)); col = terminal.Color() - print 'Dry run, so not doing much. But I would do this:' - print - print 'Send a total of %d patch%s with %scover letter.' % ( + print('Dry run, so not doing much. But I would do this:') + print() + print('Send a total of %d patch%s with %scover letter.' % ( len(args), '' if len(args) == 1 else 'es', - self.get('cover') and 'a ' or 'no ') + self.get('cover') and 'a ' or 'no ')) # TODO: Colour the patches according to whether they passed checks for upto in range(len(args)): commit = self.commits[upto] - print col.Color(col.GREEN, ' %s' % args[upto]) + print(col.Color(col.GREEN, ' %s' % args[upto])) cc_list = list(self._generated_cc[commit.patch]) for email in set(cc_list) - to_set - cc_set: if email == None: email = col.Color(col.YELLOW, "" % tag) if email: - print ' Cc: ',email + print(' Cc: ', email) print for item in to_set: - print 'To:\t ', item + print('To:\t ', item) for item in cc_set - to_set: - print 'Cc:\t ', item - print 'Version: ', self.get('version') - print 'Prefix:\t ', self.get('prefix') + print('Cc:\t ', item) + print('Version: ', self.get('version')) + print('Prefix:\t ', self.get('prefix')) if self.cover: - print 'Cover: %d lines' % len(self.cover) + print('Cover: %d lines' % len(self.cover)) cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) all_ccs = itertools.chain(cover_cc, *self._generated_cc.values()) for email in set(all_ccs) - to_set - cc_set: - print ' Cc: ',email + print(' Cc: ', email) if cmd: - print 'Git command: %s' % cmd + print('Git command: %s' % cmd) def MakeChangeLog(self, commit): """Create a list of changes for each version. @@ -191,13 +193,13 @@ class Series(dict): else: if version > 1: str = 'Change log missing for v%d' % version - print col.Color(col.RED, str) + print(col.Color(col.RED, str)) for version in changes_copy: str = 'Change log for unknown version v%d' % version - print col.Color(col.RED, str) + print(col.Color(col.RED, str)) elif self.changes: str = 'Change log exists, but no version is set' - print col.Color(col.RED, str) + print(col.Color(col.RED, str)) def MakeCcFile(self, process_tags, cover_fname, raise_on_error, add_maintainers): @@ -228,12 +230,12 @@ class Series(dict): if add_maintainers: list += get_maintainer.GetMaintainer(commit.patch) all_ccs += list - print >>fd, commit.patch, ', '.join(set(list)) + print(commit.patch, ', '.join(set(list)), file=fd) self._generated_cc[commit.patch] = list if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) - print >>fd, cover_fname, ', '.join(set(cover_cc + all_ccs)) + print(cover_fname, ', '.join(set(cover_cc + all_ccs)), file=fd) fd.close() return fname diff --git a/tools/patman/settings.py b/tools/patman/settings.py index ba2a68f..01f6c38 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -3,6 +3,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +from __future__ import print_function + import ConfigParser import os import re @@ -156,7 +158,7 @@ def ReadGitAliases(fname): try: fd = open(fname, 'r') except IOError: - print "Warning: Cannot find alias file '%s'" % fname + print("Warning: Cannot find alias file '%s'" % fname) return re_line = re.compile('alias\s+(\S+)\s+(.*)') @@ -167,7 +169,7 @@ def ReadGitAliases(fname): m = re_line.match(line) if not m: - print "Warning: Alias file line '%s' not understood" % line + print("Warning: Alias file line '%s' not understood" % line) continue list = alias.get(m.group(1), []) @@ -200,10 +202,10 @@ def CreatePatmanConfigFile(config_fname): try: f = open(config_fname, 'w') except IOError: - print "Couldn't create patman config file\n" + print("Couldn't create patman config file\n") raise - print >>f, "[alias]\nme: %s <%s>" % (name, email) + print("[alias]\nme: %s <%s>" % (name, email), file=f) f.close(); def _UpdateDefaults(parser, config): @@ -233,7 +235,7 @@ def _UpdateDefaults(parser, config): val = config.getint('settings', name) parser.set_default(name, val) else: - print "WARNING: Unknown setting %s" % name + print("WARNING: Unknown setting %s" % name) def _ReadAliasFile(fname): """Read in the U-Boot git alias file if it exists. @@ -258,7 +260,7 @@ def _ReadAliasFile(fname): continue alias[words[1]] = [s.strip() for s in words[2].split(',')] if bad_line: - print bad_line + print(bad_line) def Setup(parser, project_name, config_fname=''): """Set up the settings module by reading config files. @@ -276,7 +278,7 @@ def Setup(parser, project_name, config_fname=''): config_fname = '%s/.patman' % os.getenv('HOME') if not os.path.exists(config_fname): - print "No config file found ~/.patman\nCreating one...\n" + print("No config file found ~/.patman\nCreating one...\n") CreatePatmanConfigFile(config_fname) config.read(config_fname) diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py index af3593e..137265f 100644 --- a/tools/patman/terminal.py +++ b/tools/patman/terminal.py @@ -8,6 +8,8 @@ This module handles terminal interaction including ANSI color codes. """ +from __future__ import print_function + import os import sys @@ -52,9 +54,9 @@ def Print(text='', newline=True, colour=None): if colour: col = Color() text = col.Color(colour, text) - print text, + print(text, end='') if newline: - print + print() else: sys.stdout.flush() @@ -81,11 +83,11 @@ def EchoPrintTestLines(): for line in print_test_list: if line.colour: col = Color() - print col.Color(line.colour, line.text), + print(col.Color(line.colour, line.text), end='') else: - print line.text, + print(line.text, end='') if line.newline: - print + print() class Color(object): diff --git a/tools/patman/test.py b/tools/patman/test.py index e8f7472..8c39f66 100644 --- a/tools/patman/test.py +++ b/tools/patman/test.py @@ -181,7 +181,7 @@ index 0000000..2234c87 elif data_type == 'indent': indent = tab else: - print 'not implemented' + print('not implemented') return data % (signoff, tab, indent, tab) def SetupData(self, data_type): -- cgit v0.10.2 From ac3fde9394ce90503930026c62ffd94bf7fa09fd Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:51 +0100 Subject: patman: Make exception handling python 3.x safe Syntax for exception handling is a little more strict in python 3.x. Convert all uses to a form accepted by both python 2.x & python 3.x. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/patman/command.py b/tools/patman/command.py index d1f0ca5..bebc495 100644 --- a/tools/patman/command.py +++ b/tools/patman/command.py @@ -85,7 +85,7 @@ def RunPipe(pipe_list, infile=None, outfile=None, try: last_pipe = cros_subprocess.Popen(cmd, cwd=cwd, **kwargs) - except Exception, err: + except Exception as err: result.exception = err if raise_on_error: raise Exception("Error running '%s': %s" % (user_pipestr, str)) diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py index 0fc4a06..ebd4300 100644 --- a/tools/patman/cros_subprocess.py +++ b/tools/patman/cros_subprocess.py @@ -166,7 +166,7 @@ class Popen(subprocess.Popen): while read_set or write_set: try: rlist, wlist, _ = select.select(read_set, write_set, [], 0.2) - except select.error, e: + except select.error as e: if e.args[0] == errno.EINTR: continue raise diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index c0fe093..0d23079 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -139,7 +139,7 @@ def GetUpstream(git_dir, branch): leaf = merge.split('/')[-1] return '%s/%s' % (remote, leaf), None else: - raise ValueError, ("Cannot determine upstream branch for branch " + raise ValueError("Cannot determine upstream branch for branch " "'%s' remote='%s', merge='%s'" % (branch, remote, merge)) @@ -224,7 +224,7 @@ def Checkout(commit_hash, git_dir=None, work_tree=None, force=False): result = command.RunPipe([pipe], capture=True, raise_on_error=False, capture_stderr=True) if result.return_code != 0: - raise OSError, 'git checkout (%s): %s' % (pipe, result.stderr) + raise OSError('git checkout (%s): %s' % (pipe, result.stderr)) def Clone(git_dir, output_dir): """Checkout the selected commit for this build @@ -236,7 +236,7 @@ def Clone(git_dir, output_dir): result = command.RunPipe([pipe], capture=True, cwd=output_dir, capture_stderr=True) if result.return_code != 0: - raise OSError, 'git clone: %s' % result.stderr + raise OSError('git clone: %s' % result.stderr) def Fetch(git_dir=None, work_tree=None): """Fetch from the origin repo @@ -252,7 +252,7 @@ def Fetch(git_dir=None, work_tree=None): pipe.append('fetch') result = command.RunPipe([pipe], capture=True, capture_stderr=True) if result.return_code != 0: - raise OSError, 'git fetch: %s' % result.stderr + raise OSError('git fetch: %s' % result.stderr) def CreatePatches(start, count, series): """Create a series of patches from the top of the current branch. @@ -489,7 +489,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0): if level > 10: msg = "Recursive email alias at '%s'" % lookup_name if raise_on_error: - raise OSError, msg + raise OSError(msg) else: print(col.Color(col.RED, msg)) return out_list @@ -498,7 +498,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0): if not lookup_name in alias: msg = "Alias '%s' not found" % lookup_name if raise_on_error: - raise ValueError, msg + raise ValueError(msg) else: print(col.Color(col.RED, msg)) return out_list -- cgit v0.10.2 From 2ce7b21e6c98301f9b05daac076db33d498cfbe1 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:52 +0100 Subject: patman: Import 'configparser' lower case to be python 3.x safe In python 3.x module names used in import statements are case sensitive, and the configparser module is named in all lower-case. Import it as such in order to avoid errors when running with python 3.x. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 01f6c38..3caf379 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -5,7 +5,11 @@ from __future__ import print_function -import ConfigParser +try: + import configparser as ConfigParser +except: + import ConfigParser + import os import re -- cgit v0.10.2 From c9eac38a25b53085f18a831eb28c27512982cc5f Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:54 +0100 Subject: patman: Use items() to iterate over dictionaries In python 3.x the iteritems() method has been removed from dictionaries, and the items() method does effectively the same thing. On python 2.x using items() is a little less efficient since it involves copying data, but as speed isn't a concern in this code switch to using items() anyway for simplicity. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 3caf379..7ef0ab0 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -94,7 +94,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): if not self.has_section(project_settings): self.add_section(project_settings) project_defaults = _default_settings.get(project_name, {}) - for setting_name, setting_value in project_defaults.iteritems(): + for setting_name, setting_value in project_defaults.items(): self.set(project_settings, setting_name, setting_value) def get(self, section, option, *args, **kwargs): -- cgit v0.10.2 From f5d44b9bae64d4fc347c537e6d5f13d630eb858d Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:55 +0100 Subject: patman: Fix doctest StringIO import for python 3.x In python 3.x StringIO is no longer a module, and the class can instead be found in the io module. Adjust the code in the doctest input to account for both. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 7ef0ab0..5f207f5 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -36,7 +36,10 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): - Merge general default settings/aliases with project-specific ones. # Sample config used for tests below... - >>> import StringIO + >>> try: + ... from StringIO import StringIO + ... except ImportError: + ... from io import StringIO >>> sample_config = ''' ... [alias] ... me: Peter P. @@ -54,25 +57,25 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): # Check to make sure that bogus project gets general alias. >>> config = _ProjectConfigParser("zzz") - >>> config.readfp(StringIO.StringIO(sample_config)) + >>> config.readfp(StringIO(sample_config)) >>> config.get("alias", "enemies") 'Evil ' # Check to make sure that alias gets overridden by project. >>> config = _ProjectConfigParser("sm") - >>> config.readfp(StringIO.StringIO(sample_config)) + >>> config.readfp(StringIO(sample_config)) >>> config.get("alias", "enemies") 'Green G. ' # Check to make sure that settings get merged with project. >>> config = _ProjectConfigParser("linux") - >>> config.readfp(StringIO.StringIO(sample_config)) + >>> config.readfp(StringIO(sample_config)) >>> sorted(config.items("settings")) [('am_hero', 'True'), ('process_tags', 'False')] # Check to make sure that settings works with unknown project. >>> config = _ProjectConfigParser("unknown") - >>> config.readfp(StringIO.StringIO(sample_config)) + >>> config.readfp(StringIO(sample_config)) >>> sorted(config.items("settings")) [('am_hero', 'True')] """ -- cgit v0.10.2 From 4ae6549f8e1cd31076c6dbabef568689fc313a13 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:56 +0100 Subject: dtoc: Use items() to iterate over dictionaries in python 3.x In python 3.x the iteritems() method has been removed from dictionaries, and the items() method does effectively the same thing. On python 2.x using items() is a little less efficient since it involves copying data, but as speed isn't a concern in the affected code switch to using items() anyway for simplicity. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py index 518aa51..12aa990 100755 --- a/tools/dtoc/dtoc.py +++ b/tools/dtoc/dtoc.py @@ -224,14 +224,14 @@ class DtbPlatdata: fields = {} # Get a list of all the valid properties in this node. - for name, prop in node.props.iteritems(): + for name, prop in node.props.items(): if name not in PROP_IGNORE_LIST and name[0] != '#': fields[name] = copy.deepcopy(prop) # If we've seen this node_name before, update the existing struct. if node_name in structs: struct = structs[node_name] - for name, prop in fields.iteritems(): + for name, prop in fields.items(): oldprop = struct.get(name) if oldprop: oldprop.Widen(prop) @@ -246,7 +246,7 @@ class DtbPlatdata: for node in self._valid_nodes: node_name = self.GetCompatName(node) struct = structs[node_name] - for name, prop in node.props.iteritems(): + for name, prop in node.props.items(): if name not in PROP_IGNORE_LIST and name[0] != '#': prop.Widen(struct[name]) upto += 1 @@ -298,7 +298,7 @@ class DtbPlatdata: var_name = Conv_name_to_c(node.name) self.Buf('static struct %s%s %s%s = {\n' % (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name)) - for pname, prop in node.props.iteritems(): + for pname, prop in node.props.items(): if pname in PROP_IGNORE_LIST or pname[0] == '#': continue ptype = TYPE_NAMES[prop.type] diff --git a/tools/dtoc/fdt_fallback.py b/tools/dtoc/fdt_fallback.py index 7d52da7..23e2679 100644 --- a/tools/dtoc/fdt_fallback.py +++ b/tools/dtoc/fdt_fallback.py @@ -58,7 +58,7 @@ class Node(NodeBase): This fills in the props and subnodes properties, recursively searching into subnodes so that the entire tree is built. """ - for name, byte_list_str in self._fdt.GetProps(self.path).iteritems(): + for name, byte_list_str in self._fdt.GetProps(self.path).items(): prop = Prop(self, name, byte_list_str) self.props[name] = prop -- cgit v0.10.2 From c4c5f9eefbda7231d0e9703905524faebe71e795 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:57 +0100 Subject: dtoc: Decode strings for struct.unpack on python 3.x On python 3.x struct.unpack will complain if we provide it with a string since it expects to operate on a bytes object. In order to satisfy this requirement, encode the string to a bytes object when running on python 3.x. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index 3a10838..e6d523b 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -8,6 +8,7 @@ import os import struct +import sys import tempfile import command @@ -22,6 +23,8 @@ def fdt32_to_cpu(val): Return: A native-endian integer value """ + if sys.version_info > (3, 0): + val = val.encode('raw_unicode_escape') return struct.unpack('>I', val)[0] def EnsureCompiled(fname): -- cgit v0.10.2 From 34c38896357db4aae266b14346927da2cd920de6 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:58 +0100 Subject: dtoc: Make integer division python 3.x safe If we use the '/' operator then python 3.x will produce a float, and refuse to multiply the string sequence in Conv_name_to_c by it with: TypeError: can't multiply sequence by non-int of type 'float' Use the '//' operator instead to enforce that we want integer rather than floating point division. Signed-off-by: Paul Burton Acked-by: Simon Glass diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py index 12aa990..11050b6 100755 --- a/tools/dtoc/dtoc.py +++ b/tools/dtoc/dtoc.py @@ -60,7 +60,7 @@ def Conv_name_to_c(name): def TabTo(num_tabs, str): if len(str) >= num_tabs * 8: return str + ' ' - return str + '\t' * (num_tabs - len(str) / 8) + return str + '\t' * (num_tabs - len(str) // 8) class DtbPlatdata: """Provide a means to convert device tree binary data to platform data -- cgit v0.10.2 From f40fa9b36f42794cc8d778eb0e8d26cfb0c40bed Mon Sep 17 00:00:00 2001 From: York Sun Date: Tue, 4 Oct 2016 14:33:50 -0700 Subject: tools: buildman: Remove duplicated code Signed-off-by: York Sun CC: Simon Glass Fixed commit subject: Signed-off-by: Simon Glass Acked-by: Simon Glass diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index c4fe219..8974351 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -304,10 +304,6 @@ class BuilderThread(threading.Thread): print >>fd, 'arch', result.toolchain.arch fd.write('%s' % result.return_code) - with open(os.path.join(build_dir, 'toolchain'), 'w') as fd: - print >>fd, 'gcc', result.toolchain.gcc - print >>fd, 'path', result.toolchain.path - # Write out the image and function size information and an objdump env = result.toolchain.MakeEnvironment(self.builder.full_path) lines = [] -- cgit v0.10.2 From d5fe013ceefe72466f192fd17f1dae8ce29684ef Mon Sep 17 00:00:00 2001 From: York Sun Date: Tue, 4 Oct 2016 14:33:51 -0700 Subject: tools: buildman: Add compiler wrapper Now we can use compiler wrapper such as ccache or distcc for buildman. Signed-off-by: York Sun CC: Simon Glass Acked-by: Simon Glass diff --git a/tools/buildman/README b/tools/buildman/README index 8c5f861..514bebc 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -211,6 +211,15 @@ arm: arm-none-eabi- and buildman will find arm-none-eabi-gcc in /usr/bin if you have it installed. +[toolchain-wrapper] +wrapper: ccache + +This tells buildman to use a compiler wrapper in front of CROSS_COMPILE. In +this example, ccache. It doesn't affect the toolchain scan. The wrapper is +added when CROSS_COMPILE environtal variable is set. The name in this +section is ignored. If more than one line is provided, only the last one +is taken. + 3. Make sure you have the require Python pre-requisites Buildman uses multiprocessing, Queue, shutil, StringIO, ConfigParser and diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index 41e4e4c..4778876 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -127,6 +127,18 @@ class Toolchain: return PRIORITY_CALC + prio return PRIORITY_CALC + prio + def GetWrapper(self, show_warning=True): + """Get toolchain wrapper from the setting file. + """ + value = '' + for name, value in bsettings.GetItems('toolchain-wrapper'): + if not value: + print "Warning: Wrapper not found" + if value: + value = value + ' ' + + return value + def MakeEnvironment(self, full_path): """Returns an environment for using the toolchain. @@ -138,10 +150,12 @@ class Toolchain: PATH """ env = dict(os.environ) + wrapper = self.GetWrapper() + if full_path: - env['CROSS_COMPILE'] = os.path.join(self.path, self.cross) + env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross) else: - env['CROSS_COMPILE'] = self.cross + env['CROSS_COMPILE'] = wrapper + self.cross env['PATH'] = self.path + ':' + env['PATH'] return env -- cgit v0.10.2 From 561e624c350ee5c281da46d23aee70b0523d4d39 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 1 Oct 2016 14:43:17 -0600 Subject: dm: mmc: Support erase At present erase is not suported with CONFIG_DM_OPS. Add it so that MMC devices can be erased. Signed-off-by: Simon Glass diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 425abb1..77424cd 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -262,6 +262,7 @@ static const struct blk_ops mmc_blk_ops = { .read = mmc_bread, #ifndef CONFIG_SPL_BUILD .write = mmc_bwrite, + .erase = mmc_berase, #endif .select_hwpart = mmc_select_hwpart, }; diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h index d8b399e..03bf24d 100644 --- a/drivers/mmc/mmc_private.h +++ b/drivers/mmc/mmc_private.h @@ -29,15 +29,15 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, #endif #if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV)) -unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start, - lbaint_t blkcnt); #ifdef CONFIG_BLK ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, const void *src); +ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt); #else ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *src); +ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt); #endif #else /* CONFIG_SPL_BUILD and CONFIG_SPL_SAVEENV is not defined */ diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c index 2289640..54acbf7 100644 --- a/drivers/mmc/mmc_write.c +++ b/drivers/mmc/mmc_write.c @@ -66,9 +66,15 @@ err_out: return err; } -unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start, - lbaint_t blkcnt) +#ifdef CONFIG_BLK +ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt) +#else +ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt) +#endif { +#ifdef CONFIG_BLK + struct blk_desc *block_dev = dev_get_uclass_platdata(dev); +#endif int dev_num = block_dev->devnum; int err = 0; u32 start_rem, blkcnt_rem; -- cgit v0.10.2 From 896a74f615d6ffcbbcbec1505b19ed3280fe7873 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 1 Oct 2016 14:43:18 -0600 Subject: dm: blk: Enable CONFIG_BLK if DM_MMC is enabled To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled. Signed-off-by: Simon Glass diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index e0110d1..68769ea 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -38,6 +38,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DM_I2C=y diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index a2cfef3..b9f1051 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -34,6 +34,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2" +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_NAND=y CONFIG_DFU_RAM=y diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig index 64e48e9..c423362 100644 --- a/configs/am43xx_evm_defconfig +++ b/configs/am43xx_evm_defconfig @@ -35,6 +35,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm" CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/am43xx_evm_usbhost_boot_defconfig b/configs/am43xx_evm_usbhost_boot_defconfig index 14d874f..aa0effb 100644 --- a/configs/am43xx_evm_usbhost_boot_defconfig +++ b/configs/am43xx_evm_usbhost_boot_defconfig @@ -38,6 +38,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm" CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig index 6c5b409..0f7b887 100644 --- a/configs/am43xx_hs_evm_defconfig +++ b/configs/am43xx_hs_evm_defconfig @@ -38,6 +38,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index 15c3389..ab66856 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -37,6 +37,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="am57xx-beagle-x15 am572x-idk" CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 192997a..6a17470 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -38,6 +38,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y diff --git a/configs/apalis_t30_defconfig b/configs/apalis_t30_defconfig index a22e6b6..3c67b90 100644 --- a/configs/apalis_t30_defconfig +++ b/configs/apalis_t30_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_E1000=y diff --git a/configs/beaver_defconfig b/configs/beaver_defconfig index 503b8d1..b11bdbd 100644 --- a/configs/beaver_defconfig +++ b/configs/beaver_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/cardhu_defconfig b/configs/cardhu_defconfig index 2d361c3..c95ed03 100644 --- a/configs/cardhu_defconfig +++ b/configs/cardhu_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/cei-tk1-som_defconfig b/configs/cei-tk1-som_defconfig index fb7e2af..32e3590 100644 --- a/configs/cei-tk1-som_defconfig +++ b/configs/cei-tk1-som_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/colibri_t20_defconfig b/configs/colibri_t20_defconfig index 2745d8b..586dd27 100644 --- a/configs/colibri_t20_defconfig +++ b/configs/colibri_t20_defconfig @@ -31,6 +31,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_CMD_UBI=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_MTD_UBI_FASTMAP=y diff --git a/configs/colibri_t30_defconfig b/configs/colibri_t30_defconfig index e9eabed..56c1e07 100644 --- a/configs/colibri_t30_defconfig +++ b/configs/colibri_t30_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_SYS_NS16550=y diff --git a/configs/dalmore_defconfig b/configs/dalmore_defconfig index 2855af5..0634fa6 100644 --- a/configs/dalmore_defconfig +++ b/configs/dalmore_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index 14ecc24..cc5540e 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -47,6 +47,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc" CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig index a18fd14..a1e715f 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -50,6 +50,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="dra7-evm dra72-evm" CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/e2220-1170_defconfig b/configs/e2220-1170_defconfig index 7d0cb68..d35e665 100644 --- a/configs/e2220-1170_defconfig +++ b/configs/e2220-1170_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/harmony_defconfig b/configs/harmony_defconfig index 4fbca28..5041768 100644 --- a/configs/harmony_defconfig +++ b/configs/harmony_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/jetson-tk1_defconfig b/configs/jetson-tk1_defconfig index af913ac..ccfbffe 100644 --- a/configs/jetson-tk1_defconfig +++ b/configs/jetson-tk1_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig index 13b91cd..27659ba 100644 --- a/configs/k2g_evm_defconfig +++ b/configs/k2g_evm_defconfig @@ -35,6 +35,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_CMD_UBI=y CONFIG_OF_CONTROL=y CONFIG_DM=y +# CONFIG_BLK is not set CONFIG_DM_MMC=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y diff --git a/configs/medcom-wide_defconfig b/configs/medcom-wide_defconfig index 24cace6..479847d 100644 --- a/configs/medcom-wide_defconfig +++ b/configs/medcom-wide_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/mx6ull_14x14_evk_defconfig b/configs/mx6ull_14x14_evk_defconfig index a106b5d..fdb3221 100644 --- a/configs/mx6ull_14x14_evk_defconfig +++ b/configs/mx6ull_14x14_evk_defconfig @@ -1,7 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_MX6=y CONFIG_TARGET_MX6ULL_14X14_EVK=y -CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="imx6ull-14x14-evk" CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6ullevk/imximage.cfg" CONFIG_BOOTDELAY=3 @@ -21,6 +20,8 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y +# CONFIG_BLK is not set +CONFIG_DM_GPIO=y CONFIG_DM_74X164=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig index b1f9993..977cf2d 100644 --- a/configs/nyan-big_defconfig +++ b/configs/nyan-big_defconfig @@ -36,6 +36,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/p2371-0000_defconfig b/configs/p2371-0000_defconfig index 69fc1ba..295cca6 100644 --- a/configs/p2371-0000_defconfig +++ b/configs/p2371-0000_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/p2371-2180_defconfig b/configs/p2371-2180_defconfig index 6ccd7a3..2ee71ba 100644 --- a/configs/p2371-2180_defconfig +++ b/configs/p2371-2180_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/p2571_defconfig b/configs/p2571_defconfig index 1fd4649..fece81b 100644 --- a/configs/p2571_defconfig +++ b/configs/p2571_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/p2771-0000-000_defconfig b/configs/p2771-0000-000_defconfig index 4c4606a..a48ba26 100644 --- a/configs/p2771-0000-000_defconfig +++ b/configs/p2771-0000-000_defconfig @@ -25,6 +25,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +# CONFIG_BLK is not set CONFIG_TEGRA186_BPMP_I2C=y CONFIG_E1000=y CONFIG_RTL8169=y diff --git a/configs/p2771-0000-500_defconfig b/configs/p2771-0000-500_defconfig index b32df1c..0fbe58e 100644 --- a/configs/p2771-0000-500_defconfig +++ b/configs/p2771-0000-500_defconfig @@ -25,6 +25,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +# CONFIG_BLK is not set CONFIG_TEGRA186_BPMP_I2C=y CONFIG_E1000=y CONFIG_RTL8169=y diff --git a/configs/paz00_defconfig b/configs/paz00_defconfig index b86f76c..436174e 100644 --- a/configs/paz00_defconfig +++ b/configs/paz00_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/pic32mzdask_defconfig b/configs/pic32mzdask_defconfig index 4e986bb..050c305 100644 --- a/configs/pic32mzdask_defconfig +++ b/configs/pic32mzdask_defconfig @@ -45,3 +45,4 @@ CONFIG_USB_MUSB_PIC32=y CONFIG_USB_STORAGE=y CONFIG_USE_TINY_PRINTF=y CONFIG_CMD_DHRYSTONE=y +# CONFIG_BLK is not set diff --git a/configs/plutux_defconfig b/configs/plutux_defconfig index b1997fe..ff77149 100644 --- a/configs/plutux_defconfig +++ b/configs/plutux_defconfig @@ -26,6 +26,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig index 85610ed..bc5793f 100644 --- a/configs/sandbox_noblk_defconfig +++ b/configs/sandbox_noblk_defconfig @@ -68,6 +68,7 @@ CONFIG_DEVRES=y CONFIG_DEBUG_DEVRES=y CONFIG_ADC=y CONFIG_ADC_SANDBOX=y +# CONFIG_BLK is not set CONFIG_CLK=y CONFIG_CPU=y CONFIG_DM_DEMO=y diff --git a/configs/seaboard_defconfig b/configs/seaboard_defconfig index 806caca..685c9e4 100644 --- a/configs/seaboard_defconfig +++ b/configs/seaboard_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/tec-ng_defconfig b/configs/tec-ng_defconfig index 9441b17..a4ae982 100644 --- a/configs/tec-ng_defconfig +++ b/configs/tec-ng_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/tec_defconfig b/configs/tec_defconfig index d8ecde2..87dc247 100644 --- a/configs/tec_defconfig +++ b/configs/tec_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/trimslice_defconfig b/configs/trimslice_defconfig index 201a870..f6236ea 100644 --- a/configs/trimslice_defconfig +++ b/configs/trimslice_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/venice2_defconfig b/configs/venice2_defconfig index 358fc8f..c07d12d 100644 --- a/configs/venice2_defconfig +++ b/configs/venice2_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y diff --git a/configs/ventana_defconfig b/configs/ventana_defconfig index 56e7ba3..e247f9a 100644 --- a/configs/ventana_defconfig +++ b/configs/ventana_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/whistler_defconfig b/configs/whistler_defconfig index 33aa977..7c93980 100644 --- a/configs/whistler_defconfig +++ b/configs/whistler_defconfig @@ -26,6 +26,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y +# CONFIG_BLK is not set CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 80eea84..fe5aa07 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -1,6 +1,7 @@ config BLK bool "Support block devices" depends on DM + default y if DM_MMC help Enable support for block devices, such as SCSI, MMC and USB flash sticks. These provide a block-level interface which permits -- cgit v0.10.2 From 252788b4eda852e0195e1903e55480b4bf4fea9d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 1 Oct 2016 14:43:19 -0600 Subject: dm: mmc: Enable DM_MMC_OPS by default with DM_MMC These two options go together and it is best to do the conversion in one step. So enable DM_MMC_OPS by default if DM_MMC is enabled. Signed-off-by: Simon Glass diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index 68769ea..c6ef650 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -43,6 +43,7 @@ CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index b9f1051..3136957 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -40,6 +40,7 @@ CONFIG_DFU_NAND=y CONFIG_DFU_RAM=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig index c423362..304743d 100644 --- a/configs/am43xx_evm_defconfig +++ b/configs/am43xx_evm_defconfig @@ -42,6 +42,7 @@ CONFIG_DFU_SF=y CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_MACRONIX=y diff --git a/configs/am43xx_evm_usbhost_boot_defconfig b/configs/am43xx_evm_usbhost_boot_defconfig index aa0effb..f385371 100644 --- a/configs/am43xx_evm_usbhost_boot_defconfig +++ b/configs/am43xx_evm_usbhost_boot_defconfig @@ -44,6 +44,7 @@ CONFIG_DFU_RAM=y CONFIG_DFU_SF=y CONFIG_DM_GPIO=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_DM_SERIAL=y diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig index 0f7b887..ad7c842 100644 --- a/configs/am43xx_hs_evm_defconfig +++ b/configs/am43xx_hs_evm_defconfig @@ -45,6 +45,7 @@ CONFIG_DFU_SF=y CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_DM_ETH=y diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index ab66856..1764a05 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -41,6 +41,7 @@ CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 6a17470..a80e882 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -42,6 +42,7 @@ CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y diff --git a/configs/apalis_t30_defconfig b/configs/apalis_t30_defconfig index 3c67b90..ec33397 100644 --- a/configs/apalis_t30_defconfig +++ b/configs/apalis_t30_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_DM=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +# CONFIG_DM_MMC_OPS is not set CONFIG_E1000=y CONFIG_PCI_TEGRA=y CONFIG_SYS_NS16550=y diff --git a/configs/beaver_defconfig b/configs/beaver_defconfig index b11bdbd..6758c56 100644 --- a/configs/beaver_defconfig +++ b/configs/beaver_defconfig @@ -34,6 +34,7 @@ CONFIG_SPL_DM=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/cardhu_defconfig b/configs/cardhu_defconfig index c95ed03..44955fa 100644 --- a/configs/cardhu_defconfig +++ b/configs/cardhu_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/cei-tk1-som_defconfig b/configs/cei-tk1-som_defconfig index 32e3590..cc162f9 100644 --- a/configs/cei-tk1-som_defconfig +++ b/configs/cei-tk1-som_defconfig @@ -34,6 +34,7 @@ CONFIG_SPL_DM=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/colibri_t20_defconfig b/configs/colibri_t20_defconfig index 586dd27..d070a27 100644 --- a/configs/colibri_t20_defconfig +++ b/configs/colibri_t20_defconfig @@ -34,6 +34,7 @@ CONFIG_SPL_DM=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +# CONFIG_DM_MMC_OPS is not set CONFIG_MTD_UBI_FASTMAP=y CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y diff --git a/configs/colibri_t30_defconfig b/configs/colibri_t30_defconfig index 56c1e07..31275d0 100644 --- a/configs/colibri_t30_defconfig +++ b/configs/colibri_t30_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_DM=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y diff --git a/configs/dalmore_defconfig b/configs/dalmore_defconfig index 0634fa6..1de5d4a 100644 --- a/configs/dalmore_defconfig +++ b/configs/dalmore_defconfig @@ -34,6 +34,7 @@ CONFIG_SPL_DM=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index cc5540e..3ee3021 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -55,6 +55,7 @@ CONFIG_DM_GPIO=y CONFIG_PCF8575_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig index a1e715f..1d7838a 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -58,6 +58,7 @@ CONFIG_DM_GPIO=y CONFIG_PCF8575_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y diff --git a/configs/e2220-1170_defconfig b/configs/e2220-1170_defconfig index d35e665..9a4c556 100644 --- a/configs/e2220-1170_defconfig +++ b/configs/e2220-1170_defconfig @@ -31,6 +31,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/harmony_defconfig b/configs/harmony_defconfig index 5041768..e1691f6 100644 --- a/configs/harmony_defconfig +++ b/configs/harmony_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/jetson-tk1_defconfig b/configs/jetson-tk1_defconfig index ccfbffe..6c284a1 100644 --- a/configs/jetson-tk1_defconfig +++ b/configs/jetson-tk1_defconfig @@ -34,6 +34,7 @@ CONFIG_SPL_DM=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig index 27659ba..3e5630b 100644 --- a/configs/k2g_evm_defconfig +++ b/configs/k2g_evm_defconfig @@ -37,6 +37,7 @@ CONFIG_OF_CONTROL=y CONFIG_DM=y # CONFIG_BLK is not set CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y diff --git a/configs/medcom-wide_defconfig b/configs/medcom-wide_defconfig index 479847d..fc19b5f 100644 --- a/configs/medcom-wide_defconfig +++ b/configs/medcom-wide_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/mx6ull_14x14_evk_defconfig b/configs/mx6ull_14x14_evk_defconfig index fdb3221..58de479 100644 --- a/configs/mx6ull_14x14_evk_defconfig +++ b/configs/mx6ull_14x14_evk_defconfig @@ -25,6 +25,7 @@ CONFIG_DM_GPIO=y CONFIG_DM_74X164=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y +# CONFIG_DM_MMC_OPS is not set CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX6=y CONFIG_DM_REGULATOR=y diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig index 977cf2d..6113162 100644 --- a/configs/nyan-big_defconfig +++ b/configs/nyan-big_defconfig @@ -44,6 +44,7 @@ CONFIG_CROS_EC_KEYB=y CONFIG_CMD_CROS_EC=y CONFIG_CROS_EC=y CONFIG_CROS_EC_SPI=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_PMIC=y diff --git a/configs/p2371-0000_defconfig b/configs/p2371-0000_defconfig index 295cca6..db2b6b1 100644 --- a/configs/p2371-0000_defconfig +++ b/configs/p2371-0000_defconfig @@ -32,6 +32,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/p2371-2180_defconfig b/configs/p2371-2180_defconfig index 2ee71ba..1c88af9 100644 --- a/configs/p2371-2180_defconfig +++ b/configs/p2371-2180_defconfig @@ -32,6 +32,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/p2571_defconfig b/configs/p2571_defconfig index fece81b..1375b52 100644 --- a/configs/p2571_defconfig +++ b/configs/p2571_defconfig @@ -32,6 +32,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/p2771-0000-000_defconfig b/configs/p2771-0000-000_defconfig index a48ba26..5748f94 100644 --- a/configs/p2771-0000-000_defconfig +++ b/configs/p2771-0000-000_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y # CONFIG_BLK is not set CONFIG_TEGRA186_BPMP_I2C=y +# CONFIG_DM_MMC_OPS is not set CONFIG_E1000=y CONFIG_RTL8169=y CONFIG_PCI_TEGRA=y diff --git a/configs/p2771-0000-500_defconfig b/configs/p2771-0000-500_defconfig index 0fbe58e..28160c2 100644 --- a/configs/p2771-0000-500_defconfig +++ b/configs/p2771-0000-500_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y # CONFIG_BLK is not set CONFIG_TEGRA186_BPMP_I2C=y +# CONFIG_DM_MMC_OPS is not set CONFIG_E1000=y CONFIG_RTL8169=y CONFIG_PCI_TEGRA=y diff --git a/configs/paz00_defconfig b/configs/paz00_defconfig index 436174e..815cf4c 100644 --- a/configs/paz00_defconfig +++ b/configs/paz00_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/plutux_defconfig b/configs/plutux_defconfig index ff77149..3885adb 100644 --- a/configs/plutux_defconfig +++ b/configs/plutux_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y diff --git a/configs/seaboard_defconfig b/configs/seaboard_defconfig index 685c9e4..326ec28 100644 --- a/configs/seaboard_defconfig +++ b/configs/seaboard_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/tec-ng_defconfig b/configs/tec-ng_defconfig index a4ae982..352ddb7 100644 --- a/configs/tec-ng_defconfig +++ b/configs/tec-ng_defconfig @@ -30,6 +30,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/tec_defconfig b/configs/tec_defconfig index 87dc247..24cd293 100644 --- a/configs/tec_defconfig +++ b/configs/tec_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/trimslice_defconfig b/configs/trimslice_defconfig index f6236ea..08aa0e0 100644 --- a/configs/trimslice_defconfig +++ b/configs/trimslice_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_RTL8169=y diff --git a/configs/venice2_defconfig b/configs/venice2_defconfig index c07d12d..b5debc4 100644 --- a/configs/venice2_defconfig +++ b/configs/venice2_defconfig @@ -34,6 +34,7 @@ CONFIG_SPL_DM=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +# CONFIG_DM_MMC_OPS is not set CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SYS_NS16550=y diff --git a/configs/ventana_defconfig b/configs/ventana_defconfig index e247f9a..a3b1b42 100644 --- a/configs/ventana_defconfig +++ b/configs/ventana_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y diff --git a/configs/whistler_defconfig b/configs/whistler_defconfig index 7c93980..b7f1b56 100644 --- a/configs/whistler_defconfig +++ b/configs/whistler_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_DM=y # CONFIG_BLK is not set +# CONFIG_DM_MMC_OPS is not set CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index ba9a723..24f4b28 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -19,6 +19,7 @@ config DM_MMC config DM_MMC_OPS bool "Support MMC controller operations using Driver Model" depends on DM_MMC + default y if DM_MMC help Driver model provides a means of supporting device operations. This option moves MMC operations under the control of driver model. The -- cgit v0.10.2 From 477dfe2ffc45720462ff0baca82076d704b785df Mon Sep 17 00:00:00 2001 From: Keerthy Date: Thu, 15 Sep 2016 17:04:06 +0530 Subject: power: regulator: Add support for gpio regulators Add support for gpio regulators. As of now this driver caters to gpio regulators with one gpio. Supports setting voltage values to gpio regulators and retrieving the values. Signed-off-by: Keerthy Reviewed-by: Simon Glass diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index c7e88c0..255eccf 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -68,6 +68,14 @@ config DM_REGULATOR_FIXED features for fixed value regulators. The driver implements get/set api for enable and get only for voltage value. +config DM_REGULATOR_GPIO + bool "Enable Driver Model for GPIO REGULATOR" + depends on DM_REGULATOR + ---help--- + This config enables implementation of driver-model regulator uclass + features for gpio regulators. The driver implements get/set for + voltage value. + config REGULATOR_RK808 bool "Enable driver for RK808 regulators" depends on DM_REGULATOR && PMIC_RK808 diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index ab461ec..e9ae22e 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_PFUZE100) += pfuze100.o obj-$(CONFIG_REGULATOR_PWM) += pwm_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o obj-$(CONFIG_REGULATOR_RK808) += rk808.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c new file mode 100644 index 0000000..0a60a9c --- /dev/null +++ b/drivers/power/regulator/gpio-regulator.c @@ -0,0 +1,137 @@ +/* + * (C) Copyright 2016 Texas Instruments Incorporated, + * Keerthy + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define GPIO_REGULATOR_MAX_STATES 2 + +DECLARE_GLOBAL_DATA_PTR; + +struct gpio_regulator_platdata { + struct gpio_desc gpio; /* GPIO for regulator voltage control */ + int states[GPIO_REGULATOR_MAX_STATES]; + int voltages[GPIO_REGULATOR_MAX_STATES]; +}; + +static int gpio_regulator_ofdata_to_platdata(struct udevice *dev) +{ + struct dm_regulator_uclass_platdata *uc_pdata; + struct gpio_regulator_platdata *dev_pdata; + struct gpio_desc *gpio; + const void *blob = gd->fdt_blob; + int node = dev->of_offset; + int ret, count, i, j; + u32 states_array[8]; + + dev_pdata = dev_get_platdata(dev); + uc_pdata = dev_get_uclass_platdata(dev); + if (!uc_pdata) + return -ENXIO; + + /* Set type to gpio */ + uc_pdata->type = REGULATOR_TYPE_GPIO; + + /* + * Get gpio regulator gpio desc + * Assuming one GPIO per regulator. + * Can be extended later to multiple GPIOs + * per gpio-regulator. As of now no instance with multiple + * gpios is presnt + */ + gpio = &dev_pdata->gpio; + ret = gpio_request_by_name(dev, "gpios", 0, gpio, GPIOD_IS_OUT); + if (ret) + debug("regulator gpio - not found! Error: %d", ret); + + count = fdtdec_get_int_array_count(blob, node, "states", + states_array, 8); + + if (!count) + return -EINVAL; + + for (i = 0, j = 0; i < count; i += 2) { + dev_pdata->voltages[j] = states_array[i]; + dev_pdata->states[j] = states_array[i + 1]; + j++; + } + + return 0; +} + +static int gpio_regulator_get_value(struct udevice *dev) +{ + struct dm_regulator_uclass_platdata *uc_pdata; + struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + int enable; + + if (!dev_pdata->gpio.dev) + return -ENOSYS; + + uc_pdata = dev_get_uclass_platdata(dev); + if (uc_pdata->min_uV > uc_pdata->max_uV) { + debug("Invalid constraints for: %s\n", uc_pdata->name); + return -EINVAL; + } + + enable = dm_gpio_get_value(&dev_pdata->gpio); + if (enable == dev_pdata->states[0]) + return dev_pdata->voltages[0]; + else + return dev_pdata->voltages[1]; +} + +static int gpio_regulator_set_value(struct udevice *dev, int uV) +{ + struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + int ret; + bool enable; + + if (!dev_pdata->gpio.dev) + return -ENOSYS; + + if (uV == dev_pdata->voltages[0]) + enable = dev_pdata->states[0]; + else if (uV == dev_pdata->voltages[1]) + enable = dev_pdata->states[1]; + else + return -EINVAL; + + ret = dm_gpio_set_value(&dev_pdata->gpio, enable); + if (ret) { + error("Can't set regulator : %s gpio to: %d\n", dev->name, + enable); + return ret; + } + + return 0; +} + +static const struct dm_regulator_ops gpio_regulator_ops = { + .get_value = gpio_regulator_get_value, + .set_value = gpio_regulator_set_value, +}; + +static const struct udevice_id gpio_regulator_ids[] = { + { .compatible = "regulator-gpio" }, + { }, +}; + +U_BOOT_DRIVER(gpio_regulator) = { + .name = "gpio regulator", + .id = UCLASS_REGULATOR, + .ops = &gpio_regulator_ops, + .of_match = gpio_regulator_ids, + .ofdata_to_platdata = gpio_regulator_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct gpio_regulator_platdata), +}; diff --git a/include/power/regulator.h b/include/power/regulator.h index 9bcd728..911956c 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -108,6 +108,7 @@ enum regulator_type { REGULATOR_TYPE_BUCK, REGULATOR_TYPE_DVS, REGULATOR_TYPE_FIXED, + REGULATOR_TYPE_GPIO, REGULATOR_TYPE_OTHER, }; -- cgit v0.10.2 From 34514b8b9ce287e2b8e90c77974889d8c53656fe Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:20:42 +0530 Subject: power: regulator: Add ctrl_reg and volt_reg fields for pmic The ctrl reg contains bit fields to enable and disable regulators, and volt_reg has the bit fields to configure the voltage values. The registers are frequently accessed hence make them part of dm_regulator_uclass_platdata structure. Signed-off-by: Keerthy Reviewed-by: Tom Rini Reviewed-by: Simon Glass diff --git a/include/power/regulator.h b/include/power/regulator.h index 911956c..f47ab67 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -153,6 +153,8 @@ enum regulator_flag { * TODO(sjg@chromium.org): Consider putting the above two into @flags * @flags: - flags value (see REGULATOR_FLAG_...) * @name** - fdt regulator name - should be taken from the device tree + * ctrl_reg: - Control register offset used to enable/disable regulator + * volt_reg: - register offset for writing voltage vsel values * * Note: * * - set automatically on device probe by the uclass's '.pre_probe' method. @@ -172,6 +174,8 @@ struct dm_regulator_uclass_platdata { bool boot_on; const char *name; int flags; + u8 ctrl_reg; + u8 volt_reg; }; /* Regulator device operations */ -- cgit v0.10.2 From 33621d247e771168ebaab2218d02e625371d144a Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:20:43 +0530 Subject: power: pmic: Palmas: Add the base pmic support Add support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write funtions to access pmic registers. Signed-off-by: Keerthy Reviewed-by: Simon Glass Reviewed-by: Tom Rini diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 13d293a..1a85566 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -143,3 +143,10 @@ config PMIC_TPS65090 FETs and a battery charger. This driver provides register access only, and you can enable the regulator/charger drivers separately if required. + +config PMIC_PALMAS + bool "Enable driver for Texas Instruments PALMAS PMIC" + depends on DM_PMIC + ---help--- + The PALMAS is a PMIC containing several LDOs, SMPS. + This driver binds the pmic children. diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 37d9eb5..6710673 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_PMIC_RK808) += rk808.o obj-$(CONFIG_PMIC_RN5T567) += rn5t567.o obj-$(CONFIG_PMIC_TPS65090) += tps65090.o obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o +obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c new file mode 100644 index 0000000..6c79a93 --- /dev/null +++ b/drivers/power/pmic/palmas.c @@ -0,0 +1,104 @@ +/* + * (C) Copyright 2016 Texas Instruments Incorporated, + * Keerthy + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const struct pmic_child_info pmic_children_info[] = { + { .prefix = "ldo", .driver = PALMAS_LDO_DRIVER }, + { .prefix = "smps", .driver = PALMAS_SMPS_DRIVER }, + { }, +}; + +static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff, + int len) +{ + if (dm_i2c_write(dev, reg, buff, len)) { + error("write error to device: %p register: %#x!", dev, reg); + return -EIO; + } + + return 0; +} + +static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{ + if (dm_i2c_read(dev, reg, buff, len)) { + error("read error from device: %p register: %#x!", dev, reg); + return -EIO; + } + + return 0; +} + +static int palmas_bind(struct udevice *dev) +{ + int pmic_node = -1, regulators_node; + const void *blob = gd->fdt_blob; + int children; + int node = dev->of_offset; + int subnode, len; + + fdt_for_each_subnode(blob, subnode, node) { + const char *name; + char *temp; + + name = fdt_get_name(blob, subnode, &len); + temp = strstr(name, "pmic"); + if (temp) { + pmic_node = subnode; + break; + } + } + + if (pmic_node <= 0) { + debug("%s: %s pmic subnode not found!", __func__, dev->name); + return -ENXIO; + } + + regulators_node = fdt_subnode_offset(blob, pmic_node, "regulators"); + + if (regulators_node <= 0) { + debug("%s: %s reg subnode not found!", __func__, dev->name); + return -ENXIO; + } + + children = pmic_bind_children(dev, regulators_node, pmic_children_info); + if (!children) + debug("%s: %s - no child found\n", __func__, dev->name); + + /* Always return success for this device */ + return 0; +} + +static struct dm_pmic_ops palmas_ops = { + .read = palmas_read, + .write = palmas_write, +}; + +static const struct udevice_id palmas_ids[] = { + { .compatible = "ti,tps659038", .data = TPS659038 }, + { .compatible = "ti,tps65917" , .data = TPS65917 }, + { } +}; + +U_BOOT_DRIVER(pmic_palmas) = { + .name = "palmas_pmic", + .id = UCLASS_PMIC, + .of_match = palmas_ids, + .bind = palmas_bind, + .ops = &palmas_ops, +}; diff --git a/include/power/palmas.h b/include/power/palmas.h new file mode 100644 index 0000000..bad5a35 --- /dev/null +++ b/include/power/palmas.h @@ -0,0 +1,25 @@ +#define PALMAS 0x0 +#define TPS659038 0x1 +#define TPS65917 0x2 + +/* I2C device address for pmic palmas */ +#define PALMAS_I2C_ADDR (0x12 >> 1) +#define PALMAS_LDO_NUM 11 +#define PALMAS_SMPS_NUM 8 + +/* Drivers name */ +#define PALMAS_LDO_DRIVER "palmas_ldo" +#define PALMAS_SMPS_DRIVER "palmas_smps" + +#define PALMAS_SMPS_VOLT_MASK 0x7F +#define PALMAS_SMPS_RANGE_MASK 0x80 +#define PALMAS_SMPS_VOLT_MAX_HEX 0x7F +#define PALMAS_SMPS_VOLT_MAX 3300000 +#define PALMAS_SMPS_MODE_MASK 0x3 +#define PALMAS_SMPS_STATUS_MASK 0x30 + +#define PALMAS_LDO_VOLT_MASK 0x3F +#define PALMAS_LDO_VOLT_MAX_HEX 0x3F +#define PALMAS_LDO_VOLT_MAX 3300000 +#define PALMAS_LDO_MODE_MASK 0x1 +#define PALMAS_LDO_STATUS_MASK 0x10 -- cgit v0.10.2 From 884d88bc8bf83d15f806350b2a1b86ff73de47f0 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:20:44 +0530 Subject: power: regulator: palmas: Add regulator support The driver provides regulator set/get voltage enable/disable functions for palmas family of PMICs. Signed-off-by: Keerthy Reviewed-by: Simon Glass Reviewed-by: Tom Rini diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 255eccf..461891c 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -133,3 +133,11 @@ config REGULATOR_TPS65090 regulators, one for each FET. The standard regulator interface is supported, but it is only possible to turn the regulators on or off. There is no voltage/current control. + +config DM_REGULATOR_PALMAS + bool "Enable driver for PALMAS PMIC regulators" + depends on PMIC_PALMAS + ---help--- + This enables implementation of driver-model regulator uclass + features for REGULATOR PALMAS and the family of PALMAS PMICs. + The driver implements get/set api for: value and enable. diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index e9ae22e..c979b51 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -16,3 +16,4 @@ obj-$(CONFIG_REGULATOR_RK808) += rk808.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o diff --git a/drivers/power/regulator/palmas_regulator.c b/drivers/power/regulator/palmas_regulator.c new file mode 100644 index 0000000..cce7cd2 --- /dev/null +++ b/drivers/power/regulator/palmas_regulator.c @@ -0,0 +1,453 @@ +/* + * (C) Copyright 2016 + * Texas Instruments Incorporated, + * + * Keerthy + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define REGULATOR_ON 0x1 +#define REGULATOR_OFF 0x0 + +#define SMPS_MODE_MASK 0x3 +#define SMPS_MODE_SHIFT 0x0 +#define LDO_MODE_MASK 0x1 +#define LDO_MODE_SHIFT 0x0 + +static const char palmas_smps_ctrl[][PALMAS_SMPS_NUM] = { + {0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38, 0x3c}, + {0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38}, + {0x20, 0x24, 0x2c, 0x30, 0x38}, +}; + +static const char palmas_smps_volt[][PALMAS_SMPS_NUM] = { + {0x23, 0x27, 0x2b, 0x2f, 0x33, 0x37, 0x3b, 0x3c}, + {0x23, 0x27, 0x2b, 0x2f, 0x33, 0x37, 0x3b}, + {0x23, 0x27, 0x2f, 0x33, 0x3B} +}; + +static const char palmas_ldo_ctrl[][PALMAS_LDO_NUM] = { + {0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x62, 0x64}, + {0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x62, 0x64}, + {0x50, 0x52, 0x54, 0x5e, 0x62} +}; + +static const char palmas_ldo_volt[][PALMAS_LDO_NUM] = { + {0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d, 0x5f, 0x61, 0x63, 0x65}, + {0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d, 0x5f, 0x61, 0x63, 0x65}, + {0x51, 0x53, 0x55, 0x5f, 0x63} +}; + +static int palmas_smps_enable(struct udevice *dev, int op, bool *enable) +{ + int ret; + unsigned int adr; + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + adr = uc_pdata->ctrl_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= PALMAS_SMPS_STATUS_MASK; + + if (ret) + *enable = true; + else + *enable = false; + + return 0; + } else if (op == PMIC_OP_SET) { + if (*enable) + ret |= PALMAS_SMPS_MODE_MASK; + else + ret &= ~(PALMAS_SMPS_MODE_MASK); + + ret = pmic_reg_write(dev->parent, adr, ret); + if (ret) + return ret; + } + + return 0; +} + +static int palmas_smps_volt2hex(int uV) +{ + if (uV > PALMAS_LDO_VOLT_MAX) + return -EINVAL; + + if (uV > 1650000) + return (uV - 1000000) / 20000 + 0x6; + + if (uV == 500000) + return 0x6; + else + return 0x6 + ((uV - 500000) / 10000); +} + +static int palmas_smps_hex2volt(int hex, bool range) +{ + unsigned int uV = 0; + + if (hex > PALMAS_SMPS_VOLT_MAX_HEX) + return -EINVAL; + + if (hex < 0x7) + uV = 500000; + else + uV = 500000 + (hex - 0x6) * 10000; + + if (range) + uV *= 2; + + return uV; +} + +static int palmas_smps_val(struct udevice *dev, int op, int *uV) +{ + unsigned int hex, adr; + int ret; + bool range; + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + + if (op == PMIC_OP_GET) + *uV = 0; + + adr = uc_pdata->volt_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + if (ret & PALMAS_SMPS_RANGE_MASK) + range = true; + else + range = false; + + ret &= PALMAS_SMPS_VOLT_MASK; + ret = palmas_smps_hex2volt(ret, range); + if (ret < 0) + return ret; + *uV = ret; + + return 0; + } + + hex = palmas_smps_volt2hex(*uV); + if (hex < 0) + return hex; + + ret &= ~PALMAS_SMPS_VOLT_MASK; + ret |= hex; + if (*uV > 1650000) + ret |= PALMAS_SMPS_RANGE_MASK; + + return pmic_reg_write(dev->parent, adr, ret); +} + +static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable) +{ + int ret; + unsigned int adr; + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + adr = uc_pdata->ctrl_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= PALMAS_LDO_STATUS_MASK; + + if (ret) + *enable = true; + else + *enable = false; + + return 0; + } else if (op == PMIC_OP_SET) { + if (*enable) + ret |= PALMAS_LDO_MODE_MASK; + else + ret &= ~(PALMAS_LDO_MODE_MASK); + + ret = pmic_reg_write(dev->parent, adr, ret); + if (ret) + return ret; + } + + return 0; +} + +static int palmas_ldo_volt2hex(int uV) +{ + if (uV > PALMAS_LDO_VOLT_MAX) + return -EINVAL; + + return (uV - 850000) / 50000; +} + +static int palmas_ldo_hex2volt(int hex) +{ + if (hex > PALMAS_LDO_VOLT_MAX_HEX) + return -EINVAL; + + if (!hex) + return 0; + + return (hex * 50000) + 850000; +} + +static int palmas_ldo_val(struct udevice *dev, int op, int *uV) +{ + unsigned int hex, adr; + int ret; + + struct dm_regulator_uclass_platdata *uc_pdata; + + if (op == PMIC_OP_GET) + *uV = 0; + + uc_pdata = dev_get_uclass_platdata(dev); + + adr = uc_pdata->volt_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= PALMAS_LDO_VOLT_MASK; + ret = palmas_ldo_hex2volt(ret); + if (ret < 0) + return ret; + *uV = ret; + return 0; + } + + hex = palmas_ldo_volt2hex(*uV); + if (hex < 0) + return hex; + + ret &= ~PALMAS_LDO_VOLT_MASK; + ret |= hex; + if (*uV > 1650000) + ret |= 0x80; + + return pmic_reg_write(dev->parent, adr, ret); +} + +static int palmas_ldo_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_platdata *uc_pdata; + struct udevice *parent; + + uc_pdata = dev_get_uclass_platdata(dev); + + parent = dev_get_parent(dev); + int type = dev_get_driver_data(parent); + + uc_pdata->type = REGULATOR_TYPE_LDO; + + if (dev->driver_data) { + u8 idx = dev->driver_data - 1; + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][idx]; + uc_pdata->volt_reg = palmas_ldo_volt[type][idx]; + } else { + /* check for ldoln and ldousb cases */ + if (!strcmp("ldoln", dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9]; + uc_pdata->volt_reg = palmas_ldo_volt[type][9]; + } else if (!strcmp("ldousb", dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10]; + uc_pdata->volt_reg = palmas_ldo_volt[type][10]; + } + } + + return 0; +} + +static int ldo_get_value(struct udevice *dev) +{ + int uV; + int ret; + + ret = palmas_ldo_val(dev, PMIC_OP_GET, &uV); + if (ret) + return ret; + + return uV; +} + +static int ldo_set_value(struct udevice *dev, int uV) +{ + return palmas_ldo_val(dev, PMIC_OP_SET, &uV); +} + +static bool ldo_get_enable(struct udevice *dev) +{ + bool enable = false; + int ret; + + ret = palmas_ldo_enable(dev, PMIC_OP_GET, &enable); + if (ret) + return ret; + + return enable; +} + +static int ldo_set_enable(struct udevice *dev, bool enable) +{ + return palmas_ldo_enable(dev, PMIC_OP_SET, &enable); +} + +static int palmas_smps_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_platdata *uc_pdata; + struct udevice *parent; + int idx; + + uc_pdata = dev_get_uclass_platdata(dev); + + parent = dev_get_parent(dev); + int type = dev_get_driver_data(parent); + + uc_pdata->type = REGULATOR_TYPE_BUCK; + + switch (type) { + case PALMAS: + case TPS659038: + switch (dev->driver_data) { + case 123: + case 12: + uc_pdata->ctrl_reg = palmas_smps_ctrl[type][0]; + uc_pdata->volt_reg = palmas_smps_volt[type][0]; + break; + case 3: + uc_pdata->ctrl_reg = palmas_smps_ctrl[type][1]; + uc_pdata->volt_reg = palmas_smps_volt[type][1]; + break; + case 45: + uc_pdata->ctrl_reg = palmas_smps_ctrl[type][2]; + uc_pdata->volt_reg = palmas_smps_volt[type][2]; + break; + case 6: + case 7: + case 8: + case 9: + case 10: + idx = dev->driver_data - 4; + uc_pdata->ctrl_reg = palmas_smps_ctrl[type][idx]; + uc_pdata->volt_reg = palmas_smps_volt[type][idx]; + break; + + default: + printf("Wrong ID for regulator\n"); + } + break; + + case TPS65917: + switch (dev->driver_data) { + case 1: + case 2: + case 3: + case 4: + case 5: + idx = dev->driver_data - 1; + uc_pdata->ctrl_reg = palmas_smps_ctrl[type][idx]; + uc_pdata->volt_reg = palmas_smps_volt[type][idx]; + break; + + default: + printf("Wrong ID for regulator\n"); + } + break; + + default: + printf("Invalid PMIC ID\n"); + } + + return 0; +} + +static int smps_get_value(struct udevice *dev) +{ + int uV; + int ret; + + ret = palmas_smps_val(dev, PMIC_OP_GET, &uV); + if (ret) + return ret; + + return uV; +} + +static int smps_set_value(struct udevice *dev, int uV) +{ + return palmas_smps_val(dev, PMIC_OP_SET, &uV); +} + +static bool smps_get_enable(struct udevice *dev) +{ + bool enable = false; + int ret; + + ret = palmas_smps_enable(dev, PMIC_OP_GET, &enable); + if (ret) + return ret; + + return enable; +} + +static int smps_set_enable(struct udevice *dev, bool enable) +{ + return palmas_smps_enable(dev, PMIC_OP_SET, &enable); +} + +static const struct dm_regulator_ops palmas_ldo_ops = { + .get_value = ldo_get_value, + .set_value = ldo_set_value, + .get_enable = ldo_get_enable, + .set_enable = ldo_set_enable, +}; + +U_BOOT_DRIVER(palmas_ldo) = { + .name = PALMAS_LDO_DRIVER, + .id = UCLASS_REGULATOR, + .ops = &palmas_ldo_ops, + .probe = palmas_ldo_probe, +}; + +static const struct dm_regulator_ops palmas_smps_ops = { + .get_value = smps_get_value, + .set_value = smps_set_value, + .get_enable = smps_get_enable, + .set_enable = smps_set_enable, +}; + +U_BOOT_DRIVER(palmas_smps) = { + .name = PALMAS_SMPS_DRIVER, + .id = UCLASS_REGULATOR, + .ops = &palmas_smps_ops, + .probe = palmas_smps_probe, +}; -- cgit v0.10.2 From 9017f1fa2a600c67e69046fe424751daf1a21a36 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:20:45 +0530 Subject: configs: dra7xx_evm_defconfig: Enable PALMAS options Enable palmas PMIC config options. Signed-off-by: Keerthy Reviewed-by: Tom Rini diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index 3ee3021..c883380 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -61,8 +61,11 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_DM_ETH=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_PALMAS=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_DM_REGULATOR_PALMAS=y CONFIG_DM_SERIAL=y CONFIG_SYS_NS16550=y CONFIG_DM_SPI=y -- cgit v0.10.2 From fc1636dff157598fdb1383d108df1d72f48254a8 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:20:46 +0530 Subject: configs: am57xx_evm_defconfig: Enable PALMAS options Enable palmas PMIC config options. Signed-off-by: Keerthy Reviewed-by: Tom Rini diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index 1764a05..d88aed2 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -46,6 +46,9 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_SPANSION=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_PALMAS=y +CONFIG_DM_REGULATOR_PALMAS=y CONFIG_DM_SERIAL=y CONFIG_SYS_NS16550=y CONFIG_DM_SPI=y -- cgit v0.10.2 From 08941bb99d0f668273cda13283e43e7ee227474d Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:20:47 +0530 Subject: configs: am57xx_evm_defconfig: Enable CMD_REG option Enable CMD_REG option. Signed-off-by: Keerthy Reviewed-by: Tom Rini diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index d88aed2..af54ebe 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y +CONFIG_CMD_REGULATOR=y CONFIG_CMD_EXT2=y CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y @@ -48,6 +49,7 @@ CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_DM_PMIC=y CONFIG_PMIC_PALMAS=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_PALMAS=y CONFIG_DM_SERIAL=y CONFIG_SYS_NS16550=y -- cgit v0.10.2 From ca1de0b5456e630522c0afe5a556e6851b8afe1e Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:34:02 +0530 Subject: power: pmic: lp873x: Add the base pmic support Add support to bind the regulators/child nodes with the pmic. Signed-off-by: Keerthy Reviewed-by: Simon Glass diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 1a85566..ce204b3 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -150,3 +150,10 @@ config PMIC_PALMAS ---help--- The PALMAS is a PMIC containing several LDOs, SMPS. This driver binds the pmic children. + +config PMIC_LP873X + bool "Enable driver for Texas Instruments LP873X PMIC" + depends on DM_PMIC + ---help--- + The LP873X is a PMIC containing couple of LDOs and couple of SMPS. + This driver binds the pmic children. diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 6710673..cd1c694 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_PMIC_RN5T567) += rn5t567.o obj-$(CONFIG_PMIC_TPS65090) += tps65090.o obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o +obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c new file mode 100644 index 0000000..307f96b --- /dev/null +++ b/drivers/power/pmic/lp873x.c @@ -0,0 +1,86 @@ +/* + * (C) Copyright 2016 Texas Instruments Incorporated, + * Keerthy + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const struct pmic_child_info pmic_children_info[] = { + { .prefix = "ldo", .driver = LP873X_LDO_DRIVER }, + { .prefix = "buck", .driver = LP873X_BUCK_DRIVER }, + { }, +}; + +static int lp873x_write(struct udevice *dev, uint reg, const uint8_t *buff, + int len) +{ + if (dm_i2c_write(dev, reg, buff, len)) { + error("write error to device: %p register: %#x!", dev, reg); + return -EIO; + } + + return 0; +} + +static int lp873x_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{ + if (dm_i2c_read(dev, reg, buff, len)) { + error("read error from device: %p register: %#x!", dev, reg); + return -EIO; + } + + return 0; +} + +static int lp873x_bind(struct udevice *dev) +{ + int regulators_node; + const void *blob = gd->fdt_blob; + int children; + int node = dev->of_offset; + + regulators_node = fdt_subnode_offset(blob, node, "regulators"); + + if (regulators_node <= 0) { + printf("%s: %s reg subnode not found!", __func__, dev->name); + return -ENXIO; + } + + children = pmic_bind_children(dev, regulators_node, pmic_children_info); + if (!children) + printf("%s: %s - no child found\n", __func__, dev->name); + + /* Always return success for this device */ + return 0; +} + +static struct dm_pmic_ops lp873x_ops = { + .read = lp873x_read, + .write = lp873x_write, +}; + +static const struct udevice_id lp873x_ids[] = { + { .compatible = "ti,lp8732", .data = LP8732 }, + { .compatible = "ti,lp8733" , .data = LP8733 }, + { } +}; + +U_BOOT_DRIVER(pmic_lp873x) = { + .name = "lp873x_pmic", + .id = UCLASS_PMIC, + .of_match = lp873x_ids, + .bind = lp873x_bind, + .ops = &lp873x_ops, +}; diff --git a/include/power/lp873x.h b/include/power/lp873x.h new file mode 100644 index 0000000..e0c0711 --- /dev/null +++ b/include/power/lp873x.h @@ -0,0 +1,19 @@ +#define LP8732 0x0 +#define LP8733 0x1 + +#define LP873X_LDO_NUM 2 +#define LP873X_BUCK_NUM 2 + +/* Drivers name */ +#define LP873X_LDO_DRIVER "lp873x_ldo" +#define LP873X_BUCK_DRIVER "lp873x_buck" + +#define LP873X_BUCK_VOLT_MASK 0xFF +#define LP873X_BUCK_VOLT_MAX_HEX 0xFF +#define LP873X_BUCK_VOLT_MAX 3360000 +#define LP873X_BUCK_MODE_MASK 0x1 + +#define LP873X_LDO_VOLT_MASK 0x1F +#define LP873X_LDO_VOLT_MAX_HEX 0x19 +#define LP873X_LDO_VOLT_MAX 3300000 +#define LP873X_LDO_MODE_MASK 0x1 -- cgit v0.10.2 From 99785de83e8198b5d5468453d49a8735b048983d Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 30 Sep 2016 09:34:03 +0530 Subject: power: regulator: lp873x: Add regulator support The driver provides regulator set/get voltage enable/disable functions for lp873x family of PMICs. Signed-off-by: Keerthy Reviewed-by: Simon Glass diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 461891c..f870e8b 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -141,3 +141,11 @@ config DM_REGULATOR_PALMAS This enables implementation of driver-model regulator uclass features for REGULATOR PALMAS and the family of PALMAS PMICs. The driver implements get/set api for: value and enable. + +config DM_REGULATOR_LP873X + bool "Enable driver for LP873X PMIC regulators" + depends on PMIC_LP873X + ---help--- + This enables implementation of driver-model regulator uclass + features for REGULATOR LP873X and the family of LP873X PMICs. + The driver implements get/set api for: value and enable. diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index c979b51..6002c88 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -17,3 +17,4 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o diff --git a/drivers/power/regulator/lp873x_regulator.c b/drivers/power/regulator/lp873x_regulator.c new file mode 100644 index 0000000..dcb19ff --- /dev/null +++ b/drivers/power/regulator/lp873x_regulator.c @@ -0,0 +1,357 @@ +/* + * (C) Copyright 2016 + * Texas Instruments Incorporated, + * + * Keerthy + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const char lp873x_buck_ctrl[LP873X_BUCK_NUM] = {0x2, 0x4}; +static const char lp873x_buck_volt[LP873X_BUCK_NUM] = {0x6, 0x7}; +static const char lp873x_ldo_ctrl[LP873X_LDO_NUM] = {0x8, 0x9}; +static const char lp873x_ldo_volt[LP873X_LDO_NUM] = {0xA, 0xB}; + +static int lp873x_buck_enable(struct udevice *dev, int op, bool *enable) +{ + int ret; + unsigned int adr; + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + adr = uc_pdata->ctrl_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= LP873X_BUCK_MODE_MASK; + + if (ret) + *enable = true; + else + *enable = false; + + return 0; + } else if (op == PMIC_OP_SET) { + if (*enable) + ret |= LP873X_BUCK_MODE_MASK; + else + ret &= ~(LP873X_BUCK_MODE_MASK); + ret = pmic_reg_write(dev->parent, adr, ret); + if (ret) + return ret; + } + + return 0; +} + +static int lp873x_buck_volt2hex(int uV) +{ + if (uV > LP873X_BUCK_VOLT_MAX) + return -EINVAL; + else if (uV > 1400000) + return (uV - 1420000) / 20000 + 0x9E; + else if (uV > 730000) + return (uV - 735000) / 5000 + 0x18; + else if (uV >= 700000) + return (uV - 700000) / 10000 + 0x1; + else + return -EINVAL; +} + +static int lp873x_buck_hex2volt(int hex) +{ + if (hex > LP873X_BUCK_VOLT_MAX_HEX) + return -EINVAL; + else if (hex > 0x9D) + return 1400000 + (hex - 0x9D) * 20000; + else if (hex > 0x17) + return 730000 + (hex - 0x17) * 5000; + else if (hex >= 0x14) + return 700000 + (hex - 0x14) * 10000; + else + return -EINVAL; +} + +static int lp873x_buck_val(struct udevice *dev, int op, int *uV) +{ + unsigned int hex, adr; + int ret; + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + + if (op == PMIC_OP_GET) + *uV = 0; + + adr = uc_pdata->volt_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= LP873X_BUCK_VOLT_MASK; + ret = lp873x_buck_hex2volt(ret); + if (ret < 0) + return ret; + *uV = ret; + + return 0; + } + + hex = lp873x_buck_volt2hex(*uV); + if (hex < 0) + return hex; + + ret &= 0x0; + ret |= hex; + + ret = pmic_reg_write(dev->parent, adr, ret); + + return ret; +} + +static int lp873x_ldo_enable(struct udevice *dev, int op, bool *enable) +{ + int ret; + unsigned int adr; + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + adr = uc_pdata->ctrl_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= LP873X_LDO_MODE_MASK; + + if (ret) + *enable = true; + else + *enable = false; + + return 0; + } else if (op == PMIC_OP_SET) { + if (*enable) + ret |= LP873X_LDO_MODE_MASK; + else + ret &= ~(LP873X_LDO_MODE_MASK); + + ret = pmic_reg_write(dev->parent, adr, ret); + if (ret) + return ret; + } + + return 0; +} + +static int lp873x_ldo_volt2hex(int uV) +{ + if (uV > LP873X_LDO_VOLT_MAX) + return -EINVAL; + + return (uV - 800000) / 100000; +} + +static int lp873x_ldo_hex2volt(int hex) +{ + if (hex > LP873X_LDO_VOLT_MAX_HEX) + return -EINVAL; + + if (!hex) + return 0; + + return (hex * 100000) + 800000; +} + +static int lp873x_ldo_val(struct udevice *dev, int op, int *uV) +{ + unsigned int hex, adr; + int ret; + + struct dm_regulator_uclass_platdata *uc_pdata; + + if (op == PMIC_OP_GET) + *uV = 0; + + uc_pdata = dev_get_uclass_platdata(dev); + + adr = uc_pdata->volt_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + ret &= LP873X_LDO_VOLT_MASK; + ret = lp873x_ldo_hex2volt(ret); + if (ret < 0) + return ret; + *uV = ret; + return 0; + } + + hex = lp873x_ldo_volt2hex(*uV); + if (hex < 0) + return hex; + + ret &= ~LP873X_LDO_VOLT_MASK; + ret |= hex; + if (*uV > 1650000) + ret |= 0x80; + ret = pmic_reg_write(dev->parent, adr, ret); + + return ret; +} + +static int lp873x_ldo_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_platdata *uc_pdata; + + uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata->type = REGULATOR_TYPE_LDO; + + int idx = dev->driver_data; + if (idx >= LP873X_LDO_NUM) { + printf("Wrong ID for regulator\n"); + return -1; + } + + uc_pdata->ctrl_reg = lp873x_ldo_ctrl[idx]; + uc_pdata->volt_reg = lp873x_ldo_volt[idx]; + + return 0; +} + +static int ldo_get_value(struct udevice *dev) +{ + int uV; + int ret; + + ret = lp873x_ldo_val(dev, PMIC_OP_GET, &uV); + if (ret) + return ret; + + return uV; +} + +static int ldo_set_value(struct udevice *dev, int uV) +{ + return lp873x_ldo_val(dev, PMIC_OP_SET, &uV); +} + +static bool ldo_get_enable(struct udevice *dev) +{ + bool enable = false; + int ret; + + ret = lp873x_ldo_enable(dev, PMIC_OP_GET, &enable); + if (ret) + return ret; + + return enable; +} + +static int ldo_set_enable(struct udevice *dev, bool enable) +{ + return lp873x_ldo_enable(dev, PMIC_OP_SET, &enable); +} + +static int lp873x_buck_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_platdata *uc_pdata; + int idx; + + uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata->type = REGULATOR_TYPE_BUCK; + + idx = dev->driver_data; + if (idx >= LP873X_BUCK_NUM) { + printf("Wrong ID for regulator\n"); + return -1; + } + + uc_pdata->ctrl_reg = lp873x_buck_ctrl[idx]; + uc_pdata->volt_reg = lp873x_buck_volt[idx]; + + return 0; +} + +static int buck_get_value(struct udevice *dev) +{ + int uV; + int ret; + + ret = lp873x_buck_val(dev, PMIC_OP_GET, &uV); + if (ret) + return ret; + + return uV; +} + +static int buck_set_value(struct udevice *dev, int uV) +{ + return lp873x_buck_val(dev, PMIC_OP_SET, &uV); +} + +static bool buck_get_enable(struct udevice *dev) +{ + bool enable = false; + int ret; + + + ret = lp873x_buck_enable(dev, PMIC_OP_GET, &enable); + if (ret) + return ret; + + return enable; +} + +static int buck_set_enable(struct udevice *dev, bool enable) +{ + return lp873x_buck_enable(dev, PMIC_OP_SET, &enable); +} + +static const struct dm_regulator_ops lp873x_ldo_ops = { + .get_value = ldo_get_value, + .set_value = ldo_set_value, + .get_enable = ldo_get_enable, + .set_enable = ldo_set_enable, +}; + +U_BOOT_DRIVER(lp873x_ldo) = { + .name = LP873X_LDO_DRIVER, + .id = UCLASS_REGULATOR, + .ops = &lp873x_ldo_ops, + .probe = lp873x_ldo_probe, +}; + +static const struct dm_regulator_ops lp873x_buck_ops = { + .get_value = buck_get_value, + .set_value = buck_set_value, + .get_enable = buck_get_enable, + .set_enable = buck_set_enable, +}; + +U_BOOT_DRIVER(lp873x_buck) = { + .name = LP873X_BUCK_DRIVER, + .id = UCLASS_REGULATOR, + .ops = &lp873x_buck_ops, + .probe = lp873x_buck_probe, +}; -- cgit v0.10.2 From 86167089b71c6b701194604e3dc66a67c6ea076a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 20:41:38 +0200 Subject: sandbox/fs: Free memory allocated by os_dirent_ls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Brüns Acked-by: Simon Glass diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c index 2703eed..cd10fd6 100644 --- a/fs/sandbox/sandboxfs.c +++ b/fs/sandbox/sandboxfs.c @@ -94,6 +94,7 @@ int sandbox_fs_ls(const char *dirname) printf("%s %10lu %s\n", os_dirent_get_typename(node->type), node->size, node->name); } + os_dirent_free(head); return 0; } diff --git a/include/os.h b/include/os.h index 1782e50..049b248 100644 --- a/include/os.h +++ b/include/os.h @@ -215,9 +215,18 @@ struct os_dirent_node { int os_dirent_ls(const char *dirname, struct os_dirent_node **headp); /** + * Free directory list + * + * This frees a linked list containing a directory listing. + * + * @param node Pointer to head of linked list + */ +void os_dirent_free(struct os_dirent_node *node); + +/** * Get the name of a directory entry type * - * @param type Type to cehck + * @param type Type to check * @return string containing the name of that type, or "???" if none/invalid */ const char *os_dirent_get_typename(enum os_dirent_t type); -- cgit v0.10.2 From ce2ec19c56d646656e64a4b8e0279820337f089e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 20:41:39 +0200 Subject: sandbox/fs: Make linking of nodes in os_dirent_ls more obvious MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, after reading/creating the second dirent, the second entry would be chained to the first entry and the first entry would be linked to head. Instead, immediately link the first entry to head. Signed-off-by: Stefan Brüns Acked-by: Simon Glass diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 2d63dd8..c71882a 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -363,8 +363,8 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) next->size = buf.st_size; if (node) node->next = next; - if (!head) - head = node; + else + head = next; } *headp = head; -- cgit v0.10.2 From f189899c2f9ae2266ea4814cf14f138cc47e319f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 20:41:40 +0200 Subject: sandbox/fs: Use correct size path name buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The readdir linux manpage explicitly states (quoting POSIX.1) that sizeof(d_name) is not correct for determining the required size, but to always use strlen. Grow the buffer if needed. Signed-off-by: Stefan Brüns Acked-by: Simon Glass diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index c71882a..16af3f5 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -320,14 +320,16 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) int ret; char *fname; int len; + int dirlen; *headp = NULL; dir = opendir(dirname); if (!dir) return -1; - /* Create a buffer for the maximum filename length */ - len = sizeof(entry.d_name) + strlen(dirname) + 2; + /* Create a buffer upfront, with typically sufficient size */ + dirlen = strlen(dirname) + 2; + len = dirlen + 256; fname = malloc(len); if (!fname) { ret = -ENOMEM; @@ -339,7 +341,12 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) if (ret || !result) break; next = malloc(sizeof(*node) + strlen(entry.d_name) + 1); - if (!next) { + if (dirlen + strlen(entry.d_name) > len) { + len = dirlen + strlen(entry.d_name); + fname = realloc(fname, len); + } + if (!next || !fname) { + free(next); os_dirent_free(head); ret = -ENOMEM; goto done; -- cgit v0.10.2 From bf635ed091dee333f4458eec617a4124b51322fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 20:41:42 +0200 Subject: sandbox/fs: Use readdir instead of deprecated readdir_r MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using readdir_r limits the maximum file name length and may even be unsafe, and is thus deprecated in since glibc 2.24. Signed-off-by: Stefan Brüns Acked-by: Simon Glass diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 16af3f5..47622a5 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -313,7 +313,7 @@ void os_dirent_free(struct os_dirent_node *node) int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) { - struct dirent entry, *result; + struct dirent *entry; struct os_dirent_node *head, *node, *next; struct stat buf; DIR *dir; @@ -337,12 +337,15 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) } for (node = head = NULL;; node = next) { - ret = readdir_r(dir, &entry, &result); - if (ret || !result) + errno = 0; + entry = readdir(dir); + if (!entry) { + ret = errno; break; - next = malloc(sizeof(*node) + strlen(entry.d_name) + 1); - if (dirlen + strlen(entry.d_name) > len) { - len = dirlen + strlen(entry.d_name); + } + next = malloc(sizeof(*node) + strlen(entry->d_name) + 1); + if (dirlen + strlen(entry->d_name) > len) { + len = dirlen + strlen(entry->d_name); fname = realloc(fname, len); } if (!next || !fname) { @@ -352,8 +355,8 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) goto done; } next->next = NULL; - strcpy(next->name, entry.d_name); - switch (entry.d_type) { + strcpy(next->name, entry->d_name); + switch (entry->d_type) { case DT_REG: next->type = OS_FILET_REG; break; -- cgit v0.10.2 From 80793db9091b40cf0078568bb5359be0e7f43e89 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 1 Oct 2016 14:42:33 -0600 Subject: sandbox: Use the address in readl/writel() functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At present these functions do not touch addr, which can raising warnings about unused variables. This fixes the following warnings: sandbox_spl defconfig drivers/core/regmap.c: In function ‘regmap_read’: drivers/core/regmap.c:125:12: warning: unused variable ‘ptr’ [-Wunused-variable] uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE); ^ drivers/core/regmap.c: In function ‘regmap_write’: drivers/core/regmap.c:134:12: warning: unused variable ‘ptr’ [-Wunused-variable] uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE); Signed-off-by: Simon Glass Fixes: 3bfb8cb4 (dm: regmap: Implement simple regmap_read & regmap_write) diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 6919632..a685635 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -40,12 +40,12 @@ static inline void unmap_sysmem(const void *vaddr) phys_addr_t map_to_sysmem(const void *ptr); /* Define nops for sandbox I/O access */ -#define readb(addr) 0 -#define readw(addr) 0 -#define readl(addr) 0 -#define writeb(v, addr) -#define writew(v, addr) -#define writel(v, addr) +#define readb(addr) ((void)addr, 0) +#define readw(addr) ((void)addr, 0) +#define readl(addr) ((void)addr, 0) +#define writeb(v, addr) ((void)addr) +#define writew(v, addr) ((void)addr) +#define writel(v, addr) ((void)addr) /* I/O access functions */ int inl(unsigned int addr); -- cgit v0.10.2 From 2f159402d9ab0dc642759d9eab3b002cde33064d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Tue, 4 Oct 2016 21:46:35 +0200 Subject: sandbox/fs: Set correct filetype for unknown filetype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "hostfs ls" command prefixes each directory entry with either DIR, LNK or " " if it is a directory, symlink resp. regular file, or "???" for any other or unknown type. The latter only works if the type is set correctly, as the entry defaults to OS_FILET_REG and e.g. socket files show up as regular files. Signed-off-by: Stefan Brüns Acked-by: Simon Glass diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 47622a5..35ea00c 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -366,6 +366,8 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) case DT_LNK: next->type = OS_FILET_LNK; break; + default: + next->type = OS_FILET_UNKNOWN; } next->size = 0; snprintf(fname, len, "%s/%s", dirname, next->name); -- cgit v0.10.2 From bfeba0173aa45c24bbdba45149716c83258d25f6 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 4 Oct 2016 17:08:08 -0700 Subject: cmd: cros_ec: Move crosec commands to cmd subdirectory Move crosec commands from drivers/misc/cros_ec.c to cmd/cros_ec.c Acked-by: Simon Glass Signed-off-by: Moritz Fischer Cc: Simon Glass Cc: Heiko Schocher Cc: Bin Meng Cc: Miao Yan Cc: Masahiro Yamada Cc: Stefan Roese Cc: Przemyslaw Marczak Cc: Maxime Ripard Cc: Nishanth Menon Cc: u-boot@lists.denx.de diff --git a/cmd/Kconfig b/cmd/Kconfig index 86554ea..e339d86 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -677,6 +677,19 @@ config CMD_TPM_TEST endmenu +menu "Firmware commands" +config CMD_CROS_EC + bool "Enable crosec command" + depends on CROS_EC + default y + help + Enable command-line access to the Chrome OS EC (Embedded + Controller). This provides the 'crosec' command which has + a number of sub-commands for performing EC tasks such as + updating its flash, accessing a small saved context area + and talking to the I2C bus behind the EC (if there is one). +endmenu + menu "Filesystem commands" config CMD_EXT2 bool "ext2 command support" diff --git a/cmd/Makefile b/cmd/Makefile index 81b98ee..9c9a9d1 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -128,6 +128,7 @@ obj-$(CONFIG_CMD_TRACE) += trace.o obj-$(CONFIG_HUSH_PARSER) += test.o obj-$(CONFIG_CMD_TPM) += tpm.o obj-$(CONFIG_CMD_TPM_TEST) += tpm_test.o +obj-$(CONFIG_CMD_CROS_EC) += cros_ec.o obj-$(CONFIG_CMD_TSI148) += tsi148.o obj-$(CONFIG_CMD_UBI) += ubi.o obj-$(CONFIG_CMD_UBIFS) += ubifs.o diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c new file mode 100644 index 0000000..abf11f0 --- /dev/null +++ b/cmd/cros_ec.c @@ -0,0 +1,365 @@ +/* + * Chromium OS cros_ec driver + * + * Copyright (c) 2016 The Chromium OS Authors. + * Copyright (c) 2016 National Instruments Corp + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +/* Note: depends on enum ec_current_image */ +static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"}; + +DECLARE_GLOBAL_DATA_PTR; + +/** + * Perform a flash read or write command + * + * @param dev CROS-EC device to read/write + * @param is_write 1 do to a write, 0 to do a read + * @param argc Number of arguments + * @param argv Arguments (2 is region, 3 is address) + * @return 0 for ok, 1 for a usage error or -ve for ec command error + * (negative EC_RES_...) + */ +static int do_read_write(struct cros_ec_dev *dev, int is_write, int argc, + char * const argv[]) +{ + uint32_t offset, size = -1U, region_size; + unsigned long addr; + char *endp; + int region; + int ret; + + region = cros_ec_decode_region(argc - 2, argv + 2); + if (region == -1) + return 1; + if (argc < 4) + return 1; + addr = simple_strtoul(argv[3], &endp, 16); + if (*argv[3] == 0 || *endp != 0) + return 1; + if (argc > 4) { + size = simple_strtoul(argv[4], &endp, 16); + if (*argv[4] == 0 || *endp != 0) + return 1; + } + + ret = cros_ec_flash_offset(dev, region, &offset, ®ion_size); + if (ret) { + debug("%s: Could not read region info\n", __func__); + return ret; + } + if (size == -1U) + size = region_size; + + ret = is_write ? + cros_ec_flash_write(dev, (uint8_t *)addr, offset, size) : + cros_ec_flash_read(dev, (uint8_t *)addr, offset, size); + if (ret) { + debug("%s: Could not %s region\n", __func__, + is_write ? "write" : "read"); + return ret; + } + + return 0; +} + +static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + struct cros_ec_dev *dev; + struct udevice *udev; + const char *cmd; + int ret = 0; + + if (argc < 2) + return CMD_RET_USAGE; + + cmd = argv[1]; + if (0 == strcmp("init", cmd)) { + /* Remove any existing device */ + ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev); + if (!ret) + device_remove(udev); + ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); + if (ret) { + printf("Could not init cros_ec device (err %d)\n", ret); + return 1; + } + return 0; + } + + ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); + if (ret) { + printf("Cannot get cros-ec device (err=%d)\n", ret); + return 1; + } + dev = dev_get_uclass_priv(udev); + if (0 == strcmp("id", cmd)) { + char id[MSG_BYTES]; + + if (cros_ec_read_id(dev, id, sizeof(id))) { + debug("%s: Could not read KBC ID\n", __func__); + return 1; + } + printf("%s\n", id); + } else if (0 == strcmp("info", cmd)) { + struct ec_response_mkbp_info info; + + if (cros_ec_info(dev, &info)) { + debug("%s: Could not read KBC info\n", __func__); + return 1; + } + printf("rows = %u\n", info.rows); + printf("cols = %u\n", info.cols); + printf("switches = %#x\n", info.switches); + } else if (0 == strcmp("curimage", cmd)) { + enum ec_current_image image; + + if (cros_ec_read_current_image(dev, &image)) { + debug("%s: Could not read KBC image\n", __func__); + return 1; + } + printf("%d\n", image); + } else if (0 == strcmp("hash", cmd)) { + struct ec_response_vboot_hash hash; + int i; + + if (cros_ec_read_hash(dev, &hash)) { + debug("%s: Could not read KBC hash\n", __func__); + return 1; + } + + if (hash.hash_type == EC_VBOOT_HASH_TYPE_SHA256) + printf("type: SHA-256\n"); + else + printf("type: %d\n", hash.hash_type); + + printf("offset: 0x%08x\n", hash.offset); + printf("size: 0x%08x\n", hash.size); + + printf("digest: "); + for (i = 0; i < hash.digest_size; i++) + printf("%02x", hash.hash_digest[i]); + printf("\n"); + } else if (0 == strcmp("reboot", cmd)) { + int region; + enum ec_reboot_cmd cmd; + + if (argc >= 3 && !strcmp(argv[2], "cold")) { + cmd = EC_REBOOT_COLD; + } else { + region = cros_ec_decode_region(argc - 2, argv + 2); + if (region == EC_FLASH_REGION_RO) + cmd = EC_REBOOT_JUMP_RO; + else if (region == EC_FLASH_REGION_RW) + cmd = EC_REBOOT_JUMP_RW; + else + return CMD_RET_USAGE; + } + + if (cros_ec_reboot(dev, cmd, 0)) { + debug("%s: Could not reboot KBC\n", __func__); + return 1; + } + } else if (0 == strcmp("events", cmd)) { + uint32_t events; + + if (cros_ec_get_host_events(dev, &events)) { + debug("%s: Could not read host events\n", __func__); + return 1; + } + printf("0x%08x\n", events); + } else if (0 == strcmp("clrevents", cmd)) { + uint32_t events = 0x7fffffff; + + if (argc >= 3) + events = simple_strtol(argv[2], NULL, 0); + + if (cros_ec_clear_host_events(dev, events)) { + debug("%s: Could not clear host events\n", __func__); + return 1; + } + } else if (0 == strcmp("read", cmd)) { + ret = do_read_write(dev, 0, argc, argv); + if (ret > 0) + return CMD_RET_USAGE; + } else if (0 == strcmp("write", cmd)) { + ret = do_read_write(dev, 1, argc, argv); + if (ret > 0) + return CMD_RET_USAGE; + } else if (0 == strcmp("erase", cmd)) { + int region = cros_ec_decode_region(argc - 2, argv + 2); + uint32_t offset, size; + + if (region == -1) + return CMD_RET_USAGE; + if (cros_ec_flash_offset(dev, region, &offset, &size)) { + debug("%s: Could not read region info\n", __func__); + ret = -1; + } else { + ret = cros_ec_flash_erase(dev, offset, size); + if (ret) { + debug("%s: Could not erase region\n", + __func__); + } + } + } else if (0 == strcmp("regioninfo", cmd)) { + int region = cros_ec_decode_region(argc - 2, argv + 2); + uint32_t offset, size; + + if (region == -1) + return CMD_RET_USAGE; + ret = cros_ec_flash_offset(dev, region, &offset, &size); + if (ret) { + debug("%s: Could not read region info\n", __func__); + } else { + printf("Region: %s\n", region == EC_FLASH_REGION_RO ? + "RO" : "RW"); + printf("Offset: %x\n", offset); + printf("Size: %x\n", size); + } + } else if (0 == strcmp("flashinfo", cmd)) { + struct ec_response_flash_info p; + + ret = cros_ec_read_flashinfo(dev, &p); + if (!ret) { + printf("Flash size: %u\n", p.flash_size); + printf("Write block size: %u\n", p.write_block_size); + printf("Erase block size: %u\n", p.erase_block_size); + } + } else if (0 == strcmp("vbnvcontext", cmd)) { + uint8_t block[EC_VBNV_BLOCK_SIZE]; + char buf[3]; + int i, len; + unsigned long result; + + if (argc <= 2) { + ret = cros_ec_read_vbnvcontext(dev, block); + if (!ret) { + printf("vbnv_block: "); + for (i = 0; i < EC_VBNV_BLOCK_SIZE; i++) + printf("%02x", block[i]); + putc('\n'); + } + } else { + /* + * TODO(clchiou): Move this to a utility function as + * cmd_spi might want to call it. + */ + memset(block, 0, EC_VBNV_BLOCK_SIZE); + len = strlen(argv[2]); + buf[2] = '\0'; + for (i = 0; i < EC_VBNV_BLOCK_SIZE; i++) { + if (i * 2 >= len) + break; + buf[0] = argv[2][i * 2]; + if (i * 2 + 1 >= len) + buf[1] = '0'; + else + buf[1] = argv[2][i * 2 + 1]; + strict_strtoul(buf, 16, &result); + block[i] = result; + } + ret = cros_ec_write_vbnvcontext(dev, block); + } + if (ret) { + debug("%s: Could not %s VbNvContext\n", __func__, + argc <= 2 ? "read" : "write"); + } + } else if (0 == strcmp("test", cmd)) { + int result = cros_ec_test(dev); + + if (result) + printf("Test failed with error %d\n", result); + else + puts("Test passed\n"); + } else if (0 == strcmp("version", cmd)) { + struct ec_response_get_version *p; + char *build_string; + + ret = cros_ec_read_version(dev, &p); + if (!ret) { + /* Print versions */ + printf("RO version: %1.*s\n", + (int)sizeof(p->version_string_ro), + p->version_string_ro); + printf("RW version: %1.*s\n", + (int)sizeof(p->version_string_rw), + p->version_string_rw); + printf("Firmware copy: %s\n", + (p->current_image < + ARRAY_SIZE(ec_current_image_name) ? + ec_current_image_name[p->current_image] : + "?")); + ret = cros_ec_read_build_info(dev, &build_string); + if (!ret) + printf("Build info: %s\n", build_string); + } + } else if (0 == strcmp("ldo", cmd)) { + uint8_t index, state; + char *endp; + + if (argc < 3) + return CMD_RET_USAGE; + index = simple_strtoul(argv[2], &endp, 10); + if (*argv[2] == 0 || *endp != 0) + return CMD_RET_USAGE; + if (argc > 3) { + state = simple_strtoul(argv[3], &endp, 10); + if (*argv[3] == 0 || *endp != 0) + return CMD_RET_USAGE; + ret = cros_ec_set_ldo(udev, index, state); + } else { + ret = cros_ec_get_ldo(udev, index, &state); + if (!ret) { + printf("LDO%d: %s\n", index, + state == EC_LDO_STATE_ON ? + "on" : "off"); + } + } + + if (ret) { + debug("%s: Could not access LDO%d\n", __func__, index); + return ret; + } + } else { + return CMD_RET_USAGE; + } + + if (ret < 0) { + printf("Error: CROS-EC command failed (error %d)\n", ret); + ret = 1; + } + + return ret; +} + +U_BOOT_CMD( + crosec, 6, 1, do_cros_ec, + "CROS-EC utility command", + "init Re-init CROS-EC (done on startup automatically)\n" + "crosec id Read CROS-EC ID\n" + "crosec info Read CROS-EC info\n" + "crosec curimage Read CROS-EC current image\n" + "crosec hash Read CROS-EC hash\n" + "crosec reboot [rw | ro | cold] Reboot CROS-EC\n" + "crosec events Read CROS-EC host events\n" + "crosec clrevents [mask] Clear CROS-EC host events\n" + "crosec regioninfo Read image info\n" + "crosec flashinfo Read flash info\n" + "crosec erase Erase EC image\n" + "crosec read [] Read EC image\n" + "crosec write [] Write EC image\n" + "crosec vbnvcontext [hexstring] Read [write] VbNvContext from EC\n" + "crosec ldo [] Switch/Read LDO state\n" + "crosec test run tests on cros_ec\n" + "crosec version Read CROS-EC version" +); diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 1e5bcb0..8073730 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -43,9 +43,6 @@ enum { DECLARE_GLOBAL_DATA_PTR; -/* Note: depends on enum ec_current_image */ -static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"}; - void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len) { #ifdef DEBUG @@ -1164,354 +1161,6 @@ int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *in, return 0; } -#ifdef CONFIG_CMD_CROS_EC - -/** - * Perform a flash read or write command - * - * @param dev CROS-EC device to read/write - * @param is_write 1 do to a write, 0 to do a read - * @param argc Number of arguments - * @param argv Arguments (2 is region, 3 is address) - * @return 0 for ok, 1 for a usage error or -ve for ec command error - * (negative EC_RES_...) - */ -static int do_read_write(struct cros_ec_dev *dev, int is_write, int argc, - char * const argv[]) -{ - uint32_t offset, size = -1U, region_size; - unsigned long addr; - char *endp; - int region; - int ret; - - region = cros_ec_decode_region(argc - 2, argv + 2); - if (region == -1) - return 1; - if (argc < 4) - return 1; - addr = simple_strtoul(argv[3], &endp, 16); - if (*argv[3] == 0 || *endp != 0) - return 1; - if (argc > 4) { - size = simple_strtoul(argv[4], &endp, 16); - if (*argv[4] == 0 || *endp != 0) - return 1; - } - - ret = cros_ec_flash_offset(dev, region, &offset, ®ion_size); - if (ret) { - debug("%s: Could not read region info\n", __func__); - return ret; - } - if (size == -1U) - size = region_size; - - ret = is_write ? - cros_ec_flash_write(dev, (uint8_t *)addr, offset, size) : - cros_ec_flash_read(dev, (uint8_t *)addr, offset, size); - if (ret) { - debug("%s: Could not %s region\n", __func__, - is_write ? "write" : "read"); - return ret; - } - - return 0; -} - -static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - struct cros_ec_dev *dev; - struct udevice *udev; - const char *cmd; - int ret = 0; - - if (argc < 2) - return CMD_RET_USAGE; - - cmd = argv[1]; - if (0 == strcmp("init", cmd)) { - /* Remove any existing device */ - ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev); - if (!ret) - device_remove(udev); - ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); - if (ret) { - printf("Could not init cros_ec device (err %d)\n", ret); - return 1; - } - return 0; - } - - ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); - if (ret) { - printf("Cannot get cros-ec device (err=%d)\n", ret); - return 1; - } - dev = dev_get_uclass_priv(udev); - if (0 == strcmp("id", cmd)) { - char id[MSG_BYTES]; - - if (cros_ec_read_id(dev, id, sizeof(id))) { - debug("%s: Could not read KBC ID\n", __func__); - return 1; - } - printf("%s\n", id); - } else if (0 == strcmp("info", cmd)) { - struct ec_response_mkbp_info info; - - if (cros_ec_info(dev, &info)) { - debug("%s: Could not read KBC info\n", __func__); - return 1; - } - printf("rows = %u\n", info.rows); - printf("cols = %u\n", info.cols); - printf("switches = %#x\n", info.switches); - } else if (0 == strcmp("curimage", cmd)) { - enum ec_current_image image; - - if (cros_ec_read_current_image(dev, &image)) { - debug("%s: Could not read KBC image\n", __func__); - return 1; - } - printf("%d\n", image); - } else if (0 == strcmp("hash", cmd)) { - struct ec_response_vboot_hash hash; - int i; - - if (cros_ec_read_hash(dev, &hash)) { - debug("%s: Could not read KBC hash\n", __func__); - return 1; - } - - if (hash.hash_type == EC_VBOOT_HASH_TYPE_SHA256) - printf("type: SHA-256\n"); - else - printf("type: %d\n", hash.hash_type); - - printf("offset: 0x%08x\n", hash.offset); - printf("size: 0x%08x\n", hash.size); - - printf("digest: "); - for (i = 0; i < hash.digest_size; i++) - printf("%02x", hash.hash_digest[i]); - printf("\n"); - } else if (0 == strcmp("reboot", cmd)) { - int region; - enum ec_reboot_cmd cmd; - - if (argc >= 3 && !strcmp(argv[2], "cold")) - cmd = EC_REBOOT_COLD; - else { - region = cros_ec_decode_region(argc - 2, argv + 2); - if (region == EC_FLASH_REGION_RO) - cmd = EC_REBOOT_JUMP_RO; - else if (region == EC_FLASH_REGION_RW) - cmd = EC_REBOOT_JUMP_RW; - else - return CMD_RET_USAGE; - } - - if (cros_ec_reboot(dev, cmd, 0)) { - debug("%s: Could not reboot KBC\n", __func__); - return 1; - } - } else if (0 == strcmp("events", cmd)) { - uint32_t events; - - if (cros_ec_get_host_events(dev, &events)) { - debug("%s: Could not read host events\n", __func__); - return 1; - } - printf("0x%08x\n", events); - } else if (0 == strcmp("clrevents", cmd)) { - uint32_t events = 0x7fffffff; - - if (argc >= 3) - events = simple_strtol(argv[2], NULL, 0); - - if (cros_ec_clear_host_events(dev, events)) { - debug("%s: Could not clear host events\n", __func__); - return 1; - } - } else if (0 == strcmp("read", cmd)) { - ret = do_read_write(dev, 0, argc, argv); - if (ret > 0) - return CMD_RET_USAGE; - } else if (0 == strcmp("write", cmd)) { - ret = do_read_write(dev, 1, argc, argv); - if (ret > 0) - return CMD_RET_USAGE; - } else if (0 == strcmp("erase", cmd)) { - int region = cros_ec_decode_region(argc - 2, argv + 2); - uint32_t offset, size; - - if (region == -1) - return CMD_RET_USAGE; - if (cros_ec_flash_offset(dev, region, &offset, &size)) { - debug("%s: Could not read region info\n", __func__); - ret = -1; - } else { - ret = cros_ec_flash_erase(dev, offset, size); - if (ret) { - debug("%s: Could not erase region\n", - __func__); - } - } - } else if (0 == strcmp("regioninfo", cmd)) { - int region = cros_ec_decode_region(argc - 2, argv + 2); - uint32_t offset, size; - - if (region == -1) - return CMD_RET_USAGE; - ret = cros_ec_flash_offset(dev, region, &offset, &size); - if (ret) { - debug("%s: Could not read region info\n", __func__); - } else { - printf("Region: %s\n", region == EC_FLASH_REGION_RO ? - "RO" : "RW"); - printf("Offset: %x\n", offset); - printf("Size: %x\n", size); - } - } else if (0 == strcmp("flashinfo", cmd)) { - struct ec_response_flash_info p; - - ret = cros_ec_read_flashinfo(dev, &p); - if (!ret) { - printf("Flash size: %u\n", p.flash_size); - printf("Write block size: %u\n", p.write_block_size); - printf("Erase block size: %u\n", p.erase_block_size); - } - } else if (0 == strcmp("vbnvcontext", cmd)) { - uint8_t block[EC_VBNV_BLOCK_SIZE]; - char buf[3]; - int i, len; - unsigned long result; - - if (argc <= 2) { - ret = cros_ec_read_vbnvcontext(dev, block); - if (!ret) { - printf("vbnv_block: "); - for (i = 0; i < EC_VBNV_BLOCK_SIZE; i++) - printf("%02x", block[i]); - putc('\n'); - } - } else { - /* - * TODO(clchiou): Move this to a utility function as - * cmd_spi might want to call it. - */ - memset(block, 0, EC_VBNV_BLOCK_SIZE); - len = strlen(argv[2]); - buf[2] = '\0'; - for (i = 0; i < EC_VBNV_BLOCK_SIZE; i++) { - if (i * 2 >= len) - break; - buf[0] = argv[2][i * 2]; - if (i * 2 + 1 >= len) - buf[1] = '0'; - else - buf[1] = argv[2][i * 2 + 1]; - strict_strtoul(buf, 16, &result); - block[i] = result; - } - ret = cros_ec_write_vbnvcontext(dev, block); - } - if (ret) { - debug("%s: Could not %s VbNvContext\n", __func__, - argc <= 2 ? "read" : "write"); - } - } else if (0 == strcmp("test", cmd)) { - int result = cros_ec_test(dev); - - if (result) - printf("Test failed with error %d\n", result); - else - puts("Test passed\n"); - } else if (0 == strcmp("version", cmd)) { - struct ec_response_get_version *p; - char *build_string; - - ret = cros_ec_read_version(dev, &p); - if (!ret) { - /* Print versions */ - printf("RO version: %1.*s\n", - (int)sizeof(p->version_string_ro), - p->version_string_ro); - printf("RW version: %1.*s\n", - (int)sizeof(p->version_string_rw), - p->version_string_rw); - printf("Firmware copy: %s\n", - (p->current_image < - ARRAY_SIZE(ec_current_image_name) ? - ec_current_image_name[p->current_image] : - "?")); - ret = cros_ec_read_build_info(dev, &build_string); - if (!ret) - printf("Build info: %s\n", build_string); - } - } else if (0 == strcmp("ldo", cmd)) { - uint8_t index, state; - char *endp; - - if (argc < 3) - return CMD_RET_USAGE; - index = simple_strtoul(argv[2], &endp, 10); - if (*argv[2] == 0 || *endp != 0) - return CMD_RET_USAGE; - if (argc > 3) { - state = simple_strtoul(argv[3], &endp, 10); - if (*argv[3] == 0 || *endp != 0) - return CMD_RET_USAGE; - ret = cros_ec_set_ldo(udev, index, state); - } else { - ret = cros_ec_get_ldo(udev, index, &state); - if (!ret) { - printf("LDO%d: %s\n", index, - state == EC_LDO_STATE_ON ? - "on" : "off"); - } - } - - if (ret) { - debug("%s: Could not access LDO%d\n", __func__, index); - return ret; - } - } else { - return CMD_RET_USAGE; - } - - if (ret < 0) { - printf("Error: CROS-EC command failed (error %d)\n", ret); - ret = 1; - } - - return ret; -} - -U_BOOT_CMD( - crosec, 6, 1, do_cros_ec, - "CROS-EC utility command", - "init Re-init CROS-EC (done on startup automatically)\n" - "crosec id Read CROS-EC ID\n" - "crosec info Read CROS-EC info\n" - "crosec curimage Read CROS-EC current image\n" - "crosec hash Read CROS-EC hash\n" - "crosec reboot [rw | ro | cold] Reboot CROS-EC\n" - "crosec events Read CROS-EC host events\n" - "crosec clrevents [mask] Clear CROS-EC host events\n" - "crosec regioninfo Read image info\n" - "crosec flashinfo Read flash info\n" - "crosec erase Erase EC image\n" - "crosec read [] Read EC image\n" - "crosec write [] Write EC image\n" - "crosec vbnvcontext [hexstring] Read [write] VbNvContext from EC\n" - "crosec ldo [] Switch/Read LDO state\n" - "crosec test run tests on cros_ec\n" - "crosec version Read CROS-EC version" -); -#endif - UCLASS_DRIVER(cros_ec) = { .id = UCLASS_CROS_EC, .name = "cros_ec", diff --git a/include/cros_ec.h b/include/cros_ec.h index 30b1908..ec7517c 100644 --- a/include/cros_ec.h +++ b/include/cros_ec.h @@ -281,6 +281,17 @@ int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset, uint32_t size); /** + * Read back flash parameters + * + * This function reads back parameters of the flash as reported by the EC + * + * @param dev Pointer to device + * @param info Pointer to output flash info struct + */ +int cros_ec_read_flashinfo(struct cros_ec_dev *dev, + struct ec_response_flash_info *info); + +/** * Write data to the flash * * Write an arbitrary amount of data to the EC flash, by repeatedly writing -- cgit v0.10.2