From patchwork Thu Jul 12 16:38:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 170725 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 0A4EE2C02E9 for ; Fri, 13 Jul 2012 02:41:45 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SpMQI-0007gk-VX; Thu, 12 Jul 2012 16:39:27 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SpMPo-0007dF-7e for linux-mtd@lists.infradead.org; Thu, 12 Jul 2012 16:38:57 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 12 Jul 2012 17:38:51 +0100 Received: from hornet.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Thu, 12 Jul 2012 17:39:50 +0100 From: Pawel Moll To: linux-mtd@lists.infradead.org Subject: [PATCH 1/2] mtd: maps: physmap: Add GPIO VPP control Date: Thu, 12 Jul 2012 17:38:40 +0100 Message-Id: <1342111121-23161-2-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342111121-23161-1-git-send-email-pawel.moll@arm.com> References: <1342111121-23161-1-git-send-email-pawel.moll@arm.com> X-OriginalArrivalTime: 12 Jul 2012 16:39:50.0968 (UTC) FILETIME=[F51C8380:01CD604C] X-MC-Unique: 112071217385138301 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 GPIO control of the VPP signal: * platform data fields to specify GPIO number and polarity * set_vpp implementation setting the GPIO value Signed-off-by: Pawel Moll --- drivers/mtd/maps/physmap.c | 22 ++++++++++++++++++++++ include/linux/mtd/physmap.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 21b0b71..3ef4e1e 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c @@ -20,6 +20,7 @@ #include #include #include +#include #define MAX_RESOURCES 4 @@ -87,6 +88,14 @@ static void physmap_set_vpp(struct map_info *map, int state) spin_unlock_irqrestore(&info->vpp_lock, flags); } +static void physmap_set_gpio_vpp(struct platform_device *pdev, int state) +{ + struct physmap_flash_data *physmap_data = pdev->dev.platform_data; + + gpio_set_value(physmap_data->gpio_vpp, + !!state ^ !!physmap_data->gpio_vpp_active_low); +} + static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", @@ -123,6 +132,19 @@ static int physmap_flash_probe(struct platform_device *dev) goto err_out; } + if (!physmap_data->set_vpp && gpio_is_valid(physmap_data->gpio_vpp)) { + unsigned long flags = GPIOF_DIR_OUT; + if (physmap_data->gpio_vpp_active_low) + flags |= GPIOF_INIT_HIGH; + else + flags |= GPIOF_INIT_LOW; + err = devm_gpio_request_one(&dev->dev, physmap_data->gpio_vpp, + flags, dev_name(&dev->dev)); + if (err) + goto err_out; + physmap_data->set_vpp = physmap_set_gpio_vpp; + } + platform_set_drvdata(dev, info); for (i = 0; i < dev->num_resources; i++) { diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h index d2887e7..b5c85b6 100644 --- a/include/linux/mtd/physmap.h +++ b/include/linux/mtd/physmap.h @@ -26,6 +26,8 @@ struct physmap_flash_data { int (*init)(struct platform_device *); void (*exit)(struct platform_device *); void (*set_vpp)(struct platform_device *, int); + int gpio_vpp; + bool gpio_vpp_active_low; unsigned int nr_parts; unsigned int pfow_base; char *probe_type;