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 {
38 int ps3_get_firmware_version(union ps3_firmware_version *v);
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);
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 {
65 enum ps3_dma_page_size {
72 enum ps3_dma_region_type {
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;
95 struct list_head head;
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)
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,
123 enum ps3_mmio_page_size {
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;
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)
154 r->bus_addr = bus_addr;
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,
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,
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,
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,
189 int ps3_free_irq(unsigned int virq);
191 /* lv1 result codes */
196 LV1_RESOURCE_SHORTAGE = -2,
197 LV1_NO_PRIVILEGE = -3,
198 LV1_DENIED_BY_POLICY = -4,
199 LV1_ACCESS_VIOLATION = -5,
201 LV1_DUPLICATE_ENTRY = -7,
202 LV1_TYPE_MISMATCH = -8,
205 LV1_WRONG_STATE = -11,
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)
226 return "LV1_SUCCESS (0)";
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)";
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)";
244 return "LV1_BUSY (-9)";
246 return "LV1_EMPTY (-10)";
247 case LV1_WRONG_STATE:
248 return "LV1_WRONG_STATE (-11)";
250 return "** unknown result ** (-12)";
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)";
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)";
277 return "** unknown result **";
284 /* system bus routines */
287 PS3_MATCH_ID_EHCI = 1,
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;
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(
332 return container_of(_dev, struct ps3_system_bus_device, core);
336 * ps3_system_bus_set_drvdata -
337 * @dev: device structure
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;
358 struct ps3_vuart_port_priv;
361 * struct ps3_vuart_port_device - a device on a vuart port
364 struct ps3_vuart_port_device {
365 enum ps3_match_id match_id;
367 struct ps3_vuart_port_priv* priv; /* private driver variables */
371 int ps3_vuart_port_device_register(struct ps3_vuart_port_device *dev);
375 void ps3_sys_manager_restart(void);
376 void ps3_sys_manager_power_off(void);
378 struct ps3_prealloc {
385 extern struct ps3_prealloc ps3fb_videomemory;