spu_priv1_mmio.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * spu hypervisor abstraction for direct hardware access.
  3. *
  4. * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
  5. * Copyright 2006 Sony Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/module.h>
  21. #include <asm/io.h>
  22. #include <asm/spu.h>
  23. #include <asm/spu_priv1.h>
  24. static void int_mask_and(struct spu *spu, int class, u64 mask)
  25. {
  26. u64 old_mask;
  27. old_mask = in_be64(&spu->priv1->int_mask_RW[class]);
  28. out_be64(&spu->priv1->int_mask_RW[class], old_mask & mask);
  29. }
  30. static void int_mask_or(struct spu *spu, int class, u64 mask)
  31. {
  32. u64 old_mask;
  33. old_mask = in_be64(&spu->priv1->int_mask_RW[class]);
  34. out_be64(&spu->priv1->int_mask_RW[class], old_mask | mask);
  35. }
  36. static void int_mask_set(struct spu *spu, int class, u64 mask)
  37. {
  38. out_be64(&spu->priv1->int_mask_RW[class], mask);
  39. }
  40. static u64 int_mask_get(struct spu *spu, int class)
  41. {
  42. return in_be64(&spu->priv1->int_mask_RW[class]);
  43. }
  44. static void int_stat_clear(struct spu *spu, int class, u64 stat)
  45. {
  46. out_be64(&spu->priv1->int_stat_RW[class], stat);
  47. }
  48. static u64 int_stat_get(struct spu *spu, int class)
  49. {
  50. return in_be64(&spu->priv1->int_stat_RW[class]);
  51. }
  52. static void int_route_set(struct spu *spu, u64 route)
  53. {
  54. out_be64(&spu->priv1->int_route_RW, route);
  55. }
  56. static u64 mfc_dar_get(struct spu *spu)
  57. {
  58. return in_be64(&spu->priv1->mfc_dar_RW);
  59. }
  60. static u64 mfc_dsisr_get(struct spu *spu)
  61. {
  62. return in_be64(&spu->priv1->mfc_dsisr_RW);
  63. }
  64. static void mfc_dsisr_set(struct spu *spu, u64 dsisr)
  65. {
  66. out_be64(&spu->priv1->mfc_dsisr_RW, dsisr);
  67. }
  68. static void mfc_sdr_set(struct spu *spu, u64 sdr)
  69. {
  70. out_be64(&spu->priv1->mfc_sdr_RW, sdr);
  71. }
  72. static void mfc_sr1_set(struct spu *spu, u64 sr1)
  73. {
  74. out_be64(&spu->priv1->mfc_sr1_RW, sr1);
  75. }
  76. static u64 mfc_sr1_get(struct spu *spu)
  77. {
  78. return in_be64(&spu->priv1->mfc_sr1_RW);
  79. }
  80. static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)
  81. {
  82. out_be64(&spu->priv1->mfc_tclass_id_RW, tclass_id);
  83. }
  84. static u64 mfc_tclass_id_get(struct spu *spu)
  85. {
  86. return in_be64(&spu->priv1->mfc_tclass_id_RW);
  87. }
  88. static void tlb_invalidate(struct spu *spu)
  89. {
  90. out_be64(&spu->priv1->tlb_invalidate_entry_W, 0ul);
  91. }
  92. static void resource_allocation_groupID_set(struct spu *spu, u64 id)
  93. {
  94. out_be64(&spu->priv1->resource_allocation_groupID_RW, id);
  95. }
  96. static u64 resource_allocation_groupID_get(struct spu *spu)
  97. {
  98. return in_be64(&spu->priv1->resource_allocation_groupID_RW);
  99. }
  100. static void resource_allocation_enable_set(struct spu *spu, u64 enable)
  101. {
  102. out_be64(&spu->priv1->resource_allocation_enable_RW, enable);
  103. }
  104. static u64 resource_allocation_enable_get(struct spu *spu)
  105. {
  106. return in_be64(&spu->priv1->resource_allocation_enable_RW);
  107. }
  108. const struct spu_priv1_ops spu_priv1_mmio_ops =
  109. {
  110. .int_mask_and = int_mask_and,
  111. .int_mask_or = int_mask_or,
  112. .int_mask_set = int_mask_set,
  113. .int_mask_get = int_mask_get,
  114. .int_stat_clear = int_stat_clear,
  115. .int_stat_get = int_stat_get,
  116. .int_route_set = int_route_set,
  117. .mfc_dar_get = mfc_dar_get,
  118. .mfc_dsisr_get = mfc_dsisr_get,
  119. .mfc_dsisr_set = mfc_dsisr_set,
  120. .mfc_sdr_set = mfc_sdr_set,
  121. .mfc_sr1_set = mfc_sr1_set,
  122. .mfc_sr1_get = mfc_sr1_get,
  123. .mfc_tclass_id_set = mfc_tclass_id_set,
  124. .mfc_tclass_id_get = mfc_tclass_id_get,
  125. .tlb_invalidate = tlb_invalidate,
  126. .resource_allocation_groupID_set = resource_allocation_groupID_set,
  127. .resource_allocation_groupID_get = resource_allocation_groupID_get,
  128. .resource_allocation_enable_set = resource_allocation_enable_set,
  129. .resource_allocation_enable_get = resource_allocation_enable_get,
  130. };