• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão1aa2b85810a5c05e6712f9a8ac2d92a1c2916c9a (tree)
Hora2022-07-21 15:09:06
AutorStefan Roese <sr@denx...>
CommiterStefan Roese

Mensagem de Log

watchdog: octeontx_wdt: Add MIPS Octeon support

This patch adds support for the Marvell Octeon watchdog driver, which
currently only support the ARM64 Octeon TX & TX2 platforms. Since the
IP is pretty similar, it makes sense to extend this driver to also
support the MIPS Octeon SoC.

A follow-up patch will enable this watchdog support on the EBB7304
eval board.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Aaron Williams <awilliams@marvell.com>
Cc: Chandrakala Chavva <cchavva@marvell.com>

Mudança Sumário

Diff

--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -213,14 +213,13 @@ config WDT_NPCM
213213 It performs full SoC reset.
214214
215215 config WDT_OCTEONTX
216- bool "OcteonTX core watchdog support"
217- depends on WDT && (ARCH_OCTEONTX || ARCH_OCTEONTX2)
216+ bool "Octeon core watchdog support"
217+ depends on WDT && (ARCH_OCTEON || ARCH_OCTEONTX || ARCH_OCTEONTX2)
218218 default y
219219 imply WATCHDOG
220220 help
221- This enables OcteonTX watchdog driver, which can be
222- found on OcteonTX/TX2 chipsets and inline with driver model.
223- Only supports watchdog reset.
221+ This enables the Octeon watchdog driver, which can be found on
222+ various Octeon parts such as Octeon II/III and OcteonTX/TX2.
224223
225224 config WDT_OMAP3
226225 bool "TI OMAP watchdog timer support"
--- a/drivers/watchdog/octeontx_wdt.c
+++ b/drivers/watchdog/octeontx_wdt.c
@@ -15,16 +15,22 @@
1515
1616 DECLARE_GLOBAL_DATA_PTR;
1717
18-#define CORE0_WDOG_OFFSET 0x40000
19-#define CORE0_POKE_OFFSET 0x50000
2018 #define CORE0_POKE_OFFSET_MASK 0xfffffULL
2119
2220 #define WDOG_MODE GENMASK_ULL(1, 0)
2321 #define WDOG_LEN GENMASK_ULL(19, 4)
2422 #define WDOG_CNT GENMASK_ULL(43, 20)
2523
24+struct octeontx_wdt_data {
25+ u32 wdog_offset;
26+ u32 poke_offset;
27+ int timer_shift;
28+ bool has_clk;
29+};
30+
2631 struct octeontx_wdt {
2732 void __iomem *reg;
33+ const struct octeontx_wdt_data *data;
2834 struct clk clk;
2935 };
3036
@@ -34,12 +40,16 @@ static int octeontx_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
3440 u64 clk_rate, val;
3541 u64 tout_wdog;
3642
37- clk_rate = clk_get_rate(&priv->clk);
38- if (IS_ERR_VALUE(clk_rate))
39- return -EINVAL;
43+ if (priv->data->has_clk) {
44+ clk_rate = clk_get_rate(&priv->clk);
45+ if (IS_ERR_VALUE(clk_rate))
46+ return -EINVAL;
47+ } else {
48+ clk_rate = gd->bus_clk;
49+ }
4050
41- /* Watchdog counts in 1024 cycle steps */
42- tout_wdog = (clk_rate * timeout_ms / 1000) >> 10;
51+ /* Watchdog counts in configured cycle steps */
52+ tout_wdog = (clk_rate * timeout_ms / 1000) >> priv->data->timer_shift;
4353
4454 /*
4555 * We can only specify the upper 16 bits of a 24 bit value.
@@ -54,7 +64,7 @@ static int octeontx_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
5464 val = FIELD_PREP(WDOG_MODE, 0x3) |
5565 FIELD_PREP(WDOG_LEN, tout_wdog) |
5666 FIELD_PREP(WDOG_CNT, tout_wdog << 8);
57- writeq(val, priv->reg + CORE0_WDOG_OFFSET);
67+ writeq(val, priv->reg + priv->data->wdog_offset);
5868
5969 return 0;
6070 }
@@ -63,7 +73,7 @@ static int octeontx_wdt_stop(struct udevice *dev)
6373 {
6474 struct octeontx_wdt *priv = dev_get_priv(dev);
6575
66- writeq(0, priv->reg + CORE0_WDOG_OFFSET);
76+ writeq(0, priv->reg + priv->data->wdog_offset);
6777
6878 return 0;
6979 }
@@ -82,7 +92,7 @@ static int octeontx_wdt_reset(struct udevice *dev)
8292 {
8393 struct octeontx_wdt *priv = dev_get_priv(dev);
8494
85- writeq(~0ULL, priv->reg + CORE0_POKE_OFFSET);
95+ writeq(~0ULL, priv->reg + priv->data->poke_offset);
8696
8797 return 0;
8898 }
@@ -103,6 +113,10 @@ static int octeontx_wdt_probe(struct udevice *dev)
103113 if (!priv->reg)
104114 return -EINVAL;
105115
116+ priv->data = (void *)dev_get_driver_data(dev);
117+ if (!priv->data)
118+ return -EINVAL;
119+
106120 /*
107121 * Save base register address in reg masking lower 20 bits
108122 * as 0xa0000 appears when extracted from the DT
@@ -110,13 +124,15 @@ static int octeontx_wdt_probe(struct udevice *dev)
110124 priv->reg = (void __iomem *)(((u64)priv->reg &
111125 ~CORE0_POKE_OFFSET_MASK));
112126
113- ret = clk_get_by_index(dev, 0, &priv->clk);
114- if (ret < 0)
115- return ret;
127+ if (priv->data->has_clk) {
128+ ret = clk_get_by_index(dev, 0, &priv->clk);
129+ if (ret < 0)
130+ return ret;
116131
117- ret = clk_enable(&priv->clk);
118- if (ret)
119- return ret;
132+ ret = clk_enable(&priv->clk);
133+ if (ret)
134+ return ret;
135+ }
120136
121137 return 0;
122138 }
@@ -128,8 +144,23 @@ static const struct wdt_ops octeontx_wdt_ops = {
128144 .expire_now = octeontx_wdt_expire_now,
129145 };
130146
147+static const struct octeontx_wdt_data octeontx_data = {
148+ .wdog_offset = 0x40000,
149+ .poke_offset = 0x50000,
150+ .timer_shift = 10,
151+ .has_clk = true,
152+};
153+
154+static const struct octeontx_wdt_data octeon_data = {
155+ .wdog_offset = 0x20000,
156+ .poke_offset = 0x30000,
157+ .timer_shift = 10,
158+ .has_clk = false,
159+};
160+
131161 static const struct udevice_id octeontx_wdt_ids[] = {
132- { .compatible = "arm,sbsa-gwdt" },
162+ { .compatible = "arm,sbsa-gwdt", .data = (ulong)&octeontx_data },
163+ { .compatible = "cavium,octeon-7890-ciu3", .data = (ulong)&octeon_data },
133164 {}
134165 };
135166
@@ -138,7 +169,7 @@ U_BOOT_DRIVER(wdt_octeontx) = {
138169 .id = UCLASS_WDT,
139170 .of_match = octeontx_wdt_ids,
140171 .ops = &octeontx_wdt_ops,
141- .priv_auto = sizeof(struct octeontx_wdt),
172+ .priv_auto = sizeof(struct octeontx_wdt),
142173 .probe = octeontx_wdt_probe,
143174 .remove = octeontx_wdt_remove,
144175 .flags = DM_FLAG_OS_PREPARE,