nuvoton_nct6102d.c 1.1 KB

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