mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
drm/mxsfb: Convert to Linux IRQ interfaces
Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers don't benefit from using it. DRM IRQ callbacks are now being called directly or inlined. Calls to platform_get_irq() can fail with a negative errno code. Abort initialization in this case. The DRM IRQ midlayer does not handle this case correctly. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20210803090704.32152-9-tzimmermann@suse.de
This commit is contained in:
parent
f026e431cf
commit
5fc40f41c1
2 changed files with 52 additions and 31 deletions
|
@ -24,7 +24,6 @@
|
|||
#include <drm/drm_fourcc.h>
|
||||
#include <drm/drm_gem_cma_helper.h>
|
||||
#include <drm/drm_gem_framebuffer_helper.h>
|
||||
#include <drm/drm_irq.h>
|
||||
#include <drm/drm_mode_config.h>
|
||||
#include <drm/drm_of.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
|
@ -153,6 +152,49 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static irqreturn_t mxsfb_irq_handler(int irq, void *data)
|
||||
{
|
||||
struct drm_device *drm = data;
|
||||
struct mxsfb_drm_private *mxsfb = drm->dev_private;
|
||||
u32 reg;
|
||||
|
||||
reg = readl(mxsfb->base + LCDC_CTRL1);
|
||||
|
||||
if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
|
||||
drm_crtc_handle_vblank(&mxsfb->crtc);
|
||||
|
||||
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void mxsfb_irq_disable(struct drm_device *drm)
|
||||
{
|
||||
struct mxsfb_drm_private *mxsfb = drm->dev_private;
|
||||
|
||||
mxsfb_enable_axi_clk(mxsfb);
|
||||
mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
|
||||
mxsfb_disable_axi_clk(mxsfb);
|
||||
}
|
||||
|
||||
static int mxsfb_irq_install(struct drm_device *dev, int irq)
|
||||
{
|
||||
if (irq == IRQ_NOTCONNECTED)
|
||||
return -ENOTCONN;
|
||||
|
||||
mxsfb_irq_disable(dev);
|
||||
|
||||
return request_irq(irq, mxsfb_irq_handler, 0, dev->driver->name, dev);
|
||||
}
|
||||
|
||||
static void mxsfb_irq_uninstall(struct drm_device *dev)
|
||||
{
|
||||
struct mxsfb_drm_private *mxsfb = dev->dev_private;
|
||||
|
||||
mxsfb_irq_disable(dev);
|
||||
free_irq(mxsfb->irq, dev);
|
||||
}
|
||||
|
||||
static int mxsfb_load(struct drm_device *drm,
|
||||
const struct mxsfb_devdata *devdata)
|
||||
{
|
||||
|
@ -226,8 +268,13 @@ static int mxsfb_load(struct drm_device *drm,
|
|||
|
||||
drm_mode_config_reset(drm);
|
||||
|
||||
ret = platform_get_irq(pdev, 0);
|
||||
if (ret < 0)
|
||||
goto err_vblank;
|
||||
mxsfb->irq = ret;
|
||||
|
||||
pm_runtime_get_sync(drm->dev);
|
||||
ret = drm_irq_install(drm, platform_get_irq(pdev, 0));
|
||||
ret = mxsfb_irq_install(drm, mxsfb->irq);
|
||||
pm_runtime_put_sync(drm->dev);
|
||||
|
||||
if (ret < 0) {
|
||||
|
@ -255,7 +302,7 @@ static void mxsfb_unload(struct drm_device *drm)
|
|||
drm_mode_config_cleanup(drm);
|
||||
|
||||
pm_runtime_get_sync(drm->dev);
|
||||
drm_irq_uninstall(drm);
|
||||
mxsfb_irq_uninstall(drm);
|
||||
pm_runtime_put_sync(drm->dev);
|
||||
|
||||
drm->dev_private = NULL;
|
||||
|
@ -263,38 +310,10 @@ static void mxsfb_unload(struct drm_device *drm)
|
|||
pm_runtime_disable(drm->dev);
|
||||
}
|
||||
|
||||
static void mxsfb_irq_disable(struct drm_device *drm)
|
||||
{
|
||||
struct mxsfb_drm_private *mxsfb = drm->dev_private;
|
||||
|
||||
mxsfb_enable_axi_clk(mxsfb);
|
||||
mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
|
||||
mxsfb_disable_axi_clk(mxsfb);
|
||||
}
|
||||
|
||||
static irqreturn_t mxsfb_irq_handler(int irq, void *data)
|
||||
{
|
||||
struct drm_device *drm = data;
|
||||
struct mxsfb_drm_private *mxsfb = drm->dev_private;
|
||||
u32 reg;
|
||||
|
||||
reg = readl(mxsfb->base + LCDC_CTRL1);
|
||||
|
||||
if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
|
||||
drm_crtc_handle_vblank(&mxsfb->crtc);
|
||||
|
||||
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
DEFINE_DRM_GEM_CMA_FOPS(fops);
|
||||
|
||||
static const struct drm_driver mxsfb_driver = {
|
||||
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
|
||||
.irq_handler = mxsfb_irq_handler,
|
||||
.irq_preinstall = mxsfb_irq_disable,
|
||||
.irq_uninstall = mxsfb_irq_disable,
|
||||
DRM_GEM_CMA_DRIVER_OPS,
|
||||
.fops = &fops,
|
||||
.name = "mxsfb-drm",
|
||||
|
|
|
@ -33,6 +33,8 @@ struct mxsfb_drm_private {
|
|||
struct clk *clk_axi;
|
||||
struct clk *clk_disp_axi;
|
||||
|
||||
unsigned int irq;
|
||||
|
||||
struct drm_device *drm;
|
||||
struct {
|
||||
struct drm_plane primary;
|
||||
|
|
Loading…
Add table
Reference in a new issue