From patchwork Sat Apr 19 14:32:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 28660 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5ABCC20553 for ; Sat, 19 Apr 2014 14:34:58 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id m5sf9634851qaj.5 for ; Sat, 19 Apr 2014 07:34:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=8Is6FFYxodtUnsnvlixGVw6fs1v7+pkKUkWiEJmX8R4=; b=FSKynAb98jj8KqVgauZXDc1qSy1ZFEcYK6RGHPMGKX3QVmRdMU284CcnNpVFF6ZdlR 8dtm3r/bE1LGTNA1p45jajj5KLfvTGWyxgNF8cgl1g6AxiL54bLh85bGfcyIZhm2AeL7 j2wZPoK3fY8Oi1CtYzrXUCLdeVHY25BM9/c0HnSPle9sIRByXgv09K4OwxkUukrjPs8Z tSCO5KLbIpPg2dkcjWLXjz1eEaei4dZeAHoJ45IxHPihqrPQPlaQvy+Pa/mx/H21t7iM C1b56mqawn2RXIUhn5cAWmwaEJt+aubBImPbNBssesvxMMyAWDyJf3U+78l0+JbJ+CPB DV2g== X-Gm-Message-State: ALoCoQlIm1YIinGMVm8Ic+egwZAvIudX20jXQgcnK6TctPj0iSa3nJ1wjQCMWerurdVvCzU+nyJ7 X-Received: by 10.236.216.39 with SMTP id f37mr2573829yhp.57.1397918098169; Sat, 19 Apr 2014 07:34:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.177 with SMTP id t46ls1828357qgt.16.gmail; Sat, 19 Apr 2014 07:34:58 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr1323995vcb.28.1397918098012; Sat, 19 Apr 2014 07:34:58 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id m14si5449810vcn.125.2014.04.19.07.34.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 19 Apr 2014 07:34:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jx11so5010325veb.3 for ; Sat, 19 Apr 2014 07:34:57 -0700 (PDT) X-Received: by 10.58.202.133 with SMTP id ki5mr19253859vec.19.1397918097934; Sat, 19 Apr 2014 07:34:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp182198vcb; Sat, 19 Apr 2014 07:34:57 -0700 (PDT) X-Received: by 10.68.202.8 with SMTP id ke8mr28135123pbc.86.1397918097168; Sat, 19 Apr 2014 07:34:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id as3si17994437pbc.49.2014.04.19.07.34.56; Sat, 19 Apr 2014 07:34:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983AbaDSOei (ORCPT + 9 others); Sat, 19 Apr 2014 10:34:38 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:58691 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754271AbaDSOe1 (ORCPT ); Sat, 19 Apr 2014 10:34:27 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3JEXm8Q028711; Sat, 19 Apr 2014 09:33:48 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3JEXmiM012787; Sat, 19 Apr 2014 09:33:48 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Sat, 19 Apr 2014 09:33:47 -0500 Received: from ula0393909.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3JEXT31019097; Sat, 19 Apr 2014 09:33:47 -0500 From: Santosh Shilimkar To: CC: , , Santosh Shilimkar , Greg Kroah-Hartman , Russell King , Arnd Bergmann , Olof Johansson , Grant Likely , Rob Herring , Catalin Marinas , Linus Walleij , Grygorii Strashko Subject: [PATCH v2 3/7] of: introduce of_dma_is_coherent() helper Date: Sat, 19 Apr 2014 10:32:48 -0400 Message-ID: <1397917972-6293-4-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397917972-6293-1-git-send-email-santosh.shilimkar@ti.com> References: <1397917972-6293-1-git-send-email-santosh.shilimkar@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: santosh.shilimkar@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The of_dma_is_coherent() helper parses the given DT device node to see if the "dma-coherent" property is supported and returns true or false accordingly. If the arch is always coherent or always noncoherent, then the default DMA ops has to be specified accordingly. Cc: Greg Kroah-Hartman Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: Grant Likely Cc: Rob Herring Cc: Catalin Marinas Cc: Linus Walleij Signed-off-by: Santosh Shilimkar Signed-off-by: Grygorii Strashko --- drivers/of/platform.c | 23 +++++++++++++++++++++++ include/linux/of_platform.h | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 2265a55..573db15 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -570,4 +570,27 @@ out: return ret; } EXPORT_SYMBOL_GPL(of_dma_get_range); + +/** + * of_dma_is_coherent - Check if device is coherent + * @np: device node + * + * It returns true if "dma-coherent" property was found + * for this device in DT. + */ +bool of_dma_is_coherent(struct device_node *np) +{ + struct device_node *node = of_node_get(np); + + while (node) { + if (of_property_read_bool(node, "dma-coherent")) { + of_node_put(node); + return true; + } + node = of_get_next_parent(node); + } + of_node_put(node); + return false; +} +EXPORT_SYMBOL_GPL(of_dma_is_coherent); #endif /* CONFIG_OF_ADDRESS */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index ba7d3dc..dc52931 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -74,6 +74,8 @@ extern int of_platform_populate(struct device_node *root, struct device *parent); extern int of_dma_get_range(struct device_node *np, dma_addr_t *dma_addr, phys_addr_t *paddr, phys_addr_t *size); +extern bool of_dma_is_coherent(struct device_node *np); + #else static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, @@ -88,6 +90,11 @@ static inline int of_dma_get_range(struct device_node *np, dma_addr_t *dma_addr, { return -ENODEV; } + +static inline bool of_dma_is_coherent(struct device_node *np) +{ + return false; +} #endif #endif /* _LINUX_OF_PLATFORM_H */