예제 #1
0
int apollolake_get_gpe(int gpe)
{
	int bank;
	uint32_t mask, sts;
	uint64_t start;
	int rc = 0;
	const uint64_t timeout_us = 1000;

	if (gpe < 0 || gpe > GPE0_DW3_31)
		return -1;

	bank = gpe / 32;
	mask = 1 << (gpe % 32);

	/* Wait for GPE status to clear */
	start = timer_us(0);
	do {
		if (timer_us(start) > timeout_us)
			break;

		sts = inl(ACPI_PMIO_BASE + GPE0_STS(bank));
		if (sts & mask) {
			outl(mask, ACPI_PMIO_BASE + GPE0_STS(bank));
			rc = 1;
		}
	} while (sts & mask);

	return rc;
}
예제 #2
0
/* Fill power state structure from ACPI PM registers */
struct chipset_power_state *fill_power_state(void)
{
    uint16_t tcobase;
    uint8_t *pmc;
    struct chipset_power_state *ps = car_get_var_ptr(&power_state);

    tcobase = pmc_tco_regs();

    ps->pm1_sts = inw(ACPI_BASE_ADDRESS + PM1_STS);
    ps->pm1_en = inw(ACPI_BASE_ADDRESS + PM1_EN);
    ps->pm1_cnt = inl(ACPI_BASE_ADDRESS + PM1_CNT);
    ps->tco1_sts = inw(tcobase + TCO1_STS);
    ps->tco2_sts = inw(tcobase + TCO2_STS);
    ps->gpe0_sts[0] = inl(ACPI_BASE_ADDRESS + GPE0_STS(0));
    ps->gpe0_sts[1] = inl(ACPI_BASE_ADDRESS + GPE0_STS(1));
    ps->gpe0_sts[2] = inl(ACPI_BASE_ADDRESS + GPE0_STS(2));
    ps->gpe0_sts[3] = inl(ACPI_BASE_ADDRESS + GPE0_STS(3));
    ps->gpe0_en[0] = inl(ACPI_BASE_ADDRESS + GPE0_EN(0));
    ps->gpe0_en[1] = inl(ACPI_BASE_ADDRESS + GPE0_EN(1));
    ps->gpe0_en[2] = inl(ACPI_BASE_ADDRESS + GPE0_EN(2));
    ps->gpe0_en[3] = inl(ACPI_BASE_ADDRESS + GPE0_EN(3));

    ps->gen_pmcon_a = pci_read_config32(PCH_DEV_PMC, GEN_PMCON_A);
    ps->gen_pmcon_b = pci_read_config32(PCH_DEV_PMC, GEN_PMCON_B);

    pmc = pmc_mmio_regs();
    ps->gblrst_cause[0] = read32(pmc + GBLRST_CAUSE0);
    ps->gblrst_cause[1] = read32(pmc + GBLRST_CAUSE1);

    ps->prev_sleep_state = prev_sleep_state(ps);

    dump_power_state(ps);

