Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Uwe Hermann | c6a1062 | 2010-10-17 19:30:58 +0000 | [diff] [blame] | 2 | |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <device/pci_ids.h> |
| 6 | #include <device/pci_ops.h> |
Sven Schnelle | 5c72a87 | 2011-04-20 08:58:30 +0000 | [diff] [blame] | 7 | #include <device/cardbus.h> |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 8 | #include <console/console.h> |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 9 | #include "chip.h" |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 10 | |
| 11 | static void ti_pci1x2y_init(struct device *dev) |
| 12 | { |
Uwe Hermann | 2d1d9ceb | 2010-12-26 14:12:38 +0000 | [diff] [blame] | 13 | |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 14 | printk(BIOS_INFO, "Init of Texas Instruments PCI1x2x PCMCIA/CardBus controller\n"); |
| 15 | struct southbridge_ti_pci1x2x_config *conf = dev->chip_info; |
| 16 | |
| 17 | if (conf) { |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 18 | /* System control (offset 0x80) */ |
| 19 | pci_write_config32(dev, 0x80, conf->scr); |
| 20 | /* Multifunction routing */ |
| 21 | pci_write_config32(dev, 0x8C, conf->mrr); |
| 22 | } |
Uwe Hermann | 2d1d9ceb | 2010-12-26 14:12:38 +0000 | [diff] [blame] | 23 | /* Set the device control register (0x92) accordingly. */ |
| 24 | pci_write_config8(dev, 0x92, pci_read_config8(dev, 0x92) | 0x02); |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 27 | static void ti_pci1x2y_set_subsystem(struct device *dev, unsigned int vendor, |
| 28 | unsigned int device) |
Sven Schnelle | 5f22f303 | 2011-04-20 08:58:16 +0000 | [diff] [blame] | 29 | { |
| 30 | /* |
| 31 | * Enable change sub-vendor ID. Clear the bit 5 to enable to write |
| 32 | * to the sub-vendor/device ids at 40 and 42. |
| 33 | */ |
| 34 | pci_write_config32(dev, 0x80, pci_read_config32(dev, 0x080) & ~0x10); |
Subrata Banik | 15ccbf0 | 2019-03-20 15:09:44 +0530 | [diff] [blame] | 35 | pci_dev_set_subsystem(dev, vendor, device); |
Sven Schnelle | 5f22f303 | 2011-04-20 08:58:16 +0000 | [diff] [blame] | 36 | pci_write_config32(dev, 0x80, pci_read_config32(dev, 0x80) | 0x10); |
| 37 | } |
| 38 | |
| 39 | static struct pci_operations ti_pci1x2y_pci_ops = { |
| 40 | .set_subsystem = ti_pci1x2y_set_subsystem, |
| 41 | }; |
| 42 | |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 43 | struct device_operations southbridge_ti_pci1x2x_pciops = { |
Sven Schnelle | 5c72a87 | 2011-04-20 08:58:30 +0000 | [diff] [blame] | 44 | .read_resources = cardbus_read_resources, |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 45 | .set_resources = pci_dev_set_resources, |
Sven Schnelle | 5c72a87 | 2011-04-20 08:58:30 +0000 | [diff] [blame] | 46 | .enable_resources = cardbus_enable_resources, |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 47 | .init = ti_pci1x2y_init, |
Sven Schnelle | 5f22f303 | 2011-04-20 08:58:16 +0000 | [diff] [blame] | 48 | .ops_pci = &ti_pci1x2y_pci_ops, |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 51 | static const struct pci_driver ti_pci1225_driver __pci_driver = { |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 52 | .ops = &southbridge_ti_pci1x2x_pciops, |
Uwe Hermann | 2d1d9ceb | 2010-12-26 14:12:38 +0000 | [diff] [blame] | 53 | .vendor = PCI_VENDOR_ID_TI, |
| 54 | .device = PCI_DEVICE_ID_TI_1225, |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 57 | static const struct pci_driver ti_pci1420_driver __pci_driver = { |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 58 | .ops = &southbridge_ti_pci1x2x_pciops, |
Uwe Hermann | 2d1d9ceb | 2010-12-26 14:12:38 +0000 | [diff] [blame] | 59 | .vendor = PCI_VENDOR_ID_TI, |
| 60 | .device = PCI_DEVICE_ID_TI_1420, |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 61 | }; |
Myles Watson | 356f848 | 2010-06-07 20:15:54 +0000 | [diff] [blame] | 62 | |
Sven Schnelle | 20f7f3b | 2011-04-20 08:58:08 +0000 | [diff] [blame] | 63 | static const struct pci_driver ti_pci1510_driver __pci_driver = { |
| 64 | .ops = &southbridge_ti_pci1x2x_pciops, |
| 65 | .vendor = PCI_VENDOR_ID_TI, |
| 66 | .device = PCI_DEVICE_ID_TI_1510, |
| 67 | }; |
| 68 | |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 69 | static const struct pci_driver ti_pci1520_driver __pci_driver = { |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 70 | .ops = &southbridge_ti_pci1x2x_pciops, |
Uwe Hermann | 2d1d9ceb | 2010-12-26 14:12:38 +0000 | [diff] [blame] | 71 | .vendor = PCI_VENDOR_ID_TI, |
| 72 | .device = PCI_DEVICE_ID_TI_1520, |
Marc Bertens | 2ad8ab8 | 2010-06-04 19:53:55 +0000 | [diff] [blame] | 73 | }; |
Sven Schnelle | baec034 | 2011-04-20 08:57:53 +0000 | [diff] [blame] | 74 | |
| 75 | struct chip_operations southbridge_ti_pci1x2x_ops = { |
| 76 | CHIP_NAME("TI PCI1x2x Cardbus controller") |
| 77 | }; |