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 void ps3_get_firmware_version(union ps3_firmware_version
*v
);
39 int ps3_compare_firmware_version(u16 major
, u16 minor
, u16 rev
);
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);
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..}
58 struct ps3_device_id
{
66 enum ps3_dma_page_size
{
73 enum ps3_dma_region_type
{
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.
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
;
96 struct list_head head
;
101 * struct ps3_dma_region_init - Helper to initialize structure variables
103 * Helper to properly initialize variables prior to calling
104 * ps3_system_bus_device_register.
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
)
112 r
->page_size
= page_size
;
113 r
->region_type
= region_type
;
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
,
124 enum ps3_mmio_page_size
{
130 * struct ps3_mmio_region - a per device mmio state variables structure
132 * Current systems can be supported with a single region per device.
135 struct ps3_mmio_region
{
136 struct ps3_device_id did
;
137 unsigned long bus_addr
;
139 enum ps3_mmio_page_size page_size
;
140 unsigned long lpar_addr
;
144 * struct ps3_mmio_region_init - Helper to initialize structure variables
146 * Helper to properly initialize variables prior to calling
147 * ps3_system_bus_device_register.
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
)
155 r
->bus_addr
= bus_addr
;
157 r
->page_size
= page_size
;
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
);
163 /* inrerrupt routines */
165 enum ps3_cpu_binding
{
166 PS3_BINDING_CPU_ANY
= -1,
167 PS3_BINDING_CPU_0
= 0,
168 PS3_BINDING_CPU_1
= 1,
171 int ps3_virq_setup(enum ps3_cpu_binding cpu
, unsigned long outlet
,
173 int ps3_virq_destroy(unsigned int virq
);
174 int ps3_irq_plug_setup(enum ps3_cpu_binding cpu
, unsigned long outlet
,
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
);
181 int ps3_io_irq_setup(enum ps3_cpu_binding cpu
, unsigned int interrupt_id
,
183 int ps3_io_irq_destroy(unsigned int virq
);
184 int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu
, void* virt_addr_bmp
,
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
);
191 int ps3_sb_event_receive_port_setup(enum ps3_cpu_binding cpu
,
192 const struct ps3_device_id
*did
, unsigned int interrupt_id
,
194 int ps3_sb_event_receive_port_destroy(const struct ps3_device_id
*did
,
195 unsigned int interrupt_id
, unsigned int virq
);
197 /* lv1 result codes */
202 LV1_RESOURCE_SHORTAGE
= -2,
203 LV1_NO_PRIVILEGE
= -3,
204 LV1_DENIED_BY_POLICY
= -4,
205 LV1_ACCESS_VIOLATION
= -5,
207 LV1_DUPLICATE_ENTRY
= -7,
208 LV1_TYPE_MISMATCH
= -8,
211 LV1_WRONG_STATE
= -11,
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,
227 static inline const char* ps3_result(int result
)
232 return "LV1_SUCCESS (0)";
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)";
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)";
250 return "LV1_BUSY (-9)";
252 return "LV1_EMPTY (-10)";
253 case LV1_WRONG_STATE
:
254 return "LV1_WRONG_STATE (-11)";
256 return "** unknown result ** (-12)";
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)";
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)";
283 return "** unknown result **";
290 /* system bus routines */
293 PS3_MATCH_ID_EHCI
= 1,
296 PS3_MATCH_ID_AV_SETTINGS
,
297 PS3_MATCH_ID_SYSTEM_MANAGER
,
301 * struct ps3_system_bus_device - a device on the system bus
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
;
315 * struct ps3_system_bus_driver - a driver for a device on the system bus
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 *); */
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
)
333 return container_of(_drv
, struct ps3_system_bus_driver
, core
);
335 static inline struct ps3_system_bus_device
*to_ps3_system_bus_device(
338 return container_of(_dev
, struct ps3_system_bus_device
, core
);
342 * ps3_system_bus_set_drvdata -
343 * @dev: device structure
347 static inline void ps3_system_bus_set_driver_data(
348 struct ps3_system_bus_device
*dev
, void *data
)
350 dev
->core
.driver_data
= data
;
352 static inline void *ps3_system_bus_get_driver_data(
353 struct ps3_system_bus_device
*dev
)
355 return dev
->core
.driver_data
;
358 /* These two need global scope for get_dma_ops(). */
360 extern struct bus_type ps3_system_bus_type
;
364 struct ps3_vuart_port_priv
;
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
;
373 struct ps3_vuart_port_priv
* priv
; /* private driver variables */
377 int ps3_vuart_port_device_register(struct ps3_vuart_port_device
*dev
);
381 #ifdef CONFIG_PS3_SYS_MANAGER
382 void ps3_sys_manager_restart(void);
383 void ps3_sys_manager_power_off(void);
385 static inline void ps3_sys_manager_restart(void) {}
386 static inline void ps3_sys_manager_power_off(void) {}
389 struct ps3_prealloc
{
396 extern struct ps3_prealloc ps3fb_videomemory
;