blob: 32c9c14e40c2edd4f45f3373a3fa8b7d06cf4a6b [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin76c37002012-10-30 09:03:43 -05002
Aaron Durbin76c37002012-10-30 09:03:43 -05003#include <device/device.h>
4#include <device/path.h>
5#include <device/smbus.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
8#include <device/pci_ops.h>
Kyösti Mälkki1cae4542020-01-06 12:31:34 +02009#include <device/smbus_host.h>
Angel Pons79b2a152020-12-05 20:43:00 +010010#include <southbridge/intel/common/smbus_ops.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050011#include "pch.h"
Aaron Durbin76c37002012-10-30 09:03:43 -050012
Elyes HAOUAS38f1d132018-09-17 08:44:18 +020013static void pch_smbus_init(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -050014{
15 struct resource *res;
16 u16 reg16;
17
18 /* Enable clock gating */
Angel Ponsbf9bc502020-06-08 00:12:43 +020019 /* FIXME: Using 32-bit ops with a 16-bit variable is a bug! These should be 16-bit! */
Aaron Durbin76c37002012-10-30 09:03:43 -050020 reg16 = pci_read_config32(dev, 0x80);
Angel Pons84fa2242020-10-24 11:53:47 +020021 reg16 &= ~((1 << 8) | (1 << 10) | (1 << 12) | (1 << 14));
Aaron Durbin76c37002012-10-30 09:03:43 -050022 pci_write_config32(dev, 0x80, reg16);
23
24 /* Set Receive Slave Address */
25 res = find_resource(dev, PCI_BASE_ADDRESS_4);
26 if (res)
Kyösti Mälkki73451fd2020-01-06 19:00:31 +020027 smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
Aaron Durbin76c37002012-10-30 09:03:43 -050028}
29
Aaron Durbin76c37002012-10-30 09:03:43 -050030static struct device_operations smbus_ops = {
31 .read_resources = smbus_read_resources,
32 .set_resources = pci_dev_set_resources,
33 .enable_resources = pci_dev_enable_resources,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +020034 .scan_bus = scan_smbus,
Aaron Durbin76c37002012-10-30 09:03:43 -050035 .init = pch_smbus_init,
36 .ops_smbus_bus = &lops_smbus_bus,
Angel Pons1fc0edd2020-05-31 00:03:28 +020037 .ops_pci = &pci_dev_ops_pci,
Aaron Durbin76c37002012-10-30 09:03:43 -050038};
39
Tristan Corrick946d3f92018-10-31 02:21:07 +130040static const unsigned short pci_device_ids[] = {
Felix Singer4ea08f92020-11-20 12:56:44 +000041 PCI_DEVICE_ID_INTEL_LPT_H_SMBUS,
42 PCI_DEVICE_ID_INTEL_LPT_LP_SMBUS,
Angel Pons8af3e0e2021-03-03 16:55:01 +010043 PCI_DEVICE_ID_INTEL_WPT_LP_SMBUS,
Tristan Corrick946d3f92018-10-31 02:21:07 +130044 0
45};
Aaron Durbin76c37002012-10-30 09:03:43 -050046
47static const struct pci_driver pch_smbus __pci_driver = {
48 .ops = &smbus_ops,
49 .vendor = PCI_VENDOR_ID_INTEL,
50 .devices = pci_device_ids,
51};