pmac_feature.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. /*
  2. * Definition of platform feature hooks for PowerMacs
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1998 Paul Mackerras &
  9. * Ben. Herrenschmidt.
  10. *
  11. *
  12. * Note: I removed media-bay details from the feature stuff, I believe it's
  13. * not worth it, the media-bay driver can directly use the mac-io
  14. * ASIC registers.
  15. *
  16. * Implementation note: Currently, none of these functions will block.
  17. * However, they may internally protect themselves with a spinlock
  18. * for way too long. Be prepared for at least some of these to block
  19. * in the future.
  20. *
  21. * Unless specifically defined, the result code is assumed to be an
  22. * error when negative, 0 is the default success result. Some functions
  23. * may return additional positive result values.
  24. *
  25. * To keep implementation simple, all feature calls are assumed to have
  26. * the prototype parameters (struct device_node* node, int value).
  27. * When either is not used, pass 0.
  28. */
  29. #ifdef __KERNEL__
  30. #ifndef __ASM_POWERPC_PMAC_FEATURE_H
  31. #define __ASM_POWERPC_PMAC_FEATURE_H
  32. #include <asm/macio.h>
  33. #include <asm/machdep.h>
  34. /*
  35. * Known Mac motherboard models
  36. *
  37. * Please, report any error here to benh@kernel.crashing.org, thanks !
  38. *
  39. * Note that I don't fully maintain this list for Core99 & MacRISC2
  40. * and I'm considering removing all NewWorld entries from it and
  41. * entirely rely on the model string.
  42. */
  43. /* PowerSurge are the first generation of PCI Pmacs. This include
  44. * all of the Grand-Central based machines. We currently don't
  45. * differentiate most of them.
  46. */
  47. #define PMAC_TYPE_PSURGE 0x10 /* PowerSurge */
  48. #define PMAC_TYPE_ANS 0x11 /* Apple Network Server */
  49. /* Here is the infamous serie of OHare based machines
  50. */
  51. #define PMAC_TYPE_COMET 0x20 /* Believed to be PowerBook 2400 */
  52. #define PMAC_TYPE_HOOPER 0x21 /* Believed to be PowerBook 3400 */
  53. #define PMAC_TYPE_KANGA 0x22 /* PowerBook 3500 (first G3) */
  54. #define PMAC_TYPE_ALCHEMY 0x23 /* Alchemy motherboard base */
  55. #define PMAC_TYPE_GAZELLE 0x24 /* Spartacus, some 5xxx/6xxx */
  56. #define PMAC_TYPE_UNKNOWN_OHARE 0x2f /* Unknown, but OHare based */
  57. /* Here are the Heathrow based machines
  58. * FIXME: Differenciate wallstreet,mainstreet,wallstreetII
  59. */
  60. #define PMAC_TYPE_GOSSAMER 0x30 /* Gossamer motherboard */
  61. #define PMAC_TYPE_SILK 0x31 /* Desktop PowerMac G3 */
  62. #define PMAC_TYPE_WALLSTREET 0x32 /* Wallstreet/Mainstreet PowerBook*/
  63. #define PMAC_TYPE_UNKNOWN_HEATHROW 0x3f /* Unknown but heathrow based */
  64. /* Here are newworld machines based on Paddington (heathrow derivative)
  65. */
  66. #define PMAC_TYPE_101_PBOOK 0x40 /* 101 PowerBook (aka Lombard) */
  67. #define PMAC_TYPE_ORIG_IMAC 0x41 /* First generation iMac */
  68. #define PMAC_TYPE_YOSEMITE 0x42 /* B&W G3 */
  69. #define PMAC_TYPE_YIKES 0x43 /* Yikes G4 (PCI graphics) */
  70. #define PMAC_TYPE_UNKNOWN_PADDINGTON 0x4f /* Unknown but paddington based */
  71. /* Core99 machines based on UniNorth 1.0 and 1.5
  72. *
  73. * Note: A single entry here may cover several actual models according
  74. * to the device-tree. (Sawtooth is most tower G4s, FW_IMAC is most
  75. * FireWire based iMacs, etc...). Those machines are too similar to be
  76. * distinguished here, when they need to be differencied, use the
  77. * device-tree "model" or "compatible" property.
  78. */
  79. #define PMAC_TYPE_ORIG_IBOOK 0x40 /* First iBook model (no firewire) */
  80. #define PMAC_TYPE_SAWTOOTH 0x41 /* Desktop G4s */
  81. #define PMAC_TYPE_FW_IMAC 0x42 /* FireWire iMacs (except Pangea based) */
  82. #define PMAC_TYPE_FW_IBOOK 0x43 /* FireWire iBooks (except iBook2) */
  83. #define PMAC_TYPE_CUBE 0x44 /* Cube PowerMac */
  84. #define PMAC_TYPE_QUICKSILVER 0x45 /* QuickSilver G4s */
  85. #define PMAC_TYPE_PISMO 0x46 /* Pismo PowerBook */
  86. #define PMAC_TYPE_TITANIUM 0x47 /* Titanium PowerBook */
  87. #define PMAC_TYPE_TITANIUM2 0x48 /* Titanium II PowerBook (no L3, M6) */
  88. #define PMAC_TYPE_TITANIUM3 0x49 /* Titanium III PowerBook (with L3 & M7) */
  89. #define PMAC_TYPE_TITANIUM4 0x50 /* Titanium IV PowerBook (with L3 & M9) */
  90. #define PMAC_TYPE_EMAC 0x50 /* eMac */
  91. #define PMAC_TYPE_UNKNOWN_CORE99 0x5f
  92. /* MacRisc2 with UniNorth 2.0 */
  93. #define PMAC_TYPE_RACKMAC 0x80 /* XServe */
  94. #define PMAC_TYPE_WINDTUNNEL 0x81
  95. /* MacRISC2 machines based on the Pangea chipset
  96. */
  97. #define PMAC_TYPE_PANGEA_IMAC 0x100 /* Flower Power iMac */
  98. #define PMAC_TYPE_IBOOK2 0x101 /* iBook2 (polycarbonate) */
  99. #define PMAC_TYPE_FLAT_PANEL_IMAC 0x102 /* Flat panel iMac */
  100. #define PMAC_TYPE_UNKNOWN_PANGEA 0x10f
  101. /* MacRISC2 machines based on the Intrepid chipset
  102. */
  103. #define PMAC_TYPE_UNKNOWN_INTREPID 0x11f /* Generic */
  104. /* MacRISC4 / G5 machines. We don't have per-machine selection here anymore,
  105. * but rather machine families
  106. */
  107. #define PMAC_TYPE_POWERMAC_G5 0x150 /* U3 & U3H based */
  108. #define PMAC_TYPE_POWERMAC_G5_U3L 0x151 /* U3L based desktop */
  109. #define PMAC_TYPE_IMAC_G5 0x152 /* iMac G5 */
  110. #define PMAC_TYPE_XSERVE_G5 0x153 /* Xserve G5 */
  111. #define PMAC_TYPE_UNKNOWN_K2 0x19f /* Any other K2 based */
  112. #define PMAC_TYPE_UNKNOWN_SHASTA 0x19e /* Any other Shasta based */
  113. /*
  114. * Motherboard flags
  115. */
  116. #define PMAC_MB_CAN_SLEEP 0x00000001
  117. #define PMAC_MB_HAS_FW_POWER 0x00000002
  118. #define PMAC_MB_OLD_CORE99 0x00000004
  119. #define PMAC_MB_MOBILE 0x00000008
  120. #define PMAC_MB_MAY_SLEEP 0x00000010
  121. /*
  122. * Feature calls supported on pmac
  123. *
  124. */
  125. /*
  126. * Use this inline wrapper
  127. */
  128. struct device_node;
  129. static inline long pmac_call_feature(int selector, struct device_node* node,
  130. long param, long value)
  131. {
  132. if (!ppc_md.feature_call || !machine_is(powermac))
  133. return -ENODEV;
  134. return ppc_md.feature_call(selector, node, param, value);
  135. }
  136. /* PMAC_FTR_SERIAL_ENABLE (struct device_node* node, int param, int value)
  137. * enable/disable an SCC side. Pass the node corresponding to the
  138. * channel side as a parameter.
  139. * param is the type of port
  140. * if param is ored with PMAC_SCC_FLAG_XMON, then the SCC is locked enabled
  141. * for use by xmon.
  142. */
  143. #define PMAC_FTR_SCC_ENABLE PMAC_FTR_DEF(0)
  144. #define PMAC_SCC_ASYNC 0
  145. #define PMAC_SCC_IRDA 1
  146. #define PMAC_SCC_I2S1 2
  147. #define PMAC_SCC_FLAG_XMON 0x00001000
  148. /* PMAC_FTR_MODEM_ENABLE (struct device_node* node, 0, int value)
  149. * enable/disable the internal modem.
  150. */
  151. #define PMAC_FTR_MODEM_ENABLE PMAC_FTR_DEF(1)
  152. /* PMAC_FTR_SWIM3_ENABLE (struct device_node* node, 0,int value)
  153. * enable/disable the swim3 (floppy) cell of a mac-io ASIC
  154. */
  155. #define PMAC_FTR_SWIM3_ENABLE PMAC_FTR_DEF(2)
  156. /* PMAC_FTR_MESH_ENABLE (struct device_node* node, 0, int value)
  157. * enable/disable the mesh (scsi) cell of a mac-io ASIC
  158. */
  159. #define PMAC_FTR_MESH_ENABLE PMAC_FTR_DEF(3)
  160. /* PMAC_FTR_IDE_ENABLE (struct device_node* node, int busID, int value)
  161. * enable/disable an IDE port of a mac-io ASIC
  162. * pass the busID parameter
  163. */
  164. #define PMAC_FTR_IDE_ENABLE PMAC_FTR_DEF(4)
  165. /* PMAC_FTR_IDE_RESET (struct device_node* node, int busID, int value)
  166. * assert(1)/release(0) an IDE reset line (mac-io IDE only)
  167. */
  168. #define PMAC_FTR_IDE_RESET PMAC_FTR_DEF(5)
  169. /* PMAC_FTR_BMAC_ENABLE (struct device_node* node, 0, int value)
  170. * enable/disable the bmac (ethernet) cell of a mac-io ASIC, also drive
  171. * it's reset line
  172. */
  173. #define PMAC_FTR_BMAC_ENABLE PMAC_FTR_DEF(6)
  174. /* PMAC_FTR_GMAC_ENABLE (struct device_node* node, 0, int value)
  175. * enable/disable the gmac (ethernet) cell of an uninorth ASIC. This
  176. * control the cell's clock.
  177. */
  178. #define PMAC_FTR_GMAC_ENABLE PMAC_FTR_DEF(7)
  179. /* PMAC_FTR_GMAC_PHY_RESET (struct device_node* node, 0, 0)
  180. * Perform a HW reset of the PHY connected to a gmac controller.
  181. * Pass the gmac device node, not the PHY node.
  182. */
  183. #define PMAC_FTR_GMAC_PHY_RESET PMAC_FTR_DEF(8)
  184. /* PMAC_FTR_SOUND_CHIP_ENABLE (struct device_node* node, 0, int value)
  185. * enable/disable the sound chip, whatever it is and provided it can
  186. * actually be controlled
  187. */
  188. #define PMAC_FTR_SOUND_CHIP_ENABLE PMAC_FTR_DEF(9)
  189. /* -- add various tweaks related to sound routing -- */
  190. /* PMAC_FTR_AIRPORT_ENABLE (struct device_node* node, 0, int value)
  191. * enable/disable the airport card
  192. */
  193. #define PMAC_FTR_AIRPORT_ENABLE PMAC_FTR_DEF(10)
  194. /* PMAC_FTR_RESET_CPU (NULL, int cpu_nr, 0)
  195. * toggle the reset line of a CPU on an uninorth-based SMP machine
  196. */
  197. #define PMAC_FTR_RESET_CPU PMAC_FTR_DEF(11)
  198. /* PMAC_FTR_USB_ENABLE (struct device_node* node, 0, int value)
  199. * enable/disable an USB cell, along with the power of the USB "pad"
  200. * on keylargo based machines
  201. */
  202. #define PMAC_FTR_USB_ENABLE PMAC_FTR_DEF(12)
  203. /* PMAC_FTR_1394_ENABLE (struct device_node* node, 0, int value)
  204. * enable/disable the firewire cell of an uninorth ASIC.
  205. */
  206. #define PMAC_FTR_1394_ENABLE PMAC_FTR_DEF(13)
  207. /* PMAC_FTR_1394_CABLE_POWER (struct device_node* node, 0, int value)
  208. * enable/disable the firewire cable power supply of the uninorth
  209. * firewire cell
  210. */
  211. #define PMAC_FTR_1394_CABLE_POWER PMAC_FTR_DEF(14)
  212. /* PMAC_FTR_SLEEP_STATE (struct device_node* node, 0, int value)
  213. * set the sleep state of the motherboard.
  214. *
  215. * Pass -1 as value to query for sleep capability
  216. * Pass 1 to set IOs to sleep
  217. * Pass 0 to set IOs to wake
  218. */
  219. #define PMAC_FTR_SLEEP_STATE PMAC_FTR_DEF(15)
  220. /* PMAC_FTR_GET_MB_INFO (NULL, selector, 0)
  221. *
  222. * returns some motherboard infos.
  223. * selector: 0 - model id
  224. * 1 - model flags (capabilities)
  225. * 2 - model name (cast to const char *)
  226. */
  227. #define PMAC_FTR_GET_MB_INFO PMAC_FTR_DEF(16)
  228. #define PMAC_MB_INFO_MODEL 0
  229. #define PMAC_MB_INFO_FLAGS 1
  230. #define PMAC_MB_INFO_NAME 2
  231. /* PMAC_FTR_READ_GPIO (NULL, int index, 0)
  232. *
  233. * read a GPIO from a mac-io controller of type KeyLargo or Pangea.
  234. * the value returned is a byte (positive), or a negative error code
  235. */
  236. #define PMAC_FTR_READ_GPIO PMAC_FTR_DEF(17)
  237. /* PMAC_FTR_WRITE_GPIO (NULL, int index, int value)
  238. *
  239. * write a GPIO of a mac-io controller of type KeyLargo or Pangea.
  240. */
  241. #define PMAC_FTR_WRITE_GPIO PMAC_FTR_DEF(18)
  242. /* PMAC_FTR_ENABLE_MPIC
  243. *
  244. * Enable the MPIC cell
  245. */
  246. #define PMAC_FTR_ENABLE_MPIC PMAC_FTR_DEF(19)
  247. /* PMAC_FTR_AACK_DELAY_ENABLE (NULL, int enable, 0)
  248. *
  249. * Enable/disable the AACK delay on the northbridge for systems using DFS
  250. */
  251. #define PMAC_FTR_AACK_DELAY_ENABLE PMAC_FTR_DEF(20)
  252. /* PMAC_FTR_DEVICE_CAN_WAKE
  253. *
  254. * Used by video drivers to inform system that they can actually perform
  255. * wakeup from sleep
  256. */
  257. #define PMAC_FTR_DEVICE_CAN_WAKE PMAC_FTR_DEF(22)
  258. /* Don't use those directly, they are for the sake of pmac_setup.c */
  259. extern long pmac_do_feature_call(unsigned int selector, ...);
  260. extern void pmac_feature_init(void);
  261. /* Video suspend tweak */
  262. extern void pmac_set_early_video_resume(void (*proc)(void *data), void *data);
  263. extern void pmac_call_early_video_resume(void);
  264. #define PMAC_FTR_DEF(x) ((0x6660000) | (x))
  265. /* The AGP driver registers itself here */
  266. extern void pmac_register_agp_pm(struct pci_dev *bridge,
  267. int (*suspend)(struct pci_dev *bridge),
  268. int (*resume)(struct pci_dev *bridge));
  269. /* Those are meant to be used by video drivers to deal with AGP
  270. * suspend resume properly
  271. */
  272. extern void pmac_suspend_agp_for_card(struct pci_dev *dev);
  273. extern void pmac_resume_agp_for_card(struct pci_dev *dev);
  274. /*
  275. * The part below is for use by macio_asic.c only, do not rely
  276. * on the data structures or constants below in a normal driver
  277. *
  278. */
  279. #define MAX_MACIO_CHIPS 2
  280. enum {
  281. macio_unknown = 0,
  282. macio_grand_central,
  283. macio_ohare,
  284. macio_ohareII,
  285. macio_heathrow,
  286. macio_gatwick,
  287. macio_paddington,
  288. macio_keylargo,
  289. macio_pangea,
  290. macio_intrepid,
  291. macio_keylargo2,
  292. macio_shasta,
  293. };
  294. struct macio_chip
  295. {
  296. struct device_node *of_node;
  297. int type;
  298. const char *name;
  299. int rev;
  300. volatile u32 __iomem *base;
  301. unsigned long flags;
  302. /* For use by macio_asic PCI driver */
  303. struct macio_bus lbus;
  304. };
  305. extern struct macio_chip macio_chips[MAX_MACIO_CHIPS];
  306. #define MACIO_FLAG_SCCA_ON 0x00000001
  307. #define MACIO_FLAG_SCCB_ON 0x00000002
  308. #define MACIO_FLAG_SCC_LOCKED 0x00000004
  309. #define MACIO_FLAG_AIRPORT_ON 0x00000010
  310. #define MACIO_FLAG_FW_SUPPORTED 0x00000020
  311. extern struct macio_chip* macio_find(struct device_node* child, int type);
  312. #define MACIO_FCR32(macio, r) ((macio)->base + ((r) >> 2))
  313. #define MACIO_FCR8(macio, r) (((volatile u8 __iomem *)((macio)->base)) + (r))
  314. #define MACIO_IN32(r) (in_le32(MACIO_FCR32(macio,r)))
  315. #define MACIO_OUT32(r,v) (out_le32(MACIO_FCR32(macio,r), (v)))
  316. #define MACIO_BIS(r,v) (MACIO_OUT32((r), MACIO_IN32(r) | (v)))
  317. #define MACIO_BIC(r,v) (MACIO_OUT32((r), MACIO_IN32(r) & ~(v)))
  318. #define MACIO_IN8(r) (in_8(MACIO_FCR8(macio,r)))
  319. #define MACIO_OUT8(r,v) (out_8(MACIO_FCR8(macio,r), (v)))
  320. /*
  321. * Those are exported by pmac feature for internal use by arch code
  322. * only like the platform function callbacks, do not use directly in drivers
  323. */
  324. extern raw_spinlock_t feature_lock;
  325. extern struct device_node *uninorth_node;
  326. extern u32 __iomem *uninorth_base;
  327. /*
  328. * Uninorth reg. access. Note that Uni-N regs are big endian
  329. */
  330. #define UN_REG(r) (uninorth_base + ((r) >> 2))
  331. #define UN_IN(r) (in_be32(UN_REG(r)))
  332. #define UN_OUT(r,v) (out_be32(UN_REG(r), (v)))
  333. #define UN_BIS(r,v) (UN_OUT((r), UN_IN(r) | (v)))
  334. #define UN_BIC(r,v) (UN_OUT((r), UN_IN(r) & ~(v)))
  335. /* Uninorth variant:
  336. *
  337. * 0 = not uninorth
  338. * 1 = U1.x or U2.x
  339. * 3 = U3
  340. * 4 = U4
  341. */
  342. extern int pmac_get_uninorth_variant(void);
  343. #endif /* __ASM_POWERPC_PMAC_FEATURE_H */
  344. #endif /* __KERNEL__ */