// 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)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 struct syscore_ops i8237_syscore_ops = {44.resume = i8237A_resume,45};4647static int __init i8237A_init_ops(void)48{49/*50* From SKL PCH onwards, the legacy DMA device is removed in which the51* I/O ports (81h-83h, 87h, 89h-8Bh, 8Fh) related to it are removed52* as well. All removed ports must return 0xff for a inb() request.53*54* Note: DMA_PAGE_2 (port 0x81) should not be checked for detecting55* the presence of DMA device since it may be used by BIOS to decode56* LPC traffic for POST codes. Original LPC only decodes one byte of57* port 0x80 but some BIOS may choose to enhance PCH LPC port 0x8x58* decoding.59*/60if (dma_inb(DMA_PAGE_0) == 0xFF)61return -ENODEV;6263/*64* It is not required to load this driver as newer SoC may not65* support 8237 DMA or bus mastering from LPC. Platform firmware66* must announce the support for such legacy devices via67* ACPI_FADT_LEGACY_DEVICES field in FADT table.68*/69if (x86_pnpbios_disabled() && dmi_get_bios_year() >= 2017)70return -ENODEV;7172register_syscore_ops(&i8237_syscore_ops);73return 0;74}75device_initcall(i8237A_init_ops);767778