Lines Matching +full:rockchip +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Rockchip Electronics Co., Ltd.
4 * Author:Mark Yao <mark.yao@rock-chips.com>
10 #include <linux/dma-mapping.h>
29 #include <asm/dma-iommu.h>
40 #define DRIVER_NAME "rockchip"
41 #define DRIVER_DESC "RockChip Soc DRM"
48 * Attach a (component) device to the shared drm dma mapping from master drm
49 * device. This is used by the VOPs to map GEM buffers to a common DMA
53 struct device *dev)
55 struct rockchip_drm_private *private = drm_dev->dev_private;
58 if (!private->domain)
70 ret = iommu_attach_device(private->domain, dev);
72 DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");
80 struct device *dev)
82 struct rockchip_drm_private *private = drm_dev->dev_private;
84 if (!private->domain)
87 iommu_detach_device(private->domain, dev);
91 struct device *dev)
93 struct rockchip_drm_private *private = drm_dev->dev_private;
96 private->iommu_dev = ERR_PTR(-ENODEV);
97 else if (!private->iommu_dev)
98 private->iommu_dev = dev;
103 struct rockchip_drm_private *private = drm_dev->dev_private;
108 if (IS_ERR_OR_NULL(private->iommu_dev))
111 private->domain = iommu_paging_domain_alloc(private->iommu_dev);
112 if (IS_ERR(private->domain)) {
113 ret = PTR_ERR(private->domain);
114 private->domain = NULL;
118 geometry = &private->domain->geometry;
119 start = geometry->aperture_start;
120 end = geometry->aperture_end;
122 DRM_DEBUG("IOMMU context initialized (aperture: %#llx-%#llx)\n",
124 drm_mm_init(&private->mm, start, end - start + 1);
125 mutex_init(&private->mm_lock);
132 struct rockchip_drm_private *private = drm_dev->dev_private;
134 if (!private->domain)
137 drm_mm_takedown(&private->mm);
138 iommu_domain_free(private->domain);
141 static int rockchip_drm_bind(struct device *dev)
151 "Failed to remove existing framebuffers - %d.\n",
162 private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL);
164 ret = -ENOMEM;
168 drm_dev->dev_private = private;
185 ret = drm_vblank_init(drm_dev, drm_dev->mode_config.num_crtc);
212 static void rockchip_drm_unbind(struct device *dev)
242 static int rockchip_drm_sys_suspend(struct device *dev)
249 static int rockchip_drm_sys_resume(struct device *dev)
271 * @np: The encoder device node
284 return -ENOENT;
288 return -ENOENT;
294 rkencoder->crtc_endpoint_id = ep.id;
300 * Check if a vop endpoint is leading to a rockchip subdriver or bridge.
304 * @ep: endpoint of a rockchip vop
306 * returns true if subdriver, false if external bridge and -ENODEV
307 * if remote port does not contain a device.
317 return -ENODEV;
319 /* status disabled will prevent creation of platform-devices */
322 return -ENODEV;
328 /* enabled non-platform-devices can immediately return here */
333 * All rockchip subdrivers have probed at this point, so
334 * any device not having a driver now is an external bridge.
336 drv = pdev->dev.driver;
353 static void rockchip_drm_match_remove(struct device *dev)
357 list_for_each_entry(link, &dev->links.consumers, s_node)
363 "rockchip,rk3399-vop-big",
367 static struct component_match *rockchip_drm_match_add(struct device *dev)
373 /* add preferred vop device match before adding driver device matches */
375 port = of_parse_phandle(dev->of_node, "ports", i);
379 if (of_device_is_available(port->parent) &&
380 of_device_compatible_match(port->parent,
384 port->parent);
391 struct device *p = NULL, *d;
394 d = platform_find_device_by_driver(p, &drv->driver);
409 return match ?: ERR_PTR(-ENODEV);
417 static int rockchip_drm_platform_of_probe(struct device *dev)
419 struct device_node *np = dev->of_node;
425 return -ENODEV;
432 if (!of_device_is_available(port->parent)) {
443 return -ENODEV;
448 "No available vop found for display-subsystem.\n");
449 return -ENODEV;
457 struct device *dev = &pdev->dev;
480 component_master_del(&pdev->dev, &rockchip_drm_ops);
482 rockchip_drm_match_remove(&pdev->dev);
487 if (component_master_is_bound(&pdev->dev, &rockchip_drm_ops)) {
495 { .compatible = "rockchip,display-subsystem", },
505 .name = "rockchip-drm",
522 return -ENODEV;
572 MODULE_AUTHOR("Mark Yao <mark.yao@rock-chips.com>");
573 MODULE_DESCRIPTION("ROCKCHIP DRM Driver");