static void enable_clock_gating(pci_dev_t dev) { u32 reg32; u16 reg16; setbits_le32(RCB_REG(0x2234), 0xf); reg16 = x86_pci_read_config16(dev, GEN_PMCON_1); reg16 |= (1 << 2) | (1 << 11); x86_pci_write_config16(dev, GEN_PMCON_1, reg16); pch_iobp_update(0xEB007F07, ~0UL, (1 << 31)); pch_iobp_update(0xEB004000, ~0UL, (1 << 7)); pch_iobp_update(0xEC007F07, ~0UL, (1 << 31)); pch_iobp_update(0xEC004000, ~0UL, (1 << 7)); reg32 = readl(RCB_REG(CG)); reg32 |= (1 << 31); reg32 |= (1 << 29) | (1 << 28); reg32 |= (1 << 27) | (1 << 26) | (1 << 25) | (1 << 24); reg32 |= (1 << 16); reg32 |= (1 << 17); reg32 |= (1 << 18); reg32 |= (1 << 22); reg32 |= (1 << 23); reg32 &= ~(1 << 20); reg32 |= (1 << 19); reg32 |= (1 << 0); reg32 |= (0xf << 1); writel(reg32, RCB_REG(CG)); setbits_le32(RCB_REG(0x38c0), 0x7); setbits_le32(RCB_REG(0x36d4), 0x6680c004); setbits_le32(RCB_REG(0x3564), 0x3); }
static void pch_misc_init(struct udevice *dev) { /* Setup SLP signal assertion, SLP_S4=4s, SLP_S3=50ms */ dm_pci_clrset_config8(dev, GEN_PMCON_3, 3 << 4 | 1 << 10, 1 << 3 | 1 << 11 | 1 << 12); /* Prepare sleep mode */ clrsetio_32(ACPI_BASE_ADDRESS + PM1_CNT, SLP_TYP, SCI_EN); /* Setup NMI on errors, disable SERR */ clrsetio_8(0x61, 0xf0, 1 << 2); /* Disable NMI sources */ setio_8(0x70, 1 << 7); /* Indicate DRAM init done for MRC */ dm_pci_clrset_config8(dev, GEN_PMCON_2, 0, 1 << 7); /* Clear status bits to prevent unexpected wake */ setbits_le32(RCB_REG(0x3310), 0x0000002f); clrsetbits_le32(RCB_REG(0x3f02), 0x0000000f, 0); /* Enable PCIe Relaxed Order */ setbits_le32(RCB_REG(0x2314), 1 << 31 | 1 << 7); setbits_le32(RCB_REG(0x1114), 1 << 15 | 1 << 14); /* Setup SERIRQ, enable continuous mode */ dm_pci_clrset_config8(dev, SERIRQ_CNTL, 0, 1 << 7 | 1 << 6); };
static int bd82x6x_lpc_early_init(struct udevice *dev) { /* Setting up Southbridge. In the northbridge code. */ debug("Setting up static southbridge registers\n"); dm_pci_write_config32(dev->parent, PCH_RCBA_BASE, DEFAULT_RCBA | 1); dm_pci_write_config32(dev->parent, PMBASE, DEFAULT_PMBASE | 1); /* Enable ACPI BAR */ dm_pci_write_config8(dev->parent, ACPI_CNTL, 0x80); debug("Disabling watchdog reboot\n"); setbits_le32(RCB_REG(GCS), 1 >> 5); /* No reset */ outw(1 << 11, DEFAULT_PMBASE | 0x60 | 0x08); /* halt timer */ dm_pci_write_config32(dev->parent, GPIO_BASE, DEFAULT_GPIOBASE | 1); dm_pci_write_config32(dev->parent, GPIO_CNTL, 0x10); return 0; }
void lpc_enable(pci_dev_t dev) { /* Enable PCH Display Port */ writew(0x0010, RCB_REG(DISPBDF)); setbits_le32(RCB_REG(FD2), PCH_ENABLE_DBDF); }
static void enable_hpet(void) { /* Move HPET to default address 0xfed00000 and enable it */ clrsetbits_le32(RCB_REG(HPTC), 3 << 0, 1 << 7); }
/* PantherPoint PCH Power Management init */ static void ppt_pm_init(pci_dev_t dev) { debug("PantherPoint PM init\n"); pci_write_config8(dev, 0xa9, 0x47); setbits_le32(RCB_REG(0x2238), 1 << 0); setbits_le32(RCB_REG(0x228c), 1 << 0); setbits_le16(RCB_REG(0x1100), (1 << 13) | (1 << 14)); setbits_le16(RCB_REG(0x0900), 1 << 14); writel(0xc03b8400, RCB_REG(0x2304)); setbits_le32(RCB_REG(0x2314), (1 << 5) | (1 << 18)); setbits_le32(RCB_REG(0x2320), (1 << 15) | (1 << 1)); clrsetbits_le32(RCB_REG(0x3314), 0x1f, 0xf); writel(0x054f0000, RCB_REG(0x3318)); writel(0x04000000, RCB_REG(0x3324)); setbits_le32(RCB_REG(0x3340), 0xfffff); setbits_le32(RCB_REG(0x3344), (1 << 1) | (1 << 0)); writel(0x0001c000, RCB_REG(0x3360)); writel(0x00061100, RCB_REG(0x3368)); writel(0x7f8fdfff, RCB_REG(0x3378)); writel(0x000003fd, RCB_REG(0x337c)); writel(0x00001000, RCB_REG(0x3388)); writel(0x0001c000, RCB_REG(0x3390)); writel(0x00000800, RCB_REG(0x33a0)); writel(0x00001000, RCB_REG(0x33b0)); writel(0x00093900, RCB_REG(0x33c0)); writel(0x24653002, RCB_REG(0x33cc)); writel(0x067388fe, RCB_REG(0x33d0)); clrsetbits_le32(RCB_REG(0x33d4), 0x0fff0fff, 0x00670060); writel(0x01010000, RCB_REG(0x3a28)); writel(0x01010404, RCB_REG(0x3a2c)); writel(0x01040000, RCB_REG(0x3a80)); clrsetbits_le32(RCB_REG(0x3a84), 0x0000ffff, 0x00001001); /* SATA 2/3 disabled */ setbits_le32(RCB_REG(0x3a84), 1 << 24); /* SATA 4/5 disabled */ setbits_le32(RCB_REG(0x3a88), 1 << 0); writel(0x00000001, RCB_REG(0x3a6c)); clrsetbits_le32(RCB_REG(0x2344), 0xff0000ff, 0xff00000c); clrsetbits_le32(RCB_REG(0x80c), 0xff << 20, 0x11 << 20); setbits_le32(RCB_REG(0x33a4), (1 << 0)); writel(0, RCB_REG(0x33c8)); setbits_le32(RCB_REG(0x21b0), 0xf); }
static int pch_power_options(const void *blob, int node, pci_dev_t dev) { u8 reg8; u16 reg16, pmbase; u32 reg32; const char *state; int pwr_on; int nmi_option; int ret; /* * Which state do we want to goto after g3 (power restored)? * 0 == S0 Full On * 1 == S5 Soft Off * * If the option is not existent (Laptops), use Kconfig setting. * TODO([email protected]): Make this configurable */ pwr_on = MAINBOARD_POWER_ON; reg16 = pci_read_config16(dev, GEN_PMCON_3); reg16 &= 0xfffe; switch (pwr_on) { case MAINBOARD_POWER_OFF: reg16 |= 1; state = "off"; break; case MAINBOARD_POWER_ON: reg16 &= ~1; state = "on"; break; case MAINBOARD_POWER_KEEP: reg16 &= ~1; state = "state keep"; break; default: state = "undefined"; } reg16 &= ~(3 << 4); /* SLP_S4# Assertion Stretch 4s */ reg16 |= (1 << 3); /* SLP_S4# Assertion Stretch Enable */ reg16 &= ~(1 << 10); reg16 |= (1 << 11); /* SLP_S3# Min Assertion Width 50ms */ reg16 |= (1 << 12); /* Disable SLP stretch after SUS well */ pci_write_config16(dev, GEN_PMCON_3, reg16); debug("Set power %s after power failure.\n", state); /* Set up NMI on errors. */ reg8 = inb(0x61); reg8 &= 0x0f; /* Higher Nibble must be 0 */ reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */ reg8 |= (1 << 2); /* PCI SERR# Disable for now */ outb(reg8, 0x61); reg8 = inb(0x70); /* TODO([email protected]): Make this configurable */ nmi_option = NMI_OFF; if (nmi_option) { debug("NMI sources enabled.\n"); reg8 &= ~(1 << 7); /* Set NMI. */ } else { debug("NMI sources disabled.\n"); /* Can't mask NMI from PCI-E and NMI_NOW */ reg8 |= (1 << 7); } outb(reg8, 0x70); /* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */ reg16 = pci_read_config16(dev, GEN_PMCON_1); reg16 &= ~(3 << 0); /* SMI# rate 1 minute */ reg16 &= ~(1 << 10); /* Disable BIOS_PCI_EXP_EN for native PME */ #if DEBUG_PERIODIC_SMIS /* Set DEBUG_PERIODIC_SMIS in pch.h to debug using periodic SMIs */ reg16 |= (3 << 0); /* Periodic SMI every 8s */ #endif pci_write_config16(dev, GEN_PMCON_1, reg16); /* Set the board's GPI routing. */ ret = pch_gpi_routing(blob, node, dev); if (ret) return ret; pmbase = pci_read_config16(dev, 0x40) & 0xfffe; writel(pmbase + GPE0_EN, fdtdec_get_int(blob, node, "intel,gpe0-enable", 0)); writew(pmbase + ALT_GP_SMI_EN, fdtdec_get_int(blob, node, "intel,alt-gp-smi-enable", 0)); /* Set up power management block and determine sleep mode */ reg32 = inl(pmbase + 0x04); /* PM1_CNT */ reg32 &= ~(7 << 10); /* SLP_TYP */ reg32 |= (1 << 0); /* SCI_EN */ outl(reg32, pmbase + 0x04); /* Clear magic status bits to prevent unexpected wake */ setbits_le32(RCB_REG(0x3310), (1 << 4) | (1 << 5) | (1 << 0)); clrbits_le32(RCB_REG(0x3f02), 0xf); return 0; }
/* Magic register settings for power management */ static void pch_pm_init_magic(struct udevice *dev) { dm_pci_write_config8(dev, 0xa9, 0x46); clrbits_le32(RCB_REG(0x232c), 1), setbits_le32(RCB_REG(0x1100), 0x0000c13f); clrsetbits_le32(RCB_REG(0x2320), 0x60, 0x10); writel(0x00012fff, RCB_REG(0x3314)); clrsetbits_le32(RCB_REG(0x3318), 0x000f0330, 0x0dcf0400); writel(0x04000000, RCB_REG(0x3324)); writel(0x00041400, RCB_REG(0x3368)); writel(0x3f8ddbff, RCB_REG(0x3388)); writel(0x00007001, RCB_REG(0x33ac)); writel(0x00181900, RCB_REG(0x33b0)); writel(0x00060A00, RCB_REG(0x33c0)); writel(0x06200840, RCB_REG(0x33d0)); writel(0x01010101, RCB_REG(0x3a28)); writel(0x040c0404, RCB_REG(0x3a2c)); writel(0x9000000a, RCB_REG(0x3a9c)); writel(0x03808033, RCB_REG(0x2b1c)); writel(0x80000009, RCB_REG(0x2b34)); writel(0x022ddfff, RCB_REG(0x3348)); writel(0x00000001, RCB_REG(0x334c)); writel(0x0001c000, RCB_REG(0x3358)); writel(0x3f8ddbff, RCB_REG(0x3380)); writel(0x0001c7e1, RCB_REG(0x3384)); writel(0x0001c7e1, RCB_REG(0x338c)); writel(0x0001c000, RCB_REG(0x3398)); writel(0x00181900, RCB_REG(0x33a8)); writel(0x00080000, RCB_REG(0x33dc)); writel(0x00000001, RCB_REG(0x33e0)); writel(0x0000040c, RCB_REG(0x3a20)); writel(0x01010101, RCB_REG(0x3a24)); writel(0x01010101, RCB_REG(0x3a30)); dm_pci_clrset_config32(dev, 0xac, 0x00200000, 0); setbits_le32(RCB_REG(0x0410), 0x00000003); setbits_le32(RCB_REG(0x2618), 0x08000000); setbits_le32(RCB_REG(0x2300), 0x00000002); setbits_le32(RCB_REG(0x2600), 0x00000008); writel(0x00007001, RCB_REG(0x33b4)); writel(0x022ddfff, RCB_REG(0x3350)); writel(0x00000001, RCB_REG(0x3354)); /* Power Optimizer */ setbits_le32(RCB_REG(0x33d4), 0x08000000); /* * This stops the LCD from turning on: * setbits_le32(RCB_REG(0x33c8), 0x08000080); */ writel(0x0000883c, RCB_REG(0x2b10)); writel(0x1e0a4616, RCB_REG(0x2b14)); writel(0x40000005, RCB_REG(0x2b24)); writel(0x0005db01, RCB_REG(0x2b20)); writel(0x05145005, RCB_REG(0x3a80)); writel(0x00001005, RCB_REG(0x3a84)); setbits_le32(RCB_REG(0x33d4), 0x2fff2fb1); setbits_le32(RCB_REG(0x33c8), 0x00008000); };
static void enable_port80_on_lpc(struct udevice *pch) { /* Enable port 80 POST on LPC */ dm_pci_write_config32(pch, PCH_RCBA_BASE, DEFAULT_RCBA | 1); clrbits_le32(RCB_REG(GCS), 4); }
/* CougarPoint PCH Power Management init */ static void cpt_pm_init(struct udevice *pch) { debug("CougarPoint PM init\n"); dm_pci_write_config8(pch, 0xa9, 0x47); setbits_le32(RCB_REG(0x2238), (1 << 6) | (1 << 0)); setbits_le32(RCB_REG(0x228c), 1 << 0); setbits_le32(RCB_REG(0x1100), (1 << 13) | (1 << 14)); setbits_le32(RCB_REG(0x0900), 1 << 14); writel(0xc0388400, RCB_REG(0x2304)); setbits_le32(RCB_REG(0x2314), (1 << 5) | (1 << 18)); setbits_le32(RCB_REG(0x2320), (1 << 15) | (1 << 1)); clrsetbits_le32(RCB_REG(0x3314), ~0x1f, 0xf); writel(0x050f0000, RCB_REG(0x3318)); writel(0x04000000, RCB_REG(0x3324)); setbits_le32(RCB_REG(0x3340), 0xfffff); setbits_le32(RCB_REG(0x3344), 1 << 1); writel(0x0001c000, RCB_REG(0x3360)); writel(0x00061100, RCB_REG(0x3368)); writel(0x7f8fdfff, RCB_REG(0x3378)); writel(0x000003fc, RCB_REG(0x337c)); writel(0x00001000, RCB_REG(0x3388)); writel(0x0001c000, RCB_REG(0x3390)); writel(0x00000800, RCB_REG(0x33a0)); writel(0x00001000, RCB_REG(0x33b0)); writel(0x00093900, RCB_REG(0x33c0)); writel(0x24653002, RCB_REG(0x33cc)); writel(0x062108fe, RCB_REG(0x33d0)); clrsetbits_le32(RCB_REG(0x33d4), 0x0fff0fff, 0x00670060); writel(0x01010000, RCB_REG(0x3a28)); writel(0x01010404, RCB_REG(0x3a2c)); writel(0x01041041, RCB_REG(0x3a80)); clrsetbits_le32(RCB_REG(0x3a84), 0x0000ffff, 0x00001001); setbits_le32(RCB_REG(0x3a84), 1 << 24); /* SATA 2/3 disabled */ setbits_le32(RCB_REG(0x3a88), 1 << 0); /* SATA 4/5 disabled */ writel(0x00000001, RCB_REG(0x3a6c)); clrsetbits_le32(RCB_REG(0x2344), ~0x00ffff00, 0xff00000c); clrsetbits_le32(RCB_REG(0x80c), 0xff << 20, 0x11 << 20); writel(0, RCB_REG(0x33c8)); setbits_le32(RCB_REG(0x21b0), 0xf); }