From patchwork Tue Jan 2 09:28:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Jaggi X-Patchwork-Id: 123100 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8755034qgn; Tue, 2 Jan 2018 01:31:07 -0800 (PST) X-Google-Smtp-Source: ACJfBotWYsjJnhM3+5Xd30ZzghErlI9/GEgQNKxa2Mqs3uQHby2M6c7seZxzMc8iFp8o98aVP63i X-Received: by 10.107.30.71 with SMTP id e68mr2610973ioe.289.1514885467070; Tue, 02 Jan 2018 01:31:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514885467; cv=none; d=google.com; s=arc-20160816; b=GMaAXhnR8BdgVe3ty+6tzcWzej/J/nq1rj5eGoCgl2lPCQzu0gKathYr9iZFfIJ/VK nuDO8DA+f/eQDnEuiLZ1LlartxUIb3ME1y9qDjl0NVpFA9XH3ulUyb1ultNLVekGQ0lj w086uVlLFCPrR6PaxwUuyjECOWPhGXB4Zec+vqaAcAGKzoTYzSNHao55LfFTUmAQO5a0 bmznwZR8IhFR24mu7IK+ET3jWddPguNg1GW+dcKo3l591b0gPCKmQtK8u7Z0XoXwGUQT IYrjihPM86bIqTq4kAoko8cAT/cJTtD/543/cHGVubnkYvpejBphIuHC8rrj57boAj/h JbNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=aHK5IU92NSbUdvBunRgAQyppMjuwnm/tPVq5rF36Idc=; b=LKBDVsx2c4+MSy26Un8HC5R+W9qWzguSy0HqSj/qJn5wSoYdh2vCn5J5j4JyLT9iM0 tbj+iFbNR53lzEw+7ezGavLEh0UY6bEErz0wK4XHZ5n/t5tcJaJOZ6oMhyUmrCMQxSfR F09c9OEH5hl+t7xjL2suXRjXJspk0ej7rbP896jxdBGq2XSbKIaZVmE7V3NMC+V1Qn6/ qpRwrEtO2ZxBI05w1hbi6ypOHaP7nmVshIi+bQSoMb7jCAXk46/o0zIlyDdiAqp/giKK RGpJPg+Hr/DaZrt5hOMgZDsVvA1vlt4MuGCDsoxzeLQjHDKK0Hxn8AUt62jqdd7hqRbt olSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FamnA6su; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h71si27759513ioi.177.2018.01.02.01.31.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 01:31:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FamnA6su; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWIsN-0002Wf-Ae; Tue, 02 Jan 2018 09:28:51 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWIsM-0002Vc-9R for xen-devel@lists.xenproject.org; Tue, 02 Jan 2018 09:28:50 +0000 X-Inumbo-ID: 2f334a1f-ef9f-11e7-b4a6-bc764e045a96 Received: from mail-pl0-x242.google.com (unknown [2607:f8b0:400e:c01::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2f334a1f-ef9f-11e7-b4a6-bc764e045a96; Tue, 02 Jan 2018 10:27:43 +0100 (CET) Received: by mail-pl0-x242.google.com with SMTP id n13so28332709plp.11 for ; Tue, 02 Jan 2018 01:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mz2B3yZ1mrabHer7L0f+I0SN726208c7ofzCW0c5FqE=; b=FamnA6suEVyYgl23KTv7fwyIyiUUfz5RJ94ViU+L16WvdU90THUt3jMCBVPN/ic0go IG8THSNLR/l3ymzHDs7DmloMn7Cn5pdhepEIuEcSiaucXzQbcwaArdRbKPi5UgxgarBo OyBabE6mzn6KybK16tCVbIJ0nImVm3zZfDBq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mz2B3yZ1mrabHer7L0f+I0SN726208c7ofzCW0c5FqE=; b=DBjzxMn507FioOVd3kXdh52GNx4XpNp8yCwKArFygaaxahxdp4yWHkDtmtFpLGERu/ 15BCXzJX7Vrino0IpP99YybZECTGC5pwcFz80XuXVXjnWvJnqHXwUVNweHB1+LrzA9tZ Hahln1LXvFgc6/9LZxIM/YJWvXcH6MkgF/Tq+VtAay6YLNY1PHpI0Kg37hrv442tchUn uQRUSmSfdynrE4j8NPlQWM+WqJaXxZmcY6Oj2d3vFNhhswnPipjEMQA47o92HimoJNp8 MglwNqeOc6VzCbUqMogBWt04hcBHrCdS/I50cxhznJrGhCLgnXpe08JZevekYlHjAXJy 8JHw== X-Gm-Message-State: AKGB3mJWlO83gHoKY3bnqRfkRXE/E4DLq/M7UMf+tN7hXmi8n+LUHXYk IOn8PkCiPpzZRqtKGyUZyiYKXX6kh/U= X-Received: by 10.159.218.72 with SMTP id x8mr45678518plv.148.1514885328436; Tue, 02 Jan 2018 01:28:48 -0800 (PST) Received: from thunder-dev-box.domain.name ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id e8sm22065207pgs.44.2018.01.02.01.28.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 01:28:47 -0800 (PST) From: manish.jaggi@linaro.org To: xen-devel@lists.xenproject.org, julien.grall@linaro.org, sameer.goel@linaro.org, andre.przywara@linaro.org Date: Tue, 2 Jan 2018 14:58:03 +0530 Message-Id: <20180102092809.1841-6-manish.jaggi@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180102092809.1841-1-manish.jaggi@linaro.org> References: <20180102092809.1841-1-manish.jaggi@linaro.org> Cc: Manish Jaggi , manish.jaggi@cavium.com Subject: [Xen-devel] [RFC 05/11] Import fwnode.h from linux X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Manish Jaggi Import fwnode.h from linux kernel tag v4.14 Signed-off-by: Manish Jaggi --- xen/include/xen/fwnode.h | 125 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/xen/include/xen/fwnode.h b/xen/include/xen/fwnode.h new file mode 100644 index 0000000000..af186a9dc6 --- /dev/null +++ b/xen/include/xen/fwnode.h @@ -0,0 +1,125 @@ +/* + * fwnode.h - Firmware device node object handle type definition. + * + * Copyright (C) 2015, Intel Corporation + * Author: Rafael J. Wysocki + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _LINUX_FWNODE_H_ +#define _LINUX_FWNODE_H_ + +#include + +struct fwnode_operations; + +struct fwnode_handle { + struct fwnode_handle *secondary; + const struct fwnode_operations *ops; +}; + +/** + * struct fwnode_endpoint - Fwnode graph endpoint + * @port: Port number + * @id: Endpoint id + * @local_fwnode: reference to the related fwnode + */ +struct fwnode_endpoint { + unsigned int port; + unsigned int id; + const struct fwnode_handle *local_fwnode; +}; + +#define NR_FWNODE_REFERENCE_ARGS 8 + +/** + * struct fwnode_reference_args - Fwnode reference with additional arguments + * @fwnode:- A reference to the base fwnode + * @nargs: Number of elements in @args array + * @args: Integer arguments on the fwnode + */ +struct fwnode_reference_args { + struct fwnode_handle *fwnode; + unsigned int nargs; + unsigned int args[NR_FWNODE_REFERENCE_ARGS]; +}; + +/** + * struct fwnode_operations - Operations for fwnode interface + * @get: Get a reference to an fwnode. + * @put: Put a reference to an fwnode. + * @property_present: Return true if a property is present. + * @property_read_integer_array: Read an array of integer properties. Return + * zero on success, a negative error code + * otherwise. + * @property_read_string_array: Read an array of string properties. Return zero + * on success, a negative error code otherwise. + * @get_parent: Return the parent of an fwnode. + * @get_next_child_node: Return the next child node in an iteration. + * @get_named_child_node: Return a child node with a given name. + * @get_reference_args: Return a reference pointed to by a property, with args + * @graph_get_next_endpoint: Return an endpoint node in an iteration. + * @graph_get_remote_endpoint: Return the remote endpoint node of a local + * endpoint node. + * @graph_get_port_parent: Return the parent node of a port node. + * @graph_parse_endpoint: Parse endpoint for port and endpoint id. + */ +struct fwnode_operations { + void (*get)(struct fwnode_handle *fwnode); + void (*put)(struct fwnode_handle *fwnode); + bool (*device_is_available)(const struct fwnode_handle *fwnode); + bool (*property_present)(const struct fwnode_handle *fwnode, + const char *propname); + int (*property_read_int_array)(const struct fwnode_handle *fwnode, + const char *propname, + unsigned int elem_size, void *val, + size_t nval); + int + (*property_read_string_array)(const struct fwnode_handle *fwnode_handle, + const char *propname, const char **val, + size_t nval); + struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode); + struct fwnode_handle * + (*get_next_child_node)(const struct fwnode_handle *fwnode, + struct fwnode_handle *child); + struct fwnode_handle * + (*get_named_child_node)(const struct fwnode_handle *fwnode, + const char *name); + int (*get_reference_args)(const struct fwnode_handle *fwnode, + const char *prop, const char *nargs_prop, + unsigned int nargs, unsigned int index, + struct fwnode_reference_args *args); + struct fwnode_handle * + (*graph_get_next_endpoint)(const struct fwnode_handle *fwnode, + struct fwnode_handle *prev); + struct fwnode_handle * + (*graph_get_remote_endpoint)(const struct fwnode_handle *fwnode); + struct fwnode_handle * + (*graph_get_port_parent)(struct fwnode_handle *fwnode); + int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode, + struct fwnode_endpoint *endpoint); +}; + +#define fwnode_has_op(fwnode, op) \ + ((fwnode) && (fwnode)->ops && (fwnode)->ops->op) +#define fwnode_call_int_op(fwnode, op, ...) \ + (fwnode ? (fwnode_has_op(fwnode, op) ? \ + (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \ + -EINVAL) +#define fwnode_call_bool_op(fwnode, op, ...) \ + (fwnode ? (fwnode_has_op(fwnode, op) ? \ + (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : false) : \ + false) +#define fwnode_call_ptr_op(fwnode, op, ...) \ + (fwnode_has_op(fwnode, op) ? \ + (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL) +#define fwnode_call_void_op(fwnode, op, ...) \ + do { \ + if (fwnode_has_op(fwnode, op)) \ + (fwnode)->ops->op(fwnode, ## __VA_ARGS__); \ + } while (false) + +#endif