From patchwork Mon Feb 22 17:16:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 81202 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1MHHfbJ023204 for ; Mon, 22 Feb 2010 17:17:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192Ab0BVRRX (ORCPT ); Mon, 22 Feb 2010 12:17:23 -0500 Received: from mail-yx0-f200.google.com ([209.85.210.200]:48663 "EHLO mail-yx0-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088Ab0BVRRW (ORCPT ); Mon, 22 Feb 2010 12:17:22 -0500 Received: by yxe38 with SMTP id 38so2642788yxe.4 for ; Mon, 22 Feb 2010 09:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=FvUvky3F2rdStt6a2hFd3F6v030eJnTIQa/y04qhqtA=; b=WWYgPB071C/DWqYr95pJUgLeZvn2rKm9EA/4Vrxxs7EaNEezfN0vWmtB5/ewaIrFSf lsz8SNhjRJIFEcYQibQy96KFxkYb64K6m4Q9qILO8vDl6g1IkPQDvb3r+z527MfdcfwC Sd/FrV9EANrGx77mOwekrz/+eOxMn9xDAqE4c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=eNXHNH8Lkqx5f0z+ur+DRJGEw8de4a900ZJkP8DZbRCQp9AdkssrS5OjqjWXtGHEEa 0P/uWM/4Zk0B9D5qBonOngw6RSJDj/jpwjw7hgy5xCDJf5LaSeHupm3I41tH0x51yxt5 idNsNV8Rvgnt+u7OmVdfINJVdrIvgkRqf25Ak= Received: by 10.150.131.3 with SMTP id e3mr5063401ybd.347.1266859040385; Mon, 22 Feb 2010 09:17:20 -0800 (PST) Received: from localhost.localdomain (adsl-99-57-147-167.dsl.rcsntx.sbcglobal.net [99.57.147.167]) by mx.google.com with ESMTPS id 9sm965994ywe.52.2010.02.22.09.17.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 22 Feb 2010 09:17:19 -0800 (PST) From: mturquette@gmail.com To: sameo@linux.intel.com Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Mike Turquette Subject: [PATCH] MFD: TWL4030: introduce remove_script function Date: Mon, 22 Feb 2010 11:16:30 -0600 Message-Id: <1266858990-3915-1-git-send-email-mturquette@ti.com> X-Mailer: git-send-email 1.6.3.2 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 22 Feb 2010 17:17:41 +0000 (UTC) diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index 5b045ff..7efa878 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c @@ -461,6 +461,56 @@ out: return err; } +int twl4030_remove_script(u8 flags) +{ + int err = 0; + + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1, + R_PROTECT_KEY); + if (err) { + pr_err("twl4030: unable to unlock PROTECT_KEY\n"); + return err; + } + + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2, + R_PROTECT_KEY); + if (err) { + pr_err("twl4030: unable to unlock PROTECT_KEY\n"); + return err; + } + + if (flags & TWL4030_WRST_SCRIPT) { + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, + R_SEQ_ADD_WARM); + if (err) + return err; + } + if (flags & TWL4030_WAKEUP12_SCRIPT) { + if (err) + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, + R_SEQ_ADD_S2A12); + return err; + } + if (flags & TWL4030_WAKEUP3_SCRIPT) { + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, + R_SEQ_ADD_S2A3); + if (err) + return err; + } + if (flags & TWL4030_SLEEP_SCRIPT) { + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, + R_SEQ_ADD_A2S); + if (err) + return err; + } + + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY); + if (err) + pr_err("TWL4030 Unable to relock registers\n"); + + return err; +} + void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) { int err = 0; diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h index 33d9d5c..d4baff8 100644 --- a/include/linux/i2c/twl.h +++ b/include/linux/i2c/twl.h @@ -550,6 +550,7 @@ struct twl4030_power_data { }; extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts); +extern int twl4030_remove_script(u8 flags); struct twl4030_codec_audio_data { unsigned int audio_mclk;