mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-07 05:45:24 +00:00
drm/hisilicon/hibmc: Add MSI irq getting and requesting for HPD
To realize HPD feature, request irq for HPD , add its handler function. We use pci_alloc_irq_vectors() to get our msi irq, because we have two interrupts now. Signed-off-by: Baihan Li <libaihan@huawei.com> Signed-off-by: Yongbang Shi <shiyongbang@huawei.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20250331074212.3370287-9-shiyongbang@huawei.com Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
This commit is contained in:
parent
3c7623fb5b
commit
b11bc1ae46
@ -99,6 +99,9 @@
|
|||||||
|
|
||||||
#define HIBMC_DP_TIMING_SYNC_CTRL 0xFF0
|
#define HIBMC_DP_TIMING_SYNC_CTRL 0xFF0
|
||||||
|
|
||||||
|
#define HIBMC_DP_INTSTAT 0x1e0724
|
||||||
|
#define HIBMC_DP_INTCLR 0x1e0728
|
||||||
|
|
||||||
/* dp serdes reg */
|
/* dp serdes reg */
|
||||||
#define HIBMC_DP_HOST_OFFSET 0x10000
|
#define HIBMC_DP_HOST_OFFSET 0x10000
|
||||||
#define HIBMC_DP_LANE0_RATE_OFFSET 0x4
|
#define HIBMC_DP_LANE0_RATE_OFFSET 0x4
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
DEFINE_DRM_GEM_FOPS(hibmc_fops);
|
DEFINE_DRM_GEM_FOPS(hibmc_fops);
|
||||||
|
|
||||||
|
static const char *g_irqs_names_map[HIBMC_MAX_VECTORS] = { "vblank", "hpd" };
|
||||||
|
|
||||||
static irqreturn_t hibmc_interrupt(int irq, void *arg)
|
static irqreturn_t hibmc_interrupt(int irq, void *arg)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = (struct drm_device *)arg;
|
struct drm_device *dev = (struct drm_device *)arg;
|
||||||
@ -49,6 +51,22 @@ static irqreturn_t hibmc_interrupt(int irq, void *arg)
|
|||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static irqreturn_t hibmc_dp_interrupt(int irq, void *arg)
|
||||||
|
{
|
||||||
|
struct drm_device *dev = (struct drm_device *)arg;
|
||||||
|
struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
|
||||||
|
u32 status;
|
||||||
|
|
||||||
|
status = readl(priv->mmio + HIBMC_DP_INTSTAT);
|
||||||
|
if (status) {
|
||||||
|
priv->dp.irq_status = status;
|
||||||
|
writel(status, priv->mmio + HIBMC_DP_INTCLR);
|
||||||
|
return IRQ_WAKE_THREAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
static int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
|
static int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
|
||||||
struct drm_mode_create_dumb *args)
|
struct drm_mode_create_dumb *args)
|
||||||
{
|
{
|
||||||
@ -251,15 +269,48 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hibmc_unload(struct drm_device *dev)
|
static void hibmc_unload(struct drm_device *dev)
|
||||||
|
{
|
||||||
|
drm_atomic_helper_shutdown(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int hibmc_msi_init(struct drm_device *dev)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
||||||
|
char name[32] = {0};
|
||||||
|
int valid_irq_num;
|
||||||
|
int irq;
|
||||||
|
int ret;
|
||||||
|
|
||||||
drm_atomic_helper_shutdown(dev);
|
ret = pci_alloc_irq_vectors(pdev, HIBMC_MIN_VECTORS,
|
||||||
|
HIBMC_MAX_VECTORS, PCI_IRQ_MSI);
|
||||||
|
if (ret < 0) {
|
||||||
|
drm_err(dev, "enabling MSI failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
free_irq(pdev->irq, dev);
|
valid_irq_num = ret;
|
||||||
|
|
||||||
pci_disable_msi(to_pci_dev(dev->dev));
|
for (int i = 0; i < valid_irq_num; i++) {
|
||||||
|
snprintf(name, ARRAY_SIZE(name) - 1, "%s-%s-%s",
|
||||||
|
dev->driver->name, pci_name(pdev), g_irqs_names_map[i]);
|
||||||
|
|
||||||
|
irq = pci_irq_vector(pdev, i);
|
||||||
|
|
||||||
|
if (i)
|
||||||
|
/* PCI devices require shared interrupts. */
|
||||||
|
ret = devm_request_threaded_irq(&pdev->dev, irq,
|
||||||
|
hibmc_dp_interrupt,
|
||||||
|
hibmc_dp_hpd_isr,
|
||||||
|
IRQF_SHARED, name, dev);
|
||||||
|
else
|
||||||
|
ret = devm_request_irq(&pdev->dev, irq, hibmc_interrupt,
|
||||||
|
IRQF_SHARED, name, dev);
|
||||||
|
if (ret) {
|
||||||
|
drm_err(dev, "install irq failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -291,15 +342,10 @@ static int hibmc_load(struct drm_device *dev)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pci_enable_msi(pdev);
|
ret = hibmc_msi_init(dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
drm_warn(dev, "enabling MSI failed: %d\n", ret);
|
drm_err(dev, "hibmc msi init failed, ret:%d\n", ret);
|
||||||
} else {
|
goto err;
|
||||||
/* PCI devices require shared interrupts. */
|
|
||||||
ret = request_irq(pdev->irq, hibmc_interrupt, IRQF_SHARED,
|
|
||||||
dev->driver->name, dev);
|
|
||||||
if (ret)
|
|
||||||
drm_warn(dev, "install irq failed: %d\n", ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset all the states of crtc/plane/encoder/connector */
|
/* reset all the states of crtc/plane/encoder/connector */
|
||||||
@ -375,7 +421,7 @@ static void hibmc_pci_remove(struct pci_dev *pdev)
|
|||||||
|
|
||||||
static void hibmc_pci_shutdown(struct pci_dev *pdev)
|
static void hibmc_pci_shutdown(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
drm_atomic_helper_shutdown(pci_get_drvdata(pdev));
|
hibmc_pci_remove(pdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_device_id hibmc_pci_table[] = {
|
static const struct pci_device_id hibmc_pci_table[] = {
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
#include "dp/dp_hw.h"
|
#include "dp/dp_hw.h"
|
||||||
|
|
||||||
|
#define HIBMC_MIN_VECTORS 1
|
||||||
|
#define HIBMC_MAX_VECTORS 2
|
||||||
|
|
||||||
struct hibmc_vdac {
|
struct hibmc_vdac {
|
||||||
struct drm_device *dev;
|
struct drm_device *dev;
|
||||||
struct drm_encoder encoder;
|
struct drm_encoder encoder;
|
||||||
|
Loading…
Reference in New Issue
Block a user