mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
* Initial commit BPi R2: Currently working/not working: - u-boot: - builds with minor issues - patching and cleanup happens on 'https://github.com/chwe17/u-boot-mt' - next (https://github.com/frank-w/BPI-R2-4.14) - boots with minor issues - ETH doesn't work with nm - sata works - no wifi (needs driver from: https://github.com/frank-w/BPI-R2-4.4) - USB not working (xhci-mtk 1a1c0000.usb: fail to get vbus) needs investigation - appended device tree is needed due to u-boot doesn't work with fdt (kernelpacking needs adjustemts e.g. cat zImage dtb > zImage-dtb - dev (kernel.org master) - untested, needs adjustments in config (e.g. CONFIG_LOCALVERSION="") - since no defconfig is available config is based on frank-w 4.16 Kernel - Kernel builds without issues - manual packing of kernel and dtb similar to next The board boots, serial console is available but everything else must be expected as not working! - to do: - u-boot needs a cleanup - binary blobs needs investigation - eMMC is **not tested** and needs for sure adjustements! (don't try nand-sata-install!!!) - bootscript isn't tested (only manual boot over u-boot console at the moment) - both kernelconfigs aren't 'armbian standard' modules need to be adjusted Only use it when you know're familiar with u-boot commands! * Small fixes, add bootscript - add bootscript for patched u-boot (needs patching of u-boot, currently under investigation and not working properly) - revert cat zImage dtb > zImage-dtb (cause not working) - first cleanup of dev kernelconfig (remove CONFIG_LOCALVERSION="") * Minor fixup -kernelconfig for next was adjustet so that USB is recognized -firt bootscripts was written to boot with source command (doesn't work 100% reliable) -slightly adjustd boardconfig (e.g. bootscript) must still be considered as early wip! * small update (FDT works now) -working bootscript -adjusted boardconfig -earlyprintk activated in kernelconfig * First attempt to get ETH working -all interfaces are bridged together -performance sucks at the moment (not clear if it's related to insane network configuration or I miss something obvious... :P ) * Major update (see below for changes): - 4.14 kernel was dropped due to https://forum.armbian.com/topic/7296-bananapi-r2-csc-mt7623-as-new-boardfamily/?do=findComment&comment=55194 and following - boot.cmd was adjusted to 'clean' mainline behaviour - next build opition and its defaultconfg was removed (at the moment dev only) - rework of the network default configuration - default configuration will be over network.d **not** NetworkManager - per default all wired interfaces are bridged together to br0 (still wip) - old 'interfaces' configuration was removed - boardconfig is adjusted (no desktop until I've prove that HDMI works) - what works/ not works: - board boots up without manual u-boot hacking - SATA, USB3 (massstorage) is tested and works without issues - due to rework of network configuration this is still wip and must be considered as 'not working' * moved to network.d for configuration of wired network - renamed bsp packages - blacklist wired interfaces for NetworkManager - defined all wired interfaces as br0 in systemd/network - defined networkd als default renderer for bionic (not tested yet!) * The houskeeping commit: - BOARDFAMILY was renamed to mt7623 instead of mt7623n (including patchfolders etc.) - Network.d has no fully control over wired networkes (block NM from controll, start networkd on firstrun etc.) - Further cleanup kernelconfig - CPU temp is visible from userspace - missed switch driver loaded - cryptodrivers are there (not tested) - still a bunch of work * Add DMA mem alloc patch -under testing! * Add next option (4.17.y) stick dev to master (4.18-rc1 untested) * minor fixes: - solve kconfig issues between 4.17 and 4.18 - stick next branch to 4.18 - first attempts to bring up gmac2 (doesn't work currently) * switch to upstream u-boot - fix ext4 dependency in patch series - kernelpacking currently broken * add bootz & cmd_ext4 * resolved merge conflict * apply ugly u-boot patch, fix bootscript * remove unneeded stuff, apply forgotten stuff * update config for dev & clean up boardconf (remove xenial) * - drop dev and next, move into default. There is no intention to provide stock kernel - fixed board description, renamed to WIP, where it can be merged later - packing boot firmware to the u-boot package - docker dependencies (aufs will be added later. not essential) - attached to 4.19.y - loading armbianEnv.txt - UUID support (tested) - enabled ZRAM (tested) - enabled eMMC install (not quite working properly yet) - Bionic has some issues with systemd networking. * gov to ondemand (thermals are conservative anyway), remove unneeded kernelconfigs * Added AUFS, remove debug from kernel boot parameters, add ath10 mPCI support (which works) * add power-off-key and rtc * Added onboard wireless, but it's enabling is disabled by default. Too fragile. * Change to CSC target
198 lines
5.4 KiB
Diff
198 lines
5.4 KiB
Diff
From patchwork Tue Oct 2 06:13:48 2018
|
|
Content-Type: text/plain; charset="utf-8"
|
|
MIME-Version: 1.0
|
|
Content-Transfer-Encoding: 7bit
|
|
Subject: [U-Boot,
|
|
11/20] watchdog: MediaTek: add watchdog driver for MediaTek SoCs
|
|
X-Patchwork-Submitter: Ryder Lee <ryder.lee@mediatek.com>
|
|
X-Patchwork-Id: 977705
|
|
Message-Id: <9b2fea0152ddf3254de66870136a25174ca0841d.1538460580.git.ryder.lee@mediatek.com>
|
|
To: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>, Albert
|
|
Aribaud <albert.u.boot@aribaud.net>
|
|
Cc: Steven Liu <steven.liu@mediatek.com>,
|
|
Roy Luo <cheng-hao.luo@mediatek.com>, Sean Wang <sean.wang@mediatek.com>,
|
|
Weijie Gao <weijie.gao@mediatek.com>, u-boot@lists.denx.de
|
|
Date: Tue, 2 Oct 2018 14:13:48 +0800
|
|
From: Ryder Lee <ryder.lee@mediatek.com>
|
|
List-Id: U-Boot discussion <u-boot.lists.denx.de>
|
|
|
|
This patch adds a common driver for the Mediatek SoC integrated watchdog.
|
|
|
|
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
|
|
---
|
|
drivers/watchdog/Kconfig | 8 +++
|
|
drivers/watchdog/Makefile | 1 +
|
|
drivers/watchdog/mtk_wdt.c | 135 +++++++++++++++++++++++++++++++++++++++++++++
|
|
3 files changed, 144 insertions(+)
|
|
create mode 100644 drivers/watchdog/mtk_wdt.c
|
|
|
|
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
|
|
index d545b3e..57a12f5 100644
|
|
--- a/drivers/watchdog/Kconfig
|
|
+++ b/drivers/watchdog/Kconfig
|
|
@@ -103,6 +103,14 @@ config WDT_CDNS
|
|
Select this to enable Cadence watchdog timer, which can be found on some
|
|
Xilinx Microzed Platform.
|
|
|
|
+config WDT_MTK
|
|
+ bool "MediaTek watchdog timer support"
|
|
+ depends on WDT && ARCH_MEDIATEK
|
|
+ help
|
|
+ Select this to enable watchdog timer for MediaTek SoCs.
|
|
+ The watchdog timer is stopped when initialized.
|
|
+ It performs full SoC reset.
|
|
+
|
|
config XILINX_TB_WATCHDOG
|
|
bool "Xilinx Axi watchdog timer support"
|
|
depends on WDT
|
|
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
|
|
index 08406ca..04fa4a6 100644
|
|
--- a/drivers/watchdog/Makefile
|
|
+++ b/drivers/watchdog/Makefile
|
|
@@ -23,3 +23,4 @@ obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o
|
|
obj-$(CONFIG_WDT_ORION) += orion_wdt.o
|
|
obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
|
|
obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o
|
|
+obj-$(CONFIG_WDT_MTK) += mtk_wdt.o
|
|
diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
|
|
new file mode 100644
|
|
index 0000000..0b50173
|
|
--- /dev/null
|
|
+++ b/drivers/watchdog/mtk_wdt.c
|
|
@@ -0,0 +1,135 @@
|
|
+// SPDX-License-Identifier: GPL-2.0
|
|
+/*
|
|
+ * Watchdog driver for MediaTek SoCs
|
|
+ *
|
|
+ * Copyright (C) 2018 MediaTek Inc.
|
|
+ * Author: Ryder Lee <ryder.lee@mediatek.com>
|
|
+ */
|
|
+
|
|
+#include <common.h>
|
|
+#include <dm.h>
|
|
+#include <wdt.h>
|
|
+#include <asm/io.h>
|
|
+
|
|
+#define MTK_WDT_MODE 0x00
|
|
+#define MTK_WDT_LENGTH 0x04
|
|
+#define MTK_WDT_RESTART 0x08
|
|
+#define MTK_WDT_STATUS 0x0c
|
|
+#define MTK_WDT_INTERVAL 0x10
|
|
+#define MTK_WDT_SWRST 0x14
|
|
+#define MTK_WDT_REQ_MODE 0x30
|
|
+#define MTK_WDT_DEBUG_CTL 0x40
|
|
+
|
|
+#define WDT_MODE_KEY (0x22 << 24)
|
|
+#define WDT_MODE_EN BIT(0)
|
|
+#define WDT_MODE_EXTPOL BIT(1)
|
|
+#define WDT_MODE_EXTEN BIT(2)
|
|
+#define WDT_MODE_IRQ_EN BIT(3)
|
|
+#define WDT_MODE_DUAL_EN BIT(6)
|
|
+
|
|
+#define WDT_LENGTH_KEY 0x8
|
|
+#define WDT_LENGTH_TIMEOUT(n) ((n) << 5)
|
|
+
|
|
+#define WDT_RESTART_KEY 0x1971
|
|
+#define WDT_SWRST_KEY 0x1209
|
|
+
|
|
+struct mtk_wdt_priv {
|
|
+ void __iomem *base;
|
|
+};
|
|
+
|
|
+static int mtk_wdt_reset(struct udevice *dev)
|
|
+{
|
|
+ struct mtk_wdt_priv *priv = dev_get_priv(dev);
|
|
+
|
|
+ /* Reload watchdog duration */
|
|
+ writel(WDT_RESTART_KEY, priv->base + MTK_WDT_RESTART);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int mtk_wdt_stop(struct udevice *dev)
|
|
+{
|
|
+ struct mtk_wdt_priv *priv = dev_get_priv(dev);
|
|
+
|
|
+ clrsetbits_le32(priv->base + MTK_WDT_MODE, WDT_MODE_EN, WDT_MODE_KEY);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int mtk_wdt_expire_now(struct udevice *dev, ulong flags)
|
|
+{
|
|
+ struct mtk_wdt_priv *priv = dev_get_priv(dev);
|
|
+
|
|
+ /* Kick watchdog to prevent counter == 0 */
|
|
+ writel(WDT_RESTART_KEY, priv->base + MTK_WDT_RESTART);
|
|
+
|
|
+ /* Reset */
|
|
+ writel(WDT_SWRST_KEY, priv->base + MTK_WDT_SWRST);
|
|
+ hang();
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static void mtk_wdt_set_timeout(struct udevice *dev, unsigned int timeout)
|
|
+{
|
|
+ struct mtk_wdt_priv *priv = dev_get_priv(dev);
|
|
+
|
|
+ /*
|
|
+ * One bit is the value of 512 ticks
|
|
+ * The clock has 32 KHz
|
|
+ */
|
|
+ timeout = WDT_LENGTH_TIMEOUT(timeout << 6) | WDT_LENGTH_KEY;
|
|
+ writel(timeout, priv->base + MTK_WDT_LENGTH);
|
|
+
|
|
+ mtk_wdt_reset(dev);
|
|
+}
|
|
+
|
|
+static int mtk_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
|
|
+{
|
|
+ struct mtk_wdt_priv *priv = dev_get_priv(dev);
|
|
+
|
|
+ mtk_wdt_set_timeout(dev, timeout);
|
|
+
|
|
+ /* Enable watchdog reset signal */
|
|
+ setbits_le32(priv->base + MTK_WDT_MODE,
|
|
+ WDT_MODE_EN | WDT_MODE_KEY | WDT_MODE_EXTEN);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int mtk_wdt_probe(struct udevice *dev)
|
|
+{
|
|
+ struct mtk_wdt_priv *priv = dev_get_priv(dev);
|
|
+
|
|
+ priv->base = dev_read_addr_ptr(dev);
|
|
+ if (!priv->base)
|
|
+ return -ENOENT;
|
|
+
|
|
+ /* Clear status */
|
|
+ clrsetbits_le32(priv->base + MTK_WDT_MODE,
|
|
+ WDT_MODE_IRQ_EN | WDT_MODE_EXTPOL, WDT_MODE_KEY);
|
|
+
|
|
+ return mtk_wdt_stop(dev);
|
|
+}
|
|
+
|
|
+static const struct wdt_ops mtk_wdt_ops = {
|
|
+ .start = mtk_wdt_start,
|
|
+ .reset = mtk_wdt_reset,
|
|
+ .stop = mtk_wdt_stop,
|
|
+ .expire_now = mtk_wdt_expire_now,
|
|
+};
|
|
+
|
|
+static const struct udevice_id mtk_wdt_ids[] = {
|
|
+ { .compatible = "mediatek,wdt"},
|
|
+ {}
|
|
+};
|
|
+
|
|
+U_BOOT_DRIVER(mtk_wdt) = {
|
|
+ .name = "mtk_wdt",
|
|
+ .id = UCLASS_WDT,
|
|
+ .of_match = mtk_wdt_ids,
|
|
+ .priv_auto_alloc_size = sizeof(struct mtk_wdt_priv),
|
|
+ .probe = mtk_wdt_probe,
|
|
+ .ops = &mtk_wdt_ops,
|
|
+ .flags = DM_FLAG_PRE_RELOC,
|
|
+};
|