From patchwork Wed Jul 18 13:22:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 171677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 281522C037E for ; Wed, 18 Jul 2012 23:25:33 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrUDn-000747-AZ; Wed, 18 Jul 2012 13:23:19 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrUCs-0006pR-W4 for linux-mtd@lists.infradead.org; Wed, 18 Jul 2012 13:22:25 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 18 Jul 2012 14:22:13 +0100 Received: from hornet.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 18 Jul 2012 14:23:25 +0100 From: Pawel Moll To: linux-mtd@lists.infradead.org Subject: [PATCH v2 1/2] mtd: maps: physmap: Add VPP regulator control Date: Wed, 18 Jul 2012 14:22:00 +0100 Message-Id: <1342617721-14715-2-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342617721-14715-1-git-send-email-pawel.moll@arm.com> References: <1342617721-14715-1-git-send-email-pawel.moll@arm.com> X-OriginalArrivalTime: 18 Jul 2012 13:23:25.0278 (UTC) FILETIME=[82C56FE0:01CD64E8] X-MC-Unique: 112071814221304401 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [91.220.42.44 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Artem Bityutskiy , David Woodhouse , Pawel Moll X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add an optional regulator control of the VPP line. "vpp" supply must be provided by the board description. Signed-off-by: Pawel Moll --- drivers/mtd/maps/physmap.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 21b0b71..57d79ea 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #define MAX_RESOURCES 4 @@ -29,6 +31,7 @@ struct physmap_flash_info { struct map_info map[MAX_RESOURCES]; spinlock_t vpp_lock; int vpp_refcnt; + struct regulator *vpp_regulator; }; static int physmap_flash_remove(struct platform_device *dev) @@ -70,19 +73,22 @@ static void physmap_set_vpp(struct map_info *map, int state) pdev = (struct platform_device *)map->map_priv_1; physmap_data = pdev->dev.platform_data; + info = platform_get_drvdata(pdev); - if (!physmap_data->set_vpp) + if (!physmap_data->set_vpp && !info->vpp_regulator) return; - info = platform_get_drvdata(pdev); - spin_lock_irqsave(&info->vpp_lock, flags); - if (state) { - if (++info->vpp_refcnt == 1) /* first nested 'on' */ + if (state && ++info->vpp_refcnt == 1) { /* first nested 'on' */ + if (physmap_data->set_vpp) physmap_data->set_vpp(pdev, 1); - } else { - if (--info->vpp_refcnt == 0) /* last nested 'off' */ + else + regulator_enable(info->vpp_regulator); + } else if (!state && --info->vpp_refcnt == 0) { /* last nested 'off' */ + if (physmap_data->set_vpp) physmap_data->set_vpp(pdev, 0); + else + regulator_disable(info->vpp_regulator); } spin_unlock_irqrestore(&info->vpp_lock, flags); } @@ -123,6 +129,10 @@ static int physmap_flash_probe(struct platform_device *dev) goto err_out; } + info->vpp_regulator = devm_regulator_get(&dev->dev, "vpp"); + if (IS_ERR(info->vpp_regulator)) + info->vpp_regulator = NULL; + platform_set_drvdata(dev, info); for (i = 0; i < dev->num_resources; i++) {