blob: 6b4f4dd2d15af5c5aabe9c32c85d74b2603dfe64 [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);
Jeremy Kerr85d02922007-09-12 18:43:15 +100050#ifdef CONFIG_SMP
Geoff Levandf58a9d12006-11-23 00:46:51 +010051void ps3_smp_cleanup_cpu(int cpu);
Jeremy Kerr85d02922007-09-12 18:43:15 +100052#else
53static inline void ps3_smp_cleanup_cpu(int cpu) { }
54#endif
Geoff Levandf58a9d12006-11-23 00:46:51 +010055
56/* time */
57
58void __init ps3_calibrate_decr(void);
59unsigned long __init ps3_get_boot_time(void);
60void ps3_get_rtc_time(struct rtc_time *time);
61int ps3_set_rtc_time(struct rtc_time *time);
62
63/* os area */
64
Geoff Levand01263e82007-10-07 07:35:44 +100065void __init ps3_os_area_save_params(void);
Geoff Levandd7b98e32007-10-07 07:35:46 +100066u64 ps3_os_area_get_rtc_diff(void);
67void ps3_os_area_set_rtc_diff(u64 rtc_diff);
Geoff Levandf58a9d12006-11-23 00:46:51 +010068
Geoff Levandde91a532006-11-23 00:46:59 +010069/* spu */
70
71#if defined(CONFIG_SPU_BASE)
72void ps3_spu_set_platform (void);
73#else
74static inline void ps3_spu_set_platform (void) {}
75#endif
76
Geoff Levand2a08ea62007-01-30 15:20:27 -080077/* repository bus info */
78
79enum ps3_bus_type {
80 PS3_BUS_TYPE_SB = 4,
81 PS3_BUS_TYPE_STORAGE = 5,
82};
83
84enum ps3_dev_type {
85 PS3_DEV_TYPE_STOR_DISK = TYPE_DISK, /* 0 */
86 PS3_DEV_TYPE_SB_GELIC = 3,
87 PS3_DEV_TYPE_SB_USB = 4,
88 PS3_DEV_TYPE_STOR_ROM = TYPE_ROM, /* 5 */
89 PS3_DEV_TYPE_SB_GPIO = 6,
90 PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC, /* 14 */
Geert Uytterhoevend51dd3d2007-09-06 18:14:57 +020091 PS3_DEV_TYPE_STOR_DUMMY = 32,
Geoff Levand6bb5cf12007-06-16 07:52:02 +100092 PS3_DEV_TYPE_NOACCESS = 255,
Geoff Levand2a08ea62007-01-30 15:20:27 -080093};
94
95int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
96 u64 *value);
97int ps3_repository_read_bus_id(unsigned int bus_index, unsigned int *bus_id);
98int ps3_repository_read_bus_type(unsigned int bus_index,
99 enum ps3_bus_type *bus_type);
100int ps3_repository_read_bus_num_dev(unsigned int bus_index,
101 unsigned int *num_dev);
102
103/* repository bus device info */
104
105enum ps3_interrupt_type {
106 PS3_INTERRUPT_TYPE_EVENT_PORT = 2,
107 PS3_INTERRUPT_TYPE_SB_OHCI = 3,
108 PS3_INTERRUPT_TYPE_SB_EHCI = 4,
109 PS3_INTERRUPT_TYPE_OTHER = 5,
110};
111
112enum ps3_reg_type {
113 PS3_REG_TYPE_SB_OHCI = 3,
114 PS3_REG_TYPE_SB_EHCI = 4,
115 PS3_REG_TYPE_SB_GPIO = 5,
116};
117
118int ps3_repository_read_dev_str(unsigned int bus_index,
119 unsigned int dev_index, const char *dev_str, u64 *value);
120int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
121 unsigned int *dev_id);
122int ps3_repository_read_dev_type(unsigned int bus_index,
123 unsigned int dev_index, enum ps3_dev_type *dev_type);
124int ps3_repository_read_dev_intr(unsigned int bus_index,
125 unsigned int dev_index, unsigned int intr_index,
126 enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id);
127int ps3_repository_read_dev_reg_type(unsigned int bus_index,
128 unsigned int dev_index, unsigned int reg_index,
129 enum ps3_reg_type *reg_type);
130int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
131 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr,
132 u64 *len);
133int ps3_repository_read_dev_reg(unsigned int bus_index,
134 unsigned int dev_index, unsigned int reg_index,
135 enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len);
136
137/* repository bus enumerators */
138
139struct ps3_repository_device {
Geoff Levanda3323d12007-06-16 07:55:58 +1000140 enum ps3_bus_type bus_type;
Geoff Levand2a08ea62007-01-30 15:20:27 -0800141 unsigned int bus_index;
Geoff Levanda3323d12007-06-16 07:55:58 +1000142 unsigned int bus_id;
143 enum ps3_dev_type dev_type;
Geoff Levand2a08ea62007-01-30 15:20:27 -0800144 unsigned int dev_index;
Geoff Levanda3323d12007-06-16 07:55:58 +1000145 unsigned int dev_id;
Geoff Levand2a08ea62007-01-30 15:20:27 -0800146};
147
Geoff Levanda3323d12007-06-16 07:55:58 +1000148static inline struct ps3_repository_device *ps3_repository_bump_device(
149 struct ps3_repository_device *repo)
Geoff Levand2a08ea62007-01-30 15:20:27 -0800150{
Geoff Levanda3323d12007-06-16 07:55:58 +1000151 repo->dev_index++;
152 return repo;
Geoff Levand2a08ea62007-01-30 15:20:27 -0800153}
Geoff Levanda3323d12007-06-16 07:55:58 +1000154int ps3_repository_find_device(struct ps3_repository_device *repo);
155int ps3_repository_find_devices(enum ps3_bus_type bus_type,
156 int (*callback)(const struct ps3_repository_device *repo));
157int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
158 unsigned int *bus_index);
159int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
Geoff Levand2a08ea62007-01-30 15:20:27 -0800160 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
Geoff Levanda3323d12007-06-16 07:55:58 +1000161int ps3_repository_find_reg(const struct ps3_repository_device *repo,
Geoff Levand2a08ea62007-01-30 15:20:27 -0800162 enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len);
163
164/* repository block device info */
165
166int ps3_repository_read_stor_dev_port(unsigned int bus_index,
167 unsigned int dev_index, u64 *port);
168int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
169 unsigned int dev_index, u64 *blk_size);
170int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
171 unsigned int dev_index, u64 *num_blocks);
172int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
173 unsigned int dev_index, unsigned int *num_regions);
174int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
175 unsigned int dev_index, unsigned int region_index,
176 unsigned int *region_id);
177int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
178 unsigned int dev_index, unsigned int region_index, u64 *region_size);
179int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
180 unsigned int dev_index, unsigned int region_index, u64 *region_start);
181int ps3_repository_read_stor_dev_info(unsigned int bus_index,
182 unsigned int dev_index, u64 *port, u64 *blk_size,
183 u64 *num_blocks, unsigned int *num_regions);
184int ps3_repository_read_stor_dev_region(unsigned int bus_index,
185 unsigned int dev_index, unsigned int region_index,
186 unsigned int *region_id, u64 *region_start, u64 *region_size);
187
188/* repository pu and memory info */
189
190int ps3_repository_read_num_pu(unsigned int *num_pu);
191int ps3_repository_read_ppe_id(unsigned int *pu_index, unsigned int *ppe_id);
192int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
193int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
194int ps3_repository_read_region_total(u64 *region_total);
195int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
196 u64 *region_total);
197
198/* repository pme info */
199
200int ps3_repository_read_num_be(unsigned int *num_be);
201int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
202int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
203int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
204
205/* repository 'Other OS' area */
206
207int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
208int ps3_repository_read_boot_dat_size(unsigned int *size);
209int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size);
210
211/* repository spu info */
212
213/**
214 * enum spu_resource_type - Type of spu resource.
215 * @spu_resource_type_shared: Logical spu is shared with other partions.
216 * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
217 *
218 * Returned by ps3_repository_read_spu_resource_id().
219 */
220
221enum ps3_spu_resource_type {
222 PS3_SPU_RESOURCE_TYPE_SHARED = 0,
223 PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
224};
225
226int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
227int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
228int ps3_repository_read_spu_resource_id(unsigned int res_index,
229 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
230
Geoff Levanda3323d12007-06-16 07:55:58 +1000231/* repository vuart info */
232
233int ps3_repository_read_vuart_av_port(unsigned int *port);
234int ps3_repository_read_vuart_sysmgr_port(unsigned int *port);
235
Geoff Levand6bb5cf12007-06-16 07:52:02 +1000236/* Page table entries */
237#define IOPTE_PP_W 0x8000000000000000ul /* protection: write */
238#define IOPTE_PP_R 0x4000000000000000ul /* protection: read */
239#define IOPTE_M 0x2000000000000000ul /* coherency required */
240#define IOPTE_SO_R 0x1000000000000000ul /* ordering: writes */
241#define IOPTE_SO_RW 0x1800000000000000ul /* ordering: r & w */
242#define IOPTE_RPN_Mask 0x07fffffffffff000ul /* RPN */
243#define IOPTE_H 0x0000000000000800ul /* cache hint */
244#define IOPTE_IOID_Mask 0x00000000000007fful /* ioid */
245
Geoff Levandf58a9d12006-11-23 00:46:51 +0100246#endif