1 /* mach64_irq.c -- IRQ handling for ATI Mach64 -*- linux-c -*-
2 * Created: Tue Feb 25, 2003 by Leif Delgass, based on radeon_irq.c/r128_irq.c
5 * Copyright (C) The Weather Channel, Inc. 2002.
6 * Copyright 2003 Leif Delgass
9 * The Weather Channel (TM) funded Tungsten Graphics to develop the
10 * initial release of the Radeon 8500 driver under the XFree86 license.
11 * This notice must be preserved.
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
20 * The above copyright notice and this permission notice (including the next
21 * paragraph) shall be included in all copies or substantial portions of the
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 * DEALINGS IN THE SOFTWARE.
33 * Keith Whitwell <keith@tungstengraphics.com>
34 * Eric Anholt <anholt@FreeBSD.org>
35 * Leif Delgass <ldelgass@retinalburn.net>
37 * $DragonFly: src/sys/dev/drm/mach64_irq.c,v 1.1 2008/04/05 18:12:29 hasso Exp $
42 #include "mach64_drm.h"
43 #include "mach64_drv.h"
45 irqreturn_t
mach64_driver_irq_handler(DRM_IRQ_ARGS
)
47 struct drm_device
*dev
= (struct drm_device
*) arg
;
48 drm_mach64_private_t
*dev_priv
=
49 (drm_mach64_private_t
*) dev
->dev_private
;
52 status
= MACH64_READ(MACH64_CRTC_INT_CNTL
);
54 /* VBLANK interrupt */
55 if (status
& MACH64_CRTC_VBLANK_INT
) {
56 /* Mask off all interrupt ack bits before setting the ack bit, since
57 * there may be other handlers outside the DRM.
59 * NOTE: On mach64, you need to keep the enable bits set when doing
60 * the ack, despite what the docs say about not acking and enabling
63 MACH64_WRITE(MACH64_CRTC_INT_CNTL
,
64 (status
& ~MACH64_CRTC_INT_ACKS
)
65 | MACH64_CRTC_VBLANK_INT
);
67 atomic_inc(&dev
->vbl_received
);
68 DRM_WAKEUP(&dev
->vbl_queue
);
69 drm_vbl_send_signals(dev
);
75 int mach64_driver_vblank_wait(struct drm_device
* dev
, unsigned int *sequence
)
77 unsigned int cur_vblank
;
80 /* Assume that the user has missed the current sequence number
81 * by about a day rather than she wants to wait for years
82 * using vertical blanks...
84 DRM_WAIT_ON(ret
, dev
->vbl_queue
, 3 * DRM_HZ
,
85 (((cur_vblank
= atomic_read(&dev
->vbl_received
))
86 - *sequence
) <= (1 << 23)));
88 *sequence
= cur_vblank
;
95 void mach64_driver_irq_preinstall(struct drm_device
* dev
)
97 drm_mach64_private_t
*dev_priv
=
98 (drm_mach64_private_t
*) dev
->dev_private
;
100 u32 status
= MACH64_READ(MACH64_CRTC_INT_CNTL
);
102 DRM_DEBUG("before install CRTC_INT_CTNL: 0x%08x\n", status
);
104 /* Disable and clear VBLANK interrupt */
105 MACH64_WRITE(MACH64_CRTC_INT_CNTL
, (status
& ~MACH64_CRTC_VBLANK_INT_EN
)
106 | MACH64_CRTC_VBLANK_INT
);
109 void mach64_driver_irq_postinstall(struct drm_device
* dev
)
111 drm_mach64_private_t
*dev_priv
=
112 (drm_mach64_private_t
*) dev
->dev_private
;
114 /* Turn on VBLANK interrupt */
115 MACH64_WRITE(MACH64_CRTC_INT_CNTL
, MACH64_READ(MACH64_CRTC_INT_CNTL
)
116 | MACH64_CRTC_VBLANK_INT_EN
);
118 DRM_DEBUG("after install CRTC_INT_CTNL: 0x%08x\n",
119 MACH64_READ(MACH64_CRTC_INT_CNTL
));
123 void mach64_driver_irq_uninstall(struct drm_device
* dev
)
125 drm_mach64_private_t
*dev_priv
=
126 (drm_mach64_private_t
*) dev
->dev_private
;
130 /* Disable and clear VBLANK interrupt */
131 MACH64_WRITE(MACH64_CRTC_INT_CNTL
,
132 (MACH64_READ(MACH64_CRTC_INT_CNTL
) &
133 ~MACH64_CRTC_VBLANK_INT_EN
)
134 | MACH64_CRTC_VBLANK_INT
);
136 DRM_DEBUG("after uninstall CRTC_INT_CTNL: 0x%08x\n",
137 MACH64_READ(MACH64_CRTC_INT_CNTL
));