blob: ccc2dc1687e960e42cca0a3a276af53ccdb973b9 [file] [log] [blame]
Patrick Georgibe61a172010-12-18 07:48:43 +00001/*
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 Hermann405721d2010-12-18 13:22:37 +00008 * published by the Free Software Foundation; version 2 of the License.
Patrick Georgibe61a172010-12-18 07:48:43 +00009 *
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 Georgibe61a172010-12-18 07:48:43 +000014 */
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
22static 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 Hermann405721d2010-12-18 13:22:37 +000034static void sch_mmc_set_subsystem(device_t dev, unsigned vendor,
35 unsigned device)
Patrick Georgibe61a172010-12-18 07:48:43 +000036{
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 Georgibe61a172010-12-18 07:48:43 +000044}
45
46static struct pci_operations lops_pci = {
Uwe Hermann405721d2010-12-18 13:22:37 +000047 .set_subsystem = &sch_mmc_set_subsystem,
Patrick Georgibe61a172010-12-18 07:48:43 +000048};
49
50static 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
59static const struct pci_driver sch_mmc1 __pci_driver = {
60 .ops = &sch_mmc_ops,
61 .vendor = PCI_VENDOR_ID_INTEL,
62 .device = 0x811C,
63};
64
65static const struct pci_driver sch_mmc2 __pci_driver = {
66 .ops = &sch_mmc_ops,
67 .vendor = PCI_VENDOR_ID_INTEL,
68 .device = 0x811D,
69};
70
71static const struct pci_driver sch_mmc3 __pci_driver = {
72 .ops = &sch_mmc_ops,
73 .vendor = PCI_VENDOR_ID_INTEL,
74 .device = 0x811E,
75
76};