aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authormatthieu castet <castet.matthieu@free.fr>2009-06-30 17:04:55 -0400
committerRalf Baechle <ralf@linux-mips.org>2009-07-03 10:45:27 -0400
commitea4bbfd0048c53c24f72ef668b39f1247bc243c0 (patch)
treedf871a70349f18842c0a38b51cad2dd3ee65b07a /drivers
parenteb9b5141a9815ef898ef6b6441f733e81c272600 (diff)
MIPS: BC47xx: Fix SSB irq setup
The current ssb irq setup in ssb_mipscore_init has the problem that it configures some device on some irq without checking that the irq is not taken by an other device. For example in my case PCI host is on irq 0 and IPSEC on irq 3. The current code: - store in dev->irq that IPSEC irq is 3 + 2 - do a set_irq 0->3 on PCI host But now IPSEC irq is not routed anymore to the mips code and dev->irq is wrong. This causes a problem described in [1]. This patch tries to solve the problem by making set_irq configure the device we want to take the irq on the shared irq0. The previous example becomes: - store in dev->irq that IPSEC irq is 3 + 2 - do a set_irq 0->3 on PCI host: - irq 3 is already taken by IPSEC. do a set_irq 3->0 on IPSEC I also added some code to print the irq configuration after irq setup to allow easier debugging. And I add extra checking in ssb_mips_irq to report device without irq or device with not routed irq. [1] http://www.danm.de/files/src/bcm5365p/REPORTED_DEVICES Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr> Acked-by : Michael Buesch <mb@bu3sch.de> Tested-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ssb/driver_mipscore.c85
1 files changed, 75 insertions, 10 deletions
diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c
index 3fd3e3b412b6..3c6feed46f6e 100644
--- a/drivers/ssb/driver_mipscore.c
+++ b/drivers/ssb/driver_mipscore.c
@@ -49,29 +49,54 @@ static const u32 ipsflag_irq_shift[] = {
49 49
50static inline u32 ssb_irqflag(struct ssb_device *dev) 50static inline u32 ssb_irqflag(struct ssb_device *dev)
51{ 51{
52 return ssb_read32(dev, SSB_TPSFLAG) & SSB_TPSFLAG_BPFLAG; 52 u32 tpsflag = ssb_read32(dev, SSB_TPSFLAG);
53 if (tpsflag)
54 return ssb_read32(dev, SSB_TPSFLAG) & SSB_TPSFLAG_BPFLAG;
55 else
56 /* not irq supported */
57 return 0x3f;
58}
59
60static struct ssb_device *find_device(struct ssb_device *rdev, int irqflag)
61{
62 struct ssb_bus *bus = rdev->bus;
63 int i;
64 for (i = 0; i < bus->nr_devices; i++) {
65 struct ssb_device *dev;
66 dev = &(bus->devices[i]);
67 if (ssb_irqflag(dev) == irqflag)
68 return dev;
69 }
70 return NULL;
53} 71}
54 72
55/* Get the MIPS IRQ assignment for a specified device. 73/* Get the MIPS IRQ assignment for a specified device.
56 * If unassigned, 0 is returned. 74 * If unassigned, 0 is returned.
75 * If disabled, 5 is returned.
76 * If not supported, 6 is returned.
57 */ 77 */
58unsigned int ssb_mips_irq(struct ssb_device *dev) 78unsigned int ssb_mips_irq(struct ssb_device *dev)
59{ 79{
60 struct ssb_bus *bus = dev->bus; 80 struct ssb_bus *bus = dev->bus;
81 struct ssb_device *mdev = bus->mipscore.dev;
61 u32 irqflag; 82 u32 irqflag;
62 u32 ipsflag; 83 u32 ipsflag;
63 u32 tmp; 84 u32 tmp;
64 unsigned int irq; 85 unsigned int irq;
65 86
66 irqflag = ssb_irqflag(dev); 87 irqflag = ssb_irqflag(dev);
88 if (irqflag == 0x3f)
89 return 6;
67 ipsflag = ssb_read32(bus->mipscore.dev, SSB_IPSFLAG); 90 ipsflag = ssb_read32(bus->mipscore.dev, SSB_IPSFLAG);
68 for (irq = 1; irq <= 4; irq++) { 91 for (irq = 1; irq <= 4; irq++) {
69 tmp = ((ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq]); 92 tmp = ((ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq]);
70 if (tmp == irqflag) 93 if (tmp == irqflag)
71 break; 94 break;
72 } 95 }
73 if (irq == 5) 96 if (irq == 5) {
74 irq = 0; 97 if ((1 << irqflag) & ssb_read32(mdev, SSB_INTVEC))
98 irq = 0;
99 }
75 100
76 return irq; 101 return irq;
77} 102}
@@ -97,25 +122,56 @@ static void set_irq(struct ssb_device *dev, unsigned int irq)
97 struct ssb_device *mdev = bus->mipscore.dev; 122 struct ssb_device *mdev = bus->mipscore.dev;
98 u32 irqflag = ssb_irqflag(dev); 123 u32 irqflag = ssb_irqflag(dev);
99 124
125 BUG_ON(oldirq == 6);
126
100 dev->irq = irq + 2; 127 dev->irq = irq + 2;
101 128
102 ssb_dprintk(KERN_INFO PFX
103 "set_irq: core 0x%04x, irq %d => %d\n",
104 dev->id.coreid, oldirq, irq);
105 /* clear the old irq */ 129 /* clear the old irq */
106 if (oldirq == 0) 130 if (oldirq == 0)
107 ssb_write32(mdev, SSB_INTVEC, (~(1 << irqflag) & ssb_read32(mdev, SSB_INTVEC))); 131 ssb_write32(mdev, SSB_INTVEC, (~(1 << irqflag) & ssb_read32(mdev, SSB_INTVEC)));
108 else 132 else if (oldirq != 5)
109 clear_irq(bus, oldirq); 133 clear_irq(bus, oldirq);
110 134
111 /* assign the new one */ 135 /* assign the new one */
112 if (irq == 0) { 136 if (irq == 0) {
113 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) | ssb_read32(mdev, SSB_INTVEC))); 137 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) | ssb_read32(mdev, SSB_INTVEC)));
114 } else { 138 } else {
139 u32 ipsflag = ssb_read32(mdev, SSB_IPSFLAG);
140 if ((ipsflag & ipsflag_irq_mask[irq]) != ipsflag_irq_mask[irq]) {
141 u32 oldipsflag = (ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq];
142 struct ssb_device *olddev = find_device(dev, oldipsflag);
143 if (olddev)
144 set_irq(olddev, 0);
145 }
115 irqflag <<= ipsflag_irq_shift[irq]; 146 irqflag <<= ipsflag_irq_shift[irq];
116 irqflag |= (ssb_read32(mdev, SSB_IPSFLAG) & ~ipsflag_irq_mask[irq]); 147 irqflag |= (ipsflag & ~ipsflag_irq_mask[irq]);
117 ssb_write32(mdev, SSB_IPSFLAG, irqflag); 148 ssb_write32(mdev, SSB_IPSFLAG, irqflag);
118 } 149 }
150 ssb_dprintk(KERN_INFO PFX
151 "set_irq: core 0x%04x, irq %d => %d\n",
152 dev->id.coreid, oldirq+2, irq+2);
153}
154
155static void print_irq(struct ssb_device *dev, unsigned int irq)
156{
157 int i;
158 static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
159 ssb_dprintk(KERN_INFO PFX
160 "core 0x%04x, irq :", dev->id.coreid);
161 for (i = 0; i <= 6; i++) {
162 ssb_dprintk(" %s%s", irq_name[i], i==irq?"*":" ");
163 }
164 ssb_dprintk("\n");
165}
166
167static void dump_irq(struct ssb_bus *bus)
168{
169 int i;
170 for (i = 0; i < bus->nr_devices; i++) {
171 struct ssb_device *dev;
172 dev = &(bus->devices[i]);
173 print_irq(dev, ssb_mips_irq(dev));
174 }
119} 175}
120 176
121static void ssb_mips_serial_init(struct ssb_mipscore *mcore) 177static void ssb_mips_serial_init(struct ssb_mipscore *mcore)
@@ -197,16 +253,23 @@ void ssb_mipscore_init(struct ssb_mipscore *mcore)
197 253
198 /* Assign IRQs to all cores on the bus, start with irq line 2, because serial usually takes 1 */ 254 /* Assign IRQs to all cores on the bus, start with irq line 2, because serial usually takes 1 */
199 for (irq = 2, i = 0; i < bus->nr_devices; i++) { 255 for (irq = 2, i = 0; i < bus->nr_devices; i++) {
256 int mips_irq;
200 dev = &(bus->devices[i]); 257 dev = &(bus->devices[i]);
201 dev->irq = ssb_mips_irq(dev) + 2; 258 mips_irq = ssb_mips_irq(dev);
259 if (mips_irq > 4)
260 dev->irq = 0;
261 else
262 dev->irq = mips_irq + 2;
263 if (dev->irq > 5)
264 continue;
202 switch (dev->id.coreid) { 265 switch (dev->id.coreid) {
203 case SSB_DEV_USB11_HOST: 266 case SSB_DEV_USB11_HOST:
204 /* shouldn't need a separate irq line for non-4710, most of them have a proper 267 /* shouldn't need a separate irq line for non-4710, most of them have a proper
205 * external usb controller on the pci */ 268 * external usb controller on the pci */
206 if ((bus->chip_id == 0x4710) && (irq <= 4)) { 269 if ((bus->chip_id == 0x4710) && (irq <= 4)) {
207 set_irq(dev, irq++); 270 set_irq(dev, irq++);
208 break;
209 } 271 }
272 break;
210 /* fallthrough */ 273 /* fallthrough */
211 case SSB_DEV_PCI: 274 case SSB_DEV_PCI:
212 case SSB_DEV_ETHERNET: 275 case SSB_DEV_ETHERNET:
@@ -220,6 +283,8 @@ void ssb_mipscore_init(struct ssb_mipscore *mcore)
220 } 283 }
221 } 284 }
222 } 285 }
286 ssb_dprintk(KERN_INFO PFX "after irq reconfiguration\n");
287 dump_irq(bus);
223 288
224 ssb_mips_serial_init(mcore); 289 ssb_mips_serial_init(mcore);
225 ssb_mips_flash_detect(mcore); 290 ssb_mips_flash_detect(mcore);