diff options
author | Archit Taneja <architt@codeaurora.org> | 2016-02-12 04:18:34 -0500 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2016-03-02 11:02:54 -0500 |
commit | 97b6ae50e05c533b6455e304d36bdf2bb5604ee6 (patch) | |
tree | 9918354dad0852f0c3d0108e7c0e59b447cefab4 | |
parent | 509e42ce0441df39d5241150c1bec32cf6347b6c (diff) |
drm/dsi: Get DSI host by DT device node
MIPI DSI devices are inherently aware of their host because they share a
parent-child hierarchy in the device tree.
Non-DSI drivers that create DSI device don't have this data. In order to
get this information, they require to a phandle to the DSI host in the
device tree.
Maintain a list of all the DSI hosts that are currently registered. This
list will be used to find the struct mipi_dsi_host corresponding to the
device tree node passed to of_find_mipi_dsi_host_by_node().
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | drivers/gpu/drm/drm_mipi_dsi.c | 39 | ||||
-rw-r--r-- | include/drm/drm_mipi_dsi.h | 3 |
2 files changed, 42 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index f2f5a6d3669a..f5d80839a90c 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c | |||
@@ -235,6 +235,37 @@ void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi) | |||
235 | } | 235 | } |
236 | EXPORT_SYMBOL(mipi_dsi_device_unregister); | 236 | EXPORT_SYMBOL(mipi_dsi_device_unregister); |
237 | 237 | ||
238 | static DEFINE_MUTEX(host_lock); | ||
239 | static LIST_HEAD(host_list); | ||
240 | |||
241 | /** | ||
242 | * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a | ||
243 | * device tree node | ||
244 | * @node: device tree node | ||
245 | * | ||
246 | * Returns: | ||
247 | * A pointer to the MIPI DSI host corresponding to @node or NULL if no | ||
248 | * such device exists (or has not been registered yet). | ||
249 | */ | ||
250 | struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node) | ||
251 | { | ||
252 | struct mipi_dsi_host *host; | ||
253 | |||
254 | mutex_lock(&host_lock); | ||
255 | |||
256 | list_for_each_entry(host, &host_list, list) { | ||
257 | if (host->dev->of_node == node) { | ||
258 | mutex_unlock(&host_lock); | ||
259 | return host; | ||
260 | } | ||
261 | } | ||
262 | |||
263 | mutex_unlock(&host_lock); | ||
264 | |||
265 | return NULL; | ||
266 | } | ||
267 | EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node); | ||
268 | |||
238 | int mipi_dsi_host_register(struct mipi_dsi_host *host) | 269 | int mipi_dsi_host_register(struct mipi_dsi_host *host) |
239 | { | 270 | { |
240 | struct device_node *node; | 271 | struct device_node *node; |
@@ -246,6 +277,10 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) | |||
246 | of_mipi_dsi_device_add(host, node); | 277 | of_mipi_dsi_device_add(host, node); |
247 | } | 278 | } |
248 | 279 | ||
280 | mutex_lock(&host_lock); | ||
281 | list_add_tail(&host->list, &host_list); | ||
282 | mutex_unlock(&host_lock); | ||
283 | |||
249 | return 0; | 284 | return 0; |
250 | } | 285 | } |
251 | EXPORT_SYMBOL(mipi_dsi_host_register); | 286 | EXPORT_SYMBOL(mipi_dsi_host_register); |
@@ -262,6 +297,10 @@ static int mipi_dsi_remove_device_fn(struct device *dev, void *priv) | |||
262 | void mipi_dsi_host_unregister(struct mipi_dsi_host *host) | 297 | void mipi_dsi_host_unregister(struct mipi_dsi_host *host) |
263 | { | 298 | { |
264 | device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn); | 299 | device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn); |
300 | |||
301 | mutex_lock(&host_lock); | ||
302 | list_del_init(&host->list); | ||
303 | mutex_unlock(&host_lock); | ||
265 | } | 304 | } |
266 | EXPORT_SYMBOL(mipi_dsi_host_unregister); | 305 | EXPORT_SYMBOL(mipi_dsi_host_unregister); |
267 | 306 | ||
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 06e0a9382b35..7a9840f8b38e 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h | |||
@@ -96,14 +96,17 @@ struct mipi_dsi_host_ops { | |||
96 | * struct mipi_dsi_host - DSI host device | 96 | * struct mipi_dsi_host - DSI host device |
97 | * @dev: driver model device node for this DSI host | 97 | * @dev: driver model device node for this DSI host |
98 | * @ops: DSI host operations | 98 | * @ops: DSI host operations |
99 | * @list: list management | ||
99 | */ | 100 | */ |
100 | struct mipi_dsi_host { | 101 | struct mipi_dsi_host { |
101 | struct device *dev; | 102 | struct device *dev; |
102 | const struct mipi_dsi_host_ops *ops; | 103 | const struct mipi_dsi_host_ops *ops; |
104 | struct list_head list; | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | int mipi_dsi_host_register(struct mipi_dsi_host *host); | 107 | int mipi_dsi_host_register(struct mipi_dsi_host *host); |
106 | void mipi_dsi_host_unregister(struct mipi_dsi_host *host); | 108 | void mipi_dsi_host_unregister(struct mipi_dsi_host *host); |
109 | struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); | ||
107 | 110 | ||
108 | /* DSI mode flags */ | 111 | /* DSI mode flags */ |
109 | 112 | ||