machdep.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. #ifdef CONFIG_KEXEC
  26. struct kimage;
  27. #endif
  28. #ifdef CONFIG_SMP
  29. struct smp_ops_t {
  30. void (*message_pass)(int target, int msg);
  31. int (*probe)(void);
  32. void (*kick_cpu)(int nr);
  33. void (*setup_cpu)(int nr);
  34. void (*take_timebase)(void);
  35. void (*give_timebase)(void);
  36. int (*cpu_enable)(unsigned int nr);
  37. int (*cpu_disable)(void);
  38. void (*cpu_die)(unsigned int nr);
  39. int (*cpu_bootable)(unsigned int nr);
  40. };
  41. #endif
  42. struct machdep_calls {
  43. char *name;
  44. #ifdef CONFIG_PPC64
  45. void (*hpte_invalidate)(unsigned long slot,
  46. unsigned long va,
  47. int psize, int ssize,
  48. int local);
  49. long (*hpte_updatepp)(unsigned long slot,
  50. unsigned long newpp,
  51. unsigned long va,
  52. int psize, int ssize,
  53. int local);
  54. void (*hpte_updateboltedpp)(unsigned long newpp,
  55. unsigned long ea,
  56. int psize, int ssize);
  57. long (*hpte_insert)(unsigned long hpte_group,
  58. unsigned long va,
  59. unsigned long prpn,
  60. unsigned long rflags,
  61. unsigned long vflags,
  62. int psize, int ssize);
  63. long (*hpte_remove)(unsigned long hpte_group);
  64. void (*flush_hash_range)(unsigned long number, int local);
  65. /* special for kexec, to be called in real mode, linar mapping is
  66. * destroyed as well */
  67. void (*hpte_clear_all)(void);
  68. void (*tce_build)(struct iommu_table * tbl,
  69. long index,
  70. long npages,
  71. unsigned long uaddr,
  72. enum dma_data_direction direction);
  73. void (*tce_free)(struct iommu_table *tbl,
  74. long index,
  75. long npages);
  76. unsigned long (*tce_get)(struct iommu_table *tbl,
  77. long index);
  78. void (*tce_flush)(struct iommu_table *tbl);
  79. void (*pci_dma_dev_setup)(struct pci_dev *dev);
  80. void (*pci_dma_bus_setup)(struct pci_bus *bus);
  81. void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
  82. unsigned long flags);
  83. void (*iounmap)(volatile void __iomem *token);
  84. #ifdef CONFIG_PM
  85. void (*iommu_save)(void);
  86. void (*iommu_restore)(void);
  87. #endif
  88. #endif /* CONFIG_PPC64 */
  89. int (*probe)(void);
  90. void (*setup_arch)(void); /* Optional, may be NULL */
  91. void (*init_early)(void);
  92. /* Optional, may be NULL. */
  93. void (*show_cpuinfo)(struct seq_file *m);
  94. void (*show_percpuinfo)(struct seq_file *m, int i);
  95. void (*init_IRQ)(void);
  96. unsigned int (*get_irq)(void);
  97. #ifdef CONFIG_KEXEC
  98. void (*kexec_cpu_down)(int crash_shutdown, int secondary);
  99. #endif
  100. /* PCI stuff */
  101. /* Called after scanning the bus, before allocating resources */
  102. void (*pcibios_fixup)(void);
  103. int (*pci_probe_mode)(struct pci_bus *);
  104. void (*pci_irq_fixup)(struct pci_dev *dev);
  105. /* To setup PHBs when using automatic OF platform driver for PCI */
  106. int (*pci_setup_phb)(struct pci_controller *host);
  107. #ifdef CONFIG_PCI_MSI
  108. int (*msi_check_device)(struct pci_dev* dev,
  109. int nvec, int type);
  110. int (*setup_msi_irqs)(struct pci_dev *dev,
  111. int nvec, int type);
  112. void (*teardown_msi_irqs)(struct pci_dev *dev);
  113. #endif
  114. void (*restart)(char *cmd);
  115. void (*power_off)(void);
  116. void (*halt)(void);
  117. void (*panic)(char *str);
  118. void (*cpu_die)(void);
  119. long (*time_init)(void); /* Optional, may be NULL */
  120. int (*set_rtc_time)(struct rtc_time *);
  121. void (*get_rtc_time)(struct rtc_time *);
  122. unsigned long (*get_boot_time)(void);
  123. unsigned char (*rtc_read_val)(int addr);
  124. void (*rtc_write_val)(int addr, unsigned char val);
  125. void (*calibrate_decr)(void);
  126. void (*progress)(char *, unsigned short);
  127. /* Interface for platform error logging */
  128. void (*log_error)(char *buf, unsigned int err_type, int fatal);
  129. unsigned char (*nvram_read_val)(int addr);
  130. void (*nvram_write_val)(int addr, unsigned char val);
  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. /* Exception handlers */
  136. int (*system_reset_exception)(struct pt_regs *regs);
  137. int (*machine_check_exception)(struct pt_regs *regs);
  138. /* Motherboard/chipset features. This is a kind of general purpose
  139. * hook used to control some machine specific features (like reset
  140. * lines, chip power control, etc...).
  141. */
  142. long (*feature_call)(unsigned int feature, ...);
  143. /* Get legacy PCI/IDE interrupt mapping */
  144. int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
  145. /* Get access protection for /dev/mem */
  146. pgprot_t (*phys_mem_access_prot)(struct file *file,
  147. unsigned long pfn,
  148. unsigned long size,
  149. pgprot_t vma_prot);
  150. /* Idle loop for this platform, leave empty for default idle loop */
  151. void (*idle_loop)(void);
  152. /*
  153. * Function for waiting for work with reduced power in idle loop;
  154. * called with interrupts disabled.
  155. */
  156. void (*power_save)(void);
  157. /* Function to enable performance monitor counters for this
  158. platform, called once per cpu. */
  159. void (*enable_pmcs)(void);
  160. /* Set DABR for this platform, leave empty for default implemenation */
  161. int (*set_dabr)(unsigned long dabr);
  162. #ifdef CONFIG_PPC32 /* XXX for now */
  163. /* A general init function, called by ppc_init in init/main.c.
  164. May be NULL. */
  165. void (*init)(void);
  166. void (*setup_io_mappings)(void);
  167. void (*early_serial_map)(void);
  168. void (*kgdb_map_scc)(void);
  169. /*
  170. * optional PCI "hooks"
  171. */
  172. /* Called after PPC generic resource fixup to perform
  173. machine specific fixups */
  174. void (*pcibios_fixup_resources)(struct pci_dev *);
  175. /* Called for each PCI bus in the system when it's probed */
  176. void (*pcibios_fixup_bus)(struct pci_bus *);
  177. /* Called when pci_enable_device() is called (initial=0) or
  178. * when a device with no assigned resource is found (initial=1).
  179. * Returns 0 to allow assignment/enabling of the device. */
  180. int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
  181. /* Called in indirect_* to avoid touching devices */
  182. int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
  183. /* Called at then very end of pcibios_init() */
  184. void (*pcibios_after_init)(void);
  185. #endif /* CONFIG_PPC32 */
  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. /* Called to do the minimal shutdown needed to run a kexec'd kernel
  192. * to run successfully.
  193. * XXX Should we move this one out of kexec scope?
  194. */
  195. void (*machine_crash_shutdown)(struct pt_regs *regs);
  196. /* Called to do what every setup is needed on image and the
  197. * reboot code buffer. Returns 0 on success.
  198. * Provide your own (maybe dummy) implementation if your platform
  199. * claims to support kexec.
  200. */
  201. int (*machine_kexec_prepare)(struct kimage *image);
  202. /* Called to handle any machine specific cleanup on image */
  203. void (*machine_kexec_cleanup)(struct kimage *image);
  204. /* Called to perform the _real_ kexec.
  205. * Do NOT allocate memory or fail here. We are past the point of
  206. * no return.
  207. */
  208. void (*machine_kexec)(struct kimage *image);
  209. #endif /* CONFIG_KEXEC */
  210. };
  211. extern void power4_idle(void);
  212. extern void power4_cpu_offline_powersave(void);
  213. extern void ppc6xx_idle(void);
  214. /*
  215. * ppc_md contains a copy of the machine description structure for the
  216. * current platform. machine_id contains the initial address where the
  217. * description was found during boot.
  218. */
  219. extern struct machdep_calls ppc_md;
  220. extern struct machdep_calls *machine_id;
  221. #define __machine_desc __attribute__ ((__section__ (".machine.desc")))
  222. #define define_machine(name) \
  223. extern struct machdep_calls mach_##name; \
  224. EXPORT_SYMBOL(mach_##name); \
  225. struct machdep_calls mach_##name __machine_desc =
  226. #define machine_is(name) \
  227. ({ \
  228. extern struct machdep_calls mach_##name \
  229. __attribute__((weak)); \
  230. machine_id == &mach_##name; \
  231. })
  232. extern void probe_machine(void);
  233. extern char cmd_line[COMMAND_LINE_SIZE];
  234. #ifdef CONFIG_PPC_PMAC
  235. /*
  236. * Power macintoshes have either a CUDA, PMU or SMU controlling
  237. * system reset, power, NVRAM, RTC.
  238. */
  239. typedef enum sys_ctrler_kind {
  240. SYS_CTRLER_UNKNOWN = 0,
  241. SYS_CTRLER_CUDA = 1,
  242. SYS_CTRLER_PMU = 2,
  243. SYS_CTRLER_SMU = 3,
  244. } sys_ctrler_t;
  245. extern sys_ctrler_t sys_ctrler;
  246. #endif /* CONFIG_PPC_PMAC */
  247. extern void setup_pci_ptrs(void);
  248. #ifdef CONFIG_SMP
  249. /* Poor default implementations */
  250. extern void __devinit smp_generic_give_timebase(void);
  251. extern void __devinit smp_generic_take_timebase(void);
  252. #endif /* CONFIG_SMP */
  253. /* Functions to produce codes on the leds.
  254. * The SRC code should be unique for the message category and should
  255. * be limited to the lower 24 bits (the upper 8 are set by these funcs),
  256. * and (for boot & dump) should be sorted numerically in the order
  257. * the events occur.
  258. */
  259. /* Print a boot progress message. */
  260. void ppc64_boot_msg(unsigned int src, const char *msg);
  261. /* Print a termination message (print only -- does not stop the kernel) */
  262. void ppc64_terminate_msg(unsigned int src, const char *msg);
  263. static inline void log_error(char *buf, unsigned int err_type, int fatal)
  264. {
  265. if (ppc_md.log_error)
  266. ppc_md.log_error(buf, err_type, fatal);
  267. }
  268. #endif /* __KERNEL__ */
  269. #endif /* _ASM_POWERPC_MACHDEP_H */