Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 2 | |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 3 | #include <device/device.h> |
| 4 | #include <device/path.h> |
| 5 | #include <device/smbus.h> |
| 6 | #include <device/pci.h> |
Elyes HAOUAS | a4dd33c | 2020-08-11 09:39:43 +0200 | [diff] [blame] | 7 | #include <device/pci_def.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 8 | #include <device/pci_ids.h> |
| 9 | #include <device/pci_ops.h> |
Kyösti Mälkki | 1cae454 | 2020-01-06 12:31:34 +0200 | [diff] [blame] | 10 | #include <device/smbus_host.h> |
Angel Pons | 79b2a15 | 2020-12-05 20:43:00 +0100 | [diff] [blame] | 11 | #include <southbridge/intel/common/smbus_ops.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 12 | #include "pch.h" |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 13 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 14 | static void pch_smbus_init(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 15 | { |
| 16 | struct resource *res; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 17 | |
| 18 | /* Enable clock gating */ |
Angel Pons | 527b682 | 2021-03-30 21:18:30 +0200 | [diff] [blame] | 19 | pci_and_config16(dev, 0x80, ~((1 << 8) | (1 << 10) | (1 << 12) | (1 << 14))); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 20 | |
| 21 | /* Set Receive Slave Address */ |
| 22 | res = find_resource(dev, PCI_BASE_ADDRESS_4); |
| 23 | if (res) |
Kyösti Mälkki | 73451fd | 2020-01-06 19:00:31 +0200 | [diff] [blame] | 24 | smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 25 | } |
| 26 | |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 27 | static struct device_operations smbus_ops = { |
| 28 | .read_resources = smbus_read_resources, |
| 29 | .set_resources = pci_dev_set_resources, |
| 30 | .enable_resources = pci_dev_enable_resources, |
Kyösti Mälkki | d0e212c | 2015-02-26 20:47:47 +0200 | [diff] [blame] | 31 | .scan_bus = scan_smbus, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 32 | .init = pch_smbus_init, |
| 33 | .ops_smbus_bus = &lops_smbus_bus, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 34 | .ops_pci = &pci_dev_ops_pci, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 35 | }; |
| 36 | |
Felix Singer | 838fbc7 | 2019-11-21 21:23:32 +0100 | [diff] [blame] | 37 | static const unsigned short pci_device_ids[] = { |
| 38 | 0x1c22, |
| 39 | 0x1e22, |
| 40 | PCI_DID_INTEL_IBEXPEAK_SMBUS, |
| 41 | 0 |
| 42 | }; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 43 | |
| 44 | static const struct pci_driver pch_smbus __pci_driver = { |
| 45 | .ops = &smbus_ops, |
| 46 | .vendor = PCI_VENDOR_ID_INTEL, |
| 47 | .devices = pci_device_ids, |
| 48 | }; |