Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/sunxi Add support for A83T eMMC.



details:   https://anonhg.NetBSD.org/src/rev/4d84732d29b4
branches:  trunk
changeset: 827441:4d84732d29b4
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Oct 28 13:13:45 2017 +0000

description:
Add support for A83T eMMC.

diffstat:

 sys/arch/arm/sunxi/sun8i_a83t_ccu.c |  20 +++++++++++++++++---
 sys/arch/arm/sunxi/sunxi_ccu.h      |   3 ++-
 sys/arch/arm/sunxi/sunxi_ccu_nm.c   |   9 +++++++--
 sys/arch/arm/sunxi/sunxi_mmc.c      |  12 ++++++++++--
 4 files changed, 36 insertions(+), 8 deletions(-)

diffs (155 lines):

diff -r 7b68b872f741 -r 4d84732d29b4 sys/arch/arm/sunxi/sun8i_a83t_ccu.c
--- a/sys/arch/arm/sunxi/sun8i_a83t_ccu.c       Sat Oct 28 12:56:27 2017 +0000
+++ b/sys/arch/arm/sunxi/sun8i_a83t_ccu.c       Sat Oct 28 13:13:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_a83t_ccu.c,v 1.3 2017/10/28 12:56:10 jmcneill Exp $ */
+/* $NetBSD: sun8i_a83t_ccu.c,v 1.4 2017/10/28 13:13:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_a83t_ccu.c,v 1.3 2017/10/28 12:56:10 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_a83t_ccu.c,v 1.4 2017/10/28 13:13:45 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -50,6 +50,7 @@
 #define        SDMMC0_CLK_REG          0x088
 #define        SDMMC1_CLK_REG          0x08c
 #define        SDMMC2_CLK_REG          0x090
+#define         SDMMC2_CLK_MODE_SELECT __BIT(30)
 #define        USBPHY_CFG_REG          0x0cc
 #define        MBUS_RST_REG            0x0fc
 #define        BUS_SOFT_RST_REG0       0x2c0
@@ -169,7 +170,7 @@
            SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
        SUNXI_CCU_NM(A83T_CLK_MMC2, "mmc2", mod_parents,
            SDMMC2_CLK_REG, __BITS(17, 16), __BITS(3,0), __BITS(25, 24), __BIT(31),
-           SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
+           SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN|SUNXI_CCU_NM_DIVIDE_BY_TWO),
 
        SUNXI_CCU_GATE(A83T_CLK_BUS_MMC0, "bus-mmc0", "ahb1",
            BUS_CLK_GATING_REG0, 8),
@@ -214,6 +215,17 @@
            USBPHY_CFG_REG, 16),
 };
 
+static void
+sun8i_a83t_ccu_init(struct sunxi_ccu_softc *sc)
+{
+       uint32_t val;
+
+       /* SDMMC2 has a mode select switch. Always use "New Mode". */
+       val = CCU_READ(sc, SDMMC2_CLK_REG);
+       val |= SDMMC2_CLK_MODE_SELECT;
+       CCU_WRITE(sc, SDMMC2_CLK_REG, val);
+}
+
 static int
 sun8i_a83t_ccu_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -244,5 +256,7 @@
        aprint_naive("\n");
        aprint_normal(": A83T CCU\n");
 
+       sun8i_a83t_ccu_init(sc);
+
        sunxi_ccu_print(sc);
 }
diff -r 7b68b872f741 -r 4d84732d29b4 sys/arch/arm/sunxi/sunxi_ccu.h
--- a/sys/arch/arm/sunxi/sunxi_ccu.h    Sat Oct 28 12:56:27 2017 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu.h    Sat Oct 28 13:13:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.14 2017/10/09 14:01:59 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.15 2017/10/28 13:13:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -161,6 +161,7 @@
        uint32_t        flags;
 #define        SUNXI_CCU_NM_POWER_OF_TWO       __BIT(0)
 #define        SUNXI_CCU_NM_ROUND_DOWN         __BIT(1)
+#define        SUNXI_CCU_NM_DIVIDE_BY_TWO      __BIT(2)
 };
 
 int    sunxi_ccu_nm_enable(struct sunxi_ccu_softc *,
diff -r 7b68b872f741 -r 4d84732d29b4 sys/arch/arm/sunxi/sunxi_ccu_nm.c
--- a/sys/arch/arm/sunxi/sunxi_ccu_nm.c Sat Oct 28 12:56:27 2017 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu_nm.c Sat Oct 28 13:13:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_nm.c,v 1.3 2017/06/29 10:53:59 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu_nm.c,v 1.4 2017/10/28 13:13:45 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_nm.c,v 1.3 2017/06/29 10:53:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_nm.c,v 1.4 2017/10/28 13:13:45 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -92,6 +92,9 @@
 
        m++;
 
+       if (nm->flags & SUNXI_CCU_NM_DIVIDE_BY_TWO)
+               m *= 2;
+
        return rate / n / m;
 }
 
@@ -142,6 +145,8 @@
                                        rate = parent_rate / (1 << n) / (m + 1);
                                else
                                        rate = parent_rate / (n + 1) / (m + 1);
+                               if (nm->flags & SUNXI_CCU_NM_DIVIDE_BY_TWO)
+                                       rate /= 2;
 
                                if (nm->flags & SUNXI_CCU_NM_ROUND_DOWN) {
                                        const int diff = new_rate - rate;
diff -r 7b68b872f741 -r 4d84732d29b4 sys/arch/arm/sunxi/sunxi_mmc.c
--- a/sys/arch/arm/sunxi/sunxi_mmc.c    Sat Oct 28 12:56:27 2017 +0000
+++ b/sys/arch/arm/sunxi/sunxi_mmc.c    Sat Oct 28 13:13:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mmc.c,v 1.15 2017/10/23 13:28:19 jmcneill Exp $ */
+/* $NetBSD: sunxi_mmc.c,v 1.16 2017/10/28 13:13:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_sunximmc.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.15 2017/10/23 13:28:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.16 2017/10/28 13:13:45 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -219,6 +219,13 @@
        .flags = 0,
 };
 
+static const struct sunxi_mmc_config sun8i_a83t_emmc_config = {
+       .idma_xferlen = 0x10000,
+       .dma_ftrglevel = 0x20070008,
+       .delays = NULL,
+       .flags = SUNXI_MMC_FLAG_NEW_TIMINGS,
+};
+
 static const struct sunxi_mmc_config sun9i_a80_mmc_config = {
        .idma_xferlen = 0x10000,
        .dma_ftrglevel = 0x200f0010,
@@ -239,6 +246,7 @@
        { "allwinner,sun4i-a10-mmc",    (uintptr_t)&sun4i_a10_mmc_config },
        { "allwinner,sun5i-a13-mmc",    (uintptr_t)&sun5i_a13_mmc_config },
        { "allwinner,sun7i-a20-mmc",    (uintptr_t)&sun7i_a20_mmc_config },
+       { "allwinner,sun8i-a83t-emmc",  (uintptr_t)&sun8i_a83t_emmc_config },
        { "allwinner,sun9i-a80-mmc",    (uintptr_t)&sun9i_a80_mmc_config },
        { "allwinner,sun50i-a64-mmc",   (uintptr_t)&sun50i_a64_mmc_config },
        { NULL }



Home | Main Index | Thread Index | Old Index