1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef __TILCDC_DRV_H__
19#define __TILCDC_DRV_H__
20
21#include <linux/clk.h>
22#include <linux/cpufreq.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25#include <linux/pm.h>
26#include <linux/pm_runtime.h>
27#include <linux/slab.h>
28#include <linux/of.h>
29#include <linux/of_device.h>
30#include <linux/list.h>
31
32#include <drm/drmP.h>
33#include <drm/drm_crtc_helper.h>
34#include <drm/drm_gem_cma_helper.h>
35#include <drm/drm_fb_cma_helper.h>
36
37
38#define TILCDC_DEFAULT_MAX_PIXELCLOCK 126000
39
40#define TILCDC_DEFAULT_MAX_WIDTH 2048
41
42
43
44
45
46#define TILCDC_DEFAULT_MAX_BANDWIDTH (1280*1024*60)
47
48
49struct tilcdc_drm_private {
50 void __iomem *mmio;
51
52 struct clk *clk;
53 int rev;
54
55
56 uint32_t max_bandwidth;
57
58
59
60
61 uint32_t max_pixelclock;
62
63
64
65
66 uint32_t max_width;
67
68
69 const uint32_t *pixelformats;
70 uint32_t num_pixelformats;
71
72
73 struct drm_atomic_state *saved_state;
74
75#ifdef CONFIG_CPU_FREQ
76 struct notifier_block freq_transition;
77#endif
78
79 struct workqueue_struct *wq;
80
81 struct drm_fbdev_cma *fbdev;
82
83 struct drm_crtc *crtc;
84
85 unsigned int num_encoders;
86 struct drm_encoder *encoders[8];
87
88 unsigned int num_connectors;
89 struct drm_connector *connectors[8];
90 const struct drm_connector_helper_funcs *connector_funcs[8];
91
92 bool is_componentized;
93};
94
95
96
97
98
99
100
101struct tilcdc_module;
102
103struct tilcdc_module_ops {
104
105 int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
106#ifdef CONFIG_DEBUG_FS
107
108 int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
109
110 void (*debugfs_cleanup)(struct tilcdc_module *mod, struct drm_minor *minor);
111#endif
112};
113
114struct tilcdc_module {
115 const char *name;
116 struct list_head list;
117 const struct tilcdc_module_ops *funcs;
118};
119
120void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
121 const struct tilcdc_module_ops *funcs);
122void tilcdc_module_cleanup(struct tilcdc_module *mod);
123
124
125
126
127
128struct tilcdc_panel_info {
129
130
131 uint32_t ac_bias;
132
133
134 uint32_t ac_bias_intrpt;
135
136
137 uint32_t dma_burst_sz;
138
139
140 uint32_t bpp;
141
142
143 uint32_t fdd;
144
145
146 bool tft_alt_mode;
147
148
149 bool invert_pxl_clk;
150
151
152 uint32_t sync_edge;
153
154
155 uint32_t sync_ctrl;
156
157
158 uint32_t raster_order;
159
160
161 uint32_t fifo_th;
162};
163
164#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
165
166struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
167irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
168void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
169void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
170 const struct tilcdc_panel_info *info);
171void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
172 bool simulate_vesa_sync);
173int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
174int tilcdc_crtc_max_width(struct drm_crtc *crtc);
175void tilcdc_crtc_disable(struct drm_crtc *crtc);
176int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
177 struct drm_framebuffer *fb,
178 struct drm_pending_vblank_event *event);
179
180int tilcdc_plane_init(struct drm_device *dev, struct drm_plane *plane);
181
182#endif
183