Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/nvidia Update tegra drm and nouveau to compile ...



details:   https://anonhg.NetBSD.org/src/rev/b5cb13443e99
branches:  trunk
changeset: 366425:b5cb13443e99
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 15:31:51 2018 +0000

description:
Update tegra drm and nouveau to compile with new drmkms.

Compile-tested only.

diffstat:

 sys/arch/arm/nvidia/tegra_drm.c      |   29 +---
 sys/arch/arm/nvidia/tegra_drm.h      |    8 +-
 sys/arch/arm/nvidia/tegra_drm_mode.c |   13 +-
 sys/arch/arm/nvidia/tegra_nouveau.c  |  241 +++++++++++++++++++---------------
 4 files changed, 147 insertions(+), 144 deletions(-)

diffs (truncated from 524 to 300 lines):

diff -r 54b98d340314 -r b5cb13443e99 sys/arch/arm/nvidia/tegra_drm.c
--- a/sys/arch/arm/nvidia/tegra_drm.c   Mon Aug 27 15:31:27 2018 +0000
+++ b/sys/arch/arm/nvidia/tegra_drm.c   Mon Aug 27 15:31:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_drm.c,v 1.9 2017/12/28 14:02:08 jmcneill Exp $ */
+/* $NetBSD: tegra_drm.c,v 1.10 2018/08/27 15:31:51 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_drm.c,v 1.9 2017/12/28 14:02:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_drm.c,v 1.10 2018/08/27 15:31:51 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -51,7 +51,6 @@
 static int     tegra_drm_match(device_t, cfdata_t, void *);
 static void    tegra_drm_attach(device_t, device_t, void *);
 
-static const char *tegra_drm_get_name(struct drm_device *);
 static int     tegra_drm_set_busid(struct drm_device *, struct drm_master *);
 
 static int     tegra_drm_load(struct drm_device *, unsigned long);
@@ -80,13 +79,9 @@
        .date = DRIVER_DATE,
        .major = DRIVER_MAJOR,
        .minor = DRIVER_MINOR,
-       .patchlevel = DRIVER_PATCHLEVEL 
-};
+       .patchlevel = DRIVER_PATCHLEVEL,
 
-static const struct drm_bus tegra_drm_bus = {
-       .bus_type = DRIVER_BUS_PLATFORM,
-       .get_name = tegra_drm_get_name,
-       .set_busid = tegra_drm_set_busid
+       .set_busid = tegra_drm_set_busid,
 };
 
 CFATTACH_DECL_NEW(tegra_drm, sizeof(struct tegra_drm_softc),
@@ -191,8 +186,6 @@
 
        prop_dictionary_get_bool(prop, "force-dvi", &sc->sc_force_dvi);
 
-       driver->bus = &tegra_drm_bus;
-
        sc->sc_ddev = drm_dev_alloc(driver, sc->sc_dev);
        if (sc->sc_ddev == NULL) {
                aprint_error_dev(self, "couldn't allocate DRM device\n");
@@ -219,12 +212,6 @@
        return;
 }
 
-static const char *
-tegra_drm_get_name(struct drm_device *ddev)
-{
-       return DRIVER_NAME;
-}
-
 static int
 tegra_drm_set_busid(struct drm_device *ddev, struct drm_master *master)
 {
@@ -243,16 +230,8 @@
 static int
 tegra_drm_load(struct drm_device *ddev, unsigned long flags)
 {
-       char *devname;
        int error;
 
-       devname = kzalloc(strlen(DRIVER_NAME) + 1, GFP_KERNEL);
-       if (devname == NULL) {
-               return -ENOMEM;
-       }
-       strcpy(devname, DRIVER_NAME);
-       ddev->devname = devname;
-
        error = tegra_drm_mode_init(ddev);
        if (error)
                goto drmerr;
diff -r 54b98d340314 -r b5cb13443e99 sys/arch/arm/nvidia/tegra_drm.h
--- a/sys/arch/arm/nvidia/tegra_drm.h   Mon Aug 27 15:31:27 2018 +0000
+++ b/sys/arch/arm/nvidia/tegra_drm.h   Mon Aug 27 15:31:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_drm.h,v 1.8 2017/12/26 14:54:52 jmcneill Exp $ */
+/* $NetBSD: tegra_drm.h,v 1.9 2018/08/27 15:31:51 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -148,9 +148,9 @@
 
 int    tegra_drm_mode_init(struct drm_device *);
 int    tegra_drm_fb_init(struct drm_device *);
-u32    tegra_drm_get_vblank_counter(struct drm_device *, int);
-int    tegra_drm_enable_vblank(struct drm_device *, int);
-void   tegra_drm_disable_vblank(struct drm_device *, int);
+u32    tegra_drm_get_vblank_counter(struct drm_device *, unsigned int);
+int    tegra_drm_enable_vblank(struct drm_device *, unsigned int);
+void   tegra_drm_disable_vblank(struct drm_device *, unsigned int);
 int    tegra_drm_framebuffer_init(struct drm_device *,
            struct tegra_framebuffer *);
 
diff -r 54b98d340314 -r b5cb13443e99 sys/arch/arm/nvidia/tegra_drm_mode.c
--- a/sys/arch/arm/nvidia/tegra_drm_mode.c      Mon Aug 27 15:31:27 2018 +0000
+++ b/sys/arch/arm/nvidia/tegra_drm_mode.c      Mon Aug 27 15:31:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_drm_mode.c,v 1.16 2017/12/26 14:54:52 jmcneill Exp $ */
+/* $NetBSD: tegra_drm_mode.c,v 1.17 2018/08/27 15:31:51 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,12 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_drm_mode.c,v 1.16 2017/12/26 14:54:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_drm_mode.c,v 1.17 2018/08/27 15:31:51 riastradh Exp $");
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_plane_helper.h>
 
 #include <dev/i2c/ddcvar.h>
 
@@ -46,6 +47,8 @@
 
 #include <dev/fdt/fdtvar.h>
 
+#include <external/bsd/drm2/dist/drm/drm_internal.h>
+
 static struct drm_framebuffer *tegra_fb_create(struct drm_device *,
                    struct drm_file *, struct drm_mode_fb_cmd2 *);
 
@@ -1321,7 +1324,7 @@
 }
 
 u32
-tegra_drm_get_vblank_counter(struct drm_device *ddev, int crtc)
+tegra_drm_get_vblank_counter(struct drm_device *ddev, unsigned int crtc)
 {
        struct tegra_drm_softc * const sc = tegra_drm_private(ddev);
 
@@ -1332,7 +1335,7 @@
 }
 
 int
-tegra_drm_enable_vblank(struct drm_device *ddev, int crtc)
+tegra_drm_enable_vblank(struct drm_device *ddev, unsigned int crtc)
 {
        struct tegra_crtc *tegra_crtc = NULL;
        struct drm_crtc *iter;
@@ -1352,7 +1355,7 @@
 }
 
 void
-tegra_drm_disable_vblank(struct drm_device *ddev, int crtc)
+tegra_drm_disable_vblank(struct drm_device *ddev, unsigned int crtc)
 {
        struct tegra_crtc *tegra_crtc = NULL;
        struct drm_crtc *iter;
diff -r 54b98d340314 -r b5cb13443e99 sys/arch/arm/nvidia/tegra_nouveau.c
--- a/sys/arch/arm/nvidia/tegra_nouveau.c       Mon Aug 27 15:31:27 2018 +0000
+++ b/sys/arch/arm/nvidia/tegra_nouveau.c       Mon Aug 27 15:31:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_nouveau.c,v 1.10 2017/05/30 22:00:25 jmcneill Exp $ */
+/* $NetBSD: tegra_nouveau.c,v 1.11 2018/08/27 15:31:51 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_nouveau.c,v 1.10 2017/05/30 22:00:25 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_nouveau.c,v 1.11 2018/08/27 15:31:51 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -45,11 +45,15 @@
 #include <dev/fdt/fdtvar.h>
 
 #include <drm/drmP.h>
-#include <engine/device.h>
+#include <core/tegra.h>
+#include <nvkm/engine/device/priv.h>
+#include <nvkm/subdev/mc/priv.h>
 
 extern char *nouveau_config;
 extern char *nouveau_debug;
-extern struct drm_driver *const nouveau_drm_driver;
+extern struct drm_driver *const nouveau_drm_driver_stub;     /* XXX */
+extern struct drm_driver *const nouveau_drm_driver_platform; /* XXX */
+static bool nouveau_driver_initialized = false;                     /* XXX */
 
 static int     tegra_nouveau_match(device_t, cfdata_t, void *);
 static void    tegra_nouveau_attach(device_t, device_t, void *);
