blob: 4f72f9d82972f34761ea0fd1bdf7affb4939b327 [file] [log] [blame]
Patrick Georgi021b7032012-11-06 11:05:38 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Patrick Georgi021b7032012-11-06 11:05:38 +010015 */
16
17#include <stdint.h>
18#include <console/console.h>
19#include <device/device.h>
20#include <device/pci.h>
21#include <device/cardbus.h>
22
23static void pci7xx1_enable(struct device *const dev)
24{
25 printk(BIOS_DEBUG, "%s: TI PCI7xx1 media controller\n", __func__);
26 if (PCI_FUNC(dev->path.pci.devfn) == 0) {
Patrick Georgi021b7032012-11-06 11:05:38 +010027 const unsigned slot = PCI_SLOT(dev->path.pci.devfn);
28
29 int fn;
30
31 /* Hide functions based on devicetree info. */
32 u16 gcr = pci_read_config16(dev, 0x86);
33 for (fn = 5; fn > 0; --fn) {
34 const struct device *const d =
Kyösti Mälkkia144e4d2018-05-23 20:00:16 +030035 pcidev_path_behind(dev->bus, PCI_DEVFN(slot, fn));
Patrick Georgi021b7032012-11-06 11:05:38 +010036 if (!d || d->enabled) continue;
37 printk(BIOS_DEBUG,
38 "%s: Hiding function #%d.\n", __func__, fn);
39 switch (fn) {
40 case 1: gcr |= 1 << 4; break; /* CardBus B */
41 case 2: gcr |= 1 << 3; break; /* OHCI 1394 */
42 case 3: gcr |= 1 << 5; break; /* Flash media */
43 case 4: gcr |= 1 << 6; break; /* SD card */
44 case 5: gcr |= 1 << 7; break; /* Smart Card */
45 }
46 }
47 pci_write_config16(dev, 0x86, gcr);
48 }
49}
50
51static struct device_operations device_ops = {
52 .read_resources = cardbus_read_resources,
53 .set_resources = pci_dev_set_resources,
54 .enable_resources = cardbus_enable_resources,
55 .init = 0,
56 .scan_bus = pci_scan_bridge,
57 .enable = pci7xx1_enable,
58 .reset_bus = pci_bus_reset,
59};
60
61static const struct pci_driver ti_pci7xx1 __pci_driver = {
62 .ops = &device_ops,
63 .vendor = 0x104c,
64 .device = 0x8031,
65};