tx4927.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*
  2. * Author: MontaVista Software, Inc.
  3. * [email protected]
  4. *
  5. * Copyright 2001-2006 MontaVista Software Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  17. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  18. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  20. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  21. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #ifndef __ASM_TXX9_TX4927_H
  28. #define __ASM_TXX9_TX4927_H
  29. #include <linux/types.h>
  30. #include <linux/io.h>
  31. #include <asm/txx9irq.h>
  32. #include <asm/txx9/tx4927pcic.h>
  33. #ifdef CONFIG_64BIT
  34. #define TX4927_REG_BASE 0xffffffffff1f0000UL
  35. #else
  36. #define TX4927_REG_BASE 0xff1f0000UL
  37. #endif
  38. #define TX4927_REG_SIZE 0x00010000
  39. #define TX4927_SDRAMC_REG (TX4927_REG_BASE + 0x8000)
  40. #define TX4927_EBUSC_REG (TX4927_REG_BASE + 0x9000)
  41. #define TX4927_DMA_REG (TX4927_REG_BASE + 0xb000)
  42. #define TX4927_PCIC_REG (TX4927_REG_BASE + 0xd000)
  43. #define TX4927_CCFG_REG (TX4927_REG_BASE + 0xe000)
  44. #define TX4927_IRC_REG (TX4927_REG_BASE + 0xf600)
  45. #define TX4927_NR_TMR 3
  46. #define TX4927_TMR_REG(ch) (TX4927_REG_BASE + 0xf000 + (ch) * 0x100)
  47. #define TX4927_NR_SIO 2
  48. #define TX4927_SIO_REG(ch) (TX4927_REG_BASE + 0xf300 + (ch) * 0x100)
  49. #define TX4927_PIO_REG (TX4927_REG_BASE + 0xf500)
  50. #define TX4927_ACLC_REG (TX4927_REG_BASE + 0xf700)
  51. #define TX4927_IR_ECCERR 0
  52. #define TX4927_IR_WTOERR 1
  53. #define TX4927_NUM_IR_INT 6
  54. #define TX4927_IR_INT(n) (2 + (n))
  55. #define TX4927_NUM_IR_SIO 2
  56. #define TX4927_IR_SIO(n) (8 + (n))
  57. #define TX4927_NUM_IR_DMA 4
  58. #define TX4927_IR_DMA(n) (10 + (n))
  59. #define TX4927_IR_PIO 14
  60. #define TX4927_IR_PDMAC 15
  61. #define TX4927_IR_PCIC 16
  62. #define TX4927_NUM_IR_TMR 3
  63. #define TX4927_IR_TMR(n) (17 + (n))
  64. #define TX4927_IR_PCIERR 22
  65. #define TX4927_IR_PCIPME 23
  66. #define TX4927_IR_ACLC 24
  67. #define TX4927_IR_ACLCPME 25
  68. #define TX4927_NUM_IR 32
  69. #define TX4927_IRC_INT 2 /* IP[2] in Status register */
  70. #define TX4927_NUM_PIO 16
  71. struct tx4927_sdramc_reg {
  72. u64 cr[4];
  73. u64 unused0[4];
  74. u64 tr;
  75. u64 unused1[2];
  76. u64 cmd;
  77. };
  78. struct tx4927_ebusc_reg {
  79. u64 cr[8];
  80. };
  81. struct tx4927_ccfg_reg {
  82. u64 ccfg;
  83. u64 crir;
  84. u64 pcfg;
  85. u64 toea;
  86. u64 clkctr;
  87. u64 unused0;
  88. u64 garbc;
  89. u64 unused1;
  90. u64 unused2;
  91. u64 ramp;
  92. };
  93. /*
  94. * CCFG
  95. */
  96. /* CCFG : Chip Configuration */
  97. #define TX4927_CCFG_WDRST 0x0000020000000000ULL
  98. #define TX4927_CCFG_WDREXEN 0x0000010000000000ULL
  99. #define TX4927_CCFG_BCFG_MASK 0x000000ff00000000ULL
  100. #define TX4927_CCFG_TINTDIS 0x01000000
  101. #define TX4927_CCFG_PCI66 0x00800000
  102. #define TX4927_CCFG_PCIMODE 0x00400000
  103. #define TX4927_CCFG_DIVMODE_MASK 0x000e0000
  104. #define TX4927_CCFG_DIVMODE_8 (0x0 << 17)
  105. #define TX4927_CCFG_DIVMODE_12 (0x1 << 17)
  106. #define TX4927_CCFG_DIVMODE_16 (0x2 << 17)
  107. #define TX4927_CCFG_DIVMODE_10 (0x3 << 17)
  108. #define TX4927_CCFG_DIVMODE_2 (0x4 << 17)
  109. #define TX4927_CCFG_DIVMODE_3 (0x5 << 17)
  110. #define TX4927_CCFG_DIVMODE_4 (0x6 << 17)
  111. #define TX4927_CCFG_DIVMODE_2_5 (0x7 << 17)
  112. #define TX4927_CCFG_BEOW 0x00010000
  113. #define TX4927_CCFG_WR 0x00008000
  114. #define TX4927_CCFG_TOE 0x00004000
  115. #define TX4927_CCFG_PCIARB 0x00002000
  116. #define TX4927_CCFG_PCIDIVMODE_MASK 0x00001800
  117. #define TX4927_CCFG_PCIDIVMODE_2_5 0x00000000
  118. #define TX4927_CCFG_PCIDIVMODE_3 0x00000800
  119. #define TX4927_CCFG_PCIDIVMODE_5 0x00001000
  120. #define TX4927_CCFG_PCIDIVMODE_6 0x00001800
  121. #define TX4927_CCFG_SYSSP_MASK 0x000000c0
  122. #define TX4927_CCFG_ENDIAN 0x00000004
  123. #define TX4927_CCFG_HALT 0x00000002
  124. #define TX4927_CCFG_ACEHOLD 0x00000001
  125. #define TX4927_CCFG_W1CBITS (TX4927_CCFG_WDRST | TX4927_CCFG_BEOW)
  126. /* PCFG : Pin Configuration */
  127. #define TX4927_PCFG_SDCLKDLY_MASK 0x30000000
  128. #define TX4927_PCFG_SDCLKDLY(d) ((d)<<28)
  129. #define TX4927_PCFG_SYSCLKEN 0x08000000
  130. #define TX4927_PCFG_SDCLKEN_ALL 0x07800000
  131. #define TX4927_PCFG_SDCLKEN(ch) (0x00800000<<(ch))
  132. #define TX4927_PCFG_PCICLKEN_ALL 0x003f0000
  133. #define TX4927_PCFG_PCICLKEN(ch) (0x00010000<<(ch))
  134. #define TX4927_PCFG_SEL2 0x00000200
  135. #define TX4927_PCFG_SEL1 0x00000100
  136. #define TX4927_PCFG_DMASEL_ALL 0x000000ff
  137. #define TX4927_PCFG_DMASEL0_MASK 0x00000003
  138. #define TX4927_PCFG_DMASEL1_MASK 0x0000000c
  139. #define TX4927_PCFG_DMASEL2_MASK 0x00000030
  140. #define TX4927_PCFG_DMASEL3_MASK 0x000000c0
  141. #define TX4927_PCFG_DMASEL0_DRQ0 0x00000000
  142. #define TX4927_PCFG_DMASEL0_SIO1 0x00000001
  143. #define TX4927_PCFG_DMASEL0_ACL0 0x00000002
  144. #define TX4927_PCFG_DMASEL0_ACL2 0x00000003
  145. #define TX4927_PCFG_DMASEL1_DRQ1 0x00000000
  146. #define TX4927_PCFG_DMASEL1_SIO1 0x00000004
  147. #define TX4927_PCFG_DMASEL1_ACL1 0x00000008
  148. #define TX4927_PCFG_DMASEL1_ACL3 0x0000000c
  149. #define TX4927_PCFG_DMASEL2_DRQ2 0x00000000 /* SEL2=0 */
  150. #define TX4927_PCFG_DMASEL2_SIO0 0x00000010 /* SEL2=0 */
  151. #define TX4927_PCFG_DMASEL2_ACL1 0x00000000 /* SEL2=1 */
  152. #define TX4927_PCFG_DMASEL2_ACL2 0x00000020 /* SEL2=1 */
  153. #define TX4927_PCFG_DMASEL2_ACL0 0x00000030 /* SEL2=1 */
  154. #define TX4927_PCFG_DMASEL3_DRQ3 0x00000000
  155. #define TX4927_PCFG_DMASEL3_SIO0 0x00000040
  156. #define TX4927_PCFG_DMASEL3_ACL3 0x00000080
  157. #define TX4927_PCFG_DMASEL3_ACL1 0x000000c0
  158. /* CLKCTR : Clock Control */
  159. #define TX4927_CLKCTR_ACLCKD 0x02000000
  160. #define TX4927_CLKCTR_PIOCKD 0x01000000
  161. #define TX4927_CLKCTR_DMACKD 0x00800000
  162. #define TX4927_CLKCTR_PCICKD 0x00400000
  163. #define TX4927_CLKCTR_TM0CKD 0x00100000
  164. #define TX4927_CLKCTR_TM1CKD 0x00080000
  165. #define TX4927_CLKCTR_TM2CKD 0x00040000
  166. #define TX4927_CLKCTR_SIO0CKD 0x00020000
  167. #define TX4927_CLKCTR_SIO1CKD 0x00010000
  168. #define TX4927_CLKCTR_ACLRST 0x00000200
  169. #define TX4927_CLKCTR_PIORST 0x00000100
  170. #define TX4927_CLKCTR_DMARST 0x00000080
  171. #define TX4927_CLKCTR_PCIRST 0x00000040
  172. #define TX4927_CLKCTR_TM0RST 0x00000010
  173. #define TX4927_CLKCTR_TM1RST 0x00000008
  174. #define TX4927_CLKCTR_TM2RST 0x00000004
  175. #define TX4927_CLKCTR_SIO0RST 0x00000002
  176. #define TX4927_CLKCTR_SIO1RST 0x00000001
  177. #define tx4927_sdramcptr \
  178. ((struct tx4927_sdramc_reg __iomem *)TX4927_SDRAMC_REG)
  179. #define tx4927_pcicptr \
  180. ((struct tx4927_pcic_reg __iomem *)TX4927_PCIC_REG)
  181. #define tx4927_ccfgptr \
  182. ((struct tx4927_ccfg_reg __iomem *)TX4927_CCFG_REG)
  183. #define tx4927_ebuscptr \
  184. ((struct tx4927_ebusc_reg __iomem *)TX4927_EBUSC_REG)
  185. #define tx4927_pioptr ((struct txx9_pio_reg __iomem *)TX4927_PIO_REG)
  186. #define TX4927_REV_PCODE() \
  187. ((__u32)__raw_readq(&tx4927_ccfgptr->crir) >> 16)
  188. #define TX4927_SDRAMC_CR(ch) __raw_readq(&tx4927_sdramcptr->cr[(ch)])
  189. #define TX4927_SDRAMC_BA(ch) ((TX4927_SDRAMC_CR(ch) >> 49) << 21)
  190. #define TX4927_SDRAMC_SIZE(ch) \
  191. ((((TX4927_SDRAMC_CR(ch) >> 33) & 0x7fff) + 1) << 21)
  192. #define TX4927_EBUSC_CR(ch) __raw_readq(&tx4927_ebuscptr->cr[(ch)])
  193. #define TX4927_EBUSC_BA(ch) ((TX4927_EBUSC_CR(ch) >> 48) << 20)
  194. #define TX4927_EBUSC_SIZE(ch) \
  195. (0x00100000 << ((unsigned long)(TX4927_EBUSC_CR(ch) >> 8) & 0xf))
  196. #define TX4927_EBUSC_WIDTH(ch) \
  197. (64 >> ((__u32)(TX4927_EBUSC_CR(ch) >> 20) & 0x3))
  198. /* utilities */
  199. static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits)
  200. {
  201. #ifdef CONFIG_32BIT
  202. unsigned long flags;
  203. local_irq_save(flags);
  204. #endif
  205. ____raw_writeq(____raw_readq(adr) & ~bits, adr);
  206. #ifdef CONFIG_32BIT
  207. local_irq_restore(flags);
  208. #endif
  209. }
  210. static inline void txx9_set64(__u64 __iomem *adr, __u64 bits)
  211. {
  212. #ifdef CONFIG_32BIT
  213. unsigned long flags;
  214. local_irq_save(flags);
  215. #endif
  216. ____raw_writeq(____raw_readq(adr) | bits, adr);
  217. #ifdef CONFIG_32BIT
  218. local_irq_restore(flags);
  219. #endif
  220. }
  221. /* These functions are not interrupt safe. */
  222. static inline void tx4927_ccfg_clear(__u64 bits)
  223. {
  224. ____raw_writeq(____raw_readq(&tx4927_ccfgptr->ccfg)
  225. & ~(TX4927_CCFG_W1CBITS | bits),
  226. &tx4927_ccfgptr->ccfg);
  227. }
  228. static inline void tx4927_ccfg_set(__u64 bits)
  229. {
  230. ____raw_writeq((____raw_readq(&tx4927_ccfgptr->ccfg)
  231. & ~TX4927_CCFG_W1CBITS) | bits,
  232. &tx4927_ccfgptr->ccfg);
  233. }
  234. static inline void tx4927_ccfg_change(__u64 change, __u64 new)
  235. {
  236. ____raw_writeq((____raw_readq(&tx4927_ccfgptr->ccfg)
  237. & ~(TX4927_CCFG_W1CBITS | change)) |
  238. new,
  239. &tx4927_ccfgptr->ccfg);
  240. }
  241. unsigned int tx4927_get_mem_size(void);
  242. void tx4927_wdt_init(void);
  243. void tx4927_setup(void);
  244. void tx4927_time_init(unsigned int tmrnr);
  245. void tx4927_sio_init(unsigned int sclk, unsigned int cts_mask);
  246. int tx4927_report_pciclk(void);
  247. int tx4927_pciclk66_setup(void);
  248. void tx4927_setup_pcierr_irq(void);
  249. void tx4927_irq_init(void);
  250. void tx4927_mtd_init(int ch);
  251. void tx4927_dmac_init(int memcpy_chan);
  252. void tx4927_aclc_init(unsigned int dma_chan_out, unsigned int dma_chan_in);
  253. #endif /* __ASM_TXX9_TX4927_H */