mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-27 13:05:03 +08:00
be8454afc5
-----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJdLMSbAAoJEAx081l5xIa+udkP/iWr8mw44tWYb8Wuzc/aR91v 02X/J4S9XTQttNn/1Gpq9ItTLMf0Gc08tk1wEBBHAWi/qGaGZS2al+rv0afeuuQa aFhQzioDi7K/YZt92iEJhdx7wVMyydICTg3INmYlSP7/FyzLp6gBQRGSJ1kX5mHZ qWsFZgUOH9V5evyB6fDMleDaqFOKfcwrD7XYwbOheL/HeYQSv5AYn3VBupBFQ76L 0hclI5VzZQ5V0nnqRTNDQVA9Yl6NTl+2eXTn5vuBtwKXEI6JJw8eihZp2oZDXqfS L441w7wGbkRPzN5kjMZjs1ToPMTlMveR5kL6Sc+o3DT/HmIr1odeaSDXR/93UOLd z0CRJ6xMC8h1ThLNHp8UgbxCKqIwYPsY2wVqjsJt7lDY5jma7Yv2YJ9ocYGHN/sO DVHcU6ugbwvuC5wZZtVZl5J4hjnBZwNRGSVK+iM0tkjalgdEuSFehXT7eQ8SphF/ yI5gD1xNEwGfZ4bvZ3u/QrDCcpUAgPIUYmxEa2tPJILQWOJ9O87yc0y9Z21k9Ef1 9yDqrFV3sPqC2xj/0ufZG/18+Yt99Ykg1jQE3RGDwD/59KAeqPbOvqTKyVODV9jE qje6ScSIc2G0713uss2bcaD3k+rCB5YL2JkKrk5OWW/T2+n9T+JFaiNh7dnSFFcU gBKyeY24OyCDMwXrby0K =SI+Y -----END PGP SIGNATURE----- Merge tag 'drm-next-2019-07-16' of git://anongit.freedesktop.org/drm/drm Pull drm updates from Dave Airlie: "The biggest thing in this is the AMD Navi GPU support, this again contains a bunch of header files that are large. These are the new AMD RX5700 GPUs that just recently became available. New drivers: - ST-Ericsson MCDE driver - Ingenic JZ47xx SoC UAPI change: - HDR source metadata property Core: - HDR inforframes and EDID parsing - drm hdmi infoframe unpacking - remove prime sg_table caching into dma-buf - New gem vram helpers to reduce driver code - Lots of drmP.h removal - reservation fencing fix - documentation updates - drm_fb_helper_connector removed - mode name command handler rewrite fbcon: - Remove the fbcon notifiers ttm: - forward progress fixes dma-buf: - make mmap call optional - debugfs refcount fixes - dma-fence free with pending signals fix - each dma-buf gets an inode Panels: - Lots of additional panel bindings amdgpu: - initial navi10 support - avoid hw reset - HDR metadata support - new thermal sensors for vega asics - RAS fixes - use HMM rather than MMU notifier - xgmi topology via kfd - SR-IOV fixes - driver reload fixes - DC use a core bpc attribute - Aux fixes for DC - Bandwidth calc updates for DC - Clock handling refactor - kfd VEGAM support vmwgfx: - Coherent memory support changes i915: - HDR Support - HDMI i2c link - Icelake multi-segmented gamma support - GuC firmware update - Mule Creek Canyon PCH support for EHL - EHL platform updtes - move i915.alpha_support to i915.force_probe - runtime PM refactoring - VBT parsing refactoring - DSI fixes - struct mutex dependency reduction - GEM code reorg mali-dp: - Komeda driver features msm: - dsi vs EPROBE_DEFER fixes - msm8998 snapdragon 835 support - a540 gpu support - mdp5 and dpu interconnect support exynos: - drmP.h removal tegra: - misc fixes tda998x: - audio support improvements - pixel repeated mode support - quantisation range handling corrections - HDMI vendor info fix armada: - interlace support fix - overlay/video plane register handling refactor - add gamma support rockchip: - RX3328 support panfrost: - expose perf counters via hidden ioctls vkms: - enumerate CRC sources list ast: - rework BO handling mgag200: - rework BO handling dw-hdmi: - suspend/resume support rcar-du: - R8A774A1 Soc Support - LVDS dual-link mode support - Additional formats - Misc fixes omapdrm: - DSI command mode display support stm - fb modifier support - runtime PM support sun4i: - use vmap ops vc4: - binner bo binding rework v3d: - compute shader support - resync/sync fixes - job management refactoring lima: - NULL pointer in irq handler fix - scheduler default timeout virtio: - fence seqno support - trace events bochs: - misc fixes tc458767: - IRQ/HDP handling sii902x: - HDMI audio support atmel-hlcdc: - misc fixes meson: - zpos support" * tag 'drm-next-2019-07-16' of git://anongit.freedesktop.org/drm/drm: (1815 commits) Revert "Merge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux into drm-next" Revert "mm: adjust apply_to_pfn_range interface for dropped token." mm: adjust apply_to_pfn_range interface for dropped token. drm/amdgpu/navi10: add uclk activity sensor drm/amdgpu: properly guard the generic discovery code drm/amdgpu: add missing documentation on new module parameters drm/amdgpu: don't invalidate caches in RELEASE_MEM, only do the writeback drm/amd/display: avoid 64-bit division drm/amdgpu/psp11: simplify the ucode register logic drm/amdgpu: properly guard DC support in navi code drm/amd/powerplay: vega20: fix uninitialized variable use drm/amd/display: dcn20: include linux/delay.h amdgpu: make pmu support optional drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq drm/amd/powerplay: Use memset to initialize metrics structs drm/amdgpu/mes10.1: Fix header guard drm/amd/powerplay: add temperature sensor support for navi10 drm/amdgpu: fix scheduler timeout calc drm/amdgpu: Prepare for hmm_range_register API change (v2) ...
311 lines
7.4 KiB
C
311 lines
7.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2012 Russell King
|
|
*/
|
|
#include <linux/clk.h>
|
|
#include <linux/component.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_graph.h>
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_probe_helper.h>
|
|
#include <drm/drm_fb_helper.h>
|
|
#include <drm/drm_of.h>
|
|
#include "armada_crtc.h"
|
|
#include "armada_drm.h"
|
|
#include "armada_gem.h"
|
|
#include "armada_fb.h"
|
|
#include "armada_hw.h"
|
|
#include <drm/armada_drm.h>
|
|
#include "armada_ioctlP.h"
|
|
|
|
static struct drm_ioctl_desc armada_ioctls[] = {
|
|
DRM_IOCTL_DEF_DRV(ARMADA_GEM_CREATE, armada_gem_create_ioctl,0),
|
|
DRM_IOCTL_DEF_DRV(ARMADA_GEM_MMAP, armada_gem_mmap_ioctl, 0),
|
|
DRM_IOCTL_DEF_DRV(ARMADA_GEM_PWRITE, armada_gem_pwrite_ioctl, 0),
|
|
};
|
|
|
|
DEFINE_DRM_GEM_FOPS(armada_drm_fops);
|
|
|
|
static struct drm_driver armada_drm_driver = {
|
|
.lastclose = drm_fb_helper_lastclose,
|
|
.gem_free_object_unlocked = armada_gem_free_object,
|
|
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
|
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
|
.gem_prime_export = armada_gem_prime_export,
|
|
.gem_prime_import = armada_gem_prime_import,
|
|
.dumb_create = armada_gem_dumb_create,
|
|
.gem_vm_ops = &armada_gem_vm_ops,
|
|
.major = 1,
|
|
.minor = 0,
|
|
.name = "armada-drm",
|
|
.desc = "Armada SoC DRM",
|
|
.date = "20120730",
|
|
.driver_features = DRIVER_GEM | DRIVER_MODESET |
|
|
DRIVER_PRIME | DRIVER_ATOMIC,
|
|
.ioctls = armada_ioctls,
|
|
.fops = &armada_drm_fops,
|
|
};
|
|
|
|
static const struct drm_mode_config_funcs armada_drm_mode_config_funcs = {
|
|
.fb_create = armada_fb_create,
|
|
.output_poll_changed = drm_fb_helper_output_poll_changed,
|
|
.atomic_check = drm_atomic_helper_check,
|
|
.atomic_commit = drm_atomic_helper_commit,
|
|
};
|
|
|
|
static int armada_drm_bind(struct device *dev)
|
|
{
|
|
struct armada_private *priv;
|
|
struct resource *mem = NULL;
|
|
int ret, n;
|
|
|
|
for (n = 0; ; n++) {
|
|
struct resource *r = platform_get_resource(to_platform_device(dev),
|
|
IORESOURCE_MEM, n);
|
|
if (!r)
|
|
break;
|
|
|
|
/* Resources above 64K are graphics memory */
|
|
if (resource_size(r) > SZ_64K)
|
|
mem = r;
|
|
else
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (!mem)
|
|
return -ENXIO;
|
|
|
|
if (!devm_request_mem_region(dev, mem->start, resource_size(mem),
|
|
"armada-drm"))
|
|
return -EBUSY;
|
|
|
|
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
|
if (!priv)
|
|
return -ENOMEM;
|
|
|
|
/*
|
|
* The drm_device structure must be at the start of
|
|
* armada_private for drm_dev_put() to work correctly.
|
|
*/
|
|
BUILD_BUG_ON(offsetof(struct armada_private, drm) != 0);
|
|
|
|
ret = drm_dev_init(&priv->drm, &armada_drm_driver, dev);
|
|
if (ret) {
|
|
dev_err(dev, "[" DRM_NAME ":%s] drm_dev_init failed: %d\n",
|
|
__func__, ret);
|
|
kfree(priv);
|
|
return ret;
|
|
}
|
|
|
|
/* Remove early framebuffers */
|
|
ret = drm_fb_helper_remove_conflicting_framebuffers(NULL,
|
|
"armada-drm-fb",
|
|
false);
|
|
if (ret) {
|
|
dev_err(dev, "[" DRM_NAME ":%s] can't kick out simple-fb: %d\n",
|
|
__func__, ret);
|
|
kfree(priv);
|
|
return ret;
|
|
}
|
|
|
|
priv->drm.dev_private = priv;
|
|
|
|
dev_set_drvdata(dev, &priv->drm);
|
|
|
|
/* Mode setting support */
|
|
drm_mode_config_init(&priv->drm);
|
|
priv->drm.mode_config.min_width = 320;
|
|
priv->drm.mode_config.min_height = 200;
|
|
|
|
/*
|
|
* With vscale enabled, the maximum width is 1920 due to the
|
|
* 1920 by 3 lines RAM
|
|
*/
|
|
priv->drm.mode_config.max_width = 1920;
|
|
priv->drm.mode_config.max_height = 2048;
|
|
|
|
priv->drm.mode_config.preferred_depth = 24;
|
|
priv->drm.mode_config.funcs = &armada_drm_mode_config_funcs;
|
|
drm_mm_init(&priv->linear, mem->start, resource_size(mem));
|
|
mutex_init(&priv->linear_lock);
|
|
|
|
ret = component_bind_all(dev, &priv->drm);
|
|
if (ret)
|
|
goto err_kms;
|
|
|
|
ret = drm_vblank_init(&priv->drm, priv->drm.mode_config.num_crtc);
|
|
if (ret)
|
|
goto err_comp;
|
|
|
|
priv->drm.irq_enabled = true;
|
|
|
|
drm_mode_config_reset(&priv->drm);
|
|
|
|
ret = armada_fbdev_init(&priv->drm);
|
|
if (ret)
|
|
goto err_comp;
|
|
|
|
drm_kms_helper_poll_init(&priv->drm);
|
|
|
|
ret = drm_dev_register(&priv->drm, 0);
|
|
if (ret)
|
|
goto err_poll;
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
armada_drm_debugfs_init(priv->drm.primary);
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
err_poll:
|
|
drm_kms_helper_poll_fini(&priv->drm);
|
|
armada_fbdev_fini(&priv->drm);
|
|
err_comp:
|
|
component_unbind_all(dev, &priv->drm);
|
|
err_kms:
|
|
drm_mode_config_cleanup(&priv->drm);
|
|
drm_mm_takedown(&priv->linear);
|
|
drm_dev_put(&priv->drm);
|
|
return ret;
|
|
}
|
|
|
|
static void armada_drm_unbind(struct device *dev)
|
|
{
|
|
struct drm_device *drm = dev_get_drvdata(dev);
|
|
struct armada_private *priv = drm->dev_private;
|
|
|
|
drm_kms_helper_poll_fini(&priv->drm);
|
|
armada_fbdev_fini(&priv->drm);
|
|
|
|
drm_dev_unregister(&priv->drm);
|
|
|
|
drm_atomic_helper_shutdown(&priv->drm);
|
|
|
|
component_unbind_all(dev, &priv->drm);
|
|
|
|
drm_mode_config_cleanup(&priv->drm);
|
|
drm_mm_takedown(&priv->linear);
|
|
|
|
drm_dev_put(&priv->drm);
|
|
}
|
|
|
|
static int compare_of(struct device *dev, void *data)
|
|
{
|
|
return dev->of_node == data;
|
|
}
|
|
|
|
static int compare_dev_name(struct device *dev, void *data)
|
|
{
|
|
const char *name = data;
|
|
return !strcmp(dev_name(dev), name);
|
|
}
|
|
|
|
static void armada_add_endpoints(struct device *dev,
|
|
struct component_match **match, struct device_node *dev_node)
|
|
{
|
|
struct device_node *ep, *remote;
|
|
|
|
for_each_endpoint_of_node(dev_node, ep) {
|
|
remote = of_graph_get_remote_port_parent(ep);
|
|
if (remote && of_device_is_available(remote))
|
|
drm_of_component_match_add(dev, match, compare_of,
|
|
remote);
|
|
of_node_put(remote);
|
|
}
|
|
}
|
|
|
|
static const struct component_master_ops armada_master_ops = {
|
|
.bind = armada_drm_bind,
|
|
.unbind = armada_drm_unbind,
|
|
};
|
|
|
|
static int armada_drm_probe(struct platform_device *pdev)
|
|
{
|
|
struct component_match *match = NULL;
|
|
struct device *dev = &pdev->dev;
|
|
int ret;
|
|
|
|
ret = drm_of_component_probe(dev, compare_dev_name, &armada_master_ops);
|
|
if (ret != -EINVAL)
|
|
return ret;
|
|
|
|
if (dev->platform_data) {
|
|
char **devices = dev->platform_data;
|
|
struct device *d;
|
|
int i;
|
|
|
|
for (i = 0; devices[i]; i++)
|
|
component_match_add(dev, &match, compare_dev_name,
|
|
devices[i]);
|
|
|
|
if (i == 0) {
|
|
dev_err(dev, "missing 'ports' property\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
for (i = 0; devices[i]; i++) {
|
|
d = bus_find_device_by_name(&platform_bus_type, NULL,
|
|
devices[i]);
|
|
if (d && d->of_node)
|
|
armada_add_endpoints(dev, &match, d->of_node);
|
|
put_device(d);
|
|
}
|
|
}
|
|
|
|
return component_master_add_with_match(&pdev->dev, &armada_master_ops,
|
|
match);
|
|
}
|
|
|
|
static int armada_drm_remove(struct platform_device *pdev)
|
|
{
|
|
component_master_del(&pdev->dev, &armada_master_ops);
|
|
return 0;
|
|
}
|
|
|
|
static const struct platform_device_id armada_drm_platform_ids[] = {
|
|
{
|
|
.name = "armada-drm",
|
|
}, {
|
|
.name = "armada-510-drm",
|
|
},
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(platform, armada_drm_platform_ids);
|
|
|
|
static struct platform_driver armada_drm_platform_driver = {
|
|
.probe = armada_drm_probe,
|
|
.remove = armada_drm_remove,
|
|
.driver = {
|
|
.name = "armada-drm",
|
|
},
|
|
.id_table = armada_drm_platform_ids,
|
|
};
|
|
|
|
static int __init armada_drm_init(void)
|
|
{
|
|
int ret;
|
|
|
|
armada_drm_driver.num_ioctls = ARRAY_SIZE(armada_ioctls);
|
|
|
|
ret = platform_driver_register(&armada_lcd_platform_driver);
|
|
if (ret)
|
|
return ret;
|
|
ret = platform_driver_register(&armada_drm_platform_driver);
|
|
if (ret)
|
|
platform_driver_unregister(&armada_lcd_platform_driver);
|
|
return ret;
|
|
}
|
|
module_init(armada_drm_init);
|
|
|
|
static void __exit armada_drm_exit(void)
|
|
{
|
|
platform_driver_unregister(&armada_drm_platform_driver);
|
|
platform_driver_unregister(&armada_lcd_platform_driver);
|
|
}
|
|
module_exit(armada_drm_exit);
|
|
|
|
MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>");
|
|
MODULE_DESCRIPTION("Armada DRM Driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("platform:armada-drm");
|