lpc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. /* TODO: Handle power failure */
  202. if (rtc_failed)
  203. printf("RTC power failed\n");
  204. }
  205. /* CougarPoint PCH Power Management init */
  206. static void cpt_pm_init(pci_dev_t dev)
  207. {
  208. debug("CougarPoint PM init\n");
  209. x86_pci_write_config8(dev, 0xa9, 0x47);
  210. setbits_le32(RCB_REG(0x2238), (1 << 6) | (1 << 0));
  211. setbits_le32(RCB_REG(0x228c), 1 << 0);
  212. setbits_le32(RCB_REG(0x1100), (1 << 13) | (1 << 14));
  213. setbits_le32(RCB_REG(0x0900), 1 << 14);
  214. writel(0xc0388400, RCB_REG(0x2304));
  215. setbits_le32(RCB_REG(0x2314), (1 << 5) | (1 << 18));
  216. setbits_le32(RCB_REG(0x2320), (1 << 15) | (1 << 1));
  217. clrsetbits_le32(RCB_REG(0x3314), ~0x1f, 0xf);
  218. writel(0x050f0000, RCB_REG(0x3318));
  219. writel(0x04000000, RCB_REG(0x3324));
  220. setbits_le32(RCB_REG(0x3340), 0xfffff);
  221. setbits_le32(RCB_REG(0x3344), 1 << 1);
  222. writel(0x0001c000, RCB_REG(0x3360));
  223. writel(0x00061100, RCB_REG(0x3368));
  224. writel(0x7f8fdfff, RCB_REG(0x3378));
  225. writel(0x000003fc, RCB_REG(0x337c));
  226. writel(0x00001000, RCB_REG(0x3388));
  227. writel(0x0001c000, RCB_REG(0x3390));
  228. writel(0x00000800, RCB_REG(0x33a0));
  229. writel(0x00001000, RCB_REG(0x33b0));
  230. writel(0x00093900, RCB_REG(0x33c0));
  231. writel(0x24653002, RCB_REG(0x33cc));
  232. writel(0x062108fe, RCB_REG(0x33d0));
  233. clrsetbits_le32(RCB_REG(0x33d4), 0x0fff0fff, 0x00670060);
  234. writel(0x01010000, RCB_REG(0x3a28));
  235. writel(0x01010404, RCB_REG(0x3a2c));
  236. writel(0x01041041, RCB_REG(0x3a80));
  237. clrsetbits_le32(RCB_REG(0x3a84), 0x0000ffff, 0x00001001);
  238. setbits_le32(RCB_REG(0x3a84), 1 << 24); /* SATA 2/3 disabled */
  239. setbits_le32(RCB_REG(0x3a88), 1 << 0); /* SATA 4/5 disabled */
  240. writel(0x00000001, RCB_REG(0x3a6c));
  241. clrsetbits_le32(RCB_REG(0x2344), ~0x00ffff00, 0xff00000c);
  242. clrsetbits_le32(RCB_REG(0x80c), 0xff << 20, 0x11 << 20);
  243. writel(0, RCB_REG(0x33c8));
  244. setbits_le32(RCB_REG(0x21b0), 0xf);
  245. }
  246. /* PantherPoint PCH Power Management init */
  247. static void ppt_pm_init(pci_dev_t dev)
  248. {
  249. debug("PantherPoint PM init\n");
  250. x86_pci_write_config8(dev, 0xa9, 0x47);
  251. setbits_le32(RCB_REG(0x2238), 1 << 0);
  252. setbits_le32(RCB_REG(0x228c), 1 << 0);
  253. setbits_le16(RCB_REG(0x1100), (1 << 13) | (1 << 14));
  254. setbits_le16(RCB_REG(0x0900), 1 << 14);
  255. writel(0xc03b8400, RCB_REG(0x2304));
  256. setbits_le32(RCB_REG(0x2314), (1 << 5) | (1 << 18));
  257. setbits_le32(RCB_REG(0x2320), (1 << 15) | (1 << 1));
  258. clrsetbits_le32(RCB_REG(0x3314), 0x1f, 0xf);
  259. writel(0x054f0000, RCB_REG(0x3318));
  260. writel(0x04000000, RCB_REG(0x3324));
  261. setbits_le32(RCB_REG(0x3340), 0xfffff);
  262. setbits_le32(RCB_REG(0x3344), (1 << 1) | (1 << 0));
  263. writel(0x0001c000, RCB_REG(0x3360));
  264. writel(0x00061100, RCB_REG(0x3368));
  265. writel(0x7f8fdfff, RCB_REG(0x3378));
  266. writel(0x000003fd, RCB_REG(0x337c));
  267. writel(0x00001000, RCB_REG(0x3388));
  268. writel(0x0001c000, RCB_REG(0x3390));
  269. writel(0x00000800, RCB_REG(0x33a0));
  270. writel(0x00001000, RCB_REG(0x33b0));
  271. writel(0x00093900, RCB_REG(0x33c0));
  272. writel(0x24653002, RCB_REG(0x33cc));
  273. writel(0x067388fe, RCB_REG(0x33d0));
  274. clrsetbits_le32(RCB_REG(0x33d4), 0x0fff0fff, 0x00670060);
  275. writel(0x01010000, RCB_REG(0x3a28));
  276. writel(0x01010404, RCB_REG(0x3a2c));
  277. writel(0x01040000, RCB_REG(0x3a80));
  278. clrsetbits_le32(RCB_REG(0x3a84), 0x0000ffff, 0x00001001);
  279. /* SATA 2/3 disabled */
  280. setbits_le32(RCB_REG(0x3a84), 1 << 24);
  281. /* SATA 4/5 disabled */
  282. setbits_le32(RCB_REG(0x3a88), 1 << 0);
  283. writel(0x00000001, RCB_REG(0x3a6c));
  284. clrsetbits_le32(RCB_REG(0x2344), 0xff0000ff, 0xff00000c);
  285. clrsetbits_le32(RCB_REG(0x80c), 0xff << 20, 0x11 << 20);
  286. setbits_le32(RCB_REG(0x33a4), (1 << 0));
  287. writel(0, RCB_REG(0x33c8));
  288. setbits_le32(RCB_REG(0x21b0), 0xf);
  289. }
  290. static void enable_hpet(void)
  291. {
  292. /* Move HPET to default address 0xfed00000 and enable it */
  293. clrsetbits_le32(RCB_REG(HPTC), 3 << 0, 1 << 7);
  294. }
  295. static void enable_clock_gating(pci_dev_t dev)
  296. {
  297. u32 reg32;
  298. u16 reg16;
  299. setbits_le32(RCB_REG(0x2234), 0xf);
  300. reg16 = x86_pci_read_config16(dev, GEN_PMCON_1);
  301. reg16 |= (1 << 2) | (1 << 11);
  302. x86_pci_write_config16(dev, GEN_PMCON_1, reg16);
  303. pch_iobp_update(0xEB007F07, ~0UL, (1 << 31));
  304. pch_iobp_update(0xEB004000, ~0UL, (1 << 7));
  305. pch_iobp_update(0xEC007F07, ~0UL, (1 << 31));
  306. pch_iobp_update(0xEC004000, ~0UL, (1 << 7));
  307. reg32 = readl(RCB_REG(CG));
  308. reg32 |= (1 << 31);
  309. reg32 |= (1 << 29) | (1 << 28);
  310. reg32 |= (1 << 27) | (1 << 26) | (1 << 25) | (1 << 24);
  311. reg32 |= (1 << 16);
  312. reg32 |= (1 << 17);
  313. reg32 |= (1 << 18);
  314. reg32 |= (1 << 22);
  315. reg32 |= (1 << 23);
  316. reg32 &= ~(1 << 20);
  317. reg32 |= (1 << 19);
  318. reg32 |= (1 << 0);
  319. reg32 |= (0xf << 1);
  320. writel(reg32, RCB_REG(CG));
  321. setbits_le32(RCB_REG(0x38c0), 0x7);
  322. setbits_le32(RCB_REG(0x36d4), 0x6680c004);
  323. setbits_le32(RCB_REG(0x3564), 0x3);
  324. }
  325. #if CONFIG_HAVE_SMI_HANDLER
  326. static void pch_lock_smm(pci_dev_t dev)
  327. {
  328. #if TEST_SMM_FLASH_LOCKDOWN
  329. u8 reg8;
  330. #endif
  331. if (acpi_slp_type != 3) {
  332. #if ENABLE_ACPI_MODE_IN_COREBOOT
  333. debug("Enabling ACPI via APMC:\n");
  334. outb(0xe1, 0xb2); /* Enable ACPI mode */
  335. debug("done.\n");
  336. #else
  337. debug("Disabling ACPI via APMC:\n");
  338. outb(0x1e, 0xb2); /* Disable ACPI mode */
  339. debug("done.\n");
  340. #endif
  341. }
  342. /* Don't allow evil boot loaders, kernels, or
  343. * userspace applications to deceive us:
  344. */
  345. smm_lock();
  346. #if TEST_SMM_FLASH_LOCKDOWN
  347. /* Now try this: */
  348. debug("Locking BIOS to RO... ");
  349. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  350. debug(" BLE: %s; BWE: %s\n", (reg8 & 2) ? "on" : "off",
  351. (reg8 & 1) ? "rw" : "ro");
  352. reg8 &= ~(1 << 0); /* clear BIOSWE */
  353. x86_pci_write_config8(dev, 0xdc, reg8);
  354. reg8 |= (1 << 1); /* set BLE */
  355. x86_pci_write_config8(dev, 0xdc, reg8);
  356. debug("ok.\n");
  357. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  358. debug(" BLE: %s; BWE: %s\n", (reg8 & 2) ? "on" : "off",
  359. (reg8 & 1) ? "rw" : "ro");
  360. debug("Writing:\n");
  361. writeb(0, 0xfff00000);
  362. debug("Testing:\n");
  363. reg8 |= (1 << 0); /* set BIOSWE */
  364. x86_pci_write_config8(dev, 0xdc, reg8);
  365. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  366. debug(" BLE: %s; BWE: %s\n", (reg8 & 2) ? "on" : "off",
  367. (reg8 & 1) ? "rw" : "ro");
  368. debug("Done.\n");
  369. #endif
  370. }
  371. #endif
  372. static void pch_disable_smm_only_flashing(pci_dev_t dev)
  373. {
  374. u8 reg8;
  375. debug("Enabling BIOS updates outside of SMM... ");
  376. reg8 = x86_pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
  377. reg8 &= ~(1 << 5);
  378. x86_pci_write_config8(dev, 0xdc, reg8);
  379. }
  380. static void pch_fixups(pci_dev_t dev)
  381. {
  382. u8 gen_pmcon_2;
  383. /* Indicate DRAM init done for MRC S3 to know it can resume */
  384. gen_pmcon_2 = x86_pci_read_config8(dev, GEN_PMCON_2);
  385. gen_pmcon_2 |= (1 << 7);
  386. x86_pci_write_config8(dev, GEN_PMCON_2, gen_pmcon_2);
  387. /* Enable DMI ASPM in the PCH */
  388. clrbits_le32(RCB_REG(0x2304), 1 << 10);
  389. setbits_le32(RCB_REG(0x21a4), (1 << 11) | (1 << 10));
  390. setbits_le32(RCB_REG(0x21a8), 0x3);
  391. }
  392. int lpc_early_init(const void *blob, int node, pci_dev_t dev)
  393. {
  394. struct reg_info {
  395. u32 base;
  396. u32 size;
  397. } values[4], *ptr;
  398. int count;
  399. int i;
  400. count = fdtdec_get_int_array_count(blob, node, "intel,gen-dec",
  401. (u32 *)values, sizeof(values) / sizeof(u32));
  402. if (count < 0)
  403. return -EINVAL;
  404. /* Set COM1/COM2 decode range */
  405. x86_pci_write_config16(dev, LPC_IO_DEC, 0x0010);
  406. /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */
  407. x86_pci_write_config16(dev, LPC_EN, KBC_LPC_EN | MC_LPC_EN |
  408. GAMEL_LPC_EN | COMA_LPC_EN);
  409. /* Write all registers but use 0 if we run out of data */
  410. count = count * sizeof(u32) / sizeof(values[0]);
  411. for (i = 0, ptr = values; i < ARRAY_SIZE(values); i++, ptr++) {
  412. u32 reg = 0;
  413. if (i < count)
  414. reg = ptr->base | PCI_COMMAND_IO | (ptr->size << 16);
  415. x86_pci_write_config32(dev, LPC_GENX_DEC(i), reg);
  416. }
  417. return 0;
  418. }
  419. int lpc_init(struct pci_controller *hose, pci_dev_t dev)
  420. {
  421. const void *blob = gd->fdt_blob;
  422. int node;
  423. debug("pch: lpc_init\n");
  424. pci_write_bar32(hose, dev, 0, 0);
  425. pci_write_bar32(hose, dev, 1, 0xff800000);
  426. pci_write_bar32(hose, dev, 2, 0xfec00000);
  427. pci_write_bar32(hose, dev, 3, 0x800);
  428. pci_write_bar32(hose, dev, 4, 0x900);
  429. node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_PCH);
  430. if (node < 0)
  431. return -ENOENT;
  432. /* Set the value for PCI command register. */
  433. x86_pci_write_config16(dev, PCI_COMMAND, 0x000f);
  434. /* IO APIC initialization. */
  435. pch_enable_apic(dev);
  436. pch_enable_serial_irqs(dev);
  437. /* Setup the PIRQ. */
  438. pch_pirq_init(blob, node, dev);
  439. /* Setup power options. */
  440. pch_power_options(blob, node, dev);
  441. /* Initialize power management */
  442. switch (pch_silicon_type()) {
  443. case PCH_TYPE_CPT: /* CougarPoint */
  444. cpt_pm_init(dev);
  445. break;
  446. case PCH_TYPE_PPT: /* PantherPoint */
  447. ppt_pm_init(dev);
  448. break;
  449. default:
  450. printf("Unknown Chipset: %#02x.%dx\n", PCI_DEV(dev),
  451. PCI_FUNC(dev));
  452. return -ENOSYS;
  453. }
  454. /* Initialize the real time clock. */
  455. pch_rtc_init(dev);
  456. /* Initialize the High Precision Event Timers, if present. */
  457. enable_hpet();
  458. /* Initialize Clock Gating */
  459. enable_clock_gating(dev);
  460. pch_disable_smm_only_flashing(dev);
  461. #if CONFIG_HAVE_SMI_HANDLER
  462. pch_lock_smm(dev);
  463. #endif
  464. pch_fixups(dev);
  465. return 0;
  466. }
  467. void lpc_enable(pci_dev_t dev)
  468. {
  469. /* Enable PCH Display Port */
  470. writew(0x0010, RCB_REG(DISPBDF));
  471. setbits_le32(RCB_REG(FD2), PCH_ENABLE_DBDF);
  472. }
  473. static const struct udevice_id bd82x6x_lpc_ids[] = {
  474. { .compatible = "intel,bd82x6x-lpc" },
  475. { }
  476. };
  477. U_BOOT_DRIVER(bd82x6x_lpc_drv) = {
  478. .name = "lpc",
  479. .id = UCLASS_LPC,
  480. .of_match = bd82x6x_lpc_ids,
  481. };