From patchwork Thu Oct 31 06:27:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 3118861 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 A68329F3E3 for ; Thu, 31 Oct 2013 06:32:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C022A203DF for ; Thu, 31 Oct 2013 06:32:34 +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 A9CB62018B for ; Thu, 31 Oct 2013 06:32:33 +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 1Vblmq-0004zJ-1r; Thu, 31 Oct 2013 06:31:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vblmb-0008ID-BC; Thu, 31 Oct 2013 06:31:05 +0000 Received: from mail-ee0-x236.google.com ([2a00:1450:4013:c00::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vblm0-0008C0-3m for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2013 06:30:35 +0000 Received: by mail-ee0-f54.google.com with SMTP id c50so457129eek.27 for ; Wed, 30 Oct 2013 23:30:06 -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=xTs5Xrrw2twgkvGE2U/y9sPPEPHvjQBjjQ599G3F5Qg=; b=hXmCxqsPCp69PAaHikrB61X3p//S7Nv2kh23QF9Fe48Xs9i9B+Re968/hGuIY/LPBi YlpPEHeHERqQ4zkldbusms5QwrE/Jevgep4Q47aw1CSlAYp6lctoWmwDR/NWSvwnTpGS tNwesP1TIIAut9I3tkfuGIrEjme+QL/k0DxXR9Nyh42DGbc7hVlQQna53mOgP0V7MPtP P4YT2lBqQNhJHvDqDBAxf6iPOmQgr4s1+IlOjXyjKgQ6Zpb8gA34Hgwp/urEBui6JAbd CKMb2tLjS7VdIrsQ1ByKi4HpbOW5CGPOqaey8TTPHPMncEiYKAaEWnbOFhdFe4aEz0xY aryA== X-Received: by 10.14.45.70 with SMTP id o46mr1417051eeb.19.1383201006335; Wed, 30 Oct 2013 23:30:06 -0700 (PDT) Received: from shock.dandreoli.com (j115181.upc-j.chello.nl. [24.132.115.181]) by mx.google.com with ESMTPSA id k7sm4389161eeg.13.2013.10.30.23.30.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Oct 2013 23:30:04 -0700 (PDT) Received: by shock.dandreoli.com (Postfix, from userid 1000) id 8F0FB3402AD; Thu, 31 Oct 2013 07:30:00 +0100 (CET) Message-Id: <20131031063000.361406973@linux.com> User-Agent: quilt/0.60-1 Date: Thu, 31 Oct 2013 07:27:16 +0100 From: Domenico Andreoli To: linux-arch@vger.kernel.org Subject: [PATCH 08/11] ARM: u300: use the common machine reset handling References: <20131031062708.520968323@linux.com> Content-Disposition: inline; filename=arm-machine-reset-u300.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131031_023028_394801_380B347C X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -1.9 (-) Cc: Russell King , Arnd Bergmann , Linus Walleij , 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: u300 as provider of reset hooks. Cc: Linus Walleij Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Domenico Andreoli --- arch/arm/mach-u300/regulator.c | 23 ++++++++++++++--------- drivers/regulator/Kconfig | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) Index: b/drivers/regulator/Kconfig =================================================================== --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -106,6 +106,7 @@ config REGULATOR_AB3100 tristate "ST-Ericsson AB3100 Regulator functions" depends on AB3100_CORE default y if AB3100_CORE + select MACHINE_RESET help These regulators correspond to functionality in the AB3100 analog baseband dealing with power regulators Index: b/arch/arm/mach-u300/regulator.c =================================================================== --- a/arch/arm/mach-u300/regulator.c +++ b/arch/arm/mach-u300/regulator.c @@ -17,6 +17,7 @@ #include #include #include +#include /* Power Management Control 16bit (R/W) */ #define U300_SYSCON_PMCR (0x50) @@ -24,20 +25,14 @@ #define U300_SYSCON_PMCR_PWR_MGNT_ENABLE (0x0001) /* - * Regulators that power the board and chip and which are - * not copuled to specific drivers are hogged in these - * instances. - */ -static struct regulator *main_power_15; - -/* * This function is used from pm.h to shut down the system by * resetting all regulators in turn and then disable regulator * LDO D (main power). */ -void u300_pm_poweroff(void) +void u300_pm_poweroff(void *dev) { sigset_t old, all; + struct regulator *main_power_15 = dev; sigfillset(&all); if (!sigprocmask(SIG_BLOCK, &all, &old)) { @@ -51,6 +46,11 @@ void u300_pm_poweroff(void) return; } +static void u300_reset_hook_release(void *dev) +{ + regulator_put(dev); +} + /* * Hog the regulators needed to power up the board. */ @@ -58,7 +58,9 @@ static int __init __u300_init_boardpower { struct device_node *np = pdev->dev.of_node; struct device_node *syscon_np; + struct regulator *main_power_15; struct regmap *regmap; + struct reset_hook hook; int err; pr_info("U300: setting up board power\n"); @@ -98,7 +100,10 @@ static int __init __u300_init_boardpower U300_SYSCON_PMCR_DCON_ENABLE, 0); /* Register globally exported PM poweroff hook */ - pm_power_off = u300_pm_poweroff; + reset_hook_init(&hook); + hook.power_off = u300_pm_poweroff; + hook.release = u300_reset_hook_release; + set_machine_reset(RESET_POWER_OFF, &hook, main_power_15); return 0; }