galileo.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/device.h>
  9. #include <asm/arch/quark.h>
  10. /*
  11. * Intel Galileo gen2 board uses GPIO Resume Well bank pin0 as the PERST# pin.
  12. *
  13. * We cannot use any public GPIO APIs in <asm-generic/gpio.h> to control this
  14. * pin, as these APIs will eventually call into gpio_ich6_ofdata_to_platdata()
  15. * in the Intel ICH6 GPIO driver where it calls PCI configuration space access
  16. * APIs which will trigger PCI enumeration process.
  17. *
  18. * Check <asm/arch-quark/quark.h> for more details.
  19. */
  20. void board_assert_perst(void)
  21. {
  22. u32 base, port, val;
  23. /* retrieve the GPIO IO base */
  24. qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
  25. base = (base & 0xffff) & ~0x7f;
  26. /* enable the pin */
  27. port = base + 0x20;
  28. val = inl(port);
  29. val |= (1 << 0);
  30. outl(val, port);
  31. /* configure the pin as output */
  32. port = base + 0x24;
  33. val = inl(port);
  34. val &= ~(1 << 0);
  35. outl(val, port);
  36. /* pull it down (assert) */
  37. port = base + 0x28;
  38. val = inl(port);
  39. val &= ~(1 << 0);
  40. outl(val, port);
  41. }
  42. void board_deassert_perst(void)
  43. {
  44. u32 base, port, val;
  45. /* retrieve the GPIO IO base */
  46. qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
  47. base = (base & 0xffff) & ~0x7f;
  48. /* pull it up (de-assert) */
  49. port = base + 0x28;
  50. val = inl(port);
  51. val |= (1 << 0);
  52. outl(val, port);
  53. }