machdep.h 8.5 KB

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