From patchwork Thu Feb 7 12:36:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: avinash philip X-Patchwork-Id: 2110751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 39C8B3FDF1 for ; Thu, 7 Feb 2013 12:41:35 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U3QlB-0002YZ-Jw; Thu, 07 Feb 2013 12:39:26 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U3Ql6-0002WZ-J7; Thu, 07 Feb 2013 12:39:21 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r17CdAax018240; Thu, 7 Feb 2013 06:39:11 -0600 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id r17CdAtZ014760; Thu, 7 Feb 2013 18:09:10 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Thu, 7 Feb 2013 18:09:09 +0530 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with SMTP id r17Cd99N024243; Thu, 7 Feb 2013 18:09:09 +0530 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id 1CC90158003; Thu, 7 Feb 2013 18:09:09 +0530 (IST) Received: from ubuntu-psp-linux.india.ext.ti.com (ubuntu-psp-linux [192.168.247.46]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r17Cd8R08395; Thu, 7 Feb 2013 18:09:08 +0530 (IST) From: Philip Avinash To: , , , , Subject: [PATCH v2 3/4] mtd: devices: elm: Low power transition support Date: Thu, 7 Feb 2013 18:06:57 +0530 Message-ID: <1360240618-11094-4-git-send-email-avinashphilip@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360240618-11094-1-git-send-email-avinashphilip@ti.com> References: <1360240618-11094-1-git-send-email-avinashphilip@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130207_073920_712820_CFCC920B X-CRM114-Status: GOOD ( 14.51 ) X-Spam-Score: -4.6 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.40 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: afzal@ti.com, nsekhar@ti.com, linux-kernel@vger.kernel.org, hvaibhav@ti.com, gururaja.hebbar@ti.com, linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In low power modes of AM335X platforms, peripherals power is cut off. This patch supports low power sleep transition support for ELM driver. Signed-off-by: Philip Avinash --- drivers/mtd/devices/elm.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c index f034239..a9ac8f2 100644 --- a/drivers/mtd/devices/elm.c +++ b/drivers/mtd/devices/elm.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -62,6 +63,7 @@ struct elm_info { struct completion elm_completion; struct list_head list; enum bch_ecc bch_type; + bool idle; }; static LIST_HEAD(elm_devices); @@ -86,9 +88,11 @@ void elm_config(struct device *dev, enum bch_ecc bch_type) u32 reg_val; struct elm_info *info = dev_get_drvdata(dev); + info->idle = true; reg_val = (bch_type & ECC_BCH_LEVEL_MASK) | (ELM_ECC_SIZE << 16); elm_write_reg(info, ELM_LOCATION_CONFIG, reg_val); info->bch_type = bch_type; + info->idle = false; } EXPORT_SYMBOL(elm_config); @@ -280,6 +284,7 @@ void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc, struct elm_info *info = dev_get_drvdata(dev); u32 reg_val; + info->idle = true; /* Enable page mode interrupt */ reg_val = elm_read_reg(info, ELM_IRQSTATUS); elm_write_reg(info, ELM_IRQSTATUS, reg_val & INTR_STATUS_PAGE_VALID); @@ -298,6 +303,7 @@ void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc, reg_val = elm_read_reg(info, ELM_IRQENABLE); elm_write_reg(info, ELM_IRQENABLE, reg_val & ~INTR_EN_PAGE_MASK); elm_error_correction(info, err_vec); + info->idle = false; } EXPORT_SYMBOL(elm_decode_bch_error_page); @@ -368,6 +374,7 @@ static int elm_probe(struct platform_device *pdev) INIT_LIST_HEAD(&info->list); list_add(&info->list, &elm_devices); platform_set_drvdata(pdev, info); + info->idle = false; return ret; } @@ -379,6 +386,38 @@ static int elm_remove(struct platform_device *pdev) return 0; } +static int elm_suspend(struct device *dev) +{ + struct elm_info *info = dev_get_drvdata(dev); + wait_queue_head_t wq; + DECLARE_WAITQUEUE(wait, current); + + init_waitqueue_head(&wq); + while (1) { + /* Make sure that ELM not running */ + if (info->idle) { + add_wait_queue(&wq, &wait); + schedule(); + remove_wait_queue(&wq, &wait); + } else { + break; + } + } + pm_runtime_put_sync(dev); + return 0; +} + +static int elm_resume(struct device *dev) +{ + struct elm_info *info = dev_get_drvdata(dev); + + pm_runtime_get_sync(dev); + elm_config(dev, info->bch_type); + return 0; +} + +static SIMPLE_DEV_PM_OPS(elm_pm_ops, elm_suspend, elm_resume); + #ifdef CONFIG_OF static const struct of_device_id elm_of_match[] = { { .compatible = "ti,am3352-elm" }, @@ -392,6 +431,7 @@ static struct platform_driver elm_driver = { .name = "elm", .owner = THIS_MODULE, .of_match_table = of_match_ptr(elm_of_match), + .pm = &elm_pm_ops, }, .probe = elm_probe, .remove = elm_remove,