blob: 39200def8d116fc0c8e1043a242007e80b65182a [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
22/* We export this macro for external modules like Alsa to know if
23 * ppc_md.feature_call is implemented or not
24 */
25#define CONFIG_PPC_HAS_FEATURE_CALLS
26
27struct machdep_calls {
28 void (*setup_arch)(void);
29 /* Optional, may be NULL. */
30 int (*show_cpuinfo)(struct seq_file *m);
31 int (*show_percpuinfo)(struct seq_file *m, int i);
32 /* Optional, may be NULL. */
33 unsigned int (*irq_canonicalize)(unsigned int irq);
34 void (*init_IRQ)(void);
35 int (*get_irq)(struct pt_regs *);
36
37 /* A general init function, called by ppc_init in init/main.c.
Benjamin Herrenschmidt51d30822005-11-23 17:57:25 +110038 May be NULL. DEPRECATED ! */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 void (*init)(void);
Benjamin Herrenschmidt51d30822005-11-23 17:57:25 +110040 /* For compatibility with merged platforms */
41 void (*init_early)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43 void (*restart)(char *cmd);
44 void (*power_off)(void);
45 void (*halt)(void);
46
47 void (*idle)(void);
48 void (*power_save)(void);
49
50 long (*time_init)(void); /* Optional, may be NULL */
51 int (*set_rtc_time)(unsigned long nowtime);
52 unsigned long (*get_rtc_time)(void);
53 unsigned char (*rtc_read_val)(int addr);
54 void (*rtc_write_val)(int addr, unsigned char val);
55 void (*calibrate_decr)(void);
56
57 void (*heartbeat)(void);
58 unsigned long heartbeat_reset;
59 unsigned long heartbeat_count;
60
61 unsigned long (*find_end_of_memory)(void);
62 void (*setup_io_mappings)(void);
63
64 void (*early_serial_map)(void);
65 void (*progress)(char *, unsigned short);
66 void (*kgdb_map_scc)(void);
67
68 unsigned char (*nvram_read_val)(int addr);
69 void (*nvram_write_val)(int addr, unsigned char val);
70 void (*nvram_sync)(void);
71
72 /*
73 * optional PCI "hooks"
74 */
75
76 /* Called after scanning the bus, before allocating resources */
77 void (*pcibios_fixup)(void);
78
79 /* Called after PPC generic resource fixup to perform
80 machine specific fixups */
81 void (*pcibios_fixup_resources)(struct pci_dev *);
82
83 /* Called for each PCI bus in the system when it's probed */
84 void (*pcibios_fixup_bus)(struct pci_bus *);
85
86 /* Called when pci_enable_device() is called (initial=0) or
87 * when a device with no assigned resource is found (initial=1).
88 * Returns 0 to allow assignment/enabling of the device. */
89 int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
90
91 /* For interrupt routing */
92 unsigned char (*pci_swizzle)(struct pci_dev *, unsigned char *);
93 int (*pci_map_irq)(struct pci_dev *, unsigned char, unsigned char);
94
95 /* Called in indirect_* to avoid touching devices */
96 int (*pci_exclude_device)(unsigned char, unsigned char);
97
98 /* Called at then very end of pcibios_init() */
99 void (*pcibios_after_init)(void);
100
101 /* Get access protection for /dev/mem */
102 pgprot_t (*phys_mem_access_prot)(struct file *file,
Roland Dreier8b150472005-10-28 17:46:18 -0700103 unsigned long pfn,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 unsigned long size,
105 pgprot_t vma_prot);
106
107 /* this is for modules, since _machine can be a define -- Cort */
108 int ppc_machine;
109
110 /* Motherboard/chipset features. This is a kind of general purpose
111 * hook used to control some machine specific features (like reset
112 * lines, chip power control, etc...).
113 */
114 long (*feature_call)(unsigned int feature, ...);
115
116#ifdef CONFIG_SMP
117 /* functions for dealing with other cpus */
118 struct smp_ops_t *smp_ops;
119#endif /* CONFIG_SMP */
Eric W. Biederman70765aa2005-06-25 14:58:07 -0700120
121#ifdef CONFIG_KEXEC
122 /* Called to shutdown machine specific hardware not already controlled
123 * by other drivers.
124 * XXX Should we move this one out of kexec scope?
125 */
126 void (*machine_shutdown)(void);
127
128 /* Called to do the minimal shutdown needed to run a kexec'd kernel
129 * to run successfully.
130 * XXX Should we move this one out of kexec scope?
131 */
132 void (*machine_crash_shutdown)(void);
133
134 /* Called to do what every setup is needed on image and the
135 * reboot code buffer. Returns 0 on success.
136 * Provide your own (maybe dummy) implementation if your platform
137 * claims to support kexec.
138 */
139 int (*machine_kexec_prepare)(struct kimage *image);
140
141 /* Called to handle any machine specific cleanup on image */
142 void (*machine_kexec_cleanup)(struct kimage *image);
143
144 /* Called to perform the _real_ kexec.
145 * Do NOT allocate memory or fail here. We are past the point of
146 * no return.
147 */
148 void (*machine_kexec)(struct kimage *image);
149#endif /* CONFIG_KEXEC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150};
151
152extern struct machdep_calls ppc_md;
153extern char cmd_line[COMMAND_LINE_SIZE];
154
155extern void setup_pci_ptrs(void);
156
157/*
158 * Power macintoshes have either a CUDA or a PMU controlling
159 * system reset, power, NVRAM, RTC.
160 */
161typedef enum sys_ctrler_kind {
162 SYS_CTRLER_UNKNOWN = 0,
163 SYS_CTRLER_CUDA = 1,
164 SYS_CTRLER_PMU = 2,
165 SYS_CTRLER_SMU = 3,
166} sys_ctrler_t;
167
168extern sys_ctrler_t sys_ctrler;
169
170#ifdef CONFIG_SMP
171struct smp_ops_t {
Paul Mackerras17a63922005-10-20 21:10:09 +1000172 void (*message_pass)(int target, int msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 int (*probe)(void);
174 void (*kick_cpu)(int nr);
175 void (*setup_cpu)(int nr);
176 void (*space_timers)(int nr);
177 void (*take_timebase)(void);
178 void (*give_timebase)(void);
179};
180
181/* Poor default implementations */
182extern void __devinit smp_generic_give_timebase(void);
183extern void __devinit smp_generic_take_timebase(void);
184#endif /* CONFIG_SMP */
185
186#endif /* _PPC_MACHDEP_H */
187#endif /* __KERNEL__ */