blob: 00a7132ac7a2eb9e2f34f84e0f831e48f77435d7 [file] [log] [blame]
Tomas Winkler9fff0422019-03-12 00:10:41 +02001/* SPDX-License-Identifier: GPL-2.0 */
Tomas Winkler9dc64d62013-01-08 23:07:17 +02002/*
Tomas Winklerf76d77f2020-06-19 19:51:15 +03003 * Copyright (c) 2012-2020, Intel Corporation. All rights reserved.
Tomas Winkler66ef5ea2012-12-25 19:06:02 +02004 * Intel Management Engine Interface (Intel MEI) Linux driver
Tomas Winkler66ef5ea2012-12-25 19:06:02 +02005 */
6
Tomas Winkler9dc64d62013-01-08 23:07:17 +02007#ifndef _MEI_INTERFACE_H_
8#define _MEI_INTERFACE_H_
9
Bjorn Helgaas81ec5502014-02-14 14:06:14 -070010#include <linux/irqreturn.h>
Tomas Winkler4ad96db2014-09-29 16:31:45 +030011#include <linux/pci.h>
12#include <linux/mei.h>
13
Tomas Winkler9dc64d62013-01-08 23:07:17 +020014#include "mei_dev.h"
Tomas Winkler52c34562013-02-06 14:06:40 +020015#include "client.h"
Tomas Winkler66ef5ea2012-12-25 19:06:02 +020016
Tomas Winkler4ad96db2014-09-29 16:31:45 +030017/*
18 * mei_cfg - mei device configuration
19 *
20 * @fw_status: FW status
21 * @quirk_probe: device exclusion quirk
Alexander Usyskin2f79d3d2020-07-28 22:22:42 +030022 * @kind: MEI head kind
Alexander Usyskin7026a5f2018-07-31 09:35:37 +030023 * @dma_size: device DMA buffers size
Alexander Usyskinf8204f02019-10-04 21:17:22 +030024 * @fw_ver_supported: is fw version retrievable from FW
Alexander Usyskin52f6efd2019-11-07 12:44:45 +020025 * @hw_trc_supported: does the hw support trc register
Tomas Winkler4ad96db2014-09-29 16:31:45 +030026 */
27struct mei_cfg {
28 const struct mei_fw_status fw_status;
Tomas Winkler45a2c762020-06-19 19:51:16 +030029 bool (*quirk_probe)(const struct pci_dev *pdev);
Alexander Usyskin2f79d3d2020-07-28 22:22:42 +030030 const char *kind;
Alexander Usyskin7026a5f2018-07-31 09:35:37 +030031 size_t dma_size[DMA_DSCR_NUM];
Alexander Usyskinf8204f02019-10-04 21:17:22 +030032 u32 fw_ver_supported:1;
Alexander Usyskin52f6efd2019-11-07 12:44:45 +020033 u32 hw_trc_supported:1;
Tomas Winkler4ad96db2014-09-29 16:31:45 +030034};
35
36
37#define MEI_PCI_DEVICE(dev, cfg) \
38 .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
39 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
Tomas Winklerf5ac3c42017-06-14 10:03:15 +030040 .driver_data = (kernel_ulong_t)(cfg),
Tomas Winkler4ad96db2014-09-29 16:31:45 +030041
Tomas Winkler180ea052014-03-18 22:52:02 +020042#define MEI_ME_RPM_TIMEOUT 500 /* ms */
43
Tomas Winkler4ad96db2014-09-29 16:31:45 +030044/**
Alexander Usyskince231392014-09-29 16:31:50 +030045 * struct mei_me_hw - me hw specific data
46 *
Tomas Winkler4ad96db2014-09-29 16:31:45 +030047 * @cfg: per device generation config and ops
Alexander Usyskinbb9f4d22015-08-02 22:20:51 +030048 * @mem_addr: io memory address
Alexander Usyskin261b3e12019-11-07 00:38:40 +020049 * @irq: irq number
Alexander Usyskinbb9f4d22015-08-02 22:20:51 +030050 * @pg_state: power gating state
51 * @d0i3_supported: di03 support
Tomas Winkler8c8d9642018-07-23 13:21:23 +030052 * @hbuf_depth: depth of hardware host/write buffer in slots
Tomas Winkler261e0712019-11-07 00:38:41 +020053 * @read_fws: read FW status register handler
Tomas Winkler4ad96db2014-09-29 16:31:45 +030054 */
Tomas Winkler52c34562013-02-06 14:06:40 +020055struct mei_me_hw {
Tomas Winkler4ad96db2014-09-29 16:31:45 +030056 const struct mei_cfg *cfg;
Tomas Winkler52c34562013-02-06 14:06:40 +020057 void __iomem *mem_addr;
Alexander Usyskin261b3e12019-11-07 00:38:40 +020058 int irq;
Tomas Winklerba9cdd02014-03-18 22:52:00 +020059 enum mei_pg_state pg_state;
Alexander Usyskinbb9f4d22015-08-02 22:20:51 +030060 bool d0i3_supported;
Tomas Winkler8c8d9642018-07-23 13:21:23 +030061 u8 hbuf_depth;
Tomas Winkler261e0712019-11-07 00:38:41 +020062 int (*read_fws)(const struct mei_device *dev, int where, u32 *val);
Tomas Winkler52c34562013-02-06 14:06:40 +020063};
Tomas Winkler66ef5ea2012-12-25 19:06:02 +020064
Tomas Winkler52c34562013-02-06 14:06:40 +020065#define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw)
66
Tomas Winklerf5ac3c42017-06-14 10:03:15 +030067/**
68 * enum mei_cfg_idx - indices to platform specific configurations.
69 *
70 * Note: has to be synchronized with mei_cfg_list[]
71 *
72 * @MEI_ME_UNDEF_CFG: Lower sentinel.
73 * @MEI_ME_ICH_CFG: I/O Controller Hub legacy devices.
74 * @MEI_ME_ICH10_CFG: I/O Controller Hub platforms Gen10
Alexander Usyskinf8204f02019-10-04 21:17:22 +030075 * @MEI_ME_PCH6_CFG: Platform Controller Hub platforms (Gen6).
76 * @MEI_ME_PCH7_CFG: Platform Controller Hub platforms (Gen7).
Tomas Winklerf5ac3c42017-06-14 10:03:15 +030077 * @MEI_ME_PCH_CPT_PBG_CFG:Platform Controller Hub workstations
78 * with quirk for Node Manager exclusion.
79 * @MEI_ME_PCH8_CFG: Platform Controller Hub Gen8 and newer
80 * client platforms.
Alexander Usyskin2f79d3d2020-07-28 22:22:42 +030081 * @MEI_ME_PCH8_ITOUCH_CFG:Platform Controller Hub Gen8 and newer
82 * client platforms (iTouch).
Tomas Winklerf76d77f2020-06-19 19:51:15 +030083 * @MEI_ME_PCH8_SPS_4_CFG: Platform Controller Hub Gen8 and newer
Tomas Winklerf5ac3c42017-06-14 10:03:15 +030084 * servers platforms with quirk for
85 * SPS firmware exclusion.
Alexander Usyskin7026a5f2018-07-31 09:35:37 +030086 * @MEI_ME_PCH12_CFG: Platform Controller Hub Gen12 and newer
Tomas Winklerf76d77f2020-06-19 19:51:15 +030087 * @MEI_ME_PCH12_SPS_4_CFG:Platform Controller Hub Gen12 up to 4.0
88 * servers platforms with quirk for
89 * SPS firmware exclusion.
90 * @MEI_ME_PCH12_SPS_CFG: Platform Controller Hub Gen12 5.0 and newer
Tomas Winklerd76bc822020-04-29 00:12:00 +030091 * servers platforms with quirk for
92 * SPS firmware exclusion.
Alexander Usyskin52f6efd2019-11-07 12:44:45 +020093 * @MEI_ME_PCH15_CFG: Platform Controller Hub Gen15 and newer
Alexander Usyskin8c289ea2020-06-19 19:51:21 +030094 * @MEI_ME_PCH15_SPS_CFG: Platform Controller Hub Gen15 and newer
95 * servers platforms with quirk for
96 * SPS firmware exclusion.
Tomas Winklerf5ac3c42017-06-14 10:03:15 +030097 * @MEI_ME_NUM_CFG: Upper Sentinel.
98 */
99enum mei_cfg_idx {
100 MEI_ME_UNDEF_CFG,
101 MEI_ME_ICH_CFG,
102 MEI_ME_ICH10_CFG,
Alexander Usyskinf8204f02019-10-04 21:17:22 +0300103 MEI_ME_PCH6_CFG,
104 MEI_ME_PCH7_CFG,
Tomas Winklerf5ac3c42017-06-14 10:03:15 +0300105 MEI_ME_PCH_CPT_PBG_CFG,
106 MEI_ME_PCH8_CFG,
Alexander Usyskin2f79d3d2020-07-28 22:22:42 +0300107 MEI_ME_PCH8_ITOUCH_CFG,
Tomas Winklerf76d77f2020-06-19 19:51:15 +0300108 MEI_ME_PCH8_SPS_4_CFG,
Alexander Usyskin7026a5f2018-07-31 09:35:37 +0300109 MEI_ME_PCH12_CFG,
Tomas Winklerf76d77f2020-06-19 19:51:15 +0300110 MEI_ME_PCH12_SPS_4_CFG,
Tomas Winklerd76bc822020-04-29 00:12:00 +0300111 MEI_ME_PCH12_SPS_CFG,
Alexander Usyskin2f79d3d2020-07-28 22:22:42 +0300112 MEI_ME_PCH12_SPS_ITOUCH_CFG,
Alexander Usyskin52f6efd2019-11-07 12:44:45 +0200113 MEI_ME_PCH15_CFG,
Alexander Usyskin8c289ea2020-06-19 19:51:21 +0300114 MEI_ME_PCH15_SPS_CFG,
Tomas Winklerf5ac3c42017-06-14 10:03:15 +0300115 MEI_ME_NUM_CFG,
116};
117
118const struct mei_cfg *mei_me_get_cfg(kernel_ulong_t idx);
Alexander Usyskin8d929d42014-05-13 01:30:53 +0300119
Tomas Winkler907b4712019-11-07 00:38:39 +0200120struct mei_device *mei_me_dev_init(struct device *parent,
Alexander Usyskin8d929d42014-05-13 01:30:53 +0300121 const struct mei_cfg *cfg);
Tomas Winkler66ef5ea2012-12-25 19:06:02 +0200122
Alexander Usyskin2d1995f2015-02-10 10:39:34 +0200123int mei_me_pg_enter_sync(struct mei_device *dev);
124int mei_me_pg_exit_sync(struct mei_device *dev);
Tomas Winklerba9cdd02014-03-18 22:52:00 +0200125
Tomas Winkler06ecd642013-02-06 14:06:42 +0200126irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id);
127irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id);
128
Tomas Winkler9dc64d62013-01-08 23:07:17 +0200129#endif /* _MEI_INTERFACE_H_ */