Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/arm Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/bf484051020e
branches:  netbsd-9
changeset: 843521:bf484051020e
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Nov 18 19:31:00 2019 +0000

description:
Pull up following revision(s) (requested by jmcneill in ticket #437):

        sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts: revision 1.2
        sys/arch/arm/sunxi/sunxi_ccu_div.c: revision 1.6
        sys/arch/arm/dts/sun50i-a64.dtsi: revision 1.13
        sys/arch/arm/dts/sun50i-a64-pine64.dts: revision 1.2
        sys/arch/arm/sunxi/sunxi_dwhdmi.c: revision 1.4
        sys/arch/arm/dts/sun50i-a64-pine64-plus.dts: revision 1.3
        sys/arch/arm/sunxi/sunxi_i2s.c: revision 1.7
        sys/arch/arm/sunxi/sun50i_a64_ccu.c: revision 1.14

Add support for A64 I2S clocks.
Add A64 HDMI audio support.
Enable HDMI audio support on Pine64, Pine64+, and Pine64 LTS boards.

diffstat:

 sys/arch/arm/dts/sun50i-a64-pine64-plus.dts      |   10 +-
 sys/arch/arm/dts/sun50i-a64-pine64.dts           |   10 +-
 sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts |   10 +-
 sys/arch/arm/dts/sun50i-a64.dtsi                 |   32 +-
 sys/arch/arm/sunxi/sun50i_a64_ccu.c              |   28 +-
 sys/arch/arm/sunxi/sunxi_ccu_div.c               |   38 ++-
 sys/arch/arm/sunxi/sunxi_dwhdmi.c                |   21 +-
 sys/arch/arm/sunxi/sunxi_i2s.c                   |  375 +++++++++++++++++-----
 8 files changed, 431 insertions(+), 93 deletions(-)

diffs (truncated from 887 to 300 lines):

diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/dts/sun50i-a64-pine64-plus.dts
--- a/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts       Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts       Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64-pine64-plus.dts,v 1.2 2017/09/09 12:05:28 jmcneill Exp $ */
+/* $NetBSD: sun50i-a64-pine64-plus.dts,v 1.2.10.1 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -49,3 +49,11 @@
 &ohci0 {
        status = "okay";
 };
+
+&i2s2 {
+       status = "okay";
+};
+
+&sound_hdmi {
+       status = "okay";
+};
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/dts/sun50i-a64-pine64.dts
--- a/sys/arch/arm/dts/sun50i-a64-pine64.dts    Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/dts/sun50i-a64-pine64.dts    Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64-pine64.dts,v 1.1 2018/02/18 12:20:25 jmcneill Exp $ */
+/* $NetBSD: sun50i-a64-pine64.dts,v 1.1.8.1 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,3 +28,11 @@
 
 #include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts"
 #include "sun50i-a64.dtsi"
+
+&i2s2 {
+       status = "okay";
+};
+
+&sound_hdmi {
+       status = "okay";
+};
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts
--- a/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts  Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts  Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64-sopine-baseboard.dts,v 1.1 2018/06/07 00:51:41 jmcneill Exp $ */
+/* $NetBSD: sun50i-a64-sopine-baseboard.dts,v 1.1.8.1 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,3 +28,11 @@
 
 #include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts"
 #include "sun50i-a64.dtsi"
+
+&i2s2 {
+       status = "okay";
+};
+
+&sound_hdmi {
+       status = "okay";
+};
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/dts/sun50i-a64.dtsi
--- a/sys/arch/arm/dts/sun50i-a64.dtsi  Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/dts/sun50i-a64.dtsi  Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64.dtsi,v 1.11.2.1 2019/11/10 13:14:41 martin Exp $ */
+/* $NetBSD: sun50i-a64.dtsi,v 1.11.2.2 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -59,6 +59,36 @@
                             <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
        };
+
+       i2s2: i2s@1c22800 {
+               #sound-dai-cells = <0>;
+               compatible = "allwinner,sun50i-a64-i2s",
+                            "allwinner,sun8i-h3-i2s";
+               reg = <0x01c22800 0x400>;
+               interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&ccu CLK_BUS_I2S2>, <&ccu CLK_I2S2>;
+               clock-names = "apb", "mod";
+               resets = <&ccu RST_BUS_I2S2>;
+               dma-names = "tx";
+               dmas = <&dma 27>;
+               status = "disabled";
+       };
+
+       sound_hdmi: sound-hdmi {
+               compatible = "simple-audio-card";
+               simple-audio-card,name = "hdmi-audio";
+               simple-audio-card,format = "i2s";
+               simple-audio-card,mclk-fs = <256>;
+               status = "disabled";
+
+               simple-audio-card,cpu {
+                       sound-dai = <&i2s2>;
+               };
+
+               simple-audio-card,codec {
+                       sound-dai = <&hdmi>;
+               };
+       };
 };
 
 &cpu0 {
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/sunxi/sun50i_a64_ccu.c
--- a/sys/arch/arm/sunxi/sun50i_a64_ccu.c       Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/sunxi/sun50i_a64_ccu.c       Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.13 2019/07/01 21:06:47 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.13.2.1 2019/11/18 19:31:00 martin 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.13 2019/07/01 21:06:47 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.13.2.1 2019/11/18 19:31:00 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -60,6 +60,9 @@
 #define        SDMMC0_CLK_REG          0x088
 #define        SDMMC1_CLK_REG          0x08c
 #define        SDMMC2_CLK_REG          0x090
+#define        I2SPCM0_CLK_REG         0x0b0
+#define        I2SPCM1_CLK_REG         0x0b4
+#define        I2SPCM2_CLK_REG         0x0b8
 #define        USBPHY_CFG_REG          0x0cc
 #define        DRAM_CFG_REG            0x0f4
 #define        MBUS_RST_REG            0x0fc
@@ -154,6 +157,7 @@
 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 *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" };
 static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL };
 static const char *gpu_parents[] = { "pll_gpu" };
 
@@ -407,6 +411,26 @@
        SUNXI_CCU_GATE(A64_CLK_HDMI_DDC, "hdmi-ddc", "hosc",
            HDMI_SLOW_CLK_REG, 31),
 
+       SUNXI_CCU_DIV_GATE(A64_CLK_I2S0, "i2s0", i2s_parents,
+           I2SPCM0_CLK_REG,    /* reg */
+           0,                  /* div */
+           __BITS(17,16),      /* sel */
+           __BIT(31),          /* enable */
+           0),
+       SUNXI_CCU_DIV_GATE(A64_CLK_I2S1, "i2s1", i2s_parents,
+           I2SPCM1_CLK_REG,    /* reg */
+           0,                  /* div */
+           __BITS(17,16),      /* sel */
+           __BIT(31),          /* enable */
+           0),
+       SUNXI_CCU_DIV_GATE(A64_CLK_I2S2, "i2s2", i2s_parents,
+           I2SPCM2_CLK_REG,    /* reg */
+           0,                  /* div */
+           __BITS(17,16),      /* sel */
+           __BIT(31),          /* enable */
+           0),
+
+
        SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents,
            TCON1_CLK_REG,      /* reg */
            __BITS(3,0),        /* div */
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/sunxi/sunxi_ccu_div.c
--- a/sys/arch/arm/sunxi/sunxi_ccu_div.c        Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu_div.c        Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_div.c,v 1.5 2018/03/19 16:19:17 bouyer Exp $ */
+/* $NetBSD: sunxi_ccu_div.c,v 1.5.6.1 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_div.c,v 1.5 2018/03/19 16:19:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_div.c,v 1.5.6.1 2019/11/18 19:31:00 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -98,6 +98,38 @@
        return rate / ratio;
 }
 
+static int
+sunxi_ccu_div_select_parent(struct sunxi_ccu_softc *sc,
+    struct sunxi_ccu_clk *clk, u_int new_rate)
+{
+       struct sunxi_ccu_div *div = &clk->u.div;
+       struct sunxi_ccu_clk *clk_parent;
+       struct clk *best_parent;
+       u_int index, best_diff;
+       const char *pname;
+
+       best_parent = NULL;
+       best_diff = ~0u;
+       for (index = 0; index < div->nparents; index++) {
+               pname = div->parents[index];
+               if (pname == NULL)
+                       continue;
+               clk_parent = sunxi_ccu_clock_find(sc, pname);
+               if (clk_parent == NULL)
+                       continue;
+               const u_int rate = clk_get_rate(&clk_parent->base);
+               const u_int diff = abs((int)rate - (int)new_rate);
+               if (diff < best_diff) {
+                       best_diff = diff;
+                       best_parent = &clk_parent->base;
+               }
+       }
+       if (best_diff == ~0u)
+               return EINVAL;
+
+       return clk_set_parent(&clk->base, best_parent);
+}
+
 int
 sunxi_ccu_div_set_rate(struct sunxi_ccu_softc *sc,
     struct sunxi_ccu_clk *clk, u_int new_rate)
@@ -119,7 +151,7 @@
                if ((div->flags & SUNXI_CCU_DIV_SET_RATE_PARENT) != 0)
                        return clk_set_rate(clkp_parent, new_rate);
                else
-                       return ENXIO;
+                       return sunxi_ccu_div_select_parent(sc, clk, new_rate);
        }
 
        val = CCU_READ(sc, div->reg);
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/sunxi/sunxi_dwhdmi.c
--- a/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_dwhdmi.c Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_dwhdmi.c,v 1.3 2019/02/02 17:35:16 jmcneill Exp $ */
+/* $NetBSD: sunxi_dwhdmi.c,v 1.3.6.1 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.3 2019/02/02 17:35:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.3.6.1 2019/11/18 19:31:00 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -197,6 +197,21 @@
        sc->sc_curmode = *adjusted_mode;
 }
 
+static audio_dai_tag_t
+sunxi_dwhdmi_dai_get_tag(device_t dev, const void *data, size_t len)
+{
+       struct sunxi_dwhdmi_softc * const sc = device_private(dev);
+
+       if (len != 4)
+               return NULL;
+
+       return &sc->sc_base.sc_dai;
+}
+
+static struct fdtbus_dai_controller_func sunxi_dwhdmi_dai_funcs = {
+       .get_tag = sunxi_dwhdmi_dai_get_tag
+};
+
 static int
 sunxi_dwhdmi_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -263,6 +278,8 @@
        sc->sc_ports.dp_ep_activate = sunxi_dwhdmi_ep_activate;
        sc->sc_ports.dp_ep_get_data = sunxi_dwhdmi_ep_get_data;
        fdt_ports_register(&sc->sc_ports, self, phandle, EP_DRM_BRIDGE);
+
+       fdtbus_register_dai_controller(self, phandle, &sunxi_dwhdmi_dai_funcs);
 }
 
 CFATTACH_DECL_NEW(sunxi_dwhdmi, sizeof(struct sunxi_dwhdmi_softc),
diff -r 5c715c93e7f7 -r bf484051020e sys/arch/arm/sunxi/sunxi_i2s.c
--- a/sys/arch/arm/sunxi/sunxi_i2s.c    Sun Nov 17 13:50:13 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_i2s.c    Mon Nov 18 19:31:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_i2s.c,v 1.6 2019/06/08 08:02:37 isaki Exp $ */
+/* $NetBSD: sunxi_i2s.c,v 1.6.2.1 2019/11/18 19:31:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>



Home | Main Index | Thread Index | Old Index