Source-Changes-HG archive

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

[src/trunk]: src/sys Add support for Allwinner A64's display pipeline.



details:   https://anonhg.NetBSD.org/src/rev/44e7f8dc275c
branches:  trunk
changeset: 448316:44e7f8dc275c
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Jan 30 01:24:00 2019 +0000

description:
Add support for Allwinner A64's display pipeline.

diffstat:

 sys/arch/arm/sunxi/files.sunxi            |   32 +-
 sys/arch/arm/sunxi/sun50i_a64_ccu.c       |   64 +++-
 sys/arch/arm/sunxi/sunxi_ccu.h            |    3 +-
 sys/arch/arm/sunxi/sunxi_ccu_fractional.c |    7 +-
 sys/arch/arm/sunxi/sunxi_drm.c            |  407 ++++++++++++++++++++++++
 sys/arch/arm/sunxi/sunxi_drm.h            |   88 +++++
 sys/arch/arm/sunxi/sunxi_dwhdmi.c         |  258 +++++++++++++++
 sys/arch/arm/sunxi/sunxi_fb.c             |  163 +++++++++
 sys/arch/arm/sunxi/sunxi_hdmiphy.c        |  501 ++++++++++++++++++++++++++++++
 sys/arch/arm/sunxi/sunxi_hdmiphy.h        |   38 ++
 sys/arch/arm/sunxi/sunxi_lcdc.c           |  317 ++++++++++++++++++
 sys/arch/arm/sunxi/sunxi_mixer.c          |  387 +++++++++++++++++++++++
 sys/dev/fdt/fdt_i2c.c                     |   16 +-
 sys/dev/fdt/fdt_phy.c                     |   10 +-
 sys/dev/fdt/fdt_port.c                    |   41 ++-
 sys/dev/fdt/fdt_port.h                    |   19 +-
 sys/dev/fdt/fdtvar.h                      |    4 +-
 sys/dev/fdt/files.fdt                     |    6 +-
 sys/dev/fdt/hdmi_connector.c              |  237 ++++++++++++++
 19 files changed, 2581 insertions(+), 17 deletions(-)

diffs (truncated from 2914 to 300 lines):

diff -r dbb565f9edc2 -r 44e7f8dc275c sys/arch/arm/sunxi/files.sunxi
--- a/sys/arch/arm/sunxi/files.sunxi    Wed Jan 30 01:20:47 2019 +0000
+++ b/sys/arch/arm/sunxi/files.sunxi    Wed Jan 30 01:24:00 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sunxi,v 1.60 2019/01/22 20:17:36 jmcneill Exp $
+#      $NetBSD: files.sunxi,v 1.61 2019/01/30 01:24:00 jmcneill Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -307,6 +307,36 @@
 attach sunxide2ccu at fdt with sunxi_de2ccu
 file   arch/arm/sunxi/sunxi_de2_ccu.c          sunxi_de2ccu
 
+# DE2 mixer
+device sunximixer: drmkms
+attach sunximixer at fdt with sunxi_mixer
+file   arch/arm/sunxi/sunxi_mixer.c            sunxi_mixer
+
+# DE2 timing controller
+device sunxilcdc: drmkms
+attach sunxilcdc at fdt with sunxi_lcdc
+file   arch/arm/sunxi/sunxi_lcdc.c             sunxi_lcdc
+
+# Display Pipeline
+define sunxifbbus { }
+device sunxidrm: drmkms, ddc_read_edid, sunxifbbus
+attach sunxidrm at fdt with sunxi_drm
+file   arch/arm/sunxi/sunxi_drm.c              sunxi_drm
+
+# DRM framebuffer console
+device sunxifb: sunxifbbus, drmfb, wsemuldisplaydev
+attach sunxifb at sunxifbbus with sunxi_fb
+file   arch/arm/sunxi/sunxi_fb.c               sunxi_fb
+
+# Allwinner HDMI (Designware based)
+attach dwhdmi at fdt with sunxi_dwhdmi
+file   arch/arm/sunxi/sunxi_dwhdmi.c           sunxi_dwhdmi
+
+# Allwinner HDMI TX PHY
+device sunxihdmiphy: drmkms
+attach sunxihdmiphy at fdt with sunxi_hdmiphy
+file   arch/arm/sunxi/sunxi_hdmiphy.c          sunxi_hdmiphy | sunxi_dwhdmi
+
 # SOC parameters
 defflag        opt_soc.h                       SOC_SUNXI
 defflag        opt_soc.h                       SOC_SUNXI_MC
