Exemplo n.º 1
0
/*
 * Function esi_change_speed (task)
 *
 *    Set the speed for the Extended Systems JetEye PC ESI-9680 type dongle
 *
 */
static int esi_change_speed(struct irda_task *task)
{
	dongle_t *self = (dongle_t *) task->instance;
	__u32 speed = (__u32) task->param;
	int dtr, rts;
	
	switch (speed) {
	case 19200:
		dtr = TRUE;
		rts = FALSE;
		break;
	case 115200:
		dtr = rts = TRUE;
		break;
	case 9600:
	default:
		dtr = FALSE;
		rts = TRUE;
		break;
	}

	/* Change speed of dongle */
	self->set_dtr_rts(self->dev, dtr, rts);
	self->speed = speed;

	irda_task_next_state(task, IRDA_TASK_DONE);

	return 0;
}
Exemplo n.º 2
0
/*
 * Function esi_reset (task)
 *
 *    Reset dongle;
 *
 */
static int esi_reset(struct irda_task *task)
{
	dongle_t *self = (dongle_t *) task->instance;
	
	self->set_dtr_rts(self->dev, FALSE, FALSE);
	irda_task_next_state(task, IRDA_TASK_DONE);

	return 0;
}
Exemplo n.º 3
0
/*
 * Function girbil_reset (driver)
 *
 *      This function resets the girbil dongle.
 *
 *      Algorithm:
 *    	  0. set RTS, and wait at least 5 ms 
 *        1. clear RTS 
 */
static int girbil_reset(struct irda_task *task)
{
	dongle_t *self = (dongle_t *) task->instance;
	__u8 control = GIRBIL_TXEN | GIRBIL_RXEN;
	int ret = 0;

	self->reset_task = task;

	switch (task->state) {
	case IRDA_TASK_INIT:
		/* Reset dongle */
		self->set_dtr_rts(self->dev, TRUE, FALSE);
		irda_task_next_state(task, IRDA_TASK_WAIT1);
		/* Sleep at least 5 ms */
		ret = MSECS_TO_JIFFIES(20);
		break;
	case IRDA_TASK_WAIT1:
		/* Set DTR and clear RTS to enter command mode */
		self->set_dtr_rts(self->dev, FALSE, TRUE);
		irda_task_next_state(task, IRDA_TASK_WAIT2);
		ret = MSECS_TO_JIFFIES(20);
		break;
	case IRDA_TASK_WAIT2:
		/* Write control byte */
		self->write(self->dev, &control, 1);
		irda_task_next_state(task, IRDA_TASK_WAIT3);
		ret = MSECS_TO_JIFFIES(20);
		break;
	case IRDA_TASK_WAIT3:
		/* Go back to normal mode */
		self->set_dtr_rts(self->dev, TRUE, TRUE);
		irda_task_next_state(task, IRDA_TASK_DONE);
		self->reset_task = NULL;
		break;
	default:
		ERROR(__FUNCTION__ "(), unknown state %d\n", task->state);
		irda_task_next_state(task, IRDA_TASK_DONE);
		self->reset_task = NULL;
		ret = -1;
		break;
	}
	return ret;
}
Exemplo n.º 4
0
static int mcp2120_reset(struct irda_task *task)
{
    dongle_t *self = (dongle_t *) task->instance;
    int ret = 0;

    self->reset_task = task;

    switch (task->state) {
    case IRDA_TASK_INIT:
        //printk("mcp2120_reset irda_task_init\n");
        /* Reset dongle by setting RTS*/
        self->set_dtr_rts(self->dev, TRUE, TRUE);
        irda_task_next_state(task, IRDA_TASK_WAIT1);
        ret = MSECS_TO_JIFFIES(50);
        break;
    case IRDA_TASK_WAIT1:
        //printk("mcp2120_reset irda_task_wait1\n");
        /* clear RTS and wait for at least 30 ms. */
        self->set_dtr_rts(self->dev, FALSE, FALSE);
        irda_task_next_state(task, IRDA_TASK_WAIT2);
        ret = MSECS_TO_JIFFIES(50);
        break;
    case IRDA_TASK_WAIT2:
        //printk("mcp2120_reset irda_task_wait2\n");
        /* Go back to normal mode */
        self->set_dtr_rts(self->dev, FALSE, FALSE);
        irda_task_next_state(task, IRDA_TASK_DONE);
        self->reset_task = NULL;
        break;
    default:
        ERROR("%s(), unknown state %d\n", __FUNCTION__, task->state);
        irda_task_next_state(task, IRDA_TASK_DONE);
        self->reset_task = NULL;
        ret = -1;
        break;
    }
    return ret;
}
Exemplo n.º 5
0
/*
 * Function actisys_change_speed (task)
 *
 *    Change speed of the ACTiSYS IR-220L and IR-220L+ type IrDA dongles.
 *    To cycle through the available baud rates, pulse RTS low for a few us.
 *
 *	First, we reset the dongle to always start from a known state.
 *	Then, we cycle through the speeds by pulsing RTS low and then up.
 *	The dongle allow us to pulse quite fast, se we can set speed in one go,
 * which is must faster ( < 100 us) and less complex than what is found
 * in some other dongle drivers...
 *	Note that even if the new speed is the same as the current speed,
 * we reassert the speed. This make sure that things are all right,
 * and it's fast anyway...
 *	By the way, this function will work for both type of dongles,
 * because the additional speed is at the end of the sequence...
 */
