Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

device property: Add support for fwnode endpoints

Similar to OF endpoints, endpoint type nodes can be also supported on
ACPI. In order to make it possible for drivers to ignore the matter,
add a type for fwnode_endpoint and a function to parse them.

On ACPI, find the child node index instead of relying on the "endpoint"
property.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Sakari Ailus and committed by
Rafael J. Wysocki
2bd5452d e44bb0cb

+47
+32
drivers/base/property.c
··· 1311 1311 return endpoint; 1312 1312 } 1313 1313 EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint); 1314 + 1315 + /** 1316 + * fwnode_graph_parse_endpoint - parse common endpoint node properties 1317 + * @fwnode: pointer to endpoint fwnode_handle 1318 + * @endpoint: pointer to the fwnode endpoint data structure 1319 + * 1320 + * Parse @fwnode representing a graph endpoint node and store the 1321 + * information in @endpoint. The caller must hold a reference to 1322 + * @fwnode. 1323 + */ 1324 + int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, 1325 + struct fwnode_endpoint *endpoint) 1326 + { 1327 + struct fwnode_handle *port_fwnode = fwnode_get_parent(fwnode); 1328 + 1329 + memset(endpoint, 0, sizeof(*endpoint)); 1330 + 1331 + endpoint->local_fwnode = fwnode; 1332 + 1333 + if (is_acpi_node(port_fwnode)) { 1334 + fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); 1335 + fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); 1336 + } else { 1337 + fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port); 1338 + fwnode_property_read_u32(fwnode, "reg", &endpoint->id); 1339 + } 1340 + 1341 + fwnode_handle_put(port_fwnode); 1342 + 1343 + return 0; 1344 + } 1345 + EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
+12
include/linux/fwnode.h
··· 27 27 struct fwnode_handle *secondary; 28 28 }; 29 29 30 + /** 31 + * struct fwnode_endpoint - Fwnode graph endpoint 32 + * @port: Port number 33 + * @id: Endpoint id 34 + * @local_fwnode: reference to the related fwnode 35 + */ 36 + struct fwnode_endpoint { 37 + unsigned int port; 38 + unsigned int id; 39 + const struct fwnode_handle *local_fwnode; 40 + }; 41 + 30 42 #endif
+3
include/linux/property.h
··· 280 280 struct fwnode_handle *fwnode_graph_get_remote_endpoint( 281 281 struct fwnode_handle *fwnode); 282 282 283 + int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, 284 + struct fwnode_endpoint *endpoint); 285 + 283 286 #endif /* _LINUX_PROPERTY_H_ */