diff -r dbb565f9edc2 -r 44e7f8dc275c sys/arch/arm/sunxi/sun50i_a64_ccu.c
--- a/sys/arch/arm/sunxi/sun50i_a64_ccu.c       Wed Jan 30 01:20:47 2019 +0000
+++ b/sys/arch/arm/sunxi/sun50i_a64_ccu.c       Wed Jan 30 01:24:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.10 2019/01/22 23:06:49 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.11 2019/01/30 01:24:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.10 2019/01/22 23:06:49 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.11 2019/01/30 01:24:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -42,8 +42,10 @@
 
 #define        PLL_CPUX_CTRL_REG       0x000
 #define        PLL_AUDIO_CTRL_REG      0x008
+#define        PLL_VIDEO0_CTRL_REG     0x010
 #define        PLL_PERIPH0_CTRL_REG    0x028
 #define        PLL_PERIPH1_CTRL_REG    0x02c
+#define        PLL_VIDEO1_CTRL_REG     0x030
 #define        PLL_DE_CTRL_REG         0x048
 #define        AHB1_APB1_CFG_REG       0x054
 #define        APB2_CFG_REG            0x058
@@ -61,7 +63,10 @@
 #define        DRAM_CFG_REG            0x0f4
 #define        MBUS_RST_REG            0x0fc
 #define        DE_CLK_REG              0x104
+#define        TCON1_CLK_REG           0x11c
 #define        AC_DIG_CLK_REG          0x140
+#define        HDMI_CLK_REG            0x150
+#define        HDMI_SLOW_CLK_REG       0x154
 #define        BUS_SOFT_RST_REG0       0x2c0
 #define        BUS_SOFT_RST_REG1       0x2c4
 #define        BUS_SOFT_RST_REG2       0x2c8
@@ -146,6 +151,8 @@
 static const char *mmc_parents[] = { "hosc", "pll_periph0_2x", "pll_periph1_2x" };
 static const char *ths_parents[] = { "hosc", NULL, NULL, NULL };
 static const char *de_parents[] = { "pll_periph0_2x", "pll_de" };
+static const char *hdmi_parents[] = { "pll_video0", "pll_video1" };
+static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL };
 
 static const struct sunxi_ccu_nkmp_tbl sun50i_a64_cpux_table[] = {
        { 60000000, 9, 0, 0, 2 },
@@ -262,8 +269,36 @@
        SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_AUDIO_4X, "pll_audio_4x", "pll_audio_base", 1, 4),
        SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_AUDIO_8X, "pll_audio_8x", "pll_audio_base", 1, 8),
 
+       SUNXI_CCU_FRACTIONAL(A64_CLK_PLL_VIDEO0, "pll_video0", "hosc",
+           PLL_VIDEO0_CTRL_REG,        /* reg */
+           __BITS(14,8),               /* m */
+           16,                         /* m_min */
+           50,                         /* m_max */
+           __BIT(24),                  /* div_en */
+           __BIT(25),                  /* frac_sel */
+           270000000, 297000000,       /* frac values */
+           __BITS(3,0),                /* prediv */
+           4,                          /* prediv_val */
+           __BIT(31),                  /* enable */
+           SUNXI_CCU_FRACTIONAL_PLUSONE | SUNXI_CCU_FRACTIONAL_SET_ENABLE),
+
+       SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_VIDEO0_2X, "pll_video0_2x", "pll_video0", 1, 2),
+
+       SUNXI_CCU_FRACTIONAL(A64_CLK_PLL_VIDEO1, "pll_video1", "hosc",
+           PLL_VIDEO1_CTRL_REG,        /* reg */
+           __BITS(14,8),               /* m */
+           16,                         /* m_min */
+           50,                         /* m_max */
+           __BIT(24),                  /* div_en */
+           __BIT(25),                  /* frac_sel */
+           270000000, 297000000,       /* frac values */
+           __BITS(3,0),                /* prediv */
+           4,                          /* prediv_val */
+           __BIT(31),                  /* enable */
+           SUNXI_CCU_FRACTIONAL_PLUSONE | SUNXI_CCU_FRACTIONAL_SET_ENABLE),
+
        SUNXI_CCU_FRACTIONAL(A64_CLK_PLL_DE, "pll_de", "hosc",
-           DE_CLK_REG,                 /* reg */
+           PLL_DE_CTRL_REG,            /* reg */
            __BITS(14,8),               /* m */
            16,                         /* m_min */
            50,                         /* m_max */
@@ -273,7 +308,7 @@
            __BITS(3,0),                /* prediv */
            2,                          /* prediv_val */
            __BIT(31),                  /* enable */
-           SUNXI_CCU_FRACTIONAL_PLUSONE),
+           SUNXI_CCU_FRACTIONAL_PLUSONE | SUNXI_CCU_FRACTIONAL_SET_ENABLE),
 
        SUNXI_CCU_PREDIV(A64_CLK_AHB1, "ahb1", ahb1_parents,
            AHB1_APB1_CFG_REG,  /* reg */
@@ -346,6 +381,23 @@
        SUNXI_CCU_GATE(A64_CLK_AC_DIG_4X, "ac-dig-4x", "pll_audio_4x",
            AC_DIG_CLK_REG, 30),
 
+       SUNXI_CCU_DIV_GATE(A64_CLK_HDMI, "hdmi", hdmi_parents,
+           HDMI_CLK_REG,       /* reg */
+           __BITS(3,0),        /* div */
+           __BITS(25,24),      /* sel */
+           __BIT(31),          /* enable */
+          0),
+
+       SUNXI_CCU_GATE(A64_CLK_HDMI_DDC, "hdmi-ddc", "hosc",
+           HDMI_SLOW_CLK_REG, 31),
+
+       SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents,
+           TCON1_CLK_REG,      /* reg */
+           __BITS(3,0),        /* div */
+           __BITS(25,24),      /* sel */
+           __BIT(31),          /* enable */
+           0),
+
        SUNXI_CCU_GATE(A64_CLK_BUS_MIPI_DSI, "bus-mipi-dsi", "ahb1",
            BUS_CLK_GATING_REG0, 1),
        SUNXI_CCU_GATE(A64_CLK_BUS_CE, "bus-ce", "ahb1",
@@ -482,5 +534,9 @@
        aprint_naive("\n");
        aprint_normal(": A64 CCU\n");
 
+       /* Set DE parent to PLL_DE */
+       clk_set_parent(&sc->sc_clks[A64_CLK_DE].base, &sc->sc_clks[A64_CLK_PLL_DE].base);
+       clk_set_rate(&sc->sc_clks[A64_CLK_PLL_DE].base, 420000000);
+
        sunxi_ccu_print(sc);
 }
