u-boot.2021.1/include/dm/device.h
207 * struct driver - A driver for a feature or peripheral
208 *
209 * This holds methods for setting up a new device, and also removing it.
210 * The device needs information to set itself up - this is provided either
211 * by platdata or a device tree node (which we find by looking up
212 * matching compatible strings with of_match).
213 *
214 * Drivers all belong to a uclass, representing a class of devices of the
215 * same type. Common elements of the drivers can be implemented in the uclass,
216 * or the uclass can provide a consistent interface to the drivers within
217 * it.
218 *
219 * @name: Device name
220 * @id: Identifies the uclass we belong to
221 * @of_match: List of compatible strings to match, and any identifying data
222 * for each.
223 * @bind: Called to bind a device to its driver
224 * @probe: Called to probe a device, i.e. activate it
225 * @remove: Called to remove a device, i.e. de-activate it
226 * @unbind: Called to unbind a device from its driver
227 * @ofdata_to_platdata: Called before probe to decode device tree data
228 * @child_post_bind: Called after a new child has been bound
229 * @child_pre_probe: Called before a child device is probed. The device has
230 * memory allocated but it has not yet been probed.
231 * @child_post_remove: Called after a child device is removed. The device
232 * has memory allocated but its device_remove() method has been called.
233 * @priv_auto_alloc_size: If non-zero this is the size of the private data
234 * to be allocated in the device's ->priv pointer. If zero, then the driver
235 * is responsible for allocating any data required.
236 * @platdata_auto_alloc_size: If non-zero this is the size of the
237 * platform data to be allocated in the device's ->platdata pointer.
238 * This is typically only useful for device-tree-aware drivers (those with
239 * an of_match), since drivers which use platdata will have the data
240 * provided in the U_BOOT_DEVICE() instantiation.
241 * @per_child_auto_alloc_size: Each device can hold private data owned by
242 * its parent. If required this will be automatically allocated if this
243 * value is non-zero.
244 * @per_child_platdata_auto_alloc_size: A bus likes to store information about
245 * its children. If non-zero this is the size of this data, to be allocated
246 * in the child's parent_platdata pointer.
247 * @ops: Driver-specific operations. This is typically a list of function
248 * pointers defined by the driver, to implement driver functions required by
249 * the uclass.
250 * @flags: driver flags - see DM_FLAGS_...
251 * @acpi_ops: Advanced Configuration and Power Interface (ACPI) operations,
252 * allowing the device to add things to the ACPI tables passed to Linux
253 */
254struct driver {
255 char *name;
256 enum uclass_id id;
257 const struct udevice_id *of_match;
258 int (*bind)(struct udevice *dev);
259 int (*probe)(struct udevice *dev);
260 int (*remove)(struct udevice *dev);
261 int (*unbind)(struct udevice *dev);
262 int (*ofdata_to_platdata)(struct udevice *dev);
263 int (*child_post_bind)(struct udevice *dev);
264 int (*child_pre_probe)(struct udevice *dev);
265 int (*child_post_remove)(struct udevice *dev);
266 int priv_auto_alloc_size;
267 int platdata_auto_alloc_size;
268 int per_child_auto_alloc_size;
269 int per_child_platdata_auto_alloc_size;
270 const void *ops; /* driver-specific operations */
271 uint32_t flags;
272#if CONFIG_IS_ENABLED(ACPIGEN)
273 struct acpi_ops *acpi_ops;
274#endif
275};