blob: 9ba9e12eb581ae2d70d4bc4d76996286dbf9a302 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer8e073822012-04-04 00:07:22 +02002
Stefan Reinauer8e073822012-04-04 00:07:22 +02003#include <device/device.h>
4#include <device/path.h>
5#include <device/smbus.h>
6#include <device/pci.h>
Elyes HAOUASa4dd33c2020-08-11 09:39:43 +02007#include <device/pci_def.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +02008#include <device/pci_ids.h>
9#include <device/pci_ops.h>
Kyösti Mälkki1cae4542020-01-06 12:31:34 +020010#include <device/smbus_host.h>
Angel Pons79b2a152020-12-05 20:43:00 +010011#include <southbridge/intel/common/smbus_ops.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +020012#include "pch.h"
Stefan Reinauer8e073822012-04-04 00:07:22 +020013
Elyes HAOUAS4aec3402018-05-25 08:29:27 +020014static void pch_smbus_init(struct device *dev)
Stefan Reinauer8e073822012-04-04 00:07:22 +020015{
16 struct resource *res;
17 u16 reg16;
18
19 /* Enable clock gating */
Angel Ponsc803f652020-06-07 22:09:01 +020020 /* FIXME: Using 32-bit ops with a 16-bit variable is a bug! These should be 16-bit! */
Stefan Reinauer8e073822012-04-04 00:07:22 +020021 reg16 = pci_read_config32(dev, 0x80);
22 reg16 &= ~((1 << 8)|(1 << 10)|(1 << 12)|(1 << 14));
23 pci_write_config32(dev, 0x80, reg16);
24
25 /* Set Receive Slave Address */
26 res = find_resource(dev, PCI_BASE_ADDRESS_4);
27 if (res)
Kyösti Mälkki73451fd2020-01-06 19:00:31 +020028 smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
Stefan Reinauer8e073822012-04-04 00:07:22 +020029}
30
Aaron Durbinaa090cb2017-09-13 16:01:52 -060031static const char *smbus_acpi_name(const struct device *dev)
Patrick Rudolph604f6982017-06-07 09:46:52 +020032{
33 return "SBUS";
34}
35
Stefan Reinauer8e073822012-04-04 00:07:22 +020036static struct device_operations smbus_ops = {
37 .read_resources = smbus_read_resources,
38 .set_resources = pci_dev_set_resources,
39 .enable_resources = pci_dev_enable_resources,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +020040 .scan_bus = scan_smbus,
Stefan Reinauer8e073822012-04-04 00:07:22 +020041 .init = pch_smbus_init,
42 .ops_smbus_bus = &lops_smbus_bus,
Angel Pons1fc0edd2020-05-31 00:03:28 +020043 .ops_pci = &pci_dev_ops_pci,
Patrick Rudolph604f6982017-06-07 09:46:52 +020044 .acpi_name = smbus_acpi_name,
Stefan Reinauer8e073822012-04-04 00:07:22 +020045};
46
Stefan Reinauer9a380ab2012-06-22 13:16:11 -070047static const unsigned short pci_device_ids[] = { 0x1c22, 0x1e22, 0 };
Stefan Reinauer8e073822012-04-04 00:07:22 +020048
Stefan Reinauer9a380ab2012-06-22 13:16:11 -070049static const struct pci_driver pch_smbus __pci_driver = {
50 .ops = &smbus_ops,
51 .vendor = PCI_VENDOR_ID_INTEL,
52 .devices = pci_device_ids,
Stefan Reinauer8e073822012-04-04 00:07:22 +020053};