1 /*********************************************************************
3 * Filename: irda_device.h
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Tue Apr 14 12:41:42 1998
9 * Modified at: Tue Aug 24 13:58:23 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
14 * Copyright (c) 1998 Haris Zukanovic, <haris@stud.cs.uit.no>
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 ********************************************************************/
36 #include <linux/tty.h>
37 #include <linux/netdevice.h>
38 #include <linux/spinlock.h>
40 #include <net/irda/irda.h>
41 #include <net/irda/qos.h>
42 #include <net/irda/dongle.h>
43 #include <net/irda/irqueue.h>
44 #include <net/irda/irlap_frame.h>
46 /* Some non-standard interface flags (should not conflict with any in if.h) */
47 #define IFF_SIR 0x0001 /* Supports SIR speeds */
48 #define IFF_MIR 0x0002 /* Supports MIR speeds */
49 #define IFF_FIR 0x0004 /* Supports FIR speeds */
50 #define IFF_VFIR 0x0008 /* Supports VFIR speeds */
51 #define IFF_PIO 0x0010 /* Supports PIO transfer of data */
52 #define IFF_DMA 0x0020 /* Supports DMA transfer of data */
53 #define IFF_SHM 0x0040 /* Supports shared memory data transfers */
54 #define IFF_DONGLE 0x0080 /* Interface has a dongle attached */
55 #define IFF_AIR 0x0100 /* Supports A(dvanced)IR standards */
62 struct dongle
*dongle
;
65 /* Chip specific info */
67 int iobase
, iobase2
; /* IO base */
68 int io_ext
, io_ext2
; /* Length of iobase */
69 int membase
; /* Shared memory base */
70 int irq
, irq2
; /* Interrupts used */
71 int fifo_size
; /* FIFO size */
73 int dma
, dma2
; /* DMA channel used */
74 int irqflags
; /* interrupt flags (ie, SA_SHIRQ|SA_INTERRUPT) */
75 int direction
; /* Link direction, used by some FIR drivers */
77 __u32 baudrate
; /* Currently used baudrate */
78 int dongle_id
; /* Dongle or transceiver currently used */
81 /* IO buffer specific info (inspired by struct sk_buff) */
83 int state
; /* Receiving state (transmit state not used) */
84 int in_frame
; /* True if receiving frame */
86 __u8
*head
; /* start of buffer */
87 __u8
*data
; /* start of data in buffer */
88 __u8
*tail
; /* end of data in buffer */
90 int len
; /* length of data */
91 int truesize
; /* total size of buffer */
94 int flags
; /* Allocation flags (GFP_KERNEL | GFP_DMA ) */
98 * This structure contains data that _we_ would have liked to be in the device
99 * structure, but we don't want to mess it up more than it is already. Better
100 * to keep the data in separate structures! This structure abstracts common
101 * stuff from IrDA port implementations.
104 QUEUE q
; /* Must be first */
105 magic_t magic
; /* Our magic bullet */
107 char name
[16]; /* Name of device "irda0" */
108 char description
[32]; /* Something like "irda0 <-> ttyS0" */
110 struct irlap_cb
*irlap
; /* The link layer we are connected to */
111 struct net_device netdev
; /* Yes! we are some kind of netdevice */
112 struct enet_statistics stats
;
114 __u32 flags
; /* Interface flags (see defs above) */
116 void *priv
; /* Pointer to low level implementation */
118 struct qos_info qos
; /* QoS capabilities for this device */
121 struct iobuff_t tx_buff
;
122 struct iobuff_t rx_buff
;
124 struct dongle
*dongle
; /* Dongle driver */
126 spinlock_t lock
; /* For serializing operations */
128 /* Media busy stuff */
130 struct timer_list media_busy_timer
;
134 /* Callbacks to driver specific implementations */
135 void (*change_speed
)(struct irda_device
*idev
, __u32 speed
);
136 int (*is_receiving
)(struct irda_device
*); /* receiving? */
137 void (*set_dtr_rts
)(struct irda_device
*idev
, int dtr
, int rts
);
138 void (*set_raw_mode
)(struct irda_device
*dev
, int mode
);
139 int (*raw_write
)(struct irda_device
*idev
, __u8
*buf
, int len
);
140 int (*raw_read
)(struct irda_device
*idev
, __u8
*buf
, int len
,
142 void (*wait_until_sent
)(struct irda_device
*);
143 void (*set_caddr
)(struct irda_device
*); /* Set connection addr */
146 extern hashbin_t
*irda_device
;
148 /* Function prototypes */
149 int irda_device_init(void);
150 void irda_device_cleanup(void);
152 int irda_device_open(struct irda_device
*, char *name
, void *priv
);
153 void irda_device_close(struct irda_device
*);
155 /* Interface to be uses by IrLAP */
156 inline void irda_device_set_media_busy(struct irda_device
*, int status
);
157 inline int irda_device_is_media_busy(struct irda_device
*);
158 inline int irda_device_is_receiving(struct irda_device
*);
159 inline void irda_device_change_speed(struct irda_device
*, int);
161 inline struct qos_info
*irda_device_get_qos(struct irda_device
*self
);
162 int irda_device_txqueue_empty(struct irda_device
*self
);
163 void irda_device_init_dongle(struct irda_device
*self
, int type
);
164 void irda_device_unregister_dongle(struct dongle
*dongle
);
165 int irda_device_register_dongle(struct dongle
*dongle
);
166 int irda_device_set_raw_mode(struct irda_device
* self
, int status
);
167 int irda_device_setup(struct net_device
*dev
);
169 void setup_dma(int channel
, char *buffer
, int count
, int mode
);
171 int irda_device_net_open(struct net_device
*dev
);
172 int irda_device_net_close(struct net_device
*dev
);
175 * Function irda_get_mtt (skb)
177 * Utility function for getting the minimum turnaround time out of
178 * the skb, where it has been hidden in the cb field.
180 extern inline __u16
irda_get_mtt(struct sk_buff
*skb
)
184 if (((struct irda_skb_cb
*)(skb
->cb
))->magic
!= LAP_MAGIC
)
187 mtt
= ((struct irda_skb_cb
*)(skb
->cb
))->mtt
;
189 ASSERT(mtt
<= 10000, return 10000;);
194 extern inline void irda_device_set_dtr_rts(struct irda_device
*self
, int dtr
,
197 if (self
->set_dtr_rts
)
198 self
->set_dtr_rts(self
, dtr
, rts
);
201 extern inline int irda_device_raw_write(struct irda_device
*self
, __u8
*buf
,
207 ret
= self
->raw_write(self
, buf
, len
);