static void enable_clock_gating(device_t dev) { u32 reg32; u16 reg16; RCBA32_AND_OR(0x2234, ~0UL, 0xf); reg16 = pci_read_config16(dev, GEN_PMCON_1); reg16 |= (1 << 2) | (1 << 11); 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 = RCBA32(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); RCBA32(CG) = reg32; RCBA32_OR(0x38c0, 0x7); RCBA32_OR(0x36d4, 0x6680c004); RCBA32_OR(0x3564, 0x3); }
static void pch_fixups(struct device *dev) { /* * Enable DMI ASPM in the PCH */ RCBA32_AND_OR(0x2304, ~(1 << 10), 0); RCBA32_OR(0x21a4, (1 << 11)|(1 << 10)); RCBA32_OR(0x21a8, 0x3); }
static void pch_fixups(struct device *dev) { u8 gen_pmcon_2; /* Indicate DRAM init done for MRC S3 to know it can resume */ gen_pmcon_2 = pci_read_config8(dev, GEN_PMCON_2); gen_pmcon_2 |= (1 << 7); pci_write_config8(dev, GEN_PMCON_2, gen_pmcon_2); /* * Enable DMI ASPM in the PCH */ RCBA32_AND_OR(0x2304, ~(1 << 10), 0); RCBA32_OR(0x21a4, (1 << 11)|(1 << 10)); RCBA32_OR(0x21a8, 0x3); }
/* PantherPoint PCH Power Management init */ static void ppt_pm_init(struct device *dev) { printk(BIOS_DEBUG, "PantherPoint PM init\n"); pci_write_config8(dev, 0xa9, 0x47); RCBA32_AND_OR(0x2238, ~0UL, (1 << 0)); RCBA32_AND_OR(0x228c, ~0UL, (1 << 0)); RCBA16_AND_OR(0x1100, ~0UL, (1 << 13)|(1 << 14)); RCBA16_AND_OR(0x0900, ~0UL, (1 << 14)); RCBA32(0x2304) = 0xc03b8400; RCBA32_AND_OR(0x2314, ~0UL, (1 << 5)|(1 << 18)); RCBA32_AND_OR(0x2320, ~0UL, (1 << 15)|(1 << 1)); RCBA32_AND_OR(0x3314, ~0x1f, 0xf); RCBA32(0x3318) = 0x054f0000; RCBA32(0x3324) = 0x04000000; RCBA32_AND_OR(0x3340, ~0UL, 0xfffff); RCBA32_AND_OR(0x3344, ~0UL, (1 << 1)|(1 << 0)); RCBA32(0x3360) = 0x0001c000; RCBA32(0x3368) = 0x00061100; RCBA32(0x3378) = 0x7f8fdfff; RCBA32(0x337c) = 0x000003fd; RCBA32(0x3388) = 0x00001000; RCBA32(0x3390) = 0x0001c000; RCBA32(0x33a0) = 0x00000800; RCBA32(0x33b0) = 0x00001000; RCBA32(0x33c0) = 0x00093900; RCBA32(0x33cc) = 0x24653002; RCBA32(0x33d0) = 0x067388fe; RCBA32_AND_OR(0x33d4, 0xf000f000, 0x00670060); RCBA32(0x3a28) = 0x01010000; RCBA32(0x3a2c) = 0x01010404; RCBA32(0x3a80) = 0x01040000; RCBA32_AND_OR(0x3a84, ~0x0000ffff, 0x00001001); RCBA32_AND_OR(0x3a84, ~0UL, (1 << 24)); /* SATA 2/3 disabled */ RCBA32_AND_OR(0x3a88, ~0UL, (1 << 0)); /* SATA 4/5 disabled */ RCBA32(0x3a6c) = 0x00000001; RCBA32_AND_OR(0x2344, 0x00ffff00, 0xff00000c); RCBA32_AND_OR(0x80c, ~(0xff << 20), 0x11 << 20); RCBA32_AND_OR(0x33a4, ~0UL, (1 << 0)); RCBA32(0x33c8) = 0; RCBA32_AND_OR(0x21b0, ~0UL, 0xf); }
static void sata_init(struct device *dev) { config_t *config = dev->chip_info; u32 reg32; u8 *abar; u16 reg16; int port; printk(BIOS_DEBUG, "SATA: Initializing controller in AHCI mode.\n"); /* Enable BARs */ pci_write_config16(dev, PCI_COMMAND, 0x0007); /* Set Interrupt Line */ /* Interrupt Pin is set by D31IP.PIP */ pci_write_config8(dev, PCI_INTERRUPT_LINE, 0x0a); /* Set timings */ pci_write_config16(dev, IDE_TIM_PRI, IDE_DECODE_ENABLE); pci_write_config16(dev, IDE_TIM_SEC, IDE_DECODE_ENABLE); /* for AHCI, Port Enable is managed in memory mapped space */ reg16 = pci_read_config16(dev, 0x92); reg16 &= ~0xf; reg16 |= 0x8000 | config->sata_port_map; pci_write_config16(dev, 0x92, reg16); udelay(2); /* Setup register 98h */ reg32 = pci_read_config32(dev, 0x98); reg32 &= ~((1 << 31) | (1 << 30)); reg32 |= 1 << 23; reg32 |= 1 << 24; /* Enable MPHY Dynamic Power Gating */ pci_write_config32(dev, 0x98, reg32); /* Setup register 9Ch */ reg16 = 0; /* Disable alternate ID */ reg16 = 1 << 5; /* BWG step 12 */ pci_write_config16(dev, 0x9c, reg16); /* SATA Initialization register */ reg32 = 0x183; reg32 |= (config->sata_port_map ^ 0xf) << 24; reg32 |= (config->sata_devslp_mux & 1) << 15; pci_write_config32(dev, 0x94, reg32); /* Initialize AHCI memory-mapped space */ abar = (u8 *)(pci_read_config32(dev, PCI_BASE_ADDRESS_5)); printk(BIOS_DEBUG, "ABAR: %p\n", abar); /* CAP (HBA Capabilities) : enable power management */ reg32 = read32(abar + 0x00); reg32 |= 0x0c006000; /* set PSC+SSC+SALP+SSS */ reg32 &= ~0x00020060; /* clear SXS+EMS+PMS */ reg32 |= (1 << 18); /* SAM: SATA AHCI MODE ONLY */ write32(abar + 0x00, reg32); /* PI (Ports implemented) */ write32(abar + 0x0c, config->sata_port_map); (void) read32(abar + 0x0c); /* Read back 1 */ (void) read32(abar + 0x0c); /* Read back 2 */ /* CAP2 (HBA Capabilities Extended)*/ if (config->sata_devslp_disable) { reg32 = read32(abar + 0x24); reg32 &= ~(1 << 3); write32(abar + 0x24, reg32); } else { /* Enable DEVSLP */ reg32 = read32(abar + 0x24); reg32 |= (1 << 5)|(1 << 4)|(1 << 3)|(1 << 2); write32(abar + 0x24, reg32); for (port = 0; port < 4; port++) { if (!(config->sata_port_map & (1 << port))) continue; reg32 = read32(abar + 0x144 + (0x80 * port)); reg32 |= (1 << 1); /* DEVSLP DSP */ write32(abar + 0x144 + (0x80 * port), reg32); } } /* * Static Power Gating for unused ports */ reg32 = RCBA32(0x3a84); /* Port 3 and 2 disabled */ if ((config->sata_port_map & ((1 << 3)|(1 << 2))) == 0) reg32 |= (1 << 24) | (1 << 26); /* Port 1 and 0 disabled */ if ((config->sata_port_map & ((1 << 1)|(1 << 0))) == 0) reg32 |= (1 << 20) | (1 << 18); RCBA32(0x3a84) = reg32; /* Set Gen3 Transmitter settings if needed */ if (config->sata_port0_gen3_tx) pch_iobp_update(SATA_IOBP_SP0_SECRT88, ~(SATA_SECRT88_VADJ_MASK << SATA_SECRT88_VADJ_SHIFT), (config->sata_port0_gen3_tx & SATA_SECRT88_VADJ_MASK) << SATA_SECRT88_VADJ_SHIFT); if (config->sata_port1_gen3_tx) pch_iobp_update(SATA_IOBP_SP1_SECRT88, ~(SATA_SECRT88_VADJ_MASK << SATA_SECRT88_VADJ_SHIFT), (config->sata_port1_gen3_tx & SATA_SECRT88_VADJ_MASK) << SATA_SECRT88_VADJ_SHIFT); /* Set Gen3 DTLE DATA / EDGE registers if needed */ if (config->sata_port0_gen3_dtle) { pch_iobp_update(SATA_IOBP_SP0DTLE_DATA, ~(SATA_DTLE_MASK << SATA_DTLE_DATA_SHIFT), (config->sata_port0_gen3_dtle & SATA_DTLE_MASK) << SATA_DTLE_DATA_SHIFT); pch_iobp_update(SATA_IOBP_SP0DTLE_EDGE, ~(SATA_DTLE_MASK << SATA_DTLE_EDGE_SHIFT), (config->sata_port0_gen3_dtle & SATA_DTLE_MASK) << SATA_DTLE_EDGE_SHIFT); } if (config->sata_port1_gen3_dtle) { pch_iobp_update(SATA_IOBP_SP1DTLE_DATA, ~(SATA_DTLE_MASK << SATA_DTLE_DATA_SHIFT), (config->sata_port1_gen3_dtle & SATA_DTLE_MASK) << SATA_DTLE_DATA_SHIFT); pch_iobp_update(SATA_IOBP_SP1DTLE_EDGE, ~(SATA_DTLE_MASK << SATA_DTLE_EDGE_SHIFT), (config->sata_port1_gen3_dtle & SATA_DTLE_MASK) << SATA_DTLE_EDGE_SHIFT); } /* * Additional Programming Requirements for Power Optimizer */ /* Step 1 */ sir_write(dev, 0x64, 0x883c9003); /* Step 2: SIR 68h[15:0] = 880Ah */ reg32 = sir_read(dev, 0x68); reg32 &= 0xffff0000; reg32 |= 0x880a; sir_write(dev, 0x68, reg32); /* Step 3: SIR 60h[3] = 1 */ reg32 = sir_read(dev, 0x60); reg32 |= (1 << 3); sir_write(dev, 0x60, reg32); /* Step 4: SIR 60h[0] = 1 */ reg32 = sir_read(dev, 0x60); reg32 |= (1 << 0); sir_write(dev, 0x60, reg32); /* Step 5: SIR 60h[1] = 1 */ reg32 = sir_read(dev, 0x60); reg32 |= (1 << 1); sir_write(dev, 0x60, reg32); /* Clock Gating */ sir_write(dev, 0x70, 0x3f00bf1f); sir_write(dev, 0x54, 0xcf000f0f); sir_write(dev, 0x58, 0x00190000); RCBA32_AND_OR(0x333c, 0xffcfffff, 0x00c00000); reg32 = pci_read_config32(dev, 0x300); reg32 |= (1 << 17) | (1 << 16) | (1 << 19); reg32 |= (1 << 31) | (1 << 30) | (1 << 29); pci_write_config32(dev, 0x300, reg32); reg32 = pci_read_config32(dev, 0x98); reg32 |= 1 << 29; pci_write_config32(dev, 0x98, reg32); /* Register Lock */ reg32 = pci_read_config32(dev, 0x9c); reg32 |= (1 << 31); pci_write_config32(dev, 0x9c, reg32); }