octeon.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2004-2008 Cavium Networks
  7. */
  8. #ifndef __ASM_OCTEON_OCTEON_H
  9. #define __ASM_OCTEON_OCTEON_H
  10. #include "cvmx.h"
  11. extern uint64_t octeon_bootmem_alloc_range_phys(uint64_t size,
  12. uint64_t alignment,
  13. uint64_t min_addr,
  14. uint64_t max_addr,
  15. int do_locking);
  16. extern void *octeon_bootmem_alloc(uint64_t size, uint64_t alignment,
  17. int do_locking);
  18. extern void *octeon_bootmem_alloc_range(uint64_t size, uint64_t alignment,
  19. uint64_t min_addr, uint64_t max_addr,
  20. int do_locking);
  21. extern void *octeon_bootmem_alloc_named(uint64_t size, uint64_t alignment,
  22. char *name);
  23. extern void *octeon_bootmem_alloc_named_range(uint64_t size, uint64_t min_addr,
  24. uint64_t max_addr, uint64_t align,
  25. char *name);
  26. extern void *octeon_bootmem_alloc_named_address(uint64_t size, uint64_t address,
  27. char *name);
  28. extern int octeon_bootmem_free_named(char *name);
  29. extern void octeon_bootmem_lock(void);
  30. extern void octeon_bootmem_unlock(void);
  31. extern int octeon_is_simulation(void);
  32. extern int octeon_is_pci_host(void);
  33. extern int octeon_usb_is_ref_clk(void);
  34. extern uint64_t octeon_get_clock_rate(void);
  35. extern const char *octeon_board_type_string(void);
  36. extern const char *octeon_get_pci_interrupts(void);
  37. extern int octeon_get_southbridge_interrupt(void);
  38. extern int octeon_get_boot_coremask(void);
  39. extern int octeon_get_boot_num_arguments(void);
  40. extern const char *octeon_get_boot_argument(int arg);
  41. extern void octeon_hal_setup_reserved32(void);
  42. extern void octeon_user_io_init(void);
  43. struct octeon_cop2_state;
  44. extern unsigned long octeon_crypto_enable(struct octeon_cop2_state *state);
  45. extern void octeon_crypto_disable(struct octeon_cop2_state *state,
  46. unsigned long flags);
  47. extern asmlinkage void octeon_cop2_restore(struct octeon_cop2_state *task);
  48. extern void octeon_init_cvmcount(void);
  49. extern void octeon_setup_delays(void);
  50. #define OCTEON_ARGV_MAX_ARGS 64
  51. #define OCTOEN_SERIAL_LEN 20
  52. struct octeon_boot_descriptor {
  53. /* Start of block referenced by assembly code - do not change! */
  54. uint32_t desc_version;
  55. uint32_t desc_size;
  56. uint64_t stack_top;
  57. uint64_t heap_base;
  58. uint64_t heap_end;
  59. /* Only used by bootloader */
  60. uint64_t entry_point;
  61. uint64_t desc_vaddr;
  62. /* End of This block referenced by assembly code - do not change! */
  63. uint32_t exception_base_addr;
  64. uint32_t stack_size;
  65. uint32_t heap_size;
  66. /* Argc count for application. */
  67. uint32_t argc;
  68. uint32_t argv[OCTEON_ARGV_MAX_ARGS];
  69. #define BOOT_FLAG_INIT_CORE (1 << 0)
  70. #define OCTEON_BL_FLAG_DEBUG (1 << 1)
  71. #define OCTEON_BL_FLAG_NO_MAGIC (1 << 2)
  72. /* If set, use uart1 for console */
  73. #define OCTEON_BL_FLAG_CONSOLE_UART1 (1 << 3)
  74. /* If set, use PCI console */
  75. #define OCTEON_BL_FLAG_CONSOLE_PCI (1 << 4)
  76. /* Call exit on break on serial port */
  77. #define OCTEON_BL_FLAG_BREAK (1 << 5)
  78. uint32_t flags;
  79. uint32_t core_mask;
  80. /* DRAM size in megabyes. */
  81. uint32_t dram_size;
  82. /* physical address of free memory descriptor block. */
  83. uint32_t phy_mem_desc_addr;
  84. /* used to pass flags from app to debugger. */
  85. uint32_t debugger_flags_base_addr;
  86. /* CPU clock speed, in hz. */
  87. uint32_t eclock_hz;
  88. /* DRAM clock speed, in hz. */
  89. uint32_t dclock_hz;
  90. /* SPI4 clock in hz. */
  91. uint32_t spi_clock_hz;
  92. uint16_t board_type;
  93. uint8_t board_rev_major;
  94. uint8_t board_rev_minor;
  95. uint16_t chip_type;
  96. uint8_t chip_rev_major;
  97. uint8_t chip_rev_minor;
  98. char board_serial_number[OCTOEN_SERIAL_LEN];
  99. uint8_t mac_addr_base[6];
  100. uint8_t mac_addr_count;
  101. uint64_t cvmx_desc_vaddr;
  102. };
  103. union octeon_cvmemctl {
  104. uint64_t u64;
  105. struct {
  106. /* RO 1 = BIST fail, 0 = BIST pass */
  107. uint64_t tlbbist:1;
  108. /* RO 1 = BIST fail, 0 = BIST pass */
  109. uint64_t l1cbist:1;
  110. /* RO 1 = BIST fail, 0 = BIST pass */
  111. uint64_t l1dbist:1;
  112. /* RO 1 = BIST fail, 0 = BIST pass */
  113. uint64_t dcmbist:1;
  114. /* RO 1 = BIST fail, 0 = BIST pass */
  115. uint64_t ptgbist:1;
  116. /* RO 1 = BIST fail, 0 = BIST pass */
  117. uint64_t wbfbist:1;
  118. /* Reserved */
  119. uint64_t reserved:22;
  120. /* R/W If set, marked write-buffer entries time out
  121. * the same as as other entries; if clear, marked
  122. * write-buffer entries use the maximum timeout. */
  123. uint64_t dismarkwblongto:1;
  124. /* R/W If set, a merged store does not clear the
  125. * write-buffer entry timeout state. */
  126. uint64_t dismrgclrwbto:1;
  127. /* R/W Two bits that are the MSBs of the resultant
  128. * CVMSEG LM word location for an IOBDMA. The other 8
  129. * bits come from the SCRADDR field of the IOBDMA. */
  130. uint64_t iobdmascrmsb:2;
  131. /* R/W If set, SYNCWS and SYNCS only order marked
  132. * stores; if clear, SYNCWS and SYNCS only order
  133. * unmarked stores. SYNCWSMARKED has no effect when
  134. * DISSYNCWS is set. */
  135. uint64_t syncwsmarked:1;
  136. /* R/W If set, SYNCWS acts as SYNCW and SYNCS acts as
  137. * SYNC. */
  138. uint64_t dissyncws:1;
  139. /* R/W If set, no stall happens on write buffer
  140. * full. */
  141. uint64_t diswbfst:1;
  142. /* R/W If set (and SX set), supervisor-level
  143. * loads/stores can use XKPHYS addresses with
  144. * VA<48>==0 */
  145. uint64_t xkmemenas:1;
  146. /* R/W If set (and UX set), user-level loads/stores
  147. * can use XKPHYS addresses with VA<48>==0 */
  148. uint64_t xkmemenau:1;
  149. /* R/W If set (and SX set), supervisor-level
  150. * loads/stores can use XKPHYS addresses with
  151. * VA<48>==1 */
  152. uint64_t xkioenas:1;
  153. /* R/W If set (and UX set), user-level loads/stores
  154. * can use XKPHYS addresses with VA<48>==1 */
  155. uint64_t xkioenau:1;
  156. /* R/W If set, all stores act as SYNCW (NOMERGE must
  157. * be set when this is set) RW, reset to 0. */
  158. uint64_t allsyncw:1;
  159. /* R/W If set, no stores merge, and all stores reach
  160. * the coherent bus in order. */
  161. uint64_t nomerge:1;
  162. /* R/W Selects the bit in the counter used for DID
  163. * time-outs 0 = 231, 1 = 230, 2 = 229, 3 =
  164. * 214. Actual time-out is between 1x and 2x this
  165. * interval. For example, with DIDTTO=3, expiration
  166. * interval is between 16K and 32K. */
  167. uint64_t didtto:2;
  168. /* R/W If set, the (mem) CSR clock never turns off. */
  169. uint64_t csrckalwys:1;
  170. /* R/W If set, mclk never turns off. */
  171. uint64_t mclkalwys:1;
  172. /* R/W Selects the bit in the counter used for write
  173. * buffer flush time-outs (WBFLT+11) is the bit
  174. * position in an internal counter used to determine
  175. * expiration. The write buffer expires between 1x and
  176. * 2x this interval. For example, with WBFLT = 0, a
  177. * write buffer expires between 2K and 4K cycles after
  178. * the write buffer entry is allocated. */
  179. uint64_t wbfltime:3;
  180. /* R/W If set, do not put Istream in the L2 cache. */
  181. uint64_t istrnol2:1;
  182. /* R/W The write buffer threshold. */
  183. uint64_t wbthresh:4;
  184. /* Reserved */
  185. uint64_t reserved2:2;
  186. /* R/W If set, CVMSEG is available for loads/stores in
  187. * kernel/debug mode. */
  188. uint64_t cvmsegenak:1;
  189. /* R/W If set, CVMSEG is available for loads/stores in
  190. * supervisor mode. */
  191. uint64_t cvmsegenas:1;
  192. /* R/W If set, CVMSEG is available for loads/stores in
  193. * user mode. */
  194. uint64_t cvmsegenau:1;
  195. /* R/W Size of local memory in cache blocks, 54 (6912
  196. * bytes) is max legal value. */
  197. uint64_t lmemsz:6;
  198. } s;
  199. };
  200. struct octeon_cf_data {
  201. unsigned long base_region_bias;
  202. unsigned int base_region; /* The chip select region used by CF */
  203. int is16bit; /* 0 - 8bit, !0 - 16bit */
  204. int dma_engine; /* -1 for no DMA */
  205. };
  206. struct octeon_i2c_data {
  207. unsigned int sys_freq;
  208. unsigned int i2c_freq;
  209. };
  210. extern void octeon_write_lcd(const char *s);
  211. extern void octeon_check_cpu_bist(void);
  212. extern int octeon_get_boot_debug_flag(void);
  213. extern int octeon_get_boot_uart(void);
  214. struct uart_port;
  215. extern unsigned int octeon_serial_in(struct uart_port *, int);
  216. extern void octeon_serial_out(struct uart_port *, int, int);
  217. /**
  218. * Write a 32bit value to the Octeon NPI register space
  219. *
  220. * @address: Address to write to
  221. * @val: Value to write
  222. */
  223. static inline void octeon_npi_write32(uint64_t address, uint32_t val)
  224. {
  225. cvmx_write64_uint32(address ^ 4, val);
  226. cvmx_read64_uint32(address ^ 4);
  227. }
  228. /**
  229. * Read a 32bit value from the Octeon NPI register space
  230. *
  231. * @address: Address to read
  232. * Returns The result
  233. */
  234. static inline uint32_t octeon_npi_read32(uint64_t address)
  235. {
  236. return cvmx_read64_uint32(address ^ 4);
  237. }
  238. extern struct cvmx_bootinfo *octeon_bootinfo;
  239. extern uint64_t octeon_bootloader_entry_addr;
  240. #endif /* __ASM_OCTEON_OCTEON_H */