cpu.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2009
  4. * Marvell Semiconductor <www.marvell.com>
  5. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  6. */
  7. #ifndef _KWCPU_H
  8. #define _KWCPU_H
  9. #include <asm/system.h>
  10. #ifndef __ASSEMBLY__
  11. #define KWCPU_WIN_CTRL_DATA(size, target, attr, en) (en | (target << 4) \
  12. | (attr << 8) | (kw_winctrl_calcsize(size) << 16))
  13. #define KWGBE_PORT_SERIAL_CONTROL1_REG(_x) \
  14. ((_x ? KW_EGIGA1_BASE : KW_EGIGA0_BASE) + 0x44c)
  15. #define KW_REG_PCIE_DEVID (KW_REG_PCIE_BASE + 0x00)
  16. #define KW_REG_PCIE_REVID (KW_REG_PCIE_BASE + 0x08)
  17. #define KW_REG_DEVICE_ID (KW_MPP_BASE + 0x34)
  18. #define KW_REG_SYSRST_CNT (KW_MPP_BASE + 0x50)
  19. #define SYSRST_CNT_1SEC_VAL (25*1000000)
  20. #define KW_REG_MPP_OUT_DRV_REG (KW_MPP_BASE + 0xE0)
  21. enum memory_bank {
  22. BANK0,
  23. BANK1,
  24. BANK2,
  25. BANK3
  26. };
  27. enum kwcpu_winen {
  28. KWCPU_WIN_DISABLE,
  29. KWCPU_WIN_ENABLE
  30. };
  31. enum kwcpu_target {
  32. KWCPU_TARGET_RESERVED,
  33. KWCPU_TARGET_MEMORY,
  34. KWCPU_TARGET_1RESERVED,
  35. KWCPU_TARGET_SASRAM,
  36. KWCPU_TARGET_PCIE
  37. };
  38. enum kwcpu_attrib {
  39. KWCPU_ATTR_SASRAM = 0x01,
  40. KWCPU_ATTR_DRAM_CS0 = 0x0e,
  41. KWCPU_ATTR_DRAM_CS1 = 0x0d,
  42. KWCPU_ATTR_DRAM_CS2 = 0x0b,
  43. KWCPU_ATTR_DRAM_CS3 = 0x07,
  44. KWCPU_ATTR_NANDFLASH = 0x2f,
  45. KWCPU_ATTR_SPIFLASH = 0x1e,
  46. KWCPU_ATTR_BOOTROM = 0x1d,
  47. KWCPU_ATTR_PCIE_IO = 0xe0,
  48. KWCPU_ATTR_PCIE_MEM = 0xe8
  49. };
  50. /*
  51. * Default Device Address MAP BAR values
  52. */
  53. #define KW_DEFADR_PCI_MEM 0x90000000
  54. #define KW_DEFADR_PCI_IO 0xC0000000
  55. #define KW_DEFADR_PCI_IO_REMAP 0xC0000000
  56. #define KW_DEFADR_SASRAM 0xC8010000
  57. #define KW_DEFADR_NANDF 0xD8000000
  58. #define KW_DEFADR_SPIF 0xE8000000
  59. #define KW_DEFADR_BOOTROM 0xF8000000
  60. /*
  61. * read feroceon/sheeva core extra feature register
  62. * using co-proc instruction
  63. */
  64. static inline unsigned int readfr_extra_feature_reg(void)
  65. {
  66. unsigned int val;
  67. asm volatile ("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr":"=r"
  68. (val)::"cc");
  69. return val;
  70. }
  71. /*
  72. * write feroceon/sheeva core extra feature register
  73. * using co-proc instruction
  74. */
  75. static inline void writefr_extra_feature_reg(unsigned int val)
  76. {
  77. asm volatile ("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr"::"r"
  78. (val):"cc");
  79. isb();
  80. }
  81. /*
  82. * MBus-L to Mbus Bridge Registers
  83. * Ref: Datasheet sec:A.3
  84. */
  85. struct kwwin_registers {
  86. u32 ctrl;
  87. u32 base;
  88. u32 remap_lo;
  89. u32 remap_hi;
  90. };
  91. /*
  92. * CPU control and status Registers
  93. * Ref: Datasheet sec:A.3.2
  94. */
  95. struct kwcpu_registers {
  96. u32 config; /*0x20100 */
  97. u32 ctrl_stat; /*0x20104 */
  98. u32 rstoutn_mask; /* 0x20108 */
  99. u32 sys_soft_rst; /* 0x2010C */
  100. u32 ahb_mbus_cause_irq; /* 0x20110 */
  101. u32 ahb_mbus_mask_irq; /* 0x20114 */
  102. u32 pad1[2];
  103. u32 ftdll_config; /* 0x20120 */
  104. u32 pad2;
  105. u32 l2_cfg; /* 0x20128 */
  106. };
  107. /*
  108. * GPIO Registers
  109. * Ref: Datasheet sec:A.19
  110. */
  111. struct kwgpio_registers {
  112. u32 dout;
  113. u32 oe;
  114. u32 blink_en;
  115. u32 din_pol;
  116. u32 din;
  117. u32 irq_cause;
  118. u32 irq_mask;
  119. u32 irq_level;
  120. };
  121. /*
  122. * functions
  123. */
  124. unsigned int mvebu_sdram_bar(enum memory_bank bank);
  125. unsigned int mvebu_sdram_bs(enum memory_bank bank);
  126. void mvebu_sdram_size_adjust(enum memory_bank bank);
  127. int kw_config_adr_windows(void);
  128. void mvebu_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
  129. unsigned int gpp0_oe, unsigned int gpp1_oe);
  130. int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
  131. unsigned int mpp16_23, unsigned int mpp24_31,
  132. unsigned int mpp32_39, unsigned int mpp40_47,
  133. unsigned int mpp48_55);
  134. unsigned int kw_winctrl_calcsize(unsigned int sizeval);
  135. #endif /* __ASSEMBLY__ */
  136. #endif /* _KWCPU_H */