// SPDX-License-Identifier: GPL-2.0-only/* * ACPI support for Intel Lynxpoint LPSS. * * Copyright (C) 2013, Intel Corporation * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> * Rafael J. Wysocki <rafael.j.wysocki@intel.com> */#include<linux/acpi.h>#include<linux/clkdev.h>#include<linux/clk-provider.h>#include<linux/dmi.h>#include<linux/err.h>#include<linux/io.h>#include<linux/mutex.h>#include<linux/pci.h>#include<linux/platform_device.h>#include<linux/platform_data/x86/clk-lpss.h>#include<linux/platform_data/x86/pmc_atom.h>#include<linux/pm_domain.h>#include<linux/pm_runtime.h>#include<linux/pwm.h>#include<linux/pxa2xx_ssp.h>#include<linux/suspend.h>#include<linux/delay.h>#include"internal.h"#ifdef CONFIG_X86_INTEL_LPSS#include<asm/cpu_device_id.h>#include<asm/intel-family.h>#include<asm/iosf_mbi.h>#define LPSS_ADDR(desc) ((unsigned long)&desc)#define LPSS_CLK_SIZE 0x04#define LPSS_LTR_SIZE 0x18/* Offsets relative to LPSS_PRIVATE_OFFSET */#define LPSS_CLK_DIVIDER_DEF_MASK (BIT(1) | BIT(16))#define LPSS_RESETS 0x04#define LPSS_RESETS_RESET_FUNC BIT(0)#define LPSS_RESETS_RESET_APB BIT(1)#define LPSS_GENERAL 0x08#define LPSS_GENERAL_LTR_MODE_SW BIT(2)#define LPSS_GENERAL_UART_RTS_OVRD BIT(3)#define LPSS_SW_LTR 0x10#define LPSS_AUTO_LTR 0x14#define LPSS_LTR_SNOOP_REQ BIT(15)#define LPSS_LTR_SNOOP_MASK 0x0000FFFF#define LPSS_LTR_SNOOP_LAT_1US 0x800#define LPSS_LTR_SNOOP_LAT_32US 0xC00#define LPSS_LTR_SNOOP_LAT_SHIFT 5#define LPSS_LTR_SNOOP_LAT_CUTOFF 3000#define LPSS_LTR_MAX_VAL 0x3FF#define LPSS_TX_INT 0x20#define LPSS_TX_INT_MASK BIT(1)#define LPSS_PRV_REG_COUNT 9/* LPSS Flags */#define LPSS_CLK BIT(0)#define LPSS_CLK_GATE BIT(1)#define LPSS_CLK_DIVIDER BIT(2)#define LPSS_LTR BIT(3)#define LPSS_SAVE_CTX BIT(4)/* * For some devices the DSDT AML code for another device turns off the device * before our suspend handler runs, causing us to read/save all 1-s (0xffffffff) * as ctx register values. * Luckily these devices always use the same ctx register values, so we can * work around this by saving the ctx registers once on activation. */#define LPSS_SAVE_CTX_ONCE BIT(5)#define LPSS_NO_D3_DELAY BIT(6)structlpss_private_data;structlpss_device_desc{unsignedintflags;constchar*clk_con_id;unsignedintprv_offset;size_tprv_size_override;conststructproperty_entry*properties;void(*setup)(structlpss_private_data*pdata);boolresume_from_noirq;};staticconststructlpss_device_desclpss_dma_desc={.flags=LPSS_CLK,};structlpss_private_data{structacpi_device*adev;void__iomem*mmio_base;resource_size_tmmio_size;unsignedintfixed_clk_rate;structclk*clk;conststructlpss_device_desc*dev_desc;u32prv_reg_ctx