Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 2 | |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
Kyösti Mälkki | df128a5 | 2019-09-21 18:35:37 +0300 | [diff] [blame] | 5 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 6 | #include <device/pci_ops.h> |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 7 | #include <device/pci_ids.h> |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 8 | #include "i82801gx.h" |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 9 | |
| 10 | static void pci_init(struct device *dev) |
| 11 | { |
| 12 | u16 reg16; |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 13 | u8 reg8; |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 14 | |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 15 | /* Enable Bus Master */ |
| 16 | reg16 = pci_read_config16(dev, PCI_COMMAND); |
| 17 | reg16 |= PCI_COMMAND_MASTER; |
| 18 | pci_write_config16(dev, PCI_COMMAND, reg16); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 19 | |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 20 | /* This device has no interrupt */ |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 21 | pci_write_config8(dev, INTR, 0xff); |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 22 | |
| 23 | /* disable parity error response and SERR */ |
Kyösti Mälkki | df128a5 | 2019-09-21 18:35:37 +0300 | [diff] [blame] | 24 | reg16 = pci_read_config16(dev, PCI_BRIDGE_CONTROL); |
| 25 | reg16 &= ~PCI_BRIDGE_CTL_PARITY; |
| 26 | reg16 &= ~PCI_BRIDGE_CTL_SERR; |
| 27 | pci_write_config16(dev, PCI_BRIDGE_CONTROL, reg16); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 28 | |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 29 | /* Master Latency Count must be set to 0x04! */ |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 30 | reg8 = pci_read_config8(dev, SMLT); |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 31 | reg8 &= 0x07; |
| 32 | reg8 |= (0x04 << 3); |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 33 | pci_write_config8(dev, SMLT, reg8); |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame] | 34 | |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 35 | /* Clear errors in status registers */ |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 36 | reg16 = pci_read_config16(dev, PSTS); |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 37 | //reg16 |= 0xf900; |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 38 | pci_write_config16(dev, PSTS, reg16); |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 39 | |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 40 | reg16 = pci_read_config16(dev, SECSTS); |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 41 | // reg16 |= 0xf900; |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 42 | pci_write_config16(dev, SECSTS, reg16); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 45 | static struct pci_operations pci_ops = { |
Kyösti Mälkki | dbd3132 | 2019-03-20 17:55:27 +0200 | [diff] [blame] | 46 | .set_subsystem = pci_dev_set_subsystem, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static struct device_operations device_ops = { |
| 50 | .read_resources = pci_bus_read_resources, |
| 51 | .set_resources = pci_dev_set_resources, |
Kyösti Mälkki | a84a734 | 2019-09-23 10:01:16 +0300 | [diff] [blame] | 52 | .enable_resources = pci_bus_enable_resources, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 53 | .init = pci_init, |
| 54 | .scan_bus = pci_scan_bridge, |
| 55 | .ops_pci = &pci_ops, |
| 56 | }; |
| 57 | |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 58 | /* Desktop */ |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 59 | /* 82801BA/CA/DB/EB/ER/FB/FR/FW/FRW/GB/GR/GDH/HB/IB/6300ESB/i3100 */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 60 | static const struct pci_driver i82801g_pci __pci_driver = { |
| 61 | .ops = &device_ops, |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 62 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 63 | .device = 0x244e, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | /* Mobile / Ultra Mobile */ |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 67 | /* 82801BAM/CAM/DBL/DBM/FBM/GBM/GHM/GU/HBM/HEM */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 68 | static const struct pci_driver i82801gmu_pci __pci_driver = { |
| 69 | .ops = &device_ops, |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 70 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 71 | .device = 0x2448, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 72 | }; |