blob: 970e83d8182ffd20f2c38928f9b56040223a8720 [file] [log] [blame]
Angel Pons7544e2f2020-04-03 01:23:10 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi021b7032012-11-06 11:05:38 +01002
3#include <stdint.h>
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02007#include <device/pci_ops.h>
Patrick Georgi021b7032012-11-06 11:05:38 +01008#include <device/cardbus.h>
9
10static void pci7xx1_enable(struct device *const dev)
11{
12 printk(BIOS_DEBUG, "%s: TI PCI7xx1 media controller\n", __func__);
13 if (PCI_FUNC(dev->path.pci.devfn) == 0) {
Martin Rothad0f4852019-10-23 21:41:43 -060014 const unsigned int slot = PCI_SLOT(dev->path.pci.devfn);
Patrick Georgi021b7032012-11-06 11:05:38 +010015
16 int fn;
17
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 =
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020022 pcidev_path_behind(dev->upstream, PCI_DEVFN(slot, fn));
Patrick Georgi021b7032012-11-06 11:05:38 +010023 if (!d || d->enabled) continue;
24 printk(BIOS_DEBUG,
25 "%s: Hiding function #%d.\n", __func__, fn);
26 switch (fn) {
Felix Singerdf98b812023-12-08 10:52:34 +010027 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 */
Patrick Georgi021b7032012-11-06 11:05:38 +010032 }
33 }
34 pci_write_config16(dev, 0x86, gcr);
35 }
36}
37
38static struct device_operations device_ops = {
39 .read_resources = cardbus_read_resources,
40 .set_resources = pci_dev_set_resources,
41 .enable_resources = cardbus_enable_resources,
42 .init = 0,
43 .scan_bus = pci_scan_bridge,
44 .enable = pci7xx1_enable,
45 .reset_bus = pci_bus_reset,
46};
47
48static const struct pci_driver ti_pci7xx1 __pci_driver = {
49 .ops = &device_ops,
50 .vendor = 0x104c,
51 .device = 0x8031,
52};