blob: 2383f4b02664914b4842351343bc1c74bfb885f1 [file] [log] [blame]
Vladimir Serbinenko795f96e2014-10-27 02:45:22 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Vladimir Serbinenko
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <kconfig.h>
22#include <console/console.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <device/pci_ids.h>
26#include <arch/io.h>
27#include "chip.h"
28
29static void rce822_enable(struct device *dev)
30{
31 struct drivers_ricoh_rce822_config *config = dev->chip_info;
32
33 pci_write_config8(dev, 0xca, 0x57);
34 pci_write_config8(dev, 0xcb, config->disable_mask);
35 pci_write_config8(dev, 0xca, 0x00);
36}
37
38static void rce822_init(struct device *dev)
39{
40 struct drivers_ricoh_rce822_config *config = dev->chip_info;
41
42 pci_write_config8(dev, 0xf9, 0xfc);
43 pci_write_config8(dev, 0xfb, config->sdwppol << 1);
44 pci_write_config8(dev, 0xf9, 0x00);
45}
46
47static void rce822_set_subsystem(device_t dev, unsigned vendor, unsigned device)
48{
49
50 if (!vendor || !device) {
51 pci_write_config32(dev, 0xac,
52 pci_read_config32(dev, PCI_VENDOR_ID));
53 } else {
54 pci_write_config32(dev, 0xac,
55 ((device & 0xffff) << 16) | (vendor & 0xffff));
56 }
57}
58
59static struct pci_operations lops_pci = {
60 .set_subsystem = &rce822_set_subsystem,
61};
62
63static struct device_operations usb_ehci_ops = {
64 .read_resources = pci_dev_read_resources,
65 .set_resources = pci_dev_set_resources,
66 .enable_resources = pci_dev_enable_resources,
67 .init = rce822_init,
68 .enable = rce822_enable,
69 .scan_bus = 0,
70 .ops_pci = &lops_pci,
71};
72
73static const unsigned short pci_device_ids[] = { 0xe822, 0xe823, 0 };
74
75static const struct pci_driver pch_usb_ehci __pci_driver = {
76 .ops = &usb_ehci_ops,
77 .vendor = PCI_VENDOR_ID_RICOH,
78 .devices = pci_device_ids,
79};