blob: cdb6fd814de8880541d2c4130b33ea7e7b9f6234 [file] [log] [blame]
Geoff Levandf58a9d12006-11-23 00:46:51 +01001/*
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 Levandf58a9d12006-11-23 00:46:51 +010024#include <linux/init.h>
25#include <linux/types.h>
26#include <linux/device.h>
Takashi Yamamoto781749a2008-01-19 07:32:46 +110027#include "cell-pmu.h"
Geoff Levandf58a9d12006-11-23 00:46:51 +010028
Geoff Levand66b44952007-01-26 19:08:21 -080029union ps3_firmware_version {
30 u64 raw;
31 struct {
32 u16 pad;
33 u16 major;
34 u16 minor;
35 u16 rev;
36 };
37};
38
Masakazu Mokuno13228102007-06-16 07:18:48 +100039void ps3_get_firmware_version(union ps3_firmware_version *v);
40int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev);
Geoff Levand66b44952007-01-26 19:08:21 -080041
Geert Uytterhoeven098e2742007-01-26 19:08:24 -080042/* 'Other OS' area */
43
44enum 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
51enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);
52
Geert Uytterhoeven0b5f0372009-02-24 14:04:20 +010053extern u64 ps3_os_area_get_rtc_diff(void);
54extern void ps3_os_area_set_rtc_diff(u64 rtc_diff);
55
Geoff Levandf58a9d12006-11-23 00:46:51 +010056/* dma routines */
57
58enum ps3_dma_page_size {
59 PS3_DMA_4K = 12U,
60 PS3_DMA_64K = 16U,
61 PS3_DMA_1M = 20U,
62 PS3_DMA_16M = 24U,
63};
64
65enum ps3_dma_region_type {
66 PS3_DMA_OTHER = 0,
67 PS3_DMA_INTERNAL = 2,
68};
69
Geoff Levand6bb5cf12007-06-16 07:52:02 +100070struct ps3_dma_region_ops;
71
Geoff Levandf58a9d12006-11-23 00:46:51 +010072/**
73 * struct ps3_dma_region - A per device dma state variables structure
74 * @did: The HV device id.
75 * @page_size: The ioc pagesize.
76 * @region_type: The HV region type.
77 * @bus_addr: The 'translated' bus address of the region.
78 * @len: The length in bytes of the region.
Geoff Levand6bb5cf12007-06-16 07:52:02 +100079 * @offset: The offset from the start of memory of the region.
80 * @ioid: The IOID of the device who owns this region
Geoff Levandf58a9d12006-11-23 00:46:51 +010081 * @chunk_list: Opaque variable used by the ioc page manager.
Geoff Levand6bb5cf12007-06-16 07:52:02 +100082 * @region_ops: struct ps3_dma_region_ops - dma region operations
Geoff Levandf58a9d12006-11-23 00:46:51 +010083 */
84
85struct ps3_dma_region {
Geoff Levand6bb5cf12007-06-16 07:52:02 +100086 struct ps3_system_bus_device *dev;
87 /* device variables */
88 const struct ps3_dma_region_ops *region_ops;
89 unsigned char ioid;
Geoff Levandf58a9d12006-11-23 00:46:51 +010090 enum ps3_dma_page_size page_size;
91 enum ps3_dma_region_type region_type;
Geoff Levandf58a9d12006-11-23 00:46:51 +010092 unsigned long len;
Geoff Levand6bb5cf12007-06-16 07:52:02 +100093 unsigned long offset;
94
95 /* driver variables (set by ps3_dma_region_create) */
96 unsigned long bus_addr;
Geoff Levandf58a9d12006-11-23 00:46:51 +010097 struct {
98 spinlock_t lock;
99 struct list_head head;
100 } chunk_list;
101};
102
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000103struct ps3_dma_region_ops {
104 int (*create)(struct ps3_dma_region *);
105 int (*free)(struct ps3_dma_region *);
106 int (*map)(struct ps3_dma_region *,
107 unsigned long virt_addr,
108 unsigned long len,
Stephen Rothwell494fd072009-01-13 19:58:10 +0000109 dma_addr_t *bus_addr,
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000110 u64 iopte_pp);
111 int (*unmap)(struct ps3_dma_region *,
Stephen Rothwell494fd072009-01-13 19:58:10 +0000112 dma_addr_t bus_addr,
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000113 unsigned long len);
114};
Geoff Levandf58a9d12006-11-23 00:46:51 +0100115/**
116 * struct ps3_dma_region_init - Helper to initialize structure variables
117 *
118 * Helper to properly initialize variables prior to calling
119 * ps3_system_bus_device_register.
120 */
121
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000122struct ps3_system_bus_device;
123
124int ps3_dma_region_init(struct ps3_system_bus_device *dev,
125 struct ps3_dma_region *r, enum ps3_dma_page_size page_size,
126 enum ps3_dma_region_type region_type, void *addr, unsigned long len);
Geoff Levandf58a9d12006-11-23 00:46:51 +0100127int ps3_dma_region_create(struct ps3_dma_region *r);
128int ps3_dma_region_free(struct ps3_dma_region *r);
129int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
Stephen Rothwell494fd072009-01-13 19:58:10 +0000130 unsigned long len, dma_addr_t *bus_addr,
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000131 u64 iopte_pp);
Stephen Rothwell494fd072009-01-13 19:58:10 +0000132int ps3_dma_unmap(struct ps3_dma_region *r, dma_addr_t bus_addr,
Geoff Levandf58a9d12006-11-23 00:46:51 +0100133 unsigned long len);
134
135/* mmio routines */
136
137enum ps3_mmio_page_size {
138 PS3_MMIO_4K = 12U,
139 PS3_MMIO_64K = 16U
140};
141
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000142struct ps3_mmio_region_ops;
Geoff Levandf58a9d12006-11-23 00:46:51 +0100143/**
144 * struct ps3_mmio_region - a per device mmio state variables structure
145 *
146 * Current systems can be supported with a single region per device.
147 */
148
149struct ps3_mmio_region {
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000150 struct ps3_system_bus_device *dev;
151 const struct ps3_mmio_region_ops *mmio_ops;
Geoff Levandf58a9d12006-11-23 00:46:51 +0100152 unsigned long bus_addr;
153 unsigned long len;
154 enum ps3_mmio_page_size page_size;
155 unsigned long lpar_addr;
156};
157
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000158struct ps3_mmio_region_ops {
159 int (*create)(struct ps3_mmio_region *);
160 int (*free)(struct ps3_mmio_region *);
161};
Geoff Levandf58a9d12006-11-23 00:46:51 +0100162/**
163 * struct ps3_mmio_region_init - Helper to initialize structure variables
164 *
165 * Helper to properly initialize variables prior to calling
166 * ps3_system_bus_device_register.
167 */
168
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000169int ps3_mmio_region_init(struct ps3_system_bus_device *dev,
170 struct ps3_mmio_region *r, unsigned long bus_addr, unsigned long len,
171 enum ps3_mmio_page_size page_size);
Geoff Levandf58a9d12006-11-23 00:46:51 +0100172int ps3_mmio_region_create(struct ps3_mmio_region *r);
173int ps3_free_mmio_region(struct ps3_mmio_region *r);
174unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
175
176/* inrerrupt routines */
177
Geoff Levand861be322007-01-26 19:08:08 -0800178enum ps3_cpu_binding {
179 PS3_BINDING_CPU_ANY = -1,
180 PS3_BINDING_CPU_0 = 0,
181 PS3_BINDING_CPU_1 = 1,
182};
183
Geoff Levanddc4f60c2007-05-01 07:01:01 +1000184int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
185 unsigned int *virq);
186int ps3_irq_plug_destroy(unsigned int virq);
187int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq);
188int ps3_event_receive_port_destroy(unsigned int virq);
Geoff Levandf58a9d12006-11-23 00:46:51 +0100189int ps3_send_event_locally(unsigned int virq);
Geoff Levanddc4f60c2007-05-01 07:01:01 +1000190
191int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
192 unsigned int *virq);
193int ps3_io_irq_destroy(unsigned int virq);
194int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
195 unsigned int *virq);
196int ps3_vuart_irq_destroy(unsigned int virq);
197int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id,
198 unsigned int class, unsigned int *virq);
199int ps3_spe_irq_destroy(unsigned int virq);
200
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000201int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev,
202 enum ps3_cpu_binding cpu, unsigned int *virq);
203int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev,
204 unsigned int virq);
Geoff Levandf58a9d12006-11-23 00:46:51 +0100205
206/* lv1 result codes */
207
208enum 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 Uytterhoeven06462d92007-09-12 18:43:16 +1000233 LV1_HARDWARE_ERROR = -24,
234 LV1_INVALID_DATA_FORMAT = -25,
235 LV1_INVALID_OPERATION = -26,
Geoff Levandf58a9d12006-11-23 00:46:51 +0100236 LV1_INTERNAL_ERROR = -32768,
237};
238
239static 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 Uytterhoeven06462d92007-09-12 18:43:16 +1000291 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 Levandf58a9d12006-11-23 00:46:51 +0100297 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 Levanda3d4d642006-11-23 00:47:00 +0100308/* system bus routines */
309
310enum ps3_match_id {
Geert Uytterhoeven46d01492008-12-03 13:52:21 +0000311 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_GPU = 10,
321 PS3_MATCH_ID_LPM = 11,
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000322};
323
Geert Uytterhoeven46d01492008-12-03 13:52:21 +0000324enum ps3_match_sub_id {
325 PS3_MATCH_SUB_ID_GPU_FB = 1,
Jim Pariscffb4add2009-01-06 11:32:10 +0000326 PS3_MATCH_SUB_ID_GPU_RAMDISK = 2,
Geert Uytterhoeven46d01492008-12-03 13:52:21 +0000327};
328
329#define PS3_MODULE_ALIAS_EHCI "ps3:1:0"
330#define PS3_MODULE_ALIAS_OHCI "ps3:2:0"
331#define PS3_MODULE_ALIAS_GELIC "ps3:3:0"
332#define PS3_MODULE_ALIAS_AV_SETTINGS "ps3:4:0"
333#define PS3_MODULE_ALIAS_SYSTEM_MANAGER "ps3:5:0"
334#define PS3_MODULE_ALIAS_STOR_DISK "ps3:6:0"
335#define PS3_MODULE_ALIAS_STOR_ROM "ps3:7:0"
336#define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8:0"
337#define PS3_MODULE_ALIAS_SOUND "ps3:9:0"
338#define PS3_MODULE_ALIAS_GPU_FB "ps3:10:1"
Geert Uytterhoeven0a2d15b2009-01-06 11:32:03 +0000339#define PS3_MODULE_ALIAS_GPU_RAMDISK "ps3:10:2"
Geert Uytterhoeven46d01492008-12-03 13:52:21 +0000340#define PS3_MODULE_ALIAS_LPM "ps3:11:0"
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000341
342enum ps3_system_bus_device_type {
343 PS3_DEVICE_TYPE_IOC0 = 1,
344 PS3_DEVICE_TYPE_SB,
345 PS3_DEVICE_TYPE_VUART,
Geoff Levanded757002008-01-19 07:32:38 +1100346 PS3_DEVICE_TYPE_LPM,
Geoff Levanda3d4d642006-11-23 00:47:00 +0100347};
348
349/**
350 * struct ps3_system_bus_device - a device on the system bus
351 */
352
353struct ps3_system_bus_device {
354 enum ps3_match_id match_id;
Masakazu Mokuno059e4932008-07-17 07:22:19 +1000355 enum ps3_match_sub_id match_sub_id;
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000356 enum ps3_system_bus_device_type dev_type;
357
Geert Uytterhoeven034e0ab2008-01-19 07:30:09 +1100358 u64 bus_id; /* SB */
359 u64 dev_id; /* SB */
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000360 unsigned int interrupt_id; /* SB */
361 struct ps3_dma_region *d_region; /* SB, IOC0 */
362 struct ps3_mmio_region *m_region; /* SB, IOC0*/
363 unsigned int port_number; /* VUART */
Geoff Levanded757002008-01-19 07:32:38 +1100364 struct { /* LPM */
365 u64 node_id;
366 u64 pu_id;
367 u64 rights;
368 } lpm;
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000369
370/* struct iommu_table *iommu_table; -- waiting for BenH's cleanups */
Geoff Levanda3d4d642006-11-23 00:47:00 +0100371 struct device core;
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000372 void *driver_priv; /* private driver variables */
Geoff Levanda3d4d642006-11-23 00:47:00 +0100373};
374
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000375int ps3_open_hv_device(struct ps3_system_bus_device *dev);
376int ps3_close_hv_device(struct ps3_system_bus_device *dev);
377
Geoff Levanda3d4d642006-11-23 00:47:00 +0100378/**
379 * struct ps3_system_bus_driver - a driver for a device on the system bus
380 */
381
382struct ps3_system_bus_driver {
383 enum ps3_match_id match_id;
Masakazu Mokuno059e4932008-07-17 07:22:19 +1000384 enum ps3_match_sub_id match_sub_id;
Geoff Levanda3d4d642006-11-23 00:47:00 +0100385 struct device_driver core;
386 int (*probe)(struct ps3_system_bus_device *);
387 int (*remove)(struct ps3_system_bus_device *);
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000388 int (*shutdown)(struct ps3_system_bus_device *);
Geoff Levanda3d4d642006-11-23 00:47:00 +0100389/* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
390/* int (*resume)(struct ps3_system_bus_device *); */
391};
392
393int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
394int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
395void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000396
397static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv(
Geoff Levanda3d4d642006-11-23 00:47:00 +0100398 struct device_driver *_drv)
399{
400 return container_of(_drv, struct ps3_system_bus_driver, core);
401}
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000402static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev(
Geoff Levanda3d4d642006-11-23 00:47:00 +0100403 struct device *_dev)
404{
405 return container_of(_dev, struct ps3_system_bus_device, core);
406}
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000407static inline struct ps3_system_bus_driver *
408 ps3_system_bus_dev_to_system_bus_drv(struct ps3_system_bus_device *_dev)
409{
410 BUG_ON(!_dev);
411 BUG_ON(!_dev->core.driver);
412 return ps3_drv_to_system_bus_drv(_dev->core.driver);
413}
Geoff Levanda3d4d642006-11-23 00:47:00 +0100414
415/**
416 * ps3_system_bus_set_drvdata -
417 * @dev: device structure
418 * @data: Data to set
419 */
420
421static inline void ps3_system_bus_set_driver_data(
422 struct ps3_system_bus_device *dev, void *data)
423{
424 dev->core.driver_data = data;
425}
426static inline void *ps3_system_bus_get_driver_data(
427 struct ps3_system_bus_device *dev)
428{
429 return dev->core.driver_data;
430}
431
432/* These two need global scope for get_dma_ops(). */
433
434extern struct bus_type ps3_system_bus_type;
435
Geoff Levandfde5efd2007-02-07 12:20:01 -0800436/* system manager */
437
Geoff Levand66c63b82007-06-16 08:03:54 +1000438struct ps3_sys_manager_ops {
439 struct ps3_system_bus_device *dev;
440 void (*power_off)(struct ps3_system_bus_device *dev);
441 void (*restart)(struct ps3_system_bus_device *dev);
442};
443
444void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops);
Geert Uytterhoevenca052f72008-03-27 11:38:31 +1100445void __noreturn ps3_sys_manager_power_off(void);
446void __noreturn ps3_sys_manager_restart(void);
447void __noreturn ps3_sys_manager_halt(void);
Geoff Levand1c43d262008-03-27 11:39:04 +1100448int ps3_sys_manager_get_wol(void);
449void ps3_sys_manager_set_wol(int state);
Geoff Levandfde5efd2007-02-07 12:20:01 -0800450
Geert Uytterhoevenfbdb3e52007-02-12 00:55:22 -0800451struct ps3_prealloc {
452 const char *name;
453 void *address;
454 unsigned long size;
455 unsigned long align;
456};
457
458extern struct ps3_prealloc ps3fb_videomemory;
Geert Uytterhoeven32d73312007-06-22 00:14:20 +1000459extern struct ps3_prealloc ps3flash_bounce_buffer;
Geert Uytterhoevenfbdb3e52007-02-12 00:55:22 -0800460
Takashi Yamamoto781749a2008-01-19 07:32:46 +1100461/* logical performance monitor */
462
463/**
464 * enum ps3_lpm_rights - Rigths granted by the system policy module.
465 *
466 * @PS3_LPM_RIGHTS_USE_LPM: The right to use the lpm.
467 * @PS3_LPM_RIGHTS_USE_TB: The right to use the internal trace buffer.
468 */
469
470enum ps3_lpm_rights {
471 PS3_LPM_RIGHTS_USE_LPM = 0x001,
472 PS3_LPM_RIGHTS_USE_TB = 0x100,
473};
474
475/**
476 * enum ps3_lpm_tb_type - Type of trace buffer lv1 should use.
477 *
478 * @PS3_LPM_TB_TYPE_NONE: Do not use a trace buffer.
479 * @PS3_LPM_RIGHTS_USE_TB: Use the lv1 internal trace buffer. Must have
480 * rights @PS3_LPM_RIGHTS_USE_TB.
481 */
482
483enum ps3_lpm_tb_type {
484 PS3_LPM_TB_TYPE_NONE = 0,
485 PS3_LPM_TB_TYPE_INTERNAL = 1,
486};
487
488int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
489 u64 tb_cache_size);
490int ps3_lpm_close(void);
491int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count,
492 unsigned long *bytes_copied);
493int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
494 unsigned long count, unsigned long *bytes_copied);
495void ps3_set_bookmark(u64 bookmark);
496void ps3_set_pm_bookmark(u64 tag, u64 incident, u64 th_id);
497int ps3_set_signal(u64 rtas_signal_group, u8 signal_bit, u16 sub_unit,
498 u8 bus_word);
499
500u32 ps3_read_phys_ctr(u32 cpu, u32 phys_ctr);
501void ps3_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val);
502u32 ps3_read_ctr(u32 cpu, u32 ctr);
503void ps3_write_ctr(u32 cpu, u32 ctr, u32 val);
504
505u32 ps3_read_pm07_control(u32 cpu, u32 ctr);
506void ps3_write_pm07_control(u32 cpu, u32 ctr, u32 val);
507u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg);
508void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val);
509
510u32 ps3_get_ctr_size(u32 cpu, u32 phys_ctr);
511void ps3_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size);
512
513void ps3_enable_pm(u32 cpu);
514void ps3_disable_pm(u32 cpu);
515void ps3_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
516void ps3_disable_pm_interrupts(u32 cpu);
517
518u32 ps3_get_and_clear_pm_interrupts(u32 cpu);
519void ps3_sync_irq(int node);
520u32 ps3_get_hw_thread_id(int cpu);
521u64 ps3_get_spe_id(void *arg);
Geoff Levand66c63b82007-06-16 08:03:54 +1000522
Geert Uytterhoeven9b82f3e2008-10-30 08:12:58 +0000523/* mutex synchronizing GPU accesses and video mode changes */
524extern struct mutex ps3_gpu_mutex;
525
Geoff Levandf58a9d12006-11-23 00:46:51 +0100526#endif