system_manager_gen5.c 2.3 KB

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