summaryrefslogtreecommitdiff
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2017-05-06 16:29:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2017-05-06 16:29:20 +0000
commitb2bfa76ccdb4a785f5ed83f61bdb96bb377642ca (patch)
treef7d48e31d86a1dc906a1d8d8b692b92b6c493c66 /sys/dev/fdt
parent03b29f50b2d8c145173ad9c91d8dd3d3a534e6cb (diff)
Add a few GMAC related clocks and implement reset logic.
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/rkclock.c24
-rw-r--r--sys/dev/fdt/rkclock_clocks.h8
2 files changed, 22 insertions, 10 deletions
diff --git a/sys/dev/fdt/rkclock.c b/sys/dev/fdt/rkclock.c
index d641cdfbe41..0b44ae9b008 100644
--- a/sys/dev/fdt/rkclock.c
+++ b/sys/dev/fdt/rkclock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rkclock.c,v 1.2 2017/05/05 13:23:52 kettenis Exp $ */
+/* $OpenBSD: rkclock.c,v 1.3 2017/05/06 16:29:19 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
@@ -31,6 +31,7 @@
/* Registers */
#define RK3399_CRU_CLKSEL_CON(i) (0x0100 + (i) * 4)
#define RK3399_CRU_CLKGATE_CON(i) (0x0300 + (i) * 4)
+#define RK3399_CRU_SOFTRST_CON(i) (0x0400 + (i) * 4)
#include "rkclock_clocks.h"
@@ -211,26 +212,26 @@ rk3399_set_frequency(void *cookie, uint32_t *cells, uint32_t freq)
void
rk3399_enable(void *cookie, uint32_t *cells, int on)
{
+ struct rkclock_softc *sc = cookie;
uint32_t idx = cells[0];
switch (idx) {
case RK3399_CLK_EMMC:
- /* Enabled by frimware! */
- break;
case RK3399_CLK_UART0:
case RK3399_CLK_UART1:
case RK3399_CLK_UART2:
case RK3399_CLK_UART3:
- /* Enabled by firmware? */
- break;
+ case RK3399_CLK_MAC_RX:
+ case RK3399_CLK_MAC_TX:
+ case RK3399_CLK_MAC:
+ case RK3399_ACLK_EMMC:
+ case RK3399_ACLK_GMAC:
+ case RK3399_PCLK_GMAC:
case RK3399_HCLK_HOST0:
case RK3399_HCLK_HOST0_ARB:
case RK3399_HCLK_HOST1:
case RK3399_HCLK_HOST1_ARB:
- /* Enabled by firmware! */
- break;
- case RK3399_ACLK_EMMC:
- /* Enabled by firmware! */
+ /* Enabled by default. */
break;
default:
printf("%s: 0x%08x\n", __func__, idx);
@@ -241,9 +242,12 @@ rk3399_enable(void *cookie, uint32_t *cells, int on)
void
rk3399_reset(void *cookie, uint32_t *cells, int on)
{
+ struct rkclock_softc *sc = cookie;
uint32_t idx = cells[0];
+ uint32_t mask = (1 << (idx % 16));
- printf("%s: 0x%08x\n", __func__, idx);
+ HWRITE4(sc, RK3399_CRU_SOFTRST_CON(idx / 16),
+ mask << 16 | (on ? mask : 0));
}
uint32_t
diff --git a/sys/dev/fdt/rkclock_clocks.h b/sys/dev/fdt/rkclock_clocks.h
index 1b83c854a3a..36bd1caacbf 100644
--- a/sys/dev/fdt/rkclock_clocks.h
+++ b/sys/dev/fdt/rkclock_clocks.h
@@ -7,8 +7,16 @@
#define RK3399_CLK_UART2 83
#define RK3399_CLK_UART3 84
+#define RK3399_CLK_MAC_RX 103
+#define RK3399_CLK_MAC_TX 104
+#define RK3399_CLK_MAC 105
+
+#define RK3399_ACLK_GMAC 213
+
#define RK3399_ACLK_EMMC 240
+#define RK3399_PCLK_GMAC 358
+
#define RK3399_HCLK_HOST0 456
#define RK3399_HCLK_HOST0_ARB 457
#define RK3399_HCLK_HOST1 458