Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: mediatek: Convert bool to single quirks entry and bitmap

To clean Mediatek SoC PCIe struct, convert all the bool to a bitmap and
use a single quirks to reference all the values. This permits cleaner
addition of new quirk without having to define a new bool in the struct.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patch.msgid.link/20251020111121.31779-4-ansuelsmth@gmail.com

authored by

Christian Marangi and committed by
Manivannan Sadhasivam
04305367 6d55d5a7

+20 -13
+20 -13
drivers/pci/controller/pcie-mediatek.c
··· 143 143 struct mtk_pcie_port; 144 144 145 145 /** 146 + * enum mtk_pcie_quirks - MTK PCIe quirks 147 + * @MTK_PCIE_FIX_CLASS_ID: host's class ID needed to be fixed 148 + * @MTK_PCIE_FIX_DEVICE_ID: host's device ID needed to be fixed 149 + * @MTK_PCIE_NO_MSI: Bridge has no MSI support, and relies on an external block 150 + */ 151 + enum mtk_pcie_quirks { 152 + MTK_PCIE_FIX_CLASS_ID = BIT(0), 153 + MTK_PCIE_FIX_DEVICE_ID = BIT(1), 154 + MTK_PCIE_NO_MSI = BIT(2), 155 + }; 156 + 157 + /** 146 158 * struct mtk_pcie_soc - differentiate between host generations 147 - * @need_fix_class_id: whether this host's class ID needed to be fixed or not 148 - * @need_fix_device_id: whether this host's device ID needed to be fixed or not 149 - * @no_msi: Bridge has no MSI support, and relies on an external block 150 159 * @device_id: device ID which this host need to be fixed 151 160 * @ops: pointer to configuration access functions 152 161 * @startup: pointer to controller setting functions 153 162 * @setup_irq: pointer to initialize IRQ functions 163 + * @quirks: PCIe device quirks. 154 164 */ 155 165 struct mtk_pcie_soc { 156 - bool need_fix_class_id; 157 - bool need_fix_device_id; 158 - bool no_msi; 159 166 unsigned int device_id; 160 167 struct pci_ops *ops; 161 168 int (*startup)(struct mtk_pcie_port *port); 162 169 int (*setup_irq)(struct mtk_pcie_port *port, struct device_node *node); 170 + enum mtk_pcie_quirks quirks; 163 171 }; 164 172 165 173 /** ··· 711 703 writel(val, port->base + PCIE_RST_CTRL); 712 704 713 705 /* Set up vendor ID and class code */ 714 - if (soc->need_fix_class_id) { 706 + if (soc->quirks & MTK_PCIE_FIX_CLASS_ID) { 715 707 val = PCI_VENDOR_ID_MEDIATEK; 716 708 writew(val, port->base + PCIE_CONF_VEND_ID); 717 709 ··· 719 711 writew(val, port->base + PCIE_CONF_CLASS_ID); 720 712 } 721 713 722 - if (soc->need_fix_device_id) 714 + if (soc->quirks & MTK_PCIE_FIX_DEVICE_ID) 723 715 writew(soc->device_id, port->base + PCIE_CONF_DEVICE_ID); 724 716 725 717 /* 100ms timeout value should be enough for Gen1/2 training */ ··· 1107 1099 1108 1100 host->ops = pcie->soc->ops; 1109 1101 host->sysdata = pcie; 1110 - host->msi_domain = pcie->soc->no_msi; 1102 + host->msi_domain = !!(pcie->soc->quirks & MTK_PCIE_NO_MSI); 1111 1103 1112 1104 err = pci_host_probe(host); 1113 1105 if (err) ··· 1195 1187 }; 1196 1188 1197 1189 static const struct mtk_pcie_soc mtk_pcie_soc_v1 = { 1198 - .no_msi = true, 1199 1190 .ops = &mtk_pcie_ops, 1200 1191 .startup = mtk_pcie_startup_port, 1192 + .quirks = MTK_PCIE_NO_MSI, 1201 1193 }; 1202 1194 1203 1195 static const struct mtk_pcie_soc mtk_pcie_soc_mt2712 = { ··· 1207 1199 }; 1208 1200 1209 1201 static const struct mtk_pcie_soc mtk_pcie_soc_mt7622 = { 1210 - .need_fix_class_id = true, 1211 1202 .ops = &mtk_pcie_ops_v2, 1212 1203 .startup = mtk_pcie_startup_port_v2, 1213 1204 .setup_irq = mtk_pcie_setup_irq, 1205 + .quirks = MTK_PCIE_FIX_CLASS_ID, 1214 1206 }; 1215 1207 1216 1208 static const struct mtk_pcie_soc mtk_pcie_soc_mt7629 = { 1217 - .need_fix_class_id = true, 1218 - .need_fix_device_id = true, 1219 1209 .device_id = PCI_DEVICE_ID_MEDIATEK_7629, 1220 1210 .ops = &mtk_pcie_ops_v2, 1221 1211 .startup = mtk_pcie_startup_port_v2, 1222 1212 .setup_irq = mtk_pcie_setup_irq, 1213 + .quirks = MTK_PCIE_FIX_CLASS_ID | MTK_PCIE_FIX_DEVICE_ID, 1223 1214 }; 1224 1215 1225 1216 static const struct of_device_id mtk_pcie_ids[] = {