1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * PS3 platform declarations.
4 *
5 * Copyright (C) 2006 Sony Computer Entertainment Inc.
6 * Copyright 2006 Sony Corp.
7 */
8
9 #if !defined(_PS3_PLATFORM_H)
10 #define _PS3_PLATFORM_H
11
12 #include <linux/rtc.h>
13 #include <scsi/scsi.h>
14
15 #include <asm/ps3.h>
16
17 /* htab */
18
19 void __init ps3_hpte_init(unsigned long htab_size);
20 void __init ps3_map_htab(void);
21
22 /* mm */
23
24 void __init ps3_mm_init(void);
25 void __init ps3_mm_vas_create(unsigned long* htab_size);
26 void ps3_mm_vas_destroy(void);
27 void ps3_mm_shutdown(void);
28
29 /* irq */
30
31 void ps3_init_IRQ(void);
32 void ps3_shutdown_IRQ(int cpu);
33 void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq);
34 void __init ps3_register_ipi_irq(unsigned int cpu, unsigned int virq);
35
36 /* smp */
37
38 void smp_init_ps3(void);
39 #ifdef CONFIG_SMP
40 void ps3_smp_cleanup_cpu(int cpu);
41 #else
ps3_smp_cleanup_cpu(int cpu)42 static inline void ps3_smp_cleanup_cpu(int cpu) { }
43 #endif
44
45 /* time */
46
47 void __init ps3_calibrate_decr(void);
48 time64_t __init ps3_get_boot_time(void);
49 void ps3_get_rtc_time(struct rtc_time *time);
50 int ps3_set_rtc_time(struct rtc_time *time);
51
52 /* os area */
53
54 void __init ps3_os_area_save_params(void);
55 void __init ps3_os_area_init(void);
56
57 /* spu */
58
59 #if defined(CONFIG_SPU_BASE)
60 void ps3_spu_set_platform (void);
61 #else
ps3_spu_set_platform(void)62 static inline void ps3_spu_set_platform (void) {}
63 #endif
64
65 /* repository bus info */
66
67 enum ps3_bus_type {
68 PS3_BUS_TYPE_SB = 4,
69 PS3_BUS_TYPE_STORAGE = 5,
70 };
71
72 enum ps3_dev_type {
73 PS3_DEV_TYPE_STOR_DISK = TYPE_DISK, /* 0 */
74 PS3_DEV_TYPE_SB_GELIC = 3,
75 PS3_DEV_TYPE_SB_USB = 4,
76 PS3_DEV_TYPE_STOR_ROM = TYPE_ROM, /* 5 */
77 PS3_DEV_TYPE_SB_GPIO = 6,
78 PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC, /* 14 */
79 };
80
81 int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
82 u64 *value);
83 int ps3_repository_read_bus_id(unsigned int bus_index, u64 *bus_id);
84 int ps3_repository_read_bus_type(unsigned int bus_index,
85 enum ps3_bus_type *bus_type);
86 int ps3_repository_read_bus_num_dev(unsigned int bus_index,
87 unsigned int *num_dev);
88
89 /* repository bus device info */
90
91 enum ps3_interrupt_type {
92 PS3_INTERRUPT_TYPE_EVENT_PORT = 2,
93 PS3_INTERRUPT_TYPE_SB_OHCI = 3,
94 PS3_INTERRUPT_TYPE_SB_EHCI = 4,
95 PS3_INTERRUPT_TYPE_OTHER = 5,
96 };
97
98 enum ps3_reg_type {
99 PS3_REG_TYPE_SB_OHCI = 3,
100 PS3_REG_TYPE_SB_EHCI = 4,
101 PS3_REG_TYPE_SB_GPIO = 5,
102 };
103
104 int ps3_repository_read_dev_str(unsigned int bus_index,
105 unsigned int dev_index, const char *dev_str, u64 *value);
106 int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
107 u64 *dev_id);
108 int ps3_repository_read_dev_type(unsigned int bus_index,
109 unsigned int dev_index, enum ps3_dev_type *dev_type);
110 int ps3_repository_read_dev_intr(unsigned int bus_index,
111 unsigned int dev_index, unsigned int intr_index,
112 enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id);
113 int ps3_repository_read_dev_reg_type(unsigned int bus_index,
114 unsigned int dev_index, unsigned int reg_index,
115 enum ps3_reg_type *reg_type);
116 int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
117 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr,
118 u64 *len);
119 int ps3_repository_read_dev_reg(unsigned int bus_index,
120 unsigned int dev_index, unsigned int reg_index,
121 enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len);
122
123 /* repository bus enumerators */
124
125 struct ps3_repository_device {
126 unsigned int bus_index;
127 unsigned int dev_index;
128 enum ps3_bus_type bus_type;
129 enum ps3_dev_type dev_type;
130 u64 bus_id;
131 u64 dev_id;
132 };
133
134 int ps3_repository_find_device(struct ps3_repository_device *repo);
135 int ps3_repository_find_device_by_id(struct ps3_repository_device *repo,
136 u64 bus_id, u64 dev_id);
137 int ps3_repository_find_devices(enum ps3_bus_type bus_type,
138 int (*callback)(const struct ps3_repository_device *repo));
139 int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
140 unsigned int *bus_index);
141 int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
142 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
143 int ps3_repository_find_reg(const struct ps3_repository_device *repo,
144 enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len);
145
146 /* repository block device info */
147
148 int ps3_repository_read_stor_dev_port(unsigned int bus_index,
149 unsigned int dev_index, u64 *port);
150 int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
151 unsigned int dev_index, u64 *blk_size);
152 int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
153 unsigned int dev_index, u64 *num_blocks);
154 int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
155 unsigned int dev_index, unsigned int *num_regions);
156 int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
157 unsigned int dev_index, unsigned int region_index,
158 unsigned int *region_id);
159 int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
160 unsigned int dev_index, unsigned int region_index, u64 *region_size);
161 int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
162 unsigned int dev_index, unsigned int region_index, u64 *region_start);
163 int ps3_repository_read_stor_dev_info(unsigned int bus_index,
164 unsigned int dev_index, u64 *port, u64 *blk_size,
165 u64 *num_blocks, unsigned int *num_regions);
166 int ps3_repository_read_stor_dev_region(unsigned int bus_index,
167 unsigned int dev_index, unsigned int region_index,
168 unsigned int *region_id, u64 *region_start, u64 *region_size);
169
170 /* repository logical pu and memory info */
171
172 int ps3_repository_read_num_pu(u64 *num_pu);
173 int ps3_repository_read_pu_id(unsigned int pu_index, u64 *pu_id);
174 int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
175 int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
176 int ps3_repository_read_region_total(u64 *region_total);
177 int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
178 u64 *region_total);
179 int ps3_repository_read_highmem_region_count(unsigned int *region_count);
180 int ps3_repository_read_highmem_base(unsigned int region_index,
181 u64 *highmem_base);
182 int ps3_repository_read_highmem_size(unsigned int region_index,
183 u64 *highmem_size);
184 int ps3_repository_read_highmem_info(unsigned int region_index,
185 u64 *highmem_base, u64 *highmem_size);
186
187 #if defined (CONFIG_PS3_REPOSITORY_WRITE)
188 int ps3_repository_write_highmem_region_count(unsigned int region_count);
189 int ps3_repository_write_highmem_base(unsigned int region_index,
190 u64 highmem_base);
191 int ps3_repository_write_highmem_size(unsigned int region_index,
192 u64 highmem_size);
193 int ps3_repository_write_highmem_info(unsigned int region_index,
194 u64 highmem_base, u64 highmem_size);
195 int ps3_repository_delete_highmem_info(unsigned int region_index);
196 #else
ps3_repository_write_highmem_region_count(unsigned int region_count)197 static inline int ps3_repository_write_highmem_region_count(
198 unsigned int region_count) {return 0;}
ps3_repository_write_highmem_base(unsigned int region_index,u64 highmem_base)199 static inline int ps3_repository_write_highmem_base(unsigned int region_index,
200 u64 highmem_base) {return 0;}
ps3_repository_write_highmem_size(unsigned int region_index,u64 highmem_size)201 static inline int ps3_repository_write_highmem_size(unsigned int region_index,
202 u64 highmem_size) {return 0;}
ps3_repository_write_highmem_info(unsigned int region_index,u64 highmem_base,u64 highmem_size)203 static inline int ps3_repository_write_highmem_info(unsigned int region_index,
204 u64 highmem_base, u64 highmem_size) {return 0;}
ps3_repository_delete_highmem_info(unsigned int region_index)205 static inline int ps3_repository_delete_highmem_info(unsigned int region_index)
206 {return 0;}
207 #endif
208
209 /* repository pme info */
210
211 int ps3_repository_read_num_be(unsigned int *num_be);
212 int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
213 int ps3_repository_read_be_id(u64 node_id, u64 *be_id);
214 int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
215 int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
216
217 /* repository performance monitor info */
218
219 int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar,
220 u64 *rights);
221
222 /* repository 'Other OS' area */
223
224 int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
225 int ps3_repository_read_boot_dat_size(unsigned int *size);
226 int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size);
227
228 /* repository spu info */
229
230 /**
231 * enum spu_resource_type - Type of spu resource.
232 * @spu_resource_type_shared: Logical spu is shared with other partions.
233 * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
234 *
235 * Returned by ps3_repository_read_spu_resource_id().
236 */
237
238 enum ps3_spu_resource_type {
239 PS3_SPU_RESOURCE_TYPE_SHARED = 0,
240 PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
241 };
242
243 int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
244 int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
245 int ps3_repository_read_spu_resource_id(unsigned int res_index,
246 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
247
248 /* repository vuart info */
249
250 int ps3_repository_read_vuart_av_port(unsigned int *port);
251 int ps3_repository_read_vuart_sysmgr_port(unsigned int *port);
252
253 #endif
254