blob: e1a0a7b213d7bdbc313cf043572e1983f0304b3a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifdef __KERNEL__
2#ifndef _PPC_MACHDEP_H
3#define _PPC_MACHDEP_H
4
5#include <linux/config.h>
6#include <linux/init.h>
Eric W. Biederman70765aa2005-06-25 14:58:07 -07007#include <linux/kexec.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9#include <asm/setup.h>
10#include <asm/page.h>
11
12#ifdef CONFIG_APUS
13#include <asm-m68k/machdep.h>
14#endif
15
16struct pt_regs;
17struct pci_bus;
18struct pci_dev;
19struct seq_file;
20struct file;
21
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110022/*
23 * This is for compatibility with ARCH=powerpc.
24 */
25#define machine_is(x) __MACHINE_IS_##x
26#define __MACHINE_IS_powermac 0
27#define __MACHINE_IS_chrp 0
28#ifdef CONFIG_PPC_PREP
29#define __MACHINE_IS_prep 1
30#else
31#define __MACHINE_IS_prep 0
32#endif
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/* We export this macro for external modules like Alsa to know if
35 * ppc_md.feature_call is implemented or not
36 */
37#define CONFIG_PPC_HAS_FEATURE_CALLS
38
39struct machdep_calls {
40 void (*setup_arch)(void);
41 /* Optional, may be NULL. */
42 int (*show_cpuinfo)(struct seq_file *m);
43 int (*show_percpuinfo)(struct seq_file *m, int i);
44 /* Optional, may be NULL. */
45 unsigned int (*irq_canonicalize)(unsigned int irq);
46 void (*init_IRQ)(void);
47 int (*get_irq)(struct pt_regs *);
48
49 /* A general init function, called by ppc_init in init/main.c.
Benjamin Herrenschmidt51d30822005-11-23 17:57:25 +110050 May be NULL. DEPRECATED ! */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 void (*init)(void);
Benjamin Herrenschmidt51d30822005-11-23 17:57:25 +110052 /* For compatibility with merged platforms */
53 void (*init_early)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 void (*restart)(char *cmd);
56 void (*power_off)(void);
57 void (*halt)(void);
58
Paul Mackerrasa0652fc2006-03-27 15:03:03 +110059 void (*idle_loop)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 void (*power_save)(void);
61
62 long (*time_init)(void); /* Optional, may be NULL */
63 int (*set_rtc_time)(unsigned long nowtime);
64 unsigned long (*get_rtc_time)(void);
65 unsigned char (*rtc_read_val)(int addr);
66 void (*rtc_write_val)(int addr, unsigned char val);
67 void (*calibrate_decr)(void);
68
69 void (*heartbeat)(void);
70 unsigned long heartbeat_reset;
71 unsigned long heartbeat_count;
72
73 unsigned long (*find_end_of_memory)(void);
74 void (*setup_io_mappings)(void);
75
76 void (*early_serial_map)(void);
77 void (*progress)(char *, unsigned short);
78 void (*kgdb_map_scc)(void);
79
80 unsigned char (*nvram_read_val)(int addr);
81 void (*nvram_write_val)(int addr, unsigned char val);
82 void (*nvram_sync)(void);
83
84 /*
85 * optional PCI "hooks"
86 */
87
88 /* Called after scanning the bus, before allocating resources */
89 void (*pcibios_fixup)(void);
90
91 /* Called after PPC generic resource fixup to perform
92 machine specific fixups */
93 void (*pcibios_fixup_resources)(struct pci_dev *);
94
95 /* Called for each PCI bus in the system when it's probed */
96 void (*pcibios_fixup_bus)(struct pci_bus *);
97
98 /* Called when pci_enable_device() is called (initial=0) or
99 * when a device with no assigned resource is found (initial=1).
100 * Returns 0 to allow assignment/enabling of the device. */
101 int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
102
103 /* For interrupt routing */
104 unsigned char (*pci_swizzle)(struct pci_dev *, unsigned char *);
105 int (*pci_map_irq)(struct pci_dev *, unsigned char, unsigned char);
106
107 /* Called in indirect_* to avoid touching devices */
108 int (*pci_exclude_device)(unsigned char, unsigned char);
109
110 /* Called at then very end of pcibios_init() */
111 void (*pcibios_after_init)(void);
112
113 /* Get access protection for /dev/mem */
114 pgprot_t (*phys_mem_access_prot)(struct file *file,
Roland Dreier8b150472005-10-28 17:46:18 -0700115 unsigned long pfn,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 unsigned long size,
117 pgprot_t vma_prot);
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 /* Motherboard/chipset features. This is a kind of general purpose
120 * hook used to control some machine specific features (like reset
121 * lines, chip power control, etc...).
122 */
123 long (*feature_call)(unsigned int feature, ...);
124
125#ifdef CONFIG_SMP
126 /* functions for dealing with other cpus */
127 struct smp_ops_t *smp_ops;
128#endif /* CONFIG_SMP */
Eric W. Biederman70765aa2005-06-25 14:58:07 -0700129
130#ifdef CONFIG_KEXEC
131 /* Called to shutdown machine specific hardware not already controlled
132 * by other drivers.
133 * XXX Should we move this one out of kexec scope?
134 */
135 void (*machine_shutdown)(void);
136
137 /* Called to do the minimal shutdown needed to run a kexec'd kernel
138 * to run successfully.
139 * XXX Should we move this one out of kexec scope?
140 */
141 void (*machine_crash_shutdown)(void);
142
143 /* Called to do what every setup is needed on image and the
144 * reboot code buffer. Returns 0 on success.
145 * Provide your own (maybe dummy) implementation if your platform
146 * claims to support kexec.
147 */
148 int (*machine_kexec_prepare)(struct kimage *image);
149
150 /* Called to handle any machine specific cleanup on image */
151 void (*machine_kexec_cleanup)(struct kimage *image);
152
153 /* Called to perform the _real_ kexec.
154 * Do NOT allocate memory or fail here. We are past the point of
155 * no return.
156 */
157 void (*machine_kexec)(struct kimage *image);
158#endif /* CONFIG_KEXEC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159};
160
161extern struct machdep_calls ppc_md;
162extern char cmd_line[COMMAND_LINE_SIZE];
163
164extern void setup_pci_ptrs(void);
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166#ifdef CONFIG_SMP
167struct smp_ops_t {
Paul Mackerras17a63922005-10-20 21:10:09 +1000168 void (*message_pass)(int target, int msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 int (*probe)(void);
170 void (*kick_cpu)(int nr);
171 void (*setup_cpu)(int nr);
172 void (*space_timers)(int nr);
173 void (*take_timebase)(void);
174 void (*give_timebase)(void);
175};
176
177/* Poor default implementations */
178extern void __devinit smp_generic_give_timebase(void);
179extern void __devinit smp_generic_take_timebase(void);
180#endif /* CONFIG_SMP */
181
182#endif /* _PPC_MACHDEP_H */
183#endif /* __KERNEL__ */