summaryrefslogtreecommitdiffstats
path: root/drivers/net/irda/esi.c
blob: d3a61af6402d917557f6065b6262d9653145a5d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*********************************************************************
 *                
 * Filename:      esi.c
 * Version:       1.5
 * Description:   Driver for the Extended Systems JetEye PC dongle
 * Status:        Experimental.
 * Author:        Dag Brattli <dagb@cs.uit.no>
 * Created at:    Sat Feb 21 18:54:38 1998
 * Modified at:   Fri Dec 17 09:14:04 1999
 * Modified by:   Dag Brattli <dagb@cs.uit.no>
 * 
 *     Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>,
 *     Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
 *     All Rights Reserved.
 *     
 *     This program is free software; you can redistribute it and/or 
 *     modify it under the terms of the GNU General Public License as 
 *     published by the Free Software Foundation; either version 2 of 
 *     the License, or (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License 
 *     along with this program; if not, write to the Free Software 
 *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *     MA 02111-1307 USA
 *     
 ********************************************************************/

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/tty.h>
#include <linux/init.h>

#include <net/irda/irda.h>
#include <net/irda/irda_device.h>

static void esi_open(dongle_t *self, struct qos_info *qos);
static void esi_close(dongle_t *self);
static int  esi_change_speed(struct irda_task *task);
static int  esi_reset(struct irda_task *task);

static struct dongle_reg dongle = {
	.type = IRDA_ESI_DONGLE,
	.open = esi_open,
	.close = esi_close,
	.reset = esi_reset,
	.change_speed = esi_change_speed,
	.owner = THIS_MODULE,
};

static int __init esi_init(void)
{
	return irda_device_register_dongle(&dongle);
}

static void __exit esi_cleanup(void)
{
	irda_device_unregister_dongle(&dongle);
}

static void esi_open(dongle_t *self, struct qos_info *qos)
{
	qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
	qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
}

static void esi_close(dongle_t *dongle)
{		
	/* Power off dongle */
	dongle->set_dtr_rts(dongle->dev, FALSE, FALSE);
}

/*
 * 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;
}

/*
 * 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;
}

MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
MODULE_DESCRIPTION("Extended Systems JetEye PC dongle driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("irda-dongle-1"); /* IRDA_ESI_DONGLE */

/*
 * Function init_module (void)
 *
 *    Initialize ESI module
 *
 */
module_init(esi_init);

/*
 * Function cleanup_module (void)
 *
 *    Cleanup ESI module
 *
 */
module_exit(esi_cleanup);

OpenPOWER on IntegriCloud