machdep.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. #ifndef _ASM_POWERPC_MACHDEP_H
  2. #define _ASM_POWERPC_MACHDEP_H
  3. #ifdef __KERNEL__
  4. /*
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #include <linux/seq_file.h>
  11. #include <linux/init.h>
  12. #include <linux/dma-mapping.h>
  13. #include <asm/setup.h>
  14. /* We export this macro for external modules like Alsa to know if
  15. * ppc_md.feature_call is implemented or not
  16. */
  17. #define CONFIG_PPC_HAS_FEATURE_CALLS
  18. struct pt_regs;
  19. struct pci_bus;
  20. struct device_node;
  21. struct iommu_table;
  22. struct rtc_time;
  23. struct file;
  24. struct pci_controller;
  25. struct kimage;
  26. #ifdef CONFIG_SMP
  27. struct smp_ops_t {
  28. void (*message_pass)(int target, int msg);
  29. int (*probe)(void);
  30. void (*kick_cpu)(int nr);
  31. void (*setup_cpu)(int nr);
  32. void (*take_timebase)(void);
  33. void (*give_timebase)(void);
  34. int (*cpu_enable)(unsigned int nr);
  35. int (*cpu_disable)(void);
  36. void (*cpu_die)(unsigned int nr);
  37. int (*cpu_bootable)(unsigned int nr);
  38. };
  39. #endif
  40. struct machdep_calls {
  41. char *name;
  42. #ifdef CONFIG_PPC64
  43. void (*hpte_invalidate)(unsigned long slot,
  44. unsigned long va,
  45. int psize, int ssize,
  46. int local);
  47. long (*hpte_updatepp)(unsigned long slot,
  48. unsigned long newpp,
  49. unsigned long va,
  50. int psize, int ssize,
  51. int local);
  52. void (*hpte_updateboltedpp)(unsigned long newpp,
  53. unsigned long ea,
  54. int psize, int ssize);
  55. long (*hpte_insert)(unsigned long hpte_group,
  56. unsigned long va,
  57. unsigned long prpn,
  58. unsigned long rflags,
  59. unsigned long vflags,
  60. int psize, int ssize);
  61. long (*hpte_remove)(unsigned long hpte_group);
  62. void (*hpte_removebolted)(unsigned long ea,
  63. int psize, int ssize);
  64. void (*flush_hash_range)(unsigned long number, int local);
  65. /* special for kexec, to be called in real mode, linear mapping is
  66. * destroyed as well */
  67. void (*hpte_clear_all)(void);
  68. int (*tce_build)(struct iommu_table *tbl,
  69. long index,
  70. long npages,
  71. unsigned long uaddr,
  72. enum dma_data_direction direction,
  73. struct dma_attrs *attrs);
  74. void (*tce_free)(struct iommu_table *tbl,
  75. long index,
  76. long npages);
  77. unsigned long (*tce_get)(struct iommu_table *tbl,
  78. long index);
  79. void (*tce_flush)(struct iommu_table *tbl);
  80. void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
  81. unsigned long flags, void *caller);
  82. void (*iounmap)(volatile void __iomem *token);
  83. #ifdef CONFIG_PM
  84. void (*iommu_save)(void);
  85. void (*iommu_restore)(void);
  86. #endif
  87. #endif /* CONFIG_PPC64 */
  88. void (*pci_dma_dev_setup)(struct pci_dev *dev);
  89. void (*pci_dma_bus_setup)(struct pci_bus *bus);
  90. /* Platform set_dma_mask override */
  91. int (*dma_set_mask)(struct device *dev, u64 dma_mask);
  92. int (*probe)(void);
  93. void (*setup_arch)(void); /* Optional, may be NULL */
  94. void (*init_early)(void);
  95. /* Optional, may be NULL. */
  96. void (*show_cpuinfo)(struct seq_file *m);
  97. void (*show_percpuinfo)(struct seq_file *m, int i);
  98. void (*init_IRQ)(void);
  99. /* Return an irq, or NO_IRQ to indicate there are none pending.
  100. * If for some reason there is no irq, but the interrupt
  101. * shouldn't be counted as spurious, return NO_IRQ_IGNORE. */
  102. unsigned int (*get_irq)(void);
  103. /* PCI stuff */
  104. /* Called after scanning the bus, before allocating resources */
  105. void (*pcibios_fixup)(void);
  106. int (*pci_probe_mode)(struct pci_bus *);
  107. void (*pci_irq_fixup)(struct pci_dev *dev);
  108. /* To setup PHBs when using automatic OF platform driver for PCI */
  109. int (*pci_setup_phb)(struct pci_controller *host);
  110. #ifdef CONFIG_PCI_MSI
  111. int (*msi_check_device)(struct pci_dev* dev,
  112. int nvec, int type);
  113. int (*setup_msi_irqs)(struct pci_dev *dev,
  114. int nvec, int type);
  115. void (*teardown_msi_irqs)(struct pci_dev *dev);
  116. #endif
  117. void (*restart)(char *cmd);
  118. void (*power_off)(void);
  119. void (*halt)(void);
  120. void (*panic)(char *str);
  121. void (*cpu_die)(void);
  122. long (*time_init)(void); /* Optional, may be NULL */
  123. int (*set_rtc_time)(struct rtc_time *);
  124. void (*get_rtc_time)(struct rtc_time *);
  125. unsigned long (*get_boot_time)(void);
  126. unsigned char (*rtc_read_val)(int addr);
  127. void (*rtc_write_val)(int addr, unsigned char val);
  128. void (*calibrate_decr)(void);
  129. void (*progress)(char *, unsigned short);
  130. /* Interface for platform error logging */
  131. void (*log_error)(char *buf, unsigned int err_type, int fatal);
  132. unsigned char (*nvram_read_val)(int addr);
  133. void (*nvram_write_val)(int addr, unsigned char val);
  134. ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index);
  135. ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index);
  136. ssize_t (*nvram_size)(void);
  137. void (*nvram_sync)(void);
  138. /* Exception handlers */
  139. int (*system_reset_exception)(struct pt_regs *regs);
  140. int (*machine_check_exception)(struct pt_regs *regs);
  141. /* Motherboard/chipset features. This is a kind of general purpose
  142. * hook used to control some machine specific features (like reset
  143. * lines, chip power control, etc...).
  144. */
  145. long (*feature_call)(unsigned int feature, ...);
  146. /* Get legacy PCI/IDE interrupt mapping */
  147. int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
  148. /* Get access protection for /dev/mem */
  149. pgprot_t (*phys_mem_access_prot)(struct file *file,
  150. unsigned long pfn,
  151. unsigned long size,
  152. pgprot_t vma_prot);
  153. /* Idle loop for this platform, leave empty for default idle loop */
  154. void (*idle_loop)(void);
  155. /*
  156. * Function for waiting for work with reduced power in idle loop;
  157. * called with interrupts disabled.
  158. */
  159. void (*power_save)(void);
  160. /* Function to enable performance monitor counters for this
  161. platform, called once per cpu. */
  162. void (*enable_pmcs)(void);
  163. /* Set DABR for this platform, leave empty for default implemenation */
  164. int (*set_dabr)(unsigned long dabr);
  165. #ifdef CONFIG_PPC32 /* XXX for now */
  166. /* A general init function, called by ppc_init in init/main.c.
  167. May be NULL. */
  168. void (*init)(void);
  169. void (*kgdb_map_scc)(void);
  170. /*
  171. * optional PCI "hooks"
  172. */
  173. /* Called at then very end of pcibios_init() */
  174. void (*pcibios_after_init)(void);
  175. #endif /* CONFIG_PPC32 */
  176. /* Called in indirect_* to avoid touching devices */
  177. int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
  178. /* Called after PPC generic resource fixup to perform
  179. machine specific fixups */
  180. void (*pcibios_fixup_resources)(struct pci_dev *);
  181. /* Called for each PCI bus in the system when it's probed */
  182. void (*pcibios_fixup_bus)(struct pci_bus *);
  183. /* Called when pci_enable_device() is called. Returns 0 to
  184. * allow assignment/enabling of the device. */
  185. int (*pcibios_enable_device_hook)(struct pci_dev *);
  186. /* Called to shutdown machine specific hardware not already controlled
  187. * by other drivers.
  188. */
  189. void (*machine_shutdown)(void);
  190. #ifdef CONFIG_KEXEC
  191. void (*kexec_cpu_down)(int crash_shutdown, int secondary);
  192. /* Called to do what every setup is needed on image and the
  193. * reboot code buffer. Returns 0 on success.
  194. * Provide your own (maybe dummy) implementation if your platform
  195. * claims to support kexec.
  196. */
  197. int (*machine_kexec_prepare)(struct kimage *image);
  198. #endif /* CONFIG_KEXEC */
  199. #ifdef CONFIG_SUSPEND
  200. /* These are called to disable and enable, respectively, IRQs when
  201. * entering a suspend state. If NULL, then the generic versions
  202. * will be called. The generic versions disable/enable the
  203. * decrementer along with interrupts.
  204. */
  205. void (*suspend_disable_irqs)(void);
  206. void (*suspend_enable_irqs)(void);
  207. #endif
  208. int (*suspend_disable_cpu)(void);
  209. #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
  210. ssize_t (*cpu_probe)(const char *, size_t);
  211. ssize_t (*cpu_release)(const char *, size_t);
  212. #endif
  213. };
  214. extern void e500_idle(void);
  215. extern void power4_idle(void);
  216. extern void power4_cpu_offline_powersave(void);
  217. extern void ppc6xx_idle(void);
  218. extern void book3e_idle(void);
  219. /*
  220. * ppc_md contains a copy of the machine description structure for the
  221. * current platform. machine_id contains the initial address where the
  222. * description was found during boot.
  223. */
  224. extern struct machdep_calls ppc_md;
  225. extern struct machdep_calls *machine_id;
  226. #define __machine_desc __attribute__ ((__section__ (".machine.desc")))
  227. #define define_machine(name) \
  228. extern struct machdep_calls mach_##name; \
  229. EXPORT_SYMBOL(mach_##name); \
  230. struct machdep_calls mach_##name __machine_desc =
  231. #define machine_is(name) \
  232. ({ \
  233. extern struct machdep_calls mach_##name \
  234. __attribute__((weak)); \
  235. machine_id == &mach_##name; \
  236. })
  237. extern void probe_machine(void);
  238. extern char cmd_line[COMMAND_LINE_SIZE];
  239. #ifdef CONFIG_PPC_PMAC
  240. /*
  241. * Power macintoshes have either a CUDA, PMU or SMU controlling
  242. * system reset, power, NVRAM, RTC.
  243. */
  244. typedef enum sys_ctrler_kind {
  245. SYS_CTRLER_UNKNOWN = 0,
  246. SYS_CTRLER_CUDA = 1,
  247. SYS_CTRLER_PMU = 2,
  248. SYS_CTRLER_SMU = 3,
  249. } sys_ctrler_t;
  250. extern sys_ctrler_t sys_ctrler;
  251. #endif /* CONFIG_PPC_PMAC */
  252. #ifdef CONFIG_SMP
  253. /* Poor default implementations */
  254. extern void __devinit smp_generic_give_timebase(void);
  255. extern void __devinit smp_generic_take_timebase(void);
  256. #endif /* CONFIG_SMP */
  257. /* Functions to produce codes on the leds.
  258. * The SRC code should be unique for the message category and should
  259. * be limited to the lower 24 bits (the upper 8 are set by these funcs),
  260. * and (for boot & dump) should be sorted numerically in the order
  261. * the events occur.
  262. */
  263. /* Print a boot progress message. */
  264. void ppc64_boot_msg(unsigned int src, const char *msg);
  265. static inline void log_error(char *buf, unsigned int err_type, int fatal)
  266. {
  267. if (ppc_md.log_error)
  268. ppc_md.log_error(buf, err_type, fatal);
  269. }
  270. #define __define_machine_initcall(mach,level,fn,id) \
  271. static int __init __machine_initcall_##mach##_##fn(void) { \
  272. if (machine_is(mach)) return fn(); \
  273. return 0; \
  274. } \
  275. __define_initcall(level,__machine_initcall_##mach##_##fn,id);
  276. #define machine_core_initcall(mach,fn) __define_machine_initcall(mach,"1",fn,1)
  277. #define machine_core_initcall_sync(mach,fn) __define_machine_initcall(mach,"1s",fn,1s)
  278. #define machine_postcore_initcall(mach,fn) __define_machine_initcall(mach,"2",fn,2)
  279. #define machine_postcore_initcall_sync(mach,fn) __define_machine_initcall(mach,"2s",fn,2s)
  280. #define machine_arch_initcall(mach,fn) __define_machine_initcall(mach,"3",fn,3)
  281. #define machine_arch_initcall_sync(mach,fn) __define_machine_initcall(mach,"3s",fn,3s)
  282. #define machine_subsys_initcall(mach,fn) __define_machine_initcall(mach,"4",fn,4)
  283. #define machine_subsys_initcall_sync(mach,fn) __define_machine_initcall(mach,"4s",fn,4s)
  284. #define machine_fs_initcall(mach,fn) __define_machine_initcall(mach,"5",fn,5)
  285. #define machine_fs_initcall_sync(mach,fn) __define_machine_initcall(mach,"5s",fn,5s)
  286. #define machine_rootfs_initcall(mach,fn) __define_machine_initcall(mach,"rootfs",fn,rootfs)
  287. #define machine_device_initcall(mach,fn) __define_machine_initcall(mach,"6",fn,6)
  288. #define machine_device_initcall_sync(mach,fn) __define_machine_initcall(mach,"6s",fn,6s)
  289. #define machine_late_initcall(mach,fn) __define_machine_initcall(mach,"7",fn,7)
  290. #define machine_late_initcall_sync(mach,fn) __define_machine_initcall(mach,"7s",fn,7s)
  291. #endif /* __KERNEL__ */
  292. #endif /* _ASM_POWERPC_MACHDEP_H */