// SPDX-License-Identifier: GPL-2.0-or-later1/*2* 8237A DMA controller suspend functions.3*4* Written by Pierre Ossman, 2005.5*/67#include <linux/dmi.h>8#include <linux/init.h>9#include <linux/syscore_ops.h>1011#include <asm/dma.h>12#include <asm/x86_init.h>1314/*15* This module just handles suspend/resume issues with the16* 8237A DMA controller (used for ISA and LPC).17* Allocation is handled in kernel/dma.c and normal usage is18* in asm/dma.h.19*/2021static void i8237A_resume(void *data)22{23unsigned long flags;24int i;2526flags = claim_dma_lock();2728dma_outb(0, DMA1_RESET_REG);29dma_outb(0, DMA2_RESET_REG);3031for (i = 0; i < 8; i++) {32set_dma_addr(i, 0x000000);33/* DMA count is a bit weird so this is not 0 */34set_dma_count(i, 1);35}3637/* Enable cascade DMA or channel 0-3 won't work */38enable_dma(4);3940release_dma_lock(flags);41}4243static const struct syscore_ops i8237_syscore_ops = {44.resume = i8237A_resume,45};4647static struct syscore i8237_syscore = {48.ops = &i8237_syscore_ops,49};5051static int __init i8237A_init_ops(void)52{53/*54* From SKL PCH onwards, the legacy DMA device is removed in which the55* I/O ports (81h-83h, 87h, 89h-8Bh, 8Fh) related to it are removed56* as well. All removed ports must return 0xff for a inb() request.57*58* Note: DMA_PAGE_2 (port 0x81) should not be checked for detecting59* the presence of DMA device since it may be used by BIOS to decode60* LPC traffic for POST codes. Original LPC only decodes one byte of61* port 0x80 but some BIOS may choose to enhance PCH LPC port 0x8x62* decoding.63*/64if (dma_inb(DMA_PAGE_0) == 0xFF)65return -ENODEV;6667/*68* It is not required to load this driver as newer SoC may not69* support 8237 DMA or bus mastering from LPC. Platform firmware70* must announce the support for such legacy devices via71* ACPI_FADT_LEGACY_DEVICES field in FADT table.72*/73if (x86_pnpbios_disabled() && dmi_get_bios_year() >= 2017)74return -ENODEV;7576register_syscore(&i8237_syscore);77return 0;78}79device_initcall(i8237A_init_ops);808182