summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c2
-rw-r--r--sys/dev/pci/drm/drm_drv.c6
-rw-r--r--sys/dev/pci/drm/drm_fb_dma_helper.c17
-rw-r--r--sys/dev/pci/drm/drm_gem_dma_helper.c22
-rw-r--r--sys/dev/pci/drm/drm_gem_framebuffer_helper.c44
-rw-r--r--sys/dev/pci/drm/drm_linux.c633
-rw-r--r--sys/dev/pci/drm/include/drm/drm_fb_dma_helper.h13
-rw-r--r--sys/dev/pci/drm/include/drm/drm_fbdev_generic.h15
-rw-r--r--sys/dev/pci/drm/include/drm/drm_gem_dma_helper.h15
-rw-r--r--sys/dev/pci/drm/include/drm/drm_gem_framebuffer_helper.h2
-rw-r--r--sys/dev/pci/drm/include/drm/drm_legacy.h1
-rw-r--r--sys/dev/pci/drm/include/drm/drm_of.h10
-rw-r--r--sys/dev/pci/drm/include/drm/drm_simple_kms_helper.h17
-rw-r--r--sys/dev/pci/drm/include/linux/align.h11
-rw-r--r--sys/dev/pci/drm/include/linux/atomic.h5
-rw-r--r--sys/dev/pci/drm/include/linux/bitmap.h23
-rw-r--r--sys/dev/pci/drm/include/linux/clk.h14
-rw-r--r--sys/dev/pci/drm/include/linux/completion.h5
-rw-r--r--sys/dev/pci/drm/include/linux/component.h34
-rw-r--r--sys/dev/pci/drm/include/linux/device.h5
-rw-r--r--sys/dev/pci/drm/include/linux/dma-mapping.h21
-rw-r--r--sys/dev/pci/drm/include/linux/gpio/consumer.h21
-rw-r--r--sys/dev/pci/drm/include/linux/interrupt.h24
-rw-r--r--sys/dev/pci/drm/include/linux/io.h5
-rw-r--r--sys/dev/pci/drm/include/linux/iommu.h29
-rw-r--r--sys/dev/pci/drm/include/linux/mux/consumer.h20
-rw-r--r--sys/dev/pci/drm/include/linux/of.h72
-rw-r--r--sys/dev/pci/drm/include/linux/of_address.h11
-rw-r--r--sys/dev/pci/drm/include/linux/of_device.h8
-rw-r--r--sys/dev/pci/drm/include/linux/of_platform.h12
-rw-r--r--sys/dev/pci/drm/include/linux/phy/phy.h39
-rw-r--r--sys/dev/pci/drm/include/linux/platform_device.h53
-rw-r--r--sys/dev/pci/drm/include/linux/pm.h10
-rw-r--r--sys/dev/pci/drm/include/linux/scatterlist.h3
-rw-r--r--sys/dev/pci/drm/include/linux/time.h4
-rw-r--r--sys/dev/pci/drm/include/linux/workqueue.h11
-rw-r--r--sys/dev/pci/drm/include/sound/pcm.h43
37 files changed, 1259 insertions, 21 deletions
diff --git a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 84dadf3eb1f..770d0af4691 100644
--- a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -985,12 +985,10 @@ static void amdgpu_dm_audio_component_unbind(struct device *kdev,
adev->dm.audio_component = NULL;
}
-#ifdef notyet
static const struct component_ops amdgpu_dm_audio_component_bind_ops = {
.bind = amdgpu_dm_audio_component_bind,
.unbind = amdgpu_dm_audio_component_unbind,
};
-#endif
static int amdgpu_dm_audio_init(struct amdgpu_device *adev)
{
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index de7239c21e2..659279c0782 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -775,6 +775,8 @@ static int devm_drm_dev_init(struct device *parent,
devm_drm_dev_init_release, dev);
}
+#endif
+
void *__devm_drm_dev_alloc(struct device *parent,
const struct drm_driver *driver,
size_t size, size_t offset)
@@ -788,17 +790,21 @@ void *__devm_drm_dev_alloc(struct device *parent,
return ERR_PTR(-ENOMEM);
drm = container + offset;
+#ifdef notyet
ret = devm_drm_dev_init(parent, drm, driver);
if (ret) {
kfree(container);
return ERR_PTR(ret);
}
drmm_add_final_kfree(drm, container);
+#endif
return container;
}
EXPORT_SYMBOL(__devm_drm_dev_alloc);
+#ifdef notyet
+
/**
* drm_dev_alloc - Allocate new DRM device
* @driver: DRM driver to allocate device for
diff --git a/sys/dev/pci/drm/drm_fb_dma_helper.c b/sys/dev/pci/drm/drm_fb_dma_helper.c
new file mode 100644
index 00000000000..1daa8e9c19c
--- /dev/null
+++ b/sys/dev/pci/drm/drm_fb_dma_helper.c
@@ -0,0 +1,17 @@
+/* Public Domain */
+
+#include <drm/drm_framebuffer.h>
+#include <drm/drm_fb_dma_helper.h>
+#include <drm/drm_gem_dma_helper.h>
+
+struct drm_gem_dma_object *
+drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb, unsigned int plane)
+{
+ struct drm_gem_object *obj;
+
+ KASSERT(plane == 0);
+ obj = fb->obj[plane];
+ if (obj)
+ return to_drm_gem_dma_obj(obj);
+ return NULL;
+}
diff --git a/sys/dev/pci/drm/drm_gem_dma_helper.c b/sys/dev/pci/drm/drm_gem_dma_helper.c
index 8c3080f02bd..06eff46a7e6 100644
--- a/sys/dev/pci/drm/drm_gem_dma_helper.c
+++ b/sys/dev/pci/drm/drm_gem_dma_helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_gem_dma_helper.c,v 1.1 2023/01/01 01:34:34 jsg Exp $ */
+/* $OpenBSD: drm_gem_dma_helper.c,v 1.2 2024/01/06 09:33:08 kettenis Exp $ */
/* $NetBSD: drm_gem_dma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca>
@@ -54,6 +54,7 @@ drm_gem_dma_create_internal(struct drm_device *ddev, size_t size,
obj->base.funcs = &drm_gem_dma_default_funcs;
if (sgt) {
+ STUB();
#ifdef notyet
error = -drm_prime_sg_to_bus_dmamem(obj->dmat, obj->dmasegs, 1,
&nsegs, sgt);
@@ -89,6 +90,7 @@ drm_gem_dma_create_internal(struct drm_device *ddev, size_t size,
if (error)
goto unload;
+ obj->dma_addr = obj->dmamap->dm_segs[0].ds_addr;
return obj;
unload:
@@ -144,16 +146,13 @@ drm_gem_dma_free_object(struct drm_gem_object *gem_obj)
}
int
-drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_device *ddev,
- struct drm_mode_create_dumb *args)
+drm_gem_dma_dumb_create_internal(struct drm_file *file_priv,
+ struct drm_device *ddev, struct drm_mode_create_dumb *args)
{
struct drm_gem_dma_object *obj;
uint32_t handle;
int error;
- args->pitch = args->width * ((args->bpp + 7) / 8);
- args->size = args->pitch * args->height;
- args->size = roundup(args->size, PAGE_SIZE);
args->handle = 0;
obj = drm_gem_dma_create(ddev, args->size);
@@ -173,6 +172,17 @@ drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_device *ddev,
}
int
+drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_device *ddev,
+ struct drm_mode_create_dumb *args)
+{
+ args->pitch = args->width * ((args->bpp + 7) / 8);
+ args->size = args->pitch * args->height;
+ args->size = roundup(args->size, PAGE_SIZE);
+
+ return drm_gem_dma_dumb_create_internal(file_priv, ddev, args);
+}
+
+int
drm_gem_dma_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
off_t offset, vaddr_t vaddr, vm_page_t *pps, int npages, int centeridx,
vm_prot_t access_type, int flags)
diff --git a/sys/dev/pci/drm/drm_gem_framebuffer_helper.c b/sys/dev/pci/drm/drm_gem_framebuffer_helper.c
index 0986c98c548..d45ef8ceb65 100644
--- a/sys/dev/pci/drm/drm_gem_framebuffer_helper.c
+++ b/sys/dev/pci/drm/drm_gem_framebuffer_helper.c
@@ -2,6 +2,7 @@
#include <drm/drm_gem.h>
#include <drm/drm_framebuffer.h>
+#include <drm/drm_modeset_helper.h>
void
drm_gem_fb_destroy(struct drm_framebuffer *fb)
@@ -20,3 +21,46 @@ drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
{
return drm_gem_handle_create(file, fb->obj[0], handle);
}
+
+const struct drm_framebuffer_funcs drm_gem_fb_funcs = {
+ .create_handle = drm_gem_fb_create_handle,
+ .destroy = drm_gem_fb_destroy,
+};
+
+struct drm_framebuffer *
+drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
+ const struct drm_mode_fb_cmd2 *cmd)
+{
+ struct drm_framebuffer *fb;
+ const struct drm_format_info *info;
+ struct drm_gem_object *gem_obj;
+ int error;
+
+ info = drm_get_format_info(dev, cmd);
+ if (!info)
+ return ERR_PTR(-EINVAL);
+
+ KASSERT(info->num_planes == 1);
+
+ gem_obj = drm_gem_object_lookup(file, cmd->handles[0]);
+ if (gem_obj == NULL)
+ return ERR_PTR(-ENOENT);
+
+ fb = malloc(sizeof(*fb), M_DRM, M_ZERO | M_WAITOK);
+
+ drm_helper_mode_fill_fb_struct(dev, fb, cmd);
+ fb->obj[0] = gem_obj;
+
+ error = drm_framebuffer_init(dev, fb, &drm_gem_fb_funcs);
+ if (error != 0)
+ goto dealloc;
+
+ return fb;
+
+dealloc:
+ drm_framebuffer_cleanup(fb);
+ free(fb, M_DRM, sizeof(*fb));
+ drm_gem_object_put(gem_obj);
+
+ return ERR_PTR(error);
+}
diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c
index d2a071d43d9..d2abfc555a2 100644
--- a/sys/dev/pci/drm/drm_linux.c
+++ b/sys/dev/pci/drm/drm_linux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.c,v 1.105 2023/12/23 14:18:27 kettenis Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.106 2024/01/06 09:33:08 kettenis Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -3182,3 +3182,634 @@ drm_firmware_drivers_only(void)
{
return false;
}
+
+
+void *
+memremap(phys_addr_t phys_addr, size_t size, int flags)
+{
+ STUB();
+ return NULL;
+}
+
+void
+memunmap(void *addr)
+{
+ STUB();
+}
+
+#include <linux/platform_device.h>
+
+bus_dma_tag_t
+dma_tag_lookup(struct device *dev)
+{
+ extern struct cfdriver drm_cd;
+ struct drm_device *drm;
+ int i;
+
+ for (i = 0; i < drm_cd.cd_ndevs; i++) {
+ drm = drm_cd.cd_devs[i];
+ if (drm && drm->dev == dev)
+ return drm->dmat;
+ }
+
+ return ((struct platform_device *)dev)->dmat;
+}
+
+LIST_HEAD(, drm_dmamem) dmamem_list = LIST_HEAD_INITIALIZER(dmamem_list);
+
+void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+ int gfp)
+{
+ bus_dma_tag_t dmat = dma_tag_lookup(dev);
+ struct drm_dmamem *mem;
+
+ mem = drm_dmamem_alloc(dmat, size, PAGE_SIZE, 1, size,
+ BUS_DMA_COHERENT, 0);
+ if (mem == NULL)
+ return NULL;
+ *dma_handle = mem->map->dm_segs[0].ds_addr;
+ LIST_INSERT_HEAD(&dmamem_list, mem, next);
+ return mem->kva;
+}
+
+void
+dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+ dma_addr_t dma_handle)
+{
+ bus_dma_tag_t dmat = dma_tag_lookup(dev);
+ struct drm_dmamem *mem;
+
+ LIST_FOREACH(mem, &dmamem_list, next) {
+ if (mem->kva == cpu_addr)
+ break;
+ }
+ KASSERT(mem);
+ KASSERT(mem->size == size);
+ KASSERT(mem->map->dm_segs[0].ds_addr == dma_handle);
+
+ LIST_REMOVE(mem, next);
+ drm_dmamem_free(dmat, mem);
+}
+
+int
+dma_get_sgtable(struct device *dev, struct sg_table *sgt, void *cpu_addr,
+ dma_addr_t dma_addr, size_t size)
+{
+ paddr_t pa;
+ int ret;
+
+ if (!pmap_extract(pmap_kernel(), (vaddr_t)cpu_addr, &pa))
+ return -EINVAL;
+
+ ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
+ if (ret)
+ return ret;
+
+ sg_set_page(sgt->sgl, PHYS_TO_VM_PAGE(pa), size, 0);
+ return 0;
+}
+
+dma_addr_t
+dma_map_resource(struct device *dev, phys_addr_t phys_addr, size_t size,
+ enum dma_data_direction dir, u_long attr)
+{
+ bus_dma_tag_t dmat= dma_tag_lookup(dev);
+ bus_dmamap_t map;
+ bus_dma_segment_t seg;
+
+ if (bus_dmamap_create(dmat, size, 1, size, 0,
+ BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW, &map))
+ return DMA_MAPPING_ERROR;
+ seg.ds_addr = phys_addr;
+ seg.ds_len = size;
+ if (bus_dmamap_load_raw(dmat, map, &seg, 1, size, BUS_DMA_WAITOK)) {
+ bus_dmamap_destroy(dmat, map);
+ return DMA_MAPPING_ERROR;
+ }
+
+ return map->dm_segs[0].ds_addr;
+}
+
+#ifdef BUS_DMA_FIXED
+
+#include <linux/iommu.h>
+
+size_t
+iommu_map_sgtable(struct iommu_domain *domain, u_long iova,
+ struct sg_table *sgt, int prot)
+{
+ bus_dma_segment_t seg;
+ int error;
+
+ error = bus_dmamap_create(domain->dmat, sgt->sgl->length, 1,
+ sgt->sgl->length, 0, BUS_DMA_WAITOK, &sgt->dmamap);
+ if (error)
+ return -ENOMEM;
+
+ sgt->dmamap->dm_segs[0].ds_addr = iova;
+ sgt->dmamap->dm_segs[0].ds_len = sgt->sgl->length;
+ sgt->dmamap->dm_nsegs = 1;
+ seg.ds_addr = VM_PAGE_TO_PHYS(sgt->sgl->__page);
+ seg.ds_len = sgt->sgl->length;
+ error = bus_dmamap_load_raw(domain->dmat, sgt->dmamap, &seg, 1,
+ sgt->sgl->length, BUS_DMA_WAITOK | BUS_DMA_FIXED);
+ if (error)
+ return -ENOMEM;
+
+ return sg_dma_len(sgt->sgl);
+}
+
+size_t
+iommu_unmap(struct iommu_domain *domain, u_long iova, size_t size)
+{
+ STUB();
+ return 0;
+}
+
+struct iommu_domain *
+iommu_get_domain_for_dev(struct device *dev)
+{
+ STUB();
+ return NULL;
+}
+
+phys_addr_t
+iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
+{
+ STUB();
+ return 0;
+}
+
+struct iommu_domain *
+iommu_domain_alloc(struct bus_type *type)
+{
+ return malloc(sizeof(struct iommu_domain), M_DEVBUF, M_WAITOK | M_ZERO);
+}
+
+int
+iommu_attach_device(struct iommu_domain *domain, struct device *dev)
+{
+ struct platform_device *pdev = (struct platform_device *)dev;
+
+ domain->dmat = pdev->dmat;
+ return 0;
+}
+
+#endif
+
+#include <linux/component.h>
+
+struct component_match {
+ struct device *dev;
+};
+
+int
+component_compare_of(struct device *dev, void *data)
+{
+ STUB();
+ return 0;
+}
+
+void
+drm_of_component_match_add(struct device *master,
+ struct component_match **matchptr,
+ int (*compare)(struct device *, void *),
+ struct device_node *np)
+{
+ struct component_match *match;
+
+ if (*matchptr == NULL) {
+ match = malloc(sizeof(struct component_match),
+ M_DEVBUF, M_WAITOK | M_ZERO);
+ match->dev = master;
+ *matchptr = match;
+ }
+}
+
+int
+component_master_add_with_match(struct device *dev,
+ const struct component_master_ops *ops, struct component_match *match)
+{
+ ops->bind(match->dev);
+ return 0;
+}
+
+#ifdef __HAVE_FDT
+
+#include <linux/platform_device.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+#include <machine/fdt.h>
+
+LIST_HEAD(, platform_device) pdev_list = LIST_HEAD_INITIALIZER(pdev_list);
+
+void
+platform_device_register(struct platform_device *pdev)
+{
+ pdev->num_resources = pdev->faa->fa_nreg;
+
+ pdev->parent = pdev->dev.dv_parent;
+ pdev->node = pdev->faa->fa_node;
+ pdev->dmat = pdev->faa->fa_dmat;
+ LIST_INSERT_HEAD(&pdev_list, pdev, next);
+}
+
+
+struct resource *
+platform_get_resource(struct platform_device *pdev, u_int type, u_int num)
+{
+ struct fdt_attach_args *faa = pdev->faa;
+
+ if (pdev->resource == NULL) {
+ pdev->resource = mallocarray(pdev->num_resources,
+ sizeof(*pdev->resource), M_DEVBUF, M_WAITOK | M_ZERO);
+ }
+
+ pdev->resource[num].start = faa->fa_reg[num].addr;
+ pdev->resource[num].end = faa->fa_reg[num].addr +
+ faa->fa_reg[num].size - 1;
+
+ return &pdev->resource[num];
+}
+
+void __iomem *
+devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+ const char *name)
+{
+ struct fdt_attach_args *faa = pdev->faa;
+ bus_space_handle_t ioh;
+ int err, idx;
+
+ idx = OF_getindex(faa->fa_node, name, "reg-names");
+ if (idx == -1 || idx >= faa->fa_nreg)
+ return ERR_PTR(-EINVAL);
+
+ err = bus_space_map(faa->fa_iot, faa->fa_reg[idx].addr,
+ faa->fa_reg[idx].size, BUS_SPACE_MAP_LINEAR, &ioh);
+ if (err)
+ return ERR_PTR(-err);
+
+ return bus_space_vaddr(faa->fa_iot, ioh);
+}
+
+#include <dev/ofw/ofw_clock.h>
+#include <linux/clk.h>
+
+struct clk *
+devm_clk_get(struct device *dev, const char *name)
+{
+ struct platform_device *pdev = (struct platform_device *)dev;
+ struct clk *clk;
+
+ clk = malloc(sizeof(*clk), M_DEVBUF, M_WAITOK);
+ clk->freq = clock_get_frequency(pdev->node, name);
+ return clk;
+}
+
+u_long
+clk_get_rate(struct clk *clk)
+{
+ return clk->freq;
+}
+
+#include <linux/gpio/consumer.h>
+#include <dev/ofw/ofw_gpio.h>
+
+struct gpio_desc {
+ uint32_t gpios[4];
+};
+
+struct gpio_desc *
+devm_gpiod_get_optional(struct device *dev, const char *name, int flags)
+{
+ struct platform_device *pdev = (struct platform_device *)dev;
+ struct gpio_desc *desc;
+ char fullname[128];
+ int len;
+
+ snprintf(fullname, sizeof(fullname), "%s-gpios", name);
+
+ desc = malloc(sizeof(*desc), M_DEVBUF, M_WAITOK | M_ZERO);
+ len = OF_getpropintarray(pdev->node, fullname, desc->gpios,
+ sizeof(desc->gpios));
+ KASSERT(len <= sizeof(desc->gpios));
+ if (len < 0) {
+ free(desc, M_DEVBUF, sizeof(*desc));
+ return NULL;
+ }
+
+ switch (flags) {
+ case GPIOD_IN:
+ gpio_controller_config_pin(desc->gpios, GPIO_CONFIG_INPUT);
+ break;
+ case GPIOD_OUT_HIGH:
+ gpio_controller_config_pin(desc->gpios, GPIO_CONFIG_OUTPUT);
+ gpio_controller_set_pin(desc->gpios, 1);
+ break;
+ default:
+ panic("%s: unimplemented flags 0x%x", __func__, flags);
+ }
+
+ return desc;
+}
+
+int
+gpiod_get_value_cansleep(const struct gpio_desc *desc)
+{
+ return gpio_controller_get_pin(((struct gpio_desc *)desc)->gpios);
+}
+
+struct phy {
+ int node;
+ const char *name;
+};
+
+struct phy *
+devm_phy_optional_get(struct device *dev, const char *name)
+{
+ struct platform_device *pdev = (struct platform_device *)dev;
+ struct phy *phy;
+ int idx;
+
+ idx = OF_getindex(pdev->node, name, "phy-names");
+ if (idx == -1)
+ return NULL;
+
+ phy = malloc(sizeof(*phy), M_DEVBUF, M_WAITOK);
+ phy->node = pdev->node;
+ phy->name = name;
+
+ return phy;
+}
+
+struct bus_type platform_bus_type;
+
+#include <dev/ofw/ofw_misc.h>
+
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+struct device_node *
+__of_devnode(void *arg)
+{
+ struct device *dev = container_of(arg, struct device, of_node);
+ struct platform_device *pdev = (struct platform_device *)dev;
+
+ return (struct device_node *)(uintptr_t)pdev->node;
+}
+
+int
+__of_device_is_compatible(struct device_node *np, const char *compatible)
+{
+ return OF_is_compatible((uintptr_t)np, compatible);
+}
+
+int
+__of_property_present(struct device_node *np, const char *propname)
+{
+ return OF_getpropbool((uintptr_t)np, (char *)propname);
+}
+
+int
+__of_property_read_variable_u32_array(struct device_node *np,
+ const char *propname, uint32_t *out_values, size_t sz_min, size_t sz_max)
+{
+ int len;
+
+ len = OF_getpropintarray((uintptr_t)np, (char *)propname, out_values,
+ sz_max * sizeof(*out_values));
+ if (len < 0)
+ return -EINVAL;
+ if (len == 0)
+ return -ENODATA;
+ if (len < sz_min * sizeof(*out_values) ||
+ len > sz_max * sizeof(*out_values))
+ return -EOVERFLOW;
+ if (sz_min == 1 && sz_max == 1)
+ return 0;
+ return len / sizeof(*out_values);
+}
+
+int
+__of_property_read_variable_u64_array(struct device_node *np,
+ const char *propname, uint64_t *out_values, size_t sz_min, size_t sz_max)
+{
+ int len;
+
+ len = OF_getpropint64array((uintptr_t)np, (char *)propname, out_values,
+ sz_max * sizeof(*out_values));
+ if (len < 0)
+ return -EINVAL;
+ if (len == 0)
+ return -ENODATA;
+ if (len < sz_min * sizeof(*out_values) ||
+ len > sz_max * sizeof(*out_values))
+ return -EOVERFLOW;
+ if (sz_min == 1 && sz_max == 1)
+ return 0;
+ return len / sizeof(*out_values);
+}
+
+int
+__of_property_match_string(struct device_node *np,
+ const char *propname, const char *str)
+{
+ int idx;
+
+ idx = OF_getindex((uintptr_t)np, str, propname);
+ if (idx == -1)
+ return -ENODATA;
+ return idx;
+}
+
+struct device_node *
+__of_parse_phandle(struct device_node *np, const char *propname, int idx)
+{
+ uint32_t phandles[16] = {};
+ int len, node;
+
+ len = OF_getpropintarray((uintptr_t)np, (char *)propname, phandles,
+ sizeof(phandles));
+ if (len < (idx + 1) * sizeof(uint32_t))
+ return NULL;
+
+ node = OF_getnodebyphandle(phandles[idx]);
+ if (node == 0)
+ return NULL;
+
+ return (struct device_node *)(uintptr_t)node;
+}
+
+int
+__of_parse_phandle_with_args(struct device_node *np, const char *propname,
+ const char *cellsname, int idx, struct of_phandle_args *args)
+{
+ uint32_t phandles[16] = {};
+ int i, len, node;
+
+ len = OF_getpropintarray((uintptr_t)np, (char *)propname, phandles,
+ sizeof(phandles));
+ if (len < (idx + 1) * sizeof(uint32_t))
+ return -ENOENT;
+
+ node = OF_getnodebyphandle(phandles[idx]);
+ if (node == 0)
+ return -ENOENT;
+
+ args->np = (struct device_node *)(uintptr_t)node;
+ args->args_count = OF_getpropint(node, (char *)cellsname, 0);
+ for (i = 0; i < args->args_count; i++)
+ args->args[i] = phandles[i + 1];
+
+ return 0;
+}
+
+int
+of_address_to_resource(struct device_node *np, int idx, struct resource *res)
+{
+ uint64_t reg[16] = {};
+ int len;
+
+ KASSERT(idx < 8);
+
+ len = OF_getpropint64array((uintptr_t)np, "reg", reg, sizeof(reg));
+ if (len < 0 || idx >= (len / (2 * sizeof(uint64_t))))
+ return -EINVAL;
+
+ res->start = reg[2 * idx];
+ res->end = reg[2 * idx] + reg[2 * idx + 1] - 1;
+
+ return 0;
+}
+
+static int
+next_node(int node)
+{
+ int peer = OF_peer(node);
+
+ while (node && !peer) {
+ node = OF_parent(node);
+ if (node)
+ peer = OF_peer(node);
+ }
+
+ return peer;
+}
+
+static int
+find_matching_node(int node, const struct of_device_id *id)
+{
+ int child, match;
+ int i;
+
+ for (child = OF_child(node); child; child = OF_peer(child)) {
+ match = find_matching_node(child, id);
+ if (match)
+ return match;
+ }
+
+ for (i = 0; id[i].compatible; i++) {
+ if (OF_is_compatible(node, id[i].compatible))
+ return node;
+ }
+
+ return 0;
+}
+
+struct device_node *
+__matching_node(struct device_node *np, const struct of_device_id *id)
+{
+ int node = OF_peer(0);
+ int match;
+
+ if (np)
+ node = next_node((uintptr_t)np);
+ while (node) {
+ match = find_matching_node(node, id);
+ if (match)
+ return (struct device_node *)(uintptr_t)match;
+ node = next_node(node);
+ }
+
+ return NULL;
+}
+
+struct platform_device *
+of_platform_device_create(struct device_node *np, const char *bus_id,
+ struct device *parent)
+{
+ struct platform_device *pdev;
+
+ pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK | M_ZERO);
+ pdev->node = (intptr_t)np;
+ pdev->parent = parent;
+
+ LIST_INSERT_HEAD(&pdev_list, pdev, next);
+
+ return pdev;
+}
+
+struct platform_device *
+of_find_device_by_node(struct device_node *np)
+{
+ struct platform_device *pdev;
+
+ LIST_FOREACH(pdev, &pdev_list, next) {
+ if (pdev->node == (intptr_t)np)
+ return pdev;
+ }
+
+ return NULL;
+}
+
+int
+of_device_is_available(struct device_node *np)
+{
+ char status[32];
+
+ if (OF_getprop((uintptr_t)np, "status", status, sizeof(status)) > 0 &&
+ strcmp(status, "disabled") == 0)
+ return 0;
+
+ return 1;
+}
+
+int
+of_dma_configure(struct device *dev, struct device_node *np, int force_dma)
+{
+ struct platform_device *pdev = (struct platform_device *)dev;
+ bus_dma_tag_t dmat = dma_tag_lookup(pdev->parent);
+
+ pdev->dmat = iommu_device_map(pdev->node, dmat);
+ return 0;
+}
+
+struct device_node *
+__of_get_compatible_child(void *p, const char *compat)
+{
+ struct device *dev = container_of(p, struct device, of_node);
+ struct platform_device *pdev = (struct platform_device *)dev;
+ int child;
+
+ for (child = OF_child(pdev->node); child; child = OF_peer(child)) {
+ if (OF_is_compatible(child, compat))
+ return (struct device_node *)(uintptr_t)child;
+ }
+ return NULL;
+}
+
+struct device_node *
+__of_get_child_by_name(void *p, const char *name)
+{
+ struct device *dev = container_of(p, struct device, of_node);
+ struct platform_device *pdev = (struct platform_device *)dev;
+ int child;
+
+ child = OF_getnodebyname(pdev->node, name);
+ if (child == 0)
+ return NULL;
+ return (struct device_node *)(uintptr_t)child;
+}
+
+#endif
diff --git a/sys/dev/pci/drm/include/drm/drm_fb_dma_helper.h b/sys/dev/pci/drm/include/drm/drm_fb_dma_helper.h
new file mode 100644
index 00000000000..8ed7abbb84c
--- /dev/null
+++ b/sys/dev/pci/drm/include/drm/drm_fb_dma_helper.h
@@ -0,0 +1,13 @@
+/* Public Domain */
+
+#ifndef _DRM_DRM_FB_DMA_HELPER_H
+#define _DRM_DRM_FB_DMA_HELPER_H
+
+#include <linux/types.h>
+
+struct drm_framebuffer;
+
+struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *,
+ unsigned int);
+
+#endif
diff --git a/sys/dev/pci/drm/include/drm/drm_fbdev_generic.h b/sys/dev/pci/drm/include/drm/drm_fbdev_generic.h
new file mode 100644
index 00000000000..75799342098
--- /dev/null
+++ b/sys/dev/pci/drm/include/drm/drm_fbdev_generic.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef DRM_FBDEV_GENERIC_H
+#define DRM_FBDEV_GENERIC_H
+
+struct drm_device;
+
+#ifdef CONFIG_DRM_FBDEV_EMULATION
+void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp);
+#else
+static inline void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
+{ }
+#endif
+
+#endif
diff --git a/sys/dev/pci/drm/include/drm/drm_gem_dma_helper.h b/sys/dev/pci/drm/include/drm/drm_gem_dma_helper.h
index ece48d244cb..be399462a56 100644
--- a/sys/dev/pci/drm/include/drm/drm_gem_dma_helper.h
+++ b/sys/dev/pci/drm/include/drm/drm_gem_dma_helper.h
@@ -1,10 +1,15 @@
/* Public Domain */
+#ifndef _DRM_DRM_GEM_DMA_HELPER_H
+#define _DRM_DRM_GEM_DMA_HELPER_H
+
#include <drm/drm_gem.h>
void drm_gem_dma_free_object(struct drm_gem_object *);
int drm_gem_dma_dumb_create(struct drm_file *, struct drm_device *,
struct drm_mode_create_dumb *);
+int drm_gem_dma_dumb_create_internal(struct drm_file *, struct drm_device *,
+ struct drm_mode_create_dumb *);
int drm_gem_dma_dumb_map_offset(struct drm_file *, struct drm_device *,
uint32_t, uint64_t *);
struct drm_gem_dma_object *drm_gem_dma_create(struct drm_device *,
@@ -23,8 +28,18 @@ struct drm_gem_dma_object {
bus_dmamap_t dmamap;
bus_dma_segment_t dmasegs[1];
size_t dmasize;
+ dma_addr_t dma_addr;
caddr_t vaddr;
struct sg_table *sgt;
};
#define to_drm_gem_dma_obj(gem_obj) container_of(gem_obj, struct drm_gem_dma_object, base)
+
+struct file_operations { int dummy; };
+#define DEFINE_DRM_GEM_DMA_FOPS(name) struct file_operations name = {};
+
+#define DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(x) \
+ .dumb_create = (x), \
+ .gem_fault = drm_gem_dma_fault
+
+#endif
diff --git a/sys/dev/pci/drm/include/drm/drm_gem_framebuffer_helper.h b/sys/dev/pci/drm/include/drm/drm_gem_framebuffer_helper.h
index 549fd5190b5..ce4f9151edc 100644
--- a/sys/dev/pci/drm/include/drm/drm_gem_framebuffer_helper.h
+++ b/sys/dev/pci/drm/include/drm/drm_gem_framebuffer_helper.h
@@ -6,6 +6,8 @@
struct drm_framebuffer;
struct drm_file;
+struct drm_framebuffer *drm_gem_fb_create(struct drm_device *,
+ struct drm_file *, const struct drm_mode_fb_cmd2 *);
void drm_gem_fb_destroy(struct drm_framebuffer *);
int drm_gem_fb_create_handle(struct drm_framebuffer *, struct drm_file *,
unsigned int *);
diff --git a/sys/dev/pci/drm/include/drm/drm_legacy.h b/sys/dev/pci/drm/include/drm/drm_legacy.h
index af041341948..cf73e3a17c8 100644
--- a/sys/dev/pci/drm/include/drm/drm_legacy.h
+++ b/sys/dev/pci/drm/include/drm/drm_legacy.h
@@ -100,6 +100,7 @@ struct drm_dmamem {
bus_size_t size;
int nsegs;
bus_dma_segment_t segs[1];
+ LIST_ENTRY(drm_dmamem) next;
};
typedef struct drm_dma_handle {
diff --git a/sys/dev/pci/drm/include/drm/drm_of.h b/sys/dev/pci/drm/include/drm/drm_of.h
index d2ce8c4086a..aebaae00503 100644
--- a/sys/dev/pci/drm/include/drm/drm_of.h
+++ b/sys/dev/pci/drm/include/drm/drm_of.h
@@ -1 +1,11 @@
/* Public domain. */
+
+#ifndef _DRM_DRM_OF_H
+#define _DRM_DRM_OF_H
+
+struct component_match;
+
+void drm_of_component_match_add(struct device *, struct component_match **,
+ int (*)(struct device *, void *), struct device_node *);
+
+#endif
diff --git a/sys/dev/pci/drm/include/drm/drm_simple_kms_helper.h b/sys/dev/pci/drm/include/drm/drm_simple_kms_helper.h
new file mode 100644
index 00000000000..ecaa86c4b2d
--- /dev/null
+++ b/sys/dev/pci/drm/include/drm/drm_simple_kms_helper.h
@@ -0,0 +1,17 @@
+/* Public domain. */
+
+#ifndef _DRM_DRM_SIMPLE_KMS_HELPER_H
+#define _DRM_DRM_SIMPLE_KMS_HELPER_H
+
+static inline void *
+__drmm_simple_encoder_alloc(struct drm_device *dev, size_t size,
+ size_t offset, int type)
+{
+ return __drmm_encoder_alloc(dev, size, offset, NULL, type, NULL);
+}
+
+#define drmm_simple_encoder_alloc(dev, type, member, encoder_type) \
+ ((type *) __drmm_simple_encoder_alloc(dev, sizeof(type), \
+ offsetof(type, member), encoder_type))
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/align.h b/sys/dev/pci/drm/include/linux/align.h
new file mode 100644
index 00000000000..183c68ca274
--- /dev/null
+++ b/sys/dev/pci/drm/include/linux/align.h
@@ -0,0 +1,11 @@
+/* Public domain. */
+
+#ifndef _LINUX_ALIGN_H
+#define _LINUX_ALIGN_H
+
+#include <sys/param.h>
+
+#undef ALIGN
+#define ALIGN(x, y) roundup2((x), (y))
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/atomic.h b/sys/dev/pci/drm/include/linux/atomic.h
index fb785a0c911..9f2c768cc05 100644
--- a/sys/dev/pci/drm/include/linux/atomic.h
+++ b/sys/dev/pci/drm/include/linux/atomic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomic.h,v 1.20 2023/01/01 01:34:58 jsg Exp $ */
+/* $OpenBSD: atomic.h,v 1.21 2024/01/06 09:33:08 kettenis Exp $ */
/**
* \file drm_atomic.h
* Atomic operations used in the DRM which may or may not be provided by the OS.
@@ -423,6 +423,9 @@ find_next_bit(const volatile void *p, int max, int b)
#define rmb() __membar("dsb ld")
#define wmb() __membar("dsb st")
#define mb() __membar("dsb sy")
+#define dma_rmb() __membar("dmb oshld")
+#define dma_wmb() __membar("dmb oshst")
+#define dma_mb() __membar("dmb osh");
#elif defined(__arm__)
#define rmb() __membar("dsb sy")
#define wmb() __membar("dsb sy")
diff --git a/sys/dev/pci/drm/include/linux/bitmap.h b/sys/dev/pci/drm/include/linux/bitmap.h
index e7883c78032..9b929701493 100644
--- a/sys/dev/pci/drm/include/linux/bitmap.h
+++ b/sys/dev/pci/drm/include/linux/bitmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bitmap.h,v 1.5 2023/01/01 01:34:58 jsg Exp $ */
+/* $OpenBSD: bitmap.h,v 1.6 2024/01/06 09:33:08 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@@ -18,6 +18,7 @@
#ifndef _LINUX_BITMAP_H
#define _LINUX_BITMAP_H
+#include <linux/align.h>
#include <linux/bitops.h>
#include <linux/string.h>
@@ -140,6 +141,26 @@ bitmap_weight(const void *p, u_int n)
return sum;
}
+static inline int
+bitmap_find_free_region(void *p, u_int n, int o)
+{
+ int b;
+
+ KASSERT(o == 0);
+ b = find_first_zero_bit(p, n);
+ if (b == n)
+ return -ENOMEM;
+ __set_bit(b, p);
+ return b;
+}
+
+static inline void
+bitmap_release_region(void *p, u_int b, int o)
+{
+ KASSERT(o == 0);
+ __clear_bit(b, p);
+}
+
void *bitmap_zalloc(u_int, gfp_t);
void bitmap_free(void *);
diff --git a/sys/dev/pci/drm/include/linux/clk.h b/sys/dev/pci/drm/include/linux/clk.h
new file mode 100644
index 00000000000..4f3cf3dab4d
--- /dev/null
+++ b/sys/dev/pci/drm/include/linux/clk.h
@@ -0,0 +1,14 @@
+/* Public domain. */
+
+#ifndef _LINUX_CLK_H
+#define _LINUX_CLK_H
+
+struct clk {
+ uint32_t freq;
+};
+
+unsigned long clk_get_rate(struct clk *);
+struct clk *devm_clk_get(struct device *, const char *);
+#define devm_clk_put(a, b)
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/completion.h b/sys/dev/pci/drm/include/linux/completion.h
index ea9c1fa13c0..7c78943ac85 100644
--- a/sys/dev/pci/drm/include/linux/completion.h
+++ b/sys/dev/pci/drm/include/linux/completion.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: completion.h,v 1.9 2020/06/22 14:19:35 jsg Exp $ */
+/* $OpenBSD: completion.h,v 1.10 2024/01/06 09:33:08 kettenis Exp $ */
/*
* Copyright (c) 2015, 2018 Mark Kettenis
*
@@ -28,6 +28,9 @@ struct completion {
struct mutex lock;
};
+#define DECLARE_COMPLETION_ONSTACK(name) \
+ struct completion name = { 0, MUTEX_INITIALIZER(IPL_TTY) }
+
static inline void
init_completion(struct completion *x)
{
diff --git a/sys/dev/pci/drm/include/linux/component.h b/sys/dev/pci/drm/include/linux/component.h
index 3f210fb079f..e042f331582 100644
--- a/sys/dev/pci/drm/include/linux/component.h
+++ b/sys/dev/pci/drm/include/linux/component.h
@@ -3,7 +3,39 @@
#ifndef _LINUX_COMPONENT_H
#define _LINUX_COMPONENT_H
+#include <sys/_null.h>
+
+struct component_match;
+struct device;
+
+struct component_ops {
+ int (*bind)(struct device *, struct device *, void *);
+ void (*unbind)(struct device *, struct device *, void *);
+};
+
+struct component_master_ops {
+ int (*bind)(struct device *);
+ void (*unbind)(struct device *);
+};
+
+static inline int
+component_add(struct device *dev, const struct component_ops *ops)
+{
+ return ops->bind(dev, NULL, NULL);
+}
+
#define component_del(a, b)
-#define component_add(a, b) 0
+
+static inline int
+component_bind_all(struct device *dev, void *data)
+{
+ return 0;
+}
+
+#define component_unbind_all(a, b)
+
+int component_compare_of(struct device *, void *);
+int component_master_add_with_match(struct device *,
+ const struct component_master_ops *, struct component_match *);
#endif
diff --git a/sys/dev/pci/drm/include/linux/device.h b/sys/dev/pci/drm/include/linux/device.h
index c72b33b3335..c9abc5e10db 100644
--- a/sys/dev/pci/drm/include/linux/device.h
+++ b/sys/dev/pci/drm/include/linux/device.h
@@ -126,4 +126,9 @@ dev_driver_string(struct device *dev)
/* should be bus id as string, ie 0000:00:02.0 */
#define dev_name(dev) ""
+static inline void
+device_set_wakeup_path(struct device *dev)
+{
+}
+
#endif
diff --git a/sys/dev/pci/drm/include/linux/dma-mapping.h b/sys/dev/pci/drm/include/linux/dma-mapping.h
index 1cd704ab088..56498c569ea 100644
--- a/sys/dev/pci/drm/include/linux/dma-mapping.h
+++ b/sys/dev/pci/drm/include/linux/dma-mapping.h
@@ -11,6 +11,8 @@ struct device;
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) -1)
+#define DMA_MAPPING_ERROR (dma_addr_t)-1
+
static inline int
dma_set_coherent_mask(struct device *dev, uint64_t m)
{
@@ -60,4 +62,23 @@ dma_mapping_error(void *dev, dma_addr_t addr)
return 0;
}
+void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, int);
+void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
+
+static inline void *
+dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dva, int gfp)
+{
+ return dma_alloc_coherent(dev, size, dva, gfp);
+}
+
+int dma_get_sgtable(struct device *, struct sg_table *, void *,
+ dma_addr_t, size_t);
+int dma_map_sgtable(struct device *, struct sg_table *,
+ enum dma_data_direction, u_long);
+void dma_unmap_sgtable(struct device *, struct sg_table *,
+ enum dma_data_direction, u_long);
+
+dma_addr_t dma_map_resource(struct device *, phys_addr_t, size_t,
+ enum dma_data_direction, u_long);
+
#endif
diff --git a/sys/dev/pci/drm/include/linux/gpio/consumer.h b/sys/dev/pci/drm/include/linux/gpio/consumer.h
index e69de29bb2d..75394c1c219 100644
--- a/sys/dev/pci/drm/include/linux/gpio/consumer.h
+++ b/sys/dev/pci/drm/include/linux/gpio/consumer.h
@@ -0,0 +1,21 @@
+/* Public domain. */
+
+#ifndef _LINUX_GPIO_CONSUMER_H
+#define _LINUX_GPIO_CONSUMER_H
+
+struct device;
+struct gpio_desc;
+
+#define GPIOD_IN 0x0001
+#define GPIOD_OUT_HIGH 0x0002
+
+struct gpio_desc *devm_gpiod_get_optional(struct device *, const char *, int);
+int gpiod_get_value_cansleep(const struct gpio_desc *);
+
+static inline int
+gpiod_to_irq(const struct gpio_desc *desc)
+{
+ return 42;
+}
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/interrupt.h b/sys/dev/pci/drm/include/linux/interrupt.h
index b555183c9b2..6841e624d6e 100644
--- a/sys/dev/pci/drm/include/linux/interrupt.h
+++ b/sys/dev/pci/drm/include/linux/interrupt.h
@@ -13,7 +13,12 @@
struct seq_file;
-#define IRQF_SHARED 0
+#define IRQF_SHARED 0x0001
+#define IRQF_ONESHOT 0x0002
+#define IRQF_NO_AUTOEN 0x0004
+
+#define IRQF_TRIGGER_RISING 0x1000
+#define IRQF_TRIGGER_FALLING 0x2000
#define request_irq(irq, hdlr, flags, name, dev) (0)
@@ -22,8 +27,25 @@ free_irq(unsigned int irq, void *dev)
{
}
+static inline void
+disable_irq(u_int irq)
+{
+}
+
+static inline void
+enable_irq(u_int irq)
+{
+}
+
typedef irqreturn_t (*irq_handler_t)(int, void *);
+static inline int
+devm_request_threaded_irq(struct device *dev, u_int irq, irq_handler_t handler,
+ irq_handler_t thread_fn, u_int irqflags, const char *devname, void *arg)
+{
+ return 0;
+}
+
struct tasklet_struct {
union {
void (*func)(unsigned long);
diff --git a/sys/dev/pci/drm/include/linux/io.h b/sys/dev/pci/drm/include/linux/io.h
index 19bf59c9740..911f8608ab6 100644
--- a/sys/dev/pci/drm/include/linux/io.h
+++ b/sys/dev/pci/drm/include/linux/io.h
@@ -183,4 +183,9 @@ IOMEM_ERR_PTR(long error)
return (void *) error;
}
+#define MEMREMAP_WB (1 << 0)
+
+void *memremap(phys_addr_t, size_t, int);
+void memunmap(void *);
+
#endif
diff --git a/sys/dev/pci/drm/include/linux/iommu.h b/sys/dev/pci/drm/include/linux/iommu.h
index e69de29bb2d..de4e385a357 100644
--- a/sys/dev/pci/drm/include/linux/iommu.h
+++ b/sys/dev/pci/drm/include/linux/iommu.h
@@ -0,0 +1,29 @@
+/* Public domain. */
+
+#ifndef _LINUX_IOMMU_H
+#define _LINUX_IOMMU_H
+
+struct bus_type;
+struct sg_table;
+
+struct iommu_domain {
+ bus_dma_tag_t dmat;
+};
+
+#define IOMMU_READ 0x0001
+#define IOMMU_WRITE 0x0002
+
+size_t iommu_map_sgtable(struct iommu_domain *, u_long,
+ struct sg_table *, int);
+size_t iommu_unmap(struct iommu_domain *, u_long, size_t);
+
+
+struct iommu_domain *iommu_get_domain_for_dev(struct device *);
+phys_addr_t iommu_iova_to_phys(struct iommu_domain *, dma_addr_t);
+
+struct iommu_domain *iommu_domain_alloc(struct bus_type *);
+#define iommu_domain_free(a)
+int iommu_attach_device(struct iommu_domain *, struct device *);
+#define iommu_detach_device(a, b)
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/mux/consumer.h b/sys/dev/pci/drm/include/linux/mux/consumer.h
new file mode 100644
index 00000000000..e3bb9cd5781
--- /dev/null
+++ b/sys/dev/pci/drm/include/linux/mux/consumer.h
@@ -0,0 +1,20 @@
+/* Public domain. */
+
+#ifndef _LINUX_MUX_CONSUMER_H
+#define _LINUX_MUX_CONSUMER_H
+
+struct mux_control;
+
+static inline struct mux_control *
+devm_mux_control_get(struct device *dev, const char *name)
+{
+ return NULL;
+}
+
+static inline int
+mux_control_select(struct mux_control *mux, u_int state)
+{
+ return 0;
+}
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/of.h b/sys/dev/pci/drm/include/linux/of.h
index cbac3f60606..f9349b1fcaf 100644
--- a/sys/dev/pci/drm/include/linux/of.h
+++ b/sys/dev/pci/drm/include/linux/of.h
@@ -12,4 +12,76 @@ of_machine_is_compatible(const char *model)
}
#endif
+struct device_node {
+ const char *full_name;
+};
+
+#define of_node dv_cfdata
+
+struct device_node *__of_get_compatible_child(void *, const char *);
+#define of_get_compatible_child(d, n) \
+ __of_get_compatible_child(&(d), (n))
+
+struct device_node *__of_get_child_by_name(void *, const char *);
+#define of_get_child_by_name(d, n) \
+ __of_get_child_by_name(&(d), (n))
+
+#define of_node_put(p)
+
+struct device_node *__of_devnode(void *);
+#define __of_node(arg) \
+ __builtin_types_compatible_p(typeof(arg), struct device_node *) ? \
+ (struct device_node *)arg : __of_devnode(&arg)
+
+int __of_property_present(struct device_node *, const char *);
+#define of_property_present(n, p) \
+ __of_property_present(__of_node(n), (p))
+
+int __of_property_read_variable_u32_array(struct device_node *,
+ const char *, uint32_t *, size_t, size_t);
+#define of_property_read_u32(n, p, o) \
+ __of_property_read_variable_u32_array(__of_node(n), (p), (o), 1, 1)
+#define of_property_read_variable_u32_array(n, p, o, l, h) \
+ __of_property_read_variable_u32_array(__of_node(n), (p), (o), (l), (h))
+
+int __of_property_read_variable_u64_array(struct device_node *,
+ const char *, uint64_t *, size_t, size_t);
+#define of_property_read_u64(n, p, o) \
+ __of_property_read_variable_u64_array(__of_node(n), (p), (o), 1, 1)
+
+int __of_property_match_string(struct device_node *,
+ const char *, const char *);
+#define of_property_match_string(n, a, b) \
+ __of_property_match_string(__of_node(n), (a), (b))
+
+struct device_node *__of_parse_phandle(struct device_node *,
+ const char *, int);
+#define of_parse_phandle(n, a, b) \
+ __of_parse_phandle(__of_node(n), (a), (b))
+
+struct of_phandle_args {
+ struct device_node *np;
+ int args_count;
+ uint32_t args[5];
+};
+
+int __of_parse_phandle_with_args(struct device_node *,
+ const char *, const char *, int, struct of_phandle_args *);
+#define of_parse_phandle_with_args(n, a, b, c, d) \
+ __of_parse_phandle_with_args(__of_node(n), (a), (b), (c), (d))
+
+int of_device_is_available(struct device_node *);
+
+struct of_device_id {
+ const char *compatible;
+ const void *data;
+};
+
+struct device_node *__matching_node(struct device_node *,
+ const struct of_device_id *);
+#define for_each_matching_node(a, b) \
+ for (a = __matching_node(NULL, b); a; a = __matching_node(a, b))
+
+static const void *of_device_get_match_data(const struct device *);
+
#endif
diff --git a/sys/dev/pci/drm/include/linux/of_address.h b/sys/dev/pci/drm/include/linux/of_address.h
new file mode 100644
index 00000000000..453e0ad79b4
--- /dev/null
+++ b/sys/dev/pci/drm/include/linux/of_address.h
@@ -0,0 +1,11 @@
+/* Public domain. */
+
+#ifndef _LINUX_OF_ADDRESS_H
+#define _LINUX_OF_ADDRESS_H
+
+struct device_node;
+struct resource;
+
+int of_address_to_resource(struct device_node *, int, struct resource *);
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/of_device.h b/sys/dev/pci/drm/include/linux/of_device.h
index e69de29bb2d..2a5fb2293f1 100644
--- a/sys/dev/pci/drm/include/linux/of_device.h
+++ b/sys/dev/pci/drm/include/linux/of_device.h
@@ -0,0 +1,8 @@
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+int __of_device_is_compatible(struct device_node *, const char *);
+#define of_device_is_compatible(n, c) \
+ __of_device_is_compatible(__of_node(n), (c))
+
+int of_dma_configure(struct device *, struct device_node *, int);
diff --git a/sys/dev/pci/drm/include/linux/of_platform.h b/sys/dev/pci/drm/include/linux/of_platform.h
new file mode 100644
index 00000000000..8743994cd8d
--- /dev/null
+++ b/sys/dev/pci/drm/include/linux/of_platform.h
@@ -0,0 +1,12 @@
+/* Public domain. */
+
+#ifndef _LINUX_OF_PLATFORM_H
+#define _LINUX_OF_PLATFORM_H
+
+struct platform_device *of_platform_device_create(struct device_node *,
+ const char *, struct device *);
+struct platform_device *of_find_device_by_node(struct device_node *);
+
+#define of_platform_device_destroy(a, b)
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/phy/phy.h b/sys/dev/pci/drm/include/linux/phy/phy.h
new file mode 100644
index 00000000000..b72dd87eea3
--- /dev/null
+++ b/sys/dev/pci/drm/include/linux/phy/phy.h
@@ -0,0 +1,39 @@
+/* Public domain. */
+
+#ifndef _LINUX_PHY_PHY_H
+#define _LINUX_PHY_PHY_H
+
+struct phy_configure_opts_dp {
+ u_int link_rate;
+ u_int lanes;
+ int set_rate : 1;
+ int set_lanes : 1;
+ int set_voltages : 1;
+};
+
+union phy_configure_opts {
+ struct phy_configure_opts_dp dp;
+};
+
+enum phy_mode {
+ PHY_MODE_INVALID,
+ PHY_MODE_DP,
+};
+
+struct phy;
+
+struct phy *devm_phy_optional_get(struct device *, const char *);
+
+static inline int
+phy_configure(struct phy *phy, union phy_configure_opts *opts)
+{
+ return 0;
+}
+
+static inline int
+phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
+{
+ return 0;
+}
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/platform_device.h b/sys/dev/pci/drm/include/linux/platform_device.h
index e69de29bb2d..b144add99f0 100644
--- a/sys/dev/pci/drm/include/linux/platform_device.h
+++ b/sys/dev/pci/drm/include/linux/platform_device.h
@@ -0,0 +1,53 @@
+/* Public domain. */
+
+#ifndef _LINUX_PLATFORM_DEVICE_H
+#define _LINUX_PLATFORM_DEVICE_H
+
+#include <linux/device.h>
+
+struct platform_driver;
+
+struct platform_device {
+ struct device dev;
+ int num_resources;
+ struct resource *resource;
+ struct device *parent;
+ bus_dma_tag_t dmat;
+ int node;
+
+#ifdef __HAVE_FDT
+ struct fdt_attach_args *faa;
+#endif
+
+ LIST_ENTRY(platform_device) next;
+};
+
+#define to_platform_device(p) (struct platform_device *)(p)
+
+extern struct bus_type platform_bus_type;
+
+void __iomem *
+devm_platform_ioremap_resource_byname(struct platform_device *, const char *);
+
+inline void
+platform_set_drvdata(struct platform_device *pdev, void *data)
+{
+ dev_set_drvdata(&pdev->dev, data);
+}
+
+inline void *
+platform_get_drvdata(struct platform_device *pdev)
+{
+ return dev_get_drvdata(&pdev->dev);
+}
+
+inline int
+platform_driver_register(struct platform_driver *platform_drv)
+{
+ return 0;
+}
+
+void platform_device_register(struct platform_device *);
+struct resource *platform_get_resource(struct platform_device *, u_int, u_int);
+
+#endif
diff --git a/sys/dev/pci/drm/include/linux/pm.h b/sys/dev/pci/drm/include/linux/pm.h
index ac202674c7b..1aa4b7aeae2 100644
--- a/sys/dev/pci/drm/include/linux/pm.h
+++ b/sys/dev/pci/drm/include/linux/pm.h
@@ -5,6 +5,16 @@
#include <linux/completion.h>
+struct dev_pm_ops {
+ int (*suspend)(struct device *);
+ int (*resume)(struct device *);
+};
+
+#define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+ const struct dev_pm_ops name = { \
+ .suspend = suspend_fn, .resume = resume_fn \
+ }
+
struct dev_pm_domain {
};
diff --git a/sys/dev/pci/drm/include/linux/scatterlist.h b/sys/dev/pci/drm/include/linux/scatterlist.h
index 614459edbfe..760fa855667 100644
--- a/sys/dev/pci/drm/include/linux/scatterlist.h
+++ b/sys/dev/pci/drm/include/linux/scatterlist.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scatterlist.h,v 1.6 2023/08/02 11:03:17 jsg Exp $ */
+/* $OpenBSD: scatterlist.h,v 1.7 2024/01/06 09:33:08 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@@ -37,6 +37,7 @@ struct sg_table {
struct scatterlist *sgl;
unsigned int nents;
unsigned int orig_nents;
+ bus_dmamap_t dmamap;
};
struct sg_page_iter {
diff --git a/sys/dev/pci/drm/include/linux/time.h b/sys/dev/pci/drm/include/linux/time.h
index fb9c3308617..7178681806b 100644
--- a/sys/dev/pci/drm/include/linux/time.h
+++ b/sys/dev/pci/drm/include/linux/time.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: time.h,v 1.4 2020/08/03 07:02:08 jsg Exp $ */
+/* $OpenBSD: time.h,v 1.5 2024/01/06 09:33:08 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@@ -29,6 +29,8 @@
#define USEC_PER_MSEC 1000L
#define USEC_PER_SEC 1000000L
+#define MSEC_PER_SEC 1000L
+
struct timespec64 {
time_t tv_sec;
long tv_nsec;
diff --git a/sys/dev/pci/drm/include/linux/workqueue.h b/sys/dev/pci/drm/include/linux/workqueue.h
index 05cccf5265b..64faa63e0da 100644
--- a/sys/dev/pci/drm/include/linux/workqueue.h
+++ b/sys/dev/pci/drm/include/linux/workqueue.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: workqueue.h,v 1.10 2023/03/21 09:44:35 jsg Exp $ */
+/* $OpenBSD: workqueue.h,v 1.11 2024/01/06 09:33:08 kettenis Exp $ */
/*
* Copyright (c) 2015 Mark Kettenis
*
@@ -35,9 +35,10 @@ extern struct workqueue_struct *system_highpri_wq;
extern struct workqueue_struct *system_unbound_wq;
extern struct workqueue_struct *system_long_wq;
-#define WQ_HIGHPRI 1
-#define WQ_FREEZABLE 2
-#define WQ_UNBOUND 4
+#define WQ_HIGHPRI (1 << 1)
+#define WQ_FREEZABLE (1 << 2)
+#define WQ_UNBOUND (1 << 3)
+#define WQ_MEM_RECLAIM (1 << 4)
#define WQ_UNBOUND_MAX_ACTIVE 4 /* matches nthreads in drm_linux.c */
@@ -49,7 +50,7 @@ alloc_workqueue(const char *name, int flags, int max_active)
}
static inline struct workqueue_struct *
-alloc_ordered_workqueue(const char *name, int flags)
+alloc_ordered_workqueue(const char *name, int flags, ...)
{
struct taskq *tq = taskq_create(name, 1, IPL_TTY, 0);
return (struct workqueue_struct *)tq;
diff --git a/sys/dev/pci/drm/include/sound/pcm.h b/sys/dev/pci/drm/include/sound/pcm.h
new file mode 100644
index 00000000000..8659f00ea7b
--- /dev/null
+++ b/sys/dev/pci/drm/include/sound/pcm.h
@@ -0,0 +1,43 @@
+/* Public domain. */
+
+#ifndef _SOUND_PCM_H
+#define _SOUND_PCM_H
+
+#define SNDRV_CHMAP_UNKNOWN 0
+#define SNDRV_CHMAP_FL 1
+#define SNDRV_CHMAP_FR 2
+#define SNDRV_CHMAP_RL 3
+#define SNDRV_CHMAP_RR 4
+#define SNDRV_CHMAP_FC 5
+#define SNDRV_CHMAP_LFE 6
+#define SNDRV_CHMAP_RC 7
+#define SNDRV_CHMAP_FLC 8
+#define SNDRV_CHMAP_FRC 9
+#define SNDRV_CHMAP_RLC 10
+#define SNDRV_CHMAP_RRC 11
+#define SNDRV_CHMAP_FLW 12
+#define SNDRV_CHMAP_FRW 13
+#define SNDRV_CHMAP_FLH 14
+#define SNDRV_CHMAP_FCH 15
+#define SNDRV_CHMAP_FRH 16
+#define SNDRV_CHMAP_TC 17
+
+#define SNDRV_PCM_RATE_KNOT -1
+
+#define SNDRV_PCM_FMTBIT_S16 0x0001
+#define SNDRV_PCM_FMTBIT_S20 0x0002
+#define SNDRV_PCM_FMTBIT_S24 0x0004
+#define SNDRV_PCM_FMTBIT_S32 0x0008
+
+struct snd_pcm_chmap_elem {
+ u_char channels;
+ u_char map[15];
+};
+
+static inline int
+snd_pcm_rate_to_rate_bit(u_int rate)
+{
+ return SNDRV_PCM_RATE_KNOT;
+}
+
+#endif