From patchwork Wed Jul 18 13:22:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 171676 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 CE38A2C037E for ; Wed, 18 Jul 2012 23:25:24 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrUDd-00070A-9s; Wed, 18 Jul 2012 13:23:09 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrUCr-0006pX-Kz 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:14 +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 2/2] mtd: maps: physmap_of: Add VPP regulator control Date: Wed, 18 Jul 2012 14:22:01 +0100 Message-Id: <1342617721-14715-3-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.0591 (UTC) FILETIME=[82F53270:01CD64E8] X-MC-Unique: 112071814221401301 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 and a standard "vpp-supply" tree property. Signed-off-by: Pawel Moll --- .../devicetree/bindings/mtd/mtd-physmap.txt | 4 ++- drivers/mtd/maps/physmap_of.c | 28 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt index a63c2bd7..40cb554 100644 --- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt +++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt @@ -13,10 +13,11 @@ file systems on embedded devices. device width times the number of interleaved chips. - device-width : (optional) Width of a single mtd chip. If omitted, assumed to be equal to 'bank-width'. + - vpp-supply : (optional) phandle to a regulator controlling VPP + line of the chips. - #address-cells, #size-cells : Must be present if the device has sub-nodes representing partitions (see below). In this case both #address-cells and #size-cells must be equal to 1. - For JEDEC compatible devices, the following additional properties are defined: @@ -33,6 +34,7 @@ Example: reg = ; bank-width = <4>; device-width = <1>; + vpp-supply = <&flash_vpp_reg> #address-cells = <1>; #size-cells = <1>; fs@0 { diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 2e6fb68..9f34320 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include struct of_flash_list { @@ -74,6 +76,18 @@ static int of_flash_remove(struct platform_device *dev) return 0; } +static void of_flash_set_vpp_regulator(struct map_info *map, int state) +{ + /* map_priv_1 = VPP regulator pointer */ + struct regulator *vpp_regulator = (struct regulator *)map->map_priv_1; + + /* map_priv_2 = "reference counter" */ + if (state && !map->map_priv_2++) + WARN_ON(regulator_enable(vpp_regulator)); + else if (!state && !--map->map_priv_2) + WARN_ON(regulator_disable(vpp_regulator)); +} + /* Helper function to handle probing of the obsolete "direct-mapped" * compatible binding, which has an extra "probe-type" property * describing the type of flash probe necessary. */ @@ -169,6 +183,7 @@ static int __devinit of_flash_probe(struct platform_device *dev) struct mtd_info **mtd_list = NULL; resource_size_t res_size; struct mtd_part_parser_data ppdata; + struct regulator *vpp_regulator = NULL; match = of_match_device(of_flash_match, &dev->dev); if (!match) @@ -200,6 +215,14 @@ static int __devinit of_flash_probe(struct platform_device *dev) dev_set_drvdata(&dev->dev, info); + if (of_get_property(dp, "vpp-supply", NULL)) { + vpp_regulator = devm_regulator_get(&dev->dev, "vpp"); + if (IS_ERR(vpp_regulator)) { + err = PTR_ERR(vpp_regulator); + goto err_flash_remove; + } + } + mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL); if (!mtd_list) goto err_flash_remove; @@ -235,6 +258,11 @@ static int __devinit of_flash_probe(struct platform_device *dev) info->list[i].map.phys = res.start; info->list[i].map.size = res_size; info->list[i].map.bankwidth = be32_to_cpup(width); + if (vpp_regulator) { + info->list[i].map.map_priv_1 = + (unsigned long)vpp_regulator; + info->list[i].map.set_vpp = of_flash_set_vpp_regulator; + } err = -ENOMEM; info->list[i].map.virt = ioremap(info->list[i].map.phys,