Angel Pons | 7544e2f | 2020-04-03 01:23:10 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 8 | #include <device/cardbus.h> |
| 9 | |
| 10 | static 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 Roth | ad0f485 | 2019-10-23 21:41:43 -0600 | [diff] [blame] | 14 | const unsigned int slot = PCI_SLOT(dev->path.pci.devfn); |
Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 15 | |
| 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 = |
Kyösti Mälkki | a144e4d | 2018-05-23 20:00:16 +0300 | [diff] [blame] | 22 | pcidev_path_behind(dev->bus, PCI_DEVFN(slot, fn)); |
Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 23 | if (!d || d->enabled) continue; |
| 24 | printk(BIOS_DEBUG, |
| 25 | "%s: Hiding function #%d.\n", __func__, fn); |
| 26 | switch (fn) { |
Felix Singer | df98b81 | 2023-12-08 10:52:34 +0100 | [diff] [blame] | 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 */ |
Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 32 | } |
| 33 | } |
| 34 | pci_write_config16(dev, 0x86, gcr); |
| 35 | } |
| 36 | } |
| 37 | |
| 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, |
| 42 | .init = 0, |
| 43 | .scan_bus = pci_scan_bridge, |
| 44 | .enable = pci7xx1_enable, |
| 45 | .reset_bus = pci_bus_reset, |
| 46 | }; |
| 47 | |
| 48 | static const struct pci_driver ti_pci7xx1 __pci_driver = { |
| 49 | .ops = &device_ops, |
| 50 | .vendor = 0x104c, |
| 51 | .device = 0x8031, |
| 52 | }; |