lpc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. /*
  2. * From coreboot southbridge/intel/bd82x6x/lpc.c
  3. *
  4. * Copyright (C) 2008-2009 coresystems GmbH
  5. *
  6. * SPDX-License-Identifier: GPL-2.0
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <errno.h>
  11. #include <fdtdec.h>
  12. #include <rtc.h>
  13. #include <pci.h>
  14. #include <asm/acpi.h>
  15. #include <asm/interrupt.h>
  16. #include <asm/io.h>
  17. #include <asm/ioapic.h>
  18. #include <asm/pci.h>
  19. #include <asm/arch/pch.h>
  20. #define NMI_OFF 0
  21. #define ENABLE_ACPI_MODE_IN_COREBOOT 0
  22. #define TEST_SMM_FLASH_LOCKDOWN 0
  23. static int pch_enable_apic(pci_dev_t dev)
  24. {
  25. u32 reg32;
  26. int i;
  27. /* Enable ACPI I/O and power management. Set SCI IRQ to IRQ9 */
  28. x86_pci_write_config8(dev, ACPI_CNTL, 0x80);
  29. writel(0, IO_APIC_INDEX);
  30. writel(1 << 25, IO_APIC_DATA);
  31. /* affirm full set of redirection table entries ("write once") */
  32. writel(1, IO_APIC_INDEX);
  33. reg32 = readl(IO_APIC_DATA);
  34. writel(1, IO_APIC_INDEX);
  35. writel(reg32, IO_APIC_DATA);
  36. writel(0, IO_APIC_INDEX);
  37. reg32 = readl(IO_APIC_DATA);
  38. debug("PCH APIC ID = %x\n", (reg32 >> 24) & 0x0f);
  39. if (reg32 != (1 << 25)) {
  40. printf("APIC Error - cannot write to registers\n");
  41. return -EPERM;
  42. }
  43. debug("Dumping IOAPIC registers\n");
  44. for (i = 0; i < 3; i++) {
  45. writel(i, IO_APIC_INDEX);
  46. debug(" reg 0x%04x:", i);
  47. reg32 = readl(IO_APIC_DATA);
  48. debug(" 0x%08x\n", reg32);
  49. }
  50. /* Select Boot Configuration register. */
  51. writel(3, IO_APIC_INDEX);
  52. /* Use Processor System Bus to deliver interrupts. */
  53. writel(1, IO_APIC_DATA);
  54. return 0;
  55. }
  56. static void pch_enable_serial_irqs(pci_dev_t dev)
  57. {
  58. u32 value;
  59. /* Set packet length and toggle silent mode bit for one frame. */
  60. value = (1 << 7) | (1 << 6) | ((21 - 17) << 2) | (0 << 0);
  61. #ifdef CONFIG_SERIRQ_CONTINUOUS_MODE
  62. x86_pci_write_config8(dev, SERIRQ_CNTL, value);
  63. #else
  64. x86_pci_write_config8(dev, SERIRQ_CNTL, value | (1 << 6));
  65. #endif
  66. }
  67. static int pch_pirq_init(const void *blob, int node, pci_dev_t dev)
  68. {
  69. uint8_t route[8], *ptr;
  70. if (fdtdec_get_byte_array(blob, node, "intel,pirq-routing", route,
  71. sizeof(route)))
  72. return -EINVAL;
  73. ptr = route;
  74. x86_pci_write_config8(dev, PIRQA_ROUT, *ptr++);
  75. x86_pci_write_config8(dev, PIRQB_ROUT, *ptr++);
  76. x86_pci_write_config8(dev, PIRQC_ROUT, *ptr++);
  77. x86_pci_write_config8(dev, PIRQD_ROUT, *ptr++);
  78. x86_pci_write_config8(dev, PIRQE_ROUT, *ptr++);
  79. x86_pci_write_config8(dev, PIRQF_ROUT, *ptr++);
  80. x86_pci_write_config8(dev, PIRQG_ROUT, *ptr++);
  81. x86_pci_write_config8(dev, PIRQH_ROUT, *ptr++);
  82. /*
  83. * TODO(sjg@chromium.org): U-Boot does not set up the interrupts
  84. * here. It's unclear if it is needed
  85. */
  86. return 0;
  87. }
  88. static int pch_gpi_routing(const void *blob, int node, pci_dev_t dev)
  89. {
  90. u8 route[16];
  91. u32 reg;
  92. int gpi;
  93. if (fdtdec_get_byte_array(blob, node, "intel,gpi-routing", route,
  94. sizeof(route)))
  95. return -EINVAL;
  96. for (reg = 0, gpi = 0; gpi < ARRAY_SIZE(route); gpi++)
  97. reg |= route[gpi] << (gpi * 2);
  98. x86_pci_write_config32(dev, 0xb8, reg);
  99. return 0;
  100. }
  101. static int pch_power_options(const void *blob, int node, pci_dev_t dev)
  102. {
  103. u8 reg8;
  104. u16 reg16, pmbase;
  105. u32 reg32;
  106. const char *state;
  107. int pwr_on;
  108. int nmi_option;
  109. int ret;
  110. /*
  111. * Which state do we want to goto after g3 (power restored)?
  112. * 0 == S0 Full On
  113. * 1 == S5 Soft Off
  114. *
  115. * If the option is not existent (Laptops), use Kconfig setting.
  116. * TODO(sjg@chromium.org): Make this configurable
  117. */
  118. pwr_on = MAINBOARD_POWER_ON;
  119. reg16 = x86_pci_read_config16(dev, GEN_PMCON_3);
  120. reg16 &= 0xfffe;
  121. switch (pwr_on) {
  122. case MAINBOARD_POWER_OFF:
  123. reg16 |= 1;
  124. state = "off";
  125. break;
  126. case MAINBOARD_POWER_ON:
  127. reg16 &= ~1;
  128. state = "on";
  129. break;
  130. case MAINBOARD_POWER_KEEP:
  131. reg16 &= ~1;
  132. state = "state keep";
  133. break;
  134. default:
  135. state = "undefined";
  136. }
  137. reg16 &= ~(3 << 4); /* SLP_S4# Assertion Stretch 4s */
  138. reg16 |= (1 << 3); /* SLP_S4# Assertion Stretch Enable */
  139. reg16 &= ~(1 << 10);
  140. reg16 |= (1 << 11); /* SLP_S3# Min Assertion Width 50ms */
  141. reg16 |= (1 << 12); /* Disable SLP stretch after SUS well */
  142. x86_pci_write_config16(dev, GEN_PMCON_3, reg16);
  143. debug("Set power %s after power failure.\n", state);
  144. /* Set up NMI on errors. */
  145. reg8 = inb(0x61);
  146. reg8 &= 0x0f; /* Higher Nibble must be 0 */
  147. reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */
  148. reg8 |= (1 << 2); /* PCI SERR# Disable for now */
  149. outb(reg8, 0x61);
  150. reg8 = inb(0x70);
  151. /* TODO(sjg@chromium.org): Make this configurable */
  152. nmi_option = NMI_OFF;
  153. if (nmi_option) {
  154. debug("NMI sources enabled.\n");
  155. reg8 &= ~(1 << 7); /* Set NMI. */
  156. } else {
  157. debug("NMI sources disabled.\n");
  158. /* Can't mask NMI from PCI-E and NMI_NOW */
  159. reg8 |= (1 << 7);
  160. }
  161. outb(reg8, 0x70);
  162. /* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */
  163. reg16 = x86_pci_read_config16(dev, GEN_PMCON_1);
  164. reg16 &= ~(3 << 0); /* SMI# rate 1 minute */
  165. reg16 &= ~(1 << 10); /* Disable BIOS_PCI_EXP_EN for native PME */
  166. #if DEBUG_PERIODIC_SMIS
  167. /* Set DEBUG_PERIODIC_SMIS in pch.h to debug using periodic SMIs */
  168. reg16 |= (3 << 0); /* Periodic SMI every 8s */
  169. #endif
  170. x86_pci_write_config16(dev, GEN_PMCON_1, reg16);
  171. /* Set the board's GPI routing. */
  172. ret = pch_gpi_routing(blob, node, dev);
  173. if (ret)
  174. return ret;
  175. pmbase = x86_pci_read_config16(dev, 0x40) & 0xfffe;
  176. writel(pmbase + GPE0_EN, fdtdec_get_int(blob, node,
  177. "intel,gpe0-enable", 0));
  178. writew(pmbase + ALT_GP_SMI_EN, fdtdec_get_int(blob, node,
  179. "intel,alt-gp-smi-enable", 0));
  180. /* Set up power management block and determine sleep mode */
  181. reg32 = inl(pmbase + 0x04); /* PM1_CNT */
  182. reg32 &= ~(7 << 10); /* SLP_TYP */
  183. reg32 |= (1 << 0); /* SCI_EN */
  184. outl(reg32, pmbase + 0x04);
  185. /* Clear magic status bits to prevent unexpected wake */
  186. setbits_le32(RCB_REG(0x3310), (1 << 4) | (1 << 5) | (1 << 0));
  187. clrbits_le32(RCB_REG(0x3f02), 0xf);
  188. return 0;
  189. }
  190. static void pch_rtc_init(pci_dev_t dev)
  191. {
  192. int rtc_failed;
  193. u8 reg8;
  194. reg8 = x86_pci_read_config8(dev, GEN_PMCON_3);
  195. rtc_failed = reg8 & RTC_BATTERY_DEAD;
  196. if (rtc_failed) {
  197. reg8 &= ~RTC_BATTERY_DEAD;
  198. x86_pci_write_config8(dev, GEN_PMCON_3, reg8);
  199. }
  200. debug("rtc_failed = 0x%x\n", rtc_failed);
  201. #if CONFIG_HAVE_ACPI_RESUME
  202. /* Avoid clearing pending interrupts and resetting the RTC control
  203. * register in the resume path because the Linux kernel relies on
  204. * this to know if it should restart the RTC timerqueue if the wake
  205. * was due to the RTC alarm.
  206. */
  207. if (acpi_get_slp_type() == 3)
  208. return;
  209. #endif
  210. /* TODO: Handle power failure */
  211. if (rtc_failed)
  212. printf("RTC power failed\n");
  213. rtc_init();
  214. }
  215. /* CougarPoint PCH Power Management init */
  216. static void cpt_pm_init(pci_dev_t dev)
  217. {
  218. debug("CougarPoint PM init\n");
  219. x86_pci_write_config8(dev, 0xa9, 0x47);
  220. setbits_le32(RCB_REG(0x2238), (1 << 6) | (1 << 0));
  221. setbits_le32(RCB_REG(0x228c), 1 << 0);
  222. setbits_le32(RCB_REG(0x1100), (1 << 13) | (1 << 14));
  223. setbits_le32(RCB_REG(0x0900), 1 << 14);
  224. writel(0xc0388400, RCB_REG(0x2304));
  225. setbits_le32(RCB_REG(0x2314), (1 << 5) | (1 << 18));
  226. setbits_le32(RCB_REG(0x2320), (1 << 15) | (1 << 1));
  227. clrsetbits_le32(RCB_REG(0x3314), ~0x1f, 0xf);
  228. writel(0x050f0000, RCB_REG(0x3318));
  229. writel(0x04000000, RCB_REG(0x3324));
  230. setbits_le32(RCB_REG(0x3340), 0xfffff);
  231. setbits_le32(RCB_REG(0x3344), 1 << 1);
  232. writel(0x0001c000, RCB_REG(0x3360));
  233. writel(0x00061100, RCB_REG(0x3368));
  234. writel(0x7f8fdfff, RCB_REG(0x3378));
  235. writel(0x000003fc, RCB_REG(0x337c));
  236. writel(0x00001000, RCB_REG(0x3388));
  237. writel(0x0001c000, RCB_REG(0x3390));
  238. writel(0x00000800, RCB_REG(0x33a0));
  239. writel(0x00001000, RCB_REG(0x33b0));
  240. writel(0x00093900, RCB_REG(0x33c0));
  241. writel(0x24653002, RCB_REG(0x33cc));
  242. writel(0x062108fe, RCB_REG(0x33d0));
  243. clrsetbits_le32(RCB_REG(0x33d4), 0x0fff0fff, 0x00670060);
  244. writel(0x01010000, RCB_REG(0x3a28));
  245. writel(0x01010404, RCB_REG(0x3a2c));
  246. writel(0x01041041, RCB_REG(0x3a80));
  247. clrsetbits_le32(RCB_REG(0x3a84), 0x0000ffff, 0x00001001);
  248. setbits_le32(RCB_REG(0x3a84), 1 << 24); /* SATA 2/3 disabled */
  249. setbits_le32(RCB_REG(0x3a88), 1 << 0); /* SATA 4/5 disabled */
  250. writel(0x00000001, RCB_REG(0x3a6c));
  251. clrsetbits_le32(RCB_REG(0x2344), ~0x00ffff00, 0xff00000c);
  252. clrsetbits_le32(RCB_REG(0x80c), 0xff << 20, 0x11 << 20);
  253. writel(0, RCB_REG(0x33c8));
  254. setbits_le32(RCB_REG(0x21b0), 0xf);
  255. }
  256. /* PantherPoint PCH Power Management init */
  257. static void ppt_pm_init(pci_dev_t dev)
  258. {
  259. debug("PantherPoint PM init\n");
  260. x86_pci_write_config8(dev, 0xa9, 0x47);
  261. setbits_le32(RCB_REG(0x2238), 1 << 0);
  262. setbits_le32(RCB_REG(0x228c), 1 << 0);
  263. setbits_le16(RCB_REG(0x1100), (1 << 13) | (1 << 14));
  264. setbits_le16(RCB_REG(0x0900), 1 << 14);
  265. writel(0xc03b8400, RCB_REG(0x2304));
  266. setbits_le32(RCB_REG(0x2314), (1 << 5) | (1 << 18));
  267. setbits_le32(RCB_REG(0x2320), (1 << 15) | (1 << 1));
  268. clrsetbits_le32(RCB_REG(0x3314), 0x1f, 0xf);
  269. writel(0x054f0000, RCB_REG(0x3318));
  270. writel(0x04000000, RCB_REG(0x3324));
  271. setbits_le32(RCB_REG(0x3340), 0xfffff);
  272. setbits_le32(RCB_REG(0x3344), (1 << 1) | (1 << 0));
  273. writel(0x0001c000, RCB_REG(0x3360));
  274. writel(0x00061100, RCB_REG(0x3368));
  275. writel(0x7f8fdfff, RCB_REG(0x3378));
  276. writel(0x000003fd, RCB_REG(0x337c));
  277. writel(0x00001000, RCB_REG(0x3388));
  278. writel(0x0001c000, RCB_REG(0x3390));
  279. writel(0x00000800, RCB_REG(0x33a0));
  280. writel(0x00001000, RCB_REG(0x33b0));
  281. writel(0x00093900, RCB_REG(0x33c0));
  282. writel(0x24653002, RCB_REG(0x33cc));
  283. writel(0x067388fe, RCB_REG(0x33d0));
  284. clrsetbits_le32(RCB_REG(0x33d4), 0x0fff0fff, 0x00670060);
  285. writel(0x01010000, RCB_REG(0x3a28));
  286. writel(0x01010404, RCB_REG(0x3a2c));
  287. writel(0x01040000, RCB_REG(0x3a80));
  288. clrsetbits_le32(RCB_REG(0x3a84), 0x0000ffff, 0x00001001);
  289. /* SATA 2/3 disabled */
  290. setbits_le32(RCB_REG(0x3a84), 1 << 24);
  291. /* SATA 4/5 disabled */
  292. setbits_le32(RCB_REG(0x3a88), 1 << 0);
  293. writel(0x00000001, RCB_REG(0x3a6c));
  294. clrsetbits_le32(RCB_REG(0x2344), 0xff0000ff, 0xff00000c);
  295. clrsetbits_le32(RCB_REG(0x80c), 0xff << 20, 0x11 << 20);
  296. setbits_le32(RCB_REG(0x33a4), (1 << 0));
  297. writel(0, RCB_REG(0x33c8));
  298. setbits_le32(RCB_REG(0x21b0), 0xf);
  299. }
  300. static void enable_hpet(void)
  301. {
  302. /* Move HPET to default address 0xfed00000 and enable it */
  303. clrsetbits_le32(RCB_REG(HPTC), 3 << 0, 1 << 7);
  304. }
  305. static void enable_clock_gating(pci_dev_t dev)
  306. {
  307. u32 reg32;
  308. u16 reg16;
  309. setbits_le32(RCB_REG(0x2234), 0xf);
  310. reg16 = x86_pci_read_config16(dev, GEN_PMCON_1);
  311. reg16 |= (1 << 2) | (1 << 11);
  312. x86_pci_write_config16(dev, GEN_PMCON_1, reg16);
  313. pch_iobp_update(0xEB007F07, ~0UL, (1 << 31));
  314. pch_iobp_update(0xEB004000, ~0UL, (1 << 7));
  315. pch_iobp_update(0xEC007F07, ~0UL, (1 << 31));
  316. pch_iobp_update(0xEC004000, ~0UL, (1 << 7));
  317. reg32 = readl(RCB_REG(CG));
  318. reg32 |= (1 << 31);
  319. reg32 |= (1 << 29) | (1 << 28);
  320. reg32 |= (1 << 27) | (1 << 26) | (1 << 25) | (1 << 24);
  321. reg32 |= (1 << 16);
  322. reg32 |= (1 << 17);
  323. reg32 |= (1 << 18);
  324. reg32 |= (1 << 22);
  325. reg32 |= (1 << 23);
  326. reg32 &= ~(1 << 20);
  327. reg32 |= (1 << 19);
  328. reg32 |= (1 << 0);
  329. reg32 |= (0xf << 1);
  330. writel(reg32, RCB_REG(CG));
  331. setbits_le32(RCB_REG(0x38c0), 0x7);
  332. setbits_le32(RCB_REG(0x36d4), 0x6680c004);
  333. setbits_le32(RCB_REG(0x3564), 0x3);
  334. }
  335. #if CONFIG_HAVE_SMI_HANDLER
  336. static void pch_lock_smm(pci_dev_t dev)
  337. {
  338. #if TEST_SMM_FLASH_LOCKDOWN
  339. u8 reg8;
  340. #endif
  341. if (acpi_slp_type != 3) {
  342. #if ENABLE_ACPI_MODE_IN_COREBOOT
  343. debug("Enabling ACPI via APMC:\n");
  344. outb(0xe1, 0xb2); /* Enable ACPI mode */
  345. debug("done.\n");
  346. #else
  347. debug("Disabling ACPI via APMC:\n");
  348. outb(0x1e, 0xb2); /* Disable ACPI mode */
  349. debug("done.\n");
  350. #endif
  351. }
  352. /* Don't allow evil boot loaders, kernels, or
  353. * userspace applications to deceive us:
  354. */
  355. smm_lock();
  356. #if TEST_SMM_FLASH_LOCKDOWN
  357. /* Now try this: */
  358. debug("Locking BIOS to RO... ");
  359. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  360. debug(" BLE: %s; BWE: %s\n", (reg8 & 2) ? "on" : "off",
  361. (reg8 & 1) ? "rw" : "ro");
  362. reg8 &= ~(1 << 0); /* clear BIOSWE */
  363. x86_pci_write_config8(dev, 0xdc, reg8);
  364. reg8 |= (1 << 1); /* set BLE */
  365. x86_pci_write_config8(dev, 0xdc, reg8);
  366. debug("ok.\n");
  367. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  368. debug(" BLE: %s; BWE: %s\n", (reg8 & 2) ? "on" : "off",
  369. (reg8 & 1) ? "rw" : "ro");
  370. debug("Writing:\n");
  371. writeb(0, 0xfff00000);
  372. debug("Testing:\n");
  373. reg8 |= (1 << 0); /* set BIOSWE */
  374. x86_pci_write_config8(dev, 0xdc, reg8);
  375. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  376. debug(" BLE: %s; BWE: %s\n", (reg8 & 2) ? "on" : "off",
  377. (reg8 & 1) ? "rw" : "ro");
  378. debug("Done.\n");
  379. #endif
  380. }
  381. #endif
  382. static void pch_disable_smm_only_flashing(pci_dev_t dev)
  383. {
  384. u8 reg8;
  385. debug("Enabling BIOS updates outside of SMM... ");
  386. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  387. reg8 &= ~(1 << 5);
  388. x86_pci_write_config8(dev, 0xdc, reg8);
  389. }
  390. static void pch_fixups(pci_dev_t dev)
  391. {
  392. u8 gen_pmcon_2;
  393. /* Indicate DRAM init done for MRC S3 to know it can resume */
  394. gen_pmcon_2 = x86_pci_read_config8(dev, GEN_PMCON_2);
  395. gen_pmcon_2 |= (1 << 7);
  396. x86_pci_write_config8(dev, GEN_PMCON_2, gen_pmcon_2);
  397. /* Enable DMI ASPM in the PCH */
  398. clrbits_le32(RCB_REG(0x2304), 1 << 10);
  399. setbits_le32(RCB_REG(0x21a4), (1 << 11) | (1 << 10));
  400. setbits_le32(RCB_REG(0x21a8), 0x3);
  401. }
  402. int lpc_early_init(const void *blob, int node, pci_dev_t dev)
  403. {
  404. struct reg_info {
  405. u32 base;
  406. u32 size;
  407. } values[4], *ptr;
  408. int count;
  409. int i;
  410. count = fdtdec_get_int_array_count(blob, node, "intel,gen-dec",
  411. (u32 *)values, sizeof(values) / sizeof(u32));
  412. if (count < 0)
  413. return -EINVAL;
  414. /* Set COM1/COM2 decode range */
  415. x86_pci_write_config16(dev, LPC_IO_DEC, 0x0010);
  416. /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */
  417. x86_pci_write_config16(dev, LPC_EN, KBC_LPC_EN | MC_LPC_EN |
  418. GAMEL_LPC_EN | COMA_LPC_EN);
  419. /* Write all registers but use 0 if we run out of data */
  420. count = count * sizeof(u32) / sizeof(values[0]);
  421. for (i = 0, ptr = values; i < ARRAY_SIZE(values); i++, ptr++) {
  422. u32 reg = 0;
  423. if (i < count)
  424. reg = ptr->base | PCI_COMMAND_IO | (ptr->size << 16);
  425. x86_pci_write_config32(dev, LPC_GENX_DEC(i), reg);
  426. }
  427. return 0;
  428. }
  429. int lpc_init(struct pci_controller *hose, pci_dev_t dev)
  430. {
  431. const void *blob = gd->fdt_blob;
  432. int node;
  433. debug("pch: lpc_init\n");
  434. pci_write_bar32(hose, dev, 0, 0);
  435. pci_write_bar32(hose, dev, 1, 0xff800000);
  436. pci_write_bar32(hose, dev, 2, 0xfec00000);
  437. pci_write_bar32(hose, dev, 3, 0x800);
  438. pci_write_bar32(hose, dev, 4, 0x900);
  439. node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_PCH);
  440. if (node < 0)
  441. return -ENOENT;
  442. /* Set the value for PCI command register. */
  443. x86_pci_write_config16(dev, PCI_COMMAND, 0x000f);
  444. /* IO APIC initialization. */
  445. pch_enable_apic(dev);
  446. pch_enable_serial_irqs(dev);
  447. /* Setup the PIRQ. */
  448. pch_pirq_init(blob, node, dev);
  449. /* Setup power options. */
  450. pch_power_options(blob, node, dev);
  451. /* Initialize power management */
  452. switch (pch_silicon_type()) {
  453. case PCH_TYPE_CPT: /* CougarPoint */
  454. cpt_pm_init(dev);
  455. break;
  456. case PCH_TYPE_PPT: /* PantherPoint */
  457. ppt_pm_init(dev);
  458. break;
  459. default:
  460. printf("Unknown Chipset: %#02x.%dx\n", PCI_DEV(dev),
  461. PCI_FUNC(dev));
  462. return -ENOSYS;
  463. }
  464. /* Initialize the real time clock. */
  465. pch_rtc_init(dev);
  466. /* Initialize the High Precision Event Timers, if present. */
  467. enable_hpet();
  468. /* Initialize Clock Gating */
  469. enable_clock_gating(dev);
  470. pch_disable_smm_only_flashing(dev);
  471. #if CONFIG_HAVE_SMI_HANDLER
  472. pch_lock_smm(dev);
  473. #endif
  474. pch_fixups(dev);
  475. return 0;
  476. }
  477. void lpc_enable(pci_dev_t dev)
  478. {
  479. /* Enable PCH Display Port */
  480. writew(0x0010, RCB_REG(DISPBDF));
  481. setbits_le32(RCB_REG(FD2), PCH_ENABLE_DBDF);
  482. }
  483. static const struct udevice_id bd82x6x_lpc_ids[] = {
  484. { .compatible = "intel,bd82x6x-lpc" },
  485. { }
  486. };
  487. U_BOOT_DRIVER(bd82x6x_lpc_drv) = {
  488. .name = "lpc",
  489. .id = UCLASS_LPC,
  490. .of_match = bd82x6x_lpc_ids,
  491. };