xref: /aosp_15_r20/external/coreboot/src/southbridge/ti/pci1x2x/pci1x2x.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ops.h>
7 #include <device/cardbus.h>
8 #include <console/console.h>
9 #include "chip.h"
10 
ti_pci1x2y_init(struct device * dev)11 static void ti_pci1x2y_init(struct device *dev)
12 {
13 	printk(BIOS_INFO, "Init of Texas Instruments PCI1x2x PCMCIA/CardBus controller\n");
14 	struct southbridge_ti_pci1x2x_config *conf = dev->chip_info;
15 
16 	if (conf) {
17 		/* System control (offset 0x80) */
18 		pci_write_config32(dev, 0x80, conf->scr);
19 		/* Multifunction routing */
20 		pci_write_config32(dev, 0x8C, conf->mrr);
21 	}
22 	/* Set the device control register (0x92) accordingly. */
23 	pci_write_config8(dev, 0x92, pci_read_config8(dev, 0x92) | 0x02);
24 }
25 
ti_pci1x2y_set_subsystem(struct device * dev,unsigned int vendor,unsigned int device)26 static void ti_pci1x2y_set_subsystem(struct device *dev, unsigned int vendor,
27 				     unsigned int device)
28 {
29 	/*
30 	 * Enable change sub-vendor ID. Clear the bit 5 to enable to write
31 	 * to the sub-vendor/device ids at 40 and 42.
32 	 */
33 	pci_write_config32(dev, 0x80, pci_read_config32(dev, 0x080) & ~0x10);
34 	pci_dev_set_subsystem(dev, vendor, device);
35 	pci_write_config32(dev, 0x80, pci_read_config32(dev, 0x80) | 0x10);
36 }
37 
38 static struct pci_operations ti_pci1x2y_pci_ops = {
39 	.set_subsystem = ti_pci1x2y_set_subsystem,
40 };
41 
42 struct device_operations southbridge_ti_pci1x2x_pciops = {
43 	.read_resources   = cardbus_read_resources,
44 	.set_resources    = pci_dev_set_resources,
45 	.enable_resources = cardbus_enable_resources,
46 	.init             = ti_pci1x2y_init,
47 	.ops_pci          = &ti_pci1x2y_pci_ops,
48 };
49 
50 static const struct pci_driver ti_pci1225_driver __pci_driver = {
51 	.ops    = &southbridge_ti_pci1x2x_pciops,
52 	.vendor = PCI_VID_TI,
53 	.device = PCI_DID_TI_1225,
54 };
55 
56 static const struct pci_driver ti_pci1420_driver __pci_driver = {
57 	.ops    = &southbridge_ti_pci1x2x_pciops,
58 	.vendor = PCI_VID_TI,
59 	.device = PCI_DID_TI_1420,
60 };
61 
62 static const struct pci_driver ti_pci1510_driver __pci_driver = {
63 	.ops    = &southbridge_ti_pci1x2x_pciops,
64 	.vendor = PCI_VID_TI,
65 	.device = PCI_DID_TI_1510,
66 };
67 
68 static const struct pci_driver ti_pci1520_driver __pci_driver = {
69 	.ops    = &southbridge_ti_pci1x2x_pciops,
70 	.vendor = PCI_VID_TI,
71 	.device = PCI_DID_TI_1520,
72 };
73 
74 struct chip_operations southbridge_ti_pci1x2x_ops = {
75 	.name = "TI PCI1x2x Cardbus controller",
76 };
77