|
24 | 24 | #include <drm/drm_fourcc.h>
|
25 | 25 | #include <drm/drm_gem_cma_helper.h>
|
26 | 26 | #include <drm/drm_gem_framebuffer_helper.h>
|
27 |
| -#include <drm/drm_irq.h> |
28 | 27 | #include <drm/drm_mode_config.h>
|
29 | 28 | #include <drm/drm_of.h>
|
30 | 29 | #include <drm/drm_probe_helper.h>
|
@@ -153,6 +152,49 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
|
153 | 152 | return 0;
|
154 | 153 | }
|
155 | 154 |
|
| 155 | +static irqreturn_t mxsfb_irq_handler(int irq, void *data) |
| 156 | +{ |
| 157 | + struct drm_device *drm = data; |
| 158 | + struct mxsfb_drm_private *mxsfb = drm->dev_private; |
| 159 | + u32 reg; |
| 160 | + |
| 161 | + reg = readl(mxsfb->base + LCDC_CTRL1); |
| 162 | + |
| 163 | + if (reg & CTRL1_CUR_FRAME_DONE_IRQ) |
| 164 | + drm_crtc_handle_vblank(&mxsfb->crtc); |
| 165 | + |
| 166 | + writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR); |
| 167 | + |
| 168 | + return IRQ_HANDLED; |
| 169 | +} |
| 170 | + |
| 171 | +static void mxsfb_irq_disable(struct drm_device *drm) |
| 172 | +{ |
| 173 | + struct mxsfb_drm_private *mxsfb = drm->dev_private; |
| 174 | + |
| 175 | + mxsfb_enable_axi_clk(mxsfb); |
| 176 | + mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc); |
| 177 | + mxsfb_disable_axi_clk(mxsfb); |
| 178 | +} |
| 179 | + |
| 180 | +static int mxsfb_irq_install(struct drm_device *dev, int irq) |
| 181 | +{ |
| 182 | + if (irq == IRQ_NOTCONNECTED) |
| 183 | + return -ENOTCONN; |
| 184 | + |
| 185 | + mxsfb_irq_disable(dev); |
| 186 | + |
| 187 | + return request_irq(irq, mxsfb_irq_handler, 0, dev->driver->name, dev); |
| 188 | +} |
| 189 | + |
| 190 | +static void mxsfb_irq_uninstall(struct drm_device *dev) |
| 191 | +{ |
| 192 | + struct mxsfb_drm_private *mxsfb = dev->dev_private; |
| 193 | + |
| 194 | + mxsfb_irq_disable(dev); |
| 195 | + free_irq(mxsfb->irq, dev); |
| 196 | +} |
| 197 | + |
156 | 198 | static int mxsfb_load(struct drm_device *drm,
|
157 | 199 | const struct mxsfb_devdata *devdata)
|
158 | 200 | {
|
@@ -226,8 +268,13 @@ static int mxsfb_load(struct drm_device *drm,
|
226 | 268 |
|
227 | 269 | drm_mode_config_reset(drm);
|
228 | 270 |
|
| 271 | + ret = platform_get_irq(pdev, 0); |
| 272 | + if (ret < 0) |
| 273 | + goto err_vblank; |
| 274 | + mxsfb->irq = ret; |
| 275 | + |
229 | 276 | pm_runtime_get_sync(drm->dev);
|
230 |
| - ret = drm_irq_install(drm, platform_get_irq(pdev, 0)); |
| 277 | + ret = mxsfb_irq_install(drm, mxsfb->irq); |
231 | 278 | pm_runtime_put_sync(drm->dev);
|
232 | 279 |
|
233 | 280 | if (ret < 0) {
|
@@ -255,46 +302,18 @@ static void mxsfb_unload(struct drm_device *drm)
|
255 | 302 | drm_mode_config_cleanup(drm);
|
256 | 303 |
|
257 | 304 | pm_runtime_get_sync(drm->dev);
|
258 |
| - drm_irq_uninstall(drm); |
| 305 | + mxsfb_irq_uninstall(drm); |
259 | 306 | pm_runtime_put_sync(drm->dev);
|
260 | 307 |
|
261 | 308 | drm->dev_private = NULL;
|
262 | 309 |
|
263 | 310 | pm_runtime_disable(drm->dev);
|
264 | 311 | }
|
265 | 312 |
|
266 |
| -static void mxsfb_irq_disable(struct drm_device *drm) |
267 |
| -{ |
268 |
| - struct mxsfb_drm_private *mxsfb = drm->dev_private; |
269 |
| - |
270 |
| - mxsfb_enable_axi_clk(mxsfb); |
271 |
| - mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc); |
272 |
| - mxsfb_disable_axi_clk(mxsfb); |
273 |
| -} |
274 |
| - |
275 |
| -static irqreturn_t mxsfb_irq_handler(int irq, void *data) |
276 |
| -{ |
277 |
| - struct drm_device *drm = data; |
278 |
| - struct mxsfb_drm_private *mxsfb = drm->dev_private; |
279 |
| - u32 reg; |
280 |
| - |
281 |
| - reg = readl(mxsfb->base + LCDC_CTRL1); |
282 |
| - |
283 |
| - if (reg & CTRL1_CUR_FRAME_DONE_IRQ) |
284 |
| - drm_crtc_handle_vblank(&mxsfb->crtc); |
285 |
| - |
286 |
| - writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR); |
287 |
| - |
288 |
| - return IRQ_HANDLED; |
289 |
| -} |
290 |
| - |
291 | 313 | DEFINE_DRM_GEM_CMA_FOPS(fops);
|
292 | 314 |
|
293 | 315 | static const struct drm_driver mxsfb_driver = {
|
294 | 316 | .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
|
295 |
| - .irq_handler = mxsfb_irq_handler, |
296 |
| - .irq_preinstall = mxsfb_irq_disable, |
297 |
| - .irq_uninstall = mxsfb_irq_disable, |
298 | 317 | DRM_GEM_CMA_DRIVER_OPS,
|
299 | 318 | .fops = &fops,
|
300 | 319 | .name = "mxsfb-drm",
|
|
0 commit comments