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(_PS3_PLATFORM_H)
22 #define _PS3_PLATFORM_H
24 #include <linux/rtc.h>
25 #include <scsi/scsi.h>
31 void __init
ps3_hpte_init(unsigned long htab_size
);
32 void __init
ps3_map_htab(void);
36 void __init
ps3_mm_init(void);
37 void __init
ps3_mm_vas_create(unsigned long* htab_size
);
38 void ps3_mm_vas_destroy(void);
39 void ps3_mm_shutdown(void);
43 void ps3_init_IRQ(void);
44 void ps3_shutdown_IRQ(int cpu
);
45 void __init
ps3_register_ipi_debug_brk(unsigned int cpu
, unsigned int virq
);
49 void smp_init_ps3(void);
51 void ps3_smp_cleanup_cpu(int cpu
);
53 static inline void ps3_smp_cleanup_cpu(int cpu
) { }
58 void __init
ps3_calibrate_decr(void);
59 unsigned long __init
ps3_get_boot_time(void);
60 void ps3_get_rtc_time(struct rtc_time
*time
);
61 int ps3_set_rtc_time(struct rtc_time
*time
);
65 void __init
ps3_os_area_save_params(void);
66 void __init
ps3_os_area_init(void);
67 u64
ps3_os_area_get_rtc_diff(void);
68 void ps3_os_area_set_rtc_diff(u64 rtc_diff
);
72 #if defined(CONFIG_SPU_BASE)
73 void ps3_spu_set_platform (void);
75 static inline void ps3_spu_set_platform (void) {}
78 /* repository bus info */
82 PS3_BUS_TYPE_STORAGE
= 5,
86 PS3_DEV_TYPE_STOR_DISK
= TYPE_DISK
, /* 0 */
87 PS3_DEV_TYPE_SB_GELIC
= 3,
88 PS3_DEV_TYPE_SB_USB
= 4,
89 PS3_DEV_TYPE_STOR_ROM
= TYPE_ROM
, /* 5 */
90 PS3_DEV_TYPE_SB_GPIO
= 6,
91 PS3_DEV_TYPE_STOR_FLASH
= TYPE_RBC
, /* 14 */
92 PS3_DEV_TYPE_STOR_DUMMY
= 32,
93 PS3_DEV_TYPE_NOACCESS
= 255,
96 int ps3_repository_read_bus_str(unsigned int bus_index
, const char *bus_str
,
98 int ps3_repository_read_bus_id(unsigned int bus_index
, u64
*bus_id
);
99 int ps3_repository_read_bus_type(unsigned int bus_index
,
100 enum ps3_bus_type
*bus_type
);
101 int ps3_repository_read_bus_num_dev(unsigned int bus_index
,
102 unsigned int *num_dev
);
104 /* repository bus device info */
106 enum ps3_interrupt_type
{
107 PS3_INTERRUPT_TYPE_EVENT_PORT
= 2,
108 PS3_INTERRUPT_TYPE_SB_OHCI
= 3,
109 PS3_INTERRUPT_TYPE_SB_EHCI
= 4,
110 PS3_INTERRUPT_TYPE_OTHER
= 5,
114 PS3_REG_TYPE_SB_OHCI
= 3,
115 PS3_REG_TYPE_SB_EHCI
= 4,
116 PS3_REG_TYPE_SB_GPIO
= 5,
119 int ps3_repository_read_dev_str(unsigned int bus_index
,
120 unsigned int dev_index
, const char *dev_str
, u64
*value
);
121 int ps3_repository_read_dev_id(unsigned int bus_index
, unsigned int dev_index
,
123 int ps3_repository_read_dev_type(unsigned int bus_index
,
124 unsigned int dev_index
, enum ps3_dev_type
*dev_type
);
125 int ps3_repository_read_dev_intr(unsigned int bus_index
,
126 unsigned int dev_index
, unsigned int intr_index
,
127 enum ps3_interrupt_type
*intr_type
, unsigned int *interrupt_id
);
128 int ps3_repository_read_dev_reg_type(unsigned int bus_index
,
129 unsigned int dev_index
, unsigned int reg_index
,
130 enum ps3_reg_type
*reg_type
);
131 int ps3_repository_read_dev_reg_addr(unsigned int bus_index
,
132 unsigned int dev_index
, unsigned int reg_index
, u64
*bus_addr
,
134 int ps3_repository_read_dev_reg(unsigned int bus_index
,
135 unsigned int dev_index
, unsigned int reg_index
,
136 enum ps3_reg_type
*reg_type
, u64
*bus_addr
, u64
*len
);
138 /* repository bus enumerators */
140 struct ps3_repository_device
{
141 unsigned int bus_index
;
142 unsigned int dev_index
;
143 enum ps3_bus_type bus_type
;
144 enum ps3_dev_type dev_type
;
149 static inline struct ps3_repository_device
*ps3_repository_bump_device(
150 struct ps3_repository_device
*repo
)
155 int ps3_repository_find_device(struct ps3_repository_device
*repo
);
156 int ps3_repository_find_device_by_id(struct ps3_repository_device
*repo
,
157 u64 bus_id
, u64 dev_id
);
158 int ps3_repository_find_devices(enum ps3_bus_type bus_type
,
159 int (*callback
)(const struct ps3_repository_device
*repo
));
160 int ps3_repository_find_bus(enum ps3_bus_type bus_type
, unsigned int from
,
161 unsigned int *bus_index
);
162 int ps3_repository_find_interrupt(const struct ps3_repository_device
*repo
,
163 enum ps3_interrupt_type intr_type
, unsigned int *interrupt_id
);
164 int ps3_repository_find_reg(const struct ps3_repository_device
*repo
,
165 enum ps3_reg_type reg_type
, u64
*bus_addr
, u64
*len
);
167 /* repository block device info */
169 int ps3_repository_read_stor_dev_port(unsigned int bus_index
,
170 unsigned int dev_index
, u64
*port
);
171 int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index
,
172 unsigned int dev_index
, u64
*blk_size
);
173 int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index
,
174 unsigned int dev_index
, u64
*num_blocks
);
175 int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index
,
176 unsigned int dev_index
, unsigned int *num_regions
);
177 int ps3_repository_read_stor_dev_region_id(unsigned int bus_index
,
178 unsigned int dev_index
, unsigned int region_index
,
179 unsigned int *region_id
);
180 int ps3_repository_read_stor_dev_region_size(unsigned int bus_index
,
181 unsigned int dev_index
, unsigned int region_index
, u64
*region_size
);
182 int ps3_repository_read_stor_dev_region_start(unsigned int bus_index
,
183 unsigned int dev_index
, unsigned int region_index
, u64
*region_start
);
184 int ps3_repository_read_stor_dev_info(unsigned int bus_index
,
185 unsigned int dev_index
, u64
*port
, u64
*blk_size
,
186 u64
*num_blocks
, unsigned int *num_regions
);
187 int ps3_repository_read_stor_dev_region(unsigned int bus_index
,
188 unsigned int dev_index
, unsigned int region_index
,
189 unsigned int *region_id
, u64
*region_start
, u64
*region_size
);
191 /* repository pu and memory info */
193 int ps3_repository_read_num_pu(unsigned int *num_pu
);
194 int ps3_repository_read_ppe_id(unsigned int *pu_index
, unsigned int *ppe_id
);
195 int ps3_repository_read_rm_base(unsigned int ppe_id
, u64
*rm_base
);
196 int ps3_repository_read_rm_size(unsigned int ppe_id
, u64
*rm_size
);
197 int ps3_repository_read_region_total(u64
*region_total
);
198 int ps3_repository_read_mm_info(u64
*rm_base
, u64
*rm_size
,
201 /* repository pme info */
203 int ps3_repository_read_num_be(unsigned int *num_be
);
204 int ps3_repository_read_be_node_id(unsigned int be_index
, u64
*node_id
);
205 int ps3_repository_read_tb_freq(u64 node_id
, u64
*tb_freq
);
206 int ps3_repository_read_be_tb_freq(unsigned int be_index
, u64
*tb_freq
);
208 /* repository 'Other OS' area */
210 int ps3_repository_read_boot_dat_addr(u64
*lpar_addr
);
211 int ps3_repository_read_boot_dat_size(unsigned int *size
);
212 int ps3_repository_read_boot_dat_info(u64
*lpar_addr
, unsigned int *size
);
214 /* repository spu info */
217 * enum spu_resource_type - Type of spu resource.
218 * @spu_resource_type_shared: Logical spu is shared with other partions.
219 * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
221 * Returned by ps3_repository_read_spu_resource_id().
224 enum ps3_spu_resource_type
{
225 PS3_SPU_RESOURCE_TYPE_SHARED
= 0,
226 PS3_SPU_RESOURCE_TYPE_EXCLUSIVE
= 0x8000000000000000UL
,
229 int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved
);
230 int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id
);
231 int ps3_repository_read_spu_resource_id(unsigned int res_index
,
232 enum ps3_spu_resource_type
* resource_type
, unsigned int *resource_id
);
234 /* repository vuart info */
236 int ps3_repository_read_vuart_av_port(unsigned int *port
);
237 int ps3_repository_read_vuart_sysmgr_port(unsigned int *port
);
239 /* Page table entries */
240 #define IOPTE_PP_W 0x8000000000000000ul /* protection: write */
241 #define IOPTE_PP_R 0x4000000000000000ul /* protection: read */
242 #define IOPTE_M 0x2000000000000000ul /* coherency required */
243 #define IOPTE_SO_R 0x1000000000000000ul /* ordering: writes */
244 #define IOPTE_SO_RW 0x1800000000000000ul /* ordering: r & w */
245 #define IOPTE_RPN_Mask 0x07fffffffffff000ul /* RPN */
246 #define IOPTE_H 0x0000000000000800ul /* cache hint */
247 #define IOPTE_IOID_Mask 0x00000000000007fful /* ioid */