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