0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/init.h>
0011 #include <linux/pci.h>
0012
0013 #include <loongson.h>
0014
0015
0016 static u8 sb_slot = 5;
0017
0018 int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
0019 {
0020 int irq = 0;
0021
0022 if (slot == sb_slot) {
0023 switch (PCI_FUNC(dev->devfn)) {
0024 case 2:
0025 irq = 10;
0026 break;
0027 case 3:
0028 irq = 11;
0029 break;
0030 case 5:
0031 irq = 9;
0032 break;
0033 }
0034 } else {
0035 irq = LOONGSON_IRQ_BASE + 25 + pin;
0036 }
0037 return irq;
0038
0039 }
0040
0041
0042 int pcibios_plat_dev_init(struct pci_dev *dev)
0043 {
0044 return 0;
0045 }
0046
0047 static void loongson2e_nec_fixup(struct pci_dev *pdev)
0048 {
0049 unsigned int val;
0050
0051
0052 pci_read_config_dword(pdev, 0xe0, &val);
0053 pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x4);
0054
0055
0056 pci_write_config_dword(pdev, 0xe4, 1 << 5);
0057 }
0058
0059 static void loongson2e_686b_func0_fixup(struct pci_dev *pdev)
0060 {
0061 unsigned char c;
0062
0063 sb_slot = PCI_SLOT(pdev->devfn);
0064
0065 printk(KERN_INFO "via686b fix: ISA bridge\n");
0066
0067
0068 pci_write_config_byte(pdev, 0x40, 0x08);
0069
0070
0071 pci_write_config_byte(pdev, 0x41, 0x01);
0072
0073
0074 pci_write_config_byte(pdev, 0x45, 0x00);
0075
0076
0077 pci_write_config_byte(pdev, 0x46, 0xe0);
0078
0079
0080
0081
0082
0083
0084
0085
0086 pci_write_config_byte(pdev, 0x47, 0xe6);
0087
0088
0089
0090
0091
0092 outb(0x2e, 0x4d1);
0093
0094
0095 pci_write_config_byte(pdev, 0x48, 0x01);
0096
0097
0098 pci_write_config_byte(pdev, 0x4a, 0x84);
0099
0100
0101
0102
0103
0104
0105 pci_write_config_byte(pdev, 0x50, 0x0e);
0106
0107
0108
0109
0110
0111
0112 pci_write_config_byte(pdev, 0x51, 0x76);
0113
0114
0115 pci_write_config_byte(pdev, 0x52, 0x34);
0116
0117
0118 pci_write_config_byte(pdev, 0x54, 0x00);
0119
0120
0121 pci_write_config_byte(pdev, 0x55, 0x90);
0122 pci_write_config_byte(pdev, 0x56, 0xba);
0123
0124 pci_write_config_byte(pdev, 0x57, 0xd0);
0125
0126
0127 pci_read_config_byte(pdev, 0x85, &c);
0128 c &= ~(0x3 << 2);
0129 pci_write_config_byte(pdev, 0x85, c);
0130
0131 printk(KERN_INFO"via686b fix: ISA bridge done\n");
0132 }
0133
0134 static void loongson2e_686b_func1_fixup(struct pci_dev *pdev)
0135 {
0136 printk(KERN_INFO"via686b fix: IDE\n");
0137
0138
0139 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 48);
0140 pci_write_config_byte(pdev, PCI_COMMAND,
0141 PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
0142 PCI_COMMAND_MASTER);
0143 pci_write_config_byte(pdev, 0x40, 0x0b);
0144
0145 pci_write_config_byte(pdev, 0x42, 0x09);
0146
0147 #if 1
0148
0149 pci_write_config_byte(pdev, 0x41, 0x02);
0150
0151
0152 pci_write_config_byte(pdev, 0x43, 0x0a);
0153 pci_write_config_byte(pdev, 0x44, 0x00);
0154
0155 pci_write_config_byte(pdev, 0x45, 0x00);
0156 #else
0157 pci_write_config_byte(pdev, 0x41, 0xc2);
0158 pci_write_config_byte(pdev, 0x43, 0x35);
0159 pci_write_config_byte(pdev, 0x44, 0x1c);
0160
0161 pci_write_config_byte(pdev, 0x45, 0x10);
0162 #endif
0163
0164 printk(KERN_INFO"via686b fix: IDE done\n");
0165 }
0166
0167 static void loongson2e_686b_func2_fixup(struct pci_dev *pdev)
0168 {
0169
0170 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 10);
0171 }
0172
0173 static void loongson2e_686b_func3_fixup(struct pci_dev *pdev)
0174 {
0175
0176 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 11);
0177 }
0178
0179 static void loongson2e_686b_func5_fixup(struct pci_dev *pdev)
0180 {
0181 unsigned int val;
0182 unsigned char c;
0183
0184
0185 pci_write_config_byte(pdev, PCI_COMMAND,
0186 PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
0187 PCI_COMMAND_MASTER);
0188 pci_read_config_dword(pdev, 0x4, &val);
0189 pci_write_config_dword(pdev, 0x4, val | 1);
0190
0191
0192 pci_write_config_byte(pdev, 0x3c, 9);
0193
0194 pci_read_config_byte(pdev, 0x8, &c);
0195
0196
0197 pci_write_config_byte(pdev, 0x41, 0xcc);
0198
0199
0200 pci_write_config_byte(pdev, 0x42, 0x20);
0201
0202
0203 pci_write_config_word(pdev, 0x2c, 0x1005);
0204 pci_write_config_word(pdev, 0x2e, 0x4710);
0205 pci_read_config_dword(pdev, 0x2c, &val);
0206
0207 pci_write_config_byte(pdev, 0x42, 0x0);
0208 }
0209
0210 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686,
0211 loongson2e_686b_func0_fixup);
0212 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
0213 loongson2e_686b_func1_fixup);
0214 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2,
0215 loongson2e_686b_func2_fixup);
0216 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3,
0217 loongson2e_686b_func3_fixup);
0218 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5,
0219 loongson2e_686b_func5_fixup);
0220 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
0221 loongson2e_nec_fixup);