Exemplo n.º 1
0
static int tc6387xb_probe(struct platform_device *pdev)
{
	struct tc6387xb_data *data;

	data = kmalloc(sizeof(struct tc6387xb_data), GFP_KERNEL);
	if(!data)
		return -ENOMEM;

	data->irq = pdev->resource[1].start;
	data->platform = pdev->dev.platform_data;
	platform_set_drvdata(pdev, data);

	tc6387xb_hwinit(pdev);
	
	soc_add_devices(pdev, tc6387xb_devices, ARRAY_SIZE(tc6387xb_devices), &pdev->resource[0], 0, data->irq);

	/* Init finished. */
	return 0;
}
Exemplo n.º 2
0
static int asic2_probe(struct platform_device *pdev)
{
	int rc;
	struct asic2_platform_data *pdata = pdev->dev.platform_data;
	struct asic2_data *asic;

	asic = kmalloc(sizeof (struct asic2_data), GFP_KERNEL);
	if (!asic)
		goto enomem3;

	memset(asic, 0, sizeof (*asic));
	pdev->dev.driver_data = asic;

	asic->irq_base = pdata->irq_base;
	if (!asic->irq_base) {
		printk ("asic2: uninitialized irq_base!\n");
		goto enomem1;
	}

	asic->mapping = ioremap((unsigned long)pdev->resource[0].start, IPAQ_ASIC2_MAP_SIZE);
	if (!asic->mapping) {
		printk ("asic2: couldn't ioremap\n");
		goto enomem1;
	}
	spin_lock_init(&asic->gpio_lock);
	spin_lock_init(&asic->clock_lock);
	asic->clock_ex1 = asic->clock_ex2 = 0;
	asic2_irq_init(asic);

	asic->irq_nr = pdev->resource[1].start;

	printk ("%s: using irq %d-%d on irq %d\n", pdev->name, asic->irq_base,
		asic->irq_base + ASIC2_NR_IRQS - 1, asic->irq_nr);

	set_irq_chained_handler(asic->irq_nr, asic2_irq_demux);
	set_irq_type(asic->irq_nr, IRQT_RISING);
	set_irq_data(asic->irq_nr, asic);

	__asic2_write_register(asic, IPAQ_ASIC2_CLOCK_Enable, ASIC2_CLOCK_EX0);	/* 32 kHz crystal on */
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_ClockPrescale, ASIC2_INTCPS_SET);
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_ClockPrescale,
			       ASIC2_INTCPS_CPS(0x0e) | ASIC2_INTCPS_SET);
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_TimerSet, 1);
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_MaskAndFlag, ASIC2_INTMASK_GLOBAL
				| ASIC2_INTMASK_UART_0 | ASIC2_INTMASK_UART_1 | ASIC2_INTMASK_TIMER);

	/* Set up GPIO */
	__asic2_write_register(asic, IPAQ_ASIC2_GPIOPIOD, GPIO2_IN_Y1_N | GPIO2_IN_X1_N);
	__asic2_write_register(asic, IPAQ_ASIC2_GPOBFSTAT, GPIO2_IN_Y1_N | GPIO2_IN_X1_N);
	__asic2_write_register(asic, IPAQ_ASIC2_GPIODIR, GPIO2_PEN_IRQ | GPIO2_SD_DETECT
				| GPIO2_EAR_IN_N | GPIO2_USB_DETECT_N | GPIO2_SD_CON_SLT);

	asic->ndevices = ARRAY_SIZE(asic2_blocks);
	asic->devices = soc_add_devices(pdev, asic2_blocks,
					ARRAY_SIZE(asic2_blocks),
					&pdev->resource[0], 0, asic->irq_base);
	if (!asic->devices)
		goto enomem;

	if (pdata && pdata->num_child_devs != 0) {
		int i;
		for (i = 0; i < pdata->num_child_devs; i++) {
			pdata->child_devs[i]->dev.parent = &pdev->dev;
			platform_device_register(pdata->child_devs[i]);
		}
	}

	return 0;

 enomem:
	rc = -ENOMEM;
 error:
	asic2_remove(pdev);
	return rc;
 enomem1:
	kfree(asic);
 enomem3:
	return -ENOMEM;
}