1
2#ifndef _ASM_POWERPC_MACHDEP_H
3#define _ASM_POWERPC_MACHDEP_H
4#ifdef __KERNEL__
5
6
7
8
9#include <linux/seq_file.h>
10#include <linux/init.h>
11#include <linux/dma-mapping.h>
12#include <linux/export.h>
13
14#include <asm/setup.h>
15
16
17
18
19#define CONFIG_PPC_HAS_FEATURE_CALLS
20
21struct pt_regs;
22struct pci_bus;
23struct device_node;
24struct iommu_table;
25struct rtc_time;
26struct file;
27struct pci_controller;
28struct kimage;
29struct pci_host_bridge;
30
31struct machdep_calls {
32 char *name;
33#ifdef CONFIG_PPC64
34 void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
35 pgprot_t prot, void *caller);
36 void (*iounmap)(volatile void __iomem *token);
37
38#ifdef CONFIG_PM
39 void (*iommu_save)(void);
40 void (*iommu_restore)(void);
41#endif
42#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
43 unsigned long (*memory_block_size)(void);
44#endif
45#endif
46
47 void (*dma_set_mask)(struct device *dev, u64 dma_mask);
48
49 int (*probe)(void);
50 void (*setup_arch)(void);
51
52 void (*show_cpuinfo)(struct seq_file *m);
53 void (*show_percpuinfo)(struct seq_file *m, int i);
54
55 unsigned long (*get_proc_freq)(unsigned int cpu);
56
57 void (*init_IRQ)(void);
58
59
60 unsigned int (*get_irq)(void);
61
62
63
64 void (*pcibios_fixup)(void);
65 void (*pci_irq_fixup)(struct pci_dev *dev);
66 int (*pcibios_root_bridge_prepare)(struct pci_host_bridge
67 *bridge);
68
69
70 int (*pci_setup_phb)(struct pci_controller *host);
71
72 void __noreturn (*restart)(char *cmd);
73 void __noreturn (*halt)(void);
74 void (*panic)(char *str);
75 void (*cpu_die)(void);
76
77 long (*time_init)(void);
78
79 int (*set_rtc_time)(struct rtc_time *);
80 void (*get_rtc_time)(struct rtc_time *);
81 time64_t (*get_boot_time)(void);
82 unsigned char (*rtc_read_val)(int addr);
83 void (*rtc_write_val)(int addr, unsigned char val);
84
85 void (*calibrate_decr)(void);
86
87 void (*progress)(char *, unsigned short);
88
89
90 void (*log_error)(char *buf, unsigned int err_type, int fatal);
91
92 unsigned char (*nvram_read_val)(int addr);
93 void (*nvram_write_val)(int addr, unsigned char val);
94 ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index);
95 ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index);
96 ssize_t (*nvram_size)(void);
97 void (*nvram_sync)(void);
98
99
100 int (*system_reset_exception)(struct pt_regs *regs);
101 int (*machine_check_exception)(struct pt_regs *regs);
102 int (*handle_hmi_exception)(struct pt_regs *regs);
103
104
105 int (*hmi_exception_early)(struct pt_regs *regs);
106 long (*machine_check_early)(struct pt_regs *regs);
107
108
109 bool (*mce_check_early_recovery)(struct pt_regs *regs);
110
111
112
113
114
115 long (*feature_call)(unsigned int feature, ...);
116
117
118 int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
119
120
121 pgprot_t (*phys_mem_access_prot)(struct file *file,
122 unsigned long pfn,
123 unsigned long size,
124 pgprot_t vma_prot);
125
126
127
128
129
130 void (*power_save)(void);
131
132
133
134 void (*enable_pmcs)(void);
135
136
137 int (*set_dabr)(unsigned long dabr,
138 unsigned long dabrx);
139
140
141 int (*set_dawr)(unsigned long dawr,
142 unsigned long dawrx);
143
144#ifdef CONFIG_PPC32
145
146
147 void (*init)(void);
148
149 void (*kgdb_map_scc)(void);
150
151
152
153
154
155 void (*pcibios_after_init)(void);
156
157#endif
158
159
160 int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
161
162
163
164 void (*pcibios_fixup_resources)(struct pci_dev *);
165
166
167 void (*pcibios_fixup_bus)(struct pci_bus *);
168
169
170 void (*pcibios_fixup_phb)(struct pci_controller *hose);
171
172
173
174
175
176 void (*pcibios_bus_add_device)(struct pci_dev *pdev);
177
178 resource_size_t (*pcibios_default_alignment)(void);
179
180#ifdef CONFIG_PCI_IOV
181 void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
182 resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
183 int (*pcibios_sriov_enable)(struct pci_dev *pdev, u16 num_vfs);
184 int (*pcibios_sriov_disable)(struct pci_dev *pdev);
185#endif
186
187
188
189
190 void (*machine_shutdown)(void);
191
192#ifdef CONFIG_KEXEC_CORE
193 void (*kexec_cpu_down)(int crash_shutdown, int secondary);
194
195
196
197
198
199
200 int (*machine_kexec_prepare)(struct kimage *image);
201
202
203
204
205
206 void (*machine_kexec)(struct kimage *image);
207#endif
208
209#ifdef CONFIG_SUSPEND
210
211
212
213
214
215 void (*suspend_disable_irqs)(void);
216 void (*suspend_enable_irqs)(void);
217#endif
218 int (*suspend_disable_cpu)(void);
219
220#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
221 ssize_t (*cpu_probe)(const char *, size_t);
222 ssize_t (*cpu_release)(const char *, size_t);
223#endif
224
225#ifdef CONFIG_ARCH_RANDOM
226 int (*get_random_seed)(unsigned long *v);
227#endif
228};
229
230extern void e500_idle(void);
231extern void power4_idle(void);
232extern void power7_idle(void);
233extern void power9_idle(void);
234extern void ppc6xx_idle(void);
235extern void book3e_idle(void);
236
237
238
239
240
241
242extern struct machdep_calls ppc_md;
243extern struct machdep_calls *machine_id;
244
245#define __machine_desc __attribute__ ((__section__ (".machine.desc")))
246
247#define define_machine(name) \
248 extern struct machdep_calls mach_##name; \
249 EXPORT_SYMBOL(mach_##name); \
250 struct machdep_calls mach_##name __machine_desc =
251
252#define machine_is(name) \
253 ({ \
254 extern struct machdep_calls mach_##name \
255 __attribute__((weak)); \
256 machine_id == &mach_##name; \
257 })
258
259extern void probe_machine(void);
260
261#ifdef CONFIG_PPC_PMAC
262
263
264
265
266typedef enum sys_ctrler_kind {
267 SYS_CTRLER_UNKNOWN = 0,
268 SYS_CTRLER_CUDA = 1,
269 SYS_CTRLER_PMU = 2,
270 SYS_CTRLER_SMU = 3,
271} sys_ctrler_t;
272extern sys_ctrler_t sys_ctrler;
273
274#endif
275
276static inline void log_error(char *buf, unsigned int err_type, int fatal)
277{
278 if (ppc_md.log_error)
279 ppc_md.log_error(buf, err_type, fatal);
280}
281
282#define __define_machine_initcall(mach, fn, id) \
283 static int __init __machine_initcall_##mach##_##fn(void) { \
284 if (machine_is(mach)) return fn(); \
285 return 0; \
286 } \
287 __define_initcall(__machine_initcall_##mach##_##fn, id);
288
289#define machine_early_initcall(mach, fn) __define_machine_initcall(mach, fn, early)
290#define machine_core_initcall(mach, fn) __define_machine_initcall(mach, fn, 1)
291#define machine_core_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 1s)
292#define machine_postcore_initcall(mach, fn) __define_machine_initcall(mach, fn, 2)
293#define machine_postcore_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 2s)
294#define machine_arch_initcall(mach, fn) __define_machine_initcall(mach, fn, 3)
295#define machine_arch_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 3s)
296#define machine_subsys_initcall(mach, fn) __define_machine_initcall(mach, fn, 4)
297#define machine_subsys_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 4s)
298#define machine_fs_initcall(mach, fn) __define_machine_initcall(mach, fn, 5)
299#define machine_fs_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 5s)
300#define machine_rootfs_initcall(mach, fn) __define_machine_initcall(mach, fn, rootfs)
301#define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6)
302#define machine_device_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 6s)
303#define machine_late_initcall(mach, fn) __define_machine_initcall(mach, fn, 7)
304#define machine_late_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 7s)
305
306#endif
307#endif
308