machdep.h 12 KB

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