blob: 54fa34f5a2ee76c6f6054ffffaf6d5408e96d2f6 [file] [log] [blame]
Corey Osgoode99bd102007-06-14 06:10:57 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Corey Osgoode99bd102007-06-14 06:10:57 +00003 *
4 * Copyright (C) 2005 Yinghai Lu <yinghailu@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
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.
Corey Osgoode99bd102007-06-14 06:10:57 +000015 */
16
Uwe Hermanncce50402007-11-07 22:09:02 +000017#include <stdint.h>
Uwe Hermann3b8db812010-10-08 16:40:23 +000018#include <device/smbus.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
Corey Osgoode99bd102007-06-14 06:10:57 +000021#include <arch/io.h>
Stefan Reinauer138be832010-02-27 01:50:21 +000022#include "i82801ax.h"
stepan836ae292010-12-08 05:42:47 +000023#include "smbus.h"
Corey Osgoode99bd102007-06-14 06:10:57 +000024
Uwe Hermann3b8db812010-10-08 16:40:23 +000025static int lsmbus_read_byte(device_t dev, u8 address)
Corey Osgoode99bd102007-06-14 06:10:57 +000026{
Uwe Hermann3b8db812010-10-08 16:40:23 +000027 u16 device;
Corey Osgoode99bd102007-06-14 06:10:57 +000028 struct resource *res;
Uwe Hermann3b8db812010-10-08 16:40:23 +000029 struct bus *pbus;
Corey Osgoode99bd102007-06-14 06:10:57 +000030
Stefan Reinauer2b34db82009-02-28 20:10:20 +000031 device = dev->path.i2c.device;
Uwe Hermann3b8db812010-10-08 16:40:23 +000032 pbus = get_pbus_smbus(dev);
33 res = find_resource(pbus->dev, 0x20);
Uwe Hermanndfb3c132007-06-19 22:47:11 +000034
Corey Osgoode99bd102007-06-14 06:10:57 +000035 return do_smbus_read_byte(res->base, device, address);
36}
37
Stefan Reinauer069385f2009-05-26 12:58:00 +000038static struct smbus_bus_operations lops_smbus_bus = {
Uwe Hermann3b8db812010-10-08 16:40:23 +000039 .read_byte = lsmbus_read_byte,
Corey Osgoode99bd102007-06-14 06:10:57 +000040};
41
Uwe Hermanncce50402007-11-07 22:09:02 +000042static const struct device_operations smbus_ops = {
Uwe Hermanndfb3c132007-06-19 22:47:11 +000043 .read_resources = pci_dev_read_resources,
44 .set_resources = pci_dev_set_resources,
45 .enable_resources = pci_dev_enable_resources,
46 .init = 0,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +020047 .scan_bus = scan_smbus,
Uwe Hermann3b8db812010-10-08 16:40:23 +000048 .enable = i82801ax_enable,
Uwe Hermanndfb3c132007-06-19 22:47:11 +000049 .ops_smbus_bus = &lops_smbus_bus,
Corey Osgoode99bd102007-06-14 06:10:57 +000050};
51
Uwe Hermanncce50402007-11-07 22:09:02 +000052/* 82801AA (ICH) */
53static const struct pci_driver i82801aa_smb __pci_driver = {
Uwe Hermanndfb3c132007-06-19 22:47:11 +000054 .ops = &smbus_ops,
55 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermanncce50402007-11-07 22:09:02 +000056 .device = PCI_DEVICE_ID_INTEL_82801AA_SMB,
Corey Osgoode99bd102007-06-14 06:10:57 +000057};
58
Uwe Hermanncce50402007-11-07 22:09:02 +000059/* 82801AB (ICH0) */
60static const struct pci_driver i82801ab_smb __pci_driver = {
Uwe Hermanndfb3c132007-06-19 22:47:11 +000061 .ops = &smbus_ops,
62 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermanncce50402007-11-07 22:09:02 +000063 .device = PCI_DEVICE_ID_INTEL_82801AB_SMB,
Corey Osgoode99bd102007-06-14 06:10:57 +000064};