[POWERPC] PS3: Compare firmware version
[deliverable/linux.git] / include / asm-powerpc / ps3.h
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
24 #include <linux/init.h>
25 #include <linux/types.h>
26 #include <linux/device.h>
27
28 union ps3_firmware_version {
29 u64 raw;
30 struct {
31 u16 pad;
32 u16 major;
33 u16 minor;
34 u16 rev;
35 };
36 };
37
38 void ps3_get_firmware_version(union ps3_firmware_version *v);
39 int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev);
40
41 /* 'Other OS' area */
42
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,
48 };
49
50 enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);
51
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..}
56 */
57
58 struct ps3_device_id {
59 unsigned int bus_id;
60 unsigned int dev_id;
61 };
62
63
64 /* dma routines */
65
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,
71 };
72
73 enum ps3_dma_region_type {
74 PS3_DMA_OTHER = 0,
75 PS3_DMA_INTERNAL = 2,
76 };
77
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.
86 */
87
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;
98 };
99
100 /**
101 * struct ps3_dma_region_init - Helper to initialize structure variables
102 *
103 * Helper to properly initialize variables prior to calling
104 * ps3_system_bus_device_register.
105 */
106
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)
110 {
111 r->did = *did;
112 r->page_size = page_size;
113 r->region_type = region_type;
114 }
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);
121
122 /* mmio routines */
123
124 enum ps3_mmio_page_size {
125 PS3_MMIO_4K = 12U,
126 PS3_MMIO_64K = 16U
127 };
128
129 /**
130 * struct ps3_mmio_region - a per device mmio state variables structure
131 *
132 * Current systems can be supported with a single region per device.
133 */
134
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;
141 };
142
143 /**
144 * struct ps3_mmio_region_init - Helper to initialize structure variables
145 *
146 * Helper to properly initialize variables prior to calling
147 * ps3_system_bus_device_register.
148 */
149
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)
153 {
154 r->did = *did;
155 r->bus_addr = bus_addr;
156 r->len = len;
157 r->page_size = page_size;
158 }
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);
162
163 /* inrerrupt routines */
164
165 enum ps3_cpu_binding {
166 PS3_BINDING_CPU_ANY = -1,
167 PS3_BINDING_CPU_0 = 0,
168 PS3_BINDING_CPU_1 = 1,
169 };
170
171 int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
172 unsigned int *virq);
173 int ps3_virq_destroy(unsigned int virq);
174 int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
175 unsigned int *virq);
176 int ps3_irq_plug_destroy(unsigned int virq);
177 int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq);
178 int ps3_event_receive_port_destroy(unsigned int virq);
179 int ps3_send_event_locally(unsigned int virq);
180
181 int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
182 unsigned int *virq);
183 int ps3_io_irq_destroy(unsigned int virq);
184 int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
185 unsigned int *virq);
186 int ps3_vuart_irq_destroy(unsigned int virq);
187 int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id,
188 unsigned int class, unsigned int *virq);
189 int ps3_spe_irq_destroy(unsigned int virq);
190
191 int ps3_sb_event_receive_port_setup(enum ps3_cpu_binding cpu,
192 const struct ps3_device_id *did, unsigned int interrupt_id,
193 unsigned int *virq);
194 int ps3_sb_event_receive_port_destroy(const struct ps3_device_id *did,
195 unsigned int interrupt_id, unsigned int virq);
196
197 /* lv1 result codes */
198
199 enum lv1_result {
200 LV1_SUCCESS = 0,
201 /* not used -1 */
202 LV1_RESOURCE_SHORTAGE = -2,
203 LV1_NO_PRIVILEGE = -3,
204 LV1_DENIED_BY_POLICY = -4,
205 LV1_ACCESS_VIOLATION = -5,
206 LV1_NO_ENTRY = -6,
207 LV1_DUPLICATE_ENTRY = -7,
208 LV1_TYPE_MISMATCH = -8,
209 LV1_BUSY = -9,
210 LV1_EMPTY = -10,
211 LV1_WRONG_STATE = -11,
212 /* not used -12 */
213 LV1_NO_MATCH = -13,
214 LV1_ALREADY_CONNECTED = -14,
215 LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
216 LV1_CONDITION_NOT_SATISFIED = -16,
217 LV1_ILLEGAL_PARAMETER_VALUE = -17,
218 LV1_BAD_OPTION = -18,
219 LV1_IMPLEMENTATION_LIMITATION = -19,
220 LV1_NOT_IMPLEMENTED = -20,
221 LV1_INVALID_CLASS_ID = -21,
222 LV1_CONSTRAINT_NOT_SATISFIED = -22,
223 LV1_ALIGNMENT_ERROR = -23,
224 LV1_INTERNAL_ERROR = -32768,
225 };
226
227 static inline const char* ps3_result(int result)
228 {
229 #if defined(DEBUG)
230 switch (result) {
231 case LV1_SUCCESS:
232 return "LV1_SUCCESS (0)";
233 case -1:
234 return "** unknown result ** (-1)";
235 case LV1_RESOURCE_SHORTAGE:
236 return "LV1_RESOURCE_SHORTAGE (-2)";
237 case LV1_NO_PRIVILEGE:
238 return "LV1_NO_PRIVILEGE (-3)";
239 case LV1_DENIED_BY_POLICY:
240 return "LV1_DENIED_BY_POLICY (-4)";
241 case LV1_ACCESS_VIOLATION:
242 return "LV1_ACCESS_VIOLATION (-5)";
243 case LV1_NO_ENTRY:
244 return "LV1_NO_ENTRY (-6)";
245 case LV1_DUPLICATE_ENTRY:
246 return "LV1_DUPLICATE_ENTRY (-7)";
247 case LV1_TYPE_MISMATCH:
248 return "LV1_TYPE_MISMATCH (-8)";
249 case LV1_BUSY:
250 return "LV1_BUSY (-9)";
251 case LV1_EMPTY:
252 return "LV1_EMPTY (-10)";
253 case LV1_WRONG_STATE:
254 return "LV1_WRONG_STATE (-11)";
255 case -12:
256 return "** unknown result ** (-12)";
257 case LV1_NO_MATCH:
258 return "LV1_NO_MATCH (-13)";
259 case LV1_ALREADY_CONNECTED:
260 return "LV1_ALREADY_CONNECTED (-14)";
261 case LV1_UNSUPPORTED_PARAMETER_VALUE:
262 return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
263 case LV1_CONDITION_NOT_SATISFIED:
264 return "LV1_CONDITION_NOT_SATISFIED (-16)";
265 case LV1_ILLEGAL_PARAMETER_VALUE:
266 return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
267 case LV1_BAD_OPTION:
268 return "LV1_BAD_OPTION (-18)";
269 case LV1_IMPLEMENTATION_LIMITATION:
270 return "LV1_IMPLEMENTATION_LIMITATION (-19)";
271 case LV1_NOT_IMPLEMENTED:
272 return "LV1_NOT_IMPLEMENTED (-20)";
273 case LV1_INVALID_CLASS_ID:
274 return "LV1_INVALID_CLASS_ID (-21)";
275 case LV1_CONSTRAINT_NOT_SATISFIED:
276 return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
277 case LV1_ALIGNMENT_ERROR:
278 return "LV1_ALIGNMENT_ERROR (-23)";
279 case LV1_INTERNAL_ERROR:
280 return "LV1_INTERNAL_ERROR (-32768)";
281 default:
282 BUG();
283 return "** unknown result **";
284 };
285 #else
286 return "";
287 #endif
288 }
289
290 /* system bus routines */
291
292 enum ps3_match_id {
293 PS3_MATCH_ID_EHCI = 1,
294 PS3_MATCH_ID_OHCI,
295 PS3_MATCH_ID_GELIC,
296 PS3_MATCH_ID_AV_SETTINGS,
297 PS3_MATCH_ID_SYSTEM_MANAGER,
298 };
299
300 /**
301 * struct ps3_system_bus_device - a device on the system bus
302 */
303
304 struct ps3_system_bus_device {
305 enum ps3_match_id match_id;
306 struct ps3_device_id did;
307 unsigned int interrupt_id;
308 /* struct iommu_table *iommu_table; -- waiting for Ben's cleanups */
309 struct ps3_dma_region *d_region;
310 struct ps3_mmio_region *m_region;
311 struct device core;
312 };
313
314 /**
315 * struct ps3_system_bus_driver - a driver for a device on the system bus
316 */
317
318 struct ps3_system_bus_driver {
319 enum ps3_match_id match_id;
320 struct device_driver core;
321 int (*probe)(struct ps3_system_bus_device *);
322 int (*remove)(struct ps3_system_bus_device *);
323 /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
324 /* int (*resume)(struct ps3_system_bus_device *); */
325 };
326
327 int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
328 int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
329 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
330 static inline struct ps3_system_bus_driver *to_ps3_system_bus_driver(
331 struct device_driver *_drv)
332 {
333 return container_of(_drv, struct ps3_system_bus_driver, core);
334 }
335 static inline struct ps3_system_bus_device *to_ps3_system_bus_device(
336 struct device *_dev)
337 {
338 return container_of(_dev, struct ps3_system_bus_device, core);
339 }
340
341 /**
342 * ps3_system_bus_set_drvdata -
343 * @dev: device structure
344 * @data: Data to set
345 */
346
347 static inline void ps3_system_bus_set_driver_data(
348 struct ps3_system_bus_device *dev, void *data)
349 {
350 dev->core.driver_data = data;
351 }
352 static inline void *ps3_system_bus_get_driver_data(
353 struct ps3_system_bus_device *dev)
354 {
355 return dev->core.driver_data;
356 }
357
358 /* These two need global scope for get_dma_ops(). */
359
360 extern struct bus_type ps3_system_bus_type;
361
362 /* vuart routines */
363
364 struct ps3_vuart_port_priv;
365
366 /**
367 * struct ps3_vuart_port_device - a device on a vuart port
368 */
369
370 struct ps3_vuart_port_device {
371 enum ps3_match_id match_id;
372 struct device core;
373 struct ps3_vuart_port_priv* priv; /* private driver variables */
374
375 };
376
377 int ps3_vuart_port_device_register(struct ps3_vuart_port_device *dev);
378
379 /* system manager */
380
381 #ifdef CONFIG_PS3_SYS_MANAGER
382 void ps3_sys_manager_restart(void);
383 void ps3_sys_manager_power_off(void);
384 #else
385 static inline void ps3_sys_manager_restart(void) {}
386 static inline void ps3_sys_manager_power_off(void) {}
387 #endif
388
389 struct ps3_prealloc {
390 const char *name;
391 void *address;
392 unsigned long size;
393 unsigned long align;
394 };
395
396 extern struct ps3_prealloc ps3fb_videomemory;
397
398 #endif
This page took 0.067362 seconds and 6 git commands to generate.