Skip to content

Commit e5d9ddf

Browse files
author
Russell King
committed
drm/armada: move IRQ handling into CRTC
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 4c83445 commit e5d9ddf

3 files changed

Lines changed: 45 additions & 63 deletions

File tree

‎drivers/gpu/drm/armada/armada_crtc.c‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc,
349349
return true;
350350
}
351351

352-
void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
352+
static void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
353353
{
354354
struct armada_vbl_event *e, *n;
355355
void __iomem *base = dcrtc->base;
@@ -410,6 +410,27 @@ void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
410410
}
411411
}
412412

413+
static irqreturn_t armada_drm_irq(int irq, void *arg)
414+
{
415+
struct armada_crtc *dcrtc = arg;
416+
u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
417+
418+
/*
419+
* This is rediculous - rather than writing bits to clear, we
420+
* have to set the actual status register value. This is racy.
421+
*/
422+
writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
423+
424+
/* Mask out those interrupts we haven't enabled */
425+
v = stat & dcrtc->irq_ena;
426+
427+
if (v & (VSYNC_IRQ|GRA_FRAME_IRQ|DUMB_FRAMEDONE)) {
428+
armada_drm_crtc_irq(dcrtc, stat);
429+
return IRQ_HANDLED;
430+
}
431+
return IRQ_NONE;
432+
}
433+
413434
/* These are locked by dev->vbl_lock */
414435
void armada_drm_crtc_disable_irq(struct armada_crtc *dcrtc, u32 mask)
415436
{
@@ -888,6 +909,8 @@ static void armada_drm_crtc_destroy(struct drm_crtc *crtc)
888909
if (!IS_ERR(dcrtc->clk))
889910
clk_disable_unprepare(dcrtc->clk);
890911

912+
writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ENA);
913+
891914
kfree(dcrtc);
892915
}
893916

@@ -1028,7 +1051,7 @@ static int armada_drm_crtc_create_properties(struct drm_device *dev)
10281051
}
10291052

10301053
int armada_drm_crtc_create(struct drm_device *dev, unsigned num,
1031-
struct resource *res)
1054+
struct resource *res, int irq)
10321055
{
10331056
struct armada_private *priv = dev->dev_private;
10341057
struct armada_crtc *dcrtc;
@@ -1074,6 +1097,15 @@ int armada_drm_crtc_create(struct drm_device *dev, unsigned num,
10741097
CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);
10751098
writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1);
10761099
writel_relaxed(0x00000000, dcrtc->base + LCD_SPU_GRA_OVSA_HPXL_VLN);
1100+
writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
1101+
writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
1102+
1103+
ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
1104+
dcrtc);
1105+
if (ret < 0) {
1106+
kfree(dcrtc);
1107+
return ret;
1108+
}
10771109

10781110
if (priv->variant->crtc_init) {
10791111
ret = priv->variant->crtc_init(dcrtc);

‎drivers/gpu/drm/armada/armada_crtc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ struct armada_crtc {
7272
};
7373
#define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
7474

75-
int armada_drm_crtc_create(struct drm_device *, unsigned, struct resource *);
75+
int armada_drm_crtc_create(struct drm_device *, unsigned, struct resource *,
76+
int);
7677
void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
7778
void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
78-
void armada_drm_crtc_irq(struct armada_crtc *, u32);
7979
void armada_drm_crtc_disable_irq(struct armada_crtc *, u32);
8080
void armada_drm_crtc_enable_irq(struct armada_crtc *, u32);
8181
void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);

‎drivers/gpu/drm/armada/armada_drv.c‎

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,16 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
155155

156156
/* Create all LCD controllers */
157157
for (n = 0; n < ARRAY_SIZE(priv->dcrtc); n++) {
158+
int irq;
159+
158160
if (!res[n])
159161
break;
160162

161-
ret = armada_drm_crtc_create(dev, n, res[n]);
163+
irq = platform_get_irq(dev->platformdev, n);
164+
if (irq < 0)
165+
goto err_kms;
166+
167+
ret = armada_drm_crtc_create(dev, n, res[n], irq);
162168
if (ret)
163169
goto err_kms;
164170
}
@@ -173,22 +179,16 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
173179
if (ret)
174180
goto err_kms;
175181

