blob: 54baa68228fbe3d07aaf957673aa734a7bf1d1f6 [file] [log] [blame]
Patrick Georgibe61a172010-12-18 07:48:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
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/path.h>
19#include <device/smbus.h>
20#include <device/pci.h>
21#include <device/pci_ids.h>
22#include <device/pci_ops.h>
23#include <arch/io.h>
24#include "sch.h"
25#include "smbus.h"
26
27static int lsmbus_read_byte(device_t dev, u8 address)
28{
29 u16 device;
30 struct resource *res;
31 struct bus *pbus;
32
33 device = dev->path.i2c.device;
34 pbus = get_pbus_smbus(dev);
35 res = find_resource(pbus->dev, 0x20);
36
37 return do_smbus_read_byte(res->base, device, address);
38}
39
40static struct smbus_bus_operations lops_smbus_bus = {
41 .read_byte = lsmbus_read_byte,
42};
43
44static void smbus_set_subsystem(device_t dev, unsigned vendor, unsigned device)
45{
46 if (!vendor || !device) {
47 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
48 pci_read_config32(dev, PCI_VENDOR_ID));
49 } else {
50 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
51 ((device & 0xffff) << 16) | (vendor & 0xffff));
52 }
53}
54
55static struct pci_operations smbus_pci_ops = {
56 .set_subsystem = smbus_set_subsystem,
57};
58
59static struct device_operations smbus_ops = {
60 .read_resources = pci_dev_read_resources,
61 .set_resources = pci_dev_set_resources,
62 .enable_resources = pci_dev_enable_resources,
63 .init = 0,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +020064 .scan_bus = scan_smbus,
Patrick Georgibe61a172010-12-18 07:48:43 +000065 .ops_smbus_bus = &lops_smbus_bus,
66 .ops_pci = &smbus_pci_ops,
67};
68
Uwe Hermann405721d2010-12-18 13:22:37 +000069// FIXME
Patrick Georgibe61a172010-12-18 07:48:43 +000070/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
71static const struct pci_driver i82801gx_smbus __pci_driver = {
72 .ops = &smbus_ops,
73 .vendor = PCI_VENDOR_ID_INTEL,
74 .device = 0x27da,
75};