From patchwork Mon Jul 6 18:54:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 491769 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D989E1402D4 for ; Tue, 7 Jul 2015 04:56:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=Jauoskd7; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2F30C4B7FD; Mon, 6 Jul 2015 20:55:57 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mKBcU9gDxX5I; Mon, 6 Jul 2015 20:55:57 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 06A914B7E3; Mon, 6 Jul 2015 20:55:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 410494B7AC for ; Mon, 6 Jul 2015 20:55:24 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nGPF0gvfUTdl for ; Mon, 6 Jul 2015 20:55:24 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ig0-f178.google.com (mail-ig0-f178.google.com [209.85.213.178]) by theia.denx.de (Postfix) with ESMTPS id 38CDD4B786 for ; Mon, 6 Jul 2015 20:55:18 +0200 (CEST) Received: by igrv9 with SMTP id v9so122883253igr.1 for ; Mon, 06 Jul 2015 11:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5Z4l0NdO0e0VGqd8fF0dHVHUH1fz4PlU9b+iyS+Aq+0=; b=Jauoskd7x4EISXkRzpkwF/dkPmMI6XJd/3BDu2Gcmi0y4dqDOZLdolYl9vD0+5+/8C 8y2DNnv72UgsOiC990cGHpMNOQUMR2brIoj0O4VYj++F8uxeMV3ychiQ+I2XnUHsFLSm CuDF9eDAEwJmFEqRJ8FgaiboN9dppEHu4VyWiUmtgcmK4JwTZsK0ayq5OP3jlv5kF/P4 Tsw5WXD4Fiu28OMdpaQYnMHATUlGMlLak5NOkTk9H3nXyY/6497c3fCpmB+MAqswV+um OiMl7NSDsKUb6UKik2kpJ+M9POaRZPOeq8/BOQVSiivJbevkf9RRz8QjrWt3TfmpdnvF dfTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5Z4l0NdO0e0VGqd8fF0dHVHUH1fz4PlU9b+iyS+Aq+0=; b=jZF2QTZTeysdHcHH0zNnZaPdBFt2qWyMBt7ecGjKrBFBt2K8gZp3vgtwAo7Z5X2Irp /0jkapMry3eamfZLWxVslRK48Yt9S8ZkXPxjVmKa32qotD3Y++4cAbkr9PfEILJ+iRWc ZQmApttwgxPfw3kky8mABg73tuYqBBfcqqO2R+GKz+ItXHiQAvm1aCKeyzrAXGGUbh7F R7S+kZEswRbWhE0dP9ibZ/wBKTj//gtfvBFwnehZEZhmXjsQVQMOdrxImk2mlyT4iKXb UTOeBl+6swBjO3er1pXAwWkejqErRyCRZSlC/FBId2vF68fWNuo1oxD2nWPoqRbJl9EJ ePDg== X-Gm-Message-State: ALoCoQlh2vyHBrmTyyWXhidVaNP7T+kHYm6311z+OW/IAqsrdwdcCM6BFq0fECiLWMwx6EMUUCNT X-Received: by 10.50.43.197 with SMTP id y5mr15717407igl.27.1436208917870; Mon, 06 Jul 2015 11:55:17 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by mx.google.com with ESMTPSA id g18sm12997647iod.5.2015.07.06.11.55.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 11:55:17 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 1A3922211B4; Mon, 6 Jul 2015 12:55:14 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 6 Jul 2015 12:54:27 -0600 Message-Id: <1436208879-8431-7-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef In-Reply-To: <1436208879-8431-1-git-send-email-sjg@chromium.org> References: <1436208879-8431-1-git-send-email-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 06/18] dm: reset: Allow reset_walk() to return X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a new reset_walk_halt() function to cause a reset and then halt on failure. The reset_walk() function returns an error code. This is needed for testing since otherwise U-Boot will halt in the middle of a test. Signed-off-by: Simon Glass --- drivers/misc/reset-uclass.c | 31 +++++++++++++++++++++++++------ include/reset.h | 11 ++++++++++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/misc/reset-uclass.c b/drivers/misc/reset-uclass.c index ba27757..fdb5c6f 100644 --- a/drivers/misc/reset-uclass.c +++ b/drivers/misc/reset-uclass.c @@ -25,23 +25,34 @@ int reset_request(struct udevice *dev, enum reset_t type) return ops->request(dev, type); } -void reset_walk(enum reset_t type) +int reset_walk(enum reset_t type) { struct udevice *dev; - int ret = 0; + int ret = -ENOSYS; while (ret != -EINPROGRESS && type < RESET_COUNT) { for (uclass_first_device(UCLASS_RESET, &dev); - dev; - uclass_next_device(&dev)) { + dev; + uclass_next_device(&dev)) { ret = reset_request(dev, type); if (ret == -EINPROGRESS) break; } + type++; } + return ret; +} + +void reset_walk_halt(enum reset_t type) +{ + int ret; + + ret = reset_walk(type); + /* Wait for the reset to take effect */ - mdelay(100); + if (ret == -EINPROGRESS) + mdelay(100); /* Still no reset? Give up */ printf("Reset not supported on this platform\n"); @@ -53,7 +64,15 @@ void reset_walk(enum reset_t type) */ void reset_cpu(ulong addr) { - reset_walk(RESET_WARM); + reset_walk_halt(RESET_WARM); +} + + +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + reset_walk_halt(RESET_WARM); + + return 0; } UCLASS_DRIVER(reset) = { diff --git a/include/reset.h b/include/reset.h index d29e108..383761e 100644 --- a/include/reset.h +++ b/include/reset.h @@ -51,8 +51,17 @@ int reset_request(struct udevice *dev, enum reset_t type); * If this function fails to reset, it will display a message and halt * * @type: Reset type to request + * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available */ -void reset_walk(enum reset_t type); +int reset_walk(enum reset_t type); + +/** + * reset_walk_halt() - try to reset, otherwise halt + * + * This calls reset_walk(). If it returns, indicating that reset is not + * supported, it prints a message and halts. + */ +void reset_walk_halt(enum reset_t type); /** * reset_cpu() - calls reset_walk(RESET_WARM)