Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108594275
D34749.id104497.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D34749.id104497.diff
View Options
Index: sys/arm/allwinner/aw_wdog.c
===================================================================
--- sys/arm/allwinner/aw_wdog.c
+++ sys/arm/allwinner/aw_wdog.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@freebsd.org>
* Copyright (c) 2016 Emmanuel Vadot <manu@freebsd.org>
+ * Copyright (c) 2022 Julien Cassette <julien.cassette@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,17 +54,26 @@
#define A10_WDOG_CTRL 0x00
#define A31_WDOG_CTRL 0x10
+#define D1_WDOG_CTRL 0x10
#define WDOG_CTRL_RESTART (1 << 0)
#define A31_WDOG_CTRL_KEY (0xa57 << 1)
+#define D1_WDOG_CTRL_KEY (0xa57 << 1)
#define A10_WDOG_MODE 0x04
#define A31_WDOG_MODE 0x18
+#define D1_WDOG_MODE 0x18
+#define D1_WDOG_MODE_KEY (0x16AA << 16)
#define A10_WDOG_MODE_INTVL_SHIFT 3
#define A31_WDOG_MODE_INTVL_SHIFT 4
+#define D1_WDOG_MODE_INTVL_SHIFT 4
#define A10_WDOG_MODE_RST_EN (1 << 1)
#define WDOG_MODE_EN (1 << 0)
#define A31_WDOG_CONFIG 0x14
+#define D1_WDOG_CONFIG 0x14
#define A31_WDOG_CONFIG_RST_EN_SYSTEM (1 << 0)
#define A31_WDOG_CONFIG_RST_EN_INT (2 << 0)
+#define D1_WDOG_CONFIG_KEY (0x16AA << 16)
+#define D1_WDOG_CONFIG_RST_EN_SYSTEM (1 << 0)
+#define D1_WDOG_CONFIG_RST_EN_INT (2 << 0)
struct aw_wdog_interval {
uint64_t milliseconds;
@@ -95,18 +105,21 @@
uint8_t wdog_ctrl;
uint32_t wdog_ctrl_key;
uint8_t wdog_mode;
+ uint32_t wdog_mode_key;
uint8_t wdog_mode_intvl_shift;
uint8_t wdog_mode_en;
uint8_t wdog_config;
- uint8_t wdog_config_value;
+ uint32_t wdog_config_value;
};
#define A10_WATCHDOG 1
#define A31_WATCHDOG 2
+#define D1_WATCHDOG 3
static struct ofw_compat_data compat_data[] = {
{"allwinner,sun4i-a10-wdt", A10_WATCHDOG},
{"allwinner,sun6i-a31-wdt", A31_WATCHDOG},
+ {"allwinner,sun20i-d1-wdt", D1_WATCHDOG},
{NULL, 0}
};
@@ -126,6 +139,9 @@
case A31_WATCHDOG:
device_set_desc(dev, "Allwinner A31 Watchdog");
return (BUS_PROBE_DEFAULT);
+ case D1_WATCHDOG:
+ device_set_desc(dev, "Allwinner D1 Watchdog");
+ return (BUS_PROBE_DEFAULT);
}
return (ENXIO);
}
@@ -155,6 +171,7 @@
case A10_WATCHDOG:
sc->wdog_ctrl = A10_WDOG_CTRL;
sc->wdog_mode = A10_WDOG_MODE;
+ sc->wdog_mode_key = 0;
sc->wdog_mode_intvl_shift = A10_WDOG_MODE_INTVL_SHIFT;
sc->wdog_mode_en = A10_WDOG_MODE_RST_EN | WDOG_MODE_EN;
break;
@@ -162,11 +179,22 @@
sc->wdog_ctrl = A31_WDOG_CTRL;
sc->wdog_ctrl_key = A31_WDOG_CTRL_KEY;
sc->wdog_mode = A31_WDOG_MODE;
+ sc->wdog_mode_key = 0;
sc->wdog_mode_intvl_shift = A31_WDOG_MODE_INTVL_SHIFT;
sc->wdog_mode_en = WDOG_MODE_EN;
sc->wdog_config = A31_WDOG_CONFIG;
sc->wdog_config_value = A31_WDOG_CONFIG_RST_EN_SYSTEM;
break;
+ case D1_WATCHDOG:
+ sc->wdog_ctrl = D1_WDOG_CTRL;
+ sc->wdog_ctrl_key = D1_WDOG_CTRL_KEY;
+ sc->wdog_mode = D1_WDOG_MODE;
+ sc->wdog_mode_key = D1_WDOG_MODE_KEY;
+ sc->wdog_mode_intvl_shift = D1_WDOG_MODE_INTVL_SHIFT;
+ sc->wdog_mode_en = WDOG_MODE_EN;
+ sc->wdog_config = D1_WDOG_CONFIG;
+ sc->wdog_config_value = D1_WDOG_CONFIG_KEY | D1_WDOG_CONFIG_RST_EN_SYSTEM;
+ break;
default:
bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res);
return (ENXIO);
@@ -199,7 +227,7 @@
(ms > wd_intervals[i].milliseconds))
i++;
if (wd_intervals[i].milliseconds) {
- WRITE(sc, sc->wdog_mode,
+ WRITE(sc, sc->wdog_mode, sc->wdog_mode_key |
(wd_intervals[i].value << sc->wdog_mode_intvl_shift) |
sc->wdog_mode_en);
WRITE(sc, sc->wdog_ctrl,
@@ -217,12 +245,12 @@
device_printf(sc->dev,
"Can't arm, timeout is more than 16 sec\n");
mtx_unlock(&sc->mtx);
- WRITE(sc, sc->wdog_mode, 0);
+ WRITE(sc, sc->wdog_mode, sc->wdog_mode_key);
return;
}
}
else
- WRITE(sc, sc->wdog_mode, 0);
+ WRITE(sc, sc->wdog_mode, sc->wdog_mode_key);
mtx_unlock(&sc->mtx);
}
@@ -243,7 +271,7 @@
return;
}
- WRITE(aw_wdog_sc, aw_wdog_sc->wdog_mode,
+ WRITE(aw_wdog_sc, aw_wdog_sc->wdog_mode, aw_wdog_sc->wdog_mode_key |
(wd_intervals[0].value << aw_wdog_sc->wdog_mode_intvl_shift) |
aw_wdog_sc->wdog_mode_en);
if (aw_wdog_sc->wdog_config)
Index: sys/riscv/allwinner/files.allwinner
===================================================================
--- /dev/null
+++ sys/riscv/allwinner/files.allwinner
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+arm/allwinner/aw_wdog.c optional aw_wdog
Index: sys/riscv/conf/GENERIC
===================================================================
--- sys/riscv/conf/GENERIC
+++ sys/riscv/conf/GENERIC
@@ -210,6 +210,10 @@
device iicbus # Bus support, required for iicoc below.
device iicoc # OpenCores I2C controller support
+# Allwinner device drivers
+device aw_wdog # Allwinner Watchdog
+files "../allwinner/files.allwinner"
+
# SiFive device drivers
device fu740_pci_dw
device sifive_gpio
Index: sys/riscv/include/machdep.h
===================================================================
--- sys/riscv/include/machdep.h
+++ sys/riscv/include/machdep.h
@@ -37,6 +37,8 @@
#ifndef _MACHINE_MACHDEP_H_
#define _MACHINE_MACHDEP_H_
+#include <vm/vm_param.h>
+
struct riscv_bootparams {
vm_offset_t kern_l1pt; /* Kernel L1 base */
vm_offset_t kern_phys; /* Kernel base (physical) addr */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 6:16 PM (5 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16203633
Default Alt Text
D34749.id104497.diff (5 KB)
Attached To
Mode
D34749: aw_wdog: support Allwinner D1 watchdog
Attached
Detach File
Event Timeline
Log In to Comment