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 Use syscon API.
details: https://anonhg.NetBSD.org/src/rev/1bcde900fa00
branches: trunk
changeset: 324366:1bcde900fa00
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Jun 30 17:54:07 2018 +0000
description:
Use syscon API.
diffstat:
sys/arch/arm/rockchip/rk_cru.c | 20 +++++---------------
sys/arch/arm/rockchip/rk_cru.h | 12 ++++--------
sys/arch/arm/rockchip/rk_cru_mux.c | 26 +++++++++++++++++---------
sys/arch/arm/rockchip/rk_cru_pll.c | 9 ++++++---
4 files changed, 32 insertions(+), 35 deletions(-)
diffs (171 lines):
diff -r f4c412ae625c -r 1bcde900fa00 sys/arch/arm/rockchip/rk_cru.c
--- a/sys/arch/arm/rockchip/rk_cru.c Sat Jun 30 17:30:37 2018 +0000
+++ b/sys/arch/arm/rockchip/rk_cru.c Sat Jun 30 17:54:07 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru.c,v 1.3 2018/06/26 17:44:04 jmcneill Exp $ */
+/* $NetBSD: rk_cru.c,v 1.4 2018/06/30 17:54:07 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
#include "opt_fdt_arm.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk_cru.c,v 1.3 2018/06/26 17:44:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru.c,v 1.4 2018/06/30 17:54:07 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -300,19 +300,9 @@
int i;
if (of_hasprop(sc->sc_phandle, "rockchip,grf")) {
- const int grf_phandle = fdtbus_get_phandle(sc->sc_phandle, "rockchip,grf");
- if (grf_phandle == -1) {
- aprint_error(": couldn't get grf phandle\n");
- return ENXIO;
- }
-
- if (fdtbus_get_reg(grf_phandle, 0, &addr, &size) != 0) {
- aprint_error(": couldn't get grf registers\n");
- return ENXIO;
- }
-
- if (bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh_grf) != 0) {
- aprint_error(": couldn't map registers\n");
+ sc->sc_grf = fdtbus_syscon_acquire(sc->sc_phandle, "rockchip,grf");
+ if (sc->sc_grf == NULL) {
+ aprint_error(": couldn't get grf syscon\n");
return ENXIO;
}
}
diff -r f4c412ae625c -r 1bcde900fa00 sys/arch/arm/rockchip/rk_cru.h
--- a/sys/arch/arm/rockchip/rk_cru.h Sat Jun 30 17:30:37 2018 +0000
+++ b/sys/arch/arm/rockchip/rk_cru.h Sat Jun 30 17:54:07 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru.h,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_cru.h,v 1.2 2018/06/30 17:54:07 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,6 +30,7 @@
#define _ARM_RK_CRU_H
#include <dev/clk/clk_backend.h>
+#include <dev/fdt/syscon.h>
struct rk_cru_softc;
struct rk_cru_clk;
@@ -293,7 +294,7 @@
int sc_phandle;
bus_space_tag_t sc_bst;
bus_space_handle_t sc_bsh;
- bus_space_handle_t sc_bsh_grf;
+ struct syscon *sc_grf;
struct clk_domain sc_clkdom;
@@ -311,11 +312,6 @@
#define CRU_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
-#define GRF_READ(sc, reg) \
- bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh_grf, (reg))
-#define GRF_WRITE(sc, reg, val) \
- bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh_grf, (reg), (val))
-
-#define HAS_GRF(sc) ((sc)->sc_bsh_grf != 0)
+#define HAS_GRF(sc) ((sc)->sc_grf != NULL)
#endif /* _ARM_RK_CRU_H */
diff -r f4c412ae625c -r 1bcde900fa00 sys/arch/arm/rockchip/rk_cru_mux.c
--- a/sys/arch/arm/rockchip/rk_cru_mux.c Sat Jun 30 17:30:37 2018 +0000
+++ b/sys/arch/arm/rockchip/rk_cru_mux.c Sat Jun 30 17:54:07 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru_mux.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_cru_mux.c,v 1.2 2018/06/30 17:54:07 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk_cru_mux.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru_mux.c,v 1.2 2018/06/30 17:54:07 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -42,13 +42,19 @@
{
struct rk_cru_mux *mux = &clk->u.mux;
const bool mux_grf = (mux->flags & RK_MUX_GRF) != 0;
+ uint32_t val;
KASSERT(clk->type == RK_CRU_MUX);
- if (mux_grf && !HAS_GRF(sc))
- return NULL;
-
- const uint32_t val = mux_grf ? GRF_READ(sc, mux->reg) : CRU_READ(sc, mux->reg);
+ if (mux_grf) {
+ if (!HAS_GRF(sc))
+ return NULL;
+ syscon_lock(sc->sc_grf);
+ val = syscon_read_4(sc->sc_grf, mux->reg);
+ syscon_unlock(sc->sc_grf);
+ } else {
+ val = CRU_READ(sc, mux->reg);
+ }
const u_int index = __SHIFTOUT(val, mux->mask);
return mux->parents[index];
@@ -71,9 +77,11 @@
const uint32_t write_mask = mux->mask << 16;
const uint32_t write_val = __SHIFTIN(index, mux->mask);
- if (mux_grf)
- GRF_WRITE(sc, mux->reg, write_mask | write_val);
- else
+ if (mux_grf) {
+ syscon_lock(sc->sc_grf);
+ syscon_write_4(sc->sc_grf, mux->reg, write_mask | write_val);
+ syscon_unlock(sc->sc_grf);
+ } else
CRU_WRITE(sc, mux->reg, write_mask | write_val);
return 0;
diff -r f4c412ae625c -r 1bcde900fa00 sys/arch/arm/rockchip/rk_cru_pll.c
--- a/sys/arch/arm/rockchip/rk_cru_pll.c Sat Jun 30 17:30:37 2018 +0000
+++ b/sys/arch/arm/rockchip/rk_cru_pll.c Sat Jun 30 17:54:07 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru_pll.c,v 1.2 2018/06/16 13:24:04 jmcneill Exp $ */
+/* $NetBSD: rk_cru_pll.c,v 1.3 2018/06/30 17:54:07 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk_cru_pll.c,v 1.2 2018/06/16 13:24:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru_pll.c,v 1.3 2018/06/30 17:54:07 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -146,11 +146,14 @@
const uint32_t write_val = pll->mode_mask;
CRU_WRITE(sc, pll->mode_reg, write_mask | write_val);
+ syscon_lock(sc->sc_grf);
for (retry = 1000; retry > 0; retry--) {
- if (GRF_READ(sc, GRF_SOC_STATUS0) & pll->lock_mask)
+ if (syscon_read_4(sc->sc_grf, GRF_SOC_STATUS0) & pll->lock_mask)
break;
delay(1);
}
+ syscon_unlock(sc->sc_grf);
+
if (retry == 0)
device_printf(sc->sc_dev, "WARNING: %s failed to lock\n",
clk->base.name);
Home |
Main Index |
Thread Index |
Old Index