176-
ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
177-
if (ret)
178-
goto err_kms;
179-
180182
dev->vblank_disable_allowed = 1;
181183

182184
ret = armada_fbdev_init(dev);
183185
if (ret)
184-
goto err_irq;
186+
goto err_kms;
185187

186188
drm_kms_helper_poll_init(dev);
187189

188190
return 0;
189191

190-
err_irq:
191-
drm_irq_uninstall(dev);
192192
err_kms:
193193
drm_mode_config_cleanup(dev);
194194
drm_mm_takedown(&priv->linear);
@@ -203,7 +203,6 @@ static int armada_drm_unload(struct drm_device *dev)
203203

204204
drm_kms_helper_poll_fini(dev);
205205
armada_fbdev_fini(dev);
206-
drm_irq_uninstall(dev);
207206
drm_mode_config_cleanup(dev);
208207
drm_mm_takedown(&priv->linear);
209208
flush_work(&priv->fb_unref_work);
@@ -259,52 +258,6 @@ static void armada_drm_disable_vblank(struct drm_device *dev, int crtc)
259258
armada_drm_crtc_disable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
260259
}
261260

262-
static irqreturn_t armada_drm_irq_handler(int irq, void *arg)
263-
{
264-
struct drm_device *dev = arg;
265-
struct armada_private *priv = dev->dev_private;
266-
struct armada_crtc *dcrtc = priv->dcrtc[0];
267-
uint32_t v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
268-
irqreturn_t handled = IRQ_NONE;
269-
270-
/*
271-
* This is rediculous - rather than writing bits to clear, we
272-
* have to set the actual status register value. This is racy.
273-
*/
274-
writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
275-
276-
/* Mask out those interrupts we haven't enabled */
277-
v = stat & dcrtc->irq_ena;
278-
279-
if (v & (VSYNC_IRQ|GRA_FRAME_IRQ|DUMB_FRAMEDONE)) {
280-
armada_drm_crtc_irq(dcrtc, stat);
281-
handled = IRQ_HANDLED;
282-
}
283-
284-
return handled;
285-
}
286-
287-
static int armada_drm_irq_postinstall(struct drm_device *dev)
288-
{
289-
struct armada_private *priv = dev->dev_private;
290-
struct armada_crtc *dcrtc = priv->dcrtc[0];
291-
292-
spin_lock_irq(&dev->vbl_lock);
293-
writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
294-
writel(0, dcrtc->base + LCD_SPU_IRQ_ISR);
295-
spin_unlock_irq(&dev->vbl_lock);
296-
297-
return 0;
298-
}
299-
300-
static void armada_drm_irq_uninstall(struct drm_device *dev)
301-
{
302-
struct armada_private *priv = dev->dev_private;
303-
struct armada_crtc *dcrtc = priv->dcrtc[0];
304-
305-
writel(0, dcrtc->base + LCD_SPU_IRQ_ENA);
306-
}
307-
308261
static struct drm_ioctl_desc armada_ioctls[] = {
309262
DRM_IOCTL_DEF_DRV(ARMADA_GEM_CREATE, armada_gem_create_ioctl,
310263
DRM_UNLOCKED),
@@ -340,9 +293,6 @@ static struct drm_driver armada_drm_driver = {
340293
.get_vblank_counter = drm_vblank_count,
341294
.enable_vblank = armada_drm_enable_vblank,
342295
.disable_vblank = armada_drm_disable_vblank,
343-
.irq_handler = armada_drm_irq_handler,
344-
.irq_postinstall = armada_drm_irq_postinstall,
345-
.irq_uninstall = armada_drm_irq_uninstall,
346296
#ifdef CONFIG_DEBUG_FS
347297
.debugfs_init = armada_drm_debugfs_init,
348298
.debugfs_cleanup = armada_drm_debugfs_cleanup,
@@ -362,7 +312,7 @@ static struct drm_driver armada_drm_driver = {
362312
.desc = "Armada SoC DRM",
363313
.date = "20120730",
364314
.driver_features = DRIVER_GEM | DRIVER_MODESET |
365-
DRIVER_HAVE_IRQ | DRIVER_PRIME,
315+
DRIVER_PRIME,
366316
.ioctls = armada_ioctls,
367317
.fops = &armada_drm_fops,
368318
};

0 commit comments

Comments
 (0)