machdep.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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/config.h>
  11. #include <linux/seq_file.h>
  12. #include <linux/init.h>
  13. #include <linux/dma-mapping.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. #ifdef CONFIG_SMP
  26. struct smp_ops_t {
  27. void (*message_pass)(int target, int msg);
  28. int (*probe)(void);
  29. void (*kick_cpu)(int nr);
  30. void (*setup_cpu)(int nr);
  31. void (*take_timebase)(void);
  32. void (*give_timebase)(void);
  33. int (*cpu_enable)(unsigned int nr);
  34. int (*cpu_disable)(void);
  35. void (*cpu_die)(unsigned int nr);
  36. int (*cpu_bootable)(unsigned int nr);
  37. };
  38. #endif
  39. struct machdep_calls {
  40. #ifdef CONFIG_PPC64
  41. void (*hpte_invalidate)(unsigned long slot,
  42. unsigned long va,
  43. int psize,
  44. int local);
  45. long (*hpte_updatepp)(unsigned long slot,
  46. unsigned long newpp,
  47. unsigned long va,
  48. int pize,
  49. int local);
  50. void (*hpte_updateboltedpp)(unsigned long newpp,
  51. unsigned long ea,
  52. int psize);
  53. long (*hpte_insert)(unsigned long hpte_group,
  54. unsigned long va,
  55. unsigned long prpn,
  56. unsigned long rflags,
  57. unsigned long vflags,
  58. int psize);
  59. long (*hpte_remove)(unsigned long hpte_group);
  60. void (*flush_hash_range)(unsigned long number, int local);
  61. /* special for kexec, to be called in real mode, linar mapping is
  62. * destroyed as well */
  63. void (*hpte_clear_all)(void);
  64. void (*tce_build)(struct iommu_table * tbl,
  65. long index,
  66. long npages,
  67. unsigned long uaddr,
  68. enum dma_data_direction direction);
  69. void (*tce_free)(struct iommu_table *tbl,
  70. long index,
  71. long npages);
  72. void (*tce_flush)(struct iommu_table *tbl);
  73. void (*iommu_dev_setup)(struct pci_dev *dev);
  74. void (*iommu_bus_setup)(struct pci_bus *bus);
  75. void (*irq_bus_setup)(struct pci_bus *bus);
  76. #endif
  77. int (*probe)(int platform);
  78. void (*setup_arch)(void);
  79. void (*init_early)(void);
  80. /* Optional, may be NULL. */
  81. void (*show_cpuinfo)(struct seq_file *m);
  82. void (*show_percpuinfo)(struct seq_file *m, int i);
  83. void (*init_IRQ)(void);
  84. int (*get_irq)(struct pt_regs *);
  85. #ifdef CONFIG_KEXEC
  86. void (*kexec_cpu_down)(int crash_shutdown, int secondary);
  87. #endif
  88. /* PCI stuff */
  89. /* Called after scanning the bus, before allocating resources */
  90. void (*pcibios_fixup)(void);
  91. int (*pci_probe_mode)(struct pci_bus *);
  92. void (*restart)(char *cmd);
  93. void (*power_off)(void);
  94. void (*halt)(void);
  95. void (*panic)(char *str);
  96. void (*cpu_die)(void);
  97. long (*time_init)(void); /* Optional, may be NULL */
  98. int (*set_rtc_time)(struct rtc_time *);
  99. void (*get_rtc_time)(struct rtc_time *);
  100. unsigned long (*get_boot_time)(void);
  101. unsigned char (*rtc_read_val)(int addr);
  102. void (*rtc_write_val)(int addr, unsigned char val);
  103. void (*calibrate_decr)(void);
  104. void (*progress)(char *, unsigned short);
  105. /* Interface for platform error logging */
  106. void (*log_error)(char *buf, unsigned int err_type, int fatal);
  107. unsigned char (*nvram_read_val)(int addr);
  108. void (*nvram_write_val)(int addr, unsigned char val);
  109. ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index);
  110. ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index);
  111. ssize_t (*nvram_size)(void);
  112. void (*nvram_sync)(void);
  113. /* Exception handlers */
  114. void (*system_reset_exception)(struct pt_regs *regs);
  115. int (*machine_check_exception)(struct pt_regs *regs);
  116. /* Motherboard/chipset features. This is a kind of general purpose
  117. * hook used to control some machine specific features (like reset
  118. * lines, chip power control, etc...).
  119. */
  120. long (*feature_call)(unsigned int feature, ...);
  121. /* Check availability of legacy devices like i8042 */
  122. int (*check_legacy_ioport)(unsigned int baseport);
  123. /* Get legacy PCI/IDE interrupt mapping */
  124. int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
  125. /* Get access protection for /dev/mem */
  126. pgprot_t (*phys_mem_access_prot)(struct file *file,
  127. unsigned long pfn,
  128. unsigned long size,
  129. pgprot_t vma_prot);
  130. /* Idle loop for this platform, leave empty for default idle loop */
  131. void (*idle_loop)(void);
  132. /* Function to enable performance monitor counters for this
  133. platform, called once per cpu. */
  134. void (*enable_pmcs)(void);
  135. /* Set DABR for this platform, leave empty for default implemenation */
  136. int (*set_dabr)(unsigned long dabr);
  137. #ifdef CONFIG_PPC32 /* XXX for now */
  138. /* A general init function, called by ppc_init in init/main.c.
  139. May be NULL. */
  140. void (*init)(void);
  141. void (*idle)(void);
  142. void (*power_save)(void);
  143. void (*heartbeat)(void);
  144. unsigned long heartbeat_reset;
  145. unsigned long heartbeat_count;
  146. void (*setup_io_mappings)(void);
  147. void (*early_serial_map)(void);
  148. void (*kgdb_map_scc)(void);
  149. /*
  150. * optional PCI "hooks"
  151. */
  152. /* Called after PPC generic resource fixup to perform
  153. machine specific fixups */
  154. void (*pcibios_fixup_resources)(struct pci_dev *);
  155. /* Called for each PCI bus in the system when it's probed */
  156. void (*pcibios_fixup_bus)(struct pci_bus *);
  157. /* Called when pci_enable_device() is called (initial=0) or
  158. * when a device with no assigned resource is found (initial=1).
  159. * Returns 0 to allow assignment/enabling of the device. */
  160. int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
  161. /* For interrupt routing */
  162. unsigned char (*pci_swizzle)(struct pci_dev *, unsigned char *);
  163. int (*pci_map_irq)(struct pci_dev *, unsigned char, unsigned char);
  164. /* Called in indirect_* to avoid touching devices */
  165. int (*pci_exclude_device)(unsigned char, unsigned char);
  166. /* Called at then very end of pcibios_init() */
  167. void (*pcibios_after_init)(void);
  168. /* this is for modules, since _machine can be a define -- Cort */
  169. int ppc_machine;
  170. #ifdef CONFIG_KEXEC
  171. /* Called to shutdown machine specific hardware not already controlled
  172. * by other drivers.
  173. * XXX Should we move this one out of kexec scope?
  174. */
  175. void (*machine_shutdown)(void);
  176. /* Called to do the minimal shutdown needed to run a kexec'd kernel
  177. * to run successfully.
  178. * XXX Should we move this one out of kexec scope?
  179. */
  180. void (*machine_crash_shutdown)(void);
  181. /* Called to do what every setup is needed on image and the
  182. * reboot code buffer. Returns 0 on success.
  183. * Provide your own (maybe dummy) implementation if your platform
  184. * claims to support kexec.
  185. */
  186. int (*machine_kexec_prepare)(struct kimage *image);
  187. /* Called to handle any machine specific cleanup on image */
  188. void (*machine_kexec_cleanup)(struct kimage *image);
  189. /* Called to perform the _real_ kexec.
  190. * Do NOT allocate memory or fail here. We are past the point of
  191. * no return.
  192. */
  193. void (*machine_kexec)(struct kimage *image);
  194. #endif /* CONFIG_KEXEC */
  195. #endif /* CONFIG_PPC32 */
  196. };
  197. extern void default_idle(void);
  198. extern void native_idle(void);
  199. extern struct machdep_calls ppc_md;
  200. extern char cmd_line[COMMAND_LINE_SIZE];
  201. #ifdef CONFIG_PPC_PMAC
  202. /*
  203. * Power macintoshes have either a CUDA, PMU or SMU controlling
  204. * system reset, power, NVRAM, RTC.
  205. */
  206. typedef enum sys_ctrler_kind {
  207. SYS_CTRLER_UNKNOWN = 0,
  208. SYS_CTRLER_CUDA = 1,
  209. SYS_CTRLER_PMU = 2,
  210. SYS_CTRLER_SMU = 3,
  211. } sys_ctrler_t;
  212. extern sys_ctrler_t sys_ctrler;
  213. #endif /* CONFIG_PPC_PMAC */
  214. extern void setup_pci_ptrs(void);
  215. #ifdef CONFIG_SMP
  216. /* Poor default implementations */
  217. extern void __devinit smp_generic_give_timebase(void);
  218. extern void __devinit smp_generic_take_timebase(void);
  219. #endif /* CONFIG_SMP */
  220. /* Functions to produce codes on the leds.
  221. * The SRC code should be unique for the message category and should
  222. * be limited to the lower 24 bits (the upper 8 are set by these funcs),
  223. * and (for boot & dump) should be sorted numerically in the order
  224. * the events occur.
  225. */
  226. /* Print a boot progress message. */
  227. void ppc64_boot_msg(unsigned int src, const char *msg);
  228. /* Print a termination message (print only -- does not stop the kernel) */
  229. void ppc64_terminate_msg(unsigned int src, const char *msg);
  230. static inline void log_error(char *buf, unsigned int err_type, int fatal)
  231. {
  232. if (ppc_md.log_error)
  233. ppc_md.log_error(buf, err_type, fatal);
  234. }
  235. #endif /* __KERNEL__ */
  236. #endif /* _ASM_POWERPC_MACHDEP_H */