]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/x86/include/asm/arch-ivybridge/pch.h
x86: ivybridge: Add SATA init
[people/ms/u-boot.git] / arch / x86 / include / asm / arch-ivybridge / pch.h
1 /*
2 * Copyright (c) 2014 Google, Inc
3 *
4 * From Coreboot src/southbridge/intel/bd82x6x/pch.h
5 *
6 * Copyright (C) 2008-2009 coresystems GmbH
7 * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
8 *
9 * SPDX-License-Identifier: GPL-2.0
10 */
11
12 #ifndef _ASM_ARCH_PCH_H
13 #define _ASM_ARCH_PCH_H
14
15 #include <pci.h>
16
17 /* PCH types */
18 #define PCH_TYPE_CPT 0x1c /* CougarPoint */
19 #define PCH_TYPE_PPT 0x1e /* IvyBridge */
20
21 /* PCH stepping values for LPC device */
22 #define PCH_STEP_A0 0
23 #define PCH_STEP_A1 1
24 #define PCH_STEP_B0 2
25 #define PCH_STEP_B1 3
26 #define PCH_STEP_B2 4
27 #define PCH_STEP_B3 5
28 #define DEFAULT_GPIOBASE 0x0480
29 #define DEFAULT_PMBASE 0x0500
30
31 #define SMBUS_IO_BASE 0x0400
32
33 int pch_silicon_revision(void);
34 int pch_silicon_type(void);
35 int pch_silicon_supported(int type, int rev);
36 void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue);
37
38 #define MAINBOARD_POWER_OFF 0
39 #define MAINBOARD_POWER_ON 1
40 #define MAINBOARD_POWER_KEEP 2
41
42 /* PCI Configuration Space (D30:F0): PCI2PCI */
43 #define PSTS 0x06
44 #define SMLT 0x1b
45 #define SECSTS 0x1e
46 #define INTR 0x3c
47 #define BCTRL 0x3e
48 #define SBR (1 << 6)
49 #define SEE (1 << 1)
50 #define PERE (1 << 0)
51
52 #define PCH_EHCI1_DEV PCI_BDF(0, 0x1d, 0)
53 #define PCH_EHCI2_DEV PCI_BDF(0, 0x1a, 0)
54 #define PCH_XHCI_DEV PCI_BDF(0, 0x14, 0)
55 #define PCH_ME_DEV PCI_BDF(0, 0x16, 0)
56 #define PCH_PCIE_DEV_SLOT 28
57
58 #define PCH_DEV PCI_BDF(0, 0, 0)
59 #define PCH_VIDEO_DEV PCI_BDF(0, 2, 0)
60
61 /* PCI Configuration Space (D31:F0): LPC */
62 #define PCH_LPC_DEV PCI_BDF(0, 0x1f, 0)
63 #define SERIRQ_CNTL 0x64
64
65 #define GEN_PMCON_1 0xa0
66 #define GEN_PMCON_2 0xa2
67 #define GEN_PMCON_3 0xa4
68 #define ETR3 0xac
69 #define ETR3_CWORWRE (1 << 18)
70 #define ETR3_CF9GR (1 << 20)
71
72 /* GEN_PMCON_3 bits */
73 #define RTC_BATTERY_DEAD (1 << 2)
74 #define RTC_POWER_FAILED (1 << 1)
75 #define SLEEP_AFTER_POWER_FAIL (1 << 0)
76
77 #define PMBASE 0x40
78 #define ACPI_CNTL 0x44
79 #define BIOS_CNTL 0xDC
80 #define GPIO_BASE 0x48 /* LPC GPIO Base Address Register */
81 #define GPIO_CNTL 0x4C /* LPC GPIO Control Register */
82 #define GPIO_ROUT 0xb8
83
84 #define PIRQA_ROUT 0x60
85 #define PIRQB_ROUT 0x61
86 #define PIRQC_ROUT 0x62
87 #define PIRQD_ROUT 0x63
88 #define PIRQE_ROUT 0x68
89 #define PIRQF_ROUT 0x69
90 #define PIRQG_ROUT 0x6A
91 #define PIRQH_ROUT 0x6B
92
93 #define GEN_PMCON_1 0xa0
94 #define GEN_PMCON_2 0xa2
95 #define GEN_PMCON_3 0xa4
96 #define ETR3 0xac
97 #define ETR3_CWORWRE (1 << 18)
98 #define ETR3_CF9GR (1 << 20)
99
100 #define PMBASE 0x40
101 #define ACPI_CNTL 0x44
102 #define BIOS_CNTL 0xDC
103 #define GPIO_BASE 0x48 /* LPC GPIO Base Address Register */
104 #define GPIO_CNTL 0x4C /* LPC GPIO Control Register */
105 #define GPIO_ROUT 0xb8
106
107 #define LPC_IO_DEC 0x80 /* IO Decode Ranges Register */
108 #define LPC_EN 0x82 /* LPC IF Enables Register */
109 #define CNF2_LPC_EN (1 << 13) /* 0x4e/0x4f */
110 #define CNF1_LPC_EN (1 << 12) /* 0x2e/0x2f */
111 #define MC_LPC_EN (1 << 11) /* 0x62/0x66 */
112 #define KBC_LPC_EN (1 << 10) /* 0x60/0x64 */
113 #define GAMEH_LPC_EN (1 << 9) /* 0x208/0x20f */
114 #define GAMEL_LPC_EN (1 << 8) /* 0x200/0x207 */
115 #define FDD_LPC_EN (1 << 3) /* LPC_IO_DEC[12] */
116 #define LPT_LPC_EN (1 << 2) /* LPC_IO_DEC[9:8] */
117 #define COMB_LPC_EN (1 << 1) /* LPC_IO_DEC[6:4] */
118 #define COMA_LPC_EN (1 << 0) /* LPC_IO_DEC[3:2] */
119 #define LPC_GEN1_DEC 0x84 /* LPC IF Generic Decode Range 1 */
120 #define LPC_GEN2_DEC 0x88 /* LPC IF Generic Decode Range 2 */
121 #define LPC_GEN3_DEC 0x8c /* LPC IF Generic Decode Range 3 */
122 #define LPC_GEN4_DEC 0x90 /* LPC IF Generic Decode Range 4 */
123 #define LPC_GENX_DEC(x) (0x84 + 4 * (x))
124
125 /* PCI Configuration Space (D31:F1): IDE */
126 #define PCH_IDE_DEV PCI_BDF(0, 0x1f, 1)
127 #define PCH_SATA_DEV PCI_BDF(0, 0x1f, 2)
128 #define PCH_SATA2_DEV PCI_BDF(0, 0x1f, 5)
129
130 #define INTR_LN 0x3c
131 #define IDE_TIM_PRI 0x40 /* IDE timings, primary */
132 #define IDE_DECODE_ENABLE (1 << 15)
133 #define IDE_SITRE (1 << 14)
134 #define IDE_ISP_5_CLOCKS (0 << 12)
135 #define IDE_ISP_4_CLOCKS (1 << 12)
136 #define IDE_ISP_3_CLOCKS (2 << 12)
137 #define IDE_RCT_4_CLOCKS (0 << 8)
138 #define IDE_RCT_3_CLOCKS (1 << 8)
139 #define IDE_RCT_2_CLOCKS (2 << 8)
140 #define IDE_RCT_1_CLOCKS (3 << 8)
141 #define IDE_DTE1 (1 << 7)
142 #define IDE_PPE1 (1 << 6)
143 #define IDE_IE1 (1 << 5)
144 #define IDE_TIME1 (1 << 4)
145 #define IDE_DTE0 (1 << 3)
146 #define IDE_PPE0 (1 << 2)
147 #define IDE_IE0 (1 << 1)
148 #define IDE_TIME0 (1 << 0)
149 #define IDE_TIM_SEC 0x42 /* IDE timings, secondary */
150
151 #define IDE_SDMA_CNT 0x48 /* Synchronous DMA control */
152 #define IDE_SSDE1 (1 << 3)
153 #define IDE_SSDE0 (1 << 2)
154 #define IDE_PSDE1 (1 << 1)
155 #define IDE_PSDE0 (1 << 0)
156
157 #define IDE_SDMA_TIM 0x4a
158
159 #define IDE_CONFIG 0x54 /* IDE I/O Configuration Register */
160 #define SIG_MODE_SEC_NORMAL (0 << 18)
161 #define SIG_MODE_SEC_TRISTATE (1 << 18)
162 #define SIG_MODE_SEC_DRIVELOW (2 << 18)
163 #define SIG_MODE_PRI_NORMAL (0 << 16)
164 #define SIG_MODE_PRI_TRISTATE (1 << 16)
165 #define SIG_MODE_PRI_DRIVELOW (2 << 16)
166 #define FAST_SCB1 (1 << 15)
167 #define FAST_SCB0 (1 << 14)
168 #define FAST_PCB1 (1 << 13)
169 #define FAST_PCB0 (1 << 12)
170 #define SCB1 (1 << 3)
171 #define SCB0 (1 << 2)
172 #define PCB1 (1 << 1)
173 #define PCB0 (1 << 0)
174
175 #define SATA_SIRI 0xa0 /* SATA Indexed Register Index */
176 #define SATA_SIRD 0xa4 /* SATA Indexed Register Data */
177 #define SATA_SP 0xd0 /* Scratchpad */
178
179 /* SATA IOBP Registers */
180 #define SATA_IOBP_SP0G3IR 0xea000151
181 #define SATA_IOBP_SP1G3IR 0xea000051
182
183 /* PCI Configuration Space (D31:F3): SMBus */
184 #define PCH_SMBUS_DEV PCI_BDF(0, 0x1f, 3)
185 #define SMB_BASE 0x20
186 #define HOSTC 0x40
187 #define SMB_RCV_SLVA 0x09
188
189 /* HOSTC bits */
190 #define I2C_EN (1 << 2)
191 #define SMB_SMI_EN (1 << 1)
192 #define HST_EN (1 << 0)
193
194 /* SMBus I/O bits. */
195 #define SMBHSTSTAT 0x0
196 #define SMBHSTCTL 0x2
197 #define SMBHSTCMD 0x3
198 #define SMBXMITADD 0x4
199 #define SMBHSTDAT0 0x5
200 #define SMBHSTDAT1 0x6
201 #define SMBBLKDAT 0x7
202 #define SMBTRNSADD 0x9
203 #define SMBSLVDATA 0xa
204 #define SMLINK_PIN_CTL 0xe
205 #define SMBUS_PIN_CTL 0xf
206
207 #define SMBUS_TIMEOUT (10 * 1000 * 100)
208
209
210 /* Root Complex Register Block */
211 #define DEFAULT_RCBA 0xfed1c000
212 #define RCB_REG(reg) (DEFAULT_RCBA + (reg))
213
214 #define PCH_RCBA_BASE 0xf0
215
216 #define VCH 0x0000 /* 32bit */
217 #define VCAP1 0x0004 /* 32bit */
218 #define VCAP2 0x0008 /* 32bit */
219 #define PVC 0x000c /* 16bit */
220 #define PVS 0x000e /* 16bit */
221
222 #define V0CAP 0x0010 /* 32bit */
223 #define V0CTL 0x0014 /* 32bit */
224 #define V0STS 0x001a /* 16bit */
225
226 #define V1CAP 0x001c /* 32bit */
227 #define V1CTL 0x0020 /* 32bit */
228 #define V1STS 0x0026 /* 16bit */
229
230 #define RCTCL 0x0100 /* 32bit */
231 #define ESD 0x0104 /* 32bit */
232 #define ULD 0x0110 /* 32bit */
233 #define ULBA 0x0118 /* 64bit */
234
235 #define RP1D 0x0120 /* 32bit */
236 #define RP1BA 0x0128 /* 64bit */
237 #define RP2D 0x0130 /* 32bit */
238 #define RP2BA 0x0138 /* 64bit */
239 #define RP3D 0x0140 /* 32bit */
240 #define RP3BA 0x0148 /* 64bit */
241 #define RP4D 0x0150 /* 32bit */
242 #define RP4BA 0x0158 /* 64bit */
243 #define HDD 0x0160 /* 32bit */
244 #define HDBA 0x0168 /* 64bit */
245 #define RP5D 0x0170 /* 32bit */
246 #define RP5BA 0x0178 /* 64bit */
247 #define RP6D 0x0180 /* 32bit */
248 #define RP6BA 0x0188 /* 64bit */
249
250 #define RPC 0x0400 /* 32bit */
251 #define RPFN 0x0404 /* 32bit */
252
253 #define TRSR 0x1e00 /* 8bit */
254 #define TRCR 0x1e10 /* 64bit */
255 #define TWDR 0x1e18 /* 64bit */
256
257 #define IOTR0 0x1e80 /* 64bit */
258 #define IOTR1 0x1e88 /* 64bit */
259 #define IOTR2 0x1e90 /* 64bit */
260 #define IOTR3 0x1e98 /* 64bit */
261
262 #define TCTL 0x3000 /* 8bit */
263
264 #define NOINT 0
265 #define INTA 1
266 #define INTB 2
267 #define INTC 3
268 #define INTD 4
269
270 #define DIR_IDR 12 /* Interrupt D Pin Offset */
271 #define DIR_ICR 8 /* Interrupt C Pin Offset */
272 #define DIR_IBR 4 /* Interrupt B Pin Offset */
273 #define DIR_IAR 0 /* Interrupt A Pin Offset */
274
275 #define PIRQA 0
276 #define PIRQB 1
277 #define PIRQC 2
278 #define PIRQD 3
279 #define PIRQE 4
280 #define PIRQF 5
281 #define PIRQG 6
282 #define PIRQH 7
283
284 /* IO Buffer Programming */
285 #define IOBPIRI 0x2330
286 #define IOBPD 0x2334
287 #define IOBPS 0x2338
288 #define IOBPS_RW_BX ((1 << 9)|(1 << 10))
289 #define IOBPS_WRITE_AX ((1 << 9)|(1 << 10))
290 #define IOBPS_READ_AX ((1 << 8)|(1 << 9)|(1 << 10))
291
292 #define D31IP 0x3100 /* 32bit */
293 #define D31IP_TTIP 24 /* Thermal Throttle Pin */
294 #define D31IP_SIP2 20 /* SATA Pin 2 */
295 #define D31IP_SMIP 12 /* SMBUS Pin */
296 #define D31IP_SIP 8 /* SATA Pin */
297 #define D30IP 0x3104 /* 32bit */
298 #define D30IP_PIP 0 /* PCI Bridge Pin */
299 #define D29IP 0x3108 /* 32bit */
300 #define D29IP_E1P 0 /* EHCI #1 Pin */
301 #define D28IP 0x310c /* 32bit */
302 #define D28IP_P8IP 28 /* PCI Express Port 8 */
303 #define D28IP_P7IP 24 /* PCI Express Port 7 */
304 #define D28IP_P6IP 20 /* PCI Express Port 6 */
305 #define D28IP_P5IP 16 /* PCI Express Port 5 */
306 #define D28IP_P4IP 12 /* PCI Express Port 4 */
307 #define D28IP_P3IP 8 /* PCI Express Port 3 */
308 #define D28IP_P2IP 4 /* PCI Express Port 2 */
309 #define D28IP_P1IP 0 /* PCI Express Port 1 */
310 #define D27IP 0x3110 /* 32bit */
311 #define D27IP_ZIP 0 /* HD Audio Pin */
312 #define D26IP 0x3114 /* 32bit */
313 #define D26IP_E2P 0 /* EHCI #2 Pin */
314 #define D25IP 0x3118 /* 32bit */
315 #define D25IP_LIP 0 /* GbE LAN Pin */
316 #define D22IP 0x3124 /* 32bit */
317 #define D22IP_KTIP 12 /* KT Pin */
318 #define D22IP_IDERIP 8 /* IDE-R Pin */
319 #define D22IP_MEI2IP 4 /* MEI #2 Pin */
320 #define D22IP_MEI1IP 0 /* MEI #1 Pin */
321 #define D20IP 0x3128 /* 32bit */
322 #define D20IP_XHCIIP 0
323 #define D31IR 0x3140 /* 16bit */
324 #define D30IR 0x3142 /* 16bit */
325 #define D29IR 0x3144 /* 16bit */
326 #define D28IR 0x3146 /* 16bit */
327 #define D27IR 0x3148 /* 16bit */
328 #define D26IR 0x314c /* 16bit */
329 #define D25IR 0x3150 /* 16bit */
330 #define D22IR 0x315c /* 16bit */
331 #define D20IR 0x3160 /* 16bit */
332 #define OIC 0x31fe /* 16bit */
333
334 #define SPI_FREQ_SWSEQ 0x3893
335 #define SPI_DESC_COMP0 0x38b0
336 #define SPI_FREQ_WR_ERA 0x38b4
337 #define SOFT_RESET_CTRL 0x38f4
338 #define SOFT_RESET_DATA 0x38f8
339
340 #define DIR_ROUTE(a, b, c, d) \
341 (((d) << DIR_IDR) | ((c) << DIR_ICR) | \
342 ((b) << DIR_IBR) | ((a) << DIR_IAR))
343
344 #define RC 0x3400 /* 32bit */
345 #define HPTC 0x3404 /* 32bit */
346 #define GCS 0x3410 /* 32bit */
347 #define BUC 0x3414 /* 32bit */
348 #define PCH_DISABLE_GBE (1 << 5)
349 #define FD 0x3418 /* 32bit */
350 #define DISPBDF 0x3424 /* 16bit */
351 #define FD2 0x3428 /* 32bit */
352 #define CG 0x341c /* 32bit */
353
354 /* Function Disable 1 RCBA 0x3418 */
355 #define PCH_DISABLE_ALWAYS ((1 << 0)|(1 << 26))
356 #define PCH_DISABLE_P2P (1 << 1)
357 #define PCH_DISABLE_SATA1 (1 << 2)
358 #define PCH_DISABLE_SMBUS (1 << 3)
359 #define PCH_DISABLE_HD_AUDIO (1 << 4)
360 #define PCH_DISABLE_EHCI2 (1 << 13)
361 #define PCH_DISABLE_LPC (1 << 14)
362 #define PCH_DISABLE_EHCI1 (1 << 15)
363 #define PCH_DISABLE_PCIE(x) (1 << (16 + x))
364 #define PCH_DISABLE_THERMAL (1 << 24)
365 #define PCH_DISABLE_SATA2 (1 << 25)
366 #define PCH_DISABLE_XHCI (1 << 27)
367
368 /* Function Disable 2 RCBA 0x3428 */
369 #define PCH_DISABLE_KT (1 << 4)
370 #define PCH_DISABLE_IDER (1 << 3)
371 #define PCH_DISABLE_MEI2 (1 << 2)
372 #define PCH_DISABLE_MEI1 (1 << 1)
373 #define PCH_ENABLE_DBDF (1 << 0)
374
375 /* ICH7 GPIOBASE */
376 #define GPIO_USE_SEL 0x00
377 #define GP_IO_SEL 0x04
378 #define GP_LVL 0x0c
379 #define GPO_BLINK 0x18
380 #define GPI_INV 0x2c
381 #define GPIO_USE_SEL2 0x30
382 #define GP_IO_SEL2 0x34
383 #define GP_LVL2 0x38
384 #define GPIO_USE_SEL3 0x40
385 #define GP_IO_SEL3 0x44
386 #define GP_LVL3 0x48
387 #define GP_RST_SEL1 0x60
388 #define GP_RST_SEL2 0x64
389 #define GP_RST_SEL3 0x68
390
391 /* ICH7 PMBASE */
392 #define PM1_STS 0x00
393 #define WAK_STS (1 << 15)
394 #define PCIEXPWAK_STS (1 << 14)
395 #define PRBTNOR_STS (1 << 11)
396 #define RTC_STS (1 << 10)
397 #define PWRBTN_STS (1 << 8)
398 #define GBL_STS (1 << 5)
399 #define BM_STS (1 << 4)
400 #define TMROF_STS (1 << 0)
401 #define PM1_EN 0x02
402 #define PCIEXPWAK_DIS (1 << 14)
403 #define RTC_EN (1 << 10)
404 #define PWRBTN_EN (1 << 8)
405 #define GBL_EN (1 << 5)
406 #define TMROF_EN (1 << 0)
407 #define PM1_CNT 0x04
408 #define SLP_EN (1 << 13)
409 #define SLP_TYP (7 << 10)
410 #define SLP_TYP_S0 0
411 #define SLP_TYP_S1 1
412 #define SLP_TYP_S3 5
413 #define SLP_TYP_S4 6
414 #define SLP_TYP_S5 7
415 #define GBL_RLS (1 << 2)
416 #define BM_RLD (1 << 1)
417 #define SCI_EN (1 << 0)
418 #define PM1_TMR 0x08
419 #define PROC_CNT 0x10
420 #define LV2 0x14
421 #define LV3 0x15
422 #define LV4 0x16
423 #define PM2_CNT 0x50 /* mobile only */
424 #define GPE0_STS 0x20
425 #define PME_B0_STS (1 << 13)
426 #define PME_STS (1 << 11)
427 #define BATLOW_STS (1 << 10)
428 #define PCI_EXP_STS (1 << 9)
429 #define RI_STS (1 << 8)
430 #define SMB_WAK_STS (1 << 7)
431 #define TCOSCI_STS (1 << 6)
432 #define SWGPE_STS (1 << 2)
433 #define HOT_PLUG_STS (1 << 1)
434 #define GPE0_EN 0x28
435 #define PME_B0_EN (1 << 13)
436 #define PME_EN (1 << 11)
437 #define TCOSCI_EN (1 << 6)
438 #define SMI_EN 0x30
439 #define INTEL_USB2_EN (1 << 18) /* Intel-Specific USB2 SMI logic */
440 #define LEGACY_USB2_EN (1 << 17) /* Legacy USB2 SMI logic */
441 #define PERIODIC_EN (1 << 14) /* SMI on PERIODIC_STS in SMI_STS */
442 #define TCO_EN (1 << 13) /* Enable TCO Logic (BIOSWE et al) */
443 #define MCSMI_EN (1 << 11) /* Trap microcontroller range access */
444 #define BIOS_RLS (1 << 7) /* asserts SCI on bit set */
445 #define SWSMI_TMR_EN (1 << 6) /* start software smi timer on bit set */
446 #define APMC_EN (1 << 5) /* Writes to APM_CNT cause SMI# */
447 #define SLP_SMI_EN (1 << 4) /* Write SLP_EN in PM1_CNT asserts SMI# */
448 #define LEGACY_USB_EN (1 << 3) /* Legacy USB circuit SMI logic */
449 #define BIOS_EN (1 << 2) /* Assert SMI# on setting GBL_RLS bit */
450 #define EOS (1 << 1) /* End of SMI (deassert SMI#) */
451 #define GBL_SMI_EN (1 << 0) /* SMI# generation at all? */
452 #define SMI_STS 0x34
453 #define ALT_GP_SMI_EN 0x38
454 #define ALT_GP_SMI_STS 0x3a
455 #define GPE_CNTL 0x42
456 #define DEVACT_STS 0x44
457 #define SS_CNT 0x50
458 #define C3_RES 0x54
459 #define TCO1_STS 0x64
460 #define DMISCI_STS (1 << 9)
461 #define TCO2_STS 0x66
462
463 int lpc_init(struct pci_controller *hose, pci_dev_t dev);
464 void lpc_enable(pci_dev_t dev);
465
466 /**
467 * lpc_early_init() - set up LPC serial ports and other early things
468 *
469 * @blob: Device tree blob
470 * @node: Offset of LPC node
471 * @dev: PCH PCI device containing the LPC
472 * @return 0 if OK, -ve on error
473 */
474 int lpc_early_init(const void *blob, int node, pci_dev_t dev);
475
476 #endif