Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/rockchip Make .reg1 and .reg2 of struct rk_cru_...



details:   https://anonhg.NetBSD.org/src/rev/62ce3331f77f
branches:  trunk
changeset: 369603:62ce3331f77f
user:      ryo <ryo%NetBSD.org@localhost>
date:      Tue Aug 23 05:32:18 2022 +0000

description:
Make .reg1 and .reg2 of struct rk_cru_cpu_rate into array, and change the type of those to bus_size_t and uint32_t.
Array size may increase in the future.

diffstat:

 sys/arch/arm/rockchip/rk3399_cru.c |  15 +++++++++++----
 sys/arch/arm/rockchip/rk_cru.h     |  20 +++++++++-----------
 sys/arch/arm/rockchip/rk_cru_arm.c |  16 +++++++---------
 3 files changed, 27 insertions(+), 24 deletions(-)

diffs (116 lines):

diff -r 3d7f2a6a5631 -r 62ce3331f77f sys/arch/arm/rockchip/rk3399_cru.c
--- a/sys/arch/arm/rockchip/rk3399_cru.c        Tue Aug 23 05:31:12 2022 +0000
+++ b/sys/arch/arm/rockchip/rk3399_cru.c        Tue Aug 23 05:32:18 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.23 2021/11/12 22:02:08 jmcneill Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.24 2022/08/23 05:32:18 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.23 2021/11/12 22:02:08 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.24 2022/08/23 05:32:18 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -143,15 +143,22 @@
 #define        RK3399_ATCLK_MASK       __BITS(4,0)
 #define        RK3399_PDBG_MASK        __BITS(12,8)
 
+#define RK3399_CPU_RATE(_rate, _reg0, _reg0_mask, _reg0_val, _reg1, _reg1_mask, _reg1_val)\
+       {                                                                               \
+               .rate = (_rate),                                                        \
+               .divs[0] = { .reg = (_reg0), .mask = (_reg0_mask), .val = (_reg0_val) },\
+               .divs[1] = { .reg = (_reg1), .mask = (_reg1_mask), .val = (_reg1_val) },\
+       }
+
 #define        RK3399_CPUL_RATE(_rate, _aclkm, _atclk, _pdbg)                  \
-       RK_CPU_RATE(_rate,                                              \
+       RK3399_CPU_RATE(_rate,                                          \
                    CLKSEL_CON(0), RK3399_ACLKM_MASK,                   \
                    __SHIFTIN((_aclkm), RK3399_ACLKM_MASK),             \
                    CLKSEL_CON(1), RK3399_ATCLK_MASK|RK3399_PDBG_MASK,  \
                    __SHIFTIN((_atclk), RK3399_ATCLK_MASK)|__SHIFTIN((_pdbg), RK3399_PDBG_MASK))
 
 #define        RK3399_CPUB_RATE(_rate, _aclkm, _atclk, _pdbg)                  \
-       RK_CPU_RATE(_rate,                                              \
+       RK3399_CPU_RATE(_rate,                                          \
                    CLKSEL_CON(2), RK3399_ACLKM_MASK,                   \
                    __SHIFTIN((_aclkm), RK3399_ACLKM_MASK),             \
                    CLKSEL_CON(3), RK3399_ATCLK_MASK|RK3399_PDBG_MASK,  \
diff -r 3d7f2a6a5631 -r 62ce3331f77f sys/arch/arm/rockchip/rk_cru.h
--- a/sys/arch/arm/rockchip/rk_cru.h    Tue Aug 23 05:31:12 2022 +0000
+++ b/sys/arch/arm/rockchip/rk_cru.h    Tue Aug 23 05:32:18 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru.h,v 1.8 2021/11/12 22:02:08 jmcneill Exp $ */
+/* $NetBSD: rk_cru.h,v 1.9 2022/08/23 05:32:18 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -141,18 +141,16 @@
                .div = (_div),                                  \
        }
 
-struct rk_cru_cpu_rate {
-       u_int           rate;
-       u_int           reg1, reg1_mask, reg1_val;
-       u_int           reg2, reg2_mask, reg2_val;
+struct rk_regmaskval {
+       bus_size_t      reg;
+       uint32_t        mask;
+       uint32_t        val;
 };
 
-#define        RK_CPU_RATE(_rate, _reg1, _reg1_mask, _reg1_val, _reg2, _reg2_mask, _reg2_val)  \
-       {                                                                               \
-               .rate = (_rate),                                                        \
-               .reg1 = (_reg1), .reg1_mask = (_reg1_mask), .reg1_val = (_reg1_val),    \
-               .reg2 = (_reg2), .reg2_mask = (_reg2_mask), .reg2_val = (_reg2_val),    \
-       }
+struct rk_cru_cpu_rate {
+       u_int                   rate;
+       struct rk_regmaskval    divs[2];
+};
 
 struct rk_cru_arm {
        bus_size_t      reg;
diff -r 3d7f2a6a5631 -r 62ce3331f77f sys/arch/arm/rockchip/rk_cru_arm.c
--- a/sys/arch/arm/rockchip/rk_cru_arm.c        Tue Aug 23 05:31:12 2022 +0000
+++ b/sys/arch/arm/rockchip/rk_cru_arm.c        Tue Aug 23 05:32:18 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru_arm.c,v 1.2 2018/09/01 19:35:53 jmcneill Exp $ */
+/* $NetBSD: rk_cru_arm.c,v 1.3 2022/08/23 05:32:18 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk_cru_arm.c,v 1.2 2018/09/01 19:35:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru_arm.c,v 1.3 2022/08/23 05:32:18 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -147,13 +147,11 @@
        if (error != 0)
                goto done;
 
-       write_mask = cpu_rate->reg1_mask << 16;
-       write_val = cpu_rate->reg1_val;
-       CRU_WRITE(sc, cpu_rate->reg1, write_mask | write_val);
-
-       write_mask = cpu_rate->reg2_mask << 16;
-       write_val = cpu_rate->reg2_val;
-       CRU_WRITE(sc, cpu_rate->reg2, write_mask | write_val);
+       for (int i = 0; i < __arraycount(cpu_rate->divs); i++) {
+               write_mask = cpu_rate->divs[i].mask << 16;
+               write_val = cpu_rate->divs[i].val;
+               CRU_WRITE(sc, cpu_rate->divs[i].reg, write_mask | write_val);
+       }
 
        write_mask = arm->div_mask << 16;
        write_val = __SHIFTIN(0, arm->div_mask);



Home | Main Index | Thread Index | Old Index