@@ -57,48 +61,67 @@
 struct tegra_nouveau_softc {
        device_t                sc_dev;
        bus_space_tag_t         sc_bst;
+       struct {
+               bus_addr_t              addr;
+               bus_size_t              size;
+       }                       sc_resources[2];
        bus_dma_tag_t           sc_dmat;
        int                     sc_phandle;
+       void                    *sc_ih;
        struct clk              *sc_clk_gpu;
        struct clk              *sc_clk_pwr;
        struct fdtbus_reset     *sc_rst_gpu;
        struct drm_device       *sc_drm_dev;
-       struct platform_device  sc_platform_dev;
-       struct nouveau_device   *sc_nv_dev;
+       struct nvkm_device      sc_nv_dev;
 };
 
 static void    tegra_nouveau_init(device_t);
 
-static int     tegra_nouveau_get_irq(struct drm_device *);
-static const char *tegra_nouveau_get_name(struct drm_device *);
 static int     tegra_nouveau_set_busid(struct drm_device *,
                                        struct drm_master *);
-static int     tegra_nouveau_irq_install(struct drm_device *,
-                                         irqreturn_t (*)(void *),
-                                         int, const char *, void *,
-                                         struct drm_bus_irq_cookie **);
-static void    tegra_nouveau_irq_uninstall(struct drm_device *,
-                                           struct drm_bus_irq_cookie *);
+
+static int     tegra_nouveau_intr(void *);
+
+static int     nvkm_device_tegra_init(struct nvkm_device *);
+static void    nvkm_device_tegra_fini(struct nvkm_device *, bool);
 
