static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const char *name) { int i; if (dev->resource[PCI_ROM_RESOURCE].start) { pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start); } #ifdef CONFIG_PPC_PMAC apple_kiwi_init(dev); #endif #if defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS) for (i = 0; i < PDC202_MAX_DEVS; i++) { if (pdc202_devs[i] == NULL) break; } if (i != PDC202_MAX_DEVS) pdc202_devs[i] = dev; if (!pdcnew_proc) { pdcnew_proc = 1; ide_pci_create_host_proc("pdcnew", pdcnew_get_info); } #endif /* DISPLAY_PDC202XX_TIMINGS && CONFIG_PROC_FS */ return dev->irq; }
static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const char *name) { unsigned long dma_base = pci_resource_start(dev, 4); unsigned long sec_dma_base = dma_base + 0x08; long pll_input, pll_output, ratio; int f, r; u8 pll_ctl0, pll_ctl1; if (dev->resource[PCI_ROM_RESOURCE].start) { pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, (unsigned long)dev->resource[PCI_ROM_RESOURCE].start); } #ifdef CONFIG_PPC_PMAC apple_kiwi_init(dev); #endif /* Calculate the required PLL output frequency */ switch(max_dma_rate(dev)) { case 4: /* it's 133 MHz for Ultra133 chips */ pll_output = 133333333; break; case 3: /* and 100 MHz for Ultra100 chips */ default: pll_output = 100000000; break; } /* * Detect PLL input clock. * On some systems, where PCI bus is running at non-standard clock rate * (e.g. 25 or 40 MHz), we have to adjust the cycle time. * PDC20268 and newer chips employ PLL circuit to help correct timing * registers setting. */ pll_input = detect_pll_input_clock(dma_base); printk("%s: PLL input clock is %ld kHz\n", name, pll_input / 1000); /* Sanity check */ if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) { printk(KERN_ERR "%s: Bad PLL input clock %ld Hz, giving up!\n", name, pll_input); goto out; } #ifdef DEBUG DBG("pll_output is %ld Hz\n", pll_output); /* Show the current clock value of PLL control register * (maybe already configured by the BIOS) */ outb(0x02, sec_dma_base + 0x01); pll_ctl0 = inb(sec_dma_base + 0x03); outb(0x03, sec_dma_base + 0x01); pll_ctl1 = inb(sec_dma_base + 0x03); DBG("pll_ctl[%02X][%02X]\n", pll_ctl0, pll_ctl1); #endif /* * Calculate the ratio of F, R and NO * POUT = (F + 2) / (( R + 2) * NO) */ ratio = pll_output / (pll_input / 1000); if (ratio < 8600L) { /* 8.6x */ /* Using NO = 0x01, R = 0x0d */ r = 0x0d; } else if (ratio < 12900L) { /* 12.9x */ /* Using NO = 0x01, R = 0x08 */ r = 0x08; } else if (ratio < 16100L) { /* 16.1x */ /* Using NO = 0x01, R = 0x06 */ r = 0x06; } else if (ratio < 64000L) { /* 64x */ r = 0x00; } else { /* Invalid ratio */ printk(KERN_ERR "%s: Bad ratio %ld, giving up!\n", name, ratio); goto out; } f = (ratio * (r + 2)) / 1000 - 2; DBG("F[%d] R[%d] ratio*1000[%ld]\n", f, r, ratio); if (unlikely(f < 0 || f > 127)) { /* Invalid F */ printk(KERN_ERR "%s: F[%d] invalid!\n", name, f); goto out; } pll_ctl0 = (u8) f; pll_ctl1 = (u8) r; DBG("Writing pll_ctl[%02X][%02X]\n", pll_ctl0, pll_ctl1); outb(0x02, sec_dma_base + 0x01); outb(pll_ctl0, sec_dma_base + 0x03); outb(0x03, sec_dma_base + 0x01); outb(pll_ctl1, sec_dma_base + 0x03); /* Wait the PLL circuit to be stable */ mdelay(30); #ifdef DEBUG /* * Show the current clock value of PLL control register */ outb(0x02, sec_dma_base + 0x01); pll_ctl0 = inb(sec_dma_base + 0x03); outb(0x03, sec_dma_base + 0x01); pll_ctl1 = inb(sec_dma_base + 0x03); DBG("pll_ctl[%02X][%02X]\n", pll_ctl0, pll_ctl1); #endif out: return dev->irq; }