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
19void __init ps3_hpte_init(unsigned long htab_size);
20void __init ps3_map_htab(void);
21
22/* mm */
23
24void __init ps3_mm_init(void);
25void __init ps3_mm_vas_create(unsigned long* htab_size);
26void ps3_mm_vas_destroy(void);
27void ps3_mm_shutdown(void);
28
29/* irq */
30
31void ps3_init_IRQ(void);
32void ps3_shutdown_IRQ(int cpu);
33void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq);
34void __init ps3_register_ipi_irq(unsigned int cpu, unsigned int virq);
35
36/* smp */
37
38void __init smp_init_ps3(void);
39#ifdef CONFIG_SMP
40void ps3_smp_cleanup_cpu(int cpu);
41#else
42static inline void ps3_smp_cleanup_cpu(int cpu) { }
43#endif
44
45/* time */
46
47void __init ps3_calibrate_decr(void);
48time64_t __init ps3_get_boot_time(void);
49void ps3_get_rtc_time(struct rtc_time *time);
50int ps3_set_rtc_time(struct rtc_time *time);
51
52/* os area */
53
54void __init ps3_os_area_save_params(void);
55void __init ps3_os_area_init(void);
56
57/* spu */
58
59#if defined(CONFIG_SPU_BASE)
60void ps3_spu_set_platform (void);
61#else
62static inline void ps3_spu_set_platform (void) {}
63#endif
64
65/* repository bus info */
66
67enum ps3_bus_type {
68	PS3_BUS_TYPE_SB = 4,
69	PS3_BUS_TYPE_STORAGE = 5,
70};
71
72enum 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
81int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
82	u64 *value);
83int ps3_repository_read_bus_id(unsigned int bus_index, u64 *bus_id);
84int ps3_repository_read_bus_type(unsigned int bus_index,
85	enum ps3_bus_type *bus_type);
86int ps3_repository_read_bus_num_dev(unsigned int bus_index,
87	unsigned int *num_dev);
88
89/* repository bus device info */
90
91enum 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
98enum 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
104int ps3_repository_read_dev_str(unsigned int bus_index,
105	unsigned int dev_index, const char *dev_str, u64 *value);
106int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
107	u64 *dev_id);
108int ps3_repository_read_dev_type(unsigned int bus_index,
109	unsigned int dev_index, enum ps3_dev_type *dev_type);
110int 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);
113int 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);
116int 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);
119int 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
125struct 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
134int ps3_repository_find_device(struct ps3_repository_device *repo);
135int ps3_repository_find_device_by_id(struct ps3_repository_device *repo,
136				     u64 bus_id, u64 dev_id);
137int __init ps3_repository_find_devices(enum ps3_bus_type bus_type,
138	int (*callback)(const struct ps3_repository_device *repo));
139int __init ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
140	unsigned int *bus_index);
141int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
142	enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
143int 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
148int ps3_repository_read_stor_dev_port(unsigned int bus_index,
149	unsigned int dev_index, u64 *port);
150int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
151	unsigned int dev_index, u64 *blk_size);
152int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
153	unsigned int dev_index, u64 *num_blocks);
154int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
155	unsigned int dev_index, unsigned int *num_regions);
156int 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);
159int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
160	unsigned int dev_index,	unsigned int region_index, u64 *region_size);
161int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
162	unsigned int dev_index, unsigned int region_index, u64 *region_start);
163int 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);
166int 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
172int ps3_repository_read_num_pu(u64 *num_pu);
173int ps3_repository_read_pu_id(unsigned int pu_index, u64 *pu_id);
174int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
175int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
176int ps3_repository_read_region_total(u64 *region_total);
177int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
178	u64 *region_total);
179int ps3_repository_read_highmem_region_count(unsigned int *region_count);
180int ps3_repository_read_highmem_base(unsigned int region_index,
181	u64 *highmem_base);
182int ps3_repository_read_highmem_size(unsigned int region_index,
183	u64 *highmem_size);
184int ps3_repository_read_highmem_info(unsigned int region_index,
185	u64 *highmem_base, u64 *highmem_size);
186
187#if defined (CONFIG_PS3_REPOSITORY_WRITE)
188int ps3_repository_write_highmem_region_count(unsigned int region_count);
189int ps3_repository_write_highmem_base(unsigned int region_index,
190	u64 highmem_base);
191int ps3_repository_write_highmem_size(unsigned int region_index,
192	u64 highmem_size);
193int ps3_repository_write_highmem_info(unsigned int region_index,
194	u64 highmem_base, u64 highmem_size);
195int ps3_repository_delete_highmem_info(unsigned int region_index);
196#else
197static inline int ps3_repository_write_highmem_region_count(
198	unsigned int region_count) {return 0;}
199static inline int ps3_repository_write_highmem_base(unsigned int region_index,
200	u64 highmem_base) {return 0;}
201static inline int ps3_repository_write_highmem_size(unsigned int region_index,
202	u64 highmem_size) {return 0;}
203static inline int ps3_repository_write_highmem_info(unsigned int region_index,
204	u64 highmem_base, u64 highmem_size) {return 0;}
205static inline int ps3_repository_delete_highmem_info(unsigned int region_index)
206	{return 0;}
207#endif
208
209/* repository pme info */
210
211int ps3_repository_read_num_be(unsigned int *num_be);
212int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
213int ps3_repository_read_be_id(u64 node_id, u64 *be_id);
214int __init ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
215int __init ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
216
217/* repository performance monitor info */
218
219int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar,
220	u64 *rights);
221
222/* repository 'Other OS' area */
223
224int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
225int ps3_repository_read_boot_dat_size(unsigned int *size);
226int 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
238enum ps3_spu_resource_type {
239	PS3_SPU_RESOURCE_TYPE_SHARED = 0,
240	PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
241};
242
243int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
244int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
245int 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
250int __init ps3_repository_read_vuart_av_port(unsigned int *port);
251int __init ps3_repository_read_vuart_sysmgr_port(unsigned int *port);
252
253#endif
254