mpc52xx.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*
  2. * Prototypes, etc. for the Freescale MPC52xx embedded cpu chips
  3. * May need to be cleaned as the port goes on ...
  4. *
  5. * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com>
  6. * Copyright (C) 2003 MontaVista, Software, Inc.
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of any
  10. * kind, whether express or implied.
  11. */
  12. #ifndef __ASM_POWERPC_MPC52xx_H__
  13. #define __ASM_POWERPC_MPC52xx_H__
  14. #ifndef __ASSEMBLY__
  15. #include <asm/types.h>
  16. #include <asm/prom.h>
  17. #include <asm/mpc5xxx.h>
  18. #endif /* __ASSEMBLY__ */
  19. #include <linux/suspend.h>
  20. /* Variants of the 5200(B) */
  21. #define MPC5200_SVR 0x80110010
  22. #define MPC5200_SVR_MASK 0xfffffff0
  23. #define MPC5200B_SVR 0x80110020
  24. #define MPC5200B_SVR_MASK 0xfffffff0
  25. /* ======================================================================== */
  26. /* Structures mapping of some unit register set */
  27. /* ======================================================================== */
  28. #ifndef __ASSEMBLY__
  29. /* Memory Mapping Control */
  30. struct mpc52xx_mmap_ctl {
  31. u32 mbar; /* MMAP_CTRL + 0x00 */
  32. u32 cs0_start; /* MMAP_CTRL + 0x04 */
  33. u32 cs0_stop; /* MMAP_CTRL + 0x08 */
  34. u32 cs1_start; /* MMAP_CTRL + 0x0c */
  35. u32 cs1_stop; /* MMAP_CTRL + 0x10 */
  36. u32 cs2_start; /* MMAP_CTRL + 0x14 */
  37. u32 cs2_stop; /* MMAP_CTRL + 0x18 */
  38. u32 cs3_start; /* MMAP_CTRL + 0x1c */
  39. u32 cs3_stop; /* MMAP_CTRL + 0x20 */
  40. u32 cs4_start; /* MMAP_CTRL + 0x24 */
  41. u32 cs4_stop; /* MMAP_CTRL + 0x28 */
  42. u32 cs5_start; /* MMAP_CTRL + 0x2c */
  43. u32 cs5_stop; /* MMAP_CTRL + 0x30 */
  44. u32 sdram0; /* MMAP_CTRL + 0x34 */
  45. u32 sdram1; /* MMAP_CTRL + 0X38 */
  46. u32 reserved[4]; /* MMAP_CTRL + 0x3c .. 0x48 */
  47. u32 boot_start; /* MMAP_CTRL + 0x4c */
  48. u32 boot_stop; /* MMAP_CTRL + 0x50 */
  49. u32 ipbi_ws_ctrl; /* MMAP_CTRL + 0x54 */
  50. u32 cs6_start; /* MMAP_CTRL + 0x58 */
  51. u32 cs6_stop; /* MMAP_CTRL + 0x5c */
  52. u32 cs7_start; /* MMAP_CTRL + 0x60 */
  53. u32 cs7_stop; /* MMAP_CTRL + 0x64 */
  54. };
  55. /* SDRAM control */
  56. struct mpc52xx_sdram {
  57. u32 mode; /* SDRAM + 0x00 */
  58. u32 ctrl; /* SDRAM + 0x04 */
  59. u32 config1; /* SDRAM + 0x08 */
  60. u32 config2; /* SDRAM + 0x0c */
  61. };
  62. /* SDMA */
  63. struct mpc52xx_sdma {
  64. u32 taskBar; /* SDMA + 0x00 */
  65. u32 currentPointer; /* SDMA + 0x04 */
  66. u32 endPointer; /* SDMA + 0x08 */
  67. u32 variablePointer; /* SDMA + 0x0c */
  68. u8 IntVect1; /* SDMA + 0x10 */
  69. u8 IntVect2; /* SDMA + 0x11 */
  70. u16 PtdCntrl; /* SDMA + 0x12 */
  71. u32 IntPend; /* SDMA + 0x14 */
  72. u32 IntMask; /* SDMA + 0x18 */
  73. u16 tcr[16]; /* SDMA + 0x1c .. 0x3a */
  74. u8 ipr[32]; /* SDMA + 0x3c .. 0x5b */
  75. u32 cReqSelect; /* SDMA + 0x5c */
  76. u32 task_size0; /* SDMA + 0x60 */
  77. u32 task_size1; /* SDMA + 0x64 */
  78. u32 MDEDebug; /* SDMA + 0x68 */
  79. u32 ADSDebug; /* SDMA + 0x6c */
  80. u32 Value1; /* SDMA + 0x70 */
  81. u32 Value2; /* SDMA + 0x74 */
  82. u32 Control; /* SDMA + 0x78 */
  83. u32 Status; /* SDMA + 0x7c */
  84. u32 PTDDebug; /* SDMA + 0x80 */
  85. };
  86. /* GPT */
  87. struct mpc52xx_gpt {
  88. u32 mode; /* GPTx + 0x00 */
  89. u32 count; /* GPTx + 0x04 */
  90. u32 pwm; /* GPTx + 0x08 */
  91. u32 status; /* GPTx + 0X0c */
  92. };
  93. /* GPIO */
  94. struct mpc52xx_gpio {
  95. u32 port_config; /* GPIO + 0x00 */
  96. u32 simple_gpioe; /* GPIO + 0x04 */
  97. u32 simple_ode; /* GPIO + 0x08 */
  98. u32 simple_ddr; /* GPIO + 0x0c */
  99. u32 simple_dvo; /* GPIO + 0x10 */
  100. u32 simple_ival; /* GPIO + 0x14 */
  101. u8 outo_gpioe; /* GPIO + 0x18 */
  102. u8 reserved1[3]; /* GPIO + 0x19 */
  103. u8 outo_dvo; /* GPIO + 0x1c */
  104. u8 reserved2[3]; /* GPIO + 0x1d */
  105. u8 sint_gpioe; /* GPIO + 0x20 */
  106. u8 reserved3[3]; /* GPIO + 0x21 */
  107. u8 sint_ode; /* GPIO + 0x24 */
  108. u8 reserved4[3]; /* GPIO + 0x25 */
  109. u8 sint_ddr; /* GPIO + 0x28 */
  110. u8 reserved5[3]; /* GPIO + 0x29 */
  111. u8 sint_dvo; /* GPIO + 0x2c */
  112. u8 reserved6[3]; /* GPIO + 0x2d */
  113. u8 sint_inten; /* GPIO + 0x30 */
  114. u8 reserved7[3]; /* GPIO + 0x31 */
  115. u16 sint_itype; /* GPIO + 0x34 */
  116. u16 reserved8; /* GPIO + 0x36 */
  117. u8 gpio_control; /* GPIO + 0x38 */
  118. u8 reserved9[3]; /* GPIO + 0x39 */
  119. u8 sint_istat; /* GPIO + 0x3c */
  120. u8 sint_ival; /* GPIO + 0x3d */
  121. u8 bus_errs; /* GPIO + 0x3e */
  122. u8 reserved10; /* GPIO + 0x3f */
  123. };
  124. #define MPC52xx_GPIO_PSC_CONFIG_UART_WITHOUT_CD 4
  125. #define MPC52xx_GPIO_PSC_CONFIG_UART_WITH_CD 5
  126. #define MPC52xx_GPIO_PCI_DIS (1<<15)
  127. /* GPIO with WakeUp*/
  128. struct mpc52xx_gpio_wkup {
  129. u8 wkup_gpioe; /* GPIO_WKUP + 0x00 */
  130. u8 reserved1[3]; /* GPIO_WKUP + 0x03 */
  131. u8 wkup_ode; /* GPIO_WKUP + 0x04 */
  132. u8 reserved2[3]; /* GPIO_WKUP + 0x05 */
  133. u8 wkup_ddr; /* GPIO_WKUP + 0x08 */
  134. u8 reserved3[3]; /* GPIO_WKUP + 0x09 */
  135. u8 wkup_dvo; /* GPIO_WKUP + 0x0C */
  136. u8 reserved4[3]; /* GPIO_WKUP + 0x0D */
  137. u8 wkup_inten; /* GPIO_WKUP + 0x10 */
  138. u8 reserved5[3]; /* GPIO_WKUP + 0x11 */
  139. u8 wkup_iinten; /* GPIO_WKUP + 0x14 */
  140. u8 reserved6[3]; /* GPIO_WKUP + 0x15 */
  141. u16 wkup_itype; /* GPIO_WKUP + 0x18 */
  142. u8 reserved7[2]; /* GPIO_WKUP + 0x1A */
  143. u8 wkup_maste; /* GPIO_WKUP + 0x1C */
  144. u8 reserved8[3]; /* GPIO_WKUP + 0x1D */
  145. u8 wkup_ival; /* GPIO_WKUP + 0x20 */
  146. u8 reserved9[3]; /* GPIO_WKUP + 0x21 */
  147. u8 wkup_istat; /* GPIO_WKUP + 0x24 */
  148. u8 reserved10[3]; /* GPIO_WKUP + 0x25 */
  149. };
  150. /* XLB Bus control */
  151. struct mpc52xx_xlb {
  152. u8 reserved[0x40];
  153. u32 config; /* XLB + 0x40 */
  154. u32 version; /* XLB + 0x44 */
  155. u32 status; /* XLB + 0x48 */
  156. u32 int_enable; /* XLB + 0x4c */
  157. u32 addr_capture; /* XLB + 0x50 */
  158. u32 bus_sig_capture; /* XLB + 0x54 */
  159. u32 addr_timeout; /* XLB + 0x58 */
  160. u32 data_timeout; /* XLB + 0x5c */
  161. u32 bus_act_timeout; /* XLB + 0x60 */
  162. u32 master_pri_enable; /* XLB + 0x64 */
  163. u32 master_priority; /* XLB + 0x68 */
  164. u32 base_address; /* XLB + 0x6c */
  165. u32 snoop_window; /* XLB + 0x70 */
  166. };
  167. #define MPC52xx_XLB_CFG_PLDIS (1 << 31)
  168. #define MPC52xx_XLB_CFG_SNOOP (1 << 15)
  169. /* Clock Distribution control */
  170. struct mpc52xx_cdm {
  171. u32 jtag_id; /* CDM + 0x00 reg0 read only */
  172. u32 rstcfg; /* CDM + 0x04 reg1 read only */
  173. u32 breadcrumb; /* CDM + 0x08 reg2 */
  174. u8 mem_clk_sel; /* CDM + 0x0c reg3 byte0 */
  175. u8 xlb_clk_sel; /* CDM + 0x0d reg3 byte1 read only */
  176. u8 ipb_clk_sel; /* CDM + 0x0e reg3 byte2 */
  177. u8 pci_clk_sel; /* CDM + 0x0f reg3 byte3 */
  178. u8 ext_48mhz_en; /* CDM + 0x10 reg4 byte0 */
  179. u8 fd_enable; /* CDM + 0x11 reg4 byte1 */
  180. u16 fd_counters; /* CDM + 0x12 reg4 byte2,3 */
  181. u32 clk_enables; /* CDM + 0x14 reg5 */
  182. u8 osc_disable; /* CDM + 0x18 reg6 byte0 */
  183. u8 reserved0[3]; /* CDM + 0x19 reg6 byte1,2,3 */
  184. u8 ccs_sleep_enable; /* CDM + 0x1c reg7 byte0 */
  185. u8 osc_sleep_enable; /* CDM + 0x1d reg7 byte1 */
  186. u8 reserved1; /* CDM + 0x1e reg7 byte2 */
  187. u8 ccs_qreq_test; /* CDM + 0x1f reg7 byte3 */
  188. u8 soft_reset; /* CDM + 0x20 u8 byte0 */
  189. u8 no_ckstp; /* CDM + 0x21 u8 byte0 */
  190. u8 reserved2[2]; /* CDM + 0x22 u8 byte1,2,3 */
  191. u8 pll_lock; /* CDM + 0x24 reg9 byte0 */
  192. u8 pll_looselock; /* CDM + 0x25 reg9 byte1 */
  193. u8 pll_sm_lockwin; /* CDM + 0x26 reg9 byte2 */
  194. u8 reserved3; /* CDM + 0x27 reg9 byte3 */
  195. u16 reserved4; /* CDM + 0x28 reg10 byte0,1 */
  196. u16 mclken_div_psc1; /* CDM + 0x2a reg10 byte2,3 */
  197. u16 reserved5; /* CDM + 0x2c reg11 byte0,1 */
  198. u16 mclken_div_psc2; /* CDM + 0x2e reg11 byte2,3 */
  199. u16 reserved6; /* CDM + 0x30 reg12 byte0,1 */
  200. u16 mclken_div_psc3; /* CDM + 0x32 reg12 byte2,3 */
  201. u16 reserved7; /* CDM + 0x34 reg13 byte0,1 */
  202. u16 mclken_div_psc6; /* CDM + 0x36 reg13 byte2,3 */
  203. };
  204. /* Interrupt controller Register set */
  205. struct mpc52xx_intr {
  206. u32 per_mask; /* INTR + 0x00 */
  207. u32 per_pri1; /* INTR + 0x04 */
  208. u32 per_pri2; /* INTR + 0x08 */
  209. u32 per_pri3; /* INTR + 0x0c */
  210. u32 ctrl; /* INTR + 0x10 */
  211. u32 main_mask; /* INTR + 0x14 */
  212. u32 main_pri1; /* INTR + 0x18 */
  213. u32 main_pri2; /* INTR + 0x1c */
  214. u32 reserved1; /* INTR + 0x20 */
  215. u32 enc_status; /* INTR + 0x24 */
  216. u32 crit_status; /* INTR + 0x28 */
  217. u32 main_status; /* INTR + 0x2c */
  218. u32 per_status; /* INTR + 0x30 */
  219. u32 reserved2; /* INTR + 0x34 */
  220. u32 per_error; /* INTR + 0x38 */
  221. };
  222. #endif /* __ASSEMBLY__ */
  223. /* ========================================================================= */
  224. /* Prototypes for MPC52xx sysdev */
  225. /* ========================================================================= */
  226. #ifndef __ASSEMBLY__
  227. /* mpc52xx_common.c */
  228. extern void mpc5200_setup_xlb_arbiter(void);
  229. extern void mpc52xx_declare_of_platform_devices(void);
  230. extern int mpc5200_psc_ac97_gpio_reset(int psc_number);
  231. extern void mpc52xx_map_common_devices(void);
  232. extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv);
  233. extern unsigned int mpc52xx_get_xtal_freq(struct device_node *node);
  234. extern void __noreturn mpc52xx_restart(char *cmd);
  235. /* mpc52xx_gpt.c */
  236. struct mpc52xx_gpt_priv;
  237. extern struct mpc52xx_gpt_priv *mpc52xx_gpt_from_irq(int irq);
  238. extern int mpc52xx_gpt_start_timer(struct mpc52xx_gpt_priv *gpt, u64 period,
  239. int continuous);
  240. extern u64 mpc52xx_gpt_timer_period(struct mpc52xx_gpt_priv *gpt);
  241. extern int mpc52xx_gpt_stop_timer(struct mpc52xx_gpt_priv *gpt);
  242. /* mpc52xx_lpbfifo.c */
  243. #define MPC52XX_LPBFIFO_FLAG_READ (0)
  244. #define MPC52XX_LPBFIFO_FLAG_WRITE (1<<0)
  245. #define MPC52XX_LPBFIFO_FLAG_NO_INCREMENT (1<<1)
  246. #define MPC52XX_LPBFIFO_FLAG_NO_DMA (1<<2)
  247. #define MPC52XX_LPBFIFO_FLAG_POLL_DMA (1<<3)
  248. struct mpc52xx_lpbfifo_request {
  249. struct list_head list;
  250. /* localplus bus address */
  251. unsigned int cs;
  252. size_t offset;
  253. /* Memory address */
  254. void *data;
  255. phys_addr_t data_phys;
  256. /* Details of transfer */
  257. size_t size;
  258. size_t pos; /* current position of transfer */
  259. int flags;
  260. int defer_xfer_start;
  261. /* What to do when finished */
  262. void (*callback)(struct mpc52xx_lpbfifo_request *);
  263. void *priv; /* Driver private data */
  264. /* statistics */
  265. int irq_count;
  266. int irq_ticks;
  267. u8 last_byte;
  268. int buffer_not_done_cnt;
  269. };
  270. extern int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req);
  271. extern void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req);
  272. extern void mpc52xx_lpbfifo_poll(void);
  273. extern int mpc52xx_lpbfifo_start_xfer(struct mpc52xx_lpbfifo_request *req);
  274. /* mpc52xx_pic.c */
  275. extern void mpc52xx_init_irq(void);
  276. extern unsigned int mpc52xx_get_irq(void);
  277. /* mpc52xx_pci.c */
  278. #ifdef CONFIG_PCI
  279. extern int __init mpc52xx_add_bridge(struct device_node *node);
  280. extern void __init mpc52xx_setup_pci(void);
  281. #else
  282. static inline void mpc52xx_setup_pci(void) { }
  283. #endif
  284. #endif /* __ASSEMBLY__ */
  285. #ifdef CONFIG_PM
  286. struct mpc52xx_suspend {
  287. void (*board_suspend_prepare)(void __iomem *mbar);
  288. void (*board_resume_finish)(void __iomem *mbar);
  289. };
  290. extern struct mpc52xx_suspend mpc52xx_suspend;
  291. extern int __init mpc52xx_pm_init(void);
  292. extern int mpc52xx_set_wakeup_gpio(u8 pin, u8 level);
  293. #ifdef CONFIG_PPC_LITE5200
  294. extern int __init lite5200_pm_init(void);
  295. /* lite5200 calls mpc5200 suspend functions, so here they are */
  296. extern int mpc52xx_pm_prepare(void);
  297. extern int mpc52xx_pm_enter(suspend_state_t);
  298. extern void mpc52xx_pm_finish(void);
  299. extern char saved_sram[0x4000]; /* reuse buffer from mpc52xx suspend */
  300. #endif
  301. #endif /* CONFIG_PM */
  302. #endif /* __ASM_POWERPC_MPC52xx_H__ */