[POWERPC] ps3: remove unneeded header include
[linux-2.6/verdex.git] / include / asm-powerpc / ps3.h
blob59ae9d7bf6a71589564bff0b4eba66a21def5f92
1 /*
2 * PS3 platform declarations.
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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.
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.
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
21 #if !defined(_ASM_POWERPC_PS3_H)
22 #define _ASM_POWERPC_PS3_H
24 #include <linux/init.h>
25 #include <linux/types.h>
26 #include <linux/device.h>
27 #include <scsi/scsi.h>
29 union ps3_firmware_version {
30 u64 raw;
31 struct {
32 u16 pad;
33 u16 major;
34 u16 minor;
35 u16 rev;
39 int ps3_get_firmware_version(union ps3_firmware_version *v);
41 /* 'Other OS' area */
43 enum ps3_param_av_multi_out {
44 PS3_PARAM_AV_MULTI_OUT_NTSC = 0,
45 PS3_PARAM_AV_MULTI_OUT_PAL_RGB = 1,
46 PS3_PARAM_AV_MULTI_OUT_PAL_YCBCR = 2,
47 PS3_PARAM_AV_MULTI_OUT_SECAM = 3,
50 enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);
52 /**
53 * struct ps3_device_id - HV bus device identifier from the system repository
54 * @bus_id: HV bus id, {1..} (zero invalid)
55 * @dev_id: HV device id, {0..}
58 struct ps3_device_id {
59 unsigned int bus_id;
60 unsigned int dev_id;
64 /* dma routines */
66 enum ps3_dma_page_size {
67 PS3_DMA_4K = 12U,
68 PS3_DMA_64K = 16U,
69 PS3_DMA_1M = 20U,
70 PS3_DMA_16M = 24U,
73 enum ps3_dma_region_type {
74 PS3_DMA_OTHER = 0,
75 PS3_DMA_INTERNAL = 2,
78 /**
79 * struct ps3_dma_region - A per device dma state variables structure
80 * @did: The HV device id.
81 * @page_size: The ioc pagesize.
82 * @region_type: The HV region type.
83 * @bus_addr: The 'translated' bus address of the region.
84 * @len: The length in bytes of the region.
85 * @chunk_list: Opaque variable used by the ioc page manager.
88 struct ps3_dma_region {
89 struct ps3_device_id did;
90 enum ps3_dma_page_size page_size;
91 enum ps3_dma_region_type region_type;
92 unsigned long bus_addr;
93 unsigned long len;
94 struct {
95 spinlock_t lock;
96 struct list_head head;
97 } chunk_list;
101 * struct ps3_dma_region_init - Helper to initialize structure variables
103 * Helper to properly initialize variables prior to calling
104 * ps3_system_bus_device_register.
107 static inline void ps3_dma_region_init(struct ps3_dma_region *r,
108 const struct ps3_device_id* did, enum ps3_dma_page_size page_size,
109 enum ps3_dma_region_type region_type)
111 r->did = *did;
112 r->page_size = page_size;
113 r->region_type = region_type;
115 int ps3_dma_region_create(struct ps3_dma_region *r);
116 int ps3_dma_region_free(struct ps3_dma_region *r);
117 int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
118 unsigned long len, unsigned long *bus_addr);
119 int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr,
120 unsigned long len);
122 /* mmio routines */
124 enum ps3_mmio_page_size {
125 PS3_MMIO_4K = 12U,
126 PS3_MMIO_64K = 16U
130 * struct ps3_mmio_region - a per device mmio state variables structure
132 * Current systems can be supported with a single region per device.
135 struct ps3_mmio_region {
136 struct ps3_device_id did;
137 unsigned long bus_addr;
138 unsigned long len;
139 enum ps3_mmio_page_size page_size;
140 unsigned long lpar_addr;
144 * struct ps3_mmio_region_init - Helper to initialize structure variables
146 * Helper to properly initialize variables prior to calling
147 * ps3_system_bus_device_register.
150 static inline void ps3_mmio_region_init(struct ps3_mmio_region *r,
151 const struct ps3_device_id* did, unsigned long bus_addr,
152 unsigned long len, enum ps3_mmio_page_size page_size)
154 r->did = *did;
155 r->bus_addr = bus_addr;
156 r->len = len;
157 r->page_size = page_size;
159 int ps3_mmio_region_create(struct ps3_mmio_region *r);
160 int ps3_free_mmio_region(struct ps3_mmio_region *r);
161 unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
163 /* inrerrupt routines */
165 enum ps3_cpu_binding {
166 PS3_BINDING_CPU_ANY = -1,
167 PS3_BINDING_CPU_0 = 0,
168 PS3_BINDING_CPU_1 = 1,
171 int ps3_alloc_io_irq(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
172 unsigned int *virq);
173 int ps3_free_io_irq(unsigned int virq);
174 int ps3_alloc_event_irq(enum ps3_cpu_binding cpu, unsigned int *virq);
175 int ps3_free_event_irq(unsigned int virq);
176 int ps3_send_event_locally(unsigned int virq);
177 int ps3_connect_event_irq(enum ps3_cpu_binding cpu,
178 const struct ps3_device_id *did, unsigned int interrupt_id,
179 unsigned int *virq);
180 int ps3_disconnect_event_irq(const struct ps3_device_id *did,
181 unsigned int interrupt_id, unsigned int virq);
182 int ps3_alloc_vuart_irq(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
183 unsigned int *virq);
184 int ps3_free_vuart_irq(unsigned int virq);
185 int ps3_alloc_spe_irq(enum ps3_cpu_binding cpu, unsigned long spe_id,
186 unsigned int class, unsigned int *virq);
187 int ps3_free_spe_irq(unsigned int virq);
188 int ps3_alloc_irq(enum ps3_cpu_binding cpu, unsigned long outlet,
189 unsigned int *virq);
190 int ps3_free_irq(unsigned int virq);
192 /* lv1 result codes */
194 enum lv1_result {
195 LV1_SUCCESS = 0,
196 /* not used -1 */
197 LV1_RESOURCE_SHORTAGE = -2,
198 LV1_NO_PRIVILEGE = -3,
199 LV1_DENIED_BY_POLICY = -4,
200 LV1_ACCESS_VIOLATION = -5,
201 LV1_NO_ENTRY = -6,
202 LV1_DUPLICATE_ENTRY = -7,
203 LV1_TYPE_MISMATCH = -8,
204 LV1_BUSY = -9,
205 LV1_EMPTY = -10,
206 LV1_WRONG_STATE = -11,
207 /* not used -12 */
208 LV1_NO_MATCH = -13,
209 LV1_ALREADY_CONNECTED = -14,
210 LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
211 LV1_CONDITION_NOT_SATISFIED = -16,
212 LV1_ILLEGAL_PARAMETER_VALUE = -17,
213 LV1_BAD_OPTION = -18,
214 LV1_IMPLEMENTATION_LIMITATION = -19,
215 LV1_NOT_IMPLEMENTED = -20,
216 LV1_INVALID_CLASS_ID = -21,
217 LV1_CONSTRAINT_NOT_SATISFIED = -22,
218 LV1_ALIGNMENT_ERROR = -23,
219 LV1_INTERNAL_ERROR = -32768,
222 static inline const char* ps3_result(int result)
224 #if defined(DEBUG)
225 switch (result) {
226 case LV1_SUCCESS:
227 return "LV1_SUCCESS (0)";
228 case -1:
229 return "** unknown result ** (-1)";
230 case LV1_RESOURCE_SHORTAGE:
231 return "LV1_RESOURCE_SHORTAGE (-2)";
232 case LV1_NO_PRIVILEGE:
233 return "LV1_NO_PRIVILEGE (-3)";
234 case LV1_DENIED_BY_POLICY:
235 return "LV1_DENIED_BY_POLICY (-4)";
236 case LV1_ACCESS_VIOLATION:
237 return "LV1_ACCESS_VIOLATION (-5)";
238 case LV1_NO_ENTRY:
239 return "LV1_NO_ENTRY (-6)";
240 case LV1_DUPLICATE_ENTRY:
241 return "LV1_DUPLICATE_ENTRY (-7)";
242 case LV1_TYPE_MISMATCH:
243 return "LV1_TYPE_MISMATCH (-8)";
244 case LV1_BUSY:
245 return "LV1_BUSY (-9)";
246 case LV1_EMPTY:
247 return "LV1_EMPTY (-10)";
248 case LV1_WRONG_STATE:
249 return "LV1_WRONG_STATE (-11)";
250 case -12:
251 return "** unknown result ** (-12)";
252 case LV1_NO_MATCH:
253 return "LV1_NO_MATCH (-13)";
254 case LV1_ALREADY_CONNECTED:
255 return "LV1_ALREADY_CONNECTED (-14)";
256 case LV1_UNSUPPORTED_PARAMETER_VALUE:
257 return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
258 case LV1_CONDITION_NOT_SATISFIED:
259 return "LV1_CONDITION_NOT_SATISFIED (-16)";
260 case LV1_ILLEGAL_PARAMETER_VALUE:
261 return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
262 case LV1_BAD_OPTION:
263 return "LV1_BAD_OPTION (-18)";
264 case LV1_IMPLEMENTATION_LIMITATION:
265 return "LV1_IMPLEMENTATION_LIMITATION (-19)";
266 case LV1_NOT_IMPLEMENTED:
267 return "LV1_NOT_IMPLEMENTED (-20)";
268 case LV1_INVALID_CLASS_ID:
269 return "LV1_INVALID_CLASS_ID (-21)";
270 case LV1_CONSTRAINT_NOT_SATISFIED:
271 return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
272 case LV1_ALIGNMENT_ERROR:
273 return "LV1_ALIGNMENT_ERROR (-23)";
274 case LV1_INTERNAL_ERROR:
275 return "LV1_INTERNAL_ERROR (-32768)";
276 default:
277 BUG();
278 return "** unknown result **";
280 #else
281 return "";
282 #endif
285 /* repository bus info */
287 enum ps3_bus_type {
288 PS3_BUS_TYPE_SB = 4,
289 PS3_BUS_TYPE_STORAGE = 5,
292 enum ps3_dev_type {
293 PS3_DEV_TYPE_STOR_DISK = TYPE_DISK, /* 0 */
294 PS3_DEV_TYPE_SB_GELIC = 3,
295 PS3_DEV_TYPE_SB_USB = 4,
296 PS3_DEV_TYPE_STOR_ROM = TYPE_ROM, /* 5 */
297 PS3_DEV_TYPE_SB_GPIO = 6,
298 PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC, /* 14 */
301 int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
302 u64 *value);
303 int ps3_repository_read_bus_id(unsigned int bus_index, unsigned int *bus_id);
304 int ps3_repository_read_bus_type(unsigned int bus_index,
305 enum ps3_bus_type *bus_type);
306 int ps3_repository_read_bus_num_dev(unsigned int bus_index,
307 unsigned int *num_dev);
309 /* repository bus device info */
311 enum ps3_interrupt_type {
312 PS3_INTERRUPT_TYPE_EVENT_PORT = 2,
313 PS3_INTERRUPT_TYPE_SB_OHCI = 3,
314 PS3_INTERRUPT_TYPE_SB_EHCI = 4,
315 PS3_INTERRUPT_TYPE_OTHER = 5,
318 enum ps3_reg_type {
319 PS3_REG_TYPE_SB_OHCI = 3,
320 PS3_REG_TYPE_SB_EHCI = 4,
321 PS3_REG_TYPE_SB_GPIO = 5,
324 int ps3_repository_read_dev_str(unsigned int bus_index,
325 unsigned int dev_index, const char *dev_str, u64 *value);
326 int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
327 unsigned int *dev_id);
328 int ps3_repository_read_dev_type(unsigned int bus_index,
329 unsigned int dev_index, enum ps3_dev_type *dev_type);
330 int ps3_repository_read_dev_intr(unsigned int bus_index,
331 unsigned int dev_index, unsigned int intr_index,
332 enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id);
333 int ps3_repository_read_dev_reg_type(unsigned int bus_index,
334 unsigned int dev_index, unsigned int reg_index,
335 enum ps3_reg_type *reg_type);
336 int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
337 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr,
338 u64 *len);
339 int ps3_repository_read_dev_reg(unsigned int bus_index,
340 unsigned int dev_index, unsigned int reg_index,
341 enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len);
343 /* repository bus enumerators */
345 struct ps3_repository_device {
346 unsigned int bus_index;
347 unsigned int dev_index;
348 struct ps3_device_id did;
351 int ps3_repository_find_device(enum ps3_bus_type bus_type,
352 enum ps3_dev_type dev_type,
353 const struct ps3_repository_device *start_dev,
354 struct ps3_repository_device *dev);
355 static inline int ps3_repository_find_first_device(
356 enum ps3_bus_type bus_type, enum ps3_dev_type dev_type,
357 struct ps3_repository_device *dev)
359 return ps3_repository_find_device(bus_type, dev_type, NULL, dev);
361 int ps3_repository_find_interrupt(const struct ps3_repository_device *dev,
362 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
363 int ps3_repository_find_reg(const struct ps3_repository_device *dev,
364 enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len);
366 /* repository block device info */
368 int ps3_repository_read_stor_dev_port(unsigned int bus_index,
369 unsigned int dev_index, u64 *port);
370 int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
371 unsigned int dev_index, u64 *blk_size);
372 int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
373 unsigned int dev_index, u64 *num_blocks);
374 int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
375 unsigned int dev_index, unsigned int *num_regions);
376 int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
377 unsigned int dev_index, unsigned int region_index,
378 unsigned int *region_id);
379 int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
380 unsigned int dev_index, unsigned int region_index, u64 *region_size);
381 int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
382 unsigned int dev_index, unsigned int region_index, u64 *region_start);
383 int ps3_repository_read_stor_dev_info(unsigned int bus_index,
384 unsigned int dev_index, u64 *port, u64 *blk_size,
385 u64 *num_blocks, unsigned int *num_regions);
386 int ps3_repository_read_stor_dev_region(unsigned int bus_index,
387 unsigned int dev_index, unsigned int region_index,
388 unsigned int *region_id, u64 *region_start, u64 *region_size);
390 /* repository pu and memory info */
392 int ps3_repository_read_num_pu(unsigned int *num_pu);
393 int ps3_repository_read_ppe_id(unsigned int *pu_index, unsigned int *ppe_id);
394 int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
395 int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
396 int ps3_repository_read_region_total(u64 *region_total);
397 int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
398 u64 *region_total);
400 /* repository pme info */
402 int ps3_repository_read_num_be(unsigned int *num_be);
403 int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
404 int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
405 int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
407 /* repository 'Other OS' area */
409 int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
410 int ps3_repository_read_boot_dat_size(unsigned int *size);
411 int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size);
413 /* repository spu info */
416 * enum spu_resource_type - Type of spu resource.
417 * @spu_resource_type_shared: Logical spu is shared with other partions.
418 * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
420 * Returned by ps3_repository_read_spu_resource_id().
423 enum ps3_spu_resource_type {
424 PS3_SPU_RESOURCE_TYPE_SHARED = 0,
425 PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
428 int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
429 int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
430 int ps3_repository_read_spu_resource_id(unsigned int res_index,
431 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
434 /* system bus routines */
436 enum ps3_match_id {
437 PS3_MATCH_ID_EHCI = 1,
438 PS3_MATCH_ID_OHCI,
439 PS3_MATCH_ID_GELIC,
440 PS3_MATCH_ID_AV_SETTINGS,
441 PS3_MATCH_ID_SYSTEM_MANAGER,
445 * struct ps3_system_bus_device - a device on the system bus
448 struct ps3_system_bus_device {
449 enum ps3_match_id match_id;
450 struct ps3_device_id did;
451 unsigned int interrupt_id;
452 /* struct iommu_table *iommu_table; -- waiting for Ben's cleanups */
453 struct ps3_dma_region *d_region;
454 struct ps3_mmio_region *m_region;
455 struct device core;
459 * struct ps3_system_bus_driver - a driver for a device on the system bus
462 struct ps3_system_bus_driver {
463 enum ps3_match_id match_id;
464 struct device_driver core;
465 int (*probe)(struct ps3_system_bus_device *);
466 int (*remove)(struct ps3_system_bus_device *);
467 /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
468 /* int (*resume)(struct ps3_system_bus_device *); */
471 int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
472 int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
473 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
474 static inline struct ps3_system_bus_driver *to_ps3_system_bus_driver(
475 struct device_driver *_drv)
477 return container_of(_drv, struct ps3_system_bus_driver, core);
479 static inline struct ps3_system_bus_device *to_ps3_system_bus_device(
480 struct device *_dev)
482 return container_of(_dev, struct ps3_system_bus_device, core);
486 * ps3_system_bus_set_drvdata -
487 * @dev: device structure
488 * @data: Data to set
491 static inline void ps3_system_bus_set_driver_data(
492 struct ps3_system_bus_device *dev, void *data)
494 dev->core.driver_data = data;
496 static inline void *ps3_system_bus_get_driver_data(
497 struct ps3_system_bus_device *dev)
499 return dev->core.driver_data;
502 /* These two need global scope for get_dma_ops(). */
504 extern struct bus_type ps3_system_bus_type;
506 #endif