xref: /openbmc/linux/arch/powerpc/platforms/ps3/platform.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1873e65bcSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2f58a9d17SGeoff Levand /*
3f58a9d17SGeoff Levand  *  PS3 platform declarations.
4f58a9d17SGeoff Levand  *
5f58a9d17SGeoff Levand  *  Copyright (C) 2006 Sony Computer Entertainment Inc.
6f58a9d17SGeoff Levand  *  Copyright 2006 Sony Corp.
7f58a9d17SGeoff Levand  */
8f58a9d17SGeoff Levand 
9f58a9d17SGeoff Levand #if !defined(_PS3_PLATFORM_H)
10f58a9d17SGeoff Levand #define _PS3_PLATFORM_H
11f58a9d17SGeoff Levand 
12f58a9d17SGeoff Levand #include <linux/rtc.h>
132a08ea69SGeoff Levand #include <scsi/scsi.h>
142a08ea69SGeoff Levand 
152a08ea69SGeoff Levand #include <asm/ps3.h>
16f58a9d17SGeoff Levand 
17f58a9d17SGeoff Levand /* htab */
18f58a9d17SGeoff Levand 
19f58a9d17SGeoff Levand void __init ps3_hpte_init(unsigned long htab_size);
20f58a9d17SGeoff Levand void __init ps3_map_htab(void);
21f58a9d17SGeoff Levand 
22f58a9d17SGeoff Levand /* mm */
23f58a9d17SGeoff Levand 
24f58a9d17SGeoff Levand void __init ps3_mm_init(void);
25f58a9d17SGeoff Levand void __init ps3_mm_vas_create(unsigned long* htab_size);
26f58a9d17SGeoff Levand void ps3_mm_vas_destroy(void);
27f58a9d17SGeoff Levand void ps3_mm_shutdown(void);
28f58a9d17SGeoff Levand 
29f58a9d17SGeoff Levand /* irq */
30f58a9d17SGeoff Levand 
31f58a9d17SGeoff Levand void ps3_init_IRQ(void);
329263e85aSGeoff Levand void ps3_shutdown_IRQ(int cpu);
33f58a9d17SGeoff Levand void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq);
3472f3bea0SGeoff Levand void __init ps3_register_ipi_irq(unsigned int cpu, unsigned int virq);
35f58a9d17SGeoff Levand 
36f58a9d17SGeoff Levand /* smp */
37f58a9d17SGeoff Levand 
38*f1ba9b94SNick Child void __init smp_init_ps3(void);
3985d02924SJeremy Kerr #ifdef CONFIG_SMP
40f58a9d17SGeoff Levand void ps3_smp_cleanup_cpu(int cpu);
4185d02924SJeremy Kerr #else
ps3_smp_cleanup_cpu(int cpu)4285d02924SJeremy Kerr static inline void ps3_smp_cleanup_cpu(int cpu) { }
4385d02924SJeremy Kerr #endif
44f58a9d17SGeoff Levand 
45f58a9d17SGeoff Levand /* time */
46f58a9d17SGeoff Levand 
47f58a9d17SGeoff Levand void __init ps3_calibrate_decr(void);
485bfd6435SArnd Bergmann time64_t __init ps3_get_boot_time(void);
49f58a9d17SGeoff Levand void ps3_get_rtc_time(struct rtc_time *time);
50f58a9d17SGeoff Levand int ps3_set_rtc_time(struct rtc_time *time);
51f58a9d17SGeoff Levand 
52f58a9d17SGeoff Levand /* os area */
53f58a9d17SGeoff Levand 
5401263e88SGeoff Levand void __init ps3_os_area_save_params(void);
557db19421SGeoff Levand void __init ps3_os_area_init(void);
56f58a9d17SGeoff Levand 
57de91a534SGeoff Levand /* spu */
58de91a534SGeoff Levand 
59de91a534SGeoff Levand #if defined(CONFIG_SPU_BASE)
60de91a534SGeoff Levand void ps3_spu_set_platform (void);
61de91a534SGeoff Levand #else
ps3_spu_set_platform(void)62de91a534SGeoff Levand static inline void ps3_spu_set_platform (void) {}
63de91a534SGeoff Levand #endif
64de91a534SGeoff Levand 
652a08ea69SGeoff Levand /* repository bus info */
662a08ea69SGeoff Levand 
672a08ea69SGeoff Levand enum ps3_bus_type {
682a08ea69SGeoff Levand 	PS3_BUS_TYPE_SB = 4,
692a08ea69SGeoff Levand 	PS3_BUS_TYPE_STORAGE = 5,
702a08ea69SGeoff Levand };
712a08ea69SGeoff Levand 
722a08ea69SGeoff Levand enum ps3_dev_type {
732a08ea69SGeoff Levand 	PS3_DEV_TYPE_STOR_DISK = TYPE_DISK,	/* 0 */
742a08ea69SGeoff Levand 	PS3_DEV_TYPE_SB_GELIC = 3,
752a08ea69SGeoff Levand 	PS3_DEV_TYPE_SB_USB = 4,
762a08ea69SGeoff Levand 	PS3_DEV_TYPE_STOR_ROM = TYPE_ROM,	/* 5 */
772a08ea69SGeoff Levand 	PS3_DEV_TYPE_SB_GPIO = 6,
782a08ea69SGeoff Levand 	PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC,	/* 14 */
792a08ea69SGeoff Levand };
802a08ea69SGeoff Levand 
812a08ea69SGeoff Levand int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
822a08ea69SGeoff Levand 	u64 *value);
83034e0ab5SGeert Uytterhoeven int ps3_repository_read_bus_id(unsigned int bus_index, u64 *bus_id);
842a08ea69SGeoff Levand int ps3_repository_read_bus_type(unsigned int bus_index,
852a08ea69SGeoff Levand 	enum ps3_bus_type *bus_type);
862a08ea69SGeoff Levand int ps3_repository_read_bus_num_dev(unsigned int bus_index,
872a08ea69SGeoff Levand 	unsigned int *num_dev);
882a08ea69SGeoff Levand 
892a08ea69SGeoff Levand /* repository bus device info */
902a08ea69SGeoff Levand 
912a08ea69SGeoff Levand enum ps3_interrupt_type {
922a08ea69SGeoff Levand 	PS3_INTERRUPT_TYPE_EVENT_PORT = 2,
932a08ea69SGeoff Levand 	PS3_INTERRUPT_TYPE_SB_OHCI = 3,
942a08ea69SGeoff Levand 	PS3_INTERRUPT_TYPE_SB_EHCI = 4,
952a08ea69SGeoff Levand 	PS3_INTERRUPT_TYPE_OTHER = 5,
962a08ea69SGeoff Levand };
972a08ea69SGeoff Levand 
982a08ea69SGeoff Levand enum ps3_reg_type {
992a08ea69SGeoff Levand 	PS3_REG_TYPE_SB_OHCI = 3,
1002a08ea69SGeoff Levand 	PS3_REG_TYPE_SB_EHCI = 4,
1012a08ea69SGeoff Levand 	PS3_REG_TYPE_SB_GPIO = 5,
1022a08ea69SGeoff Levand };
1032a08ea69SGeoff Levand 
1042a08ea69SGeoff Levand int ps3_repository_read_dev_str(unsigned int bus_index,
1052a08ea69SGeoff Levand 	unsigned int dev_index, const char *dev_str, u64 *value);
1062a08ea69SGeoff Levand int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
107034e0ab5SGeert Uytterhoeven 	u64 *dev_id);
1082a08ea69SGeoff Levand int ps3_repository_read_dev_type(unsigned int bus_index,
1092a08ea69SGeoff Levand 	unsigned int dev_index, enum ps3_dev_type *dev_type);
1102a08ea69SGeoff Levand int ps3_repository_read_dev_intr(unsigned int bus_index,
1112a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int intr_index,
1122a08ea69SGeoff Levand 	enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id);
1132a08ea69SGeoff Levand int ps3_repository_read_dev_reg_type(unsigned int bus_index,
1142a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int reg_index,
1152a08ea69SGeoff Levand 	enum ps3_reg_type *reg_type);
1162a08ea69SGeoff Levand int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
1172a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int reg_index, u64 *bus_addr,
1182a08ea69SGeoff Levand 	u64 *len);
1192a08ea69SGeoff Levand int ps3_repository_read_dev_reg(unsigned int bus_index,
1202a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int reg_index,
1212a08ea69SGeoff Levand 	enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len);
1222a08ea69SGeoff Levand 
1232a08ea69SGeoff Levand /* repository bus enumerators */
1242a08ea69SGeoff Levand 
1252a08ea69SGeoff Levand struct ps3_repository_device {
1262a08ea69SGeoff Levand 	unsigned int bus_index;
1272a08ea69SGeoff Levand 	unsigned int dev_index;
128034e0ab5SGeert Uytterhoeven 	enum ps3_bus_type bus_type;
129034e0ab5SGeert Uytterhoeven 	enum ps3_dev_type dev_type;
130034e0ab5SGeert Uytterhoeven 	u64 bus_id;
131034e0ab5SGeert Uytterhoeven 	u64 dev_id;
1322a08ea69SGeoff Levand };
1332a08ea69SGeoff Levand 
134a3323d1aSGeoff Levand int ps3_repository_find_device(struct ps3_repository_device *repo);
135e06bcf3cSGeert Uytterhoeven int ps3_repository_find_device_by_id(struct ps3_repository_device *repo,
136e06bcf3cSGeert Uytterhoeven 				     u64 bus_id, u64 dev_id);
137*f1ba9b94SNick Child int __init ps3_repository_find_devices(enum ps3_bus_type bus_type,
138a3323d1aSGeoff Levand 	int (*callback)(const struct ps3_repository_device *repo));
139*f1ba9b94SNick Child int __init ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
140a3323d1aSGeoff Levand 	unsigned int *bus_index);
141a3323d1aSGeoff Levand int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
1422a08ea69SGeoff Levand 	enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
143a3323d1aSGeoff Levand int ps3_repository_find_reg(const struct ps3_repository_device *repo,
1442a08ea69SGeoff Levand 	enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len);
1452a08ea69SGeoff Levand 
1462a08ea69SGeoff Levand /* repository block device info */
1472a08ea69SGeoff Levand 
1482a08ea69SGeoff Levand int ps3_repository_read_stor_dev_port(unsigned int bus_index,
1492a08ea69SGeoff Levand 	unsigned int dev_index, u64 *port);
1502a08ea69SGeoff Levand int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
1512a08ea69SGeoff Levand 	unsigned int dev_index, u64 *blk_size);
1522a08ea69SGeoff Levand int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
1532a08ea69SGeoff Levand 	unsigned int dev_index, u64 *num_blocks);
1542a08ea69SGeoff Levand int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
1552a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int *num_regions);
1562a08ea69SGeoff Levand int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
1572a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int region_index,
1582a08ea69SGeoff Levand 	unsigned int *region_id);
1592a08ea69SGeoff Levand int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
1602a08ea69SGeoff Levand 	unsigned int dev_index,	unsigned int region_index, u64 *region_size);
1612a08ea69SGeoff Levand int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
1622a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int region_index, u64 *region_start);
1632a08ea69SGeoff Levand int ps3_repository_read_stor_dev_info(unsigned int bus_index,
1642a08ea69SGeoff Levand 	unsigned int dev_index, u64 *port, u64 *blk_size,
1652a08ea69SGeoff Levand 	u64 *num_blocks, unsigned int *num_regions);
1662a08ea69SGeoff Levand int ps3_repository_read_stor_dev_region(unsigned int bus_index,
1672a08ea69SGeoff Levand 	unsigned int dev_index, unsigned int region_index,
1682a08ea69SGeoff Levand 	unsigned int *region_id, u64 *region_start, u64 *region_size);
1692a08ea69SGeoff Levand 
170c2b16e1cSTakashi Yamamoto /* repository logical pu and memory info */
1712a08ea69SGeoff Levand 
172c2b16e1cSTakashi Yamamoto int ps3_repository_read_num_pu(u64 *num_pu);
173c2b16e1cSTakashi Yamamoto int ps3_repository_read_pu_id(unsigned int pu_index, u64 *pu_id);
1742a08ea69SGeoff Levand int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
1752a08ea69SGeoff Levand int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
1762a08ea69SGeoff Levand int ps3_repository_read_region_total(u64 *region_total);
1772a08ea69SGeoff Levand int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
1782a08ea69SGeoff Levand 	u64 *region_total);
1796750edbdSAndre Heider int ps3_repository_read_highmem_region_count(unsigned int *region_count);
1806750edbdSAndre Heider int ps3_repository_read_highmem_base(unsigned int region_index,
1816750edbdSAndre Heider 	u64 *highmem_base);
1826750edbdSAndre Heider int ps3_repository_read_highmem_size(unsigned int region_index,
1836750edbdSAndre Heider 	u64 *highmem_size);
1846750edbdSAndre Heider int ps3_repository_read_highmem_info(unsigned int region_index,
1856750edbdSAndre Heider 	u64 *highmem_base, u64 *highmem_size);
1862a08ea69SGeoff Levand 
187c02d3506SGeoff Levand #if defined (CONFIG_PS3_REPOSITORY_WRITE)
18879f2a81bSGeoff Levand int ps3_repository_write_highmem_region_count(unsigned int region_count);
18979f2a81bSGeoff Levand int ps3_repository_write_highmem_base(unsigned int region_index,
19079f2a81bSGeoff Levand 	u64 highmem_base);
19179f2a81bSGeoff Levand int ps3_repository_write_highmem_size(unsigned int region_index,
19279f2a81bSGeoff Levand 	u64 highmem_size);
19379f2a81bSGeoff Levand int ps3_repository_write_highmem_info(unsigned int region_index,
19479f2a81bSGeoff Levand 	u64 highmem_base, u64 highmem_size);
19579f2a81bSGeoff Levand int ps3_repository_delete_highmem_info(unsigned int region_index);
196c02d3506SGeoff Levand #else
ps3_repository_write_highmem_region_count(unsigned int region_count)197c02d3506SGeoff Levand static inline int ps3_repository_write_highmem_region_count(
198c02d3506SGeoff Levand 	unsigned int region_count) {return 0;}
ps3_repository_write_highmem_base(unsigned int region_index,u64 highmem_base)199c02d3506SGeoff Levand static inline int ps3_repository_write_highmem_base(unsigned int region_index,
200c02d3506SGeoff Levand 	u64 highmem_base) {return 0;}
ps3_repository_write_highmem_size(unsigned int region_index,u64 highmem_size)201c02d3506SGeoff Levand static inline int ps3_repository_write_highmem_size(unsigned int region_index,
202c02d3506SGeoff Levand 	u64 highmem_size) {return 0;}
ps3_repository_write_highmem_info(unsigned int region_index,u64 highmem_base,u64 highmem_size)203c02d3506SGeoff Levand static inline int ps3_repository_write_highmem_info(unsigned int region_index,
204c02d3506SGeoff Levand 	u64 highmem_base, u64 highmem_size) {return 0;}
ps3_repository_delete_highmem_info(unsigned int region_index)205c02d3506SGeoff Levand static inline int ps3_repository_delete_highmem_info(unsigned int region_index)
206c02d3506SGeoff Levand 	{return 0;}
207c02d3506SGeoff Levand #endif
20879f2a81bSGeoff Levand 
2092a08ea69SGeoff Levand /* repository pme info */
2102a08ea69SGeoff Levand 
2112a08ea69SGeoff Levand int ps3_repository_read_num_be(unsigned int *num_be);
2122a08ea69SGeoff Levand int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
213c2b16e1cSTakashi Yamamoto int ps3_repository_read_be_id(u64 node_id, u64 *be_id);
214*f1ba9b94SNick Child int __init ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
215*f1ba9b94SNick Child int __init ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
2162a08ea69SGeoff Levand 
217c2b16e1cSTakashi Yamamoto /* repository performance monitor info */
218c2b16e1cSTakashi Yamamoto 
219c2b16e1cSTakashi Yamamoto int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar,
220c2b16e1cSTakashi Yamamoto 	u64 *rights);
221c2b16e1cSTakashi Yamamoto 
2222a08ea69SGeoff Levand /* repository 'Other OS' area */
2232a08ea69SGeoff Levand 
2242a08ea69SGeoff Levand int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
2252a08ea69SGeoff Levand int ps3_repository_read_boot_dat_size(unsigned int *size);
2262a08ea69SGeoff Levand int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size);
2272a08ea69SGeoff Levand 
2282a08ea69SGeoff Levand /* repository spu info */
2292a08ea69SGeoff Levand 
2302a08ea69SGeoff Levand /**
2312a08ea69SGeoff Levand  * enum spu_resource_type - Type of spu resource.
2322a08ea69SGeoff Levand  * @spu_resource_type_shared: Logical spu is shared with other partions.
2332a08ea69SGeoff Levand  * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
2342a08ea69SGeoff Levand  *
2352a08ea69SGeoff Levand  * Returned by ps3_repository_read_spu_resource_id().
2362a08ea69SGeoff Levand  */
2372a08ea69SGeoff Levand 
2382a08ea69SGeoff Levand enum ps3_spu_resource_type {
2392a08ea69SGeoff Levand 	PS3_SPU_RESOURCE_TYPE_SHARED = 0,
2402a08ea69SGeoff Levand 	PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
2412a08ea69SGeoff Levand };
2422a08ea69SGeoff Levand 
2432a08ea69SGeoff Levand int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
2442a08ea69SGeoff Levand int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
2452a08ea69SGeoff Levand int ps3_repository_read_spu_resource_id(unsigned int res_index,
2462a08ea69SGeoff Levand 	enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
2472a08ea69SGeoff Levand 
248a3323d1aSGeoff Levand /* repository vuart info */
249a3323d1aSGeoff Levand 
250*f1ba9b94SNick Child int __init ps3_repository_read_vuart_av_port(unsigned int *port);
251*f1ba9b94SNick Child int __init ps3_repository_read_vuart_sysmgr_port(unsigned int *port);
252a3323d1aSGeoff Levand 
253f58a9d17SGeoff Levand #endif
254