From patchwork Thu Apr 24 00:40:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 4045351 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 011E09F387 for ; Thu, 24 Apr 2014 00:43:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4159202EC for ; Thu, 24 Apr 2014 00:43:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B096C202F0 for ; Thu, 24 Apr 2014 00:43:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wd7j3-0003Te-O3; Thu, 24 Apr 2014 00:41:17 +0000 Received: from mho-02-ewr.mailhop.org ([204.13.248.72]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wd7if-0003IX-Vy for linux-arm-kernel@lists.infradead.org; Thu, 24 Apr 2014 00:40:55 +0000 Received: from 99-127-230-128.lightspeed.sntcca.sbcglobal.net ([99.127.230.128] helo=muffinssi.muru.com) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.72) (envelope-from ) id 1Wd7iM-0003DG-6d; Thu, 24 Apr 2014 00:40:34 +0000 X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 99.127.230.128 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX199V275nChKsQF1e8tWnnsd From: Tony Lindgren To: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org Subject: [PATCH 1/4] mfd: twl4030-power: Add recommended idle configuration Date: Wed, 23 Apr 2014 17:40:27 -0700 Message-Id: <1398300030-7386-2-git-send-email-tony@atomide.com> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1398300030-7386-1-git-send-email-tony@atomide.com> References: <1398300030-7386-1-git-send-email-tony@atomide.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140423_174054_193541_8E365676 X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: 0.0 (/) Cc: Peter De Schrijver , Lee Jones , Samuel Ortiz 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=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, 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 These settings are based on the "Recommended Sleep Sequences for the Zoom Platform" pdf at: http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf These settings assume most of the regulators are under control of Linux, and cuts off VDD1 and VDD2 during off-idle as Linux cannot do it. For any board specific changes to these, let's patch them in as changes to the generic data in the follow-up patches. This keeps the board specific changes small. Note that this does not consider the twl5030 errata 27. That can be added later on after it has been tested. Cc: Peter De Schrijver Cc: Samuel Ortiz Cc: Lee Jones Signed-off-by: Tony Lindgren --- .../devicetree/bindings/mfd/twl4030-power.txt | 4 + drivers/mfd/twl4030-power.c | 165 +++++++++++++++++++++ 2 files changed, 169 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt index b906116..bbd6603 100644 --- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt +++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt @@ -8,10 +8,14 @@ Required properties: - compatible : must be one of the following "ti,twl4030-power" "ti,twl4030-power-reset" + "ti,twl4030-power-idle" The use of ti,twl4030-power-reset is recommended at least on 3530 that needs a special configuration for warm reset to work. +When using ti,twl4030-power-idle, the TI recommended configuration +for idle modes is loaded to the tlw4030 PMIC. + Optional properties: - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or SLEEP-to-OFF transition when the system poweroffs. diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index 1db0560..89a8528 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c @@ -595,11 +595,176 @@ static struct twl4030_power_data omap3_reset = { .resource_config = omap3_rconfig, }; +/* Recommended generic default idle configuration for off-idle */ + +/* Broadcast message to put res to sleep */ +static struct twl4030_ins omap3_idle_sleep_on_seq[] = { + { MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, + 0, RES_STATE_SLEEP), 2 }, +}; + +static struct twl4030_script omap3_idle_sleep_on_script = { + .script = omap3_idle_sleep_on_seq, + .size = ARRAY_SIZE(omap3_idle_sleep_on_seq), + .flags = TWL4030_SLEEP_SCRIPT, +}; + +/* Broadcast message to put res to active */ +static struct twl4030_ins omap3_idle_wakeup_p12_seq[] = { + { MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, + 0, RES_STATE_ACTIVE), 2 }, + }; + +static struct twl4030_script omap3_idle_wakeup_p12_script = { + .script = omap3_idle_wakeup_p12_seq, + .size = ARRAY_SIZE(omap3_idle_wakeup_p12_seq), + .flags = TWL4030_WAKEUP12_SCRIPT, +}; + +/* Broadcast message to put res to active */ +static struct twl4030_ins omap3_idle_wakeup_p3_seq[] = { + { MSG_SINGULAR(DEV_GRP_NULL, RES_CLKEN, RES_STATE_ACTIVE), 0x37 }, + { MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, + 0, RES_STATE_ACTIVE), 2 }, +}; + +static struct twl4030_script omap3_idle_wakeup_p3_script = { + .script = omap3_idle_wakeup_p3_seq, + .size = ARRAY_SIZE(omap3_idle_wakeup_p3_seq), + .flags = TWL4030_WAKEUP3_SCRIPT, +}; + +static struct twl4030_script omap3_idle_wrst_script = { + .script = omap3_wrst_seq, + .size = ARRAY_SIZE(omap3_wrst_seq), + .flags = TWL4030_WRST_SCRIPT, +}; + +static struct twl4030_script *omap3_idle_scripts[] = { + &omap3_idle_wakeup_p12_script, + &omap3_idle_wakeup_p3_script, + &omap3_idle_wrst_script, + &omap3_idle_sleep_on_script, +}; + +/* + * Usable values for .remap_sleep and .remap_off + * Based on table "5.3.3 Resource Operating modes" + */ +enum { + TWL_REMAP_OFF = 0, + TWL_REMAP_SLEEP = 8, + TWL_REMAP_ACTIVE = 9, +}; + +#define TWL_DEV_GRP_P123 (DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3) + +/* + * Recommended configuration based on "Recommended Sleep + * Sequences for the Zoom Platform": + * http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf + */ +static struct twl4030_resconfig omap3_idle_rconfig[] = { + { .resource = RES_VAUX1, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VAUX2, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VAUX3, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VAUX4, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VMMC1, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VPLL1, .devgroup = DEV_GRP_P1, + .type = 3, .type2 = 1, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_OFF, }, + { .resource = RES_VPLL2, .devgroup = DEV_GRP_P1, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VDAC, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VINTANA1, .devgroup = TWL_DEV_GRP_P123, + .type = 1, .type2 = 2, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VINTANA2, .devgroup = TWL_DEV_GRP_P123, + .type = 0, .type2 = 2, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VINTDIG, .devgroup = TWL_DEV_GRP_P123, + .type = 1, .type2 = 2, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VIO, .devgroup = TWL_DEV_GRP_P123, + .type = 2, .type2 = 2, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VDD1, .devgroup = DEV_GRP_P1, + .type = 4, .type2 = 1, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_OFF, }, + { .resource = RES_VDD2, .devgroup = DEV_GRP_P1, + .type = 3, .type2 = 1, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_OFF, }, + { .resource = RES_VUSB_1V5, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VUSB_1V8, .devgroup = DEV_GRP_NULL, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_VUSB_3V1, .devgroup = TWL_DEV_GRP_P123, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + /* Resource #20 USB charge pump skipped */ + { .resource = RES_REGEN, .devgroup = TWL_DEV_GRP_P123, + .type = 2, .type2 = 1, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_NRES_PWRON, .devgroup = TWL_DEV_GRP_P123, + .type = 0, .type2 = 1, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP }, + { .resource = RES_CLKEN, .devgroup = TWL_DEV_GRP_P123, + .type = 3, .type2 = 2, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_SYSEN, .devgroup = TWL_DEV_GRP_P123, + .type = 6, .type2 = -1, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, + .type = 0, .type2 = 2, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_32KCLKOUT, .devgroup = TWL_DEV_GRP_P123, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_RESET, .devgroup = TWL_DEV_GRP_P123, + .type = 6, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { .resource = RES_MAIN_REF, .devgroup = TWL_DEV_GRP_P123, + .type = 0, .type2 = 0, .remap_off = TWL_REMAP_OFF, + .remap_sleep = TWL_REMAP_SLEEP, }, + { /* Terminator */ }, +}; + +static struct twl4030_power_data omap3_idle = { + .scripts = omap3_idle_scripts, + .num = ARRAY_SIZE(omap3_idle_scripts), + .resource_config = omap3_idle_rconfig, +}; + static struct of_device_id twl4030_power_of_match[] = { { .compatible = "ti,twl4030-power-reset", .data = &omap3_reset, }, + { + .compatible = "ti,twl4030-power-idle", + .data = &omap3_idle, + }, { }, }; MODULE_DEVICE_TABLE(of, twl4030_power_of_match);