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