Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 1 | /* |
| 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 Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 15 | */ |
| 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 | |
| 23 | static 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) { |
| 27 | const uint16_t secondary = dev->bus->secondary; |
| 28 | const unsigned slot = PCI_SLOT(dev->path.pci.devfn); |
| 29 | |
| 30 | int fn; |
| 31 | |
| 32 | /* Hide functions based on devicetree info. */ |
| 33 | u16 gcr = pci_read_config16(dev, 0x86); |
| 34 | for (fn = 5; fn > 0; --fn) { |
| 35 | const struct device *const d = |
| 36 | dev_find_slot(secondary, PCI_DEVFN(slot, fn)); |
| 37 | if (!d || d->enabled) continue; |
| 38 | printk(BIOS_DEBUG, |
| 39 | "%s: Hiding function #%d.\n", __func__, fn); |
| 40 | switch (fn) { |
| 41 | case 1: gcr |= 1 << 4; break; /* CardBus B */ |
| 42 | case 2: gcr |= 1 << 3; break; /* OHCI 1394 */ |
| 43 | case 3: gcr |= 1 << 5; break; /* Flash media */ |
| 44 | case 4: gcr |= 1 << 6; break; /* SD card */ |
| 45 | case 5: gcr |= 1 << 7; break; /* Smart Card */ |
| 46 | } |
| 47 | } |
| 48 | pci_write_config16(dev, 0x86, gcr); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | static struct device_operations device_ops = { |
| 53 | .read_resources = cardbus_read_resources, |
| 54 | .set_resources = pci_dev_set_resources, |
| 55 | .enable_resources = cardbus_enable_resources, |
| 56 | .init = 0, |
| 57 | .scan_bus = pci_scan_bridge, |
| 58 | .enable = pci7xx1_enable, |
| 59 | .reset_bus = pci_bus_reset, |
| 60 | }; |
| 61 | |
| 62 | static const struct pci_driver ti_pci7xx1 __pci_driver = { |
| 63 | .ops = &device_ops, |
| 64 | .vendor = 0x104c, |
| 65 | .device = 0x8031, |
| 66 | }; |