    return ps;
}
예제 #3
0
파일: pmutil.c 프로젝트: Oxyoptia/coreboot
/* returns prev_sleep_state */
int fill_power_state(struct chipset_power_state *ps)
{
	int i;
	uintptr_t pmc_bar0 = read_pmc_mmio_bar();

	ps->pm1_sts = inw(ACPI_PMIO_BASE + PM1_STS);
	ps->pm1_en = inw(ACPI_PMIO_BASE + PM1_EN);
	ps->pm1_cnt = inl(ACPI_PMIO_BASE + PM1_CNT);
	ps->tco_sts = inl(ACPI_PMIO_BASE + TCO_STS);
	ps->prsts = read32((void *)(pmc_bar0 + PRSTS));
	ps->gen_pmcon1 =read32((void *)(pmc_bar0 + GEN_PMCON1));
	ps->gen_pmcon2 = read32((void *)(pmc_bar0 + GEN_PMCON2));
	ps->gen_pmcon3 = read32((void *)(pmc_bar0 + GEN_PMCON3));

	ps->prev_sleep_state = chipset_prev_sleep_state(ps);

	printk(BIOS_DEBUG, "pm1_sts: %04x pm1_en: %04x pm1_cnt: %08x\n",
		ps->pm1_sts, ps->pm1_en, ps->pm1_cnt);
	printk(BIOS_DEBUG, "prsts: %08x tco_sts: %08x\n",
		ps->prsts, ps->tco_sts);
	printk(BIOS_DEBUG,
		 "gen_pmcon1: %08x gen_pmcon2: %08x gen_pmcon3: %08x\n",
		ps->gen_pmcon1, ps->gen_pmcon2, ps->gen_pmcon3);
	printk(BIOS_DEBUG, "smi_en: %08x smi_sts: %08x\n",
		inl(ACPI_PMIO_BASE + SMI_EN), inl(ACPI_PMIO_BASE + SMI_STS));
	for (i=0; i < GPE0_REG_MAX; i++) {
		ps->gpe0_sts[i] = inl(ACPI_PMIO_BASE + GPE0_STS(i));
		ps->gpe0_en[i] = inl(ACPI_PMIO_BASE + GPE0_EN(i));
		printk(BIOS_DEBUG, "gpe0_sts[%d]: %08x gpe0_en[%d]: %08x\n",
			i, ps->gpe0_sts[i], i, ps->gpe0_en[i]);
	}
	printk(BIOS_DEBUG, "prev_sleep_state %d\n", ps->prev_sleep_state);
	return ps->prev_sleep_state;
}
예제 #4
0
파일: acpi.c 프로젝트: af00/coreboot
void acpi_fill_fadt(acpi_fadt_t * fadt)
{
	const uint16_t pmbase = ACPI_PMIO_BASE;

	/* Use ACPI 5.0 revision. */
	fadt->header.revision = ACPI_FADT_REV_ACPI_5_0;

	fadt->sci_int = acpi_sci_irq();
	fadt->smi_cmd = APM_CNT;
	fadt->acpi_enable = APM_CNT_ACPI_ENABLE;
	fadt->acpi_disable = APM_CNT_ACPI_DISABLE;

	fadt->pm1a_evt_blk = pmbase + PM1_STS;
	fadt->pm1a_cnt_blk = pmbase + PM1_CNT;
	fadt->pm_tmr_blk = pmbase + PM1_TMR;
	fadt->gpe0_blk = pmbase + GPE0_STS(0);

	fadt->pm1_evt_len = 4;
	fadt->pm1_cnt_len = 2;
	fadt->pm_tmr_len = 4;
	/* There are 4 GPE0 STS/EN pairs each 32 bits wide. */
	fadt->gpe0_blk_len = 2 * GPE0_REG_MAX * sizeof(uint32_t);
	fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED;
	fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED;
	fadt->flush_size = 0x400;	/* twice of cache size*/
	fadt->flush_stride = 0x10;	/* Cache line width  */
	fadt->duty_offset = 1;
	fadt->duty_width = 3;
	fadt->day_alrm = 0xd;
	fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042;

	fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
	    ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON |
	    ACPI_FADT_RESET_REGISTER | ACPI_FADT_SEALED_CASE |
	    ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_PLATFORM_CLOCK;

	fadt->reset_reg.space_id = 1;
	fadt->reset_reg.bit_width = 8;
	fadt->reset_reg.addrl = 0xcf9;
	fadt->reset_value = 6;

	fadt->x_pm1a_evt_blk.space_id = 1;
	fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
	fadt->x_pm1a_evt_blk.addrl = pmbase + PM1_STS;

	fadt->x_pm1b_evt_blk.space_id = 1;

	fadt->x_pm1a_cnt_blk.space_id = 1;
	fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
	fadt->x_pm1a_cnt_blk.addrl = pmbase + PM1_CNT;

	fadt->x_pm1b_cnt_blk.space_id = 1;

	fadt->x_pm_tmr_blk.space_id = 1;
	fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
	fadt->x_pm_tmr_blk.addrl = pmbase + PM1_TMR;

	fadt->x_gpe1_blk.space_id = 1;
}
예제 #5
0
파일: pmutil.c 프로젝트: AdriDlu/coreboot
/* Enable TCO SCI */
void enable_tco_sci(void)
{
	/* Clear pending events */
	outl(ACPI_BASE_ADDRESS + GPE0_STS(3), TCOSCI_STS);

	/* Enable TCO SCI events */
	enable_gpe(TCOSCI_EN);
}
예제 #6
0
파일: pmutil.c 프로젝트: AdriDlu/coreboot
/* Clear all GPE status and return "standard" GPE event status */
u32 clear_gpe_status(void)
{
	const char *gpe0_sts_3_bits[] = {
		[1] = "HOTPLUG",
		[2] = "SWGPE",
		[6] = "TCO_SCI",
		[7] = "SMB_WAK",
		[9] = "PCI_EXP",
		[10] = "BATLOW",
		[11] = "PME",
		[12] = "ME",
		[13] = "PME_B0",
		[16] = "GPIO27",
		[18] = "WADT"
	};

	print_gpe_gpio(reset_gpe(GPE0_STS(GPE_31_0), GPE0_EN(GPE_31_0)), 0);
	print_gpe_gpio(reset_gpe(GPE0_STS(GPE_63_32), GPE0_EN(GPE_63_32)), 32);
	print_gpe_gpio(reset_gpe(GPE0_STS(GPE_94_64), GPE0_EN(GPE_94_64)), 64);
	return print_gpe_status(reset_gpe(GPE0_STS(GPE_STD), GPE0_EN(GPE_STD)),
				gpe0_sts_3_bits);
}
예제 #7
0
/* Fill power state structure from ACPI PM registers */
void power_state_get(struct udevice *pch_dev, struct chipset_power_state *ps)
{
    ps->pm1_sts = inw(ACPI_BASE_ADDRESS + PM1_STS);
    ps->pm1_en = inw(ACPI_BASE_ADDRESS + PM1_EN);
    ps->pm1_cnt = inl(ACPI_BASE_ADDRESS + PM1_CNT);
    ps->tco1_sts = inw(ACPI_BASE_ADDRESS + TCO1_STS);
    ps->tco2_sts = inw(ACPI_BASE_ADDRESS + TCO2_STS);
    ps->gpe0_sts[0] = inl(ACPI_BASE_ADDRESS + GPE0_STS(0));
    ps->gpe0_sts[1] = inl(ACPI_BASE_ADDRESS + GPE0_STS(1));
    ps->gpe0_sts[2] = inl(ACPI_BASE_ADDRESS + GPE0_STS(2));
    ps->gpe0_sts[3] = inl(ACPI_BASE_ADDRESS + GPE0_STS(3));
    ps->gpe0_en[0] = inl(ACPI_BASE_ADDRESS + GPE0_EN(0));
    ps->gpe0_en[1] = inl(ACPI_BASE_ADDRESS + GPE0_EN(1));
    ps->gpe0_en[2] = inl(ACPI_BASE_ADDRESS + GPE0_EN(2));
    ps->gpe0_en[3] = inl(ACPI_BASE_ADDRESS + GPE0_EN(3));

    dm_pci_read_config16(pch_dev, GEN_PMCON_1, &ps->gen_pmcon1);
    dm_pci_read_config16(pch_dev, GEN_PMCON_2, &ps->gen_pmcon2);
    dm_pci_read_config16(pch_dev, GEN_PMCON_3, &ps->gen_pmcon3);

    ps->prev_sleep_state = prev_sleep_state(ps);

    dump_power_state(ps);
}
예제 #8
0
파일: pmutil.c 프로젝트: Oxyoptia/coreboot
static uint32_t reset_gpe_status(void)
{
	uint32_t gpe_sts = inl(ACPI_PMIO_BASE + GPE0_STS(0));
	outl(gpe_sts, ACPI_PMIO_BASE + GPE0_STS(0));
	return gpe_sts;
}