pch.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2014 Google, Inc
  4. *
  5. * From Coreboot src/southbridge/intel/bd82x6x/pch.h
  6. *
  7. * Copyright (C) 2008-2009 coresystems GmbH
  8. * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
  9. */
  10. #ifndef _ASM_ARCH_PCH_H
  11. #define _ASM_ARCH_PCH_H
  12. #include <pci.h>
  13. /* PCH types */
  14. #define PCH_TYPE_CPT 0x1c /* CougarPoint */
  15. #define PCH_TYPE_PPT 0x1e /* IvyBridge */
  16. /* PCH stepping values for LPC device */
  17. #define PCH_STEP_A0 0
  18. #define PCH_STEP_A1 1
  19. #define PCH_STEP_B0 2
  20. #define PCH_STEP_B1 3
  21. #define PCH_STEP_B2 4
  22. #define PCH_STEP_B3 5
  23. #define DEFAULT_GPIOBASE 0x0480
  24. #define DEFAULT_PMBASE 0x0500
  25. #define SMBUS_IO_BASE 0x0400
  26. #define MAINBOARD_POWER_OFF 0
  27. #define MAINBOARD_POWER_ON 1
  28. #define MAINBOARD_POWER_KEEP 2
  29. /* PCI Configuration Space (D30:F0): PCI2PCI */
  30. #define PSTS 0x06
  31. #define SMLT 0x1b
  32. #define SECSTS 0x1e
  33. #define INTR 0x3c
  34. #define BCTRL 0x3e
  35. #define SBR (1 << 6)
  36. #define SEE (1 << 1)
  37. #define PERE (1 << 0)
  38. #define PCH_EHCI1_DEV PCI_BDF(0, 0x1d, 0)
  39. #define PCH_EHCI2_DEV PCI_BDF(0, 0x1a, 0)
  40. #define PCH_XHCI_DEV PCI_BDF(0, 0x14, 0)
  41. #define PCH_ME_DEV PCI_BDF(0, 0x16, 0)
  42. #define PCH_PCIE_DEV_SLOT 28
  43. #define PCH_DEV PCI_BDF(0, 0, 0)
  44. #define PCH_VIDEO_DEV PCI_BDF(0, 2, 0)
  45. /* PCI Configuration Space (D31:F0): LPC */
  46. #define PCH_LPC_DEV PCI_BDF(0, 0x1f, 0)
  47. #define SERIRQ_CNTL 0x64
  48. #define GEN_PMCON_1 0xa0
  49. #define GEN_PMCON_2 0xa2
  50. #define GEN_PMCON_3 0xa4
  51. #define ETR3 0xac
  52. #define ETR3_CWORWRE (1 << 18)
  53. #define ETR3_CF9GR (1 << 20)
  54. /* GEN_PMCON_3 bits */
  55. #define RTC_BATTERY_DEAD (1 << 2)
  56. #define RTC_POWER_FAILED (1 << 1)
  57. #define SLEEP_AFTER_POWER_FAIL (1 << 0)
  58. #define BIOS_CNTL 0xDC
  59. #define GPIO_BASE 0x48 /* LPC GPIO Base Address Register */
  60. #define GPIO_CNTL 0x4C /* LPC GPIO Control Register */
  61. #define GPIO_ROUT 0xb8
  62. #define PIRQA_ROUT 0x60
  63. #define PIRQB_ROUT 0x61
  64. #define PIRQC_ROUT 0x62
  65. #define PIRQD_ROUT 0x63
  66. #define PIRQE_ROUT 0x68
  67. #define PIRQF_ROUT 0x69
  68. #define PIRQG_ROUT 0x6A
  69. #define PIRQH_ROUT 0x6B
  70. #define GEN_PMCON_1 0xa0
  71. #define GEN_PMCON_2 0xa2
  72. #define GEN_PMCON_3 0xa4
  73. #define ETR3 0xac
  74. #define ETR3_CWORWRE (1 << 18)
  75. #define ETR3_CF9GR (1 << 20)
  76. #define PMBASE 0x40
  77. #define ACPI_CNTL 0x44
  78. #define BIOS_CNTL 0xDC
  79. #define GPIO_BASE 0x48 /* LPC GPIO Base Address Register */
  80. #define GPIO_CNTL 0x4C /* LPC GPIO Control Register */
  81. #define GPIO_ROUT 0xb8
  82. /* PCI Configuration Space (D31:F1): IDE */
  83. #define PCH_IDE_DEV PCI_BDF(0, 0x1f, 1)
  84. #define PCH_SATA_DEV PCI_BDF(0, 0x1f, 2)
  85. #define PCH_SATA2_DEV PCI_BDF(0, 0x1f, 5)
  86. #define IDE_SDMA_CNT 0x48 /* Synchronous DMA control */
  87. #define IDE_SSDE1 (1 << 3)
  88. #define IDE_SSDE0 (1 << 2)
  89. #define IDE_PSDE1 (1 << 1)
  90. #define IDE_PSDE0 (1 << 0)
  91. #define IDE_SDMA_TIM 0x4a
  92. #define IDE_CONFIG 0x54 /* IDE I/O Configuration Register */
  93. #define SIG_MODE_SEC_NORMAL (0 << 18)
  94. #define SIG_MODE_SEC_TRISTATE (1 << 18)
  95. #define SIG_MODE_SEC_DRIVELOW (2 << 18)
  96. #define SIG_MODE_PRI_NORMAL (0 << 16)
  97. #define SIG_MODE_PRI_TRISTATE (1 << 16)
  98. #define SIG_MODE_PRI_DRIVELOW (2 << 16)
  99. #define FAST_SCB1 (1 << 15)
  100. #define FAST_SCB0 (1 << 14)
  101. #define FAST_PCB1 (1 << 13)
  102. #define FAST_PCB0 (1 << 12)
  103. #define SCB1 (1 << 3)
  104. #define SCB0 (1 << 2)
  105. #define PCB1 (1 << 1)
  106. #define PCB0 (1 << 0)
  107. #define SATA_SIRI 0xa0 /* SATA Indexed Register Index */
  108. #define SATA_SIRD 0xa4 /* SATA Indexed Register Data */
  109. #define SATA_SP 0xd0 /* Scratchpad */
  110. /* SATA IOBP Registers */
  111. #define SATA_IOBP_SP0G3IR 0xea000151
  112. #define SATA_IOBP_SP1G3IR 0xea000051
  113. #define VCH 0x0000 /* 32bit */
  114. #define VCAP1 0x0004 /* 32bit */
  115. #define VCAP2 0x0008 /* 32bit */
  116. #define PVC 0x000c /* 16bit */
  117. #define PVS 0x000e /* 16bit */
  118. #define V0CAP 0x0010 /* 32bit */
  119. #define V0CTL 0x0014 /* 32bit */
  120. #define V0STS 0x001a /* 16bit */
  121. #define V1CAP 0x001c /* 32bit */
  122. #define V1CTL 0x0020 /* 32bit */
  123. #define V1STS 0x0026 /* 16bit */
  124. #define RCTCL 0x0100 /* 32bit */
  125. #define ESD 0x0104 /* 32bit */
  126. #define ULD 0x0110 /* 32bit */
  127. #define ULBA 0x0118 /* 64bit */
  128. #define RP1D 0x0120 /* 32bit */
  129. #define RP1BA 0x0128 /* 64bit */
  130. #define RP2D 0x0130 /* 32bit */
  131. #define RP2BA 0x0138 /* 64bit */
  132. #define RP3D 0x0140 /* 32bit */
  133. #define RP3BA 0x0148 /* 64bit */
  134. #define RP4D 0x0150 /* 32bit */
  135. #define RP4BA 0x0158 /* 64bit */
  136. #define HDD 0x0160 /* 32bit */
  137. #define HDBA 0x0168 /* 64bit */
  138. #define RP5D 0x0170 /* 32bit */
  139. #define RP5BA 0x0178 /* 64bit */
  140. #define RP6D 0x0180 /* 32bit */
  141. #define RP6BA 0x0188 /* 64bit */
  142. #define RPC 0x0400 /* 32bit */
  143. #define RPFN 0x0404 /* 32bit */
  144. #define TRSR 0x1e00 /* 8bit */
  145. #define TRCR 0x1e10 /* 64bit */
  146. #define TWDR 0x1e18 /* 64bit */
  147. #define IOTR0 0x1e80 /* 64bit */
  148. #define IOTR1 0x1e88 /* 64bit */
  149. #define IOTR2 0x1e90 /* 64bit */
  150. #define IOTR3 0x1e98 /* 64bit */
  151. #define TCTL 0x3000 /* 8bit */
  152. #define NOINT 0
  153. #define INTA 1
  154. #define INTB 2
  155. #define INTC 3
  156. #define INTD 4
  157. #define DIR_IDR 12 /* Interrupt D Pin Offset */
  158. #define DIR_ICR 8 /* Interrupt C Pin Offset */
  159. #define DIR_IBR 4 /* Interrupt B Pin Offset */
  160. #define DIR_IAR 0 /* Interrupt A Pin Offset */
  161. #define PIRQA 0
  162. #define PIRQB 1
  163. #define PIRQC 2
  164. #define PIRQD 3
  165. #define PIRQE 4
  166. #define PIRQF 5
  167. #define PIRQG 6
  168. #define PIRQH 7
  169. /* IO Buffer Programming */
  170. #define IOBPIRI 0x2330
  171. #define IOBPD 0x2334
  172. #define IOBPS 0x2338
  173. #define IOBPS_RW_BX ((1 << 9)|(1 << 10))
  174. #define IOBPS_WRITE_AX ((1 << 9)|(1 << 10))
  175. #define IOBPS_READ_AX ((1 << 8)|(1 << 9)|(1 << 10))
  176. #define D31IP 0x3100 /* 32bit */
  177. #define D31IP_TTIP 24 /* Thermal Throttle Pin */
  178. #define D31IP_SIP2 20 /* SATA Pin 2 */
  179. #define D31IP_SMIP 12 /* SMBUS Pin */
  180. #define D31IP_SIP 8 /* SATA Pin */
  181. #define D30IP 0x3104 /* 32bit */
  182. #define D30IP_PIP 0 /* PCI Bridge Pin */
  183. #define D29IP 0x3108 /* 32bit */
  184. #define D29IP_E1P 0 /* EHCI #1 Pin */
  185. #define D28IP 0x310c /* 32bit */
  186. #define D28IP_P8IP 28 /* PCI Express Port 8 */
  187. #define D28IP_P7IP 24 /* PCI Express Port 7 */
  188. #define D28IP_P6IP 20 /* PCI Express Port 6 */
  189. #define D28IP_P5IP 16 /* PCI Express Port 5 */
  190. #define D28IP_P4IP 12 /* PCI Express Port 4 */
  191. #define D28IP_P3IP 8 /* PCI Express Port 3 */
  192. #define D28IP_P2IP 4 /* PCI Express Port 2 */
  193. #define D28IP_P1IP 0 /* PCI Express Port 1 */
  194. #define D27IP 0x3110 /* 32bit */
  195. #define D27IP_ZIP 0 /* HD Audio Pin */
  196. #define D26IP 0x3114 /* 32bit */
  197. #define D26IP_E2P 0 /* EHCI #2 Pin */
  198. #define D25IP 0x3118 /* 32bit */
  199. #define D25IP_LIP 0 /* GbE LAN Pin */
  200. #define D22IP 0x3124 /* 32bit */
  201. #define D22IP_KTIP 12 /* KT Pin */
  202. #define D22IP_IDERIP 8 /* IDE-R Pin */
  203. #define D22IP_MEI2IP 4 /* MEI #2 Pin */
  204. #define D22IP_MEI1IP 0 /* MEI #1 Pin */
  205. #define D20IP 0x3128 /* 32bit */
  206. #define D20IP_XHCIIP 0
  207. #define D31IR 0x3140 /* 16bit */
  208. #define D30IR 0x3142 /* 16bit */
  209. #define D29IR 0x3144 /* 16bit */
  210. #define D28IR 0x3146 /* 16bit */
  211. #define D27IR 0x3148 /* 16bit */
  212. #define D26IR 0x314c /* 16bit */
  213. #define D25IR 0x3150 /* 16bit */
  214. #define D22IR 0x315c /* 16bit */
  215. #define D20IR 0x3160 /* 16bit */
  216. #define OIC 0x31fe /* 16bit */
  217. #define SPI_FREQ_SWSEQ 0x3893
  218. #define SPI_DESC_COMP0 0x38b0
  219. #define SPI_FREQ_WR_ERA 0x38b4
  220. #define DIR_ROUTE(a, b, c, d) \
  221. (((d) << DIR_IDR) | ((c) << DIR_ICR) | \
  222. ((b) << DIR_IBR) | ((a) << DIR_IAR))
  223. #define HPTC 0x3404 /* 32bit */
  224. #define BUC 0x3414 /* 32bit */
  225. #define PCH_DISABLE_GBE (1 << 5)
  226. #define FD 0x3418 /* 32bit */
  227. #define DISPBDF 0x3424 /* 16bit */
  228. #define FD2 0x3428 /* 32bit */
  229. #define CG 0x341c /* 32bit */
  230. /* Function Disable 1 RCBA 0x3418 */
  231. #define PCH_DISABLE_ALWAYS ((1 << 0)|(1 << 26))
  232. #define PCH_DISABLE_P2P (1 << 1)
  233. #define PCH_DISABLE_SATA1 (1 << 2)
  234. #define PCH_DISABLE_SMBUS (1 << 3)
  235. #define PCH_DISABLE_HD_AUDIO (1 << 4)
  236. #define PCH_DISABLE_EHCI2 (1 << 13)
  237. #define PCH_DISABLE_LPC (1 << 14)
  238. #define PCH_DISABLE_EHCI1 (1 << 15)
  239. #define PCH_DISABLE_PCIE(x) (1 << (16 + x))
  240. #define PCH_DISABLE_THERMAL (1 << 24)
  241. #define PCH_DISABLE_SATA2 (1 << 25)
  242. #define PCH_DISABLE_XHCI (1 << 27)
  243. /* Function Disable 2 RCBA 0x3428 */
  244. #define PCH_DISABLE_KT (1 << 4)
  245. #define PCH_DISABLE_IDER (1 << 3)
  246. #define PCH_DISABLE_MEI2 (1 << 2)
  247. #define PCH_DISABLE_MEI1 (1 << 1)
  248. #define PCH_ENABLE_DBDF (1 << 0)
  249. /* ICH7 GPIOBASE */
  250. #define GPIO_USE_SEL 0x00
  251. #define GP_IO_SEL 0x04
  252. #define GP_LVL 0x0c
  253. #define GPO_BLINK 0x18
  254. #define GPI_INV 0x2c
  255. #define GPIO_USE_SEL2 0x30
  256. #define GP_IO_SEL2 0x34
  257. #define GP_LVL2 0x38
  258. #define GPIO_USE_SEL3 0x40
  259. #define GP_IO_SEL3 0x44
  260. #define GP_LVL3 0x48
  261. #define GP_RST_SEL1 0x60
  262. #define GP_RST_SEL2 0x64
  263. #define GP_RST_SEL3 0x68
  264. /* ICH7 PMBASE */
  265. #define PM1_STS 0x00
  266. #define WAK_STS (1 << 15)
  267. #define PCIEXPWAK_STS (1 << 14)
  268. #define PRBTNOR_STS (1 << 11)
  269. #define RTC_STS (1 << 10)
  270. #define PWRBTN_STS (1 << 8)
  271. #define GBL_STS (1 << 5)
  272. #define BM_STS (1 << 4)
  273. #define TMROF_STS (1 << 0)
  274. #define PM1_EN 0x02
  275. #define PCIEXPWAK_DIS (1 << 14)
  276. #define RTC_EN (1 << 10)
  277. #define PWRBTN_EN (1 << 8)
  278. #define GBL_EN (1 << 5)
  279. #define TMROF_EN (1 << 0)
  280. #define PM1_CNT 0x04
  281. #define SLP_EN (1 << 13)
  282. #define SLP_TYP (7 << 10)
  283. #define SLP_TYP_S0 0
  284. #define SLP_TYP_S1 1
  285. #define SLP_TYP_S3 5
  286. #define SLP_TYP_S4 6
  287. #define SLP_TYP_S5 7
  288. #define GBL_RLS (1 << 2)
  289. #define BM_RLD (1 << 1)
  290. #define SCI_EN (1 << 0)
  291. #define PM1_TMR 0x08
  292. #define PROC_CNT 0x10
  293. #define LV2 0x14
  294. #define LV3 0x15
  295. #define LV4 0x16
  296. #define PM2_CNT 0x50 /* mobile only */
  297. #define GPE0_STS 0x20
  298. #define PME_B0_STS (1 << 13)
  299. #define PME_STS (1 << 11)
  300. #define BATLOW_STS (1 << 10)
  301. #define PCI_EXP_STS (1 << 9)
  302. #define RI_STS (1 << 8)
  303. #define SMB_WAK_STS (1 << 7)
  304. #define TCOSCI_STS (1 << 6)
  305. #define SWGPE_STS (1 << 2)
  306. #define HOT_PLUG_STS (1 << 1)
  307. #define GPE0_EN 0x28
  308. #define PME_B0_EN (1 << 13)
  309. #define PME_EN (1 << 11)
  310. #define TCOSCI_EN (1 << 6)
  311. #define SMI_EN 0x30
  312. #define INTEL_USB2_EN (1 << 18) /* Intel-Specific USB2 SMI logic */
  313. #define LEGACY_USB2_EN (1 << 17) /* Legacy USB2 SMI logic */
  314. #define PERIODIC_EN (1 << 14) /* SMI on PERIODIC_STS in SMI_STS */
  315. #define TCO_EN (1 << 13) /* Enable TCO Logic (BIOSWE et al) */
  316. #define MCSMI_EN (1 << 11) /* Trap microcontroller range access */
  317. #define BIOS_RLS (1 << 7) /* asserts SCI on bit set */
  318. #define SWSMI_TMR_EN (1 << 6) /* start software smi timer on bit set */
  319. #define APMC_EN (1 << 5) /* Writes to APM_CNT cause SMI# */
  320. #define SLP_SMI_EN (1 << 4) /* Write SLP_EN in PM1_CNT asserts SMI# */
  321. #define LEGACY_USB_EN (1 << 3) /* Legacy USB circuit SMI logic */
  322. #define BIOS_EN (1 << 2) /* Assert SMI# on setting GBL_RLS bit */
  323. #define EOS (1 << 1) /* End of SMI (deassert SMI#) */
  324. #define GBL_SMI_EN (1 << 0) /* SMI# generation at all? */
  325. #define SMI_STS 0x34
  326. #define ALT_GP_SMI_EN 0x38
  327. #define ALT_GP_SMI_STS 0x3a
  328. #define GPE_CNTL 0x42
  329. #define DEVACT_STS 0x44
  330. #define SS_CNT 0x50
  331. #define C3_RES 0x54
  332. #define TCO1_STS 0x64
  333. #define DMISCI_STS (1 << 9)
  334. #define TCO2_STS 0x66
  335. /**
  336. * pch_silicon_revision() - Read silicon device ID from the PCH
  337. *
  338. * @dev: PCH device
  339. * @return silicon device ID
  340. */
  341. int pch_silicon_type(struct udevice *dev);
  342. /**
  343. * pch_pch_iobp_update() - Update a pch register
  344. *
  345. * @dev: PCH device
  346. * @address: Address to update
  347. * @andvalue: Value to AND with existing value
  348. * @orvalue: Value to OR with existing value
  349. */
  350. void pch_iobp_update(struct udevice *dev, u32 address, u32 andvalue,
  351. u32 orvalue);
  352. #endif