1 /* This file is part of the coreboot project. */
2 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ops.h>
7 #include <console/console.h>
8 #include <device/cardbus.h>
13 static int cardbus_count
= 0;
16 static void pci7420_cardbus_init(struct device
*dev
)
22 struct southbridge_ti_pci7420_config
*config
= dev
->chip_info
;
23 int smartcard_enabled
= 0;
25 printk(BIOS_DEBUG
, "TI PCI7420/7620 init\n");
28 printk(BIOS_DEBUG
, "PCI7420: No configuration found.\n");
30 smartcard_enabled
= config
->smartcard_enabled
;
33 reg32
= pci_read_config32(dev
, SYSCTL
);
35 pci_write_config32(dev
, SYSCTL
, reg32
);
38 reg8
= pci_read_config8(dev
, CARDCTL
);
40 pci_write_config8(dev
, CARDCTL
, reg8
);
42 /* Power switch select and FM disable */
43 reg16
= pci_read_config16(dev
, GENCTL
);
44 reg16
|= P12V_SW_SEL
; // 12V capable power switch
45 if (smartcard_enabled
== 0)
47 pci_write_config16(dev
, GENCTL
, reg16
);
49 /* Multifunction routing status */
50 pci_write_config32(dev
, MFUNC
, 0x018a1b22);
53 /* This is a workaround for buggy kernels. This should
54 * probably be read from the device tree, but as long
55 * as only one mainboard is using this bridge it does
58 * Basically what we do here is assign INTA to the first
59 * cardbus controller, and INTB to the second one. We know
60 * there are only two of them.
62 pci_write_config8(dev
, PCI_INTERRUPT_PIN
, cardbus_count
);
67 static void pci7420_cardbus_read_resources(struct device
*dev
)
69 cardbus_read_resources(dev
);
72 static void pci7420_cardbus_set_resources(struct device
*dev
)
74 printk(BIOS_DEBUG
, "%s In set resources\n",dev_path(dev
));
76 pci_dev_set_resources(dev
);
78 printk(BIOS_DEBUG
, "%s done set resources\n",dev_path(dev
));
81 static struct device_operations ti_pci7420_ops
= {
82 .read_resources
= pci7420_cardbus_read_resources
,
83 .set_resources
= pci7420_cardbus_set_resources
,
84 .enable_resources
= cardbus_enable_resources
,
85 .init
= pci7420_cardbus_init
,
86 .scan_bus
= pci_scan_bridge
,
89 static const struct pci_driver ti_pci7420_driver __pci_driver
= {
90 .ops
= &ti_pci7420_ops
,
95 static const struct pci_driver ti_pci7620_driver __pci_driver
= {
96 .ops
= &ti_pci7420_ops
,
101 struct chip_operations southbridge_ti_pci7420_ops
= {
102 CHIP_NAME("Texas Instruments PCI7420/7620 Cardbus Controller")