Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbbH1TmT (ORCPT ); Fri, 28 Aug 2015 15:42:19 -0400 Received: from mail-bn1on0143.outbound.protection.outlook.com ([157.56.110.143]:56992 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752700AbbH1Tlv (ORCPT ); Fri, 28 Aug 2015 15:41:51 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; From: Han Xu To: CC: , , , , , , , , , , Subject: [PATCH v3 2/6] dmaengine: mxs: support i.MX7D and deep sleep mode Date: Fri, 28 Aug 2015 14:32:41 -0500 Message-ID: <1440790365-28072-3-git-send-email-b45815@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440790365-28072-1-git-send-email-b45815@freescale.com> References: <1440790365-28072-1-git-send-email-b45815@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD047;1:edaJqs6ZcPlfNFgTvuBtzxLZaGbkSSjd/wtWEpthtxpleiCY0104TNT94l8FNDebL2no2e/BSs+OOhxjtN66lUecN6nQSKtyBUQbCIPeoR6lznCus6IUmLxr4/TxGwz/+d5zAbhw+Jk7wlC9G0SCmx9XA1GDiTqrK+Pfy87ivLfKNqujcoKcmCZA64gJbRMR7a7Mft6IGRuBwnavNVeRQwjlSFJZDf1qfQl+nMuqsWdQKLUIKflCUiybSAXMXMpMGrLQ1+CkAW92arSJ4nOs1064+0a5PjX/JT5uBeO7pID7UKEwTyqeOSgj/mMNwXzE60fyCZ4bddyziZEIcLfy65ek7D3tdqXL4HT5Emv04JKSP38IardJfYoZK/SztAOBgkIuwkatqsFtPqPxyJVwsN394qgKkqwnNskr1UpQuZc= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(189002)(199003)(6806004)(76176999)(19580395003)(85426001)(104016003)(19580405001)(50466002)(105606002)(48376002)(5001860100001)(33646002)(64706001)(47776003)(50226001)(92566002)(87936001)(50986999)(46102003)(229853001)(36756003)(2351001)(110136002)(2950100001)(106466001)(189998001)(5007970100001)(62966003)(68736005)(5003940100001)(97736004)(5001830100001)(4001540100001)(77156002)(81156007)(77096005)(5001960100002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB556;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB556;2:hE6quHA1QiYrF0EewYIJfFE9QsxNH4g/BHtpJ1LaAdymSifCd3ZYJYwrIrmQyUqCV9YI1K/9+sch8Gz/dcXS7OFZKqWPcLPCuqvzHSvfqeVe2uzsqeeWpfqfIZkgTpT/DyuBPxHVdCNse6sfdiKbnrFsTAievN1cq943zxkIBTM=;3:w2m1dMQgAzAa4kB14U4FXc+nCML0IJn4Ntyh1ZZJrHBWsGOA9b4FyTijiayZVhlUlb9M+avgE0ELdIxm5KojeQGqciZ7oOmf0cLmne+DMfUApFVp4GMupAvvr/yBcCieQFc6YvUI6DCyTXPJ2dzW5mmr8PU05CjQFfg/xM2xdfud5NnQld4UwK+Njwv+8D/rvhE+XWRMwKB5XyI8CUAi5kHlV/tqPeRtlgigEK8sc/w=;25:X0GxrwQtDMbWdRwkF9beNOyKOHtd2ruaQXHlaFfTxi34uA/L+Ad32Vj2xSu7k28bBdQr9twmCw/6dqvclfssfQWGo8BaRw4rMVKsGoMgOyRqFzin7byPXgQRqCdDe9fDBeLFyShNpuw9Dx6V1MghIGmdNaDp1tLbkacTIvI13ovWPB7cet96+LkeqPeEbUt5/8OTzTaYH3vj8hroa7elwrM05tBOsPTiR7A+LNY0ktjaCnZfWBAcr2ZmiCLDBCGM X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB556; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB556;20:pFqpkRJb0eBLZFX54MTiSrpBDErVPLUqFk1CjfjEdtldJYsGHRTHSQwVSuBvrCYUsOewN29Wk+CcoCNZiT7f9pm5uJDMJKF7iO8s1mXNLcS5CW459mWqdiuYqiLD7vYo2CvbOkvlIkXpJfikmeon0bXbPwj9pJ6pMaI1GeuMrnsIamjeiJpOsbheRLshDtHP3xA5KyUjVDox86hB89D7vbjhY6+ywtHfFXgyWyrG+71c99axlrxuzzm6vv0jkKlaQrIh3FOTkfbLkleLFcYy+hDabA0sorC2lyfA8unrkJcNswtavITpROpdDUL/6BvzVq1hzGmVukfjZVvKMzzpIsD7MIkC34YW3OHh428PUc0=;4:lJINbziaNeAfKmBwaW88aLU9HIKKjuY80mfW58bFwbs7EF7XtD6729Q9OlIqO8MK5fNKZWrGpuAhbJn9C9Ree1bOdzNeIuaRm5PbcJxLnJ/q/J0oscnmiu+9wcJlTIPCczvmasPt6uuYwR9DV+VSTJIaofbpdgzGmiwooYJ1nOOzcj5r+M81HyS4iuQ23b/boEuvuLRGV0+KRrow2yiJpRpbNxTK9qkuxQxr5PhN784LgpYZWaKsK1Ax2MycoFq2hfwx/yF587u4QmgUTM1jR8+hUrFf2wQS5aGlQY4+8X2ANXROB/yubkq29wu0B1TV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:BY2PR03MB556;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB556; X-Forefront-PRVS: 0682FC00E8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB556;23:XhrZHuUBfEFgAbaEnLHa4RSNGq5VcPAa5FpiUf7a6B?= =?us-ascii?Q?/b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fzB154R6eS+gbYVvj?= =?us-ascii?Q?VAecZvOYSF7xZVE1qnk20aQUDet27M/NdkLlVyQo+pLpttJlI7K+yk4q8ybu?= =?us-ascii?Q?JA1bTCq7st81+iDr3jIkaYCy4ex0xTgozv7v4bO3JCaCTEWL1nagFHGlq1j4?= =?us-ascii?Q?Vk9/I5gHobciaicwW6gqII0OX3zvyM60hES5nq5ae5cAdeeQxPZhjeZ7Xvh9?= =?us-ascii?Q?xW8pz4v13BXyrGwsqYfSot7RrmoC4w?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB556;5:X2tdmdtzrM00cJmseISmJ87iTTJKJ6Q8kDuarPaFKR7pRgatd3VUNTQ04IPmAsNi9oEc4V3tH/It5eTzdP15r08oeujPYkKpDU4DtQXvg4/QxNzrRA1sCo+LKAbn0V5Y2m9q/qOb/yT/7WSJIa6Cgg==;24:aZ8noPR1B5StcczxKMRfDJmbtGZ9Nq9nnKSSYnccIwKYlA0gJ/pgndBG+DEd/nlv2pfZ5xiRhdRZFFaH+ziDKRgQn8JcWNIgXwR06yJV3A4=;20:0DMn2NJ6cdFn8011LK6nF/GuDN1UsMFET1aHU7vk43LyAsoomT4/zf0UpDymyOvqCFRjYmtorTwqr6gvK8+vcg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2015 19:41:43.5772 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB556 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5656 Lines: 196 From: Huang Shijie The patch support i.MX7D platform by adding extra DMA clock. Deep Sleep Mode(dsm) turns off the power for APBH DMA module, add suspend/resume function and re-init the APBH DMA during resume. Signed-off-by: Huang Shijie Signed-off-by: Han Xu Signed-off-by: Adrian Alonso --- drivers/dma/mxs-dma.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index 60de352..5be13ad 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c @@ -1,5 +1,5 @@ /* - * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved. * * Refer to drivers/dma/imx-sdma.c * @@ -28,7 +28,6 @@ #include #include #include - #include #include "dmaengine.h" @@ -135,6 +134,7 @@ enum mxs_dma_devtype { enum mxs_dma_id { IMX23_DMA, IMX28_DMA, + IMX7D_DMA, }; struct mxs_dma_engine { @@ -142,6 +142,7 @@ struct mxs_dma_engine { enum mxs_dma_devtype type; void __iomem *base; struct clk *clk; + struct clk *clk_io; struct dma_device dma_device; struct device_dma_parameters dma_parms; struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS]; @@ -167,6 +168,9 @@ static struct mxs_dma_type mxs_dma_types[] = { }, { .id = IMX28_DMA, .type = MXS_DMA_APBX, + }, { + .id = IMX7D_DMA, + .type = MXS_DMA_APBH, } }; @@ -184,6 +188,9 @@ static const struct platform_device_id mxs_dma_ids[] = { .name = "imx28-dma-apbx", .driver_data = (kernel_ulong_t) &mxs_dma_types[3], }, { + .name = "imx7d-dma-apbh", + .driver_data = (kernel_ulong_t) &mxs_dma_types[4], + }, { /* end of list */ } }; @@ -193,6 +200,7 @@ static const struct of_device_id mxs_dma_dt_ids[] = { { .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], }, { .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], }, { .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], }, + { .compatible = "fsl,imx7d-dma-apbh", .data = &mxs_dma_ids[4], }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids); @@ -440,6 +448,12 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan) if (ret) goto err_clk; + if (mxs_dma->dev_id == IMX7D_DMA) { + ret = clk_prepare_enable(mxs_dma->clk_io); + if (ret) + goto err_clk_unprepare; + } + mxs_dma_reset_chan(chan); dma_async_tx_descriptor_init(&mxs_chan->desc, chan); @@ -450,6 +464,8 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan) return 0; +err_clk_unprepare: + clk_disable_unprepare(mxs_dma->clk); err_clk: free_irq(mxs_chan->chan_irq, mxs_dma); err_irq: @@ -471,6 +487,9 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan) dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE, mxs_chan->ccw, mxs_chan->ccw_phys); + if (mxs_dma->dev_id == IMX7D_DMA) + clk_disable_unprepare(mxs_dma->clk_io); + clk_disable_unprepare(mxs_dma->clk); } @@ -693,7 +712,7 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan, return mxs_chan->status; } -static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) +static int mxs_dma_init(struct mxs_dma_engine *mxs_dma) { int ret; @@ -701,6 +720,12 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) if (ret) return ret; + if (mxs_dma->dev_id == IMX7D_DMA) { + ret = clk_prepare_enable(mxs_dma->clk_io); + if (ret) + goto err_out; + } + ret = stmp_reset_block(mxs_dma->base); if (ret) goto err_out; @@ -803,9 +828,19 @@ static int __init mxs_dma_probe(struct platform_device *pdev) if (IS_ERR(mxs_dma->base)) return PTR_ERR(mxs_dma->base); - mxs_dma->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(mxs_dma->clk)) - return PTR_ERR(mxs_dma->clk); + if (mxs_dma->dev_id == IMX7D_DMA) { + mxs_dma->clk = devm_clk_get(&pdev->dev, "dma_apbh_bch"); + if (IS_ERR(mxs_dma->clk)) + return PTR_ERR(mxs_dma->clk); + mxs_dma->clk_io = devm_clk_get(&pdev->dev, "dma_apbh_io"); + if (IS_ERR(mxs_dma->clk_io)) + return PTR_ERR(mxs_dma->clk_io); + + } else { + mxs_dma->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(mxs_dma->clk)) + return PTR_ERR(mxs_dma->clk); + } dma_cap_set(DMA_SLAVE, mxs_dma->dma_device.cap_mask); dma_cap_set(DMA_CYCLIC, mxs_dma->dma_device.cap_mask); @@ -835,6 +870,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev) mxs_dma->pdev = pdev; mxs_dma->dma_device.dev = &pdev->dev; + dev_set_drvdata(&pdev->dev, mxs_dma); /* mxs_dma gets 65535 bytes maximum sg size */ mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms; @@ -872,9 +908,25 @@ static int __init mxs_dma_probe(struct platform_device *pdev) return 0; } +static int mxs_dma_pm_resume(struct device *dev) +{ + struct mxs_dma_engine *mxs_dma = dev_get_drvdata(dev); + int ret; + + ret = mxs_dma_init(mxs_dma); + if (ret) + return ret; + return 0; +} + +static const struct dev_pm_ops mxs_dma_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(NULL, mxs_dma_pm_resume) +}; + static struct platform_driver mxs_dma_driver = { .driver = { .name = "mxs-dma", + .pm = &mxs_dma_pm_ops, .of_match_table = mxs_dma_dt_ids, }, .id_table = mxs_dma_ids, -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/