1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright 2021 Google Inc.
4  *
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.
8  */
9 
10 #ifndef _DP_AUX_BUS_H_
11 #define _DP_AUX_BUS_H_
12 
13 #include <linux/device.h>
14 #include <linux/mod_devicetable.h>
15 
16 /**
17  * struct dp_aux_ep_device - Main dev structure for DP AUX endpoints
18  *
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
21  * be hooked up there.
22  */
23 struct dp_aux_ep_device {
24 	/** @dev: The normal dev pointer */
25 	struct device dev;
26 	/** @aux: Pointer to the aux bus */
27 	struct drm_dp_aux *aux;
28 };
29 
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;
35 };
36 
37 static inline struct dp_aux_ep_device *to_dp_aux_ep_dev(struct device *dev)
38 {
39 	return container_of(dev, struct dp_aux_ep_device, dev);
40 }
41 
42 static inline struct dp_aux_ep_driver *to_dp_aux_ep_drv(struct device_driver *drv)
43 {
44 	return container_of(drv, struct dp_aux_ep_driver, driver);
45 }
46 
47 int of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux);
48 void of_dp_aux_depopulate_ep_devices(struct drm_dp_aux *aux);
49 int devm_of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux);
50 
51 #define dp_aux_dp_driver_register(aux_ep_drv) \
52 	__dp_aux_dp_driver_register(aux_ep_drv, THIS_MODULE)
53 int __dp_aux_dp_driver_register(struct dp_aux_ep_driver *aux_ep_drv,
54 				struct module *owner);
55 void dp_aux_dp_driver_unregister(struct dp_aux_ep_driver *aux_ep_drv);
56 
57 #endif /* _DP_AUX_BUS_H_ */
58