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