1da68386dSThomas Zimmermann // SPDX-License-Identifier: GPL-2.0
2da68386dSThomas Zimmermann /*
3da68386dSThomas Zimmermann * Copyright 2021 Google Inc.
4da68386dSThomas Zimmermann *
5da68386dSThomas Zimmermann * The DP AUX bus is used for devices that are connected over a DisplayPort
63800b171SDouglas Anderson * AUX bus. The device on the far side of the bus is referred to as an
73800b171SDouglas Anderson * endpoint in this code.
8da68386dSThomas Zimmermann *
93800b171SDouglas Anderson * There is only one device connected to the DP AUX bus: an eDP panel.
10da68386dSThomas Zimmermann * Though historically panels (even DP panels) have been modeled as simple
11da68386dSThomas Zimmermann * platform devices, putting them under the DP AUX bus allows the panel driver
12da68386dSThomas Zimmermann * to perform transactions on that bus.
13da68386dSThomas Zimmermann */
14da68386dSThomas Zimmermann
15da68386dSThomas Zimmermann #include <linux/init.h>
16da68386dSThomas Zimmermann #include <linux/kernel.h>
17da68386dSThomas Zimmermann #include <linux/module.h>
18da68386dSThomas Zimmermann #include <linux/of_device.h>
19da68386dSThomas Zimmermann #include <linux/pm_domain.h>
20da68386dSThomas Zimmermann #include <linux/pm_runtime.h>
21da68386dSThomas Zimmermann
22da68386dSThomas Zimmermann #include <drm/display/drm_dp_aux_bus.h>
23da68386dSThomas Zimmermann #include <drm/display/drm_dp_helper.h>
24da68386dSThomas Zimmermann
253800b171SDouglas Anderson struct dp_aux_ep_device_with_data {
263800b171SDouglas Anderson struct dp_aux_ep_device aux_ep;
273800b171SDouglas Anderson int (*done_probing)(struct drm_dp_aux *aux);
283800b171SDouglas Anderson };
293800b171SDouglas Anderson
30da68386dSThomas Zimmermann /**
31da68386dSThomas Zimmermann * dp_aux_ep_match() - The match function for the dp_aux_bus.
32da68386dSThomas Zimmermann * @dev: The device to match.
33da68386dSThomas Zimmermann * @drv: The driver to try to match against.
34da68386dSThomas Zimmermann *
35da68386dSThomas Zimmermann * At the moment, we just match on device tree.
36da68386dSThomas Zimmermann *
37da68386dSThomas Zimmermann * Return: True if this driver matches this device; false otherwise.
38da68386dSThomas Zimmermann */
dp_aux_ep_match(struct device * dev,const struct device_driver * drv)39*d69d8048SGreg Kroah-Hartman static int dp_aux_ep_match(struct device *dev, const struct device_driver *drv)
40da68386dSThomas Zimmermann {
41da68386dSThomas Zimmermann return !!of_match_device(drv->of_match_table, dev);
42da68386dSThomas Zimmermann }
43da68386dSThomas Zimmermann
44da68386dSThomas Zimmermann /**
45da68386dSThomas Zimmermann * dp_aux_ep_probe() - The probe function for the dp_aux_bus.
46da68386dSThomas Zimmermann * @dev: The device to probe.
47da68386dSThomas Zimmermann *
48da68386dSThomas Zimmermann * Calls through to the endpoint driver probe.
49da68386dSThomas Zimmermann *
50da68386dSThomas Zimmermann * Return: 0 if no error or negative error code.
51da68386dSThomas Zimmermann */
dp_aux_ep_probe(struct device * dev)52da68386dSThomas Zimmermann static int dp_aux_ep_probe(struct device *dev)
53da68386dSThomas Zimmermann {
54da68386dSThomas Zimmermann struct dp_aux_ep_driver *aux_ep_drv = to_dp_aux_ep_drv(dev->driver);
55da68386dSThomas Zimmermann struct dp_aux_ep_device *aux_ep = to_dp_aux_ep_dev(dev);
563800b171SDouglas Anderson struct dp_aux_ep_device_with_data *aux_ep_with_data =
573800b171SDouglas Anderson container_of(aux_ep, struct dp_aux_ep_device_with_data, aux_ep);
58da68386dSThomas Zimmermann int ret;
59da68386dSThomas Zimmermann
60da68386dSThomas Zimmermann ret = dev_pm_domain_attach(dev, true);
61da68386dSThomas Zimmermann if (ret)
62da68386dSThomas Zimmermann return dev_err_probe(dev, ret, "Failed to attach to PM Domain\n");
63da68386dSThomas Zimmermann
64da68386dSThomas Zimmermann ret = aux_ep_drv->probe(aux_ep);
65da68386dSThomas Zimmermann if (ret)
663800b171SDouglas Anderson goto err_attached;
673800b171SDouglas Anderson
683800b171SDouglas Anderson if (aux_ep_with_data->done_probing) {
693800b171SDouglas Anderson ret = aux_ep_with_data->done_probing(aux_ep->aux);
703800b171SDouglas Anderson if (ret) {
713800b171SDouglas Anderson /*
723800b171SDouglas Anderson * The done_probing() callback should not return
733800b171SDouglas Anderson * -EPROBE_DEFER to us. If it does, we treat it as an
743800b171SDouglas Anderson * error. Passing it on as-is would cause the _panel_
753800b171SDouglas Anderson * to defer.
763800b171SDouglas Anderson */
773800b171SDouglas Anderson if (ret == -EPROBE_DEFER) {
783800b171SDouglas Anderson dev_err(dev,
793800b171SDouglas Anderson "DP AUX done_probing() can't defer\n");
803800b171SDouglas Anderson ret = -EINVAL;
813800b171SDouglas Anderson }
823800b171SDouglas Anderson goto err_probed;
833800b171SDouglas Anderson }
843800b171SDouglas Anderson }
853800b171SDouglas Anderson
863800b171SDouglas Anderson return 0;
873800b171SDouglas Anderson err_probed:
883800b171SDouglas Anderson if (aux_ep_drv->remove)
893800b171SDouglas Anderson aux_ep_drv->remove(aux_ep);
903800b171SDouglas Anderson err_attached:
91da68386dSThomas Zimmermann dev_pm_domain_detach(dev, true);
92da68386dSThomas Zimmermann
93da68386dSThomas Zimmermann return ret;
94da68386dSThomas Zimmermann }
95da68386dSThomas Zimmermann
96da68386dSThomas Zimmermann /**
97da68386dSThomas Zimmermann * dp_aux_ep_remove() - The remove function for the dp_aux_bus.
98da68386dSThomas Zimmermann * @dev: The device to remove.
99da68386dSThomas Zimmermann *
100da68386dSThomas Zimmermann * Calls through to the endpoint driver remove.
101da68386dSThomas Zimmermann */
dp_aux_ep_remove(struct device * dev)102da68386dSThomas Zimmermann static void dp_aux_ep_remove(struct device *dev)
103da68386dSThomas Zimmermann {
104da68386dSThomas Zimmermann struct dp_aux_ep_driver *aux_ep_drv = to_dp_aux_ep_drv(dev->driver);
105da68386dSThomas Zimmermann struct dp_aux_ep_device *aux_ep = to_dp_aux_ep_dev(dev);
106da68386dSThomas Zimmermann
107da68386dSThomas Zimmermann if (aux_ep_drv->remove)
108da68386dSThomas Zimmermann aux_ep_drv->remove(aux_ep);
109da68386dSThomas Zimmermann dev_pm_domain_detach(dev, true);
110da68386dSThomas Zimmermann }
111da68386dSThomas Zimmermann
112da68386dSThomas Zimmermann /**
113da68386dSThomas Zimmermann * dp_aux_ep_shutdown() - The shutdown function for the dp_aux_bus.
114da68386dSThomas Zimmermann * @dev: The device to shutdown.
115da68386dSThomas Zimmermann *
116da68386dSThomas Zimmermann * Calls through to the endpoint driver shutdown.
117da68386dSThomas Zimmermann */
dp_aux_ep_shutdown(struct device * dev)118da68386dSThomas Zimmermann static void dp_aux_ep_shutdown(struct device *dev)
119da68386dSThomas Zimmermann {
120da68386dSThomas Zimmermann struct dp_aux_ep_driver *aux_ep_drv;
121da68386dSThomas Zimmermann
122da68386dSThomas Zimmermann if (!dev->driver)
123da68386dSThomas Zimmermann return;
124da68386dSThomas Zimmermann
125da68386dSThomas Zimmermann aux_ep_drv = to_dp_aux_ep_drv(dev->driver);
126da68386dSThomas Zimmermann if (aux_ep_drv->shutdown)
127da68386dSThomas Zimmermann aux_ep_drv->shutdown(to_dp_aux_ep_dev(dev));
128da68386dSThomas Zimmermann }
129da68386dSThomas Zimmermann
13078cb1f1dSRicardo B. Marliere static const struct bus_type dp_aux_bus_type = {
131da68386dSThomas Zimmermann .name = "dp-aux",
132da68386dSThomas Zimmermann .match = dp_aux_ep_match,
133da68386dSThomas Zimmermann .probe = dp_aux_ep_probe,
134da68386dSThomas Zimmermann .remove = dp_aux_ep_remove,
135da68386dSThomas Zimmermann .shutdown = dp_aux_ep_shutdown,
136da68386dSThomas Zimmermann };
137da68386dSThomas Zimmermann
modalias_show(struct device * dev,struct device_attribute * attr,char * buf)138da68386dSThomas Zimmermann static ssize_t modalias_show(struct device *dev,
139da68386dSThomas Zimmermann struct device_attribute *attr, char *buf)
140da68386dSThomas Zimmermann {
141da68386dSThomas Zimmermann return of_device_modalias(dev, buf, PAGE_SIZE);
142da68386dSThomas Zimmermann }
143da68386dSThomas Zimmermann static DEVICE_ATTR_RO(modalias);
144da68386dSThomas Zimmermann
145da68386dSThomas Zimmermann static struct attribute *dp_aux_ep_dev_attrs[] = {
146da68386dSThomas Zimmermann &dev_attr_modalias.attr,
147da68386dSThomas Zimmermann NULL,
148da68386dSThomas Zimmermann };
149da68386dSThomas Zimmermann ATTRIBUTE_GROUPS(dp_aux_ep_dev);
150da68386dSThomas Zimmermann
151da68386dSThomas Zimmermann /**
152da68386dSThomas Zimmermann * dp_aux_ep_dev_release() - Free memory for the dp_aux_ep device
153da68386dSThomas Zimmermann * @dev: The device to free.
154da68386dSThomas Zimmermann */
dp_aux_ep_dev_release(struct device * dev)155da68386dSThomas Zimmermann static void dp_aux_ep_dev_release(struct device *dev)
156da68386dSThomas Zimmermann {
1573800b171SDouglas Anderson struct dp_aux_ep_device *aux_ep = to_dp_aux_ep_dev(dev);
1583800b171SDouglas Anderson struct dp_aux_ep_device_with_data *aux_ep_with_data =
1593800b171SDouglas Anderson container_of(aux_ep, struct dp_aux_ep_device_with_data, aux_ep);
1603800b171SDouglas Anderson
1613800b171SDouglas Anderson kfree(aux_ep_with_data);
162da68386dSThomas Zimmermann }
163da68386dSThomas Zimmermann
dp_aux_ep_dev_modalias(const struct device * dev,struct kobj_uevent_env * env)164162736b0SGreg Kroah-Hartman static int dp_aux_ep_dev_modalias(const struct device *dev, struct kobj_uevent_env *env)
165a77ad4bfSGreg Kroah-Hartman {
166a77ad4bfSGreg Kroah-Hartman return of_device_uevent_modalias(dev, env);
167a77ad4bfSGreg Kroah-Hartman }
168a77ad4bfSGreg Kroah-Hartman
169da68386dSThomas Zimmermann static struct device_type dp_aux_device_type_type = {
170da68386dSThomas Zimmermann .groups = dp_aux_ep_dev_groups,
171a77ad4bfSGreg Kroah-Hartman .uevent = dp_aux_ep_dev_modalias,
172da68386dSThomas Zimmermann .release = dp_aux_ep_dev_release,
173da68386dSThomas Zimmermann };
174da68386dSThomas Zimmermann
175da68386dSThomas Zimmermann /**
176da68386dSThomas Zimmermann * of_dp_aux_ep_destroy() - Destroy an DP AUX endpoint device
177da68386dSThomas Zimmermann * @dev: The device to destroy.
178da68386dSThomas Zimmermann * @data: Not used
179da68386dSThomas Zimmermann *
1803800b171SDouglas Anderson * This is just used as a callback by of_dp_aux_depopulate_bus() and
181da68386dSThomas Zimmermann * is called for _all_ of the child devices of the device providing the AUX bus.
182da68386dSThomas Zimmermann * We'll only act on those that are of type "dp_aux_bus_type".
183da68386dSThomas Zimmermann *
1843800b171SDouglas Anderson * This function is effectively an inverse of what's in
1853800b171SDouglas Anderson * of_dp_aux_populate_bus(). NOTE: since we only populate one child
1863800b171SDouglas Anderson * then it's expected that only one device will match all the "if" tests in
1873800b171SDouglas Anderson * this function and get to the device_unregister().
188da68386dSThomas Zimmermann *
189da68386dSThomas Zimmermann * Return: 0 if no error or negative error code.
190da68386dSThomas Zimmermann */
of_dp_aux_ep_destroy(struct device * dev,void * data)191da68386dSThomas Zimmermann static int of_dp_aux_ep_destroy(struct device *dev, void *data)
192da68386dSThomas Zimmermann {
193da68386dSThomas Zimmermann struct device_node *np = dev->of_node;
194da68386dSThomas Zimmermann
195da68386dSThomas Zimmermann if (dev->bus != &dp_aux_bus_type)
196da68386dSThomas Zimmermann return 0;
197da68386dSThomas Zimmermann
198da68386dSThomas Zimmermann if (!of_node_check_flag(np, OF_POPULATED))
199da68386dSThomas Zimmermann return 0;
200da68386dSThomas Zimmermann
201da68386dSThomas Zimmermann of_node_clear_flag(np, OF_POPULATED);
202da68386dSThomas Zimmermann of_node_put(np);
203da68386dSThomas Zimmermann
204da68386dSThomas Zimmermann device_unregister(dev);
205da68386dSThomas Zimmermann
206da68386dSThomas Zimmermann return 0;
207da68386dSThomas Zimmermann }
208da68386dSThomas Zimmermann
209da68386dSThomas Zimmermann /**
2103800b171SDouglas Anderson * of_dp_aux_depopulate_bus() - Undo of_dp_aux_populate_bus
2113800b171SDouglas Anderson * @aux: The AUX channel whose device we want to depopulate
212da68386dSThomas Zimmermann *
2133800b171SDouglas Anderson * This will destroy the device that was created
2143800b171SDouglas Anderson * by of_dp_aux_populate_bus().
215da68386dSThomas Zimmermann */
of_dp_aux_depopulate_bus(struct drm_dp_aux * aux)2163800b171SDouglas Anderson void of_dp_aux_depopulate_bus(struct drm_dp_aux *aux)
217da68386dSThomas Zimmermann {
218da68386dSThomas Zimmermann device_for_each_child_reverse(aux->dev, NULL, of_dp_aux_ep_destroy);
219da68386dSThomas Zimmermann }
2203800b171SDouglas Anderson EXPORT_SYMBOL_GPL(of_dp_aux_depopulate_bus);
221da68386dSThomas Zimmermann
222da68386dSThomas Zimmermann /**
2233800b171SDouglas Anderson * of_dp_aux_populate_bus() - Populate the endpoint device on the DP AUX
2243800b171SDouglas Anderson * @aux: The AUX channel whose device we want to populate. It is required that
225da68386dSThomas Zimmermann * drm_dp_aux_init() has already been called for this AUX channel.
2263800b171SDouglas Anderson * @done_probing: Callback functions to call after EP device finishes probing.
2273800b171SDouglas Anderson * Will not be called if there are no EP devices and this
2283800b171SDouglas Anderson * function will return -ENODEV.
229da68386dSThomas Zimmermann *
2303800b171SDouglas Anderson * This will populate the device (expected to be an eDP panel) under the
2313800b171SDouglas Anderson * "aux-bus" node of the device providing the AUX channel (AKA aux->dev).
232da68386dSThomas Zimmermann *
233da68386dSThomas Zimmermann * When this function finishes, it is _possible_ (but not guaranteed) that
2343800b171SDouglas Anderson * our sub-device will have finished probing. It should be noted that if our
2353800b171SDouglas Anderson * sub-device returns -EPROBE_DEFER or is probing asynchronously for some
2363800b171SDouglas Anderson * reason that we will not return any error codes ourselves but our
2373800b171SDouglas Anderson * sub-device will _not_ have actually probed successfully yet.
2383800b171SDouglas Anderson *
2393800b171SDouglas Anderson * In many cases it's important for the caller of this function to be notified
2403800b171SDouglas Anderson * when our sub device finishes probing. Our sub device is expected to be an
2413800b171SDouglas Anderson * eDP panel and the caller is expected to be an eDP controller. The eDP
2423800b171SDouglas Anderson * controller needs to be able to get a reference to the panel when it finishes
2433800b171SDouglas Anderson * probing. For this reason the caller can pass in a function pointer that
2443800b171SDouglas Anderson * will be called when our sub-device finishes probing.
245da68386dSThomas Zimmermann *
246da68386dSThomas Zimmermann * If this function succeeds you should later make sure you call
2473800b171SDouglas Anderson * of_dp_aux_depopulate_bus() to undo it, or just use the devm version
248da68386dSThomas Zimmermann * of this function.
249da68386dSThomas Zimmermann *
2503800b171SDouglas Anderson * Return: 0 if no error or negative error code; returns -ENODEV if there are
2513800b171SDouglas Anderson * no children. The done_probing() function won't be called in that
2523800b171SDouglas Anderson * case.
253da68386dSThomas Zimmermann */
of_dp_aux_populate_bus(struct drm_dp_aux * aux,int (* done_probing)(struct drm_dp_aux * aux))2543800b171SDouglas Anderson int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
2553800b171SDouglas Anderson int (*done_probing)(struct drm_dp_aux *aux))
256da68386dSThomas Zimmermann {
2573800b171SDouglas Anderson struct device_node *bus = NULL, *np = NULL;
258da68386dSThomas Zimmermann struct dp_aux_ep_device *aux_ep;
2593800b171SDouglas Anderson struct dp_aux_ep_device_with_data *aux_ep_with_data;
260da68386dSThomas Zimmermann int ret;
261da68386dSThomas Zimmermann
262da68386dSThomas Zimmermann /* drm_dp_aux_init() should have been called already; warn if not */
263da68386dSThomas Zimmermann WARN_ON_ONCE(!aux->ddc.algo);
264da68386dSThomas Zimmermann
265da68386dSThomas Zimmermann if (!aux->dev->of_node)
2663800b171SDouglas Anderson return -ENODEV;
267da68386dSThomas Zimmermann bus = of_get_child_by_name(aux->dev->of_node, "aux-bus");
268da68386dSThomas Zimmermann if (!bus)
2693800b171SDouglas Anderson return -ENODEV;
270da68386dSThomas Zimmermann
2713800b171SDouglas Anderson np = of_get_next_available_child(bus, NULL);
2723800b171SDouglas Anderson of_node_put(bus);
2733800b171SDouglas Anderson if (!np)
2743800b171SDouglas Anderson return -ENODEV;
275da68386dSThomas Zimmermann
2763800b171SDouglas Anderson if (of_node_test_and_set_flag(np, OF_POPULATED)) {
2773800b171SDouglas Anderson dev_err(aux->dev, "DP AUX EP device already populated\n");
2783800b171SDouglas Anderson ret = -EINVAL;
2793800b171SDouglas Anderson goto err_did_get_np;
2803800b171SDouglas Anderson }
2813800b171SDouglas Anderson
2823800b171SDouglas Anderson aux_ep_with_data = kzalloc(sizeof(*aux_ep_with_data), GFP_KERNEL);
2833800b171SDouglas Anderson if (!aux_ep_with_data) {
2843800b171SDouglas Anderson ret = -ENOMEM;
2853800b171SDouglas Anderson goto err_did_set_populated;
2863800b171SDouglas Anderson }
2873800b171SDouglas Anderson
2883800b171SDouglas Anderson aux_ep_with_data->done_probing = done_probing;
2893800b171SDouglas Anderson
2903800b171SDouglas Anderson aux_ep = &aux_ep_with_data->aux_ep;
291da68386dSThomas Zimmermann aux_ep->aux = aux;
292da68386dSThomas Zimmermann aux_ep->dev.parent = aux->dev;
293da68386dSThomas Zimmermann aux_ep->dev.bus = &dp_aux_bus_type;
294da68386dSThomas Zimmermann aux_ep->dev.type = &dp_aux_device_type_type;
295da68386dSThomas Zimmermann aux_ep->dev.of_node = of_node_get(np);
296da68386dSThomas Zimmermann dev_set_name(&aux_ep->dev, "aux-%s", dev_name(aux->dev));
297da68386dSThomas Zimmermann
298da68386dSThomas Zimmermann ret = device_register(&aux_ep->dev);
299da68386dSThomas Zimmermann if (ret) {
300da68386dSThomas Zimmermann dev_err(aux->dev, "Failed to create AUX EP for %pOF: %d\n", np, ret);
301da68386dSThomas Zimmermann
302da68386dSThomas Zimmermann /*
303da68386dSThomas Zimmermann * As per docs of device_register(), call this instead
304da68386dSThomas Zimmermann * of kfree() directly for error cases.
305da68386dSThomas Zimmermann */
306da68386dSThomas Zimmermann put_device(&aux_ep->dev);
307da68386dSThomas Zimmermann
3083800b171SDouglas Anderson goto err_did_set_populated;
309da68386dSThomas Zimmermann }
310da68386dSThomas Zimmermann
311da68386dSThomas Zimmermann return 0;
312da68386dSThomas Zimmermann
3133800b171SDouglas Anderson err_did_set_populated:
3143800b171SDouglas Anderson of_node_clear_flag(np, OF_POPULATED);
3153800b171SDouglas Anderson
3163800b171SDouglas Anderson err_did_get_np:
3173800b171SDouglas Anderson of_node_put(np);
3183800b171SDouglas Anderson
3193800b171SDouglas Anderson return ret;
3203800b171SDouglas Anderson }
3213800b171SDouglas Anderson EXPORT_SYMBOL_GPL(of_dp_aux_populate_bus);
3223800b171SDouglas Anderson
of_dp_aux_depopulate_bus_void(void * data)3233800b171SDouglas Anderson static void of_dp_aux_depopulate_bus_void(void *data)
324da68386dSThomas Zimmermann {
3253800b171SDouglas Anderson of_dp_aux_depopulate_bus(data);
326da68386dSThomas Zimmermann }
327da68386dSThomas Zimmermann
328da68386dSThomas Zimmermann /**
3293800b171SDouglas Anderson * devm_of_dp_aux_populate_bus() - devm wrapper for of_dp_aux_populate_bus()
3303800b171SDouglas Anderson * @aux: The AUX channel whose device we want to populate
3313800b171SDouglas Anderson * @done_probing: Callback functions to call after EP device finishes probing.
3323800b171SDouglas Anderson * Will not be called if there are no EP devices and this
3333800b171SDouglas Anderson * function will return -ENODEV.
334da68386dSThomas Zimmermann *
335da68386dSThomas Zimmermann * Handles freeing w/ devm on the device "aux->dev".
336da68386dSThomas Zimmermann *
3373800b171SDouglas Anderson * Return: 0 if no error or negative error code; returns -ENODEV if there are
3383800b171SDouglas Anderson * no children. The done_probing() function won't be called in that
3393800b171SDouglas Anderson * case.
340da68386dSThomas Zimmermann */
devm_of_dp_aux_populate_bus(struct drm_dp_aux * aux,int (* done_probing)(struct drm_dp_aux * aux))3413800b171SDouglas Anderson int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
3423800b171SDouglas Anderson int (*done_probing)(struct drm_dp_aux *aux))
343da68386dSThomas Zimmermann {
344da68386dSThomas Zimmermann int ret;
345da68386dSThomas Zimmermann
3463800b171SDouglas Anderson ret = of_dp_aux_populate_bus(aux, done_probing);
347da68386dSThomas Zimmermann if (ret)
348da68386dSThomas Zimmermann return ret;
349da68386dSThomas Zimmermann
350da68386dSThomas Zimmermann return devm_add_action_or_reset(aux->dev,
3513800b171SDouglas Anderson of_dp_aux_depopulate_bus_void, aux);
352da68386dSThomas Zimmermann }
3533800b171SDouglas Anderson EXPORT_SYMBOL_GPL(devm_of_dp_aux_populate_bus);
354da68386dSThomas Zimmermann
__dp_aux_dp_driver_register(struct dp_aux_ep_driver * drv,struct module * owner)355da68386dSThomas Zimmermann int __dp_aux_dp_driver_register(struct dp_aux_ep_driver *drv, struct module *owner)
356da68386dSThomas Zimmermann {
357da68386dSThomas Zimmermann drv->driver.owner = owner;
358da68386dSThomas Zimmermann drv->driver.bus = &dp_aux_bus_type;
359da68386dSThomas Zimmermann
360da68386dSThomas Zimmermann return driver_register(&drv->driver);
361da68386dSThomas Zimmermann }
362da68386dSThomas Zimmermann EXPORT_SYMBOL_GPL(__dp_aux_dp_driver_register);
363da68386dSThomas Zimmermann
dp_aux_dp_driver_unregister(struct dp_aux_ep_driver * drv)364da68386dSThomas Zimmermann void dp_aux_dp_driver_unregister(struct dp_aux_ep_driver *drv)
365da68386dSThomas Zimmermann {
366da68386dSThomas Zimmermann driver_unregister(&drv->driver);
367da68386dSThomas Zimmermann }
368da68386dSThomas Zimmermann EXPORT_SYMBOL_GPL(dp_aux_dp_driver_unregister);
369da68386dSThomas Zimmermann
dp_aux_bus_init(void)370da68386dSThomas Zimmermann static int __init dp_aux_bus_init(void)
371da68386dSThomas Zimmermann {
372da68386dSThomas Zimmermann int ret;
373da68386dSThomas Zimmermann
374da68386dSThomas Zimmermann ret = bus_register(&dp_aux_bus_type);
375da68386dSThomas Zimmermann if (ret)
376da68386dSThomas Zimmermann return ret;
377da68386dSThomas Zimmermann
378da68386dSThomas Zimmermann return 0;
379da68386dSThomas Zimmermann }
380da68386dSThomas Zimmermann
dp_aux_bus_exit(void)381da68386dSThomas Zimmermann static void __exit dp_aux_bus_exit(void)
382da68386dSThomas Zimmermann {
383da68386dSThomas Zimmermann bus_unregister(&dp_aux_bus_type);
384da68386dSThomas Zimmermann }
385da68386dSThomas Zimmermann
386da68386dSThomas Zimmermann subsys_initcall(dp_aux_bus_init);
387da68386dSThomas Zimmermann module_exit(dp_aux_bus_exit);
388da68386dSThomas Zimmermann
389da68386dSThomas Zimmermann MODULE_AUTHOR("Douglas Anderson <dianders@chromium.org>");
390da68386dSThomas Zimmermann MODULE_DESCRIPTION("DRM DisplayPort AUX bus");
391da68386dSThomas Zimmermann MODULE_LICENSE("GPL v2");
392