octeontx_wdt.c 1.3 KB

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