coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ti_pci7xx1.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <stdint.h>
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>
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) {
14  const unsigned int slot = PCI_SLOT(dev->path.pci.devfn);
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 =
22  pcidev_path_behind(dev->bus, PCI_DEVFN(slot, fn));
23  if (!d || d->enabled) continue;
25  "%s: Hiding function #%d.\n", __func__, fn);
26  switch (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 */
32  }
33  }
34  pci_write_config16(dev, 0x86, gcr);
35  }
36 }
37 
38 static struct device_operations device_ops = {
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 };
void cardbus_enable_resources(struct device *dev)
void cardbus_read_resources(struct device *dev)
#define printk(level,...)
Definition: stdlib.h:16
DEVTREE_CONST struct device * pcidev_path_behind(const struct bus *parent, pci_devfn_t devfn)
Definition: device_const.c:211
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define PCI_DEVFN(slot, func)
Definition: pci_def.h:548
#define PCI_FUNC(devfn)
Definition: pci_def.h:550
#define PCI_SLOT(devfn)
Definition: pci_def.h:549
void pci_bus_reset(struct bus *bus)
Definition: pci_device.c:777
void pci_scan_bridge(struct device *dev)
Scan a PCI bridge and the buses behind the bridge.
Definition: pci_device.c:1598
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
uint16_t u16
Definition: stdint.h:48
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct pci_path pci
Definition: path.h:116
Definition: device.h:107
struct device_path path
Definition: device.h:115
DEVTREE_CONST struct bus * bus
Definition: device.h:108
unsigned int enabled
Definition: device.h:122
unsigned int devfn
Definition: path.h:54
static struct device_operations device_ops
Definition: ti_pci7xx1.c:38
static const struct pci_driver ti_pci7xx1 __pci_driver
Definition: ti_pci7xx1.c:48
static void pci7xx1_enable(struct device *const dev)
Definition: ti_pci7xx1.c:10