blob: 036380248db155f38bbfbb9fcb31bcee0b29041e [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>
Aaron Durbin76c37002012-10-30 09:03:43 -05004#include <device/smbus.h>
5#include <device/pci.h>
6#include <device/pci_ids.h>
7#include <device/pci_ops.h>
Kyösti Mälkki1cae4542020-01-06 12:31:34 +02008#include <device/smbus_host.h>
Angel Pons79b2a152020-12-05 20:43:00 +01009#include <southbridge/intel/common/smbus_ops.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050010#include "pch.h"
Aaron Durbin76c37002012-10-30 09:03:43 -050011
Elyes HAOUAS38f1d132018-09-17 08:44:18 +020012static void pch_smbus_init(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -050013{
14 struct resource *res;
Aaron Durbin76c37002012-10-30 09:03:43 -050015
16 /* Enable clock gating */
Angel Pons527b6822021-03-30 21:18:30 +020017 pci_and_config16(dev, 0x80, ~((1 << 8) | (1 << 10) | (1 << 12) | (1 << 14)));
Aaron Durbin76c37002012-10-30 09:03:43 -050018
19 /* Set Receive Slave Address */
Angel Ponsf32ae102021-11-03 13:07:14 +010020 res = probe_resource(dev, PCI_BASE_ADDRESS_4);
Aaron Durbin76c37002012-10-30 09:03:43 -050021 if (res)
Kyösti Mälkki73451fd2020-01-06 19:00:31 +020022 smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
Aaron Durbin76c37002012-10-30 09:03:43 -050023}
24
Aaron Durbin76c37002012-10-30 09:03:43 -050025static struct device_operations smbus_ops = {
26 .read_resources = smbus_read_resources,
27 .set_resources = pci_dev_set_resources,
28 .enable_resources = pci_dev_enable_resources,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +020029 .scan_bus = scan_smbus,
Aaron Durbin76c37002012-10-30 09:03:43 -050030 .init = pch_smbus_init,
31 .ops_smbus_bus = &lops_smbus_bus,
Angel Pons1fc0edd2020-05-31 00:03:28 +020032 .ops_pci = &pci_dev_ops_pci,
Aaron Durbin76c37002012-10-30 09:03:43 -050033};
34
Tristan Corrick946d3f92018-10-31 02:21:07 +130035static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010036 PCI_DID_INTEL_LPT_H_SMBUS,
Angel Pons434d7d42022-10-07 00:36:00 +020037 PCI_DID_INTEL_LPT_H_SMBUS_9,
Felix Singer43b7f412022-03-07 04:34:52 +010038 PCI_DID_INTEL_LPT_LP_SMBUS,
39 PCI_DID_INTEL_WPT_LP_SMBUS,
Tristan Corrick946d3f92018-10-31 02:21:07 +130040 0
41};
Aaron Durbin76c37002012-10-30 09:03:43 -050042
43static const struct pci_driver pch_smbus __pci_driver = {
44 .ops = &smbus_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010045 .vendor = PCI_VID_INTEL,
Aaron Durbin76c37002012-10-30 09:03:43 -050046 .devices = pci_device_ids,
47};