Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 2 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 3 | #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älkki | 1cae454 | 2020-01-06 12:31:34 +0200 | [diff] [blame] | 9 | #include <device/smbus_host.h> |
Angel Pons | 79b2a15 | 2020-12-05 20:43:00 +0100 | [diff] [blame] | 10 | #include <southbridge/intel/common/smbus_ops.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 11 | #include "pch.h" |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 12 | |
Elyes HAOUAS | 38f1d13 | 2018-09-17 08:44:18 +0200 | [diff] [blame] | 13 | static void pch_smbus_init(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 14 | { |
| 15 | struct resource *res; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 16 | |
| 17 | /* Enable clock gating */ |
Angel Pons | 527b682 | 2021-03-30 21:18:30 +0200 | [diff] [blame] | 18 | pci_and_config16(dev, 0x80, ~((1 << 8) | (1 << 10) | (1 << 12) | (1 << 14))); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 19 | |
| 20 | /* Set Receive Slave Address */ |
Angel Pons | f32ae10 | 2021-11-03 13:07:14 +0100 | [diff] [blame] | 21 | res = probe_resource(dev, PCI_BASE_ADDRESS_4); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 22 | if (res) |
Kyösti Mälkki | 73451fd | 2020-01-06 19:00:31 +0200 | [diff] [blame] | 23 | smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 24 | } |
| 25 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 26 | static struct device_operations smbus_ops = { |
| 27 | .read_resources = smbus_read_resources, |
| 28 | .set_resources = pci_dev_set_resources, |
| 29 | .enable_resources = pci_dev_enable_resources, |
Kyösti Mälkki | d0e212c | 2015-02-26 20:47:47 +0200 | [diff] [blame] | 30 | .scan_bus = scan_smbus, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 31 | .init = pch_smbus_init, |
| 32 | .ops_smbus_bus = &lops_smbus_bus, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 33 | .ops_pci = &pci_dev_ops_pci, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 34 | }; |
| 35 | |
Tristan Corrick | 946d3f9 | 2018-10-31 02:21:07 +1300 | [diff] [blame] | 36 | static const unsigned short pci_device_ids[] = { |
Felix Singer | 4ea08f9 | 2020-11-20 12:56:44 +0000 | [diff] [blame] | 37 | PCI_DEVICE_ID_INTEL_LPT_H_SMBUS, |
| 38 | PCI_DEVICE_ID_INTEL_LPT_LP_SMBUS, |
Angel Pons | 8af3e0e | 2021-03-03 16:55:01 +0100 | [diff] [blame] | 39 | PCI_DEVICE_ID_INTEL_WPT_LP_SMBUS, |
Tristan Corrick | 946d3f9 | 2018-10-31 02:21:07 +1300 | [diff] [blame] | 40 | 0 |
| 41 | }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 42 | |
| 43 | static const struct pci_driver pch_smbus __pci_driver = { |
| 44 | .ops = &smbus_ops, |
| 45 | .vendor = PCI_VENDOR_ID_INTEL, |
| 46 | .devices = pci_device_ids, |
| 47 | }; |