static int actisys_change_speed(struct irda_task *task)
{
	dongle_t *self = (dongle_t *) task->instance;
	__u32 speed = (__u32) task->param;	/* Target speed */
	int ret = 0;
	int i = 0;

        IRDA_DEBUG(4, __FUNCTION__ "(), speed=%d (was %d)\n", speed, 
		   self->speed);

	/* Go to a known state by reseting the dongle */

	/* Reset the dongle : set DTR low for 10 us */
	self->set_dtr_rts(self->dev, FALSE, TRUE);
	udelay(MIN_DELAY);

	/* Go back to normal mode (we are now at 9600 b/s) */
	self->set_dtr_rts(self->dev, TRUE, TRUE);
 
	/* 
	 * Now, we can set the speed requested. Send RTS pulses until we
         * reach the target speed 
	 */
	for (i=0; i<MAX_SPEEDS; i++) {
		if (speed == baud_rates[i]) {
			self->speed = baud_rates[i];
			break;
		}
		/* Make sure previous pulse is finished */
		udelay(MIN_DELAY);

		/* Set RTS low for 10 us */
		self->set_dtr_rts(self->dev, TRUE, FALSE);
		udelay(MIN_DELAY);

		/* Set RTS high for 10 us */
		self->set_dtr_rts(self->dev, TRUE, TRUE);
	}

	/* Check if life is sweet... */
	if (i >= MAX_SPEEDS)
		ret = -1;  /* This should not happen */

	/* Basta lavoro, on se casse d'ici... */
	irda_task_next_state(task, IRDA_TASK_DONE);

	return ret;
}
Exemplo n.º 6
0
/*
 * Function ep7211_ir_reset (task)
 *
 *      Reset the EP7211 I/R. We don't really have to do anything.
 *
 */
static int ep7211_ir_reset(struct irda_task *task)
{
	irda_task_next_state(task, IRDA_TASK_DONE);
	return 0;
}
Exemplo n.º 7
0
/*
 * Function ep7211_ir_change_speed (task)
 *
 *    Change speed of the EP7211 I/R port. We don't really have to do anything
 *    for the EP7211 as long as the rate is being changed at the serial port
 *    level.
 */
static int ep7211_ir_change_speed(struct irda_task *task)
{
	irda_task_next_state(task, IRDA_TASK_DONE);
	return 0;
}
Exemplo n.º 8
0
/*
 * Function mcp2120_change_speed (dev, speed)
 *
 *    Set the speed for the MCP2120.
 *
 */
