linux-zen-desktop/drivers/gpu/drm/exynos/exynos_drm_dsi.c

196 lines
5.0 KiB
C
Raw Normal View History

2023-08-30 17:31:07 +02:00
// SPDX-License-Identifier: GPL-2.0-only
/*
2023-10-24 12:59:35 +02:00
* Samsung MIPI DSIM glue for Exynos SoCs.
2023-08-30 17:31:07 +02:00
*
* Copyright (c) 2014 Samsung Electronics Co., Ltd
*
* Contacts: Tomasz Figa <t.figa@samsung.com>
2023-10-24 12:59:35 +02:00
*/
2023-08-30 17:31:07 +02:00
#include <linux/component.h>
#include <linux/of_device.h>
2023-10-24 12:59:35 +02:00
#include <drm/bridge/samsung-dsim.h>
2023-08-30 17:31:07 +02:00
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
#include "exynos_drm_crtc.h"
#include "exynos_drm_drv.h"
struct exynos_dsi {
struct drm_encoder encoder;
};
2023-10-24 12:59:35 +02:00
static irqreturn_t exynos_dsi_te_irq_handler(struct samsung_dsim *dsim)
2023-08-30 17:31:07 +02:00
{
2023-10-24 12:59:35 +02:00
struct exynos_dsi *dsi = dsim->priv;
2023-08-30 17:31:07 +02:00
struct drm_encoder *encoder = &dsi->encoder;
2023-10-24 12:59:35 +02:00
if (dsim->state & DSIM_STATE_VIDOUT_AVAILABLE)
2023-08-30 17:31:07 +02:00
exynos_drm_crtc_te_handler(encoder->crtc);
return IRQ_HANDLED;
}
2023-10-24 12:59:35 +02:00
static int exynos_dsi_host_attach(struct samsung_dsim *dsim,
2023-08-30 17:31:07 +02:00
struct mipi_dsi_device *device)
{
2023-10-24 12:59:35 +02:00
struct exynos_dsi *dsi = dsim->priv;
2023-08-30 17:31:07 +02:00
struct drm_encoder *encoder = &dsi->encoder;
struct drm_device *drm = encoder->dev;
2023-10-24 12:59:35 +02:00
drm_bridge_attach(encoder, &dsim->bridge,
2023-08-30 17:31:07 +02:00
list_first_entry_or_null(&encoder->bridge_chain,
struct drm_bridge,
chain_node), 0);
mutex_lock(&drm->mode_config.mutex);
2023-10-24 12:59:35 +02:00
dsim->lanes = device->lanes;
dsim->format = device->format;
dsim->mode_flags = device->mode_flags;
2023-08-30 17:31:07 +02:00
exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD)->i80_mode =
2023-10-24 12:59:35 +02:00
!(dsim->mode_flags & MIPI_DSI_MODE_VIDEO);
2023-08-30 17:31:07 +02:00
mutex_unlock(&drm->mode_config.mutex);
if (drm->mode_config.poll_enabled)
drm_kms_helper_hotplug_event(drm);
return 0;
}
2023-10-24 12:59:35 +02:00
static void exynos_dsi_host_detach(struct samsung_dsim *dsim,
struct mipi_dsi_device *device)
2023-08-30 17:31:07 +02:00
{
2023-10-24 12:59:35 +02:00
struct exynos_dsi *dsi = dsim->priv;
2023-08-30 17:31:07 +02:00
struct drm_device *drm = dsi->encoder.dev;
if (drm->mode_config.poll_enabled)
drm_kms_helper_hotplug_event(drm);
}
2023-10-24 12:59:35 +02:00
static int exynos_dsi_bind(struct device *dev, struct device *master, void *data)
2023-08-30 17:31:07 +02:00
{
2023-10-24 12:59:35 +02:00
struct samsung_dsim *dsim = dev_get_drvdata(dev);
struct exynos_dsi *dsi = dsim->priv;
2023-08-30 17:31:07 +02:00
struct drm_encoder *encoder = &dsi->encoder;
struct drm_device *drm_dev = data;
int ret;
drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS);
ret = exynos_drm_set_possible_crtcs(encoder, EXYNOS_DISPLAY_TYPE_LCD);
if (ret < 0)
return ret;
2023-10-24 12:59:35 +02:00
return mipi_dsi_host_register(&dsim->dsi_host);
2023-08-30 17:31:07 +02:00
}
2023-10-24 12:59:35 +02:00
static void exynos_dsi_unbind(struct device *dev, struct device *master, void *data)
2023-08-30 17:31:07 +02:00
{
2023-10-24 12:59:35 +02:00
struct samsung_dsim *dsim = dev_get_drvdata(dev);
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
dsim->bridge.funcs->atomic_disable(&dsim->bridge, NULL);
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
mipi_dsi_host_unregister(&dsim->dsi_host);
2023-08-30 17:31:07 +02:00
}
static const struct component_ops exynos_dsi_component_ops = {
.bind = exynos_dsi_bind,
.unbind = exynos_dsi_unbind,
};
2023-10-24 12:59:35 +02:00
static int exynos_dsi_register_host(struct samsung_dsim *dsim)
2023-08-30 17:31:07 +02:00
{
struct exynos_dsi *dsi;
2023-10-24 12:59:35 +02:00
dsi = devm_kzalloc(dsim->dev, sizeof(*dsi), GFP_KERNEL);
2023-08-30 17:31:07 +02:00
if (!dsi)
return -ENOMEM;
2023-10-24 12:59:35 +02:00
dsim->priv = dsi;
dsim->bridge.pre_enable_prev_first = true;
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
return component_add(dsim->dev, &exynos_dsi_component_ops);
2023-08-30 17:31:07 +02:00
}
2023-10-24 12:59:35 +02:00
static void exynos_dsi_unregister_host(struct samsung_dsim *dsim)
2023-08-30 17:31:07 +02:00
{
2023-10-24 12:59:35 +02:00
component_del(dsim->dev, &exynos_dsi_component_ops);
2023-08-30 17:31:07 +02:00
}
2023-10-24 12:59:35 +02:00
static const struct samsung_dsim_host_ops exynos_dsi_exynos_host_ops = {
.register_host = exynos_dsi_register_host,
.unregister_host = exynos_dsi_unregister_host,
.attach = exynos_dsi_host_attach,
.detach = exynos_dsi_host_detach,
.te_irq_handler = exynos_dsi_te_irq_handler,
};
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
static const struct samsung_dsim_plat_data exynos3250_dsi_pdata = {
.hw_type = DSIM_TYPE_EXYNOS3250,
.host_ops = &exynos_dsi_exynos_host_ops,
};
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
static const struct samsung_dsim_plat_data exynos4210_dsi_pdata = {
.hw_type = DSIM_TYPE_EXYNOS4210,
.host_ops = &exynos_dsi_exynos_host_ops,
};
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
static const struct samsung_dsim_plat_data exynos5410_dsi_pdata = {
.hw_type = DSIM_TYPE_EXYNOS5410,
.host_ops = &exynos_dsi_exynos_host_ops,
};
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
static const struct samsung_dsim_plat_data exynos5422_dsi_pdata = {
.hw_type = DSIM_TYPE_EXYNOS5422,
.host_ops = &exynos_dsi_exynos_host_ops,
};
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
static const struct samsung_dsim_plat_data exynos5433_dsi_pdata = {
.hw_type = DSIM_TYPE_EXYNOS5433,
.host_ops = &exynos_dsi_exynos_host_ops,
};
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
static const struct of_device_id exynos_dsi_of_match[] = {
{
.compatible = "samsung,exynos3250-mipi-dsi",
.data = &exynos3250_dsi_pdata,
},
{
.compatible = "samsung,exynos4210-mipi-dsi",
.data = &exynos4210_dsi_pdata,
},
{
.compatible = "samsung,exynos5410-mipi-dsi",
.data = &exynos5410_dsi_pdata,
},
{
.compatible = "samsung,exynos5422-mipi-dsi",
.data = &exynos5422_dsi_pdata,
},
{
.compatible = "samsung,exynos5433-mipi-dsi",
.data = &exynos5433_dsi_pdata,
},
{ /* sentinel. */ }
2023-08-30 17:31:07 +02:00
};
2023-10-24 12:59:35 +02:00
MODULE_DEVICE_TABLE(of, exynos_dsi_of_match);
2023-08-30 17:31:07 +02:00
struct platform_driver dsi_driver = {
2023-10-24 12:59:35 +02:00
.probe = samsung_dsim_probe,
.remove = samsung_dsim_remove,
2023-08-30 17:31:07 +02:00
.driver = {
.name = "exynos-dsi",
.owner = THIS_MODULE,
2023-10-24 12:59:35 +02:00
.pm = &samsung_dsim_pm_ops,
2023-08-30 17:31:07 +02:00
.of_match_table = exynos_dsi_of_match,
},
};
MODULE_AUTHOR("Tomasz Figa <t.figa@samsung.com>");
MODULE_AUTHOR("Andrzej Hajda <a.hajda@samsung.com>");
MODULE_DESCRIPTION("Samsung SoC MIPI DSI Master");
MODULE_LICENSE("GPL v2");