1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ops.h>
8 #include <device/cardbus.h>
10 static void pci7xx1_enable(struct device
*const dev
)
12 printk(BIOS_DEBUG
, "%s: TI PCI7xx1 media controller\n", __func__
);
13 if (PCI_FUNC(dev
->path
.pci
.devfn
) == 0) {
14 const unsigned int slot
= PCI_SLOT(dev
->path
.pci
.devfn
);
18 /* Hide functions based on devicetree info. */
19 u16 gcr
= pci_read_config16(dev
, 0x86);
20 for (fn
= 5; fn
> 0; --fn
) {
21 const struct device
*const d
=
22 pcidev_path_behind(dev
->upstream
, PCI_DEVFN(slot
, fn
));
23 if (!d
|| d
->enabled
) continue;
25 "%s: Hiding function #%d.\n", __func__
, fn
);
27 case 1: gcr
|= 1 << 4; break; /* CardBus B */
28 case 2: gcr
|= 1 << 3; break; /* OHCI 1394 */
29 case 3: gcr
|= 1 << 5; break; /* Flash media */
30 case 4: gcr
|= 1 << 6; break; /* SD card */
31 case 5: gcr
|= 1 << 7; break; /* Smart Card */
34 pci_write_config16(dev
, 0x86, gcr
);
38 static struct device_operations device_ops
= {
39 .read_resources
= cardbus_read_resources
,
40 .set_resources
= pci_dev_set_resources
,
41 .enable_resources
= cardbus_enable_resources
,
43 .scan_bus
= pci_scan_bridge
,
44 .enable
= pci7xx1_enable
,
45 .reset_bus
= pci_bus_reset
,
48 static const struct pci_driver ti_pci7xx1 __pci_driver
= {