system_manager.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2013 Altera Corporation <www.altera.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/system_manager.h>
  9. #include <asm/arch/fpga_manager.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. static struct socfpga_system_manager *sysmgr_regs =
  12. (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
  13. /*
  14. * Populate the value for SYSMGR.FPGAINTF.MODULE based on pinmux setting.
  15. * The value is not wrote to SYSMGR.FPGAINTF.MODULE but
  16. * CONFIG_SYSMGR_ISWGRP_HANDOFF.
  17. */
  18. static void populate_sysmgr_fpgaintf_module(void)
  19. {
  20. uint32_t handoff_val = 0;
  21. /* ISWGRP_HANDOFF_FPGAINTF */
  22. writel(0, &sysmgr_regs->iswgrp_handoff[2]);
  23. /* Enable the signal for those HPS peripherals that use FPGA. */
  24. if (readl(&sysmgr_regs->nandusefpga) == SYSMGR_FPGAINTF_USEFPGA)
  25. handoff_val |= SYSMGR_FPGAINTF_NAND;
  26. if (readl(&sysmgr_regs->rgmii1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
  27. handoff_val |= SYSMGR_FPGAINTF_EMAC1;
  28. if (readl(&sysmgr_regs->sdmmcusefpga) == SYSMGR_FPGAINTF_USEFPGA)
  29. handoff_val |= SYSMGR_FPGAINTF_SDMMC;
  30. if (readl(&sysmgr_regs->rgmii0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
  31. handoff_val |= SYSMGR_FPGAINTF_EMAC0;
  32. if (readl(&sysmgr_regs->spim0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
  33. handoff_val |= SYSMGR_FPGAINTF_SPIM0;
  34. if (readl(&sysmgr_regs->spim1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
  35. handoff_val |= SYSMGR_FPGAINTF_SPIM1;
  36. /* populate (not writing) the value for SYSMGR.FPGAINTF.MODULE
  37. based on pinmux setting */
  38. setbits_le32(&sysmgr_regs->iswgrp_handoff[2], handoff_val);
  39. handoff_val = readl(&sysmgr_regs->iswgrp_handoff[2]);
  40. if (fpgamgr_test_fpga_ready()) {
  41. /* Enable the required signals only */
  42. writel(handoff_val, &sysmgr_regs->fpgaintfgrp_module);
  43. }
  44. }
  45. /*
  46. * Configure all the pin muxes
  47. */
  48. void sysmgr_pinmux_init(void)
  49. {
  50. uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
  51. int i;
  52. for (i = 0; i < ARRAY_SIZE(sys_mgr_init_table); i++) {
  53. writel(sys_mgr_init_table[i], regs);
  54. regs += sizeof(regs);
  55. }
  56. populate_sysmgr_fpgaintf_module();
  57. }
  58. /*
  59. * This bit allows the bootrom to configure the IOs after a warm reset.
  60. */
  61. void sysmgr_enable_warmrstcfgio(void)
  62. {
  63. setbits_le32(&sysmgr_regs->romcodegrp_ctrl,
  64. SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
  65. }