2 * This file is part of the coreboot project.
4 * Copyright (C) 2004 Tyan Computer
5 * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
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.
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
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <device/pci.h>
24 #include <device/pci_ids.h>
25 #include <device/pci_ops.h>
26 #include <device/smbus.h>
30 #include "ck804_smbus.h"
32 static int lsmbus_recv_byte(device_t dev)
38 device = dev->path.i2c.device;
39 pbus = get_pbus_smbus(dev);
41 res = find_resource(pbus->dev, 0x20 + (pbus->link_num * 4));
43 return do_smbus_recv_byte(res->base, device);
46 static int lsmbus_send_byte(device_t dev, uint8_t val)
52 device = dev->path.i2c.device;
53 pbus = get_pbus_smbus(dev);
55 res = find_resource(pbus->dev, 0x20 + (pbus->link_num * 4));
57 return do_smbus_send_byte(res->base, device, val);
60 static int lsmbus_read_byte(device_t dev, uint8_t address)
66 device = dev->path.i2c.device;
67 pbus = get_pbus_smbus(dev);
69 res = find_resource(pbus->dev, 0x20 + (pbus->link_num * 4));
71 return do_smbus_read_byte(res->base, device, address);
74 static int lsmbus_write_byte(device_t dev, uint8_t address, uint8_t val)
80 device = dev->path.i2c.device;
81 pbus = get_pbus_smbus(dev);
83 res = find_resource(pbus->dev, 0x20 + (pbus->link_num * 4));
85 return do_smbus_write_byte(res->base, device, address, val);
88 static struct smbus_bus_operations lops_smbus_bus = {
89 .recv_byte = lsmbus_recv_byte,
90 .send_byte = lsmbus_send_byte,
91 .read_byte = lsmbus_read_byte,
92 .write_byte = lsmbus_write_byte,
95 static struct device_operations smbus_ops = {
96 .read_resources = pci_dev_read_resources,
97 .set_resources = pci_dev_set_resources,
98 .enable_resources = pci_dev_enable_resources,
100 .scan_bus = scan_static_bus,
101 // .enable = ck804_enable,
102 .ops_pci = &ck804_pci_ops,
103 .ops_smbus_bus = &lops_smbus_bus,
106 static const struct pci_driver smbus_driver __pci_driver = {
108 .vendor = PCI_VENDOR_ID_NVIDIA,
109 .device = PCI_DEVICE_ID_NVIDIA_CK804_SM,