-static struct drm_bus drm_tegra_nouveau_bus = {
-       .bus_type = DRIVER_BUS_PLATFORM,
-       .get_irq = tegra_nouveau_get_irq,
-       .get_name = tegra_nouveau_get_name,
-       .set_busid = tegra_nouveau_set_busid,
-       .irq_install = tegra_nouveau_irq_install,
-       .irq_uninstall = tegra_nouveau_irq_uninstall
-};
+static bus_space_tag_t
+               nvkm_device_tegra_resource_tag(struct nvkm_device *, unsigned);
+static bus_addr_t
+               nvkm_device_tegra_resource_addr(struct nvkm_device *, unsigned);
+static bus_size_t
+               nvkm_device_tegra_resource_size(struct nvkm_device *, unsigned);
 
 CFATTACH_DECL_NEW(tegra_nouveau, sizeof(struct tegra_nouveau_softc),
        tegra_nouveau_match, tegra_nouveau_attach, NULL, NULL);
 
+static const struct nvkm_device_func nvkm_device_tegra_func = {
+       .tegra = NULL,          /* XXX */
+       .dtor = NULL,
+       .init = nvkm_device_tegra_init,
+       .fini = nvkm_device_tegra_fini,
+       .resource_tag = nvkm_device_tegra_resource_tag,
+       .resource_addr = nvkm_device_tegra_resource_addr,
+       .resource_size = nvkm_device_tegra_resource_size,
+       .cpu_coherent = false,
+};
+
+static const struct nvkm_device_tegra_func gk20a_platform_data = {
+       .iommu_bit = 34,
+};
+
+static const struct of_compat_data compat_data[] = {
+       { "nvidia,gk20a", (uintptr_t)&gk20a_platform_data },
+       { "nvidia,gm20b", (uintptr_t)&gk20a_platform_data },
+       { NULL, 0 },
+};
+
 static int
 tegra_nouveau_match(device_t parent, cfdata_t cf, void *aux)
 {
-       const char * const compatible[] = { "nvidia,gk20a", NULL };
        struct fdt_attach_args * const faa = aux;
 
-       return of_match_compatible(faa->faa_phandle, compatible);
+       return of_match_compat_data(faa->faa_phandle, compat_data);
 }
 
 static void
@@ -107,8 +130,21 @@
        struct tegra_nouveau_softc * const sc = device_private(self);
        struct fdt_attach_args * const faa = aux;
        prop_dictionary_t prop = device_properties(self);
+       const struct of_compat_data *data =
+           of_search_compatible(faa->faa_phandle, compat_data);
+       const struct nvkm_device_tegra_func *tegra_func =
+           (const void *)data->data;
        int error;
 
+       KASSERT(tegra_func != NULL);
+
+       if (!nouveau_driver_initialized) {



Home | Main Index | Thread Index | Old Index