static int kempld_detect_device(struct kempld_device_data *pld) { char *version_type; u8 index_reg; int ret; mutex_lock(&pld->lock); /* Check for empty IO space */ index_reg = ioread8(pld->io_index); if (index_reg == 0xff && ioread8(pld->io_data) == 0xff) { mutex_unlock(&pld->lock); return -ENODEV; } /* Release hardware mutex if acquired */ if (!(index_reg & KEMPLD_MUTEX_KEY)) { iowrite8(KEMPLD_MUTEX_KEY, pld->io_index); /* PXT and COMe-cPC2 boards may require a second release */ iowrite8(KEMPLD_MUTEX_KEY, pld->io_index); } mutex_unlock(&pld->lock); ret = kempld_get_info(pld); if (ret) return ret; switch (pld->info.type) { case 0: version_type = "release"; break; case 1: version_type = "debug"; break; case 2: version_type = "custom"; break; default: version_type = "unspecified"; } dev_info(pld->dev, "Found Kontron PLD %d\n", pld->info.number); dev_info(pld->dev, "%s version %d.%d build %d, specification %d.%d\n", version_type, pld->info.major, pld->info.minor, pld->info.buildnr, pld->info.spec_major, pld->info.spec_minor); return kempld_register_cells(pld); }
static int kempld_detect_device(struct kempld_device_data *pld) { u8 index_reg; int ret; mutex_lock(&pld->lock); /* Check for empty IO space */ index_reg = ioread8(pld->io_index); if (index_reg == 0xff && ioread8(pld->io_data) == 0xff) { mutex_unlock(&pld->lock); return -ENODEV; } /* Release hardware mutex if acquired */ if (!(index_reg & KEMPLD_MUTEX_KEY)) { iowrite8(KEMPLD_MUTEX_KEY, pld->io_index); /* PXT and COMe-cPC2 boards may require a second release */ iowrite8(KEMPLD_MUTEX_KEY, pld->io_index); } mutex_unlock(&pld->lock); ret = kempld_get_info(pld); if (ret) return ret; dev_info(pld->dev, "Found Kontron PLD - %s (%s), spec %d.%d\n", pld->info.version, kempld_get_type_string(pld), pld->info.spec_major, pld->info.spec_minor); ret = sysfs_create_group(&pld->dev->kobj, &pld_attr_group); if (ret) return ret; ret = kempld_register_cells(pld); if (ret) sysfs_remove_group(&pld->dev->kobj, &pld_attr_group); return ret; }