xref: /openbmc/linux/arch/powerpc/include/asm/ps3.h (revision b7810ea8)
1873e65bcSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b8b572e1SStephen Rothwell /*
3b8b572e1SStephen Rothwell  *  PS3 platform declarations.
4b8b572e1SStephen Rothwell  *
5b8b572e1SStephen Rothwell  *  Copyright (C) 2006 Sony Computer Entertainment Inc.
6b8b572e1SStephen Rothwell  *  Copyright 2006 Sony Corp.
7b8b572e1SStephen Rothwell  */
8b8b572e1SStephen Rothwell 
9b8b572e1SStephen Rothwell #if !defined(_ASM_POWERPC_PS3_H)
10b8b572e1SStephen Rothwell #define _ASM_POWERPC_PS3_H
11b8b572e1SStephen Rothwell 
12b8b572e1SStephen Rothwell #include <linux/types.h>
13b8b572e1SStephen Rothwell #include <linux/device.h>
14a1ce3928SDavid Howells #include <asm/cell-pmu.h>
15b8b572e1SStephen Rothwell 
16b8b572e1SStephen Rothwell union ps3_firmware_version {
17b8b572e1SStephen Rothwell 	u64 raw;
18b8b572e1SStephen Rothwell 	struct {
19b8b572e1SStephen Rothwell 		u16 pad;
20b8b572e1SStephen Rothwell 		u16 major;
21b8b572e1SStephen Rothwell 		u16 minor;
22b8b572e1SStephen Rothwell 		u16 rev;
23b8b572e1SStephen Rothwell 	};
24b8b572e1SStephen Rothwell };
25b8b572e1SStephen Rothwell 
26b8b572e1SStephen Rothwell void ps3_get_firmware_version(union ps3_firmware_version *v);
27b8b572e1SStephen Rothwell int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev);
28b8b572e1SStephen Rothwell 
29b8b572e1SStephen Rothwell /* 'Other OS' area */
30b8b572e1SStephen Rothwell 
31b8b572e1SStephen Rothwell enum ps3_param_av_multi_out {
32b8b572e1SStephen Rothwell 	PS3_PARAM_AV_MULTI_OUT_NTSC = 0,
33b8b572e1SStephen Rothwell 	PS3_PARAM_AV_MULTI_OUT_PAL_RGB = 1,
34b8b572e1SStephen Rothwell 	PS3_PARAM_AV_MULTI_OUT_PAL_YCBCR = 2,
35b8b572e1SStephen Rothwell 	PS3_PARAM_AV_MULTI_OUT_SECAM = 3,
36b8b572e1SStephen Rothwell };
37b8b572e1SStephen Rothwell 
38b8b572e1SStephen Rothwell enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);
39b8b572e1SStephen Rothwell 
400b5f037aSGeert Uytterhoeven extern u64 ps3_os_area_get_rtc_diff(void);
410b5f037aSGeert Uytterhoeven extern void ps3_os_area_set_rtc_diff(u64 rtc_diff);
420b5f037aSGeert Uytterhoeven 
43a4e623fbSGeert Uytterhoeven struct ps3_os_area_flash_ops {
44a4e623fbSGeert Uytterhoeven 	ssize_t (*read)(void *buf, size_t count, loff_t pos);
45a4e623fbSGeert Uytterhoeven 	ssize_t (*write)(const void *buf, size_t count, loff_t pos);
46a4e623fbSGeert Uytterhoeven };
47a4e623fbSGeert Uytterhoeven 
48a4e623fbSGeert Uytterhoeven extern void ps3_os_area_flash_register(const struct ps3_os_area_flash_ops *ops);
49a4e623fbSGeert Uytterhoeven 
50b8b572e1SStephen Rothwell /* dma routines */
51b8b572e1SStephen Rothwell 
52b8b572e1SStephen Rothwell enum ps3_dma_page_size {
53b8b572e1SStephen Rothwell 	PS3_DMA_4K = 12U,
54b8b572e1SStephen Rothwell 	PS3_DMA_64K = 16U,
55b8b572e1SStephen Rothwell 	PS3_DMA_1M = 20U,
56b8b572e1SStephen Rothwell 	PS3_DMA_16M = 24U,
57b8b572e1SStephen Rothwell };
58b8b572e1SStephen Rothwell 
59b8b572e1SStephen Rothwell enum ps3_dma_region_type {
60b8b572e1SStephen Rothwell 	PS3_DMA_OTHER = 0,
61b8b572e1SStephen Rothwell 	PS3_DMA_INTERNAL = 2,
62b8b572e1SStephen Rothwell };
63b8b572e1SStephen Rothwell 
64b8b572e1SStephen Rothwell struct ps3_dma_region_ops;
65b8b572e1SStephen Rothwell 
66b8b572e1SStephen Rothwell /**
67b8b572e1SStephen Rothwell  * struct ps3_dma_region - A per device dma state variables structure
68b8b572e1SStephen Rothwell  * @did: The HV device id.
69b8b572e1SStephen Rothwell  * @page_size: The ioc pagesize.
70b8b572e1SStephen Rothwell  * @region_type: The HV region type.
71b8b572e1SStephen Rothwell  * @bus_addr: The 'translated' bus address of the region.
72b8b572e1SStephen Rothwell  * @len: The length in bytes of the region.
73b8b572e1SStephen Rothwell  * @offset: The offset from the start of memory of the region.
749733862eSGeoff Levand  * @dma_mask: Device dma_mask.
75b8b572e1SStephen Rothwell  * @ioid: The IOID of the device who owns this region
76b8b572e1SStephen Rothwell  * @chunk_list: Opaque variable used by the ioc page manager.
77b8b572e1SStephen Rothwell  * @region_ops: struct ps3_dma_region_ops - dma region operations
78b8b572e1SStephen Rothwell  */
79b8b572e1SStephen Rothwell 
80b8b572e1SStephen Rothwell struct ps3_dma_region {
81b8b572e1SStephen Rothwell 	struct ps3_system_bus_device *dev;
82b8b572e1SStephen Rothwell 	/* device variables */
83b8b572e1SStephen Rothwell 	const struct ps3_dma_region_ops *region_ops;
84b8b572e1SStephen Rothwell 	unsigned char ioid;
85b8b572e1SStephen Rothwell 	enum ps3_dma_page_size page_size;
86b8b572e1SStephen Rothwell 	enum ps3_dma_region_type region_type;
87b8b572e1SStephen Rothwell 	unsigned long len;
88b8b572e1SStephen Rothwell 	unsigned long offset;
899733862eSGeoff Levand 	u64 dma_mask;
90b8b572e1SStephen Rothwell 
91b8b572e1SStephen Rothwell 	/* driver variables  (set by ps3_dma_region_create) */
92b8b572e1SStephen Rothwell 	unsigned long bus_addr;
93b8b572e1SStephen Rothwell 	struct {
94b8b572e1SStephen Rothwell 		spinlock_t lock;
95b8b572e1SStephen Rothwell 		struct list_head head;
96b8b572e1SStephen Rothwell 	} chunk_list;
97b8b572e1SStephen Rothwell };
98b8b572e1SStephen Rothwell 
99b8b572e1SStephen Rothwell struct ps3_dma_region_ops {
100b8b572e1SStephen Rothwell 	int (*create)(struct ps3_dma_region *);
101b8b572e1SStephen Rothwell 	int (*free)(struct ps3_dma_region *);
102b8b572e1SStephen Rothwell 	int (*map)(struct ps3_dma_region *,
103b8b572e1SStephen Rothwell 		   unsigned long virt_addr,
104b8b572e1SStephen Rothwell 		   unsigned long len,
105494fd07aSStephen Rothwell 		   dma_addr_t *bus_addr,
106b8b572e1SStephen Rothwell 		   u64 iopte_pp);
107b8b572e1SStephen Rothwell 	int (*unmap)(struct ps3_dma_region *,
108494fd07aSStephen Rothwell 		     dma_addr_t bus_addr,
109b8b572e1SStephen Rothwell 		     unsigned long len);
110b8b572e1SStephen Rothwell };
111b8b572e1SStephen Rothwell /**
112b8b572e1SStephen Rothwell  * struct ps3_dma_region_init - Helper to initialize structure variables
113b8b572e1SStephen Rothwell  *
114b8b572e1SStephen Rothwell  * Helper to properly initialize variables prior to calling
115b8b572e1SStephen Rothwell  * ps3_system_bus_device_register.
116b8b572e1SStephen Rothwell  */
117b8b572e1SStephen Rothwell 
118b8b572e1SStephen Rothwell struct ps3_system_bus_device;
119b8b572e1SStephen Rothwell 
120b8b572e1SStephen Rothwell int ps3_dma_region_init(struct ps3_system_bus_device *dev,
121b8b572e1SStephen Rothwell 	struct ps3_dma_region *r, enum ps3_dma_page_size page_size,
122b8b572e1SStephen Rothwell 	enum ps3_dma_region_type region_type, void *addr, unsigned long len);
123b8b572e1SStephen Rothwell int ps3_dma_region_create(struct ps3_dma_region *r);
124b8b572e1SStephen Rothwell int ps3_dma_region_free(struct ps3_dma_region *r);
125b8b572e1SStephen Rothwell int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
126494fd07aSStephen Rothwell 	unsigned long len, dma_addr_t *bus_addr,
127b8b572e1SStephen Rothwell 	u64 iopte_pp);
128494fd07aSStephen Rothwell int ps3_dma_unmap(struct ps3_dma_region *r, dma_addr_t bus_addr,
129b8b572e1SStephen Rothwell 	unsigned long len);
130b8b572e1SStephen Rothwell 
131b8b572e1SStephen Rothwell /* mmio routines */
132b8b572e1SStephen Rothwell 
133b8b572e1SStephen Rothwell enum ps3_mmio_page_size {
134b8b572e1SStephen Rothwell 	PS3_MMIO_4K = 12U,
135b8b572e1SStephen Rothwell 	PS3_MMIO_64K = 16U
136b8b572e1SStephen Rothwell };
137b8b572e1SStephen Rothwell 
138b8b572e1SStephen Rothwell struct ps3_mmio_region_ops;
139b8b572e1SStephen Rothwell /**
140b8b572e1SStephen Rothwell  * struct ps3_mmio_region - a per device mmio state variables structure
141b8b572e1SStephen Rothwell  *
142b8b572e1SStephen Rothwell  * Current systems can be supported with a single region per device.
143b8b572e1SStephen Rothwell  */
144b8b572e1SStephen Rothwell 
145b8b572e1SStephen Rothwell struct ps3_mmio_region {
146b8b572e1SStephen Rothwell 	struct ps3_system_bus_device *dev;
147b8b572e1SStephen Rothwell 	const struct ps3_mmio_region_ops *mmio_ops;
148b8b572e1SStephen Rothwell 	unsigned long bus_addr;
149b8b572e1SStephen Rothwell 	unsigned long len;
150b8b572e1SStephen Rothwell 	enum ps3_mmio_page_size page_size;
151b8b572e1SStephen Rothwell 	unsigned long lpar_addr;
152b8b572e1SStephen Rothwell };
153b8b572e1SStephen Rothwell 
154b8b572e1SStephen Rothwell struct ps3_mmio_region_ops {
155b8b572e1SStephen Rothwell 	int (*create)(struct ps3_mmio_region *);
156b8b572e1SStephen Rothwell 	int (*free)(struct ps3_mmio_region *);
157b8b572e1SStephen Rothwell };
158b8b572e1SStephen Rothwell /**
159b8b572e1SStephen Rothwell  * struct ps3_mmio_region_init - Helper to initialize structure variables
160b8b572e1SStephen Rothwell  *
161b8b572e1SStephen Rothwell  * Helper to properly initialize variables prior to calling
162b8b572e1SStephen Rothwell  * ps3_system_bus_device_register.
163b8b572e1SStephen Rothwell  */
164b8b572e1SStephen Rothwell 
165b8b572e1SStephen Rothwell int ps3_mmio_region_init(struct ps3_system_bus_device *dev,
166b8b572e1SStephen Rothwell 	struct ps3_mmio_region *r, unsigned long bus_addr, unsigned long len,
167b8b572e1SStephen Rothwell 	enum ps3_mmio_page_size page_size);
168b8b572e1SStephen Rothwell int ps3_mmio_region_create(struct ps3_mmio_region *r);
169b8b572e1SStephen Rothwell int ps3_free_mmio_region(struct ps3_mmio_region *r);
170b8b572e1SStephen Rothwell unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
171b8b572e1SStephen Rothwell 
172b8b572e1SStephen Rothwell /* inrerrupt routines */
173b8b572e1SStephen Rothwell 
174b8b572e1SStephen Rothwell enum ps3_cpu_binding {
175b8b572e1SStephen Rothwell 	PS3_BINDING_CPU_ANY = -1,
176b8b572e1SStephen Rothwell 	PS3_BINDING_CPU_0 = 0,
177b8b572e1SStephen Rothwell 	PS3_BINDING_CPU_1 = 1,
178b8b572e1SStephen Rothwell };
179b8b572e1SStephen Rothwell 
180b8b572e1SStephen Rothwell int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
181b8b572e1SStephen Rothwell 	unsigned int *virq);
182b8b572e1SStephen Rothwell int ps3_irq_plug_destroy(unsigned int virq);
183b8b572e1SStephen Rothwell int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq);
184b8b572e1SStephen Rothwell int ps3_event_receive_port_destroy(unsigned int virq);
185b8b572e1SStephen Rothwell int ps3_send_event_locally(unsigned int virq);
186b8b572e1SStephen Rothwell 
187b8b572e1SStephen Rothwell int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
188b8b572e1SStephen Rothwell 	unsigned int *virq);
189b8b572e1SStephen Rothwell int ps3_io_irq_destroy(unsigned int virq);
190b8b572e1SStephen Rothwell int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
191b8b572e1SStephen Rothwell 	unsigned int *virq);
192b8b572e1SStephen Rothwell int ps3_vuart_irq_destroy(unsigned int virq);
193b8b572e1SStephen Rothwell int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id,
194b8b572e1SStephen Rothwell 	unsigned int class, unsigned int *virq);
195b8b572e1SStephen Rothwell int ps3_spe_irq_destroy(unsigned int virq);
196b8b572e1SStephen Rothwell 
197b8b572e1SStephen Rothwell int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev,
198b8b572e1SStephen Rothwell 	enum ps3_cpu_binding cpu, unsigned int *virq);
199b8b572e1SStephen Rothwell int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev,
200b8b572e1SStephen Rothwell 	unsigned int virq);
201b8b572e1SStephen Rothwell 
202b8b572e1SStephen Rothwell /* lv1 result codes */
203b8b572e1SStephen Rothwell 
204b8b572e1SStephen Rothwell enum lv1_result {
205b8b572e1SStephen Rothwell 	LV1_SUCCESS                     = 0,
206b8b572e1SStephen Rothwell 	/* not used                       -1 */
207b8b572e1SStephen Rothwell 	LV1_RESOURCE_SHORTAGE           = -2,
208b8b572e1SStephen Rothwell 	LV1_NO_PRIVILEGE                = -3,
209b8b572e1SStephen Rothwell 	LV1_DENIED_BY_POLICY            = -4,
210b8b572e1SStephen Rothwell 	LV1_ACCESS_VIOLATION            = -5,
211b8b572e1SStephen Rothwell 	LV1_NO_ENTRY                    = -6,
212b8b572e1SStephen Rothwell 	LV1_DUPLICATE_ENTRY             = -7,
213b8b572e1SStephen Rothwell 	LV1_TYPE_MISMATCH               = -8,
214b8b572e1SStephen Rothwell 	LV1_BUSY                        = -9,
215b8b572e1SStephen Rothwell 	LV1_EMPTY                       = -10,
216b8b572e1SStephen Rothwell 	LV1_WRONG_STATE                 = -11,
217b8b572e1SStephen Rothwell 	/* not used                       -12 */
218b8b572e1SStephen Rothwell 	LV1_NO_MATCH                    = -13,
219b8b572e1SStephen Rothwell 	LV1_ALREADY_CONNECTED           = -14,
220b8b572e1SStephen Rothwell 	LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
221b8b572e1SStephen Rothwell 	LV1_CONDITION_NOT_SATISFIED     = -16,
222b8b572e1SStephen Rothwell 	LV1_ILLEGAL_PARAMETER_VALUE     = -17,
223b8b572e1SStephen Rothwell 	LV1_BAD_OPTION                  = -18,
224b8b572e1SStephen Rothwell 	LV1_IMPLEMENTATION_LIMITATION   = -19,
225b8b572e1SStephen Rothwell 	LV1_NOT_IMPLEMENTED             = -20,
226b8b572e1SStephen Rothwell 	LV1_INVALID_CLASS_ID            = -21,
227b8b572e1SStephen Rothwell 	LV1_CONSTRAINT_NOT_SATISFIED    = -22,
228b8b572e1SStephen Rothwell 	LV1_ALIGNMENT_ERROR             = -23,
229b8b572e1SStephen Rothwell 	LV1_HARDWARE_ERROR              = -24,
230b8b572e1SStephen Rothwell 	LV1_INVALID_DATA_FORMAT         = -25,
231b8b572e1SStephen Rothwell 	LV1_INVALID_OPERATION           = -26,
232b8b572e1SStephen Rothwell 	LV1_INTERNAL_ERROR              = -32768,
233b8b572e1SStephen Rothwell };
234b8b572e1SStephen Rothwell 
ps3_result(int result)235b8b572e1SStephen Rothwell static inline const char* ps3_result(int result)
236b8b572e1SStephen Rothwell {
2376caebff1SGeoff Levand #if defined(DEBUG) || defined(PS3_VERBOSE_RESULT) || defined(CONFIG_PS3_VERBOSE_RESULT)
238b8b572e1SStephen Rothwell 	switch (result) {
239b8b572e1SStephen Rothwell 	case LV1_SUCCESS:
240b8b572e1SStephen Rothwell 		return "LV1_SUCCESS (0)";
241b8b572e1SStephen Rothwell 	case -1:
242b8b572e1SStephen Rothwell 		return "** unknown result ** (-1)";
243b8b572e1SStephen Rothwell 	case LV1_RESOURCE_SHORTAGE:
244b8b572e1SStephen Rothwell 		return "LV1_RESOURCE_SHORTAGE (-2)";
245b8b572e1SStephen Rothwell 	case LV1_NO_PRIVILEGE:
246b8b572e1SStephen Rothwell 		return "LV1_NO_PRIVILEGE (-3)";
247b8b572e1SStephen Rothwell 	case LV1_DENIED_BY_POLICY:
248b8b572e1SStephen Rothwell 		return "LV1_DENIED_BY_POLICY (-4)";
249b8b572e1SStephen Rothwell 	case LV1_ACCESS_VIOLATION:
250b8b572e1SStephen Rothwell 		return "LV1_ACCESS_VIOLATION (-5)";
251b8b572e1SStephen Rothwell 	case LV1_NO_ENTRY:
252b8b572e1SStephen Rothwell 		return "LV1_NO_ENTRY (-6)";
253b8b572e1SStephen Rothwell 	case LV1_DUPLICATE_ENTRY:
254b8b572e1SStephen Rothwell 		return "LV1_DUPLICATE_ENTRY (-7)";
255b8b572e1SStephen Rothwell 	case LV1_TYPE_MISMATCH:
256b8b572e1SStephen Rothwell 		return "LV1_TYPE_MISMATCH (-8)";
257b8b572e1SStephen Rothwell 	case LV1_BUSY:
258b8b572e1SStephen Rothwell 		return "LV1_BUSY (-9)";
259b8b572e1SStephen Rothwell 	case LV1_EMPTY:
260b8b572e1SStephen Rothwell 		return "LV1_EMPTY (-10)";
261b8b572e1SStephen Rothwell 	case LV1_WRONG_STATE:
262b8b572e1SStephen Rothwell 		return "LV1_WRONG_STATE (-11)";
263b8b572e1SStephen Rothwell 	case -12:
264b8b572e1SStephen Rothwell 		return "** unknown result ** (-12)";
265b8b572e1SStephen Rothwell 	case LV1_NO_MATCH:
266b8b572e1SStephen Rothwell 		return "LV1_NO_MATCH (-13)";
267b8b572e1SStephen Rothwell 	case LV1_ALREADY_CONNECTED:
268b8b572e1SStephen Rothwell 		return "LV1_ALREADY_CONNECTED (-14)";
269b8b572e1SStephen Rothwell 	case LV1_UNSUPPORTED_PARAMETER_VALUE:
270b8b572e1SStephen Rothwell 		return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
271b8b572e1SStephen Rothwell 	case LV1_CONDITION_NOT_SATISFIED:
272b8b572e1SStephen Rothwell 		return "LV1_CONDITION_NOT_SATISFIED (-16)";
273b8b572e1SStephen Rothwell 	case LV1_ILLEGAL_PARAMETER_VALUE:
274b8b572e1SStephen Rothwell 		return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
275b8b572e1SStephen Rothwell 	case LV1_BAD_OPTION:
276b8b572e1SStephen Rothwell 		return "LV1_BAD_OPTION (-18)";
277b8b572e1SStephen Rothwell 	case LV1_IMPLEMENTATION_LIMITATION:
278b8b572e1SStephen Rothwell 		return "LV1_IMPLEMENTATION_LIMITATION (-19)";
279b8b572e1SStephen Rothwell 	case LV1_NOT_IMPLEMENTED:
280b8b572e1SStephen Rothwell 		return "LV1_NOT_IMPLEMENTED (-20)";
281b8b572e1SStephen Rothwell 	case LV1_INVALID_CLASS_ID:
282b8b572e1SStephen Rothwell 		return "LV1_INVALID_CLASS_ID (-21)";
283b8b572e1SStephen Rothwell 	case LV1_CONSTRAINT_NOT_SATISFIED:
284b8b572e1SStephen Rothwell 		return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
285b8b572e1SStephen Rothwell 	case LV1_ALIGNMENT_ERROR:
286b8b572e1SStephen Rothwell 		return "LV1_ALIGNMENT_ERROR (-23)";
287b8b572e1SStephen Rothwell 	case LV1_HARDWARE_ERROR:
288b8b572e1SStephen Rothwell 		return "LV1_HARDWARE_ERROR (-24)";
289b8b572e1SStephen Rothwell 	case LV1_INVALID_DATA_FORMAT:
290b8b572e1SStephen Rothwell 		return "LV1_INVALID_DATA_FORMAT (-25)";
291b8b572e1SStephen Rothwell 	case LV1_INVALID_OPERATION:
292b8b572e1SStephen Rothwell 		return "LV1_INVALID_OPERATION (-26)";
293b8b572e1SStephen Rothwell 	case LV1_INTERNAL_ERROR:
294b8b572e1SStephen Rothwell 		return "LV1_INTERNAL_ERROR (-32768)";
295b8b572e1SStephen Rothwell 	default:
296b8b572e1SStephen Rothwell 		BUG();
297b8b572e1SStephen Rothwell 		return "** unknown result **";
298b8b572e1SStephen Rothwell 	};
299b8b572e1SStephen Rothwell #else
300b8b572e1SStephen Rothwell 	return "";
301b8b572e1SStephen Rothwell #endif
302b8b572e1SStephen Rothwell }
303b8b572e1SStephen Rothwell 
304b8b572e1SStephen Rothwell /* system bus routines */
305b8b572e1SStephen Rothwell 
306b8b572e1SStephen Rothwell enum ps3_match_id {
307b8b572e1SStephen Rothwell 	PS3_MATCH_ID_EHCI		= 1,
308b8b572e1SStephen Rothwell 	PS3_MATCH_ID_OHCI		= 2,
309b8b572e1SStephen Rothwell 	PS3_MATCH_ID_GELIC		= 3,
310b8b572e1SStephen Rothwell 	PS3_MATCH_ID_AV_SETTINGS	= 4,
311b8b572e1SStephen Rothwell 	PS3_MATCH_ID_SYSTEM_MANAGER	= 5,
312b8b572e1SStephen Rothwell 	PS3_MATCH_ID_STOR_DISK		= 6,
313b8b572e1SStephen Rothwell 	PS3_MATCH_ID_STOR_ROM		= 7,
314b8b572e1SStephen Rothwell 	PS3_MATCH_ID_STOR_FLASH		= 8,
315b8b572e1SStephen Rothwell 	PS3_MATCH_ID_SOUND		= 9,
31646d01492SGeert Uytterhoeven 	PS3_MATCH_ID_GPU		= 10,
317b8b572e1SStephen Rothwell 	PS3_MATCH_ID_LPM		= 11,
318b8b572e1SStephen Rothwell };
319b8b572e1SStephen Rothwell 
32046d01492SGeert Uytterhoeven enum ps3_match_sub_id {
32146d01492SGeert Uytterhoeven 	PS3_MATCH_SUB_ID_GPU_FB		= 1,
322cffb4addSJim Paris 	PS3_MATCH_SUB_ID_GPU_RAMDISK	= 2,
32346d01492SGeert Uytterhoeven };
32446d01492SGeert Uytterhoeven 
32546d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_EHCI		"ps3:1:0"
32646d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_OHCI		"ps3:2:0"
32746d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_GELIC		"ps3:3:0"
32846d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_AV_SETTINGS	"ps3:4:0"
32946d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_SYSTEM_MANAGER	"ps3:5:0"
33046d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_STOR_DISK	"ps3:6:0"
33146d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_STOR_ROM	"ps3:7:0"
33246d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_STOR_FLASH	"ps3:8:0"
33346d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_SOUND		"ps3:9:0"
33446d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_GPU_FB		"ps3:10:1"
3350a2d15b9SGeert Uytterhoeven #define PS3_MODULE_ALIAS_GPU_RAMDISK	"ps3:10:2"
33646d01492SGeert Uytterhoeven #define PS3_MODULE_ALIAS_LPM		"ps3:11:0"
337b8b572e1SStephen Rothwell 
338b8b572e1SStephen Rothwell enum ps3_system_bus_device_type {
339b8b572e1SStephen Rothwell 	PS3_DEVICE_TYPE_IOC0 = 1,
340b8b572e1SStephen Rothwell 	PS3_DEVICE_TYPE_SB,
341b8b572e1SStephen Rothwell 	PS3_DEVICE_TYPE_VUART,
342b8b572e1SStephen Rothwell 	PS3_DEVICE_TYPE_LPM,
343b8b572e1SStephen Rothwell };
344b8b572e1SStephen Rothwell 
345b8b572e1SStephen Rothwell /**
346b8b572e1SStephen Rothwell  * struct ps3_system_bus_device - a device on the system bus
347b8b572e1SStephen Rothwell  */
348b8b572e1SStephen Rothwell 
349b8b572e1SStephen Rothwell struct ps3_system_bus_device {
350b8b572e1SStephen Rothwell 	enum ps3_match_id match_id;
351b8b572e1SStephen Rothwell 	enum ps3_match_sub_id match_sub_id;
352b8b572e1SStephen Rothwell 	enum ps3_system_bus_device_type dev_type;
353b8b572e1SStephen Rothwell 
354b8b572e1SStephen Rothwell 	u64 bus_id;                       /* SB */
355b8b572e1SStephen Rothwell 	u64 dev_id;                       /* SB */
356b8b572e1SStephen Rothwell 	unsigned int interrupt_id;        /* SB */
357b8b572e1SStephen Rothwell 	struct ps3_dma_region *d_region;  /* SB, IOC0 */
358b8b572e1SStephen Rothwell 	struct ps3_mmio_region *m_region; /* SB, IOC0*/
359b8b572e1SStephen Rothwell 	unsigned int port_number;         /* VUART */
360b8b572e1SStephen Rothwell 	struct {                          /* LPM */
361b8b572e1SStephen Rothwell 		u64 node_id;
362b8b572e1SStephen Rothwell 		u64 pu_id;
363b8b572e1SStephen Rothwell 		u64 rights;
364b8b572e1SStephen Rothwell 	} lpm;
365b8b572e1SStephen Rothwell 
366b8b572e1SStephen Rothwell /*	struct iommu_table *iommu_table; -- waiting for BenH's cleanups */
367b8b572e1SStephen Rothwell 	struct device core;
368b8b572e1SStephen Rothwell 	void *driver_priv; /* private driver variables */
369b8b572e1SStephen Rothwell };
370b8b572e1SStephen Rothwell 
371b8b572e1SStephen Rothwell int ps3_open_hv_device(struct ps3_system_bus_device *dev);
372b8b572e1SStephen Rothwell int ps3_close_hv_device(struct ps3_system_bus_device *dev);
373b8b572e1SStephen Rothwell 
374b8b572e1SStephen Rothwell /**
375b8b572e1SStephen Rothwell  * struct ps3_system_bus_driver - a driver for a device on the system bus
376b8b572e1SStephen Rothwell  */
377b8b572e1SStephen Rothwell 
378b8b572e1SStephen Rothwell struct ps3_system_bus_driver {
379b8b572e1SStephen Rothwell 	enum ps3_match_id match_id;
380b8b572e1SStephen Rothwell 	enum ps3_match_sub_id match_sub_id;
381b8b572e1SStephen Rothwell 	struct device_driver core;
382b8b572e1SStephen Rothwell 	int (*probe)(struct ps3_system_bus_device *);
3836d247e4dSUwe Kleine-König 	void (*remove)(struct ps3_system_bus_device *);
3846d247e4dSUwe Kleine-König 	void (*shutdown)(struct ps3_system_bus_device *);
385b8b572e1SStephen Rothwell /*	int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
386b8b572e1SStephen Rothwell /*	int (*resume)(struct ps3_system_bus_device *); */
387b8b572e1SStephen Rothwell };
388b8b572e1SStephen Rothwell 
389b8b572e1SStephen Rothwell int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
390b8b572e1SStephen Rothwell int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
391b8b572e1SStephen Rothwell void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
392b8b572e1SStephen Rothwell 
ps3_drv_to_system_bus_drv(struct device_driver * _drv)393b8b572e1SStephen Rothwell static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv(
394b8b572e1SStephen Rothwell 	struct device_driver *_drv)
395b8b572e1SStephen Rothwell {
396b8b572e1SStephen Rothwell 	return container_of(_drv, struct ps3_system_bus_driver, core);
397b8b572e1SStephen Rothwell }
ps3_dev_to_system_bus_dev(const struct device * _dev)398b8b572e1SStephen Rothwell static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev(
399*b7810ea8SStephen Rothwell 	const struct device *_dev)
400b8b572e1SStephen Rothwell {
401b8b572e1SStephen Rothwell 	return container_of(_dev, struct ps3_system_bus_device, core);
402b8b572e1SStephen Rothwell }
403b8b572e1SStephen Rothwell static inline struct ps3_system_bus_driver *
ps3_system_bus_dev_to_system_bus_drv(struct ps3_system_bus_device * _dev)404b8b572e1SStephen Rothwell 	ps3_system_bus_dev_to_system_bus_drv(struct ps3_system_bus_device *_dev)
405b8b572e1SStephen Rothwell {
406b8b572e1SStephen Rothwell 	BUG_ON(!_dev);
407b8b572e1SStephen Rothwell 	BUG_ON(!_dev->core.driver);
408b8b572e1SStephen Rothwell 	return ps3_drv_to_system_bus_drv(_dev->core.driver);
409b8b572e1SStephen Rothwell }
410b8b572e1SStephen Rothwell 
411b8b572e1SStephen Rothwell /**
412b8b572e1SStephen Rothwell  * ps3_system_bus_set_drvdata -
413b8b572e1SStephen Rothwell  * @dev: device structure
414b8b572e1SStephen Rothwell  * @data: Data to set
415b8b572e1SStephen Rothwell  */
416b8b572e1SStephen Rothwell 
ps3_system_bus_set_drvdata(struct ps3_system_bus_device * dev,void * data)41703fa68c2SGeert Uytterhoeven static inline void ps3_system_bus_set_drvdata(
418b8b572e1SStephen Rothwell 	struct ps3_system_bus_device *dev, void *data)
419b8b572e1SStephen Rothwell {
4209f08e9dbSGeert Uytterhoeven 	dev_set_drvdata(&dev->core, data);
421b8b572e1SStephen Rothwell }
ps3_system_bus_get_drvdata(struct ps3_system_bus_device * dev)42203fa68c2SGeert Uytterhoeven static inline void *ps3_system_bus_get_drvdata(
423b8b572e1SStephen Rothwell 	struct ps3_system_bus_device *dev)
424b8b572e1SStephen Rothwell {
4259f08e9dbSGeert Uytterhoeven 	return dev_get_drvdata(&dev->core);
426b8b572e1SStephen Rothwell }
427b8b572e1SStephen Rothwell 
428b8b572e1SStephen Rothwell /* system manager */
429b8b572e1SStephen Rothwell 
430b8b572e1SStephen Rothwell struct ps3_sys_manager_ops {
431b8b572e1SStephen Rothwell 	struct ps3_system_bus_device *dev;
432b8b572e1SStephen Rothwell 	void (*power_off)(struct ps3_system_bus_device *dev);
433b8b572e1SStephen Rothwell 	void (*restart)(struct ps3_system_bus_device *dev);
434b8b572e1SStephen Rothwell };
435b8b572e1SStephen Rothwell 
436b8b572e1SStephen Rothwell void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops);
437b8b572e1SStephen Rothwell void __noreturn ps3_sys_manager_power_off(void);
438b8b572e1SStephen Rothwell void __noreturn ps3_sys_manager_restart(void);
439b8b572e1SStephen Rothwell void __noreturn ps3_sys_manager_halt(void);
440b8b572e1SStephen Rothwell int ps3_sys_manager_get_wol(void);
441b8b572e1SStephen Rothwell void ps3_sys_manager_set_wol(int state);
442b8b572e1SStephen Rothwell 
443b8b572e1SStephen Rothwell struct ps3_prealloc {
444b8b572e1SStephen Rothwell     const char *name;
445b8b572e1SStephen Rothwell     void *address;
446b8b572e1SStephen Rothwell     unsigned long size;
447b8b572e1SStephen Rothwell     unsigned long align;
448b8b572e1SStephen Rothwell };
449b8b572e1SStephen Rothwell 
450b8b572e1SStephen Rothwell extern struct ps3_prealloc ps3fb_videomemory;
451b8b572e1SStephen Rothwell extern struct ps3_prealloc ps3flash_bounce_buffer;
452b8b572e1SStephen Rothwell 
453b8b572e1SStephen Rothwell /* logical performance monitor */
454b8b572e1SStephen Rothwell 
455b8b572e1SStephen Rothwell /**
456b8b572e1SStephen Rothwell  * enum ps3_lpm_rights - Rigths granted by the system policy module.
457b8b572e1SStephen Rothwell  *
458b8b572e1SStephen Rothwell  * @PS3_LPM_RIGHTS_USE_LPM: The right to use the lpm.
459b8b572e1SStephen Rothwell  * @PS3_LPM_RIGHTS_USE_TB: The right to use the internal trace buffer.
460b8b572e1SStephen Rothwell  */
461b8b572e1SStephen Rothwell 
462b8b572e1SStephen Rothwell enum ps3_lpm_rights {
463b8b572e1SStephen Rothwell 	PS3_LPM_RIGHTS_USE_LPM = 0x001,
464b8b572e1SStephen Rothwell 	PS3_LPM_RIGHTS_USE_TB = 0x100,
465b8b572e1SStephen Rothwell };
466b8b572e1SStephen Rothwell 
467b8b572e1SStephen Rothwell /**
468b8b572e1SStephen Rothwell  * enum ps3_lpm_tb_type - Type of trace buffer lv1 should use.
469b8b572e1SStephen Rothwell  *
470b8b572e1SStephen Rothwell  * @PS3_LPM_TB_TYPE_NONE: Do not use a trace buffer.
471b8b572e1SStephen Rothwell  * @PS3_LPM_RIGHTS_USE_TB: Use the lv1 internal trace buffer.  Must have
472b8b572e1SStephen Rothwell  *  rights @PS3_LPM_RIGHTS_USE_TB.
473b8b572e1SStephen Rothwell  */
474b8b572e1SStephen Rothwell 
475b8b572e1SStephen Rothwell enum ps3_lpm_tb_type {
476b8b572e1SStephen Rothwell 	PS3_LPM_TB_TYPE_NONE = 0,
477b8b572e1SStephen Rothwell 	PS3_LPM_TB_TYPE_INTERNAL = 1,
478b8b572e1SStephen Rothwell };
479b8b572e1SStephen Rothwell 
480b8b572e1SStephen Rothwell int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
481b8b572e1SStephen Rothwell 	u64 tb_cache_size);
482b8b572e1SStephen Rothwell int ps3_lpm_close(void);
483b8b572e1SStephen Rothwell int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count,
484b8b572e1SStephen Rothwell 	unsigned long *bytes_copied);
485b8b572e1SStephen Rothwell int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
486b8b572e1SStephen Rothwell 	unsigned long count, unsigned long *bytes_copied);
487b8b572e1SStephen Rothwell void ps3_set_bookmark(u64 bookmark);
488b8b572e1SStephen Rothwell void ps3_set_pm_bookmark(u64 tag, u64 incident, u64 th_id);
489b8b572e1SStephen Rothwell int ps3_set_signal(u64 rtas_signal_group, u8 signal_bit, u16 sub_unit,
490b8b572e1SStephen Rothwell 	u8 bus_word);
491b8b572e1SStephen Rothwell 
492b8b572e1SStephen Rothwell u32 ps3_read_phys_ctr(u32 cpu, u32 phys_ctr);
493b8b572e1SStephen Rothwell void ps3_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val);
494b8b572e1SStephen Rothwell u32 ps3_read_ctr(u32 cpu, u32 ctr);
495b8b572e1SStephen Rothwell void ps3_write_ctr(u32 cpu, u32 ctr, u32 val);
496b8b572e1SStephen Rothwell 
497b8b572e1SStephen Rothwell u32 ps3_read_pm07_control(u32 cpu, u32 ctr);
498b8b572e1SStephen Rothwell void ps3_write_pm07_control(u32 cpu, u32 ctr, u32 val);
499b8b572e1SStephen Rothwell u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg);
500b8b572e1SStephen Rothwell void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val);
501b8b572e1SStephen Rothwell 
502b8b572e1SStephen Rothwell u32 ps3_get_ctr_size(u32 cpu, u32 phys_ctr);
503b8b572e1SStephen Rothwell void ps3_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size);
504b8b572e1SStephen Rothwell 
505b8b572e1SStephen Rothwell void ps3_enable_pm(u32 cpu);
506b8b572e1SStephen Rothwell void ps3_disable_pm(u32 cpu);
507b8b572e1SStephen Rothwell void ps3_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
508b8b572e1SStephen Rothwell void ps3_disable_pm_interrupts(u32 cpu);
509b8b572e1SStephen Rothwell 
510b8b572e1SStephen Rothwell u32 ps3_get_and_clear_pm_interrupts(u32 cpu);
511b8b572e1SStephen Rothwell void ps3_sync_irq(int node);
512b8b572e1SStephen Rothwell u32 ps3_get_hw_thread_id(int cpu);
513b8b572e1SStephen Rothwell u64 ps3_get_spe_id(void *arg);
514b8b572e1SStephen Rothwell 
515166dd7d3SBenjamin Herrenschmidt void ps3_early_mm_init(void);
516166dd7d3SBenjamin Herrenschmidt 
517b8b572e1SStephen Rothwell #endif
518