예제 #1
0
파일: nmi_debug.c 프로젝트: 274914765/C
static int __init nmi_debug_setup(char *str)
{
    char *p, *sep;

    register_die_notifier(&nmi_debug_nb);
    if (nmi_enable()) {
        printk(KERN_WARNING "Unable to enable NMI.\n");
        return 0;
    }

    if (*str != '=')
        return 0;

    for (p = str + 1; *p; p = sep + 1) {
        sep = strchr(p, ',');
        if (sep)
            *sep = 0;
        if (strcmp(p, "state") == 0)
            nmi_actions |= NMI_SHOW_STATE;
        else if (strcmp(p, "regs") == 0)
            nmi_actions |= NMI_SHOW_REGS;
        else if (strcmp(p, "debounce") == 0)
            nmi_actions |= NMI_DEBOUNCE;
        else if (strcmp(p, "die") == 0)
            nmi_actions |= NMI_DIE;
        else
            printk(KERN_WARNING "NMI: Unrecognized action `%s'\n",
                p);
        if (!sep)
            break;
    }

    return 0;
}
예제 #2
0
static int __init eic_probe(struct platform_device *pdev)
{
	struct eic *eic;
	struct resource *regs;
	unsigned int i;
	unsigned int nr_of_irqs;
	unsigned int int_irq;
	int ret;
	u32 pattern;

	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	int_irq = platform_get_irq(pdev, 0);
	if (!regs || (int)int_irq <= 0) {
		dev_dbg(&pdev->dev, "missing regs and/or irq resource\n");
		return -ENXIO;
	}

	ret = -ENOMEM;
	eic = kzalloc(sizeof(struct eic), GFP_KERNEL);
	if (!eic) {
		dev_dbg(&pdev->dev, "no memory for eic structure\n");
		goto err_kzalloc;
	}

	eic->first_irq = EIM_IRQ_BASE + 32 * pdev->id;
	eic->regs = ioremap(regs->start, resource_size(regs));
	if (!eic->regs) {
		dev_dbg(&pdev->dev, "failed to map regs\n");
		goto err_ioremap;
	}

	/*
                                                       
                            
  */
	eic_writel(eic, IDR, ~0UL);
	eic_writel(eic, MODE, ~0UL);
	pattern = eic_readl(eic, MODE);
	nr_of_irqs = fls(pattern);

	/*                                                  */
	eic_writel(eic, EDGE, 0UL);
	eic_writel(eic, LEVEL, 0UL);

	eic->chip = &eic_chip;

	for (i = 0; i < nr_of_irqs; i++) {
		irq_set_chip_and_handler(eic->first_irq + i, &eic_chip,
					 handle_level_irq);
		irq_set_chip_data(eic->first_irq + i, eic);
	}

	irq_set_chained_handler(int_irq, demux_eic_irq);
	irq_set_handler_data(int_irq, eic);

	if (pdev->id == 0) {
		nmi_eic = eic;
		if (nmi_enabled)
			/*
                                                
                       
    */
			nmi_enable();
	}

	dev_info(&pdev->dev,
		 "External Interrupt Controller at 0x%p, IRQ %u\n",
		 eic->regs, int_irq);
	dev_info(&pdev->dev,
		 "Handling %u external IRQs, starting with IRQ %u\n",
		 nr_of_irqs, eic->first_irq);

	return 0;

err_ioremap:
	kfree(eic);
err_kzalloc:
	return ret;
}