Exemple #1
0
static int __devinit elektor_probe(struct device *dev, unsigned int id)
{
	init_waitqueue_head(&pcf_wait);
	if (pcf_isa_init())
		return -ENODEV;
	pcf_isa_ops.dev.parent = dev;
	if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
		goto fail;

	dev_info(dev, "found device at %#x\n", base);

	return 0;

 fail:
	if (irq > 0) {
		disable_irq(irq);
		free_irq(irq, NULL);
	}

	if (!mmapped) {
		ioport_unmap(base_iomem);
		release_region(base, 2);
	} else {
		iounmap(base_iomem);
		release_mem_region(base, 2);
	}
	return -ENODEV;
}
Exemple #2
0
static int __init i2c_pcfepp_init(void) 
{
  struct i2c_pcf_epp *pepp = &gpe;

  printk(KERN_DEBUG "i2c-pcf-epp.o: i2c pcf8584-epp adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
  if (base == 0)
    pepp->pe_base = DEFAULT_BASE;
  else
    pepp->pe_base = base;

  if (irq == 0)
    pepp->pe_irq = DEFAULT_IRQ;
  else if (irq<0) {
    // switch off irq
    pepp->pe_irq=0;
  } else {
    pepp->pe_irq = irq;
  }
  if (clock == 0)
    pepp->pe_clock = DEFAULT_CLOCK;
  else
    pepp->pe_clock = clock;

  if (own == 0)
    pepp->pe_own = DEFAULT_OWN;
  else
    pepp->pe_own = own;

  pcf_epp_data.data = (void *)pepp;
  init_waitqueue_head(&pcf_wait);
  if (pcf_epp_init(pepp) == 0) {
    int ret;
    if ( (ret = i2c_pcf_add_bus(&pcf_epp_ops)) < 0) {
      printk(KERN_WARNING "i2c_pcf_add_bus caused an error: %d\n",ret);
      release_region(pepp->pe_base , 5);
      return ret;
    }
  } else {
    
    return -ENODEV;
  }
  printk(KERN_DEBUG "i2c-pcf-epp.o: found device at %#x.\n", pepp->pe_base);
  return 0;
}
Exemple #3
0
static int __init i2c_pcfisa_init(void)
{
#ifdef __alpha__
    /* check to see we have memory mapped PCF8584 connected to the
    Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
    if ((base == 0) && pci_present()) {

        struct pci_dev *cy693_dev =
            pci_find_device(PCI_VENDOR_ID_CONTAQ,
                            PCI_DEVICE_ID_CONTAQ_82C693, NULL);

        if (cy693_dev) {
            char config;
            /* yeap, we've found cypress, let's check config */
            if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {

                DEB3(printk("i2c-elektor.o: found cy82c693, config register 0x47 = 0x%02x.\n", config));

                /* UP2000 board has this register set to 0xe1,
                                   but the most significant bit as seems can be
                   reset during the proper initialisation
                                   sequence if guys from API decides to do that
                                   (so, we can even enable Tsunami Pchip
                                   window for the upper 1 Gb) */

                /* so just check for ROMCS at 0xe0000,
                                   ROMCS enabled for writes
                   and external XD Bus buffer in use. */
                if ((config & 0x7f) == 0x61) {
                    /* seems to be UP2000 like board */
                    base = 0xe0000;
                    /* I don't know why we need to
                       write twice */
                    mmapped = 2;
                    /* UP2000 drives ISA with
                    8.25 MHz (PCI/4) clock
                    			   (this can be read from cypress) */
                    clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
                    printk("i2c-elektor.o: found API UP2000 like board, will probe PCF8584 later.\n");
                }
            }
        }
    }
#endif

    /* sanity checks for mmapped I/O */
    if (mmapped && base < 0xc8000) {
        printk("i2c-elektor.o: incorrect base address (0x%0X) specified for mmapped I/O.\n", base);
        return -ENODEV;
    }

    printk("i2c-elektor.o: i2c pcf8584-isa adapter module\n");

    if (base == 0) {
        base = DEFAULT_BASE;
    }

#if (LINUX_VERSION_CODE >= 0x020301)
    init_waitqueue_head(&pcf_wait);
#endif
    if (pcf_isa_init() == 0) {
        if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
            return -ENODEV;
    } else {
        return -ENODEV;
    }

    printk("i2c-elektor.o: found device at %#x.\n", base);

    return 0;
}