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[] = { |
Wonkyu Kim | 9f40107 | 2020-11-13 15:16:32 -0800 | [diff] [blame^] | 42 | PCI_DID_INTEL_MTL_HWSEQ_SPI, |
| 43 | PCI_DID_INTEL_MTL_GSPI0, |
| 44 | PCI_DID_INTEL_MTL_GSPI1, |
| 45 | PCI_DID_INTEL_MTL_GSPI2, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 46 | PCI_DID_INTEL_SPT_SPI1, |
| 47 | PCI_DID_INTEL_SPT_SPI2, |
| 48 | PCI_DID_INTEL_SPT_SPI3, |
| 49 | PCI_DID_INTEL_APL_SPI0, |
| 50 | PCI_DID_INTEL_APL_SPI1, |
| 51 | PCI_DID_INTEL_APL_SPI2, |
| 52 | PCI_DID_INTEL_APL_HWSEQ_SPI, |
| 53 | PCI_DID_INTEL_GLK_SPI0, |
| 54 | PCI_DID_INTEL_GLK_SPI1, |
| 55 | PCI_DID_INTEL_GLK_SPI2, |
| 56 | PCI_DID_INTEL_CNL_SPI0, |
| 57 | PCI_DID_INTEL_CNL_SPI1, |
| 58 | PCI_DID_INTEL_CNL_SPI2, |
| 59 | PCI_DID_INTEL_CNL_HWSEQ_SPI, |
| 60 | PCI_DID_INTEL_CNP_H_SPI0, |
| 61 | PCI_DID_INTEL_CNP_H_SPI1, |
| 62 | PCI_DID_INTEL_CNP_H_SPI2, |
| 63 | PCI_DID_INTEL_CNP_H_HWSEQ_SPI, |
| 64 | PCI_DID_INTEL_LWB_SPI, |
| 65 | PCI_DID_INTEL_LWB_SPI_SUPER, |
| 66 | PCI_DID_INTEL_ICP_SPI0, |
| 67 | PCI_DID_INTEL_ICP_SPI1, |
| 68 | PCI_DID_INTEL_ICP_SPI2, |
| 69 | PCI_DID_INTEL_ICP_HWSEQ_SPI, |
| 70 | PCI_DID_INTEL_CMP_SPI0, |
| 71 | PCI_DID_INTEL_CMP_SPI1, |
| 72 | PCI_DID_INTEL_CMP_SPI2, |
| 73 | PCI_DID_INTEL_CMP_HWSEQ_SPI, |
| 74 | PCI_DID_INTEL_CMP_H_SPI0, |
| 75 | PCI_DID_INTEL_CMP_H_SPI1, |
| 76 | PCI_DID_INTEL_CMP_H_SPI2, |
| 77 | PCI_DID_INTEL_CMP_H_HWSEQ_SPI, |
| 78 | PCI_DID_INTEL_TGP_SPI0, |
| 79 | PCI_DID_INTEL_TGP_GSPI0, |
| 80 | PCI_DID_INTEL_TGP_GSPI1, |
| 81 | PCI_DID_INTEL_TGP_GSPI2, |
| 82 | PCI_DID_INTEL_TGP_GSPI3, |
| 83 | PCI_DID_INTEL_TGP_GSPI4, |
| 84 | PCI_DID_INTEL_TGP_GSPI5, |
| 85 | PCI_DID_INTEL_TGP_GSPI6, |
| 86 | PCI_DID_INTEL_TGP_H_SPI0, |
| 87 | PCI_DID_INTEL_TGP_H_GSPI0, |
| 88 | PCI_DID_INTEL_TGP_H_GSPI1, |
| 89 | PCI_DID_INTEL_TGP_H_GSPI2, |
| 90 | PCI_DID_INTEL_TGP_H_GSPI3, |
| 91 | PCI_DID_INTEL_MCC_SPI0, |
| 92 | PCI_DID_INTEL_MCC_GSPI0, |
| 93 | PCI_DID_INTEL_MCC_GSPI1, |
| 94 | PCI_DID_INTEL_MCC_GSPI2, |
| 95 | PCI_DID_INTEL_JSP_SPI0, |
| 96 | PCI_DID_INTEL_JSP_SPI1, |
| 97 | PCI_DID_INTEL_JSP_SPI2, |
| 98 | PCI_DID_INTEL_JSP_HWSEQ_SPI, |
| 99 | PCI_DID_INTEL_ADP_P_HWSEQ_SPI, |
| 100 | PCI_DID_INTEL_ADP_S_HWSEQ_SPI, |
| 101 | PCI_DID_INTEL_ADP_M_N_HWSEQ_SPI, |
| 102 | PCI_DID_INTEL_ADP_P_SPI0, |
| 103 | PCI_DID_INTEL_ADP_P_SPI1, |
| 104 | PCI_DID_INTEL_ADP_P_SPI2, |
| 105 | PCI_DID_INTEL_ADP_P_SPI3, |
| 106 | PCI_DID_INTEL_ADP_P_SPI4, |
| 107 | PCI_DID_INTEL_ADP_P_SPI5, |
| 108 | PCI_DID_INTEL_ADP_P_SPI6, |
| 109 | PCI_DID_INTEL_ADP_S_SPI0, |
| 110 | PCI_DID_INTEL_ADP_S_SPI1, |
| 111 | PCI_DID_INTEL_ADP_S_SPI2, |
| 112 | PCI_DID_INTEL_ADP_S_SPI3, |
| 113 | PCI_DID_INTEL_ADP_S_SPI4, |
| 114 | PCI_DID_INTEL_ADP_S_SPI5, |
| 115 | PCI_DID_INTEL_ADP_S_SPI6, |
| 116 | PCI_DID_INTEL_ADP_M_N_SPI0, |
| 117 | PCI_DID_INTEL_ADP_M_N_SPI1, |
| 118 | PCI_DID_INTEL_ADP_M_SPI2, |
| 119 | PCI_DID_INTEL_SPR_HWSEQ_SPI, |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 120 | 0 |
| 121 | }; |
| 122 | |
| 123 | static const struct pci_driver pch_spi __pci_driver = { |
| 124 | .ops = &spi_dev_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 125 | .vendor = PCI_VID_INTEL, |
Subrata Banik | 6c4b591 | 2017-11-07 16:10:05 +0530 | [diff] [blame] | 126 | .devices = pci_device_ids, |
| 127 | }; |