platform.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright(c) 2015 EZchip Technologies.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * The full GNU General Public License is included in this distribution in
  14. * the file called "COPYING".
  15. */
  16. #include <linux/init.h>
  17. #include <linux/io.h>
  18. #include <asm/mach_desc.h>
  19. #include <plat/mtm.h>
  20. static void __init eznps_configure_msu(void)
  21. {
  22. int cpu;
  23. struct nps_host_reg_msu_en_cfg msu_en_cfg = {.value = 0};
  24. msu_en_cfg.msu_en = 1;
  25. msu_en_cfg.ipi_en = 1;
  26. msu_en_cfg.gim_0_en = 1;
  27. msu_en_cfg.gim_1_en = 1;
  28. /* enable IPI and GIM messages on all clusters */
  29. for (cpu = 0 ; cpu < eznps_max_cpus; cpu += eznps_cpus_per_cluster)
  30. iowrite32be(msu_en_cfg.value,
  31. nps_host_reg(cpu, NPS_MSU_BLKID, NPS_MSU_EN_CFG));
  32. }
  33. static void __init eznps_configure_gim(void)
  34. {
  35. u32 reg_value;
  36. u32 gim_int_lines;
  37. struct nps_host_reg_gim_p_int_dst gim_p_int_dst = {.value = 0};
  38. gim_int_lines = NPS_GIM_UART_LINE;
  39. gim_int_lines |= NPS_GIM_DBG_LAN_EAST_TX_DONE_LINE;
  40. gim_int_lines |= NPS_GIM_DBG_LAN_EAST_RX_RDY_LINE;
  41. gim_int_lines |= NPS_GIM_DBG_LAN_WEST_TX_DONE_LINE;
  42. gim_int_lines |= NPS_GIM_DBG_LAN_WEST_RX_RDY_LINE;
  43. /*
  44. * IRQ polarity
  45. * low or high level
  46. * negative or positive edge
  47. */
  48. reg_value = ioread32be(REG_GIM_P_INT_POL_0);
  49. reg_value &= ~gim_int_lines;
  50. iowrite32be(reg_value, REG_GIM_P_INT_POL_0);
  51. /* IRQ type level or edge */
  52. reg_value = ioread32be(REG_GIM_P_INT_SENS_0);
  53. reg_value |= NPS_GIM_DBG_LAN_EAST_TX_DONE_LINE;
  54. reg_value |= NPS_GIM_DBG_LAN_WEST_TX_DONE_LINE;
  55. iowrite32be(reg_value, REG_GIM_P_INT_SENS_0);
  56. /*
  57. * GIM interrupt select type for
  58. * dbg_lan TX and RX interrupts
  59. * should be type 1
  60. * type 0 = IRQ line 6
  61. * type 1 = IRQ line 7
  62. */
  63. gim_p_int_dst.is = 1;
  64. iowrite32be(gim_p_int_dst.value, REG_GIM_P_INT_DST_10);
  65. iowrite32be(gim_p_int_dst.value, REG_GIM_P_INT_DST_11);
  66. iowrite32be(gim_p_int_dst.value, REG_GIM_P_INT_DST_25);
  67. iowrite32be(gim_p_int_dst.value, REG_GIM_P_INT_DST_26);
  68. /*
  69. * CTOP IRQ lines should be defined
  70. * as blocking in GIM
  71. */
  72. iowrite32be(gim_int_lines, REG_GIM_P_INT_BLK_0);
  73. /* enable CTOP IRQ lines in GIM */
  74. iowrite32be(gim_int_lines, REG_GIM_P_INT_EN_0);
  75. }
  76. static void __init eznps_early_init(void)
  77. {
  78. eznps_configure_msu();
  79. eznps_configure_gim();
  80. }
  81. static const char *eznps_compat[] __initconst = {
  82. "ezchip,arc-nps",
  83. NULL,
  84. };
  85. MACHINE_START(NPS, "nps")
  86. .dt_compat = eznps_compat,
  87. .init_early = eznps_early_init,
  88. MACHINE_END