diff options
Diffstat (limited to 'drivers/gpu/drm/tilcdc')
-rw-r--r-- | drivers/gpu/drm/tilcdc/Kconfig | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/Makefile | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 57 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_drv.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_panel.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 270 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_slave_compat.dts | 72 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_slave_compat.h | 25 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 4 |
9 files changed, 51 insertions, 399 deletions
diff --git a/drivers/gpu/drm/tilcdc/Kconfig b/drivers/gpu/drm/tilcdc/Kconfig index 28fed7e206d0..81ac82455ce4 100644 --- a/drivers/gpu/drm/tilcdc/Kconfig +++ b/drivers/gpu/drm/tilcdc/Kconfig | |||
@@ -12,14 +12,3 @@ config DRM_TILCDC | |||
12 | controller, for example AM33xx in beagle-bone, DA8xx, or | 12 | controller, for example AM33xx in beagle-bone, DA8xx, or |
13 | OMAP-L1xx. This driver replaces the FB_DA8XX fbdev driver. | 13 | OMAP-L1xx. This driver replaces the FB_DA8XX fbdev driver. |
14 | 14 | ||
15 | config DRM_TILCDC_SLAVE_COMPAT | ||
16 | bool "Support device tree blobs using TI LCDC Slave binding" | ||
17 | depends on DRM_TILCDC | ||
18 | default y | ||
19 | select OF_RESOLVE | ||
20 | select OF_OVERLAY | ||
21 | help | ||
22 | Choose this option if you need a kernel that is compatible | ||
23 | with device tree blobs using the obsolete "ti,tilcdc,slave" | ||
24 | binding. If you find "ti,tilcdc,slave"-string from your DTB, | ||
25 | you probably need this. Otherwise you do not. | ||
diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile index 55ebd516728f..87f9480e43b0 100644 --- a/drivers/gpu/drm/tilcdc/Makefile +++ b/drivers/gpu/drm/tilcdc/Makefile | |||
@@ -1,10 +1,8 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | ifeq (, $(findstring -W,$(EXTRA_CFLAGS))) | 2 | ifeq (, $(findstring -W,$(EXTRA_CFLAGS))) |
2 | ccflags-y += -Werror | 3 | ccflags-y += -Werror |
3 | endif | 4 | endif |
4 | 5 | ||
5 | obj-$(CONFIG_DRM_TILCDC_SLAVE_COMPAT) += tilcdc_slave_compat.o \ | ||
6 | tilcdc_slave_compat.dtb.o | ||
7 | |||
8 | tilcdc-y := \ | 6 | tilcdc-y := \ |
9 | tilcdc_plane.o \ | 7 | tilcdc_plane.o \ |
10 | tilcdc_crtc.o \ | 8 | tilcdc_crtc.o \ |
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 406fe4544b83..6ef4d1a1e3a9 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/completion.h> | 24 | #include <linux/completion.h> |
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/of_graph.h> | 26 | #include <linux/of_graph.h> |
27 | #include <linux/math64.h> | ||
27 | 28 | ||
28 | #include "tilcdc_drv.h" | 29 | #include "tilcdc_drv.h" |
29 | #include "tilcdc_regs.h" | 30 | #include "tilcdc_regs.h" |
@@ -48,6 +49,7 @@ struct tilcdc_crtc { | |||
48 | unsigned int lcd_fck_rate; | 49 | unsigned int lcd_fck_rate; |
49 | 50 | ||
50 | ktime_t last_vblank; | 51 | ktime_t last_vblank; |
52 | unsigned int hvtotal_us; | ||
51 | 53 | ||
52 | struct drm_framebuffer *curr_fb; | 54 | struct drm_framebuffer *curr_fb; |
53 | struct drm_framebuffer *next_fb; | 55 | struct drm_framebuffer *next_fb; |
@@ -75,7 +77,7 @@ static void unref_worker(struct drm_flip_work *work, void *val) | |||
75 | struct drm_device *dev = tilcdc_crtc->base.dev; | 77 | struct drm_device *dev = tilcdc_crtc->base.dev; |
76 | 78 | ||
77 | mutex_lock(&dev->mode_config.mutex); | 79 | mutex_lock(&dev->mode_config.mutex); |
78 | drm_framebuffer_unreference(val); | 80 | drm_framebuffer_put(val); |
79 | mutex_unlock(&dev->mode_config.mutex); | 81 | mutex_unlock(&dev->mode_config.mutex); |
80 | } | 82 | } |
81 | 83 | ||
@@ -292,6 +294,12 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc) | |||
292 | LCDC_V2_CORE_CLK_EN); | 294 | LCDC_V2_CORE_CLK_EN); |
293 | } | 295 | } |
294 | 296 | ||
297 | uint tilcdc_mode_hvtotal(const struct drm_display_mode *mode) | ||
298 | { | ||
299 | return (uint) div_u64(1000llu * mode->htotal * mode->vtotal, | ||
300 | mode->clock); | ||
301 | } | ||
302 | |||
295 | static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) | 303 | static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) |
296 | { | 304 | { |
297 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 305 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
@@ -456,9 +464,12 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) | |||
456 | 464 | ||
457 | set_scanout(crtc, fb); | 465 | set_scanout(crtc, fb); |
458 | 466 | ||
459 | drm_framebuffer_reference(fb); | 467 | drm_framebuffer_get(fb); |
460 | 468 | ||
461 | crtc->hwmode = crtc->state->adjusted_mode; | 469 | crtc->hwmode = crtc->state->adjusted_mode; |
470 | |||
471 | tilcdc_crtc->hvtotal_us = | ||
472 | tilcdc_mode_hvtotal(&crtc->hwmode); | ||
462 | } | 473 | } |
463 | 474 | ||
464 | static void tilcdc_crtc_enable(struct drm_crtc *crtc) | 475 | static void tilcdc_crtc_enable(struct drm_crtc *crtc) |
@@ -467,7 +478,6 @@ static void tilcdc_crtc_enable(struct drm_crtc *crtc) | |||
467 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 478 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
468 | unsigned long flags; | 479 | unsigned long flags; |
469 | 480 | ||
470 | WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); | ||
471 | mutex_lock(&tilcdc_crtc->enable_lock); | 481 | mutex_lock(&tilcdc_crtc->enable_lock); |
472 | if (tilcdc_crtc->enabled || tilcdc_crtc->shutdown) { | 482 | if (tilcdc_crtc->enabled || tilcdc_crtc->shutdown) { |
473 | mutex_unlock(&tilcdc_crtc->enable_lock); | 483 | mutex_unlock(&tilcdc_crtc->enable_lock); |
@@ -564,7 +574,6 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool shutdown) | |||
564 | 574 | ||
565 | static void tilcdc_crtc_disable(struct drm_crtc *crtc) | 575 | static void tilcdc_crtc_disable(struct drm_crtc *crtc) |
566 | { | 576 | { |
567 | WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); | ||
568 | tilcdc_crtc_off(crtc, false); | 577 | tilcdc_crtc_off(crtc, false); |
569 | } | 578 | } |
570 | 579 | ||
@@ -608,9 +617,7 @@ static void tilcdc_crtc_destroy(struct drm_crtc *crtc) | |||
608 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 617 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
609 | struct tilcdc_drm_private *priv = crtc->dev->dev_private; | 618 | struct tilcdc_drm_private *priv = crtc->dev->dev_private; |
610 | 619 | ||
611 | drm_modeset_lock(&crtc->mutex, NULL); | 620 | tilcdc_crtc_shutdown(crtc); |
612 | tilcdc_crtc_disable(crtc); | ||
613 | drm_modeset_unlock(&crtc->mutex); | ||
614 | 621 | ||
615 | flush_workqueue(priv->wq); | 622 | flush_workqueue(priv->wq); |
616 | 623 | ||
@@ -626,14 +633,12 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc, | |||
626 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 633 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
627 | struct drm_device *dev = crtc->dev; | 634 | struct drm_device *dev = crtc->dev; |
628 | 635 | ||
629 | WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); | ||
630 | |||
631 | if (tilcdc_crtc->event) { | 636 | if (tilcdc_crtc->event) { |
632 | dev_err(dev->dev, "already pending page flip!\n"); | 637 | dev_err(dev->dev, "already pending page flip!\n"); |
633 | return -EBUSY; | 638 | return -EBUSY; |
634 | } | 639 | } |
635 | 640 | ||
636 | drm_framebuffer_reference(fb); | 641 | drm_framebuffer_get(fb); |
637 | 642 | ||
638 | crtc->primary->fb = fb; | 643 | crtc->primary->fb = fb; |
639 | tilcdc_crtc->event = event; | 644 | tilcdc_crtc->event = event; |
@@ -648,7 +653,7 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc, | |||
648 | spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags); | 653 | spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags); |
649 | 654 | ||
650 | next_vblank = ktime_add_us(tilcdc_crtc->last_vblank, | 655 | next_vblank = ktime_add_us(tilcdc_crtc->last_vblank, |
651 | 1000000 / crtc->hwmode.vrefresh); | 656 | tilcdc_crtc->hvtotal_us); |
652 | tdiff = ktime_to_us(ktime_sub(next_vblank, ktime_get())); | 657 | tdiff = ktime_to_us(ktime_sub(next_vblank, ktime_get())); |
653 | 658 | ||
654 | if (tdiff < TILCDC_VBLANK_SAFETY_THRESHOLD_US) | 659 | if (tdiff < TILCDC_VBLANK_SAFETY_THRESHOLD_US) |
@@ -728,11 +733,39 @@ static void tilcdc_crtc_disable_vblank(struct drm_crtc *crtc) | |||
728 | { | 733 | { |
729 | } | 734 | } |
730 | 735 | ||
736 | static void tilcdc_crtc_reset(struct drm_crtc *crtc) | ||
737 | { | ||
738 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | ||
739 | struct drm_device *dev = crtc->dev; | ||
740 | int ret; | ||
741 | |||
742 | drm_atomic_helper_crtc_reset(crtc); | ||
743 | |||
744 | /* Turn the raster off if it for some reason is on. */ | ||
745 | pm_runtime_get_sync(dev->dev); | ||
746 | if (tilcdc_read(dev, LCDC_RASTER_CTRL_REG) & LCDC_RASTER_ENABLE) { | ||
747 | /* Enable DMA Frame Done Interrupt */ | ||
748 | tilcdc_write(dev, LCDC_INT_ENABLE_SET_REG, LCDC_FRAME_DONE); | ||
749 | tilcdc_clear_irqstatus(dev, 0xffffffff); | ||
750 | |||
751 | tilcdc_crtc->frame_done = false; | ||
752 | tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); | ||
753 | |||
754 | ret = wait_event_timeout(tilcdc_crtc->frame_done_wq, | ||
755 | tilcdc_crtc->frame_done, | ||
756 | msecs_to_jiffies(500)); | ||
757 | if (ret == 0) | ||
758 | dev_err(dev->dev, "%s: timeout waiting for framedone\n", | ||
759 | __func__); | ||
760 | } | ||
761 | pm_runtime_put_sync(dev->dev); | ||
762 | } | ||
763 | |||
731 | static const struct drm_crtc_funcs tilcdc_crtc_funcs = { | 764 | static const struct drm_crtc_funcs tilcdc_crtc_funcs = { |
732 | .destroy = tilcdc_crtc_destroy, | 765 | .destroy = tilcdc_crtc_destroy, |
733 | .set_config = drm_atomic_helper_set_config, | 766 | .set_config = drm_atomic_helper_set_config, |
734 | .page_flip = drm_atomic_helper_page_flip, | 767 | .page_flip = drm_atomic_helper_page_flip, |
735 | .reset = drm_atomic_helper_crtc_reset, | 768 | .reset = tilcdc_crtc_reset, |
736 | .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, | 769 | .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, |
737 | .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, | 770 | .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, |
738 | .enable_vblank = tilcdc_crtc_enable_vblank, | 771 | .enable_vblank = tilcdc_crtc_enable_vblank, |
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index b0d70f943cec..72ce063aa0d8 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <drm/drm_atomic.h> | 23 | #include <drm/drm_atomic.h> |
24 | #include <drm/drm_atomic_helper.h> | 24 | #include <drm/drm_atomic_helper.h> |
25 | #include <drm/drm_fb_helper.h> | 25 | #include <drm/drm_fb_helper.h> |
26 | #include <drm/drm_gem_framebuffer_helper.h> | ||
26 | 27 | ||
27 | #include "tilcdc_drv.h" | 28 | #include "tilcdc_drv.h" |
28 | #include "tilcdc_regs.h" | 29 | #include "tilcdc_regs.h" |
@@ -65,7 +66,7 @@ static struct of_device_id tilcdc_of_match[]; | |||
65 | static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev, | 66 | static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev, |
66 | struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd) | 67 | struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd) |
67 | { | 68 | { |
68 | return drm_fb_cma_create(dev, file_priv, mode_cmd); | 69 | return drm_gem_fb_create(dev, file_priv, mode_cmd); |
69 | } | 70 | } |
70 | 71 | ||
71 | static void tilcdc_fb_output_poll_changed(struct drm_device *dev) | 72 | static void tilcdc_fb_output_poll_changed(struct drm_device *dev) |
@@ -225,7 +226,7 @@ static void tilcdc_fini(struct drm_device *dev) | |||
225 | 226 | ||
226 | pm_runtime_disable(dev->dev); | 227 | pm_runtime_disable(dev->dev); |
227 | 228 | ||
228 | drm_dev_unref(dev); | 229 | drm_dev_put(dev); |
229 | } | 230 | } |
230 | 231 | ||
231 | static int tilcdc_init(struct drm_driver *ddrv, struct device *dev) | 232 | static int tilcdc_init(struct drm_driver *ddrv, struct device *dev) |
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index 1813a3623ce6..8eebb5f826a6 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c | |||
@@ -418,7 +418,7 @@ static int panel_remove(struct platform_device *pdev) | |||
418 | return 0; | 418 | return 0; |
419 | } | 419 | } |
420 | 420 | ||
421 | static struct of_device_id panel_of_match[] = { | 421 | static const struct of_device_id panel_of_match[] = { |
422 | { .compatible = "ti,tilcdc,panel", }, | 422 | { .compatible = "ti,tilcdc,panel", }, |
423 | { }, | 423 | { }, |
424 | }; | 424 | }; |
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c deleted file mode 100644 index 623a9140493c..000000000000 --- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c +++ /dev/null | |||
@@ -1,270 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Texas Instruments | ||
3 | * Author: Jyri Sarha <jsarha@ti.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License version 2 as published by | ||
7 | * the Free Software Foundation. | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * To support the old "ti,tilcdc,slave" binding the binding has to be | ||
13 | * transformed to the new external encoder binding. | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/of.h> | ||
18 | #include <linux/of_graph.h> | ||
19 | #include <linux/of_fdt.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/list.h> | ||
22 | |||
23 | #include "tilcdc_slave_compat.h" | ||
24 | |||
25 | struct kfree_table { | ||
26 | int total; | ||
27 | int num; | ||
28 | void **table; | ||
29 | }; | ||
30 | |||
31 | static int __init kfree_table_init(struct kfree_table *kft) | ||
32 | { | ||
33 | kft->total = 32; | ||
34 | kft->num = 0; | ||
35 | kft->table = kmalloc(kft->total * sizeof(*kft->table), | ||
36 | GFP_KERNEL); | ||
37 | if (!kft->table) | ||
38 | return -ENOMEM; | ||
39 | |||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | static int __init kfree_table_add(struct kfree_table *kft, void *p) | ||
44 | { | ||
45 | if (kft->num == kft->total) { | ||
46 | void **old = kft->table; | ||
47 | |||
48 | kft->total *= 2; | ||
49 | kft->table = krealloc(old, kft->total * sizeof(*kft->table), | ||
50 | GFP_KERNEL); | ||
51 | if (!kft->table) { | ||
52 | kft->table = old; | ||
53 | kfree(p); | ||
54 | return -ENOMEM; | ||
55 | } | ||
56 | } | ||
57 | kft->table[kft->num++] = p; | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static void __init kfree_table_free(struct kfree_table *kft) | ||
62 | { | ||
63 | int i; | ||
64 | |||
65 | for (i = 0; i < kft->num; i++) | ||
66 | kfree(kft->table[i]); | ||
67 | |||
68 | kfree(kft->table); | ||
69 | } | ||
70 | |||
71 | static | ||
72 | struct property * __init tilcdc_prop_dup(const struct property *prop, | ||
73 | struct kfree_table *kft) | ||
74 | { | ||
75 | struct property *nprop; | ||
76 | |||
77 | nprop = kzalloc(sizeof(*nprop), GFP_KERNEL); | ||
78 | if (!nprop || kfree_table_add(kft, nprop)) | ||
79 | return NULL; | ||
80 | |||
81 | nprop->name = kstrdup(prop->name, GFP_KERNEL); | ||
82 | if (!nprop->name || kfree_table_add(kft, nprop->name)) | ||
83 | return NULL; | ||
84 | |||
85 | nprop->value = kmemdup(prop->value, prop->length, GFP_KERNEL); | ||
86 | if (!nprop->value || kfree_table_add(kft, nprop->value)) | ||
87 | return NULL; | ||
88 | |||
89 | nprop->length = prop->length; | ||
90 | |||
91 | return nprop; | ||
92 | } | ||
93 | |||
94 | static void __init tilcdc_copy_props(struct device_node *from, | ||
95 | struct device_node *to, | ||
96 | const char * const props[], | ||
97 | struct kfree_table *kft) | ||
98 | { | ||
99 | struct property *prop; | ||
100 | int i; | ||
101 | |||
102 | for (i = 0; props[i]; i++) { | ||
103 | prop = of_find_property(from, props[i], NULL); | ||
104 | if (!prop) | ||
105 | continue; | ||
106 | |||
107 | prop = tilcdc_prop_dup(prop, kft); | ||
108 | if (!prop) | ||
109 | continue; | ||
110 | |||
111 | prop->next = to->properties; | ||
112 | to->properties = prop; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | static int __init tilcdc_prop_str_update(struct property *prop, | ||
117 | const char *str, | ||
118 | struct kfree_table *kft) | ||
119 | { | ||
120 | prop->value = kstrdup(str, GFP_KERNEL); | ||
121 | if (kfree_table_add(kft, prop->value) || !prop->value) | ||
122 | return -ENOMEM; | ||
123 | prop->length = strlen(str)+1; | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static void __init tilcdc_node_disable(struct device_node *node) | ||
128 | { | ||
129 | struct property *prop; | ||
130 | |||
131 | prop = kzalloc(sizeof(*prop), GFP_KERNEL); | ||
132 | if (!prop) | ||
133 | return; | ||
134 | |||
135 | prop->name = "status"; | ||
136 | prop->value = "disabled"; | ||
137 | prop->length = strlen((char *)prop->value)+1; | ||
138 | |||
139 | of_update_property(node, prop); | ||
140 | } | ||
141 | |||
142 | static struct device_node * __init tilcdc_get_overlay(struct kfree_table *kft) | ||
143 | { | ||
144 | const int size = __dtb_tilcdc_slave_compat_end - | ||
145 | __dtb_tilcdc_slave_compat_begin; | ||
146 | static void *overlay_data; | ||
147 | struct device_node *overlay; | ||
148 | int ret; | ||
149 | |||
150 | if (!size) { | ||
151 | pr_warn("%s: No overlay data\n", __func__); | ||
152 | return NULL; | ||
153 | } | ||
154 | |||
155 | overlay_data = kmemdup(__dtb_tilcdc_slave_compat_begin, | ||
156 | size, GFP_KERNEL); | ||
157 | if (!overlay_data || kfree_table_add(kft, overlay_data)) | ||
158 | return NULL; | ||
159 | |||
160 | of_fdt_unflatten_tree(overlay_data, NULL, &overlay); | ||
161 | if (!overlay) { | ||
162 | pr_warn("%s: Unfattening overlay tree failed\n", __func__); | ||
163 | return NULL; | ||
164 | } | ||
165 | |||
166 | of_node_set_flag(overlay, OF_DETACHED); | ||
167 | ret = of_resolve_phandles(overlay); | ||
168 | if (ret) { | ||
169 | pr_err("%s: Failed to resolve phandles: %d\n", __func__, ret); | ||
170 | return NULL; | ||
171 | } | ||
172 | |||
173 | return overlay; | ||
174 | } | ||
175 | |||
176 | static const struct of_device_id tilcdc_slave_of_match[] __initconst = { | ||
177 | { .compatible = "ti,tilcdc,slave", }, | ||
178 | {}, | ||
179 | }; | ||
180 | |||
181 | static const struct of_device_id tilcdc_of_match[] __initconst = { | ||
182 | { .compatible = "ti,am33xx-tilcdc", }, | ||
183 | {}, | ||
184 | }; | ||
185 | |||
186 | static const struct of_device_id tilcdc_tda998x_of_match[] __initconst = { | ||
187 | { .compatible = "nxp,tda998x", }, | ||
188 | {}, | ||
189 | }; | ||
190 | |||
191 | static const char * const tilcdc_slave_props[] __initconst = { | ||
192 | "pinctrl-names", | ||
193 | "pinctrl-0", | ||
194 | "pinctrl-1", | ||
195 | NULL | ||
196 | }; | ||
197 | |||
198 | static void __init tilcdc_convert_slave_node(void) | ||
199 | { | ||
200 | struct device_node *slave = NULL, *lcdc = NULL; | ||
201 | struct device_node *i2c = NULL, *fragment = NULL; | ||
202 | struct device_node *overlay, *encoder; | ||
203 | struct property *prop; | ||
204 | /* For all memory needed for the overlay tree. This memory can | ||
205 | be freed after the overlay has been applied. */ | ||
206 | struct kfree_table kft; | ||
207 | int ret; | ||
208 | |||
209 | if (kfree_table_init(&kft)) | ||
210 | return; | ||
211 | |||
212 | lcdc = of_find_matching_node(NULL, tilcdc_of_match); | ||
213 | slave = of_find_matching_node(NULL, tilcdc_slave_of_match); | ||
214 | |||
215 | if (!slave || !of_device_is_available(lcdc)) | ||
216 | goto out; | ||
217 | |||
218 | i2c = of_parse_phandle(slave, "i2c", 0); | ||
219 | if (!i2c) { | ||
220 | pr_err("%s: Can't find i2c node trough phandle\n", __func__); | ||
221 | goto out; | ||
222 | } | ||
223 | |||
224 | overlay = tilcdc_get_overlay(&kft); | ||
225 | if (!overlay) | ||
226 | goto out; | ||
227 | |||
228 | encoder = of_find_matching_node(overlay, tilcdc_tda998x_of_match); | ||
229 | if (!encoder) { | ||
230 | pr_err("%s: Failed to find tda998x node\n", __func__); | ||
231 | goto out; | ||
232 | } | ||
233 | |||
234 | tilcdc_copy_props(slave, encoder, tilcdc_slave_props, &kft); | ||
235 | |||
236 | for_each_child_of_node(overlay, fragment) { | ||
237 | prop = of_find_property(fragment, "target-path", NULL); | ||
238 | if (!prop) | ||
239 | continue; | ||
240 | if (!strncmp("i2c", (char *)prop->value, prop->length)) | ||
241 | if (tilcdc_prop_str_update(prop, i2c->full_name, &kft)) | ||
242 | goto out; | ||
243 | if (!strncmp("lcdc", (char *)prop->value, prop->length)) | ||
244 | if (tilcdc_prop_str_update(prop, lcdc->full_name, &kft)) | ||
245 | goto out; | ||
246 | } | ||
247 | |||
248 | tilcdc_node_disable(slave); | ||
249 | |||
250 | ret = of_overlay_create(overlay); | ||
251 | if (ret) | ||
252 | pr_err("%s: Creating overlay failed: %d\n", __func__, ret); | ||
253 | else | ||
254 | pr_info("%s: ti,tilcdc,slave node successfully converted\n", | ||
255 | __func__); | ||
256 | out: | ||
257 | kfree_table_free(&kft); | ||
258 | of_node_put(i2c); | ||
259 | of_node_put(slave); | ||
260 | of_node_put(lcdc); | ||
261 | of_node_put(fragment); | ||
262 | } | ||
263 | |||
264 | static int __init tilcdc_slave_compat_init(void) | ||
265 | { | ||
266 | tilcdc_convert_slave_node(); | ||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | subsys_initcall(tilcdc_slave_compat_init); | ||
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.dts b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.dts deleted file mode 100644 index 693f8b0aea2d..000000000000 --- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.dts +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* | ||
2 | * DTS overlay for converting ti,tilcdc,slave binding to new binding. | ||
3 | * | ||
4 | * Copyright (C) 2015 Texas Instruments Inc. | ||
5 | * Author: Jyri Sarha <jsarha@ti.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * target-path property values are simple tags that are replaced with | ||
14 | * correct values in tildcdc_slave_compat.c. Some properties are also | ||
15 | * copied over from the ti,tilcdc,slave node. | ||
16 | */ | ||
17 | |||
18 | /dts-v1/; | ||
19 | / { | ||
20 | fragment@0 { | ||
21 | target-path = "i2c"; | ||
22 | __overlay__ { | ||
23 | #address-cells = <1>; | ||
24 | #size-cells = <0>; | ||
25 | tda19988 { | ||
26 | compatible = "nxp,tda998x"; | ||
27 | reg = <0x70>; | ||
28 | status = "okay"; | ||
29 | |||
30 | port { | ||
31 | hdmi_0: endpoint@0 { | ||
32 | remote-endpoint = <&lcd_0>; | ||
33 | }; | ||
34 | }; | ||
35 | }; | ||
36 | }; | ||
37 | }; | ||
38 | |||
39 | fragment@1 { | ||
40 | target-path = "lcdc"; | ||
41 | __overlay__ { | ||
42 | port { | ||
43 | lcd_0: endpoint@0 { | ||
44 | remote-endpoint = <&hdmi_0>; | ||
45 | }; | ||
46 | }; | ||
47 | }; | ||
48 | }; | ||
49 | |||
50 | __local_fixups__ { | ||
51 | fragment@0 { | ||
52 | __overlay__ { | ||
53 | tda19988 { | ||
54 | port { | ||
55 | endpoint@0 { | ||
56 | remote-endpoint = <0>; | ||
57 | }; | ||
58 | }; | ||
59 | }; | ||
60 | }; | ||
61 | }; | ||
62 | fragment@1 { | ||
63 | __overlay__ { | ||
64 | port { | ||
65 | endpoint@0 { | ||
66 | remote-endpoint = <0>; | ||
67 | }; | ||
68 | }; | ||
69 | }; | ||
70 | }; | ||
71 | }; | ||
72 | }; | ||
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.h b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.h deleted file mode 100644 index 403d35d87d0b..000000000000 --- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.h +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Texas Instruments | ||
3 | * Author: Jyri Sarha <jsarha@ti.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License version 2 as published by | ||
7 | * the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along with | ||
15 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | /* This header declares the symbols defined in tilcdc_slave_compat.dts */ | ||
18 | |||
19 | #ifndef __TILCDC_SLAVE_COMPAT_H__ | ||
20 | #define __TILCDC_SLAVE_COMPAT_H__ | ||
21 | |||
22 | extern uint8_t __dtb_tilcdc_slave_compat_begin[]; | ||
23 | extern uint8_t __dtb_tilcdc_slave_compat_end[]; | ||
24 | |||
25 | #endif /* __TILCDC_SLAVE_COMPAT_H__ */ | ||
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c index 1e2dfb1b1d6b..7e3643462a08 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | |||
@@ -289,8 +289,6 @@ static const struct tilcdc_module_ops tfp410_module_ops = { | |||
289 | * Device: | 289 | * Device: |
290 | */ | 290 | */ |
291 | 291 | ||
292 | static struct of_device_id tfp410_of_match[]; | ||
293 | |||
294 | static int tfp410_probe(struct platform_device *pdev) | 292 | static int tfp410_probe(struct platform_device *pdev) |
295 | { | 293 | { |
296 | struct device_node *node = pdev->dev.of_node; | 294 | struct device_node *node = pdev->dev.of_node; |
@@ -375,7 +373,7 @@ static int tfp410_remove(struct platform_device *pdev) | |||
375 | return 0; | 373 | return 0; |
376 | } | 374 | } |
377 | 375 | ||
378 | static struct of_device_id tfp410_of_match[] = { | 376 | static const struct of_device_id tfp410_of_match[] = { |
379 | { .compatible = "ti,tilcdc,tfp410", }, | 377 | { .compatible = "ti,tilcdc,tfp410", }, |
380 | { }, | 378 | { }, |
381 | }; | 379 | }; |