cpu.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22. * MA 02110-1301 USA
  23. */
  24. #ifndef _KWCPU_H
  25. #define _KWCPU_H
  26. #include <asm/system.h>
  27. #ifndef __ASSEMBLY__
  28. #define KWCPU_WIN_CTRL_DATA(size, target, attr, en) (en | (target << 4) \
  29. | (attr << 8) | (kw_winctrl_calcsize(size) << 16))
  30. #define KWGBE_PORT_SERIAL_CONTROL1_REG(_x) \
  31. ((_x ? KW_EGIGA0_BASE : KW_EGIGA1_BASE) + 0x44c)
  32. #define KW_REG_DEVICE_ID (KW_MPP_BASE + 0x34)
  33. #define KW_REG_MPP_OUT_DRV_REG (KW_MPP_BASE + 0xE0)
  34. enum memory_bank {
  35. BANK0,
  36. BANK1,
  37. BANK2,
  38. BANK3
  39. };
  40. enum kwcpu_winen {
  41. KWCPU_WIN_DISABLE,
  42. KWCPU_WIN_ENABLE
  43. };
  44. enum kwcpu_target {
  45. KWCPU_TARGET_RESERVED,
  46. KWCPU_TARGET_MEMORY,
  47. KWCPU_TARGET_1RESERVED,
  48. KWCPU_TARGET_SASRAM,
  49. KWCPU_TARGET_PCIE
  50. };
  51. enum kwcpu_attrib {
  52. KWCPU_ATTR_SASRAM = 0x01,
  53. KWCPU_ATTR_DRAM_CS0 = 0x0e,
  54. KWCPU_ATTR_DRAM_CS1 = 0x0d,
  55. KWCPU_ATTR_DRAM_CS2 = 0x0b,
  56. KWCPU_ATTR_DRAM_CS3 = 0x07,
  57. KWCPU_ATTR_NANDFLASH = 0x2f,
  58. KWCPU_ATTR_SPIFLASH = 0x1e,
  59. KWCPU_ATTR_BOOTROM = 0x1d,
  60. KWCPU_ATTR_PCIE_IO = 0xe0,
  61. KWCPU_ATTR_PCIE_MEM = 0xe8
  62. };
  63. /*
  64. * Default Device Address MAP BAR values
  65. */
  66. #define KW_DEFADR_PCI_MEM 0x90000000
  67. #define KW_DEFADR_PCI_IO 0xC0000000
  68. #define KW_DEFADR_PCI_IO_REMAP 0xC0000000
  69. #define KW_DEFADR_SASRAM 0xC8010000
  70. #define KW_DEFADR_NANDF 0xD8000000
  71. #define KW_DEFADR_SPIF 0xE8000000
  72. #define KW_DEFADR_BOOTROM 0xF8000000
  73. /*
  74. * read feroceon/sheeva core extra feature register
  75. * using co-proc instruction
  76. */
  77. static inline unsigned int readfr_extra_feature_reg(void)
  78. {
  79. unsigned int val;
  80. asm volatile ("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr":"=r"
  81. (val)::"cc");
  82. return val;
  83. }
  84. /*
  85. * write feroceon/sheeva core extra feature register
  86. * using co-proc instruction
  87. */
  88. static inline void writefr_extra_feature_reg(unsigned int val)
  89. {
  90. asm volatile ("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr"::"r"
  91. (val):"cc");
  92. isb();
  93. }
  94. /*
  95. * MBus-L to Mbus Bridge Registers
  96. * Ref: Datasheet sec:A.3
  97. */
  98. struct kwwin_registers {
  99. u32 ctrl;
  100. u32 base;
  101. u32 remap_lo;
  102. u32 remap_hi;
  103. };
  104. /*
  105. * CPU control and status Registers
  106. * Ref: Datasheet sec:A.3.2
  107. */
  108. struct kwcpu_registers {
  109. u32 config; /*0x20100 */
  110. u32 ctrl_stat; /*0x20104 */
  111. u32 rstoutn_mask; /* 0x20108 */
  112. u32 sys_soft_rst; /* 0x2010C */
  113. u32 ahb_mbus_cause_irq; /* 0x20110 */
  114. u32 ahb_mbus_mask_irq; /* 0x20114 */
  115. u32 pad1[2];
  116. u32 ftdll_config; /* 0x20120 */
  117. u32 pad2;
  118. u32 l2_cfg; /* 0x20128 */
  119. };
  120. /*
  121. * GPIO Registers
  122. * Ref: Datasheet sec:A.19
  123. */
  124. struct kwgpio_registers {
  125. u32 dout;
  126. u32 oe;
  127. u32 blink_en;
  128. u32 din_pol;
  129. u32 din;
  130. u32 irq_cause;
  131. u32 irq_mask;
  132. u32 irq_level;
  133. };
  134. /*
  135. * functions
  136. */
  137. void reset_cpu(unsigned long ignored);
  138. unsigned char get_random_hex(void);
  139. unsigned int kw_sdram_bar(enum memory_bank bank);
  140. unsigned int kw_sdram_bs(enum memory_bank bank);
  141. int kw_config_adr_windows(void);
  142. void kw_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
  143. unsigned int gpp0_oe, unsigned int gpp1_oe);
  144. int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
  145. unsigned int mpp16_23, unsigned int mpp24_31,
  146. unsigned int mpp32_39, unsigned int mpp40_47,
  147. unsigned int mpp48_55);
  148. unsigned int kw_winctrl_calcsize(unsigned int sizeval);
  149. #endif /* __ASSEMBLY__ */
  150. #endif /* _KWCPU_H */