Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 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 | |
| 21 | #if !defined(_ASM_POWERPC_PS3_H) |
| 22 | #define _ASM_POWERPC_PS3_H |
| 23 | |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 24 | #include <linux/init.h> |
| 25 | #include <linux/types.h> |
| 26 | #include <linux/device.h> |
Takashi Yamamoto | 781749a | 2008-01-19 07:32:46 +1100 | [diff] [blame] | 27 | #include "cell-pmu.h" |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 28 | |
Geoff Levand | 66b4495 | 2007-01-26 19:08:21 -0800 | [diff] [blame] | 29 | union ps3_firmware_version { |
| 30 | u64 raw; |
| 31 | struct { |
| 32 | u16 pad; |
| 33 | u16 major; |
| 34 | u16 minor; |
| 35 | u16 rev; |
| 36 | }; |
| 37 | }; |
| 38 | |
Masakazu Mokuno | 1322810 | 2007-06-16 07:18:48 +1000 | [diff] [blame] | 39 | void ps3_get_firmware_version(union ps3_firmware_version *v); |
| 40 | int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev); |
Geoff Levand | 66b4495 | 2007-01-26 19:08:21 -0800 | [diff] [blame] | 41 | |
Geert Uytterhoeven | 098e274 | 2007-01-26 19:08:24 -0800 | [diff] [blame] | 42 | /* 'Other OS' area */ |
| 43 | |
| 44 | enum ps3_param_av_multi_out { |
| 45 | PS3_PARAM_AV_MULTI_OUT_NTSC = 0, |
| 46 | PS3_PARAM_AV_MULTI_OUT_PAL_RGB = 1, |
| 47 | PS3_PARAM_AV_MULTI_OUT_PAL_YCBCR = 2, |
| 48 | PS3_PARAM_AV_MULTI_OUT_SECAM = 3, |
| 49 | }; |
| 50 | |
| 51 | enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void); |
| 52 | |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 53 | /* dma routines */ |
| 54 | |
| 55 | enum ps3_dma_page_size { |
| 56 | PS3_DMA_4K = 12U, |
| 57 | PS3_DMA_64K = 16U, |
| 58 | PS3_DMA_1M = 20U, |
| 59 | PS3_DMA_16M = 24U, |
| 60 | }; |
| 61 | |
| 62 | enum ps3_dma_region_type { |
| 63 | PS3_DMA_OTHER = 0, |
| 64 | PS3_DMA_INTERNAL = 2, |
| 65 | }; |
| 66 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 67 | struct ps3_dma_region_ops; |
| 68 | |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 69 | /** |
| 70 | * struct ps3_dma_region - A per device dma state variables structure |
| 71 | * @did: The HV device id. |
| 72 | * @page_size: The ioc pagesize. |
| 73 | * @region_type: The HV region type. |
| 74 | * @bus_addr: The 'translated' bus address of the region. |
| 75 | * @len: The length in bytes of the region. |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 76 | * @offset: The offset from the start of memory of the region. |
| 77 | * @ioid: The IOID of the device who owns this region |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 78 | * @chunk_list: Opaque variable used by the ioc page manager. |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 79 | * @region_ops: struct ps3_dma_region_ops - dma region operations |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 80 | */ |
| 81 | |
| 82 | struct ps3_dma_region { |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 83 | struct ps3_system_bus_device *dev; |
| 84 | /* device variables */ |
| 85 | const struct ps3_dma_region_ops *region_ops; |
| 86 | unsigned char ioid; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 87 | enum ps3_dma_page_size page_size; |
| 88 | enum ps3_dma_region_type region_type; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 89 | unsigned long len; |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 90 | unsigned long offset; |
| 91 | |
| 92 | /* driver variables (set by ps3_dma_region_create) */ |
| 93 | unsigned long bus_addr; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 94 | struct { |
| 95 | spinlock_t lock; |
| 96 | struct list_head head; |
| 97 | } chunk_list; |
| 98 | }; |
| 99 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 100 | struct ps3_dma_region_ops { |
| 101 | int (*create)(struct ps3_dma_region *); |
| 102 | int (*free)(struct ps3_dma_region *); |
| 103 | int (*map)(struct ps3_dma_region *, |
| 104 | unsigned long virt_addr, |
| 105 | unsigned long len, |
| 106 | unsigned long *bus_addr, |
| 107 | u64 iopte_pp); |
| 108 | int (*unmap)(struct ps3_dma_region *, |
| 109 | unsigned long bus_addr, |
| 110 | unsigned long len); |
| 111 | }; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 112 | /** |
| 113 | * struct ps3_dma_region_init - Helper to initialize structure variables |
| 114 | * |
| 115 | * Helper to properly initialize variables prior to calling |
| 116 | * ps3_system_bus_device_register. |
| 117 | */ |
| 118 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 119 | struct ps3_system_bus_device; |
| 120 | |
| 121 | int ps3_dma_region_init(struct ps3_system_bus_device *dev, |
| 122 | struct ps3_dma_region *r, enum ps3_dma_page_size page_size, |
| 123 | enum ps3_dma_region_type region_type, void *addr, unsigned long len); |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 124 | int ps3_dma_region_create(struct ps3_dma_region *r); |
| 125 | int ps3_dma_region_free(struct ps3_dma_region *r); |
| 126 | int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr, |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 127 | unsigned long len, unsigned long *bus_addr, |
| 128 | u64 iopte_pp); |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 129 | int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr, |
| 130 | unsigned long len); |
| 131 | |
| 132 | /* mmio routines */ |
| 133 | |
| 134 | enum ps3_mmio_page_size { |
| 135 | PS3_MMIO_4K = 12U, |
| 136 | PS3_MMIO_64K = 16U |
| 137 | }; |
| 138 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 139 | struct ps3_mmio_region_ops; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 140 | /** |
| 141 | * struct ps3_mmio_region - a per device mmio state variables structure |
| 142 | * |
| 143 | * Current systems can be supported with a single region per device. |
| 144 | */ |
| 145 | |
| 146 | struct ps3_mmio_region { |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 147 | struct ps3_system_bus_device *dev; |
| 148 | const struct ps3_mmio_region_ops *mmio_ops; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 149 | unsigned long bus_addr; |
| 150 | unsigned long len; |
| 151 | enum ps3_mmio_page_size page_size; |
| 152 | unsigned long lpar_addr; |
| 153 | }; |
| 154 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 155 | struct ps3_mmio_region_ops { |
| 156 | int (*create)(struct ps3_mmio_region *); |
| 157 | int (*free)(struct ps3_mmio_region *); |
| 158 | }; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 159 | /** |
| 160 | * struct ps3_mmio_region_init - Helper to initialize structure variables |
| 161 | * |
| 162 | * Helper to properly initialize variables prior to calling |
| 163 | * ps3_system_bus_device_register. |
| 164 | */ |
| 165 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 166 | int ps3_mmio_region_init(struct ps3_system_bus_device *dev, |
| 167 | struct ps3_mmio_region *r, unsigned long bus_addr, unsigned long len, |
| 168 | enum ps3_mmio_page_size page_size); |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 169 | int ps3_mmio_region_create(struct ps3_mmio_region *r); |
| 170 | int ps3_free_mmio_region(struct ps3_mmio_region *r); |
| 171 | unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr); |
| 172 | |
| 173 | /* inrerrupt routines */ |
| 174 | |
Geoff Levand | 861be32 | 2007-01-26 19:08:08 -0800 | [diff] [blame] | 175 | enum ps3_cpu_binding { |
| 176 | PS3_BINDING_CPU_ANY = -1, |
| 177 | PS3_BINDING_CPU_0 = 0, |
| 178 | PS3_BINDING_CPU_1 = 1, |
| 179 | }; |
| 180 | |
Geoff Levand | dc4f60c | 2007-05-01 07:01:01 +1000 | [diff] [blame] | 181 | int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet, |
Geoff Levand | 861be32 | 2007-01-26 19:08:08 -0800 | [diff] [blame] | 182 | unsigned int *virq); |
Geoff Levand | dc4f60c | 2007-05-01 07:01:01 +1000 | [diff] [blame] | 183 | int ps3_virq_destroy(unsigned int virq); |
| 184 | int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet, |
| 185 | unsigned int *virq); |
| 186 | int ps3_irq_plug_destroy(unsigned int virq); |
| 187 | int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq); |
| 188 | int ps3_event_receive_port_destroy(unsigned int virq); |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 189 | int ps3_send_event_locally(unsigned int virq); |
Geoff Levand | dc4f60c | 2007-05-01 07:01:01 +1000 | [diff] [blame] | 190 | |
| 191 | int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id, |
| 192 | unsigned int *virq); |
| 193 | int ps3_io_irq_destroy(unsigned int virq); |
| 194 | int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp, |
| 195 | unsigned int *virq); |
| 196 | int ps3_vuart_irq_destroy(unsigned int virq); |
| 197 | int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id, |
| 198 | unsigned int class, unsigned int *virq); |
| 199 | int ps3_spe_irq_destroy(unsigned int virq); |
| 200 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 201 | int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev, |
| 202 | enum ps3_cpu_binding cpu, unsigned int *virq); |
| 203 | int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev, |
| 204 | unsigned int virq); |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 205 | |
| 206 | /* lv1 result codes */ |
| 207 | |
| 208 | enum lv1_result { |
| 209 | LV1_SUCCESS = 0, |
| 210 | /* not used -1 */ |
| 211 | LV1_RESOURCE_SHORTAGE = -2, |
| 212 | LV1_NO_PRIVILEGE = -3, |
| 213 | LV1_DENIED_BY_POLICY = -4, |
| 214 | LV1_ACCESS_VIOLATION = -5, |
| 215 | LV1_NO_ENTRY = -6, |
| 216 | LV1_DUPLICATE_ENTRY = -7, |
| 217 | LV1_TYPE_MISMATCH = -8, |
| 218 | LV1_BUSY = -9, |
| 219 | LV1_EMPTY = -10, |
| 220 | LV1_WRONG_STATE = -11, |
| 221 | /* not used -12 */ |
| 222 | LV1_NO_MATCH = -13, |
| 223 | LV1_ALREADY_CONNECTED = -14, |
| 224 | LV1_UNSUPPORTED_PARAMETER_VALUE = -15, |
| 225 | LV1_CONDITION_NOT_SATISFIED = -16, |
| 226 | LV1_ILLEGAL_PARAMETER_VALUE = -17, |
| 227 | LV1_BAD_OPTION = -18, |
| 228 | LV1_IMPLEMENTATION_LIMITATION = -19, |
| 229 | LV1_NOT_IMPLEMENTED = -20, |
| 230 | LV1_INVALID_CLASS_ID = -21, |
| 231 | LV1_CONSTRAINT_NOT_SATISFIED = -22, |
| 232 | LV1_ALIGNMENT_ERROR = -23, |
Geert Uytterhoeven | 06462d9 | 2007-09-12 18:43:16 +1000 | [diff] [blame] | 233 | LV1_HARDWARE_ERROR = -24, |
| 234 | LV1_INVALID_DATA_FORMAT = -25, |
| 235 | LV1_INVALID_OPERATION = -26, |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 236 | LV1_INTERNAL_ERROR = -32768, |
| 237 | }; |
| 238 | |
| 239 | static inline const char* ps3_result(int result) |
| 240 | { |
| 241 | #if defined(DEBUG) |
| 242 | switch (result) { |
| 243 | case LV1_SUCCESS: |
| 244 | return "LV1_SUCCESS (0)"; |
| 245 | case -1: |
| 246 | return "** unknown result ** (-1)"; |
| 247 | case LV1_RESOURCE_SHORTAGE: |
| 248 | return "LV1_RESOURCE_SHORTAGE (-2)"; |
| 249 | case LV1_NO_PRIVILEGE: |
| 250 | return "LV1_NO_PRIVILEGE (-3)"; |
| 251 | case LV1_DENIED_BY_POLICY: |
| 252 | return "LV1_DENIED_BY_POLICY (-4)"; |
| 253 | case LV1_ACCESS_VIOLATION: |
| 254 | return "LV1_ACCESS_VIOLATION (-5)"; |
| 255 | case LV1_NO_ENTRY: |
| 256 | return "LV1_NO_ENTRY (-6)"; |
| 257 | case LV1_DUPLICATE_ENTRY: |
| 258 | return "LV1_DUPLICATE_ENTRY (-7)"; |
| 259 | case LV1_TYPE_MISMATCH: |
| 260 | return "LV1_TYPE_MISMATCH (-8)"; |
| 261 | case LV1_BUSY: |
| 262 | return "LV1_BUSY (-9)"; |
| 263 | case LV1_EMPTY: |
| 264 | return "LV1_EMPTY (-10)"; |
| 265 | case LV1_WRONG_STATE: |
| 266 | return "LV1_WRONG_STATE (-11)"; |
| 267 | case -12: |
| 268 | return "** unknown result ** (-12)"; |
| 269 | case LV1_NO_MATCH: |
| 270 | return "LV1_NO_MATCH (-13)"; |
| 271 | case LV1_ALREADY_CONNECTED: |
| 272 | return "LV1_ALREADY_CONNECTED (-14)"; |
| 273 | case LV1_UNSUPPORTED_PARAMETER_VALUE: |
| 274 | return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)"; |
| 275 | case LV1_CONDITION_NOT_SATISFIED: |
| 276 | return "LV1_CONDITION_NOT_SATISFIED (-16)"; |
| 277 | case LV1_ILLEGAL_PARAMETER_VALUE: |
| 278 | return "LV1_ILLEGAL_PARAMETER_VALUE (-17)"; |
| 279 | case LV1_BAD_OPTION: |
| 280 | return "LV1_BAD_OPTION (-18)"; |
| 281 | case LV1_IMPLEMENTATION_LIMITATION: |
| 282 | return "LV1_IMPLEMENTATION_LIMITATION (-19)"; |
| 283 | case LV1_NOT_IMPLEMENTED: |
| 284 | return "LV1_NOT_IMPLEMENTED (-20)"; |
| 285 | case LV1_INVALID_CLASS_ID: |
| 286 | return "LV1_INVALID_CLASS_ID (-21)"; |
| 287 | case LV1_CONSTRAINT_NOT_SATISFIED: |
| 288 | return "LV1_CONSTRAINT_NOT_SATISFIED (-22)"; |
| 289 | case LV1_ALIGNMENT_ERROR: |
| 290 | return "LV1_ALIGNMENT_ERROR (-23)"; |
Geert Uytterhoeven | 06462d9 | 2007-09-12 18:43:16 +1000 | [diff] [blame] | 291 | case LV1_HARDWARE_ERROR: |
| 292 | return "LV1_HARDWARE_ERROR (-24)"; |
| 293 | case LV1_INVALID_DATA_FORMAT: |
| 294 | return "LV1_INVALID_DATA_FORMAT (-25)"; |
| 295 | case LV1_INVALID_OPERATION: |
| 296 | return "LV1_INVALID_OPERATION (-26)"; |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 297 | case LV1_INTERNAL_ERROR: |
| 298 | return "LV1_INTERNAL_ERROR (-32768)"; |
| 299 | default: |
| 300 | BUG(); |
| 301 | return "** unknown result **"; |
| 302 | }; |
| 303 | #else |
| 304 | return ""; |
| 305 | #endif |
| 306 | } |
| 307 | |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 308 | /* system bus routines */ |
| 309 | |
| 310 | enum ps3_match_id { |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 311 | PS3_MATCH_ID_EHCI = 1, |
| 312 | PS3_MATCH_ID_OHCI = 2, |
| 313 | PS3_MATCH_ID_GELIC = 3, |
| 314 | PS3_MATCH_ID_AV_SETTINGS = 4, |
| 315 | PS3_MATCH_ID_SYSTEM_MANAGER = 5, |
| 316 | PS3_MATCH_ID_STOR_DISK = 6, |
| 317 | PS3_MATCH_ID_STOR_ROM = 7, |
| 318 | PS3_MATCH_ID_STOR_FLASH = 8, |
| 319 | PS3_MATCH_ID_SOUND = 9, |
| 320 | PS3_MATCH_ID_GRAPHICS = 10, |
Geoff Levand | ed75700 | 2008-01-19 07:32:38 +1100 | [diff] [blame] | 321 | PS3_MATCH_ID_LPM = 11, |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | #define PS3_MODULE_ALIAS_EHCI "ps3:1" |
| 325 | #define PS3_MODULE_ALIAS_OHCI "ps3:2" |
| 326 | #define PS3_MODULE_ALIAS_GELIC "ps3:3" |
| 327 | #define PS3_MODULE_ALIAS_AV_SETTINGS "ps3:4" |
| 328 | #define PS3_MODULE_ALIAS_SYSTEM_MANAGER "ps3:5" |
| 329 | #define PS3_MODULE_ALIAS_STOR_DISK "ps3:6" |
| 330 | #define PS3_MODULE_ALIAS_STOR_ROM "ps3:7" |
| 331 | #define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8" |
| 332 | #define PS3_MODULE_ALIAS_SOUND "ps3:9" |
| 333 | #define PS3_MODULE_ALIAS_GRAPHICS "ps3:10" |
Geoff Levand | ed75700 | 2008-01-19 07:32:38 +1100 | [diff] [blame] | 334 | #define PS3_MODULE_ALIAS_LPM "ps3:11" |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 335 | |
| 336 | enum ps3_system_bus_device_type { |
| 337 | PS3_DEVICE_TYPE_IOC0 = 1, |
| 338 | PS3_DEVICE_TYPE_SB, |
| 339 | PS3_DEVICE_TYPE_VUART, |
Geoff Levand | ed75700 | 2008-01-19 07:32:38 +1100 | [diff] [blame] | 340 | PS3_DEVICE_TYPE_LPM, |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | /** |
| 344 | * struct ps3_system_bus_device - a device on the system bus |
| 345 | */ |
| 346 | |
| 347 | struct ps3_system_bus_device { |
| 348 | enum ps3_match_id match_id; |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 349 | enum ps3_system_bus_device_type dev_type; |
| 350 | |
Geert Uytterhoeven | 034e0ab | 2008-01-19 07:30:09 +1100 | [diff] [blame] | 351 | u64 bus_id; /* SB */ |
| 352 | u64 dev_id; /* SB */ |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 353 | unsigned int interrupt_id; /* SB */ |
| 354 | struct ps3_dma_region *d_region; /* SB, IOC0 */ |
| 355 | struct ps3_mmio_region *m_region; /* SB, IOC0*/ |
| 356 | unsigned int port_number; /* VUART */ |
Geoff Levand | ed75700 | 2008-01-19 07:32:38 +1100 | [diff] [blame] | 357 | struct { /* LPM */ |
| 358 | u64 node_id; |
| 359 | u64 pu_id; |
| 360 | u64 rights; |
| 361 | } lpm; |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 362 | |
| 363 | /* struct iommu_table *iommu_table; -- waiting for BenH's cleanups */ |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 364 | struct device core; |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 365 | void *driver_priv; /* private driver variables */ |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 366 | }; |
| 367 | |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 368 | int ps3_open_hv_device(struct ps3_system_bus_device *dev); |
| 369 | int ps3_close_hv_device(struct ps3_system_bus_device *dev); |
| 370 | |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 371 | /** |
| 372 | * struct ps3_system_bus_driver - a driver for a device on the system bus |
| 373 | */ |
| 374 | |
| 375 | struct ps3_system_bus_driver { |
| 376 | enum ps3_match_id match_id; |
| 377 | struct device_driver core; |
| 378 | int (*probe)(struct ps3_system_bus_device *); |
| 379 | int (*remove)(struct ps3_system_bus_device *); |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 380 | int (*shutdown)(struct ps3_system_bus_device *); |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 381 | /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */ |
| 382 | /* int (*resume)(struct ps3_system_bus_device *); */ |
| 383 | }; |
| 384 | |
| 385 | int ps3_system_bus_device_register(struct ps3_system_bus_device *dev); |
| 386 | int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv); |
| 387 | void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv); |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 388 | |
| 389 | static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv( |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 390 | struct device_driver *_drv) |
| 391 | { |
| 392 | return container_of(_drv, struct ps3_system_bus_driver, core); |
| 393 | } |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 394 | static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev( |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 395 | struct device *_dev) |
| 396 | { |
| 397 | return container_of(_dev, struct ps3_system_bus_device, core); |
| 398 | } |
Geoff Levand | 6bb5cf1 | 2007-06-16 07:52:02 +1000 | [diff] [blame] | 399 | static inline struct ps3_system_bus_driver * |
| 400 | ps3_system_bus_dev_to_system_bus_drv(struct ps3_system_bus_device *_dev) |
| 401 | { |
| 402 | BUG_ON(!_dev); |
| 403 | BUG_ON(!_dev->core.driver); |
| 404 | return ps3_drv_to_system_bus_drv(_dev->core.driver); |
| 405 | } |
Geoff Levand | a3d4d64 | 2006-11-23 00:47:00 +0100 | [diff] [blame] | 406 | |
| 407 | /** |
| 408 | * ps3_system_bus_set_drvdata - |
| 409 | * @dev: device structure |
| 410 | * @data: Data to set |
| 411 | */ |
| 412 | |
| 413 | static inline void ps3_system_bus_set_driver_data( |
| 414 | struct ps3_system_bus_device *dev, void *data) |
| 415 | { |
| 416 | dev->core.driver_data = data; |
| 417 | } |
| 418 | static inline void *ps3_system_bus_get_driver_data( |
| 419 | struct ps3_system_bus_device *dev) |
| 420 | { |
| 421 | return dev->core.driver_data; |
| 422 | } |
| 423 | |
| 424 | /* These two need global scope for get_dma_ops(). */ |
| 425 | |
| 426 | extern struct bus_type ps3_system_bus_type; |
| 427 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 428 | /* system manager */ |
| 429 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 430 | struct ps3_sys_manager_ops { |
| 431 | struct ps3_system_bus_device *dev; |
| 432 | void (*power_off)(struct ps3_system_bus_device *dev); |
| 433 | void (*restart)(struct ps3_system_bus_device *dev); |
| 434 | }; |
| 435 | |
| 436 | void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 437 | void ps3_sys_manager_power_off(void); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 438 | void ps3_sys_manager_restart(void); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 439 | |
Geert Uytterhoeven | fbdb3e5b | 2007-02-12 00:55:22 -0800 | [diff] [blame] | 440 | struct ps3_prealloc { |
| 441 | const char *name; |
| 442 | void *address; |
| 443 | unsigned long size; |
| 444 | unsigned long align; |
| 445 | }; |
| 446 | |
| 447 | extern struct ps3_prealloc ps3fb_videomemory; |
Geert Uytterhoeven | 32d7331 | 2007-06-22 00:14:20 +1000 | [diff] [blame] | 448 | extern struct ps3_prealloc ps3flash_bounce_buffer; |
Geert Uytterhoeven | fbdb3e5b | 2007-02-12 00:55:22 -0800 | [diff] [blame] | 449 | |
Takashi Yamamoto | 781749a | 2008-01-19 07:32:46 +1100 | [diff] [blame] | 450 | /* logical performance monitor */ |
| 451 | |
| 452 | /** |
| 453 | * enum ps3_lpm_rights - Rigths granted by the system policy module. |
| 454 | * |
| 455 | * @PS3_LPM_RIGHTS_USE_LPM: The right to use the lpm. |
| 456 | * @PS3_LPM_RIGHTS_USE_TB: The right to use the internal trace buffer. |
| 457 | */ |
| 458 | |
| 459 | enum ps3_lpm_rights { |
| 460 | PS3_LPM_RIGHTS_USE_LPM = 0x001, |
| 461 | PS3_LPM_RIGHTS_USE_TB = 0x100, |
| 462 | }; |
| 463 | |
| 464 | /** |
| 465 | * enum ps3_lpm_tb_type - Type of trace buffer lv1 should use. |
| 466 | * |
| 467 | * @PS3_LPM_TB_TYPE_NONE: Do not use a trace buffer. |
| 468 | * @PS3_LPM_RIGHTS_USE_TB: Use the lv1 internal trace buffer. Must have |
| 469 | * rights @PS3_LPM_RIGHTS_USE_TB. |
| 470 | */ |
| 471 | |
| 472 | enum ps3_lpm_tb_type { |
| 473 | PS3_LPM_TB_TYPE_NONE = 0, |
| 474 | PS3_LPM_TB_TYPE_INTERNAL = 1, |
| 475 | }; |
| 476 | |
| 477 | int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache, |
| 478 | u64 tb_cache_size); |
| 479 | int ps3_lpm_close(void); |
| 480 | int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count, |
| 481 | unsigned long *bytes_copied); |
| 482 | int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf, |
| 483 | unsigned long count, unsigned long *bytes_copied); |
| 484 | void ps3_set_bookmark(u64 bookmark); |
| 485 | void ps3_set_pm_bookmark(u64 tag, u64 incident, u64 th_id); |
| 486 | int ps3_set_signal(u64 rtas_signal_group, u8 signal_bit, u16 sub_unit, |
| 487 | u8 bus_word); |
| 488 | |
| 489 | u32 ps3_read_phys_ctr(u32 cpu, u32 phys_ctr); |
| 490 | void ps3_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val); |
| 491 | u32 ps3_read_ctr(u32 cpu, u32 ctr); |
| 492 | void ps3_write_ctr(u32 cpu, u32 ctr, u32 val); |
| 493 | |
| 494 | u32 ps3_read_pm07_control(u32 cpu, u32 ctr); |
| 495 | void ps3_write_pm07_control(u32 cpu, u32 ctr, u32 val); |
| 496 | u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg); |
| 497 | void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val); |
| 498 | |
| 499 | u32 ps3_get_ctr_size(u32 cpu, u32 phys_ctr); |
| 500 | void ps3_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size); |
| 501 | |
| 502 | void ps3_enable_pm(u32 cpu); |
| 503 | void ps3_disable_pm(u32 cpu); |
| 504 | void ps3_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask); |
| 505 | void ps3_disable_pm_interrupts(u32 cpu); |
| 506 | |
| 507 | u32 ps3_get_and_clear_pm_interrupts(u32 cpu); |
| 508 | void ps3_sync_irq(int node); |
| 509 | u32 ps3_get_hw_thread_id(int cpu); |
| 510 | u64 ps3_get_spe_id(void *arg); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 511 | |
Geoff Levand | f58a9d1 | 2006-11-23 00:46:51 +0100 | [diff] [blame] | 512 | #endif |