aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-09 13:28:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-09 13:28:47 -0400
commit0415052db4f92b7e272fc15802ad8b8be672deea (patch)
tree6273d2ecfa56fa21a94e1c8f632e5fefa5f3baa3 /include/linux
parent4b4704520d97b74e045154fc3b844b73ae4e7ebd (diff)
parent33ee09cd59ce154b64f9df942dfa5456db90d5f9 (diff)
Merge tag 'devprop-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "These add helpers for counting items in a property array and extend the "software nodes" support to be more convenient for representing device properties supplied by drivers and make the intel_cht_int33fe driver use that. Specifics: - Add helpers to count items in a property array (Andy Shevchenko). - Extend "software nodes" support to be more convenient for representing device properties supplied by drivers (Heikki Krogerus). - Add device_find_child_by_name() helper to the driver core (Heikki Krogerus). - Extend device connection code to also look for references provided via fwnode pointers (Heikki Krogerus). - Start to register proper struct device objects for USB Type-C muxes and orientation switches (Heikki Krogerus). - Update the intel_cht_int33fe driver to describe devices in a more general way with the help of "software nodes" (Heikki Krogerus)" * tag 'devprop-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: device property: Add helpers to count items in an array platform/x86: intel_cht_int33fe: Replacing the old connections with references platform/x86: intel_cht_int33fe: Supply fwnodes for the external dependencies platform/x86: intel_cht_int33fe: Provide fwnode for the USB connector platform/x86: intel_cht_int33fe: Provide software nodes for the devices platform/x86: intel_cht_int33fe: Remove unused fusb302 device property platform/x86: intel_cht_int33fe: Register max17047 in its own function usb: typec: Registering real device entries for the muxes device connection: Find connections also by checking the references device property: Introduce fwnode_find_reference() ACPI / property: Don't limit named child node matching to data nodes driver core: Add helper device_find_child_by_name() software node: Add software_node_get_reference_args() software node: Use kobject name when finding child nodes by name software node: Add support for static node descriptors software node: Simplify software_node_release() function software node: Allow node creation without properties
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h2
-rw-r--r--include/linux/property.h95
-rw-r--r--include/linux/usb/typec_mux.h62
3 files changed, 125 insertions, 34 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index b6ff25d9fff4..adfcabcba8a1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1255,6 +1255,8 @@ extern int device_for_each_child_reverse(struct device *dev, void *data,
1255 int (*fn)(struct device *dev, void *data)); 1255 int (*fn)(struct device *dev, void *data));
1256extern struct device *device_find_child(struct device *dev, void *data, 1256extern struct device *device_find_child(struct device *dev, void *data,
1257 int (*match)(struct device *dev, void *data)); 1257 int (*match)(struct device *dev, void *data));
1258extern struct device *device_find_child_by_name(struct device *parent,
1259 const char *name);
1258extern int device_rename(struct device *dev, const char *new_name); 1260extern int device_rename(struct device *dev, const char *new_name);
1259extern int device_move(struct device *dev, struct device *new_parent, 1261extern int device_move(struct device *dev, struct device *new_parent,
1260 enum dpm_order dpm_order); 1262 enum dpm_order dpm_order);
diff --git a/include/linux/property.h b/include/linux/property.h
index e9caa290cda5..5a910ad79591 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -76,6 +76,10 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
76 unsigned int nargs, unsigned int index, 76 unsigned int nargs, unsigned int index,
77 struct fwnode_reference_args *args); 77 struct fwnode_reference_args *args);
78 78
79struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
80 const char *name,
81 unsigned int index);
82
79struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); 83struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
80struct fwnode_handle *fwnode_get_next_parent( 84struct fwnode_handle *fwnode_get_next_parent(
81 struct fwnode_handle *fwnode); 85 struct fwnode_handle *fwnode);
@@ -141,6 +145,26 @@ static inline int device_property_read_u64(struct device *dev,
141 return device_property_read_u64_array(dev, propname, val, 1); 145 return device_property_read_u64_array(dev, propname, val, 1);
142} 146}
143 147
148static inline int device_property_count_u8(struct device *dev, const char *propname)
149{
150 return device_property_read_u8_array(dev, propname, NULL, 0);
151}
152
153static inline int device_property_count_u16(struct device *dev, const char *propname)
154{
155 return device_property_read_u16_array(dev, propname, NULL, 0);
156}
157
158static inline int device_property_count_u32(struct device *dev, const char *propname)
159{
160 return device_property_read_u32_array(dev, propname, NULL, 0);
161}
162
163static inline int device_property_count_u64(struct device *dev, const char *propname)
164{
165 return device_property_read_u64_array(dev, propname, NULL, 0);
166}
167
144static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode, 168static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
145 const char *propname) 169 const char *propname)
146{ 170{
@@ -171,6 +195,30 @@ static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
171 return fwnode_property_read_u64_array(fwnode, propname, val, 1); 195 return fwnode_property_read_u64_array(fwnode, propname, val, 1);
172} 196}
173 197
198static inline int fwnode_property_count_u8(const struct fwnode_handle *fwnode,
199 const char *propname)
200{
201 return fwnode_property_read_u8_array(fwnode, propname, NULL, 0);
202}
203
204static inline int fwnode_property_count_u16(const struct fwnode_handle *fwnode,
205 const char *propname)
206{
207 return fwnode_property_read_u16_array(fwnode, propname, NULL, 0);
208}
209
210static inline int fwnode_property_count_u32(const struct fwnode_handle *fwnode,
211 const char *propname)
212{
213 return fwnode_property_read_u32_array(fwnode, propname, NULL, 0);
214}
215
216static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode,
217 const char *propname)
218{
219 return fwnode_property_read_u64_array(fwnode, propname, NULL, 0);
220}
221
174/** 222/**
175 * struct property_entry - "Built-in" device property representation. 223 * struct property_entry - "Built-in" device property representation.
176 * @name: Name of the property. 224 * @name: Name of the property.
@@ -329,7 +377,54 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
329/* -------------------------------------------------------------------------- */ 377/* -------------------------------------------------------------------------- */
330/* Software fwnode support - when HW description is incomplete or missing */ 378/* Software fwnode support - when HW description is incomplete or missing */
331 379
380struct software_node;
381
382/**
383 * struct software_node_ref_args - Reference with additional arguments
384 * @node: Reference to a software node
385 * @nargs: Number of elements in @args array
386 * @args: Integer arguments
387 */
388struct software_node_ref_args {
389 const struct software_node *node;
390 unsigned int nargs;
391 u64 args[NR_FWNODE_REFERENCE_ARGS];
392};
393
394/**
395 * struct software_node_reference - Named software node reference property
396 * @name: Name of the property
397 * @nrefs: Number of elements in @refs array
398 * @refs: Array of references with optional arguments
399 */
400struct software_node_reference {
401 const char *name;
402 unsigned int nrefs;
403 const struct software_node_ref_args *refs;
404};
405
406/**
407 * struct software_node - Software node description
408 * @name: Name of the software node
409 * @parent: Parent of the software node
410 * @properties: Array of device properties
411 * @references: Array of software node reference properties
412 */
413struct software_node {
414 const char *name;
415 const struct software_node *parent;
416 const struct property_entry *properties;
417 const struct software_node_reference *references;
418};
419
332bool is_software_node(const struct fwnode_handle *fwnode); 420bool is_software_node(const struct fwnode_handle *fwnode);
421const struct software_node *to_software_node(struct fwnode_handle *fwnode);
422struct fwnode_handle *software_node_fwnode(const struct software_node *node);
423
424int software_node_register_nodes(const struct software_node *nodes);
425void software_node_unregister_nodes(const struct software_node *nodes);
426
427int software_node_register(const struct software_node *node);
333 428
334int software_node_notify(struct device *dev, unsigned long action); 429int software_node_notify(struct device *dev, unsigned long action);
335 430
diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h
index 43f40685e53c..873ace5b0cf8 100644
--- a/include/linux/usb/typec_mux.h
+++ b/include/linux/usb/typec_mux.h
@@ -3,54 +3,48 @@
3#ifndef __USB_TYPEC_MUX 3#ifndef __USB_TYPEC_MUX
4#define __USB_TYPEC_MUX 4#define __USB_TYPEC_MUX
5 5
6#include <linux/list.h>
7#include <linux/usb/typec.h> 6#include <linux/usb/typec.h>
8 7
9struct device; 8struct device;
9struct typec_mux;
10struct typec_switch;
11struct fwnode_handle;
10 12
11/** 13typedef int (*typec_switch_set_fn_t)(struct typec_switch *sw,
12 * struct typec_switch - USB Type-C cable orientation switch 14 enum typec_orientation orientation);
13 * @dev: Switch device
14 * @entry: List entry
15 * @set: Callback to the driver for setting the orientation
16 *
17 * USB Type-C pin flipper switch routing the correct data pairs from the
18 * connector to the USB controller depending on the orientation of the cable
19 * plug.
20 */
21struct typec_switch {
22 struct device *dev;
23 struct list_head entry;
24
25 int (*set)(struct typec_switch *sw, enum typec_orientation orientation);
26};
27 15
28/** 16struct typec_switch_desc {
29 * struct typec_switch - USB Type-C connector pin mux 17 struct fwnode_handle *fwnode;
30 * @dev: Mux device 18 typec_switch_set_fn_t set;
31 * @entry: List entry 19 void *drvdata;
32 * @set: Callback to the driver for setting the state of the mux
33 *
34 * Pin Multiplexer/DeMultiplexer switch routing the USB Type-C connector pins to
35 * different components depending on the requested mode of operation. Used with
36 * Accessory/Alternate modes.
37 */
38struct typec_mux {
39 struct device *dev;
40 struct list_head entry;
41
42 int (*set)(struct typec_mux *mux, int state);
43}; 20};
44 21
45struct typec_switch *typec_switch_get(struct device *dev); 22struct typec_switch *typec_switch_get(struct device *dev);
46void typec_switch_put(struct typec_switch *sw); 23void typec_switch_put(struct typec_switch *sw);
47int typec_switch_register(struct typec_switch *sw); 24struct typec_switch *
25typec_switch_register(struct device *parent,
26 const struct typec_switch_desc *desc);
48void typec_switch_unregister(struct typec_switch *sw); 27void typec_switch_unregister(struct typec_switch *sw);
49 28
29void typec_switch_set_drvdata(struct typec_switch *sw, void *data);
30void *typec_switch_get_drvdata(struct typec_switch *sw);
31
32typedef int (*typec_mux_set_fn_t)(struct typec_mux *mux, int state);
33
34struct typec_mux_desc {
35 struct fwnode_handle *fwnode;
36 typec_mux_set_fn_t set;
37 void *drvdata;
38};
39
50struct typec_mux * 40struct typec_mux *
51typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc); 41typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc);
52void typec_mux_put(struct typec_mux *mux); 42void typec_mux_put(struct typec_mux *mux);
53int typec_mux_register(struct typec_mux *mux); 43struct typec_mux *
44typec_mux_register(struct device *parent, const struct typec_mux_desc *desc);
54void typec_mux_unregister(struct typec_mux *mux); 45void typec_mux_unregister(struct typec_mux *mux);
55 46
47void typec_mux_set_drvdata(struct typec_mux *mux, void *data);
48void *typec_mux_get_drvdata(struct typec_mux *mux);
49
56#endif /* __USB_TYPEC_MUX */ 50#endif /* __USB_TYPEC_MUX */