blob: 1e0670e0c5c2ad7a0a661e7664d5b4dca69e5000 [file] [log] [blame]
Suneel Garapati7072b172019-10-21 16:09:36 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2019 Marvell International Ltd.
4 *
5 * https://spdx.org/licenses
6 */
7
8#include <dm.h>
9#include <errno.h>
10#include <wdt.h>
11#include <asm/io.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15#define CORE0_POKE_OFFSET 0x50000
16#define CORE0_POKE_OFFSET_MASK 0xfffffULL
17
18struct octeontx_wdt {
19 void __iomem *reg;
20};
21
22static int octeontx_wdt_reset(struct udevice *dev)
23{
24 struct octeontx_wdt *priv = dev_get_priv(dev);
25
26 writeq(~0ULL, priv->reg);
27
28 return 0;
29}
30
31static int octeontx_wdt_probe(struct udevice *dev)
32{
33 struct octeontx_wdt *priv = dev_get_priv(dev);
34
35 priv->reg = dev_remap_addr(dev);
36 if (!priv->reg)
37 return -EINVAL;
38
39 /*
40 * Save core poke register address in reg (its not 0xa0000 as
41 * extracted from the DT but 0x50000 instead)
42 */
43 priv->reg = (void __iomem *)(((u64)priv->reg &
44 ~CORE0_POKE_OFFSET_MASK) |
45 CORE0_POKE_OFFSET);
46
47 return 0;
48}
49
50static const struct wdt_ops octeontx_wdt_ops = {
51 .reset = octeontx_wdt_reset,
52};
53
54static const struct udevice_id octeontx_wdt_ids[] = {
55 { .compatible = "arm,sbsa-gwdt" },
56 {}
57};
58
59U_BOOT_DRIVER(wdt_octeontx) = {
60 .name = "wdt_octeontx",
61 .id = UCLASS_WDT,
62 .of_match = octeontx_wdt_ids,
63 .ops = &octeontx_wdt_ops,
64 .priv_auto_alloc_size = sizeof(struct octeontx_wdt),
65 .probe = octeontx_wdt_probe,
66};