From patchwork Wed Nov 14 09:11:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 12834 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 035C223FC1 for ; Wed, 14 Nov 2012 09:24:04 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8F35CA188D6 for ; Wed, 14 Nov 2012 09:24:03 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so260136iej.11 for ; Wed, 14 Nov 2012 01:24:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :dlp-filter:x-mtr:x-brightmail-tracker:x-brightmail-tracker :x-cfilter-loop:x-gm-message-state; bh=TqMt6TXyGMv8ZIPjIm/duhKKhBrRfeiBUphzLaUnPWk=; b=N1+qHjbrCxkWI7L0Cdb+UOoaIqreMn1RWlHJ16Uijyn89JV4yloW7Nn2kgJyByV7EF gIlhpNJ8s3hb6mucyik6cTjBaMxlNlMmwgtvfbjCaT4DsWpAf9IES7cG8hxlwvEIBM5i VdlGDt+Nj4FJctG9zCrXctrtBK1JH6uVmDejx1DAkPkZlNymE9448OWiNUoPBqOjtLBZ toQtXQ9zD/WPrIwOIsuMbyTipAREJ3Nncdc8mt6c6mo/Et57684o3Joqd9GS/3FwV3HI eS0ZgSFkosVQ8j7luKjmVytzAP7MeQCvclqxZZIhl0gnRacZfrjUWneSMnEJTHaU+s+F 3B0g== Received: by 10.43.7.132 with SMTP id oo4mr23723018icb.6.1352885042992; Wed, 14 Nov 2012 01:24:02 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp633323igt; Wed, 14 Nov 2012 01:24:02 -0800 (PST) Received: by 10.68.233.136 with SMTP id tw8mr70235260pbc.133.1352885042383; Wed, 14 Nov 2012 01:24:02 -0800 (PST) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id m8si17379919pav.162.2012.11.14.01.24.02; Wed, 14 Nov 2012 01:24:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.34 as permitted sender) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.34 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDH00K9102XWJC0@mailout4.samsung.com>; Wed, 14 Nov 2012 18:08:57 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 31.F8.01231.9AF53A05; Wed, 14 Nov 2012 18:08:57 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-f8-50a35fa9dd90 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id E0.F8.01231.9AF53A05; Wed, 14 Nov 2012 18:08:57 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDG00I7CZWU0Z70@mmp2.samsung.com>; Wed, 14 Nov 2012 18:08:57 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, hs@denx.de Subject: [PATCH 4/6 V2] FDT: Api to find compatible id for a given node Date: Wed, 14 Nov 2012 14:41:17 +0530 Message-id: <1352884279-24067-5-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1352884279-24067-1-git-send-email-rajeshwari.s@samsung.com> References: <1352884279-24067-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsWyRsSkWndl/OIAgwMXtC0err/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlfGv/yFjwjbdi5sk+5gbGTu4uRk4OCQETiVPXzrBC 2GISF+6tZ+ti5OIQEljKKNE4bQYTTNGzhfeYIRLTGSU29N1jhHAmMkl8uTuPBaSKTcBIYuvJ aYwgtoiAhMSv/qtgNrNAhsTtD0vAaoQF3CWuzVwAFmcRUJVY9fw1WJxXwEPiYcsSqDMUJI5N /Qpmcwp4Svx/0ANmCwHVTN6xnQ2iV0Di2+RDQL0cQPWyEpsOMEO0XmeTuHtHGcKWlDi44gbL BEbhBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzECw/H0v2dSOxhXNlgcYhTgYFTi4f3Y uihAiDWxrLgy9xCjBAezkghvrNXiACHelMTKqtSi/Pii0pzU4kOMPkCHTGSWEk3OB8ZKXkm8 obGJuamxqaWRkZmpKQ5hJXHeZo+UACGB9MSS1OzU1ILUIphxTBycUg2Mc+KfMixdul38SZnT CVOH6EUGSxcH9ysuL619tWG6+tFIPy2ZMzoXL2Q7r1C4HONRmq7as/9E4MHdh7wnyTB/V7wp 21Pv27C34kXs6rJdKtMfNwtkG8QoHq5s+uRvmSsiuLB0qdLyu2abdR6xLLbbWPnu2IzJhQGZ rZ0v7dt3vfVYrvdftzRBiaU4I9FQi7moOBEAKbm68nQCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsVy+t9jQd2V8YsDDF6fU7B4uP4mi8WUw19Y HJg87lzbwxbAGNXAaJORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+Ti E6DrlpkDNFtJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmPGt/SNjwTfe ipkn+5gbGDu5uxg5OSQETCSeLbzHDGGLSVy4t56ti5GLQ0hgOqPEhr57jBDORCaJL3fnsYBU sQkYSWw9OY0RxBYRkJD41X8VzGYWyJC4/WEJWI2wgLvEtZkLwOIsAqoSq56/BovzCnhIPGxZ wgqxTUHi2NSvYDangKfE/wc9YLYQUM3kHdvZJjDyLmBkWMUomlqQXFCclJ5rqFecmFtcmpeu l5yfu4kRHO7PpHYwrmywOMQowMGoxMP7sXVRgBBrYllxZe4hRgkOZiUR3lirxQFCvCmJlVWp RfnxRaU5qcWHGH2ArprILCWanA+MxbySeENjE3NTY1NLEwsTM0scwkrivM0eKQFCAumJJanZ qakFqUUw45g4OKUaGPnVp/y2tfZTSZttxtd+rYErYg2r/bZIScuFqTNSl73corBna9QM9WlX P0xMbZbRjA7T15SQ/3mU74RUkkqH7Dmr5vMPb109Y/i2Puxm66u+hKbUx8+fr7qxX/6wx/6Q vJYVZoXaTSerF05UnHbnfsHpnUc3nKsI9srIz5j+/YZrR8t0qyTebUosxRmJhlrMRcWJAITC OtGkAgAA X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQncpPqQWjQlTaqA6epEsQTdLciFUJFrLp7EIiHBRoeoAC+vbmRYxDSCDjMvhCfRlwOkgC5P This patch adds api to find compatible id for a given FDT node Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass Acked-by: Heiko Schocher --- Changes in V2: - None include/fdtdec.h | 14 ++++++++++++++ lib/fdtdec.c | 12 ++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index f9aac31..d501d7e 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -389,4 +389,18 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name, */ const u8 *fdtdec_locate_byte_array(const void *blob, int node, const char *prop_name, int count); + +/** + * Find the compatible ID for a given node. + * + * Generally each node has at least one compatible string attached to it. + * This function looks through our list of known compatible strings and + * returns the corresponding ID which matches the compatible string. + * + * @param blob FDT blob to use + * @param node Node containing compatible string to find + * @return compatible ID, or COMPAT_UNKNOWN if we cannot find a match + */ +enum fdt_compat_id fdtdec_lookup(const void *blob, int node); + #endif diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 6e8c24c..dbfca1a 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -516,3 +516,15 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node, return NULL; return cell; } + +enum fdt_compat_id fdtdec_lookup(const void *blob, int node) +{ + enum fdt_compat_id id; + + /* Search our drivers */ + for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++) + if (0 == fdt_node_check_compatible(blob, node, + compat_names[id])) + return id; + return COMPAT_UNKNOWN; +}