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_virq_setup(enum ps3_cpu_binding cpu
, unsigned long outlet
,
172 int ps3_virq_destroy(unsigned int virq
);
173 int ps3_irq_plug_setup(enum ps3_cpu_binding cpu
, unsigned long outlet
,
175 int ps3_irq_plug_destroy(unsigned int virq
);
176 int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu
, unsigned int *virq
);
177 int ps3_event_receive_port_destroy(unsigned int virq
);
178 int ps3_send_event_locally(unsigned int virq
);
180 int ps3_io_irq_setup(enum ps3_cpu_binding cpu
, unsigned int interrupt_id
,
182 int ps3_io_irq_destroy(unsigned int virq
);
183 int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu
, void* virt_addr_bmp
,
185 int ps3_vuart_irq_destroy(unsigned int virq
);
186 int ps3_spe_irq_setup(enum ps3_cpu_binding cpu
, unsigned long spe_id
,
187 unsigned int class, unsigned int *virq
);
188 int ps3_spe_irq_destroy(unsigned int virq
);
190 int ps3_sb_event_receive_port_setup(enum ps3_cpu_binding cpu
,
191 const struct ps3_device_id
*did
, unsigned int interrupt_id
,
193 int ps3_sb_event_receive_port_destroy(const struct ps3_device_id
*did
,
194 unsigned int interrupt_id
, unsigned int virq
);
196 /* lv1 result codes */
201 LV1_RESOURCE_SHORTAGE
= -2,
202 LV1_NO_PRIVILEGE
= -3,
203 LV1_DENIED_BY_POLICY
= -4,
204 LV1_ACCESS_VIOLATION
= -5,
206 LV1_DUPLICATE_ENTRY
= -7,
207 LV1_TYPE_MISMATCH
= -8,
210 LV1_WRONG_STATE
= -11,
213 LV1_ALREADY_CONNECTED
= -14,
214 LV1_UNSUPPORTED_PARAMETER_VALUE
= -15,
215 LV1_CONDITION_NOT_SATISFIED
= -16,
216 LV1_ILLEGAL_PARAMETER_VALUE
= -17,
217 LV1_BAD_OPTION
= -18,
218 LV1_IMPLEMENTATION_LIMITATION
= -19,
219 LV1_NOT_IMPLEMENTED
= -20,
220 LV1_INVALID_CLASS_ID
= -21,
221 LV1_CONSTRAINT_NOT_SATISFIED
= -22,
222 LV1_ALIGNMENT_ERROR
= -23,
223 LV1_INTERNAL_ERROR
= -32768,
226 static inline const char* ps3_result(int result
)
231 return "LV1_SUCCESS (0)";
233 return "** unknown result ** (-1)";
234 case LV1_RESOURCE_SHORTAGE
:
235 return "LV1_RESOURCE_SHORTAGE (-2)";
236 case LV1_NO_PRIVILEGE
:
237 return "LV1_NO_PRIVILEGE (-3)";
238 case LV1_DENIED_BY_POLICY
:
239 return "LV1_DENIED_BY_POLICY (-4)";
240 case LV1_ACCESS_VIOLATION
:
241 return "LV1_ACCESS_VIOLATION (-5)";
243 return "LV1_NO_ENTRY (-6)";
244 case LV1_DUPLICATE_ENTRY
:
245 return "LV1_DUPLICATE_ENTRY (-7)";
246 case LV1_TYPE_MISMATCH
:
247 return "LV1_TYPE_MISMATCH (-8)";
249 return "LV1_BUSY (-9)";
251 return "LV1_EMPTY (-10)";
252 case LV1_WRONG_STATE
:
253 return "LV1_WRONG_STATE (-11)";
255 return "** unknown result ** (-12)";
257 return "LV1_NO_MATCH (-13)";
258 case LV1_ALREADY_CONNECTED
:
259 return "LV1_ALREADY_CONNECTED (-14)";
260 case LV1_UNSUPPORTED_PARAMETER_VALUE
:
261 return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
262 case LV1_CONDITION_NOT_SATISFIED
:
263 return "LV1_CONDITION_NOT_SATISFIED (-16)";
264 case LV1_ILLEGAL_PARAMETER_VALUE
:
265 return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
267 return "LV1_BAD_OPTION (-18)";
268 case LV1_IMPLEMENTATION_LIMITATION
:
269 return "LV1_IMPLEMENTATION_LIMITATION (-19)";
270 case LV1_NOT_IMPLEMENTED
:
271 return "LV1_NOT_IMPLEMENTED (-20)";
272 case LV1_INVALID_CLASS_ID
:
273 return "LV1_INVALID_CLASS_ID (-21)";
274 case LV1_CONSTRAINT_NOT_SATISFIED
:
275 return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
276 case LV1_ALIGNMENT_ERROR
:
277 return "LV1_ALIGNMENT_ERROR (-23)";
278 case LV1_INTERNAL_ERROR
:
279 return "LV1_INTERNAL_ERROR (-32768)";
282 return "** unknown result **";
289 /* system bus routines */
292 PS3_MATCH_ID_EHCI
= 1,
295 PS3_MATCH_ID_AV_SETTINGS
,
296 PS3_MATCH_ID_SYSTEM_MANAGER
,
300 * struct ps3_system_bus_device - a device on the system bus
303 struct ps3_system_bus_device
{
304 enum ps3_match_id match_id
;
305 struct ps3_device_id did
;
306 unsigned int interrupt_id
;
307 /* struct iommu_table *iommu_table; -- waiting for Ben's cleanups */
308 struct ps3_dma_region
*d_region
;
309 struct ps3_mmio_region
*m_region
;
314 * struct ps3_system_bus_driver - a driver for a device on the system bus
317 struct ps3_system_bus_driver
{
318 enum ps3_match_id match_id
;
319 struct device_driver core
;
320 int (*probe
)(struct ps3_system_bus_device
*);
321 int (*remove
)(struct ps3_system_bus_device
*);
322 /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
323 /* int (*resume)(struct ps3_system_bus_device *); */
326 int ps3_system_bus_device_register(struct ps3_system_bus_device
*dev
);
327 int ps3_system_bus_driver_register(struct ps3_system_bus_driver
*drv
);
328 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver
*drv
);
329 static inline struct ps3_system_bus_driver
*to_ps3_system_bus_driver(
330 struct device_driver
*_drv
)
332 return container_of(_drv
, struct ps3_system_bus_driver
, core
);
334 static inline struct ps3_system_bus_device
*to_ps3_system_bus_device(
337 return container_of(_dev
, struct ps3_system_bus_device
, core
);
341 * ps3_system_bus_set_drvdata -
342 * @dev: device structure
346 static inline void ps3_system_bus_set_driver_data(
347 struct ps3_system_bus_device
*dev
, void *data
)
349 dev
->core
.driver_data
= data
;
351 static inline void *ps3_system_bus_get_driver_data(
352 struct ps3_system_bus_device
*dev
)
354 return dev
->core
.driver_data
;
357 /* These two need global scope for get_dma_ops(). */
359 extern struct bus_type ps3_system_bus_type
;
363 struct ps3_vuart_port_priv
;
366 * struct ps3_vuart_port_device - a device on a vuart port
369 struct ps3_vuart_port_device
{
370 enum ps3_match_id match_id
;
372 struct ps3_vuart_port_priv
* priv
; /* private driver variables */
376 int ps3_vuart_port_device_register(struct ps3_vuart_port_device
*dev
);
380 #ifdef CONFIG_PS3_SYS_MANAGER
381 void ps3_sys_manager_restart(void);
382 void ps3_sys_manager_power_off(void);
384 static inline void ps3_sys_manager_restart(void) {}
385 static inline void ps3_sys_manager_power_off(void) {}
388 struct ps3_prealloc
{
395 extern struct ps3_prealloc ps3fb_videomemory
;