Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright 2021 Google Inc.
0004  *
0005  * The DP AUX bus is used for devices that are connected over a DisplayPort
0006  * AUX bus. The devices on the far side of the bus are referred to as
0007  * endpoints in this code.
0008  */
0009 
0010 #ifndef _DP_AUX_BUS_H_
0011 #define _DP_AUX_BUS_H_
0012 
0013 #include <linux/device.h>
0014 #include <linux/mod_devicetable.h>
0015 
0016 /**
0017  * struct dp_aux_ep_device - Main dev structure for DP AUX endpoints
0018  *
0019  * This is used to instantiate devices that are connected via a DP AUX
0020  * bus. Usually the device is a panel, but conceivable other devices could
0021  * be hooked up there.
0022  */
0023 struct dp_aux_ep_device {
0024     /** @dev: The normal dev pointer */
0025     struct device dev;
0026     /** @aux: Pointer to the aux bus */
0027     struct drm_dp_aux *aux;
0028 };
0029 
0030 struct dp_aux_ep_driver {
0031     int (*probe)(struct dp_aux_ep_device *aux_ep);
0032     void (*remove)(struct dp_aux_ep_device *aux_ep);
0033     void (*shutdown)(struct dp_aux_ep_device *aux_ep);
0034     struct device_driver driver;
0035 };
0036 
0037 static inline struct dp_aux_ep_device *to_dp_aux_ep_dev(struct device *dev)
0038 {
0039     return container_of(dev, struct dp_aux_ep_device, dev);
0040 }
0041 
0042 static inline struct dp_aux_ep_driver *to_dp_aux_ep_drv(struct device_driver *drv)
0043 {
0044     return container_of(drv, struct dp_aux_ep_driver, driver);
0045 }
0046 
0047 int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
0048                int (*done_probing)(struct drm_dp_aux *aux));
0049 void of_dp_aux_depopulate_bus(struct drm_dp_aux *aux);
0050 int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
0051                 int (*done_probing)(struct drm_dp_aux *aux));
0052 
0053 /* Deprecated versions of the above functions. To be removed when no callers. */
0054 static inline int of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
0055 {
0056     int ret;
0057 
0058     ret = of_dp_aux_populate_bus(aux, NULL);
0059 
0060     /* New API returns -ENODEV for no child case; adapt to old assumption */
0061     return (ret != -ENODEV) ? ret : 0;
0062 }
0063 
0064 static inline int devm_of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
0065 {
0066     int ret;
0067 
0068     ret = devm_of_dp_aux_populate_bus(aux, NULL);
0069 
0070     /* New API returns -ENODEV for no child case; adapt to old assumption */
0071     return (ret != -ENODEV) ? ret : 0;
0072 }
0073 
0074 static inline void of_dp_aux_depopulate_ep_devices(struct drm_dp_aux *aux)
0075 {
0076     of_dp_aux_depopulate_bus(aux);
0077 }
0078 
0079 #define dp_aux_dp_driver_register(aux_ep_drv) \
0080     __dp_aux_dp_driver_register(aux_ep_drv, THIS_MODULE)
0081 int __dp_aux_dp_driver_register(struct dp_aux_ep_driver *aux_ep_drv,
0082                 struct module *owner);
0083 void dp_aux_dp_driver_unregister(struct dp_aux_ep_driver *aux_ep_drv);
0084 
0085 #endif /* _DP_AUX_BUS_H_ */