From patchwork Thu Apr 2 18:58:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Brownell X-Patchwork-Id: 15983 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n32IwG3I017267 for ; Thu, 2 Apr 2009 18:58:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754784AbZDBS6Q (ORCPT ); Thu, 2 Apr 2009 14:58:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751437AbZDBS6Q (ORCPT ); Thu, 2 Apr 2009 14:58:16 -0400 Received: from n26.bullet.mail.mud.yahoo.com ([68.142.206.221]:24752 "HELO n26.bullet.mail.mud.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754784AbZDBS6P (ORCPT ); Thu, 2 Apr 2009 14:58:15 -0400 Received: from [68.142.194.243] by n26.bullet.mail.mud.yahoo.com with NNFMP; 02 Apr 2009 18:58:13 -0000 Received: from [68.142.201.68] by t1.bullet.mud.yahoo.com with NNFMP; 02 Apr 2009 18:58:13 -0000 Received: from [127.0.0.1] by omp420.mail.mud.yahoo.com with NNFMP; 02 Apr 2009 18:58:13 -0000 X-Yahoo-Newman-Id: 593611.88757.bm@omp420.mail.mud.yahoo.com Received: (qmail 55594 invoked from network); 2 Apr 2009 18:58:13 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:Cc:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id; b=YERu0Dc9uezcNlqzjEBfR1DvPf+iS+6R5gkU5+9M4RqOsibVKAqVforvZiNcDOpbSnpp03p7xpiq0MCfCW1HM8HXb0W7r73FodRd+iPaspzF4PrLfZfyzYzAnglo5aL8n62Pgnk21wmBYHFaLbd1zcfoATXXxGZx1cXrvFCr6Ik= ; Received: from unknown (HELO albert) (david-b@69.226.223.132 with plain) by smtp106.sbc.mail.sp1.yahoo.com with SMTP; 2 Apr 2009 18:58:12 -0000 X-YMail-OSG: yi_J9O0VM1kLQeffsu89xRXVbFhMnjPTZJ5HeibGxA_ac08YDYvaQbbKjLtGxrNo4yqAdzhgKW2qFJj_bhoM8UiVPZTnpqKuHtbkN5sztNFcFQXa_vQZq9Dfi3OOkpsaYqRHeXa8UNc8GTYq_s8O9Fez1Gv3SwQF1NMax.g2ynD9H2k9OuVeH6cG6RF.RfJFS1pLeJnBvFVapy2D9fBxyHB828SgsLTYfi1jSsEyOBxy0ocq7UWgO8jteO7U6IfJYSAo82viT0ofybiY64OcVv86ykqBcZBrc.f.CclDplkY6Z.60UN2Rw7dmaTcD5xnX5HfJlA- X-Yahoo-Newman-Property: ymail-3 From: David Brownell To: Koen Kooi Subject: Re: [PATCH v3] ARM: OMAP: board-ldp: add regulator info to get the microSD slot working again Date: Thu, 2 Apr 2009 11:58:11 -0700 User-Agent: KMail/1.9.10 Cc: linux-omap@vger.kernel.org References: <1238489589-12216-1-git-send-email-koen@beagleboard.org> In-Reply-To: <1238489589-12216-1-git-send-email-koen@beagleboard.org> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200904021158.11612.david-b@pacbell.net> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Ack on that v3 patch, FWIW ... but also: On Tuesday 31 March 2009, Koen Kooi wrote: > +static const struct twl4030_resconfig ldp_resconfig[] = { > +       /* disable regulators that u-boot left enabled; the > +        * devices' drivers should be managing these. > +        */ > +       { .resource = RES_VMMC1, }, > +       { 0, }, > +}; > + Purely for information -- as in, maybe *more* regulators should be disabled -- here's a patch I tend to run with. Obviously it's better to set the resconfig stuff than to do what this originally tried to do, but this predates resconfig. All this does (now) is print some messages that highlight when regulators end up in wierd states after initialization. - Dave --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html =============== --- a/drivers/regulator/twl4030-regulator.c +++ b/drivers/regulator/twl4030-regulator.c @@ -39,6 +39,9 @@ struct twlreg_info { /* FIXED_LDO voltage */ u8 deciV; + /* true iff regulator is set up for Linux*/ + bool in_use; + /* voltage in mV = table[VSEL]; table_len must be a power-of-two */ u8 table_len; const u16 *table; @@ -419,6 +422,8 @@ static struct twlreg_info twl4030_regs[] /* VUSBCP is managed *only* by the USB subchip */ }; +static bool is_4030; + static int twl4030reg_probe(struct platform_device *pdev) { int i; @@ -430,6 +435,8 @@ static int twl4030reg_probe(struct platf for (i = 0, info = NULL; i < ARRAY_SIZE(twl4030_regs); i++) { if (twl4030_regs[i].desc.id != pdev->id) continue; + if (pdev->id == TWL4030_REG_VAUX2_4030) + is_4030 = true; info = twl4030_regs + i; break; } @@ -458,6 +465,8 @@ static int twl4030reg_probe(struct platf } platform_set_drvdata(pdev, rdev); + info->in_use = true; + /* NOTE: many regulators support short-circuit IRQs (presentable * as REGULATOR_OVER_CURRENT notifications?) configured via: * - SC_CONFIG @@ -469,6 +478,64 @@ static int twl4030reg_probe(struct platf return 0; } +/* + * Make sure all LDOs are in the P1 (Linux) group or none; and that + * if Linux can't have enabled them, they're in no group (disabled). + * Unused-but-enabled LDOs are a constant power drain. + * + * NOTE: something else must disable LDOs which Linux manages, but + * which may have been wrongly enabled during system startup. + */ +static __init int twl4030_ldo_tweak(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(twl4030_regs); i++) { + struct twlreg_info *info = &twl4030_regs[i]; + int dev_grp, new_grp; + int status; + + /* ignore the "other" VAUX2 descriptor */ + if (info->base == 0x1b) { + if (info->desc.id == TWL4030_REG_VAUX2_4030) { + if (!is_4030) + continue; + } else { + if (is_4030) + continue; + } + } + + dev_grp = twl4030reg_read(info, VREG_GRP); + if (dev_grp < 0) + continue; + dev_grp &= 0xf0; + + if (info->in_use) + new_grp = dev_grp & (P1_GRP | WARM_CFG); + else + new_grp = 0; + if (dev_grp == new_grp) + continue; + + /* reset and report this; the bootloader might be fixable */ +#if 0 + status = twl4030reg_write(info, VREG_GRP, new_grp); +#else + status = 0; +#endif + if (status < 0) + pr_err("TWL: can't update LDO %s, err %d\n", + info->desc.name, status); + else + pr_info("TWL: LDO %s, dev_grp %02x --> %02x\n", + info->desc.name, dev_grp, new_grp); + + } + return 0; +} +late_initcall(twl4030_ldo_tweak); + static int __devexit twl4030reg_remove(struct platform_device *pdev) { regulator_unregister(platform_get_drvdata(pdev));