Lines Matching refs:idd
40 static int nic_wait(struct ioc3_driver_data *idd)
45 mcr = readl(&idd->vma->mcr);
51 static int nic_reset(struct ioc3_driver_data *idd)
57 writel(mcr_pack(500, 65), &idd->vma->mcr);
58 presence = nic_wait(idd);
66 static int nic_read_bit(struct ioc3_driver_data *idd)
72 writel(mcr_pack(6, 13), &idd->vma->mcr);
73 result = nic_wait(idd);
81 static void nic_write_bit(struct ioc3_driver_data *idd, int bit)
84 writel(mcr_pack(6, 110), &idd->vma->mcr);
86 writel(mcr_pack(80, 30), &idd->vma->mcr);
88 nic_wait(idd);
91 static unsigned nic_read_byte(struct ioc3_driver_data *idd)
97 result = (result >> 1) | (nic_read_bit(idd) << 7);
102 static void nic_write_byte(struct ioc3_driver_data *idd, int byte)
110 nic_write_bit(idd, bit);
115 nic_find(struct ioc3_driver_data *idd, int *last, unsigned long addr)
119 nic_reset(idd);
122 nic_write_byte(idd, 0xF0);
126 a = nic_read_bit(idd);
127 b = nic_read_bit(idd);
143 nic_write_bit(idd, (addr>>index)&1);
150 nic_write_bit(idd, a);
158 static void nic_addr(struct ioc3_driver_data *idd, unsigned long addr)
162 nic_reset(idd);
163 nic_write_byte(idd, 0xF0);
165 nic_read_bit(idd);
166 nic_read_bit(idd);
167 nic_write_bit(idd, (addr>>index)&1);
216 read_redir_page(struct ioc3_driver_data *idd, unsigned long addr, int page,
231 nic_addr(idd, addr);
232 nic_write_byte(idd, 0xF0);
233 nic_write_byte(idd, (page << 5) & 0xE0);
234 nic_write_byte(idd, (page >> 3) & 0x1F);
236 data[i] = nic_read_byte(idd);
247 read_redir_map(struct ioc3_driver_data *idd, unsigned long addr,
255 nic_addr(idd, addr);
256 nic_write_byte(idd, 0xAA);
257 nic_write_byte(idd, 0x00);
258 nic_write_byte(idd, 0x01);
261 redir[i+j] = nic_read_byte(idd);
263 crc16_byte(&crc, nic_read_byte(idd));
264 crc16_byte(&crc, nic_read_byte(idd));
277 static void read_nic(struct ioc3_driver_data *idd, unsigned long addr)
284 read_redir_map(idd, addr, redir);
286 read_redir_page(idd, addr, 0, redir, data);
287 read_redir_page(idd, addr, 1, redir, data+32);
302 strcpy(idd->nic_part, part);
307 idd->nic_serial[j++] = data[i+1];
308 idd->nic_serial[j] = 0;
311 static void read_mac(struct ioc3_driver_data *idd, unsigned long addr)
317 nic_addr(idd, addr);
318 nic_write_byte(idd, 0xF0);
319 nic_write_byte(idd, 0x00);
320 nic_write_byte(idd, 0x00);
321 nic_read_byte(idd);
323 data[i] = nic_read_byte(idd);
326 idd->nic_mac[10-i] = data[i];
333 idd->nic_mac[i] = 0x00;
336 static void probe_nic(struct ioc3_driver_data *idd)
341 writel(GPCR_MLAN_EN, &idd->vma->gpcr_s);
344 idd->nic_part[0] = 0;
345 idd->nic_serial[0] = 0;
346 addr = first = nic_find(idd, &save, 0);
355 read_nic(idd, addr);
360 read_mac(idd, addr);
364 addr = nic_find(idd, &save, addr);
375 static void write_ireg(struct ioc3_driver_data *idd, uint32_t val, int which)
379 spin_lock_irqsave(&idd->ir_lock, flags);
382 writel(val, &idd->vma->sio_ies);
385 writel(val, &idd->vma->sio_iec);
388 spin_unlock_irqrestore(&idd->ir_lock, flags);
390 static inline uint32_t get_pending_intrs(struct ioc3_driver_data *idd)
395 spin_lock_irqsave(&idd->ir_lock, flag);
396 intrs = readl(&idd->vma->sio_ir);
397 intrs &= readl(&idd->vma->sio_ies);
398 spin_unlock_irqrestore(&idd->ir_lock, flag);
405 struct ioc3_driver_data *idd = arg;
411 if(idd->dual_irq && readb(&idd->vma->eisr)) {
413 if(ioc3_ethernet && idd->active[ioc3_ethernet->id] &&
416 idd, 0);
419 pending = get_pending_intrs(idd); /* look at the IO IRQs */
422 if(idd->active[id] && ioc3_submodules[id]
425 write_ireg(idd, ioc3_submodules[id]->irq_mask,
428 idd, pending & ioc3_submodules[id]->irq_mask))
431 write_ireg(idd, ioc3_submodules[id]->irq_mask,
439 write_ireg(idd, pending, IOC3_W_IEC);
448 struct ioc3_driver_data *idd = (struct ioc3_driver_data *)arg;
451 if(!idd->dual_irq)
454 if(ioc3_ethernet && idd->active[ioc3_ethernet->id]
456 handled = handled && !ioc3_ethernet->intr(ioc3_ethernet, idd, 0);
462 struct ioc3_driver_data *idd, unsigned int irqs)
464 write_ireg(idd, irqs & is->irq_mask, IOC3_W_IES);
467 void ioc3_ack(struct ioc3_submodule *is, struct ioc3_driver_data *idd,
470 writel(irqs & is->irq_mask, &idd->vma->sio_ir);
474 struct ioc3_driver_data *idd, unsigned int irqs)
476 write_ireg(idd, irqs & is->irq_mask, IOC3_W_IEC);
479 void ioc3_gpcr_set(struct ioc3_driver_data *idd, unsigned int val)
482 spin_lock_irqsave(&idd->gpio_lock, flags);
483 writel(val, &idd->vma->gpcr_s);
484 spin_unlock_irqrestore(&idd->gpio_lock, flags);
500 struct ioc3_driver_data *idd;
530 list_for_each_entry(idd, &ioc3_devices, list) {
532 idd->active[alloc_id] = 1;
533 idd->active[alloc_id] = !is->probe(is, idd);
543 struct ioc3_driver_data *idd;
558 list_for_each_entry(idd, &ioc3_devices, list)
559 if(idd->active[is->id]) {
561 if(is->remove(is, idd))
566 pci_name(idd->pdev));
567 idd->active[is->id] = 0;
569 write_ireg(idd, is->irq_mask, IOC3_W_IEC);
581 static int ioc3_class(struct ioc3_driver_data *idd)
585 if(!strncmp(idd->nic_part, "030-0891-", 9))
587 if(!strncmp(idd->nic_part, "030-1155-", 9))
589 if(!strncmp(idd->nic_part, "030-1657-", 9))
591 if(!strncmp(idd->nic_part, "030-1664-", 9))
595 if(!idd->nic_part[0])
600 idd->nic_part, idd->nic_serial, ioc3_class_names[res]);
606 struct ioc3_driver_data *idd;
632 idd = kzalloc(sizeof(struct ioc3_driver_data), GFP_KERNEL);
633 if (!idd) {
640 spin_lock_init(&idd->ir_lock);
641 spin_lock_init(&idd->gpio_lock);
642 idd->pdev = pdev;
647 idd->pma = pci_resource_start(pdev, 0);
648 if (!idd->pma) {
656 if (!request_mem_region(idd->pma, IOC3_PCI_SIZE, "ioc3")) {
664 idd->vma = ioremap(idd->pma, IOC3_PCI_SIZE);
665 if (!idd->vma) {
675 pci_set_drvdata(pdev, idd);
677 list_add_tail(&idd->list, &ioc3_devices);
678 idd->id = ioc3_counter++;
681 idd->gpdr_shadow = readl(&idd->vma->gpdr);
684 probe_nic(idd);
687 idd->class = ioc3_class(idd);
696 write_ireg(idd, ~0, IOC3_W_IEC);
697 writel(~0, &idd->vma->sio_ir);
700 if(idd->class == IOC3_CLASS_BASE_IP30
701 || idd->class == IOC3_CLASS_BASE_IP27) {
702 writel(0, &idd->vma->eier);
703 writel(~0, &idd->vma->eisr);
705 idd->dual_irq = 1;
707 "ioc3-eth", (void *)idd)) {
708 idd->irq_eth = pdev->irq;
715 "ioc3-io", (void *)idd)) {
716 idd->irq_io = pdev->irq+2;
724 "ioc3", (void *)idd)) {
725 idd->irq_io = pdev->irq;
736 idd->active[id] = 1;
737 idd->active[id] = !ioc3_submodules[id]->probe
738 (ioc3_submodules[id], idd);
746 release_mem_region(idd->pma, IOC3_PCI_SIZE);
748 kfree(idd);
759 struct ioc3_driver_data *idd;
761 idd = pci_get_drvdata(pdev);
765 if(idd->active[id]) {
768 idd))
775 idd->active[id] = 0;
779 write_ireg(idd, ~0, IOC3_W_IEC);
780 writel(~0, &idd->vma->sio_ir);
783 free_irq(idd->irq_io, (void *)idd);
784 if(idd->dual_irq)
785 free_irq(idd->irq_eth, (void *)idd);
786 iounmap(idd->vma);
787 release_mem_region(idd->pma, IOC3_PCI_SIZE);
794 list_del(&idd->list);
796 kfree(idd);