From patchwork Tue Dec 4 07:53:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 1836531 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 AD07F3FC71 for ; Tue, 4 Dec 2012 08:02:15 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TfnOn-0006dk-ND; Tue, 04 Dec 2012 07:58:37 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TfnOe-0006c4-DI for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2012 07:58:29 +0000 Received: from penbh01.corp.atmel.com ([10.168.5.31]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id qB47qxxH014406; Mon, 3 Dec 2012 23:53:02 -0800 (PST) Received: from penmb01.corp.atmel.com ([10.168.5.33]) by penbh01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 4 Dec 2012 15:58:15 +0800 Received: from shaarm01.corp.atmel.com ([10.217.6.34]) by penmb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 4 Dec 2012 15:58:13 +0800 From: Wenyou Yang To: linux-arm-kernel@lists.infradead.org Subject: [v2 PATCH 01/14] of: add dma-mask binding Date: Tue, 4 Dec 2012 15:53:47 +0800 Message-Id: <1354607640-13229-2-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354607640-13229-1-git-send-email-wenyou.yang@atmel.com> References: <1354607640-13229-1-git-send-email-wenyou.yang@atmel.com> X-OriginalArrivalTime: 04 Dec 2012 07:58:13.0718 (UTC) FILETIME=[1C64E760:01CDD1F5] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121204_025828_759603_22DCF3F0 X-CRM114-Status: GOOD ( 11.31 ) 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.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: richard.genoud@gmail.com, JM.Lin@atmel.com, nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org, rob.herring@calxeda.com, wenyou.yang@atmel.com, grant.likely@secretlab.ca, plagnioj@jcrosoft.com, devicetree-discuss@lists.ozlabs.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: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jean-Christophe PLAGNIOL-VILLARD This will allow each device to specify its dma-mask for this we use the coherent_dma_mask as pointer. By default the dma-mask will be set to DMA_BIT_MASK(32). The microblaze architecture hook is drop Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: grant.likely@secretlab.ca Cc: rob.herring@calxeda.com Cc: devicetree-discuss@lists.ozlabs.org --- drivers/of/platform.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b80891b..31ed405 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -130,6 +130,21 @@ void of_device_make_bus_id(struct device *dev) dev_set_name(dev, "%s.%d", node->name, magic - 1); } +static void of_get_dma_mask(struct device *dev, struct device_node *np) +{ + const __be32 *prop; + int len; + + prop = of_get_property(np, "dma-mask", &len); + + dev->dma_mask = &dev->coherent_dma_mask; + + if (!prop) + dev->coherent_dma_mask = DMA_BIT_MASK(32); + else + dev->coherent_dma_mask = of_read_number(prop, len / 4); +} + /** * of_device_alloc - Allocate and initialize an of_device * @np: device node to assign to device @@ -171,10 +186,8 @@ struct platform_device *of_device_alloc(struct device_node *np, WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq); } + of_get_dma_mask(&dev->dev, np); dev->dev.of_node = of_node_get(np); -#if defined(CONFIG_MICROBLAZE) - dev->dev.dma_mask = &dev->archdata.dma_mask; -#endif dev->dev.parent = parent; if (bus_id) @@ -211,10 +224,6 @@ struct platform_device *of_platform_device_create_pdata( if (!dev) return NULL; -#if defined(CONFIG_MICROBLAZE) - dev->archdata.dma_mask = 0xffffffffUL; -#endif - dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); dev->dev.bus = &platform_bus_type; dev->dev.platform_data = platform_data;