diff -r dbb565f9edc2 -r 44e7f8dc275c sys/arch/arm/sunxi/sunxi_ccu.h
--- a/sys/arch/arm/sunxi/sunxi_ccu.h    Wed Jan 30 01:20:47 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu.h    Wed Jan 30 01:24:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.20 2019/01/22 23:06:49 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.21 2019/01/30 01:24:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -373,6 +373,7 @@
        uint32_t        enable;
        uint32_t        flags;
 #define        SUNXI_CCU_FRACTIONAL_PLUSONE    __BIT(0)
+#define        SUNXI_CCU_FRACTIONAL_SET_ENABLE __BIT(1)
 };
 
 int    sunxi_ccu_fractional_enable(struct sunxi_ccu_softc *,
diff -r dbb565f9edc2 -r 44e7f8dc275c sys/arch/arm/sunxi/sunxi_ccu_fractional.c
--- a/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Wed Jan 30 01:20:47 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Wed Jan 30 01:24:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_fractional.c,v 1.3 2019/01/22 23:06:49 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.3 2019/01/22 23:06:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -169,8 +169,11 @@
 
        val &= ~fractional->m;
        val |= __SHIFTIN(best_m, fractional->m);
+       if (fractional->flags & SUNXI_CCU_FRACTIONAL_SET_ENABLE)
+               val |= fractional->enable;
        CCU_WRITE(sc, fractional->reg, val);
 
+
        return 0;
 }
 
diff -r dbb565f9edc2 -r 44e7f8dc275c sys/arch/arm/sunxi/sunxi_drm.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/sunxi/sunxi_drm.c    Wed Jan 30 01:24:00 2019 +0000
@@ -0,0 +1,407 @@
+/* $NetBSD: sunxi_drm.c,v 1.1 2019/01/30 01:24:00 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.1 2019/01/30 01:24:00 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+
+#include <uvm/uvm_extern.h>
+#include <uvm/uvm_object.h>
+#include <uvm/uvm_device.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+
+#include <dev/fdt/fdtvar.h>
+#include <dev/fdt/fdt_port.h>
+
+#include <arm/sunxi/sunxi_drm.h>
+
+static TAILQ_HEAD(, sunxi_drm_endpoint) sunxi_drm_endpoints =
+    TAILQ_HEAD_INITIALIZER(sunxi_drm_endpoints);
+
+static const char * const compatible[] = {
+       "allwinner,sun50i-a64-display-engine",
+       NULL
+};
+
+static const char * fb_compatible[] = {
+       "allwinner,simple-framebuffer",
+       NULL
+};
+
+static int     sunxi_drm_match(device_t, cfdata_t, void *);
+static void    sunxi_drm_attach(device_t, device_t, void *);
+
+static void    sunxi_drm_init(device_t);
+
+static int     sunxi_drm_set_busid(struct drm_device *, struct drm_master *);
+
+static int     sunxi_drm_load(struct drm_device *, unsigned long);



Home | Main Index | Thread Index | Old Index