linux_dsm_epyc7002/drivers/gpu/drm/tidss/tidss_irq.c
Jyri Sarha 32a1795f57 drm/tidss: New driver for TI Keystone platform Display SubSystem
This patch adds a new DRM driver for Texas Instruments DSS IPs used on
Texas Instruments Keystone K2G, AM65x, and J721e SoCs. The new DSS IP is
a major change to the older DSS IP versions, which are supported by
the omapdrm driver. While on higher level the Keystone DSS resembles
the older DSS versions, the registers are completely different and the
internal pipelines differ a lot.

DSS IP found on K2G is an "ultra-light" version, and has only a single
plane and a single output. The K3 DSS IPs are found on AM65x and J721E
SoCs. AM65x DSS has two video ports, one full video plane, and another
"lite" plane without scaling support. J721E has 4 video ports, 2 video
planes and 2 lite planes. AM65x DSS has also an integrated OLDI (LVDS)
output.

Version history:

v2: - rebased on top of drm-next-2019-11-27
    - sort all include lines in all files
    - remove all include <drm/drmP.h>
    - remove select "select VIDEOMODE_HELPERS"
    - call dispc_vp_setup() later in tidss_crtc_atomic_flush() (there is no
      to call it in new modeset case as it is also called in vp_enable())
    - change probe sequence and drm_device allocation (follow example in
      drm_drv.c)
    - use __maybe_unused instead of #ifdef for pm functions
    - remove "struct drm_fbdev_cma *fbdev;" from driver data
    - check panel connector type before connecting it

v3: no change

v4: no change

v5: - remove fifo underflow irq handling, it is not an error and
      it should be used for debug purposes only
    - memory tuning, prefetch plane fifo up to high-threshold value to
      minimize possibility of underflows.

v6: - Check CTM and gamma support from dispc_features when creating crtc
    - Implement CTM support for k2g and fix k3 CTM implementation
    - Remove gamma property persistence and always write color properties
      in a new modeset

v7: - Fix checkpatch.pl --strict issues
    - Rebase on top of drm-misc-next-2020-01-10

v8: - Remove idle debug prints from dispc_init()
    - Add Reviewed-by: Benoit Parrot <bparrot@ti.com>

v9: - Rename dispc_write_irqenable() to dispc_set_irqenable() to avoid
      conflict exported omapfb function with same name
    - Add Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Co-developed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/925fbfad58ff828e8e07fdff7073a0ee65750c3d.1580129724.git.jsarha@ti.com
2020-01-27 19:27:30 +02:00

147 lines
3.6 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
* Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
*/
#include <drm/drm_print.h>
#include "tidss_crtc.h"
#include "tidss_dispc.h"
#include "tidss_drv.h"
#include "tidss_irq.h"
#include "tidss_plane.h"
/* call with wait_lock and dispc runtime held */
static void tidss_irq_update(struct tidss_device *tidss)
{
assert_spin_locked(&tidss->wait_lock);
dispc_set_irqenable(tidss->dispc, tidss->irq_mask);
}
void tidss_irq_enable_vblank(struct drm_crtc *crtc)
{
struct drm_device *ddev = crtc->dev;
struct tidss_device *tidss = ddev->dev_private;
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
u32 hw_videoport = tcrtc->hw_videoport;
unsigned long flags;
spin_lock_irqsave(&tidss->wait_lock, flags);
tidss->irq_mask |= DSS_IRQ_VP_VSYNC_EVEN(hw_videoport) |
DSS_IRQ_VP_VSYNC_ODD(hw_videoport);
tidss_irq_update(tidss);
spin_unlock_irqrestore(&tidss->wait_lock, flags);
}
void tidss_irq_disable_vblank(struct drm_crtc *crtc)
{
struct drm_device *ddev = crtc->dev;
struct tidss_device *tidss = ddev->dev_private;
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
u32 hw_videoport = tcrtc->hw_videoport;
unsigned long flags;
spin_lock_irqsave(&tidss->wait_lock, flags);
tidss->irq_mask &= ~(DSS_IRQ_VP_VSYNC_EVEN(hw_videoport) |
DSS_IRQ_VP_VSYNC_ODD(hw_videoport));
tidss_irq_update(tidss);
spin_unlock_irqrestore(&tidss->wait_lock, flags);
}
irqreturn_t tidss_irq_handler(int irq, void *arg)
{
struct drm_device *ddev = (struct drm_device *)arg;
struct tidss_device *tidss = ddev->dev_private;
unsigned int id;
dispc_irq_t irqstatus;
if (WARN_ON(!ddev->irq_enabled))
return IRQ_NONE;
irqstatus = dispc_read_and_clear_irqstatus(tidss->dispc);
for (id = 0; id < tidss->num_crtcs; id++) {
struct drm_crtc *crtc = tidss->crtcs[id];
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
u32 hw_videoport = tcrtc->hw_videoport;
if (irqstatus & (DSS_IRQ_VP_VSYNC_EVEN(hw_videoport) |
DSS_IRQ_VP_VSYNC_ODD(hw_videoport)))
tidss_crtc_vblank_irq(crtc);
if (irqstatus & (DSS_IRQ_VP_FRAME_DONE(hw_videoport)))
tidss_crtc_framedone_irq(crtc);
if (irqstatus & DSS_IRQ_VP_SYNC_LOST(hw_videoport))
tidss_crtc_error_irq(crtc, irqstatus);
}
if (irqstatus & DSS_IRQ_DEVICE_OCP_ERR)
dev_err_ratelimited(tidss->dev, "OCP error\n");
return IRQ_HANDLED;
}
void tidss_irq_resume(struct tidss_device *tidss)
{
unsigned long flags;
spin_lock_irqsave(&tidss->wait_lock, flags);
tidss_irq_update(tidss);
spin_unlock_irqrestore(&tidss->wait_lock, flags);
}
void tidss_irq_preinstall(struct drm_device *ddev)
{
struct tidss_device *tidss = ddev->dev_private;
spin_lock_init(&tidss->wait_lock);
tidss_runtime_get(tidss);
dispc_set_irqenable(tidss->dispc, 0);
dispc_read_and_clear_irqstatus(tidss->dispc);
tidss_runtime_put(tidss);
}
int tidss_irq_postinstall(struct drm_device *ddev)
{
struct tidss_device *tidss = ddev->dev_private;
unsigned long flags;
unsigned int i;
tidss_runtime_get(tidss);
spin_lock_irqsave(&tidss->wait_lock, flags);
tidss->irq_mask = DSS_IRQ_DEVICE_OCP_ERR;
for (i = 0; i < tidss->num_crtcs; ++i) {
struct tidss_crtc *tcrtc = to_tidss_crtc(tidss->crtcs[i]);
tidss->irq_mask |= DSS_IRQ_VP_SYNC_LOST(tcrtc->hw_videoport);
tidss->irq_mask |= DSS_IRQ_VP_FRAME_DONE(tcrtc->hw_videoport);
}
tidss_irq_update(tidss);
spin_unlock_irqrestore(&tidss->wait_lock, flags);
tidss_runtime_put(tidss);
return 0;
}
void tidss_irq_uninstall(struct drm_device *ddev)
{
struct tidss_device *tidss = ddev->dev_private;
tidss_runtime_get(tidss);
dispc_set_irqenable(tidss->dispc, 0);
tidss_runtime_put(tidss);
}