ps3.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * PS3 platform declarations.
  3. *
  4. * Copyright (C) 2006 Sony Computer Entertainment Inc.
  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. #if !defined(_ASM_POWERPC_PS3_H)
  21. #define _ASM_POWERPC_PS3_H
  22. #include <linux/compiler.h> /* for __deprecated */
  23. #include <linux/init.h>
  24. #include <linux/types.h>
  25. #include <linux/device.h>
  26. /**
  27. * struct ps3_device_id - HV bus device identifier from the system repository
  28. * @bus_id: HV bus id, {1..} (zero invalid)
  29. * @dev_id: HV device id, {0..}
  30. */
  31. struct ps3_device_id {
  32. unsigned int bus_id;
  33. unsigned int dev_id;
  34. };
  35. /* dma routines */
  36. enum ps3_dma_page_size {
  37. PS3_DMA_4K = 12U,
  38. PS3_DMA_64K = 16U,
  39. PS3_DMA_1M = 20U,
  40. PS3_DMA_16M = 24U,
  41. };
  42. enum ps3_dma_region_type {
  43. PS3_DMA_OTHER = 0,
  44. PS3_DMA_INTERNAL = 2,
  45. };
  46. /**
  47. * struct ps3_dma_region - A per device dma state variables structure
  48. * @did: The HV device id.
  49. * @page_size: The ioc pagesize.
  50. * @region_type: The HV region type.
  51. * @bus_addr: The 'translated' bus address of the region.
  52. * @len: The length in bytes of the region.
  53. * @chunk_list: Opaque variable used by the ioc page manager.
  54. */
  55. struct ps3_dma_region {
  56. struct ps3_device_id did;
  57. enum ps3_dma_page_size page_size;
  58. enum ps3_dma_region_type region_type;
  59. unsigned long bus_addr;
  60. unsigned long len;
  61. struct {
  62. spinlock_t lock;
  63. struct list_head head;
  64. } chunk_list;
  65. };
  66. /**
  67. * struct ps3_dma_region_init - Helper to initialize structure variables
  68. *
  69. * Helper to properly initialize variables prior to calling
  70. * ps3_system_bus_device_register.
  71. */
  72. static inline void ps3_dma_region_init(struct ps3_dma_region *r,
  73. const struct ps3_device_id* did, enum ps3_dma_page_size page_size,
  74. enum ps3_dma_region_type region_type)
  75. {
  76. r->did = *did;
  77. r->page_size = page_size;
  78. r->region_type = region_type;
  79. }
  80. int ps3_dma_region_create(struct ps3_dma_region *r);
  81. int ps3_dma_region_free(struct ps3_dma_region *r);
  82. int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
  83. unsigned long len, unsigned long *bus_addr);
  84. int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr,
  85. unsigned long len);
  86. /* mmio routines */
  87. enum ps3_mmio_page_size {
  88. PS3_MMIO_4K = 12U,
  89. PS3_MMIO_64K = 16U
  90. };
  91. /**
  92. * struct ps3_mmio_region - a per device mmio state variables structure
  93. *
  94. * Current systems can be supported with a single region per device.
  95. */
  96. struct ps3_mmio_region {
  97. struct ps3_device_id did;
  98. unsigned long bus_addr;
  99. unsigned long len;
  100. enum ps3_mmio_page_size page_size;
  101. unsigned long lpar_addr;
  102. };
  103. /**
  104. * struct ps3_mmio_region_init - Helper to initialize structure variables
  105. *
  106. * Helper to properly initialize variables prior to calling
  107. * ps3_system_bus_device_register.
  108. */
  109. static inline void ps3_mmio_region_init(struct ps3_mmio_region *r,
  110. const struct ps3_device_id* did, unsigned long bus_addr,
  111. unsigned long len, enum ps3_mmio_page_size page_size)
  112. {
  113. r->did = *did;
  114. r->bus_addr = bus_addr;
  115. r->len = len;
  116. r->page_size = page_size;
  117. }
  118. int ps3_mmio_region_create(struct ps3_mmio_region *r);
  119. int ps3_free_mmio_region(struct ps3_mmio_region *r);
  120. unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
  121. /* inrerrupt routines */
  122. int ps3_alloc_io_irq(unsigned int interrupt_id, unsigned int *virq);
  123. int ps3_free_io_irq(unsigned int virq);
  124. int ps3_alloc_event_irq(unsigned int *virq);
  125. int ps3_free_event_irq(unsigned int virq);
  126. int ps3_send_event_locally(unsigned int virq);
  127. int ps3_connect_event_irq(const struct ps3_device_id *did,
  128. unsigned int interrupt_id, unsigned int *virq);
  129. int ps3_disconnect_event_irq(const struct ps3_device_id *did,
  130. unsigned int interrupt_id, unsigned int virq);
  131. int ps3_alloc_vuart_irq(void* virt_addr_bmp, unsigned int *virq);
  132. int ps3_free_vuart_irq(unsigned int virq);
  133. int ps3_alloc_spe_irq(unsigned long spe_id, unsigned int class,
  134. unsigned int *virq);
  135. int ps3_free_spe_irq(unsigned int virq);
  136. /* lv1 result codes */
  137. enum lv1_result {
  138. LV1_SUCCESS = 0,
  139. /* not used -1 */
  140. LV1_RESOURCE_SHORTAGE = -2,
  141. LV1_NO_PRIVILEGE = -3,
  142. LV1_DENIED_BY_POLICY = -4,
  143. LV1_ACCESS_VIOLATION = -5,
  144. LV1_NO_ENTRY = -6,
  145. LV1_DUPLICATE_ENTRY = -7,
  146. LV1_TYPE_MISMATCH = -8,
  147. LV1_BUSY = -9,
  148. LV1_EMPTY = -10,
  149. LV1_WRONG_STATE = -11,
  150. /* not used -12 */
  151. LV1_NO_MATCH = -13,
  152. LV1_ALREADY_CONNECTED = -14,
  153. LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
  154. LV1_CONDITION_NOT_SATISFIED = -16,
  155. LV1_ILLEGAL_PARAMETER_VALUE = -17,
  156. LV1_BAD_OPTION = -18,
  157. LV1_IMPLEMENTATION_LIMITATION = -19,
  158. LV1_NOT_IMPLEMENTED = -20,
  159. LV1_INVALID_CLASS_ID = -21,
  160. LV1_CONSTRAINT_NOT_SATISFIED = -22,
  161. LV1_ALIGNMENT_ERROR = -23,
  162. LV1_INTERNAL_ERROR = -32768,
  163. };
  164. static inline const char* ps3_result(int result)
  165. {
  166. #if defined(DEBUG)
  167. switch (result) {
  168. case LV1_SUCCESS:
  169. return "LV1_SUCCESS (0)";
  170. case -1:
  171. return "** unknown result ** (-1)";
  172. case LV1_RESOURCE_SHORTAGE:
  173. return "LV1_RESOURCE_SHORTAGE (-2)";
  174. case LV1_NO_PRIVILEGE:
  175. return "LV1_NO_PRIVILEGE (-3)";
  176. case LV1_DENIED_BY_POLICY:
  177. return "LV1_DENIED_BY_POLICY (-4)";
  178. case LV1_ACCESS_VIOLATION:
  179. return "LV1_ACCESS_VIOLATION (-5)";
  180. case LV1_NO_ENTRY:
  181. return "LV1_NO_ENTRY (-6)";
  182. case LV1_DUPLICATE_ENTRY:
  183. return "LV1_DUPLICATE_ENTRY (-7)";
  184. case LV1_TYPE_MISMATCH:
  185. return "LV1_TYPE_MISMATCH (-8)";
  186. case LV1_BUSY:
  187. return "LV1_BUSY (-9)";
  188. case LV1_EMPTY:
  189. return "LV1_EMPTY (-10)";
  190. case LV1_WRONG_STATE:
  191. return "LV1_WRONG_STATE (-11)";
  192. case -12:
  193. return "** unknown result ** (-12)";
  194. case LV1_NO_MATCH:
  195. return "LV1_NO_MATCH (-13)";
  196. case LV1_ALREADY_CONNECTED:
  197. return "LV1_ALREADY_CONNECTED (-14)";
  198. case LV1_UNSUPPORTED_PARAMETER_VALUE:
  199. return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
  200. case LV1_CONDITION_NOT_SATISFIED:
  201. return "LV1_CONDITION_NOT_SATISFIED (-16)";
  202. case LV1_ILLEGAL_PARAMETER_VALUE:
  203. return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
  204. case LV1_BAD_OPTION:
  205. return "LV1_BAD_OPTION (-18)";
  206. case LV1_IMPLEMENTATION_LIMITATION:
  207. return "LV1_IMPLEMENTATION_LIMITATION (-19)";
  208. case LV1_NOT_IMPLEMENTED:
  209. return "LV1_NOT_IMPLEMENTED (-20)";
  210. case LV1_INVALID_CLASS_ID:
  211. return "LV1_INVALID_CLASS_ID (-21)";
  212. case LV1_CONSTRAINT_NOT_SATISFIED:
  213. return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
  214. case LV1_ALIGNMENT_ERROR:
  215. return "LV1_ALIGNMENT_ERROR (-23)";
  216. case LV1_INTERNAL_ERROR:
  217. return "LV1_INTERNAL_ERROR (-32768)";
  218. default:
  219. BUG();
  220. return "** unknown result **";
  221. };
  222. #else
  223. return "";
  224. #endif
  225. }
  226. #endif