winbond_w83627.c 956 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Stefan Roese <sr@denx.de>
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include <asm/pnp_def.h>
  8. #define WINBOND_ENTRY_KEY 0x87
  9. #define WINBOND_EXIT_KEY 0xaa
  10. /* Enable configuration: pass entry key '0x87' into index port dev twice */
  11. static void pnp_enter_conf_state(u16 dev)
  12. {
  13. u16 port = dev >> 8;
  14. outb(WINBOND_ENTRY_KEY, port);
  15. outb(WINBOND_ENTRY_KEY, port);
  16. }
  17. /* Disable configuration: pass exit key '0xAA' into index port dev */
  18. static void pnp_exit_conf_state(u16 dev)
  19. {
  20. u16 port = dev >> 8;
  21. outb(WINBOND_EXIT_KEY, port);
  22. }
  23. /* Bring up early serial debugging output before the RAM is initialized */
  24. void winbond_enable_serial(uint dev, uint iobase, uint irq)
  25. {
  26. pnp_enter_conf_state(dev);
  27. pnp_set_logical_device(dev);
  28. pnp_set_enable(dev, 0);
  29. pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
  30. pnp_set_irq(dev, PNP_IDX_IRQ0, irq);
  31. pnp_set_enable(dev, 1);
  32. pnp_exit_conf_state(dev);
  33. }