11195Srgrimes/* SPDX-License-Identifier: GPL-2.0 */ 250472Speter/* 337Srgrimes * Copyright (c) 2012-2022, Intel Corporation. All rights reserved. 4156813Sru * Intel Management Engine Interface (Intel MEI) Linux driver 5156813Sru */ 6156813Sru 738103Speter#ifndef _MEI_INTERFACE_H_ 873251Sgshapiro#define _MEI_INTERFACE_H_ 938103Speter 10183242Ssam#include <linux/irqreturn.h> 11184343Ssam#include <linux/pci.h> 12183242Ssam#include <linux/mei.h> 13161748Scperciva 14183242Ssam#include "mei_dev.h" 15162674Spiso#include "client.h" 16158266Sume 17183242Ssam/* 18200028Sume * mei_cfg - mei device configuration 19145693Sbrooks * 20183242Ssam * @fw_status: FW status 21204820Sed * @quirk_probe: device exclusion quirk 22155210Srwatson * @kind: MEI head kind 23199249Sed * @dma_size: device DMA buffers size 24199249Sed * @fw_ver_supported: is fw version retrievable from FW 25199249Sed * @hw_trc_supported: does the hw support trc register 26199249Sed */ 27199249Sedstruct mei_cfg { 28199249Sed const struct mei_fw_status fw_status; 29155210Srwatson bool (*quirk_probe)(const struct pci_dev *pdev); 30155210Srwatson const char *kind; 31155210Srwatson size_t dma_size[DMA_DSCR_NUM]; 32155210Srwatson u32 fw_ver_supported:1; 33155210Srwatson u32 hw_trc_supported:1; 34155210Srwatson}; 35155210Srwatson 36155210Srwatson 37183242Ssam#define MEI_PCI_DEVICE(dev, cfg) \ 38183242Ssam .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ 39183242Ssam .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ 40183242Ssam .driver_data = (kernel_ulong_t)(cfg), 41183242Ssam 42183242Ssam#define MEI_ME_RPM_TIMEOUT 500 /* ms */ 43183242Ssam 44183242Ssam/** 45183242Ssam * struct mei_me_hw - me hw specific data 46183242Ssam * 47183242Ssam * @cfg: per device generation config and ops 48183242Ssam * @mem_addr: io memory address 49183242Ssam * @irq: irq number 50183242Ssam * @pg_state: power gating state 51183242Ssam * @d0i3_supported: di03 support 52183242Ssam * @hbuf_depth: depth of hardware host/write buffer in slots 53183242Ssam * @read_fws: read FW status register handler 54183242Ssam * @polling_thread: interrupt polling thread 55183242Ssam * @wait_active: the polling thread activity wait queue 56183242Ssam * @is_active: the device is active 57183242Ssam */ 58183242Ssamstruct mei_me_hw { 59156813Sru const struct mei_cfg *cfg; 60183242Ssam void __iomem *mem_addr; 61121911Smarkm int irq; 6237Srgrimes enum mei_pg_state pg_state; 63183242Ssam bool d0i3_supported; 64183242Ssam u8 hbuf_depth; 65158115Sume int (*read_fws)(const struct mei_device *dev, int where, u32 *val); 66158115Sume /* polling */ 67208320Sjkim struct task_struct *polling_thread; 68183242Ssam wait_queue_head_t wait_active; 69183242Ssam bool is_active; 70183242Ssam}; 71193635Sedwin 72193635Sedwin#define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw) 73193635Sedwin 74193635Sedwinstatic inline bool mei_me_hw_use_polling(const struct mei_me_hw *hw) 75156813Sru{ 7657488Speter return hw->irq < 0; 7774837Sgreen} 78124214Sdes 7957459Smarkm/** 80156813Sru * enum mei_cfg_idx - indices to platform specific configurations. 8160677Skris * 8260677Skris * Note: has to be synchronized with mei_cfg_list[] 8360677Skris * 84183242Ssam * @MEI_ME_UNDEF_CFG: Lower sentinel. 85183242Ssam * @MEI_ME_ICH_CFG: I/O Controller Hub legacy devices. 86183242Ssam * @MEI_ME_ICH10_CFG: I/O Controller Hub platforms Gen10 87183242Ssam * @MEI_ME_PCH6_CFG: Platform Controller Hub platforms (Gen6). 88183242Ssam * @MEI_ME_PCH7_CFG: Platform Controller Hub platforms (Gen7). 89183242Ssam * @MEI_ME_PCH_CPT_PBG_CFG:Platform Controller Hub workstations 90183242Ssam * with quirk for Node Manager exclusion. 91183242Ssam * @MEI_ME_PCH8_CFG: Platform Controller Hub Gen8 and newer 92183242Ssam * client platforms. 93183242Ssam * @MEI_ME_PCH8_ITOUCH_CFG:Platform Controller Hub Gen8 and newer 94183242Ssam * client platforms (iTouch). 95183242Ssam * @MEI_ME_PCH8_SPS_4_CFG: Platform Controller Hub Gen8 and newer 96184343Ssam * servers platforms with quirk for 97184343Ssam * SPS firmware exclusion. 98184343Ssam * @MEI_ME_PCH12_CFG: Platform Controller Hub Gen12 and newer 99184343Ssam * @MEI_ME_PCH12_SPS_4_CFG:Platform Controller Hub Gen12 up to 4.0 100183268Ssam * servers platforms with quirk for 101183268Ssam * SPS firmware exclusion. 102183268Ssam * @MEI_ME_PCH12_SPS_CFG: Platform Controller Hub Gen12 5.0 and newer 103183268Ssam * servers platforms with quirk for 10482521Salex * SPS firmware exclusion. 105108002Sgreen * @MEI_ME_PCH12_SPS_ITOUCH_CFG: Platform Controller Hub Gen12 106147Srgrimes * client platforms (iTouch) 107196767Sflz * @MEI_ME_PCH15_CFG: Platform Controller Hub Gen15 and newer 108156813Sru * @MEI_ME_PCH15_SPS_CFG: Platform Controller Hub Gen15 and newer 10995144Sgshapiro * servers platforms with quirk for 11095144Sgshapiro * SPS firmware exclusion. 111156813Sru * @MEI_ME_GSC_CFG: Graphics System Controller 112135851Sdougb * @MEI_ME_GSCFI_CFG: Graphics System Controller Firmware Interface 113156813Sru * @MEI_ME_NUM_CFG: Upper Sentinel. 114135851Sdougb */ 115135851Sdougbenum mei_cfg_idx { 116135851Sdougb MEI_ME_UNDEF_CFG, 11799451Sru MEI_ME_ICH_CFG, 11899451Sru MEI_ME_ICH10_CFG, 11999451Sru MEI_ME_PCH6_CFG, 120156813Sru MEI_ME_PCH7_CFG, 121117292Sgshapiro MEI_ME_PCH_CPT_PBG_CFG, 122117292Sgshapiro MEI_ME_PCH8_CFG, 12364598Sgshapiro MEI_ME_PCH8_ITOUCH_CFG, 12464598Sgshapiro MEI_ME_PCH8_SPS_4_CFG, 125117292Sgshapiro MEI_ME_PCH12_CFG, 12637Srgrimes MEI_ME_PCH12_SPS_4_CFG, 127263Srgrimes MEI_ME_PCH12_SPS_CFG, 12899449Sru MEI_ME_PCH12_SPS_ITOUCH_CFG, 129263Srgrimes MEI_ME_PCH15_CFG, 130124831Sru MEI_ME_PCH15_SPS_CFG, 131156813Sru MEI_ME_GSC_CFG, 132173135Syar MEI_ME_GSCFI_CFG, 133124831Sru MEI_ME_NUM_CFG, 134124831Sru}; 1354487Sphk 136173135Syarconst struct mei_cfg *mei_me_get_cfg(kernel_ulong_t idx); 137173135Syar 1385948Sjkhstruct mei_device *mei_me_dev_init(struct device *parent, 139142794Sru const struct mei_cfg *cfg, bool slow_fw); 140142794Sru 141152471Sruint mei_me_pg_enter_sync(struct mei_device *dev); 142152471Sruint mei_me_pg_exit_sync(struct mei_device *dev); 143142794Sru 144152471Sruirqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id); 145152471Sruirqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id); 146142794Sruint mei_me_polling_thread(void *_dev); 147149515Simp 148149515Simp#endif /* _MEI_INTERFACE_H_ */ 149142794Sru