Exemple #1
0
static int micro_probe (struct platform_device *dev)
{
	int result=0;
	//struct platform_device *plat;

	printk(KERN_ERR "micro probe : begin \n");

	h3600_micro_reset_comm();

	result = request_irq(IRQ_Ser1UART, h3600_micro_serial_isr,
			     SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
			     "h3600_micro", h3600_micro_serial_isr);
	if ( result ) {
		printk(KERN_CRIT "%s: unable to grab serial port IRQ\n", __FUNCTION__);
		return result;
	} else {
		printk(KERN_ERR "h3600_micro : grab serial port IRQ\n");
	}

	/*--- add platform devices that should be avaiable with micro ---*/
	platform_set_drvdata(devices[h3600keys], &micro);
	platform_set_drvdata(devices[h3600batt], &micro);
	platform_set_drvdata(devices[h3600ts], &micro);

	result = platform_add_devices(devices, ARRAY_SIZE(devices));
	if ( result != 0 ) {
		printk(KERN_ERR "micro probe : platform_add_devices fail [%d].\n", result);
	}

	spin_lock_init(&micro.lock);

	printk(KERN_ERR "micro probe : end [%d]\n",result);

	return result;
}
Exemple #2
0
static int micro_resume (struct platform_device *dev)
{
	printk(KERN_ERR "micro : resume\n");
	h3600_micro_reset_comm();
	mdelay(10);

	return 0;
}
static int h3600_micro_pm_callback(pm_request_t req)
{
        if (1) printk("%s: req=%d\n", __FUNCTION__, req);
	
	switch (req) {
	case PM_RESUME:
		h3600_micro_reset_comm();
		break;
	}
	return 0;
}
static int h3600_micro_setup( void )
{
	int result, i;

        printk("%s: setting up microcontroller interface\n", __FUNCTION__);

	if ( machine_is_h3100() ) {
		g_micro_ops = &h3100_micro_ops;
	} 
	else if ( machine_is_h3600() ) {
		g_micro_ops = &h3600_micro_ops;
	}
	else {
		printk("%s: illegal iPAQ model %s\n", __FUNCTION__, h3600_generic_name() );
		return -ENODEV;
	}

	/* Set up our structures */
	for(i = 0; i < NUM_HANDLERS; i++)
	{
		init_waitqueue_head((wait_queue_head_t *) &g_handlers[i].waitq );
	}
	init_MUTEX((struct semaphore *) &g_txdev.lock );

	/* Start working */
	h3600_micro_reset_comm();

	/* Set up interrupts */
	result = request_irq(IRQ_Ser1UART, h3600_micro_serial_isr, SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
                             "h3600_ts", h3600_micro_serial_isr);
	if ( result ) {
		printk(KERN_CRIT "%s: unable to grab serial port IRQ\n", __FUNCTION__);
		return result;
	}

	result = request_irq(IRQ_GPIO_H3600_ACTION_BUTTON, 
			     h3600_micro_action_isr, 
			     SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
			     "h3600_action", h3600_micro_action_isr);
        set_irq_type( IRQ_GPIO_H3600_ACTION_BUTTON, IRQT_BOTHEDGE );

	if ( result ) {
		printk(KERN_CRIT "%s: unable to grab action button IRQ\n", __FUNCTION__);
		goto failed0;
	}

	result = request_irq(IRQ_GPIO_H3600_NPOWER_BUTTON, 
			     h3600_micro_power_isr, 
			     SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
			     "h3600_suspend", h3600_micro_power_isr);
        set_irq_type( IRQ_GPIO_H3600_NPOWER_BUTTON, IRQT_BOTHEDGE );

	if ( result ) {
		printk(KERN_CRIT "%s: unable to grab power button IRQ\n", __FUNCTION__);
		goto failed1;
	}

	result = request_irq(IRQ_GPIO_H3600_OPT_DET, h3600_micro_sleeve_isr, 
			     SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
                             "h3600_sleeve", h3600_micro_sleeve_isr);
        set_irq_type( IRQ_GPIO_H3600_OPT_DET, IRQT_BOTHEDGE );
	
	if ( result ){
		printk(KERN_CRIT "%s: unable to grab option pack detect IRQ\n", __FUNCTION__);
		goto failed2;
	}

	/* Register in /proc filesystem */
	micro_proc_dir = proc_mkdir(H3600_MICRO_PROC_DIR, NULL);
	if ( micro_proc_dir )
		create_proc_read_entry(H3600_MICRO_PROC_STATS, 0, micro_proc_dir, 
				       h3600_micro_proc_stats_read, NULL );
	else
		printk(KERN_ALERT "%s: unable to create proc entry %s\n", __FUNCTION__, H3600_MICRO_PROC_DIR);

	/* Register with power management */
	h3600_register_pm_callback( h3600_micro_pm_callback );

	/* Set some GPIO direction registers */
	GPDR |= (GPIO_H3600_CLK_SET0 | GPIO_H3600_CLK_SET1);

	return 0;
 failed2:
		free_irq( IRQ_GPIO_H3600_NPOWER_BUTTON, h3600_micro_power_isr);
 failed1:
		free_irq( IRQ_GPIO_H3600_ACTION_BUTTON, h3600_micro_action_isr );
 failed0:
		free_irq( IRQ_Ser1UART, h3600_micro_serial_isr );
		return result;
}