nuvoton_nct6102d.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Stefan Roese <sr@denx.de>
  4. */
  5. #include <common.h>
  6. #include <nuvoton_nct6102d.h>
  7. #include <asm/io.h>
  8. #include <asm/pnp_def.h>
  9. static void superio_outb(int reg, int val)
  10. {
  11. outb(reg, NCT_EFER);
  12. outb(val, NCT_EFDR);
  13. }
  14. static inline int superio_inb(int reg)
  15. {
  16. outb(reg, NCT_EFER);
  17. return inb(NCT_EFDR);
  18. }
  19. static int superio_enter(void)
  20. {
  21. outb(NCT_ENTRY_KEY, NCT_EFER); /* Enter extended function mode */
  22. outb(NCT_ENTRY_KEY, NCT_EFER); /* Again according to manual */
  23. return 0;
  24. }
  25. static void superio_select(int ld)
  26. {
  27. superio_outb(NCT_LD_SELECT_REG, ld);
  28. }
  29. static void superio_exit(void)
  30. {
  31. outb(NCT_EXIT_KEY, NCT_EFER); /* Leave extended function mode */
  32. }
  33. /*
  34. * The Nuvoton NCT6102D starts per default after reset with both,
  35. * the internal watchdog and the internal legacy UART enabled. This
  36. * code provides a function to disable the watchdog.
  37. */
  38. int nct6102d_wdt_disable(void)
  39. {
  40. superio_enter();
  41. /* Select logical device for WDT */
  42. superio_select(NCT6102D_LD_WDT);
  43. superio_outb(NCT6102D_WDT_TIMEOUT, 0x00);
  44. superio_exit();
  45. return 0;
  46. }