blob: 75cb8d9e90cb12a4cd05434d65e7e13e564fcc2c [file] [log] [blame]
Geoff Levandf58a9d12006-11-23 00:46:51 +01001/*
2 * PS3 platform declarations.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
6 *
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.
10 *
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.
15 *
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
19 */
20
21#if !defined(_PS3_PLATFORM_H)
22#define _PS3_PLATFORM_H
23
24#include <linux/rtc.h>
Geoff Levand2a08ea62007-01-30 15:20:27 -080025#include <scsi/scsi.h>
26
27#include <asm/ps3.h>
Geoff Levandf58a9d12006-11-23 00:46:51 +010028
29/* htab */
30
31void __init ps3_hpte_init(unsigned long htab_size);
32void __init ps3_map_htab(void);
33
34/* mm */
35
36void __init ps3_mm_init(void);
37void __init ps3_mm_vas_create(unsigned long* htab_size);
38void ps3_mm_vas_destroy(void);
39void ps3_mm_shutdown(void);
40
41/* irq */
42
43void ps3_init_IRQ(void);
Geoff Levand9263e852007-06-16 07:19:32 +100044void ps3_shutdown_IRQ(int cpu);
Geoff Levandf58a9d12006-11-23 00:46:51 +010045void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq);
46
47/* smp */
48
49void smp_init_ps3(void);
50void ps3_smp_cleanup_cpu(int cpu);
51
52/* time */
53
54void __init ps3_calibrate_decr(void);
55unsigned long __init ps3_get_boot_time(void);
56void ps3_get_rtc_time(struct rtc_time *time);
57int ps3_set_rtc_time(struct rtc_time *time);
58
59/* os area */
60
61int __init ps3_os_area_init(void);
62u64 ps3_os_area_rtc_diff(void);
63
Geoff Levandde91a532006-11-23 00:46:59 +010064/* spu */
65
66#if defined(CONFIG_SPU_BASE)
67void ps3_spu_set_platform (void);
68#else
69static inline void ps3_spu_set_platform (void) {}
70#endif
71
Geoff Levand2a08ea62007-01-30 15:20:27 -080072/* repository bus info */
73
74enum ps3_bus_type {
75 PS3_BUS_TYPE_SB = 4,
76 PS3_BUS_TYPE_STORAGE = 5,
77};
78
79enum ps3_dev_type {
80 PS3_DEV_TYPE_STOR_DISK = TYPE_DISK, /* 0 */
81 PS3_DEV_TYPE_SB_GELIC = 3,
82 PS3_DEV_TYPE_SB_USB = 4,
83 PS3_DEV_TYPE_STOR_ROM = TYPE_ROM, /* 5 */
84 PS3_DEV_TYPE_SB_GPIO = 6,
85 PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC, /* 14 */
Geoff Levand6bb5cf12007-06-16 07:52:02 +100086 PS3_DEV_TYPE_NOACCESS = 255,
Geoff Levand2a08ea62007-01-30 15:20:27 -080087};
88
89int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
90 u64 *value);
91int ps3_repository_read_bus_id(unsigned int bus_index, unsigned int *bus_id);
92int ps3_repository_read_bus_type(unsigned int bus_index,
93 enum ps3_bus_type *bus_type);
94int ps3_repository_read_bus_num_dev(unsigned int bus_index,
95 unsigned int *num_dev);
96
97/* repository bus device info */
98
99enum ps3_interrupt_type {
100 PS3_INTERRUPT_TYPE_EVENT_PORT = 2,
101 PS3_INTERRUPT_TYPE_SB_OHCI = 3,
102 PS3_INTERRUPT_TYPE_SB_EHCI = 4,
103 PS3_INTERRUPT_TYPE_OTHER = 5,
104};
105
106enum ps3_reg_type {
107 PS3_REG_TYPE_SB_OHCI = 3,
108 PS3_REG_TYPE_SB_EHCI = 4,
109 PS3_REG_TYPE_SB_GPIO = 5,
110};
111
112int ps3_repository_read_dev_str(unsigned int bus_index,
113 unsigned int dev_index, const char *dev_str, u64 *value);
114int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
115 unsigned int *dev_id);
116int ps3_repository_read_dev_type(unsigned int bus_index,
117 unsigned int dev_index, enum ps3_dev_type *dev_type);
118int ps3_repository_read_dev_intr(unsigned int bus_index,
119 unsigned int dev_index, unsigned int intr_index,
120 enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id);
121int ps3_repository_read_dev_reg_type(unsigned int bus_index,
122 unsigned int dev_index, unsigned int reg_index,
123 enum ps3_reg_type *reg_type);
124int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
125 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr,
126 u64 *len);
127int ps3_repository_read_dev_reg(unsigned int bus_index,
128 unsigned int dev_index, unsigned int reg_index,
129 enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len);
130
131/* repository bus enumerators */
132
133struct ps3_repository_device {
134 unsigned int bus_index;
135 unsigned int dev_index;
136 struct ps3_device_id did;
137};
138
139int ps3_repository_find_device(enum ps3_bus_type bus_type,
140 enum ps3_dev_type dev_type,
141 const struct ps3_repository_device *start_dev,
142 struct ps3_repository_device *dev);
143static inline int ps3_repository_find_first_device(
144 enum ps3_bus_type bus_type, enum ps3_dev_type dev_type,
145 struct ps3_repository_device *dev)
146{
147 return ps3_repository_find_device(bus_type, dev_type, NULL, dev);
148}
149int ps3_repository_find_interrupt(const struct ps3_repository_device *dev,
150 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
151int ps3_repository_find_reg(const struct ps3_repository_device *dev,
152 enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len);
153
154/* repository block device info */
155
156int ps3_repository_read_stor_dev_port(unsigned int bus_index,
157 unsigned int dev_index, u64 *port);
158int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
159 unsigned int dev_index, u64 *blk_size);
160int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
161 unsigned int dev_index, u64 *num_blocks);
162int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
163 unsigned int dev_index, unsigned int *num_regions);
164int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
165 unsigned int dev_index, unsigned int region_index,
166 unsigned int *region_id);
167int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
168 unsigned int dev_index, unsigned int region_index, u64 *region_size);
169int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
170 unsigned int dev_index, unsigned int region_index, u64 *region_start);
171int ps3_repository_read_stor_dev_info(unsigned int bus_index,
172 unsigned int dev_index, u64 *port, u64 *blk_size,
173 u64 *num_blocks, unsigned int *num_regions);
174int ps3_repository_read_stor_dev_region(unsigned int bus_index,
175 unsigned int dev_index, unsigned int region_index,
176 unsigned int *region_id, u64 *region_start, u64 *region_size);
177
178/* repository pu and memory info */
179
180int ps3_repository_read_num_pu(unsigned int *num_pu);
181int ps3_repository_read_ppe_id(unsigned int *pu_index, unsigned int *ppe_id);
182int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
183int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
184int ps3_repository_read_region_total(u64 *region_total);
185int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
186 u64 *region_total);
187
188/* repository pme info */
189
190int ps3_repository_read_num_be(unsigned int *num_be);
191int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
192int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
193int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
194
195/* repository 'Other OS' area */
196
197int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
198int ps3_repository_read_boot_dat_size(unsigned int *size);
199int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size);
200
201/* repository spu info */
202
203/**
204 * enum spu_resource_type - Type of spu resource.
205 * @spu_resource_type_shared: Logical spu is shared with other partions.
206 * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
207 *
208 * Returned by ps3_repository_read_spu_resource_id().
209 */
210
211enum ps3_spu_resource_type {
212 PS3_SPU_RESOURCE_TYPE_SHARED = 0,
213 PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
214};
215
216int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
217int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
218int ps3_repository_read_spu_resource_id(unsigned int res_index,
219 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
220
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000221/* Page table entries */
222#define IOPTE_PP_W 0x8000000000000000ul /* protection: write */
223#define IOPTE_PP_R 0x4000000000000000ul /* protection: read */
224#define IOPTE_M 0x2000000000000000ul /* coherency required */
225#define IOPTE_SO_R 0x1000000000000000ul /* ordering: writes */
226#define IOPTE_SO_RW 0x1800000000000000ul /* ordering: r & w */
227#define IOPTE_RPN_Mask 0x07fffffffffff000ul /* RPN */
228#define IOPTE_H 0x0000000000000800ul /* cache hint */
229#define IOPTE_IOID_Mask 0x00000000000007fful /* ioid */
230
Geoff Levandf58a9d12006-11-23 00:46:51 +0100231#endif