1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (c) 2021 Linaro Limited 4 * Author: AKASHI Takahiro 5 */ 6 7 #ifndef _DM_TAG_H 8 #define _DM_TAG_H 9 10 #include <linux/list.h> 11 #include <linux/types.h> 12 13 struct dm_stats; 14 struct udevice; 15 16 enum dm_tag_t { 17 /* Types of core tags that can be attached to devices */ 18 DM_TAG_PLAT, 19 DM_TAG_PARENT_PLAT, 20 DM_TAG_UC_PLAT, 21 22 DM_TAG_PRIV, 23 DM_TAG_PARENT_PRIV, 24 DM_TAG_UC_PRIV, 25 DM_TAG_DRIVER_DATA, 26 DM_TAG_ATTACH_COUNT, 27 28 /* EFI_LOADER */ 29 DM_TAG_EFI = DM_TAG_ATTACH_COUNT, 30 31 DM_TAG_COUNT, 32 }; 33 34 /** 35 * dmtag_node 36 * 37 * @sibling: List of dm-tag nodes 38 * @dev: Associated udevice 39 * @tag: Tag type 40 * @ptr: Pointer as a value 41 * @val: Value 42 */ 43 struct dmtag_node { 44 struct list_head sibling; 45 struct udevice *dev; 46 enum dm_tag_t tag; 47 union { 48 void *ptr; 49 ulong val; 50 }; 51 }; 52 53 /** 54 * dev_tag_set_ptr() - set a tag's value as a pointer 55 * @dev: Device to operate 56 * @tag: Tag type 57 * @ptr: Pointer to set 58 * 59 * Set the value, @ptr, as of @tag associated with the device, @dev 60 * 61 * Return: 0 on success, -ve on error 62 */ 63 int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr); 64 65 /** 66 * dev_tag_set_val() set a tag's value as an integer 67 * @dev: Device to operate 68 * @tag: Tag type 69 * @val: Value to set 70 * 71 * Set the value, @val, as of @tag associated with the device, @dev 72 * 73 * Return: on success, -ve on error 74 */ 75 int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val); 76 77 /** 78 * dev_tag_get_ptr() - get a tag's value as a pointer 79 * @dev: Device to operate 80 * @tag: Tag type 81 * @ptrp: Pointer to tag's value (pointer) 82 * 83 * Get a tag's value as a pointer 84 * 85 * Return: on success, -ve on error 86 */ 87 int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp); 88 89 /** 90 * dev_tag_get_val() - get a tag's value as an integer 91 * @dev: Device to operate 92 * @tag: Tag type 93 * @valp: Pointer to tag's value (ulong) 94 * 95 * Get a tag's value as an integer 96 * 97 * Return: 0 on success, -ve on error 98 */ 99 int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp); 100 101 /** 102 * dev_tag_del() - delete a tag 103 * @dev: Device to operate 104 * @tag: Tag type 105 * 106 * Delete a tag of @tag associated with the device, @dev 107 * 108 * Return: 0 on success, -ve on error 109 */ 110 int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); 111 112 /** 113 * dev_tag_del_all() - delete all tags 114 * @dev: Device to operate 115 * 116 * Delete all the tags associated with the device, @dev 117 * 118 * Return: 0 on success, -ve on error 119 */ 120 int dev_tag_del_all(struct udevice *dev); 121 122 /** 123 * dev_tag_collect_stats() - Collect information on driver model performance 124 * 125 * This collects information on how driver model is performing. For now it only 126 * includes memory usage 127 * 128 * @stats: Place to put the collected information 129 */ 130 void dev_tag_collect_stats(struct dm_stats *stats); 131 132 /** 133 * tag_get_name() - Get the name of a tag 134 * 135 * @tag: Tag to look up, which must be valid 136 * Returns: Name of tag 137 */ 138 const char *tag_get_name(enum dm_tag_t tag); 139 140 #endif /* _DM_TAG_H */ 141