Paul Mackerras | b41fc4f | 2005-10-26 21:53:19 +1000 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_MACHDEP_H |
| 2 | #define _ASM_POWERPC_MACHDEP_H |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 3 | #ifdef __KERNEL__ |
| 4 | |
| 5 | /* |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 12 | #include <linux/seq_file.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/dma-mapping.h> |
Paul Gortmaker | 9308794 | 2011-07-29 16:19:31 +1000 | [diff] [blame] | 15 | #include <linux/export.h> |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 16 | |
| 17 | #include <asm/setup.h> |
| 18 | |
| 19 | /* We export this macro for external modules like Alsa to know if |
| 20 | * ppc_md.feature_call is implemented or not |
| 21 | */ |
| 22 | #define CONFIG_PPC_HAS_FEATURE_CALLS |
| 23 | |
| 24 | struct pt_regs; |
| 25 | struct pci_bus; |
| 26 | struct device_node; |
| 27 | struct iommu_table; |
| 28 | struct rtc_time; |
| 29 | struct file; |
Benjamin Herrenschmidt | 4c9d280 | 2006-11-11 17:25:08 +1100 | [diff] [blame] | 30 | struct pci_controller; |
Michael Ellerman | 3d1229d | 2005-11-14 23:35:00 +1100 | [diff] [blame] | 31 | struct kimage; |
Kleber Sacilotto de Souza | d82fb31 | 2013-05-03 12:43:12 +0000 | [diff] [blame] | 32 | struct pci_host_bridge; |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 33 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 34 | struct machdep_calls { |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 35 | char *name; |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 36 | #ifdef CONFIG_PPC64 |
| 37 | void (*hpte_invalidate)(unsigned long slot, |
Aneesh Kumar K.V | 5524a27 | 2012-09-10 02:52:50 +0000 | [diff] [blame] | 38 | unsigned long vpn, |
Aneesh Kumar K.V | db3d853 | 2013-06-20 14:30:13 +0530 | [diff] [blame] | 39 | int bpsize, int apsize, |
| 40 | int ssize, int local); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 41 | long (*hpte_updatepp)(unsigned long slot, |
| 42 | unsigned long newpp, |
Aneesh Kumar K.V | 5524a27 | 2012-09-10 02:52:50 +0000 | [diff] [blame] | 43 | unsigned long vpn, |
Aneesh Kumar K.V | db3d853 | 2013-06-20 14:30:13 +0530 | [diff] [blame] | 44 | int bpsize, int apsize, |
Aneesh Kumar K.V | aefa568 | 2014-12-04 11:00:14 +0530 | [diff] [blame] | 45 | int ssize, unsigned long flags); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 46 | void (*hpte_updateboltedpp)(unsigned long newpp, |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 47 | unsigned long ea, |
Paul Mackerras | 1189be6 | 2007-10-11 20:37:10 +1000 | [diff] [blame] | 48 | int psize, int ssize); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 49 | long (*hpte_insert)(unsigned long hpte_group, |
Aneesh Kumar K.V | 5524a27 | 2012-09-10 02:52:50 +0000 | [diff] [blame] | 50 | unsigned long vpn, |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 51 | unsigned long prpn, |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 52 | unsigned long rflags, |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 53 | unsigned long vflags, |
Aneesh Kumar K.V | b1022fb | 2013-04-28 09:37:35 +0000 | [diff] [blame] | 54 | int psize, int apsize, |
| 55 | int ssize); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 56 | long (*hpte_remove)(unsigned long hpte_group); |
Badari Pulavarty | f8c8803 | 2008-01-29 09:19:24 +1100 | [diff] [blame] | 57 | void (*hpte_removebolted)(unsigned long ea, |
| 58 | int psize, int ssize); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 59 | void (*flush_hash_range)(unsigned long number, int local); |
Aneesh Kumar K.V | fa1f8ae | 2014-08-13 12:31:58 +0530 | [diff] [blame] | 60 | void (*hugepage_invalidate)(unsigned long vsid, |
| 61 | unsigned long addr, |
Aneesh Kumar K.V | 1a52728 | 2013-06-20 14:30:27 +0530 | [diff] [blame] | 62 | unsigned char *hpte_slot_array, |
Aneesh Kumar K.V | d557b09 | 2014-11-02 21:15:28 +0530 | [diff] [blame] | 63 | int psize, int ssize, int local); |
Sonny Rao | bee376f | 2010-11-18 00:39:23 +0000 | [diff] [blame] | 64 | /* special for kexec, to be called in real mode, linear mapping is |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 65 | * destroyed as well */ |
| 66 | void (*hpte_clear_all)(void); |
| 67 | |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 68 | void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size, |
Benjamin Herrenschmidt | 1cdab55 | 2009-02-22 16:19:14 +0000 | [diff] [blame] | 69 | unsigned long flags, void *caller); |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 70 | void (*iounmap)(volatile void __iomem *token); |
Johannes Berg | 7e11580 | 2007-05-03 22:28:32 +1000 | [diff] [blame] | 71 | |
| 72 | #ifdef CONFIG_PM |
| 73 | void (*iommu_save)(void); |
| 74 | void (*iommu_restore)(void); |
| 75 | #endif |
Anton Blanchard | a5d8625 | 2014-06-04 17:50:47 +1000 | [diff] [blame] | 76 | #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE |
| 77 | unsigned long (*memory_block_size)(void); |
| 78 | #endif |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 79 | #endif /* CONFIG_PPC64 */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 80 | |
Milton Miller | 6a5c7be | 2011-06-24 09:05:22 +0000 | [diff] [blame] | 81 | /* Platform set_dma_mask and dma_get_required_mask overrides */ |
Benjamin Herrenschmidt | 5b6e9ff | 2010-08-30 19:23:52 +0000 | [diff] [blame] | 82 | int (*dma_set_mask)(struct device *dev, u64 dma_mask); |
Milton Miller | 6a5c7be | 2011-06-24 09:05:22 +0000 | [diff] [blame] | 83 | u64 (*dma_get_required_mask)(struct device *dev); |
Benjamin Herrenschmidt | 5b6e9ff | 2010-08-30 19:23:52 +0000 | [diff] [blame] | 84 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 85 | int (*probe)(void); |
Grant Likely | 38db7e7 | 2007-10-11 04:48:18 +1000 | [diff] [blame] | 86 | void (*setup_arch)(void); /* Optional, may be NULL */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 87 | void (*init_early)(void); |
| 88 | /* Optional, may be NULL. */ |
Paul Mackerras | d8699e6 | 2005-10-20 17:02:01 +1000 | [diff] [blame] | 89 | void (*show_cpuinfo)(struct seq_file *m); |
| 90 | void (*show_percpuinfo)(struct seq_file *m, int i); |
Gautham R. Shenoy | 2299d03 | 2014-03-11 17:01:18 +0530 | [diff] [blame] | 91 | /* Returns the current operating frequency of "cpu" in Hz */ |
| 92 | unsigned long (*get_proc_freq)(unsigned int cpu); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 93 | |
| 94 | void (*init_IRQ)(void); |
Michael Ellerman | 9b647a3 | 2009-04-22 15:31:38 +0000 | [diff] [blame] | 95 | |
Stephen Rothwell | 7ba3e4f | 2012-03-21 18:09:51 +0000 | [diff] [blame] | 96 | /* Return an irq, or NO_IRQ to indicate there are none pending. */ |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 97 | unsigned int (*get_irq)(void); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 98 | |
| 99 | /* PCI stuff */ |
Gavin Shan | 6ec7334 | 2015-02-13 15:16:32 +1100 | [diff] [blame] | 100 | /* Called after allocating resources */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 101 | void (*pcibios_fixup)(void); |
Benjamin Herrenschmidt | f90bb15 | 2006-11-11 17:24:51 +1100 | [diff] [blame] | 102 | void (*pci_irq_fixup)(struct pci_dev *dev); |
Kleber Sacilotto de Souza | d82fb31 | 2013-05-03 12:43:12 +0000 | [diff] [blame] | 103 | int (*pcibios_root_bridge_prepare)(struct pci_host_bridge |
| 104 | *bridge); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 105 | |
Benjamin Herrenschmidt | 4c9d280 | 2006-11-11 17:25:08 +1100 | [diff] [blame] | 106 | /* To setup PHBs when using automatic OF platform driver for PCI */ |
| 107 | int (*pci_setup_phb)(struct pci_controller *host); |
| 108 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 109 | void (*restart)(char *cmd); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 110 | void (*halt)(void); |
| 111 | void (*panic)(char *str); |
| 112 | void (*cpu_die)(void); |
| 113 | |
| 114 | long (*time_init)(void); /* Optional, may be NULL */ |
| 115 | |
| 116 | int (*set_rtc_time)(struct rtc_time *); |
| 117 | void (*get_rtc_time)(struct rtc_time *); |
| 118 | unsigned long (*get_boot_time)(void); |
| 119 | unsigned char (*rtc_read_val)(int addr); |
| 120 | void (*rtc_write_val)(int addr, unsigned char val); |
| 121 | |
| 122 | void (*calibrate_decr)(void); |
| 123 | |
| 124 | void (*progress)(char *, unsigned short); |
| 125 | |
| 126 | /* Interface for platform error logging */ |
| 127 | void (*log_error)(char *buf, unsigned int err_type, int fatal); |
| 128 | |
Paul Mackerras | 35499c0 | 2005-10-22 16:02:39 +1000 | [diff] [blame] | 129 | unsigned char (*nvram_read_val)(int addr); |
| 130 | void (*nvram_write_val)(int addr, unsigned char val); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 131 | ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index); |
| 132 | ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index); |
| 133 | ssize_t (*nvram_size)(void); |
| 134 | void (*nvram_sync)(void); |
| 135 | |
| 136 | /* Exception handlers */ |
Arnd Bergmann | c902be7 | 2006-01-04 19:55:53 +0000 | [diff] [blame] | 137 | int (*system_reset_exception)(struct pt_regs *regs); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 138 | int (*machine_check_exception)(struct pt_regs *regs); |
Mahesh Salgaonkar | 0869b6f | 2014-07-29 18:40:01 +0530 | [diff] [blame] | 139 | int (*handle_hmi_exception)(struct pt_regs *regs); |
| 140 | |
| 141 | /* Early exception handlers called in realmode */ |
| 142 | int (*hmi_exception_early)(struct pt_regs *regs); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 143 | |
Mahesh Salgaonkar | 55672ec | 2013-12-16 10:46:24 +0530 | [diff] [blame] | 144 | /* Called during machine check exception to retrive fixup address. */ |
| 145 | bool (*mce_check_early_recovery)(struct pt_regs *regs); |
| 146 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 147 | /* Motherboard/chipset features. This is a kind of general purpose |
| 148 | * hook used to control some machine specific features (like reset |
| 149 | * lines, chip power control, etc...). |
| 150 | */ |
| 151 | long (*feature_call)(unsigned int feature, ...); |
| 152 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 153 | /* Get legacy PCI/IDE interrupt mapping */ |
| 154 | int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel); |
| 155 | |
| 156 | /* Get access protection for /dev/mem */ |
| 157 | pgprot_t (*phys_mem_access_prot)(struct file *file, |
Roland Dreier | 8b15047 | 2005-10-28 17:46:18 -0700 | [diff] [blame] | 158 | unsigned long pfn, |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 159 | unsigned long size, |
| 160 | pgprot_t vma_prot); |
| 161 | |
Paul Mackerras | a0652fc | 2006-03-27 15:03:03 +1100 | [diff] [blame] | 162 | /* |
| 163 | * Function for waiting for work with reduced power in idle loop; |
| 164 | * called with interrupts disabled. |
| 165 | */ |
| 166 | void (*power_save)(void); |
| 167 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 168 | /* Function to enable performance monitor counters for this |
| 169 | platform, called once per cpu. */ |
| 170 | void (*enable_pmcs)(void); |
| 171 | |
Michael Ellerman | 76032de | 2005-11-07 13:12:03 +1100 | [diff] [blame] | 172 | /* Set DABR for this platform, leave empty for default implemenation */ |
Michael Neuling | 4474ef0 | 2012-09-06 21:24:56 +0000 | [diff] [blame] | 173 | int (*set_dabr)(unsigned long dabr, |
| 174 | unsigned long dabrx); |
Michael Ellerman | 76032de | 2005-11-07 13:12:03 +1100 | [diff] [blame] | 175 | |
Michael Neuling | bf99de3 | 2012-12-20 14:06:45 +0000 | [diff] [blame] | 176 | /* Set DAWR for this platform, leave empty for default implemenation */ |
| 177 | int (*set_dawr)(unsigned long dawr, |
| 178 | unsigned long dawrx); |
| 179 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 180 | #ifdef CONFIG_PPC32 /* XXX for now */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 181 | /* A general init function, called by ppc_init in init/main.c. |
| 182 | May be NULL. */ |
| 183 | void (*init)(void); |
| 184 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 185 | void (*kgdb_map_scc)(void); |
| 186 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 187 | /* |
| 188 | * optional PCI "hooks" |
| 189 | */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 190 | /* Called at then very end of pcibios_init() */ |
| 191 | void (*pcibios_after_init)(void); |
| 192 | |
Michael Ellerman | 3d1229d | 2005-11-14 23:35:00 +1100 | [diff] [blame] | 193 | #endif /* CONFIG_PPC32 */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 194 | |
Kumar Gala | 89c2dd6 | 2009-08-25 16:20:45 +0000 | [diff] [blame] | 195 | /* Called in indirect_* to avoid touching devices */ |
| 196 | int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char); |
| 197 | |
Benjamin Herrenschmidt | bf5e2ba | 2007-12-20 14:54:51 +1100 | [diff] [blame] | 198 | /* Called after PPC generic resource fixup to perform |
| 199 | machine specific fixups */ |
| 200 | void (*pcibios_fixup_resources)(struct pci_dev *); |
| 201 | |
| 202 | /* Called for each PCI bus in the system when it's probed */ |
| 203 | void (*pcibios_fixup_bus)(struct pci_bus *); |
| 204 | |
Benjamin Herrenschmidt | 491b98c | 2011-11-06 18:55:57 +0000 | [diff] [blame] | 205 | /* Called after scan and before resource survey */ |
| 206 | void (*pcibios_fixup_phb)(struct pci_controller *hose); |
| 207 | |
Wei Yang | 6e628c7 | 2015-03-25 16:23:55 +0800 | [diff] [blame] | 208 | #ifdef CONFIG_PCI_IOV |
| 209 | void (*pcibios_fixup_sriov)(struct pci_dev *pdev); |
Wei Yang | 5350ab3 | 2015-03-25 16:23:56 +0800 | [diff] [blame] | 210 | resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno); |
Wei Yang | 6e628c7 | 2015-03-25 16:23:55 +0800 | [diff] [blame] | 211 | #endif /* CONFIG_PCI_IOV */ |
| 212 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 213 | /* Called to shutdown machine specific hardware not already controlled |
| 214 | * by other drivers. |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 215 | */ |
| 216 | void (*machine_shutdown)(void); |
| 217 | |
Michael Ellerman | 3d1229d | 2005-11-14 23:35:00 +1100 | [diff] [blame] | 218 | #ifdef CONFIG_KEXEC |
Anton Blanchard | 50266a1 | 2011-01-06 17:54:15 +0000 | [diff] [blame] | 219 | void (*kexec_cpu_down)(int crash_shutdown, int secondary); |
| 220 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 221 | /* Called to do what every setup is needed on image and the |
| 222 | * reboot code buffer. Returns 0 on success. |
| 223 | * Provide your own (maybe dummy) implementation if your platform |
| 224 | * claims to support kexec. |
| 225 | */ |
| 226 | int (*machine_kexec_prepare)(struct kimage *image); |
Anton Blanchard | 357574c | 2011-02-23 12:46:16 +0000 | [diff] [blame] | 227 | |
| 228 | /* Called to perform the _real_ kexec. |
| 229 | * Do NOT allocate memory or fail here. We are past the point of |
| 230 | * no return. |
| 231 | */ |
| 232 | void (*machine_kexec)(struct kimage *image); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 233 | #endif /* CONFIG_KEXEC */ |
Scott Wood | 7ac5dde | 2007-12-13 04:35:19 +1100 | [diff] [blame] | 234 | |
| 235 | #ifdef CONFIG_SUSPEND |
| 236 | /* These are called to disable and enable, respectively, IRQs when |
| 237 | * entering a suspend state. If NULL, then the generic versions |
| 238 | * will be called. The generic versions disable/enable the |
| 239 | * decrementer along with interrupts. |
| 240 | */ |
| 241 | void (*suspend_disable_irqs)(void); |
| 242 | void (*suspend_enable_irqs)(void); |
| 243 | #endif |
Brian King | 32d8ad4 | 2010-07-07 12:31:02 +0000 | [diff] [blame] | 244 | int (*suspend_disable_cpu)(void); |
Nathan Fontenot | 12633e8 | 2009-11-25 17:23:25 +0000 | [diff] [blame] | 245 | |
| 246 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE |
| 247 | ssize_t (*cpu_probe)(const char *, size_t); |
| 248 | ssize_t (*cpu_release)(const char *, size_t); |
| 249 | #endif |
Michael Ellerman | a4da0d5 | 2013-10-11 14:07:57 +1100 | [diff] [blame] | 250 | |
| 251 | #ifdef CONFIG_ARCH_RANDOM |
Paul Mackerras | 01c9348 | 2015-07-17 20:11:43 +1000 | [diff] [blame^] | 252 | int (*get_random_seed)(unsigned long *v); |
Michael Ellerman | a4da0d5 | 2013-10-11 14:07:57 +1100 | [diff] [blame] | 253 | #endif |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 254 | }; |
| 255 | |
Kumar Gala | fc4033b | 2008-06-18 16:26:52 -0500 | [diff] [blame] | 256 | extern void e500_idle(void); |
Paul Mackerras | a0652fc | 2006-03-27 15:03:03 +1100 | [diff] [blame] | 257 | extern void power4_idle(void); |
Benjamin Herrenschmidt | 948cf67 | 2011-01-24 18:42:41 +1100 | [diff] [blame] | 258 | extern void power7_idle(void); |
Paul Mackerras | a0652fc | 2006-03-27 15:03:03 +1100 | [diff] [blame] | 259 | extern void ppc6xx_idle(void); |
Benjamin Herrenschmidt | 34d97e07 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 260 | extern void book3e_idle(void); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 261 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 262 | /* |
| 263 | * ppc_md contains a copy of the machine description structure for the |
| 264 | * current platform. machine_id contains the initial address where the |
| 265 | * description was found during boot. |
| 266 | */ |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 267 | extern struct machdep_calls ppc_md; |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 268 | extern struct machdep_calls *machine_id; |
| 269 | |
| 270 | #define __machine_desc __attribute__ ((__section__ (".machine.desc"))) |
| 271 | |
Paul Mackerras | d0e15be | 2006-04-23 10:42:04 +1000 | [diff] [blame] | 272 | #define define_machine(name) \ |
| 273 | extern struct machdep_calls mach_##name; \ |
| 274 | EXPORT_SYMBOL(mach_##name); \ |
| 275 | struct machdep_calls mach_##name __machine_desc = |
| 276 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 277 | #define machine_is(name) \ |
| 278 | ({ \ |
| 279 | extern struct machdep_calls mach_##name \ |
| 280 | __attribute__((weak)); \ |
| 281 | machine_id == &mach_##name; \ |
| 282 | }) |
| 283 | |
| 284 | extern void probe_machine(void); |
| 285 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 286 | #ifdef CONFIG_PPC_PMAC |
| 287 | /* |
| 288 | * Power macintoshes have either a CUDA, PMU or SMU controlling |
| 289 | * system reset, power, NVRAM, RTC. |
| 290 | */ |
| 291 | typedef enum sys_ctrler_kind { |
| 292 | SYS_CTRLER_UNKNOWN = 0, |
| 293 | SYS_CTRLER_CUDA = 1, |
| 294 | SYS_CTRLER_PMU = 2, |
| 295 | SYS_CTRLER_SMU = 3, |
| 296 | } sys_ctrler_t; |
| 297 | extern sys_ctrler_t sys_ctrler; |
| 298 | |
| 299 | #endif /* CONFIG_PPC_PMAC */ |
| 300 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 301 | static inline void log_error(char *buf, unsigned int err_type, int fatal) |
| 302 | { |
| 303 | if (ppc_md.log_error) |
| 304 | ppc_md.log_error(buf, err_type, fatal); |
| 305 | } |
| 306 | |
Matthew Leach | 7929d40 | 2012-12-17 15:59:32 -0800 | [diff] [blame] | 307 | #define __define_machine_initcall(mach, fn, id) \ |
Grant Likely | 800d68c | 2007-12-02 17:10:28 +1100 | [diff] [blame] | 308 | static int __init __machine_initcall_##mach##_##fn(void) { \ |
| 309 | if (machine_is(mach)) return fn(); \ |
| 310 | return 0; \ |
| 311 | } \ |
Matthew Leach | 7929d40 | 2012-12-17 15:59:32 -0800 | [diff] [blame] | 312 | __define_initcall(__machine_initcall_##mach##_##fn, id); |
Grant Likely | 800d68c | 2007-12-02 17:10:28 +1100 | [diff] [blame] | 313 | |
Michael Ellerman | 8d3c941 | 2014-07-15 22:22:23 +1000 | [diff] [blame] | 314 | #define machine_early_initcall(mach, fn) __define_machine_initcall(mach, fn, early) |
Matthew Leach | 7929d40 | 2012-12-17 15:59:32 -0800 | [diff] [blame] | 315 | #define machine_core_initcall(mach, fn) __define_machine_initcall(mach, fn, 1) |
| 316 | #define machine_core_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 1s) |
| 317 | #define machine_postcore_initcall(mach, fn) __define_machine_initcall(mach, fn, 2) |
| 318 | #define machine_postcore_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 2s) |
| 319 | #define machine_arch_initcall(mach, fn) __define_machine_initcall(mach, fn, 3) |
| 320 | #define machine_arch_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 3s) |
| 321 | #define machine_subsys_initcall(mach, fn) __define_machine_initcall(mach, fn, 4) |
| 322 | #define machine_subsys_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 4s) |
| 323 | #define machine_fs_initcall(mach, fn) __define_machine_initcall(mach, fn, 5) |
| 324 | #define machine_fs_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 5s) |
| 325 | #define machine_rootfs_initcall(mach, fn) __define_machine_initcall(mach, fn, rootfs) |
| 326 | #define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6) |
| 327 | #define machine_device_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 6s) |
| 328 | #define machine_late_initcall(mach, fn) __define_machine_initcall(mach, fn, 7) |
| 329 | #define machine_late_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 7s) |
Grant Likely | 800d68c | 2007-12-02 17:10:28 +1100 | [diff] [blame] | 330 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 331 | #endif /* __KERNEL__ */ |
Paul Mackerras | b41fc4f | 2005-10-26 21:53:19 +1000 | [diff] [blame] | 332 | #endif /* _ASM_POWERPC_MACHDEP_H */ |