29
29
#include <drm/drm_fb_helper.h>
30
30
#include <drm/drm_gem_cma_helper.h>
31
31
#include <drm/drm_gem_framebuffer_helper.h>
32
- #include <drm/drm_irq.h>
33
32
#include <drm/drm_modeset_helper.h>
34
33
#include <drm/drm_of.h>
35
34
#include <drm/drm_probe_helper.h>
38
37
#include "hdlcd_drv.h"
39
38
#include "hdlcd_regs.h"
40
39
40
+ static irqreturn_t hdlcd_irq (int irq , void * arg )
41
+ {
42
+ struct drm_device * drm = arg ;
43
+ struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
44
+ unsigned long irq_status ;
45
+
46
+ irq_status = hdlcd_read (hdlcd , HDLCD_REG_INT_STATUS );
47
+
48
+ #ifdef CONFIG_DEBUG_FS
49
+ if (irq_status & HDLCD_INTERRUPT_UNDERRUN )
50
+ atomic_inc (& hdlcd -> buffer_underrun_count );
51
+
52
+ if (irq_status & HDLCD_INTERRUPT_DMA_END )
53
+ atomic_inc (& hdlcd -> dma_end_count );
54
+
55
+ if (irq_status & HDLCD_INTERRUPT_BUS_ERROR )
56
+ atomic_inc (& hdlcd -> bus_error_count );
57
+
58
+ if (irq_status & HDLCD_INTERRUPT_VSYNC )
59
+ atomic_inc (& hdlcd -> vsync_count );
60
+
61
+ #endif
62
+ if (irq_status & HDLCD_INTERRUPT_VSYNC )
63
+ drm_crtc_handle_vblank (& hdlcd -> crtc );
64
+
65
+ /* acknowledge interrupt(s) */
66
+ hdlcd_write (hdlcd , HDLCD_REG_INT_CLEAR , irq_status );
67
+
68
+ return IRQ_HANDLED ;
69
+ }
70
+
71
+ static void hdlcd_irq_preinstall (struct drm_device * drm )
72
+ {
73
+ struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
74
+ /* Ensure interrupts are disabled */
75
+ hdlcd_write (hdlcd , HDLCD_REG_INT_MASK , 0 );
76
+ hdlcd_write (hdlcd , HDLCD_REG_INT_CLEAR , ~0 );
77
+ }
78
+
79
+ static void hdlcd_irq_postinstall (struct drm_device * drm )
80
+ {
81
+ #ifdef CONFIG_DEBUG_FS
82
+ struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
83
+ unsigned long irq_mask = hdlcd_read (hdlcd , HDLCD_REG_INT_MASK );
84
+
85
+ /* enable debug interrupts */
86
+ irq_mask |= HDLCD_DEBUG_INT_MASK ;
87
+
88
+ hdlcd_write (hdlcd , HDLCD_REG_INT_MASK , irq_mask );
89
+ #endif
90
+ }
91
+
92
+ static int hdlcd_irq_install (struct drm_device * drm , int irq )
93
+ {
94
+ int ret ;
95
+
96
+ if (irq == IRQ_NOTCONNECTED )
97
+ return - ENOTCONN ;
98
+
99
+ hdlcd_irq_preinstall (drm );
100
+
101
+ ret = request_irq (irq , hdlcd_irq , 0 , drm -> driver -> name , drm );
102
+ if (ret )
103
+ return ret ;
104
+
105
+ hdlcd_irq_postinstall (drm );
106
+
107
+ return 0 ;
108
+ }
109
+
110
+ static void hdlcd_irq_uninstall (struct drm_device * drm )
111
+ {
112
+ struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
113
+ /* disable all the interrupts that we might have enabled */
114
+ unsigned long irq_mask = hdlcd_read (hdlcd , HDLCD_REG_INT_MASK );
115
+
116
+ #ifdef CONFIG_DEBUG_FS
117
+ /* disable debug interrupts */
118
+ irq_mask &= ~HDLCD_DEBUG_INT_MASK ;
119
+ #endif
120
+
121
+ /* disable vsync interrupts */
122
+ irq_mask &= ~HDLCD_INTERRUPT_VSYNC ;
123
+ hdlcd_write (hdlcd , HDLCD_REG_INT_MASK , irq_mask );
124
+
125
+ free_irq (hdlcd -> irq , drm );
126
+ }
127
+
41
128
static int hdlcd_load (struct drm_device * drm , unsigned long flags )
42
129
{
43
130
struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
@@ -90,7 +177,12 @@ static int hdlcd_load(struct drm_device *drm, unsigned long flags)
90
177
goto setup_fail ;
91
178
}
92
179
93
- ret = drm_irq_install (drm , platform_get_irq (pdev , 0 ));
180
+ ret = platform_get_irq (pdev , 0 );
181
+ if (ret < 0 )
182
+ goto irq_fail ;
183
+ hdlcd -> irq = ret ;
184
+
185
+ ret = hdlcd_irq_install (drm , hdlcd -> irq );
94
186
if (ret < 0 ) {
95
187
DRM_ERROR ("failed to install IRQ handler\n" );
96
188
goto irq_fail ;
@@ -122,76 +214,6 @@ static void hdlcd_setup_mode_config(struct drm_device *drm)
122
214
drm -> mode_config .funcs = & hdlcd_mode_config_funcs ;
123
215
}
124
216
125
- static irqreturn_t hdlcd_irq (int irq , void * arg )
126
- {
127
- struct drm_device * drm = arg ;
128
- struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
129
- unsigned long irq_status ;
130
-
131
- irq_status = hdlcd_read (hdlcd , HDLCD_REG_INT_STATUS );
132
-
133
- #ifdef CONFIG_DEBUG_FS
134
- if (irq_status & HDLCD_INTERRUPT_UNDERRUN )
135
- atomic_inc (& hdlcd -> buffer_underrun_count );
136
-
137
- if (irq_status & HDLCD_INTERRUPT_DMA_END )
138
- atomic_inc (& hdlcd -> dma_end_count );
139
-
140
- if (irq_status & HDLCD_INTERRUPT_BUS_ERROR )
141
- atomic_inc (& hdlcd -> bus_error_count );
142
-
143
- if (irq_status & HDLCD_INTERRUPT_VSYNC )
144
- atomic_inc (& hdlcd -> vsync_count );
145
-
146
- #endif
147
- if (irq_status & HDLCD_INTERRUPT_VSYNC )
148
- drm_crtc_handle_vblank (& hdlcd -> crtc );
149
-
150
- /* acknowledge interrupt(s) */
151
- hdlcd_write (hdlcd , HDLCD_REG_INT_CLEAR , irq_status );
152
-
153
- return IRQ_HANDLED ;
154
- }
155
-
156
- static void hdlcd_irq_preinstall (struct drm_device * drm )
157
- {
158
- struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
159
- /* Ensure interrupts are disabled */
160
- hdlcd_write (hdlcd , HDLCD_REG_INT_MASK , 0 );
161
- hdlcd_write (hdlcd , HDLCD_REG_INT_CLEAR , ~0 );
162
- }
163
-
164
- static int hdlcd_irq_postinstall (struct drm_device * drm )
165
- {
166
- #ifdef CONFIG_DEBUG_FS
167
- struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
168
- unsigned long irq_mask = hdlcd_read (hdlcd , HDLCD_REG_INT_MASK );
169
-
170
- /* enable debug interrupts */
171
- irq_mask |= HDLCD_DEBUG_INT_MASK ;
172
-
173
- hdlcd_write (hdlcd , HDLCD_REG_INT_MASK , irq_mask );
174
- #endif
175
- return 0 ;
176
- }
177
-
178
- static void hdlcd_irq_uninstall (struct drm_device * drm )
179
- {
180
- struct hdlcd_drm_private * hdlcd = drm -> dev_private ;
181
- /* disable all the interrupts that we might have enabled */
182
- unsigned long irq_mask = hdlcd_read (hdlcd , HDLCD_REG_INT_MASK );
183
-
184
- #ifdef CONFIG_DEBUG_FS
185
- /* disable debug interrupts */
186
- irq_mask &= ~HDLCD_DEBUG_INT_MASK ;
187
- #endif
188
-
189
- /* disable vsync interrupts */
190
- irq_mask &= ~HDLCD_INTERRUPT_VSYNC ;
191
-
192
- hdlcd_write (hdlcd , HDLCD_REG_INT_MASK , irq_mask );
193
- }
194
-
195
217
#ifdef CONFIG_DEBUG_FS
196
218
static int hdlcd_show_underrun_count (struct seq_file * m , void * arg )
197
219
{
@@ -236,10 +258,6 @@ DEFINE_DRM_GEM_CMA_FOPS(fops);
236
258
237
259
static const struct drm_driver hdlcd_driver = {
238
260
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC ,
239
- .irq_handler = hdlcd_irq ,
240
- .irq_preinstall = hdlcd_irq_preinstall ,
241
- .irq_postinstall = hdlcd_irq_postinstall ,
242
- .irq_uninstall = hdlcd_irq_uninstall ,
243
261
DRM_GEM_CMA_DRIVER_OPS ,
244
262
#ifdef CONFIG_DEBUG_FS
245
263
.debugfs_init = hdlcd_debugfs_init ,
@@ -316,7 +334,7 @@ static int hdlcd_drm_bind(struct device *dev)
316
334
err_unload :
317
335
of_node_put (hdlcd -> crtc .port );
318
336
hdlcd -> crtc .port = NULL ;
319
- drm_irq_uninstall (drm );
337
+ hdlcd_irq_uninstall (drm );
320
338
of_reserved_mem_device_release (drm -> dev );
321
339
err_free :
322
340
drm_mode_config_cleanup (drm );
@@ -338,7 +356,7 @@ static void hdlcd_drm_unbind(struct device *dev)
338
356
hdlcd -> crtc .port = NULL ;
339
357
pm_runtime_get_sync (dev );
340
358
drm_atomic_helper_shutdown (drm );
341
- drm_irq_uninstall (drm );
359
+ hdlcd_irq_uninstall (drm );
342
360
pm_runtime_put (dev );
343
361
if (pm_runtime_enabled (dev ))
344
362
pm_runtime_disable (dev );
0 commit comments