dba323da9afbf2d8a0750779b73685211364e716
[openwrt.git] / target / linux / lantiq / patches-3.2 / 0054-MIPS-lantiq-pci-move-pcibios-code-into-fixup-lantiq..patch
1 From 49b5d2242091e216736216d98d7f940870d4f1ec Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 8 Mar 2012 15:53:10 +0100
4 Subject: [PATCH 54/70] MIPS: lantiq: pci: move pcibios code into
5  fixup-lantiq.c
6
7 ---
8  arch/mips/pci/Makefile       |    1 +
9  arch/mips/pci/fixup-lantiq.c |   42 ++++++++++++++++++++++++++++++++++++++++++
10  arch/mips/pci/pci-lantiq.c   |   24 ++----------------------
11  3 files changed, 45 insertions(+), 22 deletions(-)
12  create mode 100644 arch/mips/pci/fixup-lantiq.c
13
14 --- a/arch/mips/pci/Makefile
15 +++ b/arch/mips/pci/Makefile
16 @@ -40,6 +40,7 @@ obj-$(CONFIG_SIBYTE_SB1250)   += fixup-sb1
17  obj-$(CONFIG_SIBYTE_BCM112X)   += fixup-sb1250.o pci-sb1250.o
18  obj-$(CONFIG_SIBYTE_BCM1x80)   += pci-bcm1480.o pci-bcm1480ht.o
19  obj-$(CONFIG_SNI_RM)           += fixup-sni.o ops-sni.o
20 +obj-$(CONFIG_LANTIQ)           += fixup-lantiq.o
21  obj-$(CONFIG_PCI_LANTIQ)       += pci-lantiq.o ops-lantiq.o
22  obj-$(CONFIG_TANBAC_TB0219)    += fixup-tb0219.o
23  obj-$(CONFIG_TANBAC_TB0226)    += fixup-tb0226.o
24 --- /dev/null
25 +++ b/arch/mips/pci/fixup-lantiq.c
26 @@ -0,0 +1,42 @@
27 +/*
28 + *  This program is free software; you can redistribute it and/or modify it
29 + *  under the terms of the GNU General Public License version 2 as published
30 + *  by the Free Software Foundation.
31 + *
32 + *  Copyright (C) 2012 John Crispin <blogic@openwrt.org>
33 + */
34 +
35 +#include <linux/of_irq.h>
36 +#include <linux/of_pci.h>
37 +
38 +int (*ltqpci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin) = NULL;
39 +int (*ltqpci_plat_arch_init)(struct pci_dev *dev) = NULL;
40 +int (*ltqpci_plat_dev_init)(struct pci_dev *dev) = NULL;
41 +int *ltq_pci_irq_map;
42 +
43 +int pcibios_plat_dev_init(struct pci_dev *dev)
44 +{
45 +       if (ltqpci_plat_arch_init)
46 +               return ltqpci_plat_arch_init(dev);
47 +
48 +       if (ltqpci_plat_dev_init)
49 +               return ltqpci_plat_dev_init(dev);
50 +
51 +       return 0;
52 +}
53 +
54 +int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
55 +{
56 +       if (ltqpci_map_irq)
57 +               return ltqpci_map_irq(dev, slot, pin);
58 +       if (ltq_pci_irq_map[slot]) {
59 +               dev_info(&dev->dev, "SLOT:%d PIN:%d IRQ:%d\n", slot, pin, ltq_pci_irq_map[slot]);
60 +               return ltq_pci_irq_map[slot];
61 +       }
62 +       printk(KERN_ERR "lq_pci: trying to map irq for unknown slot %d\n",
63 +               slot);
64 +
65 +       return 0;
66 +}
67 +
68 +
69 --- a/arch/mips/pci/pci-lantiq.c
70 +++ b/arch/mips/pci/pci-lantiq.c
71 @@ -93,16 +93,14 @@ static struct ltq_pci_gpio_map ltq_pci_g
72         { 37, 2, 0, "pci-req4" },
73  };
74  
75 -__iomem void *ltq_pci_mapped_cfg;
76 +__iomem void *ltq_pci_cfgbase;
77  static __iomem void *ltq_pci_membase;
78  
79 -int (*ltqpci_plat_dev_init)(struct pci_dev *dev) = NULL;
80 -
81  /* Since the PCI REQ pins can be reused for other functionality, make it
82     possible to exclude those from interpretation by the PCI controller */
83  static int ltq_pci_req_mask = 0xf;
84  
85 -static int *ltq_pci_irq_map;
86 +extern int *ltq_pci_irq_map;
87  
88  struct pci_ops ltq_pci_ops = {
89         .read   = ltq_pci_read_config_dword,
90 @@ -131,14 +129,6 @@ static struct pci_controller ltq_pci_con
91         .io_offset      = 0x00000000UL,
92  };
93  
94 -int pcibios_plat_dev_init(struct pci_dev *dev)
95 -{
96 -       if (ltqpci_plat_dev_init)
97 -               return ltqpci_plat_dev_init(dev);
98 -
99 -       return 0;
100 -}
101 -
102  static u32 ltq_calc_bar11mask(void)
103  {
104         u32 mem, bar11mask;
105 @@ -256,16 +246,6 @@ static int __devinit ltq_pci_startup(str
106         return 0;
107  }
108  
109 -int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
110 -{
111 -       if (ltq_pci_irq_map[slot])
112 -               return ltq_pci_irq_map[slot];
113 -       printk(KERN_ERR "lq_pci: trying to map irq for unknown slot %d\n",
114 -               slot);
115 -
116 -       return 0;
117 -}
118 -
119  static int __devinit ltq_pci_probe(struct platform_device *pdev)
120  {
121         struct ltq_pci_data *ltq_pci_data =