[POWERPC] Compile fixes for arch/powerpc dcr code
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-powerpc / ps3.h
blob4f5a1e01fdace5454a9bfa78e369f3592b61ff90
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 int ps3_get_firmware_version(union ps3_firmware_version *v);
40 /* 'Other OS' area */
42 enum ps3_param_av_multi_out {
43 PS3_PARAM_AV_MULTI_OUT_NTSC = 0,
44 PS3_PARAM_AV_MULTI_OUT_PAL_RGB = 1,
45 PS3_PARAM_AV_MULTI_OUT_PAL_YCBCR = 2,
46 PS3_PARAM_AV_MULTI_OUT_SECAM = 3,
49 enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);
51 /**
52 * struct ps3_device_id - HV bus device identifier from the system repository
53 * @bus_id: HV bus id, {1..} (zero invalid)
54 * @dev_id: HV device id, {0..}
57 struct ps3_device_id {
58 unsigned int bus_id;
59 unsigned int dev_id;
63 /* dma routines */
65 enum ps3_dma_page_size {
66 PS3_DMA_4K = 12U,
67 PS3_DMA_64K = 16U,
68 PS3_DMA_1M = 20U,
69 PS3_DMA_16M = 24U,
72 enum ps3_dma_region_type {
73 PS3_DMA_OTHER = 0,
74 PS3_DMA_INTERNAL = 2,
77 /**
78 * struct ps3_dma_region - A per device dma state variables structure
79 * @did: The HV device id.
80 * @page_size: The ioc pagesize.
81 * @region_type: The HV region type.
82 * @bus_addr: The 'translated' bus address of the region.
83 * @len: The length in bytes of the region.
84 * @chunk_list: Opaque variable used by the ioc page manager.
87 struct ps3_dma_region {
88 struct ps3_device_id did;
89 enum ps3_dma_page_size page_size;
90 enum ps3_dma_region_type region_type;
91 unsigned long bus_addr;
92 unsigned long len;
93 struct {
94 spinlock_t lock;
95 struct list_head head;
96 } chunk_list;
99 /**
100 * struct ps3_dma_region_init - Helper to initialize structure variables
102 * Helper to properly initialize variables prior to calling
103 * ps3_system_bus_device_register.
106 static inline void ps3_dma_region_init(struct ps3_dma_region *r,
107 const struct ps3_device_id* did, enum ps3_dma_page_size page_size,
108 enum ps3_dma_region_type region_type)
110 r->did = *did;
111 r->page_size = page_size;
112 r->region_type = region_type;
114 int ps3_dma_region_create(struct ps3_dma_region *r);
115 int ps3_dma_region_free(struct ps3_dma_region *r);
116 int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
117 unsigned long len, unsigned long *bus_addr);
118 int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr,
119 unsigned long len);
121 /* mmio routines */
123 enum ps3_mmio_page_size {
124 PS3_MMIO_4K = 12U,
125 PS3_MMIO_64K = 16U
129 * struct ps3_mmio_region - a per device mmio state variables structure
131 * Current systems can be supported with a single region per device.
134 struct ps3_mmio_region {
135 struct ps3_device_id did;
136 unsigned long bus_addr;
137 unsigned long len;
138 enum ps3_mmio_page_size page_size;
139 unsigned long lpar_addr;
143 * struct ps3_mmio_region_init - Helper to initialize structure variables
145 * Helper to properly initialize variables prior to calling
146 * ps3_system_bus_device_register.
149 static inline void ps3_mmio_region_init(struct ps3_mmio_region *r,
150 const struct ps3_device_id* did, unsigned long bus_addr,
151 unsigned long len, enum ps3_mmio_page_size page_size)
153 r->did = *did;
154 r->bus_addr = bus_addr;
155 r->len = len;
156 r->page_size = page_size;
158 int ps3_mmio_region_create(struct ps3_mmio_region *r);
159 int ps3_free_mmio_region(struct ps3_mmio_region *r);
160 unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
162 /* inrerrupt routines */
164 enum ps3_cpu_binding {
165 PS3_BINDING_CPU_ANY = -1,
166 PS3_BINDING_CPU_0 = 0,
167 PS3_BINDING_CPU_1 = 1,
170 int ps3_alloc_io_irq(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
171 unsigned int *virq);
172 int ps3_free_io_irq(unsigned int virq);
173 int ps3_alloc_event_irq(enum ps3_cpu_binding cpu, unsigned int *virq);
174 int ps3_free_event_irq(unsigned int virq);
175 int ps3_send_event_locally(unsigned int virq);
176 int ps3_connect_event_irq(enum ps3_cpu_binding cpu,
177 const struct ps3_device_id *did, unsigned int interrupt_id,
178 unsigned int *virq);
179 int ps3_disconnect_event_irq(const struct ps3_device_id *did,
180 unsigned int interrupt_id, unsigned int virq);
181 int ps3_alloc_vuart_irq(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
182 unsigned int *virq);
183 int ps3_free_vuart_irq(unsigned int virq);
184 int ps3_alloc_spe_irq(enum ps3_cpu_binding cpu, unsigned long spe_id,
185 unsigned int class, unsigned int *virq);
186 int ps3_free_spe_irq(unsigned int virq);
187 int ps3_alloc_irq(enum ps3_cpu_binding cpu, unsigned long outlet,
188 unsigned int *virq);
189 int ps3_free_irq(unsigned int virq);
191 /* lv1 result codes */
193 enum lv1_result {
194 LV1_SUCCESS = 0,
195 /* not used -1 */
196 LV1_RESOURCE_SHORTAGE = -2,
197 LV1_NO_PRIVILEGE = -3,
198 LV1_DENIED_BY_POLICY = -4,
199 LV1_ACCESS_VIOLATION = -5,
200 LV1_NO_ENTRY = -6,
201 LV1_DUPLICATE_ENTRY = -7,
202 LV1_TYPE_MISMATCH = -8,
203 LV1_BUSY = -9,
204 LV1_EMPTY = -10,
205 LV1_WRONG_STATE = -11,
206 /* not used -12 */
207 LV1_NO_MATCH = -13,
208 LV1_ALREADY_CONNECTED = -14,
209 LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
210 LV1_CONDITION_NOT_SATISFIED = -16,
211 LV1_ILLEGAL_PARAMETER_VALUE = -17,
212 LV1_BAD_OPTION = -18,
213 LV1_IMPLEMENTATION_LIMITATION = -19,
214 LV1_NOT_IMPLEMENTED = -20,
215 LV1_INVALID_CLASS_ID = -21,
216 LV1_CONSTRAINT_NOT_SATISFIED = -22,
217 LV1_ALIGNMENT_ERROR = -23,
218 LV1_INTERNAL_ERROR = -32768,
221 static inline const char* ps3_result(int result)
223 #if defined(DEBUG)
224 switch (result) {
225 case LV1_SUCCESS:
226 return "LV1_SUCCESS (0)";
227 case -1:
228 return "** unknown result ** (-1)";
229 case LV1_RESOURCE_SHORTAGE:
230 return "LV1_RESOURCE_SHORTAGE (-2)";
231 case LV1_NO_PRIVILEGE:
232 return "LV1_NO_PRIVILEGE (-3)";
233 case LV1_DENIED_BY_POLICY:
234 return "LV1_DENIED_BY_POLICY (-4)";
235 case LV1_ACCESS_VIOLATION:
236 return "LV1_ACCESS_VIOLATION (-5)";
237 case LV1_NO_ENTRY:
238 return "LV1_NO_ENTRY (-6)";
239 case LV1_DUPLICATE_ENTRY:
240 return "LV1_DUPLICATE_ENTRY (-7)";
241 case LV1_TYPE_MISMATCH:
242 return "LV1_TYPE_MISMATCH (-8)";
243 case LV1_BUSY:
244 return "LV1_BUSY (-9)";
245 case LV1_EMPTY:
246 return "LV1_EMPTY (-10)";
247 case LV1_WRONG_STATE:
248 return "LV1_WRONG_STATE (-11)";
249 case -12:
250 return "** unknown result ** (-12)";
251 case LV1_NO_MATCH:
252 return "LV1_NO_MATCH (-13)";
253 case LV1_ALREADY_CONNECTED:
254 return "LV1_ALREADY_CONNECTED (-14)";
255 case LV1_UNSUPPORTED_PARAMETER_VALUE:
256 return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
257 case LV1_CONDITION_NOT_SATISFIED:
258 return "LV1_CONDITION_NOT_SATISFIED (-16)";
259 case LV1_ILLEGAL_PARAMETER_VALUE:
260 return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
261 case LV1_BAD_OPTION:
262 return "LV1_BAD_OPTION (-18)";
263 case LV1_IMPLEMENTATION_LIMITATION:
264 return "LV1_IMPLEMENTATION_LIMITATION (-19)";
265 case LV1_NOT_IMPLEMENTED:
266 return "LV1_NOT_IMPLEMENTED (-20)";
267 case LV1_INVALID_CLASS_ID:
268 return "LV1_INVALID_CLASS_ID (-21)";
269 case LV1_CONSTRAINT_NOT_SATISFIED:
270 return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
271 case LV1_ALIGNMENT_ERROR:
272 return "LV1_ALIGNMENT_ERROR (-23)";
273 case LV1_INTERNAL_ERROR:
274 return "LV1_INTERNAL_ERROR (-32768)";
275 default:
276 BUG();
277 return "** unknown result **";
279 #else
280 return "";
281 #endif
284 /* system bus routines */
286 enum ps3_match_id {
287 PS3_MATCH_ID_EHCI = 1,
288 PS3_MATCH_ID_OHCI,
289 PS3_MATCH_ID_GELIC,
290 PS3_MATCH_ID_AV_SETTINGS,
291 PS3_MATCH_ID_SYSTEM_MANAGER,
295 * struct ps3_system_bus_device - a device on the system bus
298 struct ps3_system_bus_device {
299 enum ps3_match_id match_id;
300 struct ps3_device_id did;
301 unsigned int interrupt_id;
302 /* struct iommu_table *iommu_table; -- waiting for Ben's cleanups */
303 struct ps3_dma_region *d_region;
304 struct ps3_mmio_region *m_region;
305 struct device core;
309 * struct ps3_system_bus_driver - a driver for a device on the system bus
312 struct ps3_system_bus_driver {
313 enum ps3_match_id match_id;
314 struct device_driver core;
315 int (*probe)(struct ps3_system_bus_device *);
316 int (*remove)(struct ps3_system_bus_device *);
317 /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
318 /* int (*resume)(struct ps3_system_bus_device *); */
321 int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
322 int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
323 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
324 static inline struct ps3_system_bus_driver *to_ps3_system_bus_driver(
325 struct device_driver *_drv)
327 return container_of(_drv, struct ps3_system_bus_driver, core);
329 static inline struct ps3_system_bus_device *to_ps3_system_bus_device(
330 struct device *_dev)
332 return container_of(_dev, struct ps3_system_bus_device, core);
336 * ps3_system_bus_set_drvdata -
337 * @dev: device structure
338 * @data: Data to set
341 static inline void ps3_system_bus_set_driver_data(
342 struct ps3_system_bus_device *dev, void *data)
344 dev->core.driver_data = data;
346 static inline void *ps3_system_bus_get_driver_data(
347 struct ps3_system_bus_device *dev)
349 return dev->core.driver_data;
352 /* These two need global scope for get_dma_ops(). */
354 extern struct bus_type ps3_system_bus_type;
356 /* vuart routines */
358 struct ps3_vuart_stats {
359 unsigned long bytes_written;
360 unsigned long bytes_read;
361 unsigned long tx_interrupts;
362 unsigned long rx_interrupts;
363 unsigned long disconnect_interrupts;
367 * struct ps3_vuart_port_device - a device on a vuart port
370 struct ps3_vuart_port_device {
371 enum ps3_match_id match_id;
372 struct device core;
374 /* private driver variables */
375 unsigned int port_number;
376 u64 interrupt_mask;
377 struct {
378 spinlock_t lock;
379 struct list_head head;
380 } tx_list;
381 struct {
382 unsigned long bytes_held;
383 spinlock_t lock;
384 struct list_head head;
385 } rx_list;
386 struct ps3_vuart_stats stats;
389 int ps3_vuart_port_device_register(struct ps3_vuart_port_device *dev);
391 #endif