Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2009-2010 iWave Systems |
| 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 |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 8 | * published by the Free Software Foundation; version 2 of the License. |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <device/device.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <arch/io.h> |
| 21 | |
| 22 | static void sch_mmc_init(struct device *dev) |
| 23 | { |
| 24 | u32 reg32; |
| 25 | |
| 26 | printk(BIOS_DEBUG, "MMC: Setting up controller.. "); |
| 27 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 28 | reg32 |= PCI_COMMAND_MASTER; |
| 29 | reg32 |= PCI_COMMAND_MEMORY; |
| 30 | pci_write_config32(dev, PCI_COMMAND, reg32); |
| 31 | printk(BIOS_DEBUG, "done.\n"); |
| 32 | } |
| 33 | |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 34 | static void sch_mmc_set_subsystem(device_t dev, unsigned vendor, |
| 35 | unsigned device) |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 36 | { |
| 37 | if (!vendor || !device) { |
| 38 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 39 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 40 | } else { |
| 41 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 42 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 43 | } |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static struct pci_operations lops_pci = { |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 47 | .set_subsystem = &sch_mmc_set_subsystem, |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | static struct device_operations sch_mmc_ops = { |
| 51 | .read_resources = pci_dev_read_resources, |
| 52 | .set_resources = pci_dev_set_resources, |
| 53 | .enable_resources = pci_dev_enable_resources, |
| 54 | .init = sch_mmc_init, |
| 55 | .scan_bus = 0, |
| 56 | .ops_pci = &lops_pci, |
| 57 | }; |
| 58 | |
| 59 | static const struct pci_driver sch_mmc1 __pci_driver = { |
| 60 | .ops = &sch_mmc_ops, |
| 61 | .vendor = PCI_VENDOR_ID_INTEL, |
| 62 | .device = 0x811C, |
| 63 | }; |
| 64 | |
| 65 | static const struct pci_driver sch_mmc2 __pci_driver = { |
| 66 | .ops = &sch_mmc_ops, |
| 67 | .vendor = PCI_VENDOR_ID_INTEL, |
| 68 | .device = 0x811D, |
| 69 | }; |
| 70 | |
| 71 | static const struct pci_driver sch_mmc3 __pci_driver = { |
| 72 | .ops = &sch_mmc_ops, |
| 73 | .vendor = PCI_VENDOR_ID_INTEL, |
| 74 | .device = 0x811E, |
| 75 | |
| 76 | }; |