Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <device/pci_ids.h> |
| 6 | #include <device/spi.h> |
| 7 | #include <intelblocks/fast_spi.h> |
| 8 | #include <intelblocks/gspi.h> |
| 9 | #include <intelblocks/spi.h> |
| 10 | #include <soc/pci_devs.h> |
| 11 | #include <spi-generic.h> |
| 12 | |
| 13 | const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = { |
| 14 | { .ctrlr = &fast_spi_flash_ctrlr, .bus_start = 0, .bus_end = 0 }, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 15 | #if !ENV_SMM && CONFIG(SOC_INTEL_COMMON_BLOCK_GSPI) |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 16 | { .ctrlr = &gspi_ctrlr, .bus_start = 1, |
| 17 | .bus_end = 1 + (CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX - 1)}, |
| 18 | #endif |
| 19 | }; |
| 20 | |
| 21 | const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map); |
| 22 | |
| 23 | static int spi_dev_to_bus(struct device *dev) |
| 24 | { |
| 25 | return spi_soc_devfn_to_bus(dev->path.pci.devfn); |
| 26 | } |
| 27 | |
| 28 | static struct spi_bus_operations spi_bus_ops = { |
| 29 | .dev_to_bus = &spi_dev_to_bus, |
| 30 | }; |
| 31 | |
| 32 | static struct device_operations spi_dev_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 33 | .read_resources = pci_dev_read_resources, |
| 34 | .set_resources = pci_dev_set_resources, |
| 35 | .enable_resources = pci_dev_enable_resources, |
| 36 | .scan_bus = scan_generic_bus, |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 37 | .ops_spi_bus = &spi_bus_ops, |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 38 | .ops_pci = &pci_dev_ops_pci, |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static const unsigned short pci_device_ids[] = { |
| 42 | PCI_DEVICE_ID_INTEL_SPT_SPI1, |
| 43 | PCI_DEVICE_ID_INTEL_SPT_SPI2, |
| 44 | PCI_DEVICE_ID_INTEL_SPT_SPI3, |
| 45 | PCI_DEVICE_ID_INTEL_APL_SPI0, |
| 46 | PCI_DEVICE_ID_INTEL_APL_SPI1, |
| 47 | PCI_DEVICE_ID_INTEL_APL_SPI2, |
| 48 | PCI_DEVICE_ID_INTEL_APL_HWSEQ_SPI, |
| 49 | PCI_DEVICE_ID_INTEL_GLK_SPI0, |
| 50 | PCI_DEVICE_ID_INTEL_GLK_SPI1, |
| 51 | PCI_DEVICE_ID_INTEL_GLK_SPI2, |
| 52 | PCI_DEVICE_ID_INTEL_CNL_SPI0, |
| 53 | PCI_DEVICE_ID_INTEL_CNL_SPI1, |
| 54 | PCI_DEVICE_ID_INTEL_CNL_SPI2, |
| 55 | PCI_DEVICE_ID_INTEL_CNL_HWSEQ_SPI, |
Lean Sheng Tan | 38c3ff7 | 2019-05-27 13:06:35 +0800 | [diff] [blame] | 56 | PCI_DEVICE_ID_INTEL_CNP_H_SPI0, |
| 57 | PCI_DEVICE_ID_INTEL_CNP_H_SPI1, |
| 58 | PCI_DEVICE_ID_INTEL_CNP_H_SPI2, |
| 59 | PCI_DEVICE_ID_INTEL_CNP_H_HWSEQ_SPI, |
Maxim Polyakov | 571d07d | 2019-08-22 13:11:32 +0300 | [diff] [blame] | 60 | PCI_DEVICE_ID_INTEL_LWB_SPI, |
| 61 | PCI_DEVICE_ID_INTEL_LWB_SPI_SUPER, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 62 | PCI_DEVICE_ID_INTEL_ICP_SPI0, |
| 63 | PCI_DEVICE_ID_INTEL_ICP_SPI1, |
| 64 | PCI_DEVICE_ID_INTEL_ICP_SPI2, |
| 65 | PCI_DEVICE_ID_INTEL_ICP_HWSEQ_SPI, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 66 | PCI_DEVICE_ID_INTEL_CMP_SPI0, |
| 67 | PCI_DEVICE_ID_INTEL_CMP_SPI1, |
| 68 | PCI_DEVICE_ID_INTEL_CMP_SPI2, |
| 69 | PCI_DEVICE_ID_INTEL_CMP_HWSEQ_SPI, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 70 | PCI_DEVICE_ID_INTEL_CMP_H_SPI0, |
| 71 | PCI_DEVICE_ID_INTEL_CMP_H_SPI1, |
| 72 | PCI_DEVICE_ID_INTEL_CMP_H_SPI2, |
| 73 | PCI_DEVICE_ID_INTEL_CMP_H_HWSEQ_SPI, |
Ravi Sarawadi | 6b5bf40 | 2019-10-21 22:25:04 -0700 | [diff] [blame] | 74 | PCI_DEVICE_ID_INTEL_TGP_SPI0, |
| 75 | PCI_DEVICE_ID_INTEL_TGP_GSPI0, |
| 76 | PCI_DEVICE_ID_INTEL_TGP_GSPI1, |
| 77 | PCI_DEVICE_ID_INTEL_TGP_GSPI2, |
| 78 | PCI_DEVICE_ID_INTEL_TGP_GSPI3, |
| 79 | PCI_DEVICE_ID_INTEL_TGP_GSPI4, |
| 80 | PCI_DEVICE_ID_INTEL_TGP_GSPI5, |
| 81 | PCI_DEVICE_ID_INTEL_TGP_GSPI6, |
Jeremy Soller | 191a8d7 | 2021-08-10 14:06:51 -0600 | [diff] [blame] | 82 | PCI_DEVICE_ID_INTEL_TGP_H_SPI0, |
| 83 | PCI_DEVICE_ID_INTEL_TGP_H_GSPI0, |
| 84 | PCI_DEVICE_ID_INTEL_TGP_H_GSPI1, |
| 85 | PCI_DEVICE_ID_INTEL_TGP_H_GSPI2, |
| 86 | PCI_DEVICE_ID_INTEL_TGP_H_GSPI3, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 87 | PCI_DEVICE_ID_INTEL_MCC_SPI0, |
| 88 | PCI_DEVICE_ID_INTEL_MCC_GSPI0, |
| 89 | PCI_DEVICE_ID_INTEL_MCC_GSPI1, |
| 90 | PCI_DEVICE_ID_INTEL_MCC_GSPI2, |
Meera Ravindranath | 3f4af0d | 2020-02-12 16:01:22 +0530 | [diff] [blame] | 91 | PCI_DEVICE_ID_INTEL_JSP_SPI0, |
| 92 | PCI_DEVICE_ID_INTEL_JSP_SPI1, |
| 93 | PCI_DEVICE_ID_INTEL_JSP_SPI2, |
| 94 | PCI_DEVICE_ID_INTEL_JSP_HWSEQ_SPI, |
Subrata Banik | f672f7f | 2020-08-03 14:29:25 +0530 | [diff] [blame] | 95 | PCI_DEVICE_ID_INTEL_ADP_P_HWSEQ_SPI, |
| 96 | PCI_DEVICE_ID_INTEL_ADP_S_HWSEQ_SPI, |
Usha P | af5a9d6 | 2022-01-17 20:24:31 +0530 | [diff] [blame] | 97 | PCI_DEVICE_ID_INTEL_ADP_M_N_HWSEQ_SPI, |
Subrata Banik | f672f7f | 2020-08-03 14:29:25 +0530 | [diff] [blame] | 98 | PCI_DEVICE_ID_INTEL_ADP_P_SPI0, |
| 99 | PCI_DEVICE_ID_INTEL_ADP_P_SPI1, |
| 100 | PCI_DEVICE_ID_INTEL_ADP_P_SPI2, |
| 101 | PCI_DEVICE_ID_INTEL_ADP_P_SPI3, |
| 102 | PCI_DEVICE_ID_INTEL_ADP_P_SPI4, |
| 103 | PCI_DEVICE_ID_INTEL_ADP_P_SPI5, |
| 104 | PCI_DEVICE_ID_INTEL_ADP_P_SPI6, |
| 105 | PCI_DEVICE_ID_INTEL_ADP_S_SPI0, |
| 106 | PCI_DEVICE_ID_INTEL_ADP_S_SPI1, |
| 107 | PCI_DEVICE_ID_INTEL_ADP_S_SPI2, |
| 108 | PCI_DEVICE_ID_INTEL_ADP_S_SPI3, |
| 109 | PCI_DEVICE_ID_INTEL_ADP_S_SPI4, |
| 110 | PCI_DEVICE_ID_INTEL_ADP_S_SPI5, |
| 111 | PCI_DEVICE_ID_INTEL_ADP_S_SPI6, |
Usha P | af5a9d6 | 2022-01-17 20:24:31 +0530 | [diff] [blame] | 112 | PCI_DEVICE_ID_INTEL_ADP_M_N_SPI0, |
| 113 | PCI_DEVICE_ID_INTEL_ADP_M_N_SPI1, |
Varshit Pandya | f4d98fdd2 | 2021-01-17 18:39:29 +0530 | [diff] [blame] | 114 | PCI_DEVICE_ID_INTEL_ADP_M_SPI2, |
Jonathan Zhang | 492a792 | 2021-03-06 10:31:46 -0800 | [diff] [blame] | 115 | PCI_DEVICE_ID_INTEL_SPR_HWSEQ_SPI, |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 116 | 0 |
| 117 | }; |
| 118 | |
| 119 | static const struct pci_driver pch_spi __pci_driver = { |
| 120 | .ops = &spi_dev_ops, |
| 121 | .vendor = PCI_VENDOR_ID_INTEL, |
| 122 | .devices = pci_device_ids, |
| 123 | }; |