static int mcp2120_change_speed(struct irda_task *task)
{
    dongle_t *self = (dongle_t *) task->instance;
    __u32 speed = (__u32) task->param;
    __u8 control[2];
    int ret = 0;

    self->speed_task = task;

    switch (task->state) {
    case IRDA_TASK_INIT:
        /* Need to reset the dongle and go to 9600 bps before
                   programming */
        //printk("Dmcp2120_change_speed irda_task_init\n");
        if (irda_task_execute(self, mcp2120_reset, NULL, task,
                              (void *) speed))
        {
            /* Dongle need more time to reset */
            irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);

            /* Give reset 1 sec to finish */
            ret = MSECS_TO_JIFFIES(1000);
        }
        break;
    case IRDA_TASK_CHILD_WAIT:
        WARNING("%s(), resetting dongle timed out!\n", __FUNCTION__);
        ret = -1;
        break;
    case IRDA_TASK_CHILD_DONE:
        /* Set DTR to enter command mode */
        self->set_dtr_rts(self->dev, TRUE, FALSE);
        udelay(500);

        switch (speed) {
        case 9600:
        default:
            control[0] = MCP2120_9600;
            //printk("mcp2120 9600\n");
            break;
        case 19200:
            control[0] = MCP2120_19200;
            //printk("mcp2120 19200\n");
            break;
        case 34800:
            control[0] = MCP2120_38400;
            //printk("mcp2120 38400\n");
            break;
        case 57600:
            control[0] = MCP2120_57600;
            //printk("mcp2120 57600\n");
            break;
        case 115200:
            control[0] = MCP2120_115200;
            //printk("mcp2120 115200\n");
            break;
        }
        control[1] = MCP2120_COMMIT;

        /* Write control bytes */
        self->write(self->dev, control, 2);

        irda_task_next_state(task, IRDA_TASK_WAIT);
        ret = MSECS_TO_JIFFIES(100);
        //printk("mcp2120_change_speed irda_child_done\n");
        break;
    case IRDA_TASK_WAIT:
        /* Go back to normal mode */
        self->set_dtr_rts(self->dev, FALSE, FALSE);
        irda_task_next_state(task, IRDA_TASK_DONE);
        self->speed_task = NULL;
        //printk("mcp2120_change_speed irda_task_wait\n");
        break;
    default:
        ERROR("%s(), unknown state %d\n", __FUNCTION__, task->state);
        irda_task_next_state(task, IRDA_TASK_DONE);
        self->speed_task = NULL;
        ret = -1;
        break;
    }
    return ret;
}
/*
 * Function ep93xx_sir_reset (task)
 *
 *      Reset the EP93xx IrDA. We don't really have to do anything.
 *
 */
static int ep93xx_sir_reset(struct irda_task *task)
{
    DPRINTK("----------------\n ep93xx_sir_reset \n-----------------\n");
    irda_task_next_state(task, IRDA_TASK_DONE);
    return 0;
}
/*
 * Function ep93xx_sir_change_speed (task)
 *
 *   Change speed of the EP93xx I/R port. We don't have to do anything
 *   here as long as the rate is being changed at the serial port
 *   level.  irtty.c should take care of that.
 */
static int ep93xx_sir_change_speed(struct irda_task *task)
{
    DPRINTK("----------------\n ep93xx_sir_change_speed \n-----------------\n");
    irda_task_next_state(task, IRDA_TASK_DONE);
    return 0;
}
Exemplo n.º 11
0
/*
 * Function girbil_change_speed (dev, speed)
 *
 *    Set the speed for the Girbil type dongle.
 *
 */
static int girbil_change_speed(struct irda_task *task)
{
	dongle_t *self = (dongle_t *) task->instance;
	__u32 speed = (__u32) task->param;
	__u8 control[2];
	int ret = 0;

	self->speed_task = task;

	switch (task->state) {
	case IRDA_TASK_INIT:
		/* Need to reset the dongle and go to 9600 bps before
                   programming */
		if (irda_task_execute(self, girbil_reset, NULL, task, 
				      (void *) speed))
		{
			/* Dongle need more time to reset */
			irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);

			/* Give reset 1 sec to finish */
			ret = MSECS_TO_JIFFIES(1000);
		}
		break;
	case IRDA_TASK_CHILD_WAIT:
		WARNING(__FUNCTION__ "(), resetting dongle timed out!\n");
		ret = -1;
		break;
	case IRDA_TASK_CHILD_DONE:
		/* Set DTR and Clear RTS to enter command mode */
		self->set_dtr_rts(self->dev, FALSE, TRUE);

		switch (speed) {
		case 9600:
		default:
			control[0] = GIRBIL_9600;
			break;
		case 19200:
			control[0] = GIRBIL_19200;
			break;
		case 34800:
			control[0] = GIRBIL_38400;
			break;
		case 57600:
			control[0] = GIRBIL_57600;
			break;
		case 115200:
			control[0] = GIRBIL_115200;
			break;
		}
		control[1] = GIRBIL_LOAD;
		
		/* Write control bytes */
		self->write(self->dev, control, 2);
		irda_task_next_state(task, IRDA_TASK_WAIT);
		ret = MSECS_TO_JIFFIES(100);
		break;
	case IRDA_TASK_WAIT:
		/* Go back to normal mode */
		self->set_dtr_rts(self->dev, TRUE, TRUE);
		irda_task_next_state(task, IRDA_TASK_DONE);
		self->speed_task = NULL;
		break;
	default:
		ERROR(__FUNCTION__ "(), unknown state %d\n", task->state);
		irda_task_next_state(task, IRDA_TASK_DONE);
		self->speed_task = NULL;
		ret = -1;
		break;
	}
	return ret;
}