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 *disp_clk;
53 struct clk *clk;
54 int rev;
55
56
57 uint32_t max_bandwidth;
58
59
60
61
62 uint32_t max_pixelclock;
63
64
65
66
67 uint32_t max_width;
68
69
70 u32 saved_register[12];
71
72#ifdef CONFIG_CPU_FREQ
73 struct notifier_block freq_transition;
74 unsigned int lcd_fck_rate;
75#endif
76
77 struct workqueue_struct *wq;
78
79 struct drm_fbdev_cma *fbdev;
80
81 struct drm_crtc *crtc;
82
83 unsigned int num_encoders;
84 struct drm_encoder *encoders[8];
85
86 unsigned int num_connectors;
87 struct drm_connector *connectors[8];
88};
89
90
91
92
93
94
95
96struct tilcdc_module;
97
98struct tilcdc_module_ops {
99
100 int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
101 void (*destroy)(struct tilcdc_module *mod);
102#ifdef CONFIG_DEBUG_FS
103
104 int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
105
106 void (*debugfs_cleanup)(struct tilcdc_module *mod, struct drm_minor *minor);
107#endif
108};
109
110struct tilcdc_module {
111 const char *name;
112 struct list_head list;
113 const struct tilcdc_module_ops *funcs;
114 unsigned int preferred_bpp;
115};
116
117void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
118 const struct tilcdc_module_ops *funcs);
119void tilcdc_module_cleanup(struct tilcdc_module *mod);
120void tilcdc_slave_probedefer(bool defered);
121
122
123
124
125
126struct tilcdc_panel_info {
127
128
129 uint32_t ac_bias;
130
131
132 uint32_t ac_bias_intrpt;
133
134
135 uint32_t dma_burst_sz;
136
137
138 uint32_t bpp;
139
140
141 uint32_t fdd;
142
143
144 bool tft_alt_mode;
145
146
147 bool invert_pxl_clk;
148
149
150 uint32_t sync_edge;
151
152
153 uint32_t sync_ctrl;
154
155
156 uint32_t raster_order;
157
158
159 uint32_t fifo_th;
160};
161
162#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
163
164struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
165void tilcdc_crtc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
166irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
167void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
168void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
169 const struct tilcdc_panel_info *info);
170int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
171int tilcdc_crtc_max_width(struct drm_crtc *crtc);
172
173#endif
174