2 * Copyright (C) 2004, 2006 MIPS Technologies, Inc. All rights reserved.
3 * Author: Maciej W. Rozycki <macro@mips.com>
4 * Copyright (C) 2018 Maciej W. Rozycki
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/dma-mapping.h>
13 #include <linux/pci.h>
16 * Set the BCM1250, etc. PCI host bridge's TRDY timeout
19 static void quirk_sb1250_pci(struct pci_dev
*dev
)
21 pci_write_config_byte(dev
, 0x40, 0xff);
23 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SIBYTE
, PCI_DEVICE_ID_BCM1250_PCI
,
27 * The BCM1250, etc. PCI host bridge does not support DAC on its 32-bit
28 * bus, so we set the bus's DMA mask accordingly. However the HT link
29 * down the artificial PCI-HT bridge supports 40-bit addressing and the
30 * SP1011 HT-PCI bridge downstream supports both DAC and a 64-bit bus
31 * width, so we record the PCI-HT bridge's secondary and subordinate bus
32 * numbers and do not set the mask for devices present in the inclusive
35 struct sb1250_bus_dma_mask_exclude
{
41 static int sb1250_bus_dma_mask(struct pci_dev
*dev
, void *data
)
43 struct sb1250_bus_dma_mask_exclude
*exclude
= data
;
47 exclude_this
= exclude
->set
&& (dev
->bus
->number
>= exclude
->start
&&
48 dev
->bus
->number
<= exclude
->end
);
49 ht_bridge
= !exclude
->set
&& (dev
->vendor
== PCI_VENDOR_ID_SIBYTE
&&
50 dev
->device
== PCI_DEVICE_ID_BCM1250_HT
);
53 dev_dbg(&dev
->dev
, "not disabling DAC for device");
54 } else if (ht_bridge
) {
55 exclude
->start
= dev
->subordinate
->number
;
56 exclude
->end
= pci_bus_max_busnr(dev
->subordinate
);
58 dev_dbg(&dev
->dev
, "not disabling DAC for [bus %02x-%02x]",
59 exclude
->start
, exclude
->end
);
61 dev_dbg(&dev
->dev
, "disabling DAC for device");
62 dev
->dev
.bus_dma_mask
= DMA_BIT_MASK(32);
68 static void quirk_sb1250_pci_dac(struct pci_dev
*dev
)
70 struct sb1250_bus_dma_mask_exclude exclude
= { .set
= false };
72 pci_walk_bus(dev
->bus
, sb1250_bus_dma_mask
, &exclude
);
74 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SIBYTE
, PCI_DEVICE_ID_BCM1250_PCI
,
75 quirk_sb1250_pci_dac
);
78 * The BCM1250, etc. PCI/HT bridge reports as a host bridge.
80 static void quirk_sb1250_ht(struct pci_dev
*dev
)
82 dev
->class = PCI_CLASS_BRIDGE_PCI
<< 8;
84 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SIBYTE
, PCI_DEVICE_ID_BCM1250_HT
,
88 * Set the SP1011 HT/PCI bridge's TRDY timeout to the finite max.
90 static void quirk_sp1011(struct pci_dev
*dev
)
92 pci_write_config_byte(dev
, 0x64, 0xff);
94 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SIPACKETS
, PCI_DEVICE_ID_SP1011
,