blob: 2b6d5e196f9990255eb5d35de3e6580a69f6003f [file] [log] [blame]
Huacai Chenc7d35552014-03-21 18:44:03 +08001/*
2 * fixup-loongson3.c
3 *
4 * Copyright (C) 2012 Lemote, Inc.
5 * Author: Xiang Yu, xiangy@lemote.com
6 * Chen Huacai, chenhc@lemote.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 */
25
26#include <linux/pci.h>
27#include <boot_param.h>
28
29static void print_fixup_info(const struct pci_dev *pdev)
30{
31 dev_info(&pdev->dev, "Device %x:%x, irq %d\n",
32 pdev->vendor, pdev->device, pdev->irq);
33}
34
35int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
36{
37 print_fixup_info(dev);
38 return dev->irq;
39}
40
41static void pci_fixup_radeon(struct pci_dev *pdev)
42{
Bjorn Helgaas53f0a502016-03-02 21:38:29 -060043 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
44
45 if (res->start)
Huacai Chenc7d35552014-03-21 18:44:03 +080046 return;
47
48 if (!loongson_sysconf.vgabios_addr)
49 return;
50
Bjorn Helgaas97f47e72016-03-02 21:42:04 -060051 pci_disable_rom(pdev);
52 if (res->parent)
53 release_resource(res);
54
55 res->start = virt_to_phys((void *) loongson_sysconf.vgabios_addr);
Bjorn Helgaas53f0a502016-03-02 21:38:29 -060056 res->end = res->start + 256*1024 - 1;
Bjorn Helgaas97f47e72016-03-02 21:42:04 -060057 res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
58 IORESOURCE_PCI_FIXED;
Huacai Chenc7d35552014-03-21 18:44:03 +080059
60 dev_info(&pdev->dev, "BAR %d: assigned %pR for Radeon ROM\n",
Bjorn Helgaas53f0a502016-03-02 21:38:29 -060061 PCI_ROM_RESOURCE, res);
Huacai Chenc7d35552014-03-21 18:44:03 +080062}
63
64DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
65 PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_radeon);
66
67/* Do platform specific device initialization at pci_enable_device() time */
68int pcibios_plat_dev_init(struct pci_dev *dev)
69{
70 return 0;
71}