diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-09 13:28:47 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-09 13:28:47 -0400 |
| commit | 0415052db4f92b7e272fc15802ad8b8be672deea (patch) | |
| tree | 6273d2ecfa56fa21a94e1c8f632e5fefa5f3baa3 /include/linux | |
| parent | 4b4704520d97b74e045154fc3b844b73ae4e7ebd (diff) | |
| parent | 33ee09cd59ce154b64f9df942dfa5456db90d5f9 (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.h | 2 | ||||
| -rw-r--r-- | include/linux/property.h | 95 | ||||
| -rw-r--r-- | include/linux/usb/typec_mux.h | 62 |
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)); |
| 1256 | extern struct device *device_find_child(struct device *dev, void *data, | 1256 | extern 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)); |
| 1258 | extern struct device *device_find_child_by_name(struct device *parent, | ||
| 1259 | const char *name); | ||
| 1258 | extern int device_rename(struct device *dev, const char *new_name); | 1260 | extern int device_rename(struct device *dev, const char *new_name); |
| 1259 | extern int device_move(struct device *dev, struct device *new_parent, | 1261 | extern 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 | ||
| 79 | struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, | ||
| 80 | const char *name, | ||
| 81 | unsigned int index); | ||
| 82 | |||
| 79 | struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); | 83 | struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); |
| 80 | struct fwnode_handle *fwnode_get_next_parent( | 84 | struct 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 | ||
| 148 | static 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 | |||
| 153 | static 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 | |||
| 158 | static 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 | |||
| 163 | static 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 | |||
| 144 | static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode, | 168 | static 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 | ||
| 198 | static 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 | |||
| 204 | static 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 | |||
| 210 | static 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 | |||
| 216 | static 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 | ||
| 380 | struct 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 | */ | ||
| 388 | struct 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 | */ | ||
| 400 | struct 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 | */ | ||
| 413 | struct 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 | |||
| 332 | bool is_software_node(const struct fwnode_handle *fwnode); | 420 | bool is_software_node(const struct fwnode_handle *fwnode); |
| 421 | const struct software_node *to_software_node(struct fwnode_handle *fwnode); | ||
| 422 | struct fwnode_handle *software_node_fwnode(const struct software_node *node); | ||
| 423 | |||
| 424 | int software_node_register_nodes(const struct software_node *nodes); | ||
| 425 | void software_node_unregister_nodes(const struct software_node *nodes); | ||
| 426 | |||
| 427 | int software_node_register(const struct software_node *node); | ||
| 333 | 428 | ||
| 334 | int software_node_notify(struct device *dev, unsigned long action); | 429 | int 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 | ||
| 9 | struct device; | 8 | struct device; |
| 9 | struct typec_mux; | ||
| 10 | struct typec_switch; | ||
| 11 | struct fwnode_handle; | ||
| 10 | 12 | ||
| 11 | /** | 13 | typedef 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 | */ | ||
| 21 | struct 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 | /** | 16 | struct 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 | */ | ||
| 38 | struct 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 | ||
| 45 | struct typec_switch *typec_switch_get(struct device *dev); | 22 | struct typec_switch *typec_switch_get(struct device *dev); |
| 46 | void typec_switch_put(struct typec_switch *sw); | 23 | void typec_switch_put(struct typec_switch *sw); |
| 47 | int typec_switch_register(struct typec_switch *sw); | 24 | struct typec_switch * |
| 25 | typec_switch_register(struct device *parent, | ||
| 26 | const struct typec_switch_desc *desc); | ||
| 48 | void typec_switch_unregister(struct typec_switch *sw); | 27 | void typec_switch_unregister(struct typec_switch *sw); |
| 49 | 28 | ||
| 29 | void typec_switch_set_drvdata(struct typec_switch *sw, void *data); | ||
| 30 | void *typec_switch_get_drvdata(struct typec_switch *sw); | ||
| 31 | |||
| 32 | typedef int (*typec_mux_set_fn_t)(struct typec_mux *mux, int state); | ||
| 33 | |||
| 34 | struct typec_mux_desc { | ||
| 35 | struct fwnode_handle *fwnode; | ||
| 36 | typec_mux_set_fn_t set; | ||
| 37 | void *drvdata; | ||
| 38 | }; | ||
| 39 | |||
| 50 | struct typec_mux * | 40 | struct typec_mux * |
| 51 | typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc); | 41 | typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc); |
| 52 | void typec_mux_put(struct typec_mux *mux); | 42 | void typec_mux_put(struct typec_mux *mux); |
| 53 | int typec_mux_register(struct typec_mux *mux); | 43 | struct typec_mux * |
| 44 | typec_mux_register(struct device *parent, const struct typec_mux_desc *desc); | ||
| 54 | void typec_mux_unregister(struct typec_mux *mux); | 45 | void typec_mux_unregister(struct typec_mux *mux); |
| 55 | 46 | ||
| 47 | void typec_mux_set_drvdata(struct typec_mux *mux, void *data); | ||
| 48 | void *typec_mux_get_drvdata(struct typec_mux *mux); | ||
| 49 | |||
| 56 | #endif /* __USB_TYPEC_MUX */ | 50 | #endif /* __USB_TYPEC_MUX */ |
