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