From patchwork Thu Oct 31 06:27:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 3119281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B51EB9F2B7 for ; Thu, 31 Oct 2013 07:05:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41F43203DF for ; Thu, 31 Oct 2013 07:05:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEE7620177 for ; Thu, 31 Oct 2013 07:05:02 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vblof-00062S-Ia; Thu, 31 Oct 2013 06:33:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vblnm-0008NN-5M; Thu, 31 Oct 2013 06:32:18 +0000 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vblm9-0008Ch-8W for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2013 06:30:43 +0000 Received: by mail-ee0-f53.google.com with SMTP id e51so1112710eek.40 for ; Wed, 30 Oct 2013 23:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:user-agent:date:from:to:cc:subject:references :content-disposition; bh=kcEtGOirGtwZFjXEZDKY6oEprQ1jb65mUi7wYhUvXXc=; b=dWdy/21TllJUGyVKbRjLKOfMRtmTpJVuVGrr8cTLorCzcd3STO9UBb3OutDw/3vliq /TctrIG+jNL2X1svFneUty5+FqIxa0RJ4t+Q/vEW6GVK52A7GZKjYaSXgsfuqH1JoZ90 PUJdOq01GLth2VZDMtJ6T7HoewJnW3btIHyjJ4nqyDK3o4GuuAAeXfq5k4Tyl9QZkr7T RHkcBmqHQxVjvc3OAjdRNEpT+nVuA4Rk+gh31hp0IheVnmz85jVWRjILsc2UMtj0yz+A w+y7TucOqiZ7f6s8XviYgHVXBglazLbJsgJH1/ePRvLVRIwiKCLxXdy5e5pYWs5zLZ80 MXHw== X-Received: by 10.14.94.199 with SMTP id n47mr1376508eef.81.1383201015343; Wed, 30 Oct 2013 23:30:15 -0700 (PDT) Received: from shock.dandreoli.com (j115181.upc-j.chello.nl. [24.132.115.181]) by mx.google.com with ESMTPSA id w6sm4403491eeo.12.2013.10.30.23.30.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Oct 2013 23:30:14 -0700 (PDT) Received: by shock.dandreoli.com (Postfix, from userid 1000) id 16143340291; Thu, 31 Oct 2013 07:29:59 +0100 (CET) Message-Id: <20131031062959.813485972@linux.com> User-Agent: quilt/0.60-1 Date: Thu, 31 Oct 2013 07:27:14 +0100 From: Domenico Andreoli To: linux-arch@vger.kernel.org Subject: [PATCH 06/11] ARM: vexpress: use the common machine reset handling References: <20131031062708.520968323@linux.com> Content-Disposition: inline; filename=arm-machine-reset-vexpress-hooks.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131031_023037_502901_A115B3DC X-CRM114-Status: GOOD ( 16.38 ) X-Spam-Score: -1.9 (-) Cc: Russell King , Arnd Bergmann , Ralf Baechle , Domenico Andreoli , linux-mips@lvger.kernel.org, Olof Johansson , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Domenico Andreoli Proof of concept: vexpress as provider of reset hooks. Platform hooks implementation. Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Domenico Andreoli --- drivers/power/reset/Kconfig | 1 + drivers/power/reset/vexpress-poweroff.c | 54 +++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 16 deletions(-) Index: b/drivers/power/reset/Kconfig =================================================================== --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -41,6 +41,7 @@ config POWER_RESET_VEXPRESS bool "ARM Versatile Express power-off and reset driver" depends on ARM || ARM64 depends on POWER_RESET && VEXPRESS_CONFIG + select MACHINE_RESET help Power off and reset support for the ARM Ltd. Versatile Express boards. Index: b/drivers/power/reset/vexpress-poweroff.c =================================================================== --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c @@ -19,7 +19,8 @@ #include #include -#include +static enum reset_func vexpress_get_func(struct platform_device *pdev); +static int vexpress_set_hook(struct platform_device *pdev); static void vexpress_reset_do(struct device *dev, const char *what) { @@ -40,34 +41,40 @@ static void vexpress_reset_do(struct dev dev_emerg(dev, "Unable to %s (%d)\n", what, err); } -static struct device *vexpress_power_off_device; - -static void vexpress_power_off(void) +static void vexpress_power_off(void *dev) { - vexpress_reset_do(vexpress_power_off_device, "power off"); + vexpress_reset_do(dev, "power off"); } -static struct device *vexpress_restart_device; - -static void vexpress_restart(enum reboot_mode reboot_mode, const char *cmd) +static void vexpress_restart(void *dev, enum reboot_mode reboot_mode, + const char *cmd) { - vexpress_reset_do(vexpress_restart_device, "restart"); + vexpress_reset_do(dev, "restart"); } static ssize_t vexpress_reset_active_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", vexpress_restart_device == dev); + struct platform_device *pdev; + enum reset_func func; + + pdev = container_of(dev, struct platform_device, dev); + func = vexpress_get_func(pdev); + + return sprintf(buf, "%d\n", isset_machine_reset(func, dev)); } static ssize_t vexpress_reset_active_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { long value; + struct platform_device *pdev; int err = kstrtol(buf, 0, &value); + pdev = container_of(dev, struct platform_device, dev); + if (!err && value) - vexpress_restart_device = dev; + vexpress_set_hook(pdev); return err ? err : count; } @@ -90,7 +97,7 @@ static struct of_device_id vexpress_rese {} }; -static int vexpress_reset_probe(struct platform_device *pdev) +static enum reset_func vexpress_get_func(struct platform_device *pdev) { enum reset_func func; const struct of_device_id *match = @@ -101,23 +108,38 @@ static int vexpress_reset_probe(struct p else func = pdev->id_entry->driver_data; + return func; +} + +static int vexpress_set_hook(struct platform_device *pdev) +{ + enum reset_func func; + struct reset_hook hook; + + func = vexpress_get_func(pdev); + reset_hook_init(&hook); + switch (func) { case RESET_POWER_OFF: - vexpress_power_off_device = &pdev->dev; - pm_power_off = vexpress_power_off; + hook.power_off = vexpress_power_off; break; case RESET_RESTART: - vexpress_restart_device = &pdev->dev; - arm_pm_restart = vexpress_restart; + hook.restart = vexpress_restart; device_create_file(&pdev->dev, &dev_attr_active); break; default: return -EINVAL; }; + set_machine_reset(func, &hook, &pdev->dev); return 0; } +static int vexpress_reset_probe(struct platform_device *pdev) +{ + return vexpress_set_hook(pdev); +} + static const struct platform_device_id vexpress_reset_id_table[] = { { .name = "vexpress-reset", .driver_data = RESET_RESTART, }, { .name = "vexpress-shutdown", .driver_data = RESET_POWER_OFF, },