i386: Reserve the right performance counter for the Intel PerfMon NMI watchdog
[usb.git] / include / asm-powerpc / ps3.h
bloba6f3f5ee7ca7f70a3ee592c0e173f91b40f3e53b
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>
28 union ps3_firmware_version {
29 u64 raw;
30 struct {
31 u16 pad;
32 u16 major;
33 u16 minor;
34 u16 rev;
38 void ps3_get_firmware_version(union ps3_firmware_version *v);
39 int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev);
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 /* dma routines */
54 enum ps3_dma_page_size {
55 PS3_DMA_4K = 12U,
56 PS3_DMA_64K = 16U,
57 PS3_DMA_1M = 20U,
58 PS3_DMA_16M = 24U,
61 enum ps3_dma_region_type {
62 PS3_DMA_OTHER = 0,
63 PS3_DMA_INTERNAL = 2,
66 struct ps3_dma_region_ops;
68 /**
69 * struct ps3_dma_region - A per device dma state variables structure
70 * @did: The HV device id.
71 * @page_size: The ioc pagesize.
72 * @region_type: The HV region type.
73 * @bus_addr: The 'translated' bus address of the region.
74 * @len: The length in bytes of the region.
75 * @offset: The offset from the start of memory of the region.
76 * @ioid: The IOID of the device who owns this region
77 * @chunk_list: Opaque variable used by the ioc page manager.
78 * @region_ops: struct ps3_dma_region_ops - dma region operations
81 struct ps3_dma_region {
82 struct ps3_system_bus_device *dev;
83 /* device variables */
84 const struct ps3_dma_region_ops *region_ops;
85 unsigned char ioid;
86 enum ps3_dma_page_size page_size;
87 enum ps3_dma_region_type region_type;
88 unsigned long len;
89 unsigned long offset;
91 /* driver variables (set by ps3_dma_region_create) */
92 unsigned long bus_addr;
93 struct {
94 spinlock_t lock;
95 struct list_head head;
96 } chunk_list;
99 struct ps3_dma_region_ops {
100 int (*create)(struct ps3_dma_region *);
101 int (*free)(struct ps3_dma_region *);
102 int (*map)(struct ps3_dma_region *,
103 unsigned long virt_addr,
104 unsigned long len,
105 unsigned long *bus_addr,
106 u64 iopte_pp);
107 int (*unmap)(struct ps3_dma_region *,
108 unsigned long bus_addr,
109 unsigned long len);
112 * struct ps3_dma_region_init - Helper to initialize structure variables
114 * Helper to properly initialize variables prior to calling
115 * ps3_system_bus_device_register.
118 struct ps3_system_bus_device;
120 int ps3_dma_region_init(struct ps3_system_bus_device *dev,
121 struct ps3_dma_region *r, enum ps3_dma_page_size page_size,
122 enum ps3_dma_region_type region_type, void *addr, unsigned long len);
123 int ps3_dma_region_create(struct ps3_dma_region *r);
124 int ps3_dma_region_free(struct ps3_dma_region *r);
125 int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
126 unsigned long len, unsigned long *bus_addr,
127 u64 iopte_pp);
128 int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr,
129 unsigned long len);
131 /* mmio routines */
133 enum ps3_mmio_page_size {
134 PS3_MMIO_4K = 12U,
135 PS3_MMIO_64K = 16U
138 struct ps3_mmio_region_ops;
140 * struct ps3_mmio_region - a per device mmio state variables structure
142 * Current systems can be supported with a single region per device.
145 struct ps3_mmio_region {
146 struct ps3_system_bus_device *dev;
147 const struct ps3_mmio_region_ops *mmio_ops;
148 unsigned long bus_addr;
149 unsigned long len;
150 enum ps3_mmio_page_size page_size;
151 unsigned long lpar_addr;
154 struct ps3_mmio_region_ops {
155 int (*create)(struct ps3_mmio_region *);
156 int (*free)(struct ps3_mmio_region *);
159 * struct ps3_mmio_region_init - Helper to initialize structure variables
161 * Helper to properly initialize variables prior to calling
162 * ps3_system_bus_device_register.
165 int ps3_mmio_region_init(struct ps3_system_bus_device *dev,
166 struct ps3_mmio_region *r, unsigned long bus_addr, unsigned long len,
167 enum ps3_mmio_page_size page_size);
168 int ps3_mmio_region_create(struct ps3_mmio_region *r);
169 int ps3_free_mmio_region(struct ps3_mmio_region *r);
170 unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
172 /* inrerrupt routines */
174 enum ps3_cpu_binding {
175 PS3_BINDING_CPU_ANY = -1,
176 PS3_BINDING_CPU_0 = 0,
177 PS3_BINDING_CPU_1 = 1,
180 int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
181 unsigned int *virq);
182 int ps3_virq_destroy(unsigned int virq);
183 int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
184 unsigned int *virq);
185 int ps3_irq_plug_destroy(unsigned int virq);
186 int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq);
187 int ps3_event_receive_port_destroy(unsigned int virq);
188 int ps3_send_event_locally(unsigned int virq);
190 int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
191 unsigned int *virq);
192 int ps3_io_irq_destroy(unsigned int virq);
193 int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
194 unsigned int *virq);
195 int ps3_vuart_irq_destroy(unsigned int virq);
196 int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id,
197 unsigned int class, unsigned int *virq);
198 int ps3_spe_irq_destroy(unsigned int virq);
200 int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev,
201 enum ps3_cpu_binding cpu, unsigned int *virq);
202 int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev,
203 unsigned int virq);
205 /* lv1 result codes */
207 enum lv1_result {
208 LV1_SUCCESS = 0,
209 /* not used -1 */
210 LV1_RESOURCE_SHORTAGE = -2,
211 LV1_NO_PRIVILEGE = -3,
212 LV1_DENIED_BY_POLICY = -4,
213 LV1_ACCESS_VIOLATION = -5,
214 LV1_NO_ENTRY = -6,
215 LV1_DUPLICATE_ENTRY = -7,
216 LV1_TYPE_MISMATCH = -8,
217 LV1_BUSY = -9,
218 LV1_EMPTY = -10,
219 LV1_WRONG_STATE = -11,
220 /* not used -12 */
221 LV1_NO_MATCH = -13,
222 LV1_ALREADY_CONNECTED = -14,
223 LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
224 LV1_CONDITION_NOT_SATISFIED = -16,
225 LV1_ILLEGAL_PARAMETER_VALUE = -17,
226 LV1_BAD_OPTION = -18,
227 LV1_IMPLEMENTATION_LIMITATION = -19,
228 LV1_NOT_IMPLEMENTED = -20,
229 LV1_INVALID_CLASS_ID = -21,
230 LV1_CONSTRAINT_NOT_SATISFIED = -22,
231 LV1_ALIGNMENT_ERROR = -23,
232 LV1_INTERNAL_ERROR = -32768,
235 static inline const char* ps3_result(int result)
237 #if defined(DEBUG)
238 switch (result) {
239 case LV1_SUCCESS:
240 return "LV1_SUCCESS (0)";
241 case -1:
242 return "** unknown result ** (-1)";
243 case LV1_RESOURCE_SHORTAGE:
244 return "LV1_RESOURCE_SHORTAGE (-2)";
245 case LV1_NO_PRIVILEGE:
246 return "LV1_NO_PRIVILEGE (-3)";
247 case LV1_DENIED_BY_POLICY:
248 return "LV1_DENIED_BY_POLICY (-4)";
249 case LV1_ACCESS_VIOLATION:
250 return "LV1_ACCESS_VIOLATION (-5)";
251 case LV1_NO_ENTRY:
252 return "LV1_NO_ENTRY (-6)";
253 case LV1_DUPLICATE_ENTRY:
254 return "LV1_DUPLICATE_ENTRY (-7)";
255 case LV1_TYPE_MISMATCH:
256 return "LV1_TYPE_MISMATCH (-8)";
257 case LV1_BUSY:
258 return "LV1_BUSY (-9)";
259 case LV1_EMPTY:
260 return "LV1_EMPTY (-10)";
261 case LV1_WRONG_STATE:
262 return "LV1_WRONG_STATE (-11)";
263 case -12:
264 return "** unknown result ** (-12)";
265 case LV1_NO_MATCH:
266 return "LV1_NO_MATCH (-13)";
267 case LV1_ALREADY_CONNECTED:
268 return "LV1_ALREADY_CONNECTED (-14)";
269 case LV1_UNSUPPORTED_PARAMETER_VALUE:
270 return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
271 case LV1_CONDITION_NOT_SATISFIED:
272 return "LV1_CONDITION_NOT_SATISFIED (-16)";
273 case LV1_ILLEGAL_PARAMETER_VALUE:
274 return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
275 case LV1_BAD_OPTION:
276 return "LV1_BAD_OPTION (-18)";
277 case LV1_IMPLEMENTATION_LIMITATION:
278 return "LV1_IMPLEMENTATION_LIMITATION (-19)";
279 case LV1_NOT_IMPLEMENTED:
280 return "LV1_NOT_IMPLEMENTED (-20)";
281 case LV1_INVALID_CLASS_ID:
282 return "LV1_INVALID_CLASS_ID (-21)";
283 case LV1_CONSTRAINT_NOT_SATISFIED:
284 return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
285 case LV1_ALIGNMENT_ERROR:
286 return "LV1_ALIGNMENT_ERROR (-23)";
287 case LV1_INTERNAL_ERROR:
288 return "LV1_INTERNAL_ERROR (-32768)";
289 default:
290 BUG();
291 return "** unknown result **";
293 #else
294 return "";
295 #endif
298 /* system bus routines */
300 enum ps3_match_id {
301 PS3_MATCH_ID_EHCI = 1,
302 PS3_MATCH_ID_OHCI = 2,
303 PS3_MATCH_ID_GELIC = 3,
304 PS3_MATCH_ID_AV_SETTINGS = 4,
305 PS3_MATCH_ID_SYSTEM_MANAGER = 5,
306 PS3_MATCH_ID_STOR_DISK = 6,
307 PS3_MATCH_ID_STOR_ROM = 7,
308 PS3_MATCH_ID_STOR_FLASH = 8,
309 PS3_MATCH_ID_SOUND = 9,
310 PS3_MATCH_ID_GRAPHICS = 10,
313 #define PS3_MODULE_ALIAS_EHCI "ps3:1"
314 #define PS3_MODULE_ALIAS_OHCI "ps3:2"
315 #define PS3_MODULE_ALIAS_GELIC "ps3:3"
316 #define PS3_MODULE_ALIAS_AV_SETTINGS "ps3:4"
317 #define PS3_MODULE_ALIAS_SYSTEM_MANAGER "ps3:5"
318 #define PS3_MODULE_ALIAS_STOR_DISK "ps3:6"
319 #define PS3_MODULE_ALIAS_STOR_ROM "ps3:7"
320 #define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8"
321 #define PS3_MODULE_ALIAS_SOUND "ps3:9"
322 #define PS3_MODULE_ALIAS_GRAPHICS "ps3:10"
324 enum ps3_system_bus_device_type {
325 PS3_DEVICE_TYPE_IOC0 = 1,
326 PS3_DEVICE_TYPE_SB,
327 PS3_DEVICE_TYPE_VUART,
331 * struct ps3_system_bus_device - a device on the system bus
334 struct ps3_system_bus_device {
335 enum ps3_match_id match_id;
336 enum ps3_system_bus_device_type dev_type;
338 unsigned int bus_id; /* SB */
339 unsigned int dev_id; /* SB */
340 unsigned int interrupt_id; /* SB */
341 struct ps3_dma_region *d_region; /* SB, IOC0 */
342 struct ps3_mmio_region *m_region; /* SB, IOC0*/
343 unsigned int port_number; /* VUART */
345 /* struct iommu_table *iommu_table; -- waiting for BenH's cleanups */
346 struct device core;
347 void *driver_priv; /* private driver variables */
350 int ps3_open_hv_device(struct ps3_system_bus_device *dev);
351 int ps3_close_hv_device(struct ps3_system_bus_device *dev);
354 * struct ps3_system_bus_driver - a driver for a device on the system bus
357 struct ps3_system_bus_driver {
358 enum ps3_match_id match_id;
359 struct device_driver core;
360 int (*probe)(struct ps3_system_bus_device *);
361 int (*remove)(struct ps3_system_bus_device *);
362 int (*shutdown)(struct ps3_system_bus_device *);
363 /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
364 /* int (*resume)(struct ps3_system_bus_device *); */
367 int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
368 int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
369 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
371 static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv(
372 struct device_driver *_drv)
374 return container_of(_drv, struct ps3_system_bus_driver, core);
376 static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev(
377 struct device *_dev)
379 return container_of(_dev, struct ps3_system_bus_device, core);
381 static inline struct ps3_system_bus_driver *
382 ps3_system_bus_dev_to_system_bus_drv(struct ps3_system_bus_device *_dev)
384 BUG_ON(!_dev);
385 BUG_ON(!_dev->core.driver);
386 return ps3_drv_to_system_bus_drv(_dev->core.driver);
390 * ps3_system_bus_set_drvdata -
391 * @dev: device structure
392 * @data: Data to set
395 static inline void ps3_system_bus_set_driver_data(
396 struct ps3_system_bus_device *dev, void *data)
398 dev->core.driver_data = data;
400 static inline void *ps3_system_bus_get_driver_data(
401 struct ps3_system_bus_device *dev)
403 return dev->core.driver_data;
406 /* These two need global scope for get_dma_ops(). */
408 extern struct bus_type ps3_system_bus_type;
410 /* system manager */
412 struct ps3_sys_manager_ops {
413 struct ps3_system_bus_device *dev;
414 void (*power_off)(struct ps3_system_bus_device *dev);
415 void (*restart)(struct ps3_system_bus_device *dev);
418 void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops);
419 void ps3_sys_manager_power_off(void);
420 void ps3_sys_manager_restart(void);
422 struct ps3_prealloc {
423 const char *name;
424 void *address;
425 unsigned long size;
426 unsigned long align;
429 extern struct ps3_prealloc ps3fb_videomemory;
430 extern struct ps3_prealloc ps3flash_bounce_buffer;
433 #endif