From patchwork Thu Nov 8 05:30:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 12750 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 BED5D23E00 for ; Thu, 8 Nov 2012 05:28:05 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 569ABA180D9 for ; Thu, 8 Nov 2012 05:28:05 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so1629141iag.11 for ; Wed, 07 Nov 2012 21:28:04 -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=UNa2A946jr44Qq8Hrrq255kiwDjhtAM/Pao92rV/XhY=; b=PQvpZng7k6x6FSF+DHuFJTruprHVhLlc6eQ9UgOfzoVQj72ZdKx3qMdNlOWkY1lkll ZZdPVDlceaNyGH8mfn0PcOejyR+zuTCHffVm4cXC1r/ytVI75/iKEnwdmE7zqYk65iRz O1zrvdi/CGMHzI1Z4Vxmb9404bQ5DXTzGyHbkcrAp0oi8NMlg/Bs1ItBIDX69w0e1UDe lc+FieTvsfVk2fLN8QiDRlZ3a3656Yrdpd9iWxg/vrwFdhIraa5pOItCvp2YHjlGZPkk dkJnpAhcr2G60ya3Hxsgko9YVJ/LgEuylbfooxSQptFX1CyLtfYmAKWCXKMwtj3KKqOQ LuHg== Received: by 10.50.173.34 with SMTP id bh2mr6893035igc.70.1352352484684; Wed, 07 Nov 2012 21:28:04 -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 n20csp325042igt; Wed, 7 Nov 2012 21:28:04 -0800 (PST) Received: by 10.68.209.230 with SMTP id mp6mr13998497pbc.8.1352352484054; Wed, 07 Nov 2012 21:28:04 -0800 (PST) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id bo5si33840628pab.276.2012.11.07.21.28.03; Wed, 07 Nov 2012 21:28:04 -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 epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MD5006SXLU6QVP0@mailout4.samsung.com>; Thu, 08 Nov 2012 14:28:03 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 24.A0.12699.2E24B905; Thu, 08 Nov 2012 14:28:03 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-81-509b42e24046 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 93.A0.12699.2E24B905; Thu, 08 Nov 2012 14:28:02 +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 <0MD500D18LOC2U10@mmp2.samsung.com>; Thu, 08 Nov 2012 14:28:02 +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] FDT: Api to find compatible id for a given node Date: Thu, 08 Nov 2012 11:00:01 +0530 Message-id: <1352352603-17114-5-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1352352603-17114-1-git-send-email-rajeshwari.s@samsung.com> References: <1352352603-17114-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsWyRsSkWvex0+wAg4tNjBYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyHnV/YSvYzFtxYO1hlgbGy1xdjJwcEgImElPuvWGE sMUkLtxbzwZiCwksZZRomcoMU3Nw6hzWLkYuoPh0RonW/bPZIJyJTBK9i5qZQKrYBIwktp6c BjZJREBC4lf/VTCbWSBD4vaHJSwgtrCAi8TON6fBNrAIqEq82vELrIZXwEPi2bLFbBDbFCSO Tf3KCmJzCnhKrPv4nRHiIg+JX/sns0P0Ckh8m3wIaCYHUL2sxKYDzCD3SAjcZpOYdOITK8Qc SYmDK26wTGAUXsDIsIpRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMjMBxP/3smvYNxVYPFIUYB DkYlHl4NydkBQqyJZcWVuYcYJTiYlUR4pxyZFSDEm5JYWZValB9fVJqTWnyI0QfokonMUqLJ +cBYySuJNzQ2MTc1NrU0MjIzNcUhrCTO2+yREiAkkJ5YkpqdmlqQWgQzjomDU6qBsVrg07Nw 6XnXRKbM3revP/HRCvGWcNu5O2P2sCzflOfJMin4ksHu98JZYS+O7Jb6frXZaMmEl6uvNf7j a17pLmDqcPJr7LSsmwcjssIrnm2TCmUNfheTlXDJafvxAxd7Ovh2HJ4/cU3b/9MH9mfdYZQ+ 2NhWtdlfY/IhuWtfc7e/a7x60rtEo1mJpTgj0VCLuag4EQCOY13JdAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsVy+t9jQd1HTrMDDDr+GFo8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzHjU/YWtYDNv xYG1h1kaGC9zdTFyckgImEgcnDqHFcIWk7hwbz1bFyMXh5DAdEaJ1v2zoZyJTBK9i5qZQKrY BIwktp6cxghiiwhISPzqvwpmMwtkSNz+sIQFxBYWcJHY+eY0G4jNIqAq8WrHL7AaXgEPiWfL FrNBbFOQODb1K9hmTgFPiXUfv4PVCAHV/No/mX0CI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV5 6XrJ+bmbGMHh/kx6B+OqBotDjAIcjEo8vBqSswOEWBPLiitzDzFKcDArifBOOTIrQIg3JbGy KrUoP76oNCe1+BCjD9BVE5mlRJPzgbGYVxJvaGxibmpsamliYWJmiUNYSZy32SMlQEggPbEk NTs1tSC1CGYcEwenVAOjUvL6uHVlNXf5Y/r0Tj6LlV6Q8o0jJnqaZJy9Q/GLORd2B6UyyJ46 ljAl6nlExPcMZwMbH5ZiV74jZovc8zokozcbrdi48PfyY7tfblwVX+x/acpOD8aK//9WBU+r YXJ5pNrz+Bx73eW1fE4SpW2/ux5pqa86sjzPx47hvRdDaYOKjd15l8NKLMUZiYZazEXFiQCo 5NgwpAIAAA== X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmmxSFYiQKT1gK+XLF9f7qeZU45tmASj941GudQXQfU35pO0qnBEPij/XkAtrhl3tbMJ6/i This patch adds api to find compatible id for a given FDT node Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass --- 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; +}