1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2021 Google Inc.
5 * The DP AUX bus is used for devices that are connected over a DisplayPort
6 * AUX bus. The devices on the far side of the bus are referred to as
7 * endpoints in this code.
10 #ifndef _DP_AUX_BUS_H_
11 #define _DP_AUX_BUS_H_
13 #include <linux/device.h>
14 #include <linux/mod_devicetable.h>
17 * struct dp_aux_ep_device - Main dev structure for DP AUX endpoints
19 * This is used to instantiate devices that are connected via a DP AUX
20 * bus. Usually the device is a panel, but conceivable other devices could
23 struct dp_aux_ep_device {
24 /** @dev: The normal dev pointer */
26 /** @aux: Pointer to the aux bus */
27 struct drm_dp_aux *aux;
30 struct dp_aux_ep_driver {
31 int (*probe)(struct dp_aux_ep_device *aux_ep);
32 void (*remove)(struct dp_aux_ep_device *aux_ep);
33 void (*shutdown)(struct dp_aux_ep_device *aux_ep);
34 struct device_driver driver;
37 static inline struct dp_aux_ep_device *to_dp_aux_ep_dev(struct device *dev)
39 return container_of(dev, struct dp_aux_ep_device, dev);
42 static inline struct dp_aux_ep_driver *to_dp_aux_ep_drv(struct device_driver *drv)
44 return container_of(drv, struct dp_aux_ep_driver, driver);
47 int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
48 int (*done_probing)(struct drm_dp_aux *aux));
49 void of_dp_aux_depopulate_bus(struct drm_dp_aux *aux);
50 int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
51 int (*done_probing)(struct drm_dp_aux *aux));
53 /* Deprecated versions of the above functions. To be removed when no callers. */
54 static inline int of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
58 ret = of_dp_aux_populate_bus(aux, NULL);
60 /* New API returns -ENODEV for no child case; adapt to old assumption */
61 return (ret != -ENODEV) ? ret : 0;
64 static inline int devm_of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
68 ret = devm_of_dp_aux_populate_bus(aux, NULL);
70 /* New API returns -ENODEV for no child case; adapt to old assumption */
71 return (ret != -ENODEV) ? ret : 0;
74 static inline void of_dp_aux_depopulate_ep_devices(struct drm_dp_aux *aux)
76 of_dp_aux_depopulate_bus(aux);
79 #define dp_aux_dp_driver_register(aux_ep_drv) \
80 __dp_aux_dp_driver_register(aux_ep_drv, THIS_MODULE)
81 int __dp_aux_dp_driver_register(struct dp_aux_ep_driver *aux_ep_drv,
82 struct module *owner);
83 void dp_aux_dp_driver_unregister(struct dp_aux_ep_driver *aux_ep_drv);
85 #endif /* _DP_AUX_BUS_H_ */