Tomas Winkler | 9fff042 | 2019-03-12 00:10:41 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Tomas Winkler | 9dc64d6 | 2013-01-08 23:07:17 +0200 | [diff] [blame] | 2 | /* |
Tomas Winkler | f76d77f | 2020-06-19 19:51:15 +0300 | [diff] [blame] | 3 | * Copyright (c) 2012-2020, Intel Corporation. All rights reserved. |
Tomas Winkler | 66ef5ea | 2012-12-25 19:06:02 +0200 | [diff] [blame] | 4 | * Intel Management Engine Interface (Intel MEI) Linux driver |
Tomas Winkler | 66ef5ea | 2012-12-25 19:06:02 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
Tomas Winkler | 9dc64d6 | 2013-01-08 23:07:17 +0200 | [diff] [blame] | 7 | #ifndef _MEI_INTERFACE_H_ |
| 8 | #define _MEI_INTERFACE_H_ |
| 9 | |
Bjorn Helgaas | 81ec550 | 2014-02-14 14:06:14 -0700 | [diff] [blame] | 10 | #include <linux/irqreturn.h> |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 11 | #include <linux/pci.h> |
| 12 | #include <linux/mei.h> |
| 13 | |
Tomas Winkler | 9dc64d6 | 2013-01-08 23:07:17 +0200 | [diff] [blame] | 14 | #include "mei_dev.h" |
Tomas Winkler | 52c3456 | 2013-02-06 14:06:40 +0200 | [diff] [blame] | 15 | #include "client.h" |
Tomas Winkler | 66ef5ea | 2012-12-25 19:06:02 +0200 | [diff] [blame] | 16 | |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 17 | /* |
| 18 | * mei_cfg - mei device configuration |
| 19 | * |
| 20 | * @fw_status: FW status |
| 21 | * @quirk_probe: device exclusion quirk |
Alexander Usyskin | 2f79d3d | 2020-07-28 22:22:42 +0300 | [diff] [blame] | 22 | * @kind: MEI head kind |
Alexander Usyskin | 7026a5f | 2018-07-31 09:35:37 +0300 | [diff] [blame] | 23 | * @dma_size: device DMA buffers size |
Alexander Usyskin | f8204f0 | 2019-10-04 21:17:22 +0300 | [diff] [blame] | 24 | * @fw_ver_supported: is fw version retrievable from FW |
Alexander Usyskin | 52f6efd | 2019-11-07 12:44:45 +0200 | [diff] [blame] | 25 | * @hw_trc_supported: does the hw support trc register |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 26 | */ |
| 27 | struct mei_cfg { |
| 28 | const struct mei_fw_status fw_status; |
Tomas Winkler | 45a2c76 | 2020-06-19 19:51:16 +0300 | [diff] [blame] | 29 | bool (*quirk_probe)(const struct pci_dev *pdev); |
Alexander Usyskin | 2f79d3d | 2020-07-28 22:22:42 +0300 | [diff] [blame] | 30 | const char *kind; |
Alexander Usyskin | 7026a5f | 2018-07-31 09:35:37 +0300 | [diff] [blame] | 31 | size_t dma_size[DMA_DSCR_NUM]; |
Alexander Usyskin | f8204f0 | 2019-10-04 21:17:22 +0300 | [diff] [blame] | 32 | u32 fw_ver_supported:1; |
Alexander Usyskin | 52f6efd | 2019-11-07 12:44:45 +0200 | [diff] [blame] | 33 | u32 hw_trc_supported:1; |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 34 | }; |
| 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 Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 40 | .driver_data = (kernel_ulong_t)(cfg), |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 41 | |
Tomas Winkler | 180ea05 | 2014-03-18 22:52:02 +0200 | [diff] [blame] | 42 | #define MEI_ME_RPM_TIMEOUT 500 /* ms */ |
| 43 | |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 44 | /** |
Alexander Usyskin | ce23139 | 2014-09-29 16:31:50 +0300 | [diff] [blame] | 45 | * struct mei_me_hw - me hw specific data |
| 46 | * |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 47 | * @cfg: per device generation config and ops |
Alexander Usyskin | bb9f4d2 | 2015-08-02 22:20:51 +0300 | [diff] [blame] | 48 | * @mem_addr: io memory address |
Alexander Usyskin | 261b3e1 | 2019-11-07 00:38:40 +0200 | [diff] [blame] | 49 | * @irq: irq number |
Alexander Usyskin | bb9f4d2 | 2015-08-02 22:20:51 +0300 | [diff] [blame] | 50 | * @pg_state: power gating state |
| 51 | * @d0i3_supported: di03 support |
Tomas Winkler | 8c8d964 | 2018-07-23 13:21:23 +0300 | [diff] [blame] | 52 | * @hbuf_depth: depth of hardware host/write buffer in slots |
Tomas Winkler | 261e071 | 2019-11-07 00:38:41 +0200 | [diff] [blame] | 53 | * @read_fws: read FW status register handler |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 54 | */ |
Tomas Winkler | 52c3456 | 2013-02-06 14:06:40 +0200 | [diff] [blame] | 55 | struct mei_me_hw { |
Tomas Winkler | 4ad96db | 2014-09-29 16:31:45 +0300 | [diff] [blame] | 56 | const struct mei_cfg *cfg; |
Tomas Winkler | 52c3456 | 2013-02-06 14:06:40 +0200 | [diff] [blame] | 57 | void __iomem *mem_addr; |
Alexander Usyskin | 261b3e1 | 2019-11-07 00:38:40 +0200 | [diff] [blame] | 58 | int irq; |
Tomas Winkler | ba9cdd0 | 2014-03-18 22:52:00 +0200 | [diff] [blame] | 59 | enum mei_pg_state pg_state; |
Alexander Usyskin | bb9f4d2 | 2015-08-02 22:20:51 +0300 | [diff] [blame] | 60 | bool d0i3_supported; |
Tomas Winkler | 8c8d964 | 2018-07-23 13:21:23 +0300 | [diff] [blame] | 61 | u8 hbuf_depth; |
Tomas Winkler | 261e071 | 2019-11-07 00:38:41 +0200 | [diff] [blame] | 62 | int (*read_fws)(const struct mei_device *dev, int where, u32 *val); |
Tomas Winkler | 52c3456 | 2013-02-06 14:06:40 +0200 | [diff] [blame] | 63 | }; |
Tomas Winkler | 66ef5ea | 2012-12-25 19:06:02 +0200 | [diff] [blame] | 64 | |
Tomas Winkler | 52c3456 | 2013-02-06 14:06:40 +0200 | [diff] [blame] | 65 | #define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw) |
| 66 | |
Tomas Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 67 | /** |
| 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 Usyskin | f8204f0 | 2019-10-04 21:17:22 +0300 | [diff] [blame] | 75 | * @MEI_ME_PCH6_CFG: Platform Controller Hub platforms (Gen6). |
| 76 | * @MEI_ME_PCH7_CFG: Platform Controller Hub platforms (Gen7). |
Tomas Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 77 | * @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 Usyskin | 2f79d3d | 2020-07-28 22:22:42 +0300 | [diff] [blame] | 81 | * @MEI_ME_PCH8_ITOUCH_CFG:Platform Controller Hub Gen8 and newer |
| 82 | * client platforms (iTouch). |
Tomas Winkler | f76d77f | 2020-06-19 19:51:15 +0300 | [diff] [blame] | 83 | * @MEI_ME_PCH8_SPS_4_CFG: Platform Controller Hub Gen8 and newer |
Tomas Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 84 | * servers platforms with quirk for |
| 85 | * SPS firmware exclusion. |
Alexander Usyskin | 7026a5f | 2018-07-31 09:35:37 +0300 | [diff] [blame] | 86 | * @MEI_ME_PCH12_CFG: Platform Controller Hub Gen12 and newer |
Tomas Winkler | f76d77f | 2020-06-19 19:51:15 +0300 | [diff] [blame] | 87 | * @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 Winkler | d76bc82 | 2020-04-29 00:12:00 +0300 | [diff] [blame] | 91 | * servers platforms with quirk for |
| 92 | * SPS firmware exclusion. |
Alexander Usyskin | 52f6efd | 2019-11-07 12:44:45 +0200 | [diff] [blame] | 93 | * @MEI_ME_PCH15_CFG: Platform Controller Hub Gen15 and newer |
Alexander Usyskin | 8c289ea | 2020-06-19 19:51:21 +0300 | [diff] [blame] | 94 | * @MEI_ME_PCH15_SPS_CFG: Platform Controller Hub Gen15 and newer |
| 95 | * servers platforms with quirk for |
| 96 | * SPS firmware exclusion. |
Tomas Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 97 | * @MEI_ME_NUM_CFG: Upper Sentinel. |
| 98 | */ |
| 99 | enum mei_cfg_idx { |
| 100 | MEI_ME_UNDEF_CFG, |
| 101 | MEI_ME_ICH_CFG, |
| 102 | MEI_ME_ICH10_CFG, |
Alexander Usyskin | f8204f0 | 2019-10-04 21:17:22 +0300 | [diff] [blame] | 103 | MEI_ME_PCH6_CFG, |
| 104 | MEI_ME_PCH7_CFG, |
Tomas Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 105 | MEI_ME_PCH_CPT_PBG_CFG, |
| 106 | MEI_ME_PCH8_CFG, |
Alexander Usyskin | 2f79d3d | 2020-07-28 22:22:42 +0300 | [diff] [blame] | 107 | MEI_ME_PCH8_ITOUCH_CFG, |
Tomas Winkler | f76d77f | 2020-06-19 19:51:15 +0300 | [diff] [blame] | 108 | MEI_ME_PCH8_SPS_4_CFG, |
Alexander Usyskin | 7026a5f | 2018-07-31 09:35:37 +0300 | [diff] [blame] | 109 | MEI_ME_PCH12_CFG, |
Tomas Winkler | f76d77f | 2020-06-19 19:51:15 +0300 | [diff] [blame] | 110 | MEI_ME_PCH12_SPS_4_CFG, |
Tomas Winkler | d76bc82 | 2020-04-29 00:12:00 +0300 | [diff] [blame] | 111 | MEI_ME_PCH12_SPS_CFG, |
Alexander Usyskin | 2f79d3d | 2020-07-28 22:22:42 +0300 | [diff] [blame] | 112 | MEI_ME_PCH12_SPS_ITOUCH_CFG, |
Alexander Usyskin | 52f6efd | 2019-11-07 12:44:45 +0200 | [diff] [blame] | 113 | MEI_ME_PCH15_CFG, |
Alexander Usyskin | 8c289ea | 2020-06-19 19:51:21 +0300 | [diff] [blame] | 114 | MEI_ME_PCH15_SPS_CFG, |
Tomas Winkler | f5ac3c4 | 2017-06-14 10:03:15 +0300 | [diff] [blame] | 115 | MEI_ME_NUM_CFG, |
| 116 | }; |
| 117 | |
| 118 | const struct mei_cfg *mei_me_get_cfg(kernel_ulong_t idx); |
Alexander Usyskin | 8d929d4 | 2014-05-13 01:30:53 +0300 | [diff] [blame] | 119 | |
Tomas Winkler | 907b471 | 2019-11-07 00:38:39 +0200 | [diff] [blame] | 120 | struct mei_device *mei_me_dev_init(struct device *parent, |
Alexander Usyskin | 8d929d4 | 2014-05-13 01:30:53 +0300 | [diff] [blame] | 121 | const struct mei_cfg *cfg); |
Tomas Winkler | 66ef5ea | 2012-12-25 19:06:02 +0200 | [diff] [blame] | 122 | |
Alexander Usyskin | 2d1995f | 2015-02-10 10:39:34 +0200 | [diff] [blame] | 123 | int mei_me_pg_enter_sync(struct mei_device *dev); |
| 124 | int mei_me_pg_exit_sync(struct mei_device *dev); |
Tomas Winkler | ba9cdd0 | 2014-03-18 22:52:00 +0200 | [diff] [blame] | 125 | |
Tomas Winkler | 06ecd64 | 2013-02-06 14:06:42 +0200 | [diff] [blame] | 126 | irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id); |
| 127 | irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id); |
| 128 | |
Tomas Winkler | 9dc64d6 | 2013-01-08 23:07:17 +0200 | [diff] [blame] | 129 | #endif /* _MEI_INTERFACE_H_ */ |