winbond_w83627.c 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 <asm/io.h>
  8. #include <asm/pnp_def.h>
  9. #define WINBOND_ENTRY_KEY 0x87
  10. #define WINBOND_EXIT_KEY 0xaa
  11. /* Enable configuration: pass entry key '0x87' into index port dev twice */
  12. static void pnp_enter_conf_state(u16 dev)
  13. {
  14. u16 port = dev >> 8;
  15. outb(WINBOND_ENTRY_KEY, port);
  16. outb(WINBOND_ENTRY_KEY, port);
  17. }
  18. /* Disable configuration: pass exit key '0xAA' into index port dev */
  19. static void pnp_exit_conf_state(u16 dev)
  20. {
  21. u16 port = dev >> 8;
  22. outb(WINBOND_EXIT_KEY, port);
  23. }
  24. /* Bring up early serial debugging output before the RAM is initialized */
  25. void winbond_enable_serial(uint dev, uint iobase, uint irq)
  26. {
  27. pnp_enter_conf_state(dev);
  28. pnp_set_logical_device(dev);
  29. pnp_set_enable(dev, 0);
  30. pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
  31. pnp_set_irq(dev, PNP_IDX_IRQ0, irq);
  32. pnp_set_enable(dev, 1);
  33. pnp_exit_conf_state(dev);
  34. }