galileo.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. int board_early_init_f(void)
  11. {
  12. return 0;
  13. }
  14. /*
  15. * Intel Galileo gen2 board uses GPIO Resume Well bank pin0 as the PERST# pin.
  16. *
  17. * We cannot use any public GPIO APIs in <asm-generic/gpio.h> to control this
  18. * pin, as these APIs will eventually call into gpio_ich6_ofdata_to_platdata()
  19. * in the Intel ICH6 GPIO driver where it calls PCI configuration space access
  20. * APIs which will trigger PCI enumeration process.
  21. *
  22. * Check <asm/arch-quark/quark.h> for more details.
  23. */
  24. void board_assert_perst(void)
  25. {
  26. u32 base, port, val;
  27. /* retrieve the GPIO IO base */
  28. qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
  29. base = (base & 0xffff) & ~0x7f;
  30. /* enable the pin */
  31. port = base + 0x20;
  32. val = inl(port);
  33. val |= (1 << 0);
  34. outl(val, port);
  35. /* configure the pin as output */
  36. port = base + 0x24;
  37. val = inl(port);
  38. val &= ~(1 << 0);
  39. outl(val, port);
  40. /* pull it down (assert) */
  41. port = base + 0x28;
  42. val = inl(port);
  43. val &= ~(1 << 0);
  44. outl(val, port);
  45. }
  46. void board_deassert_perst(void)
  47. {
  48. u32 base, port, val;
  49. /* retrieve the GPIO IO base */
  50. qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
  51. base = (base & 0xffff) & ~0x7f;
  52. /* pull it up (de-assert) */
  53. port = base + 0x28;
  54. val = inl(port);
  55. val |= (1 << 0);
  56. outl(val, port);
  57. }