Lines Matching +full:memory +full:- +full:controller

2  *	PCI handling of I2O controller
4 * Copyright (C) 1999-2002 Red Hat Software
37 #define OSM_DESCRIPTION "I2O-subsystem"
49 * i2o_pci_free - Frees the DMA memory for the I2O controller
50 * @c: I2O controller to free
52 * Remove all allocated DMA memory and unmap memory IO regions. If MTRR
59 dev = &c->pdev->dev; in i2o_pci_free()
61 i2o_dma_free(dev, &c->out_queue); in i2o_pci_free()
62 i2o_dma_free(dev, &c->status_block); in i2o_pci_free()
63 kfree(c->lct); in i2o_pci_free()
64 i2o_dma_free(dev, &c->dlct); in i2o_pci_free()
65 i2o_dma_free(dev, &c->hrt); in i2o_pci_free()
66 i2o_dma_free(dev, &c->status); in i2o_pci_free()
68 if (c->raptor && c->in_queue.virt) in i2o_pci_free()
69 iounmap(c->in_queue.virt); in i2o_pci_free()
71 if (c->base.virt) in i2o_pci_free()
72 iounmap(c->base.virt); in i2o_pci_free()
74 pci_release_regions(c->pdev); in i2o_pci_free()
78 * i2o_pci_alloc - Allocate DMA memory, map IO memory for I2O controller
79 * @c: I2O controller
81 * Allocate DMA memory for a PCI (or in theory AGP) I2O controller. All
82 * IO mappings are also done here. If MTRR is enabled, also do add memory
89 struct pci_dev *pdev = c->pdev; in i2o_pci_alloc()
90 struct device *dev = &pdev->dev; in i2o_pci_alloc()
94 printk(KERN_ERR "%s: device already claimed\n", c->name); in i2o_pci_alloc()
95 return -ENODEV; in i2o_pci_alloc()
101 if (!c->base.phys) { in i2o_pci_alloc()
102 c->base.phys = pci_resource_start(pdev, i); in i2o_pci_alloc()
103 c->base.len = pci_resource_len(pdev, i); in i2o_pci_alloc()
109 if (pdev->device == 0xa501) { in i2o_pci_alloc()
110 if (pdev->subsystem_device >= 0xc032 && in i2o_pci_alloc()
111 pdev->subsystem_device <= 0xc03b) { in i2o_pci_alloc()
112 if (c->base.len > 0x400000) in i2o_pci_alloc()
113 c->base.len = 0x400000; in i2o_pci_alloc()
115 if (c->base.len > 0x100000) in i2o_pci_alloc()
116 c->base.len = 0x100000; in i2o_pci_alloc()
119 if (!c->raptor) in i2o_pci_alloc()
122 c->in_queue.phys = pci_resource_start(pdev, i); in i2o_pci_alloc()
123 c->in_queue.len = pci_resource_len(pdev, i); in i2o_pci_alloc()
130 printk(KERN_ERR "%s: I2O controller has no memory regions" in i2o_pci_alloc()
131 " defined.\n", c->name); in i2o_pci_alloc()
133 return -EINVAL; in i2o_pci_alloc()
136 /* Map the I2O controller */ in i2o_pci_alloc()
137 if (c->raptor) { in i2o_pci_alloc()
138 printk(KERN_INFO "%s: PCI I2O controller\n", c->name); in i2o_pci_alloc()
140 (unsigned long)c->base.phys, (unsigned long)c->base.len); in i2o_pci_alloc()
142 (unsigned long)c->in_queue.phys, in i2o_pci_alloc()
143 (unsigned long)c->in_queue.len); in i2o_pci_alloc()
145 printk(KERN_INFO "%s: PCI I2O controller at %08lX size=%ld\n", in i2o_pci_alloc()
146 c->name, (unsigned long)c->base.phys, in i2o_pci_alloc()
147 (unsigned long)c->base.len); in i2o_pci_alloc()
149 c->base.virt = ioremap_nocache(c->base.phys, c->base.len); in i2o_pci_alloc()
150 if (!c->base.virt) { in i2o_pci_alloc()
151 printk(KERN_ERR "%s: Unable to map controller.\n", c->name); in i2o_pci_alloc()
153 return -ENOMEM; in i2o_pci_alloc()
156 if (c->raptor) { in i2o_pci_alloc()
157 c->in_queue.virt = in i2o_pci_alloc()
158 ioremap_nocache(c->in_queue.phys, c->in_queue.len); in i2o_pci_alloc()
159 if (!c->in_queue.virt) { in i2o_pci_alloc()
160 printk(KERN_ERR "%s: Unable to map controller.\n", in i2o_pci_alloc()
161 c->name); in i2o_pci_alloc()
163 return -ENOMEM; in i2o_pci_alloc()
166 c->in_queue = c->base; in i2o_pci_alloc()
168 c->irq_status = c->base.virt + I2O_IRQ_STATUS; in i2o_pci_alloc()
169 c->irq_mask = c->base.virt + I2O_IRQ_MASK; in i2o_pci_alloc()
170 c->in_port = c->base.virt + I2O_IN_PORT; in i2o_pci_alloc()
171 c->out_port = c->base.virt + I2O_OUT_PORT; in i2o_pci_alloc()
174 if (pdev->vendor == PCI_VENDOR_ID_MOTOROLA && pdev->device == 0x18c0) { in i2o_pci_alloc()
176 if (be32_to_cpu(readl(c->base.virt + 0x10000)) & 0x10000000) { in i2o_pci_alloc()
178 "service I2O.\n", c->name); in i2o_pci_alloc()
180 return -ENODEV; in i2o_pci_alloc()
182 c->irq_status += I2O_MOTOROLA_PORT_OFFSET; in i2o_pci_alloc()
183 c->irq_mask += I2O_MOTOROLA_PORT_OFFSET; in i2o_pci_alloc()
184 c->in_port += I2O_MOTOROLA_PORT_OFFSET; in i2o_pci_alloc()
185 c->out_port += I2O_MOTOROLA_PORT_OFFSET; in i2o_pci_alloc()
187 c->name); in i2o_pci_alloc()
191 if (i2o_dma_alloc(dev, &c->status, 8)) { in i2o_pci_alloc()
193 return -ENOMEM; in i2o_pci_alloc()
196 if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt))) { in i2o_pci_alloc()
198 return -ENOMEM; in i2o_pci_alloc()
201 if (i2o_dma_alloc(dev, &c->dlct, 8192)) { in i2o_pci_alloc()
203 return -ENOMEM; in i2o_pci_alloc()
206 if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block))) { in i2o_pci_alloc()
208 return -ENOMEM; in i2o_pci_alloc()
211 if (i2o_dma_alloc(dev, &c->out_queue, in i2o_pci_alloc()
215 return -ENOMEM; in i2o_pci_alloc()
224 * i2o_pci_interrupt - Interrupt handler for I2O controller
226 * @dev_id: pointer to the I2O controller
228 * Handle an interrupt from a PCI based I2O controller. This turns out
229 * to be rather simple. We keep the controller pointer in the cookie.
237 while (readl(c->irq_status) & I2O_IRQ_OUTBOUND_POST) { in i2o_pci_interrupt()
238 m = readl(c->out_port); in i2o_pci_interrupt()
244 m = readl(c->out_port); in i2o_pci_interrupt()
261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller
264 * Allocate an interrupt for the I2O controller, and activate interrupts
265 * on the I2O controller.
271 struct pci_dev *pdev = c->pdev; in i2o_pci_irq_enable()
274 writel(0xffffffff, c->irq_mask); in i2o_pci_irq_enable()
276 if (pdev->irq) { in i2o_pci_irq_enable()
277 rc = request_irq(pdev->irq, i2o_pci_interrupt, IRQF_SHARED, in i2o_pci_irq_enable()
278 c->name, c); in i2o_pci_irq_enable()
281 "\n", c->name, pdev->irq); in i2o_pci_irq_enable()
286 writel(0x00000000, c->irq_mask); in i2o_pci_irq_enable()
288 printk(KERN_INFO "%s: Installed at IRQ %d\n", c->name, pdev->irq); in i2o_pci_irq_enable()
294 * i2o_pci_irq_disable - Free interrupt for I2O controller
295 * @c: I2O controller
297 * Disable interrupts in I2O controller and then free interrupt.
301 writel(0xffffffff, c->irq_mask); in i2o_pci_irq_disable()
303 if (c->pdev->irq > 0) in i2o_pci_irq_disable()
304 free_irq(c->pdev->irq, c); in i2o_pci_irq_disable()
308 * i2o_pci_probe - Probe the PCI device for an I2O controller
312 * Probe the PCI device for any device which is a memory of the
313 * Intelligent, I2O class or an Adaptec Zero Channel Controller. We
327 if ((pdev->class & 0xff) > 1) { in i2o_pci_probe()
330 return -ENODEV; in i2o_pci_probe()
342 rc = -ENODEV; in i2o_pci_probe()
350 printk(KERN_ERR "i2o: couldn't allocate memory for %s\n", in i2o_pci_probe()
355 printk(KERN_INFO "%s: controller found (%s)\n", c->name, in i2o_pci_probe()
358 c->pdev = pdev; in i2o_pci_probe()
359 c->device.parent = &pdev->dev; in i2o_pci_probe()
362 if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) { in i2o_pci_probe()
363 c->short_req = 1; in i2o_pci_probe()
365 c->name); in i2o_pci_probe()
368 if (pdev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) { in i2o_pci_probe()
373 i960 = pci_get_slot(c->pdev->bus, in i2o_pci_probe()
374 PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0)); in i2o_pci_probe()
381 c->promise = 1; in i2o_pci_probe()
382 c->limit_sectors = 1; in i2o_pci_probe()
385 if (pdev->subsystem_vendor == PCI_VENDOR_ID_DPT) in i2o_pci_probe()
386 c->adaptec = 1; in i2o_pci_probe()
389 if (pdev->vendor == PCI_VENDOR_ID_DPT) { in i2o_pci_probe()
390 c->no_quiesce = 1; in i2o_pci_probe()
391 if (pdev->device == 0xa511) in i2o_pci_probe()
392 c->raptor = 1; in i2o_pci_probe()
394 if (pdev->subsystem_device == 0xc05a) { in i2o_pci_probe()
395 c->limit_sectors = 1; in i2o_pci_probe()
397 "%s: limit sectors per request to %d\n", c->name, in i2o_pci_probe()
403 printk(KERN_INFO "%s: 64-bit DMA unavailable\n", in i2o_pci_probe()
404 c->name); in i2o_pci_probe()
406 c->pae_support = 1; in i2o_pci_probe()
407 printk(KERN_INFO "%s: using 64-bit DMA\n", in i2o_pci_probe()
408 c->name); in i2o_pci_probe()
415 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller " in i2o_pci_probe()
416 "failed\n", c->name); in i2o_pci_probe()
422 "controller\n", c->name); in i2o_pci_probe()
450 * i2o_pci_remove - Removes a I2O controller from the system
451 * @pdev: I2O controller which should be removed
453 * Reset the I2O controller, disable interrupts and remove all allocated
467 printk(KERN_INFO "%s: Controller removed.\n", c->name); in i2o_pci_remove()
469 put_device(&c->device); in i2o_pci_remove()
472 /* PCI driver for I2O controller */
481 * i2o_pci_init - registers I2O PCI driver in PCI subsystem
491 * i2o_pci_exit - unregisters I2O PCI driver from PCI subsystem