blob: 103a2d18ed2f9c3db0132b97a0e26630f72d47da [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
2 * $Id: smsc-ircc2.c,v 1.19.2.5 2002/10/27 11:34:26 dip Exp $
3 *
4 * Description: Driver for the SMC Infrared Communications Controller
5 * Status: Experimental.
6 * Author: Daniele Peri (peri@csai.unipa.it)
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07007 * Created at:
8 * Modified at:
9 * Modified by:
10 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * Copyright (c) 2002 Daniele Peri
12 * All Rights Reserved.
13 * Copyright (c) 2002 Jean Tourrilhes
Linus Walleijc1e14a62006-04-05 22:33:59 -070014 * Copyright (c) 2006 Linus Walleij
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 *
16 *
17 * Based on smc-ircc.c:
18 *
19 * Copyright (c) 2001 Stefani Seibold
20 * Copyright (c) 1999-2001 Dag Brattli
Dmitry Torokhov527b6af2005-09-06 15:19:17 -070021 * Copyright (c) 1998-1999 Thomas Davis,
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 *
23 * and irport.c:
24 *
25 * Copyright (c) 1997, 1998, 1999-2000 Dag Brattli, All Rights Reserved.
26 *
Dmitry Torokhov527b6af2005-09-06 15:19:17 -070027 *
28 * This program is free software; you can redistribute it and/or
29 * modify it under the terms of the GNU General Public License as
30 * published by the Free Software Foundation; either version 2 of
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 * the License, or (at your option) any later version.
Dmitry Torokhov527b6af2005-09-06 15:19:17 -070032 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * This program is distributed in the hope that it will be useful,
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 * GNU General Public License for more details.
Dmitry Torokhov527b6af2005-09-06 15:19:17 -070037 *
38 * You should have received a copy of the GNU General Public License
39 * along with this program; if not, write to the Free Software
40 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 * MA 02111-1307 USA
42 *
43 ********************************************************************/
44
45#include <linux/module.h>
46#include <linux/kernel.h>
47#include <linux/types.h>
48#include <linux/skbuff.h>
49#include <linux/netdevice.h>
50#include <linux/ioport.h>
51#include <linux/delay.h>
52#include <linux/slab.h>
53#include <linux/init.h>
54#include <linux/rtnetlink.h>
55#include <linux/serial_reg.h>
56#include <linux/dma-mapping.h>
David Brownelld94c77b2006-05-09 15:26:11 -070057#include <linux/pnp.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010058#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#include <asm/io.h>
61#include <asm/dma.h>
62#include <asm/byteorder.h>
63
64#include <linux/spinlock.h>
65#include <linux/pm.h>
Linus Walleijc1e14a62006-04-05 22:33:59 -070066#ifdef CONFIG_PCI
67#include <linux/pci.h>
68#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <net/irda/wrapper.h>
71#include <net/irda/irda.h>
72#include <net/irda/irda_device.h>
73
74#include "smsc-ircc2.h"
75#include "smsc-sio.h"
76
Dmitry Torokhov98b77772005-09-06 15:19:19 -070077
78MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>");
79MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
80MODULE_LICENSE("GPL");
81
Dmitry Torokhov98b77772005-09-06 15:19:19 -070082static int ircc_dma = 255;
83module_param(ircc_dma, int, 0);
84MODULE_PARM_DESC(ircc_dma, "DMA channel");
85
86static int ircc_irq = 255;
87module_param(ircc_irq, int, 0);
88MODULE_PARM_DESC(ircc_irq, "IRQ line");
89
90static int ircc_fir;
91module_param(ircc_fir, int, 0);
92MODULE_PARM_DESC(ircc_fir, "FIR Base Address");
93
94static int ircc_sir;
95module_param(ircc_sir, int, 0);
96MODULE_PARM_DESC(ircc_sir, "SIR Base Address");
97
98static int ircc_cfg;
99module_param(ircc_cfg, int, 0);
100MODULE_PARM_DESC(ircc_cfg, "Configuration register base address");
101
102static int ircc_transceiver;
103module_param(ircc_transceiver, int, 0);
104MODULE_PARM_DESC(ircc_transceiver, "Transceiver type");
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/* Types */
107
Linus Walleijc1e14a62006-04-05 22:33:59 -0700108#ifdef CONFIG_PCI
109struct smsc_ircc_subsystem_configuration {
110 unsigned short vendor; /* PCI vendor ID */
111 unsigned short device; /* PCI vendor ID */
112 unsigned short subvendor; /* PCI subsystem vendor ID */
113 unsigned short subdevice; /* PCI sybsystem device ID */
114 unsigned short sir_io; /* I/O port for SIR */
115 unsigned short fir_io; /* I/O port for FIR */
116 unsigned char fir_irq; /* FIR IRQ */
117 unsigned char fir_dma; /* FIR DMA */
118 unsigned short cfg_base; /* I/O port for chip configuration */
119 int (*preconfigure)(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); /* Preconfig function */
120 const char *name; /* name shown as info */
121};
122#endif
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124struct smsc_transceiver {
125 char *name;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700126 void (*set_for_speed)(int fir_base, u32 speed);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 int (*probe)(int fir_base);
128};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
130struct smsc_chip {
131 char *name;
132 #if 0
133 u8 type;
134 #endif
135 u16 flags;
136 u8 devid;
137 u8 rev;
138};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140struct smsc_chip_address {
141 unsigned int cfg_base;
142 unsigned int type;
143};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145/* Private data for each instance */
146struct smsc_ircc_cb {
147 struct net_device *netdev; /* Yes! we are some kind of netdevice */
148 struct net_device_stats stats;
149 struct irlap_cb *irlap; /* The link layer we are binded to */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 chipio_t io; /* IrDA controller information */
152 iobuff_t tx_buff; /* Transmit buffer */
153 iobuff_t rx_buff; /* Receive buffer */
154 dma_addr_t tx_buff_dma;
155 dma_addr_t rx_buff_dma;
156
157 struct qos_info qos; /* QoS capabilities for this device */
158
159 spinlock_t lock; /* For serializing operations */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 __u32 new_speed;
162 __u32 flags; /* Interface flags */
163
164 int tx_buff_offsets[10]; /* Offsets between frames in tx_buff */
165 int tx_len; /* Number of frames in tx_buff */
166
167 int transceiver;
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700168 struct platform_device *pldev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169};
170
171/* Constants */
172
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700173#define SMSC_IRCC2_DRIVER_NAME "smsc-ircc2"
174
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175#define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
176#define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700177#define SMSC_IRCC2_C_NET_TIMEOUT 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178#define SMSC_IRCC2_C_SIR_STOP 0
179
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700180static const char *driver_name = SMSC_IRCC2_DRIVER_NAME;
181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182/* Prototypes */
183
184static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq);
185static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base);
186static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
187static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self);
188static void smsc_ircc_init_chip(struct smsc_ircc_cb *self);
189static int __exit smsc_ircc_close(struct smsc_ircc_cb *self);
Dmitry Torokhov80a90582005-09-06 15:19:21 -0700190static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self);
191static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self);
193static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev);
194static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev);
Dmitry Torokhov80a90582005-09-06 15:19:21 -0700195static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs);
196static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self);
Dmitry Torokhov0fa2f492005-09-06 15:19:24 -0700197static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed);
198static void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, u32 speed);
David Howells7d12e782006-10-05 14:55:46 +0100199static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev);
201static void smsc_ircc_sir_start(struct smsc_ircc_cb *self);
202#if SMSC_IRCC2_C_SIR_STOP
203static void smsc_ircc_sir_stop(struct smsc_ircc_cb *self);
204#endif
205static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self);
206static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
207static int smsc_ircc_net_open(struct net_device *dev);
208static int smsc_ircc_net_close(struct net_device *dev);
209static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
210#if SMSC_IRCC2_C_NET_TIMEOUT
211static void smsc_ircc_timeout(struct net_device *dev);
212#endif
213static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self);
215static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self);
216static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed);
217static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);
218
219/* Probing */
220static int __init smsc_ircc_look_for_chips(void);
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700221static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);
222static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
223static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224static int __init smsc_superio_fdc(unsigned short cfg_base);
225static int __init smsc_superio_lpc(unsigned short cfg_base);
Linus Walleijc1e14a62006-04-05 22:33:59 -0700226#ifdef CONFIG_PCI
227static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf);
228static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
Linus Walleij08d09992006-04-14 16:03:33 -0700229static void __init preconfigure_ali_port(struct pci_dev *dev,
230 unsigned short port);
Linus Walleijc1e14a62006-04-05 22:33:59 -0700231static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
232static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
233 unsigned short ircc_fir,
234 unsigned short ircc_sir,
235 unsigned char ircc_dma,
236 unsigned char ircc_irq);
237#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
239/* Transceivers specific functions */
240
241static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed);
242static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base);
243static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed);
244static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base);
245static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed);
246static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
247
248/* Power Management */
249
Russell King3ae5eae2005-11-09 22:32:44 +0000250static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state);
251static int smsc_ircc_resume(struct platform_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Russell King3ae5eae2005-11-09 22:32:44 +0000253static struct platform_driver smsc_ircc_driver = {
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700254 .suspend = smsc_ircc_suspend,
255 .resume = smsc_ircc_resume,
Russell King3ae5eae2005-11-09 22:32:44 +0000256 .driver = {
257 .name = SMSC_IRCC2_DRIVER_NAME,
258 },
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700259};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261/* Transceivers for SMSC-ircc */
262
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700263static struct smsc_transceiver smsc_transceivers[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264{
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700265 { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800 },
266 { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select },
267 { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc },
268 { NULL, NULL }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269};
Dmitry Torokhova956f4c2005-09-06 15:19:20 -0700270#define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272/* SMC SuperIO chipsets definitions */
273
274#define KEY55_1 0 /* SuperIO Configuration mode with Key <0x55> */
275#define KEY55_2 1 /* SuperIO Configuration mode with Key <0x55,0x55> */
276#define NoIRDA 2 /* SuperIO Chip has no IRDA Port */
277#define SIR 0 /* SuperIO Chip has only slow IRDA */
278#define FIR 4 /* SuperIO Chip has fast IRDA */
279#define SERx4 8 /* SuperIO Chip supports 115,2 KBaud * 4=460,8 KBaud */
280
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700281static struct smsc_chip __initdata fdc_chips_flat[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282{
283 /* Base address 0x3f0 or 0x370 */
284 { "37C44", KEY55_1|NoIRDA, 0x00, 0x00 }, /* This chip cannot be detected */
285 { "37C665GT", KEY55_2|NoIRDA, 0x65, 0x01 },
286 { "37C665GT", KEY55_2|NoIRDA, 0x66, 0x01 },
287 { "37C669", KEY55_2|SIR|SERx4, 0x03, 0x02 },
288 { "37C669", KEY55_2|SIR|SERx4, 0x04, 0x02 }, /* ID? */
289 { "37C78", KEY55_2|NoIRDA, 0x78, 0x00 },
290 { "37N769", KEY55_1|FIR|SERx4, 0x28, 0x00 },
291 { "37N869", KEY55_1|FIR|SERx4, 0x29, 0x00 },
292 { NULL }
293};
294
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700295static struct smsc_chip __initdata fdc_chips_paged[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
297 /* Base address 0x3f0 or 0x370 */
298 { "37B72X", KEY55_1|SIR|SERx4, 0x4c, 0x00 },
299 { "37B77X", KEY55_1|SIR|SERx4, 0x43, 0x00 },
300 { "37B78X", KEY55_1|SIR|SERx4, 0x44, 0x00 },
301 { "37B80X", KEY55_1|SIR|SERx4, 0x42, 0x00 },
302 { "37C67X", KEY55_1|FIR|SERx4, 0x40, 0x00 },
303 { "37C93X", KEY55_2|SIR|SERx4, 0x02, 0x01 },
304 { "37C93XAPM", KEY55_1|SIR|SERx4, 0x30, 0x01 },
305 { "37C93XFR", KEY55_2|FIR|SERx4, 0x03, 0x01 },
306 { "37M707", KEY55_1|SIR|SERx4, 0x42, 0x00 },
307 { "37M81X", KEY55_1|SIR|SERx4, 0x4d, 0x00 },
308 { "37N958FR", KEY55_1|FIR|SERx4, 0x09, 0x04 },
309 { "37N971", KEY55_1|FIR|SERx4, 0x0a, 0x00 },
310 { "37N972", KEY55_1|FIR|SERx4, 0x0b, 0x00 },
311 { NULL }
312};
313
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700314static struct smsc_chip __initdata lpc_chips_flat[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315{
316 /* Base address 0x2E or 0x4E */
317 { "47N227", KEY55_1|FIR|SERx4, 0x5a, 0x00 },
318 { "47N267", KEY55_1|FIR|SERx4, 0x5e, 0x00 },
319 { NULL }
320};
321
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700322static struct smsc_chip __initdata lpc_chips_paged[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
324 /* Base address 0x2E or 0x4E */
325 { "47B27X", KEY55_1|SIR|SERx4, 0x51, 0x00 },
326 { "47B37X", KEY55_1|SIR|SERx4, 0x52, 0x00 },
327 { "47M10X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
328 { "47M120", KEY55_1|NoIRDA|SERx4, 0x5c, 0x00 },
329 { "47M13X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
330 { "47M14X", KEY55_1|SIR|SERx4, 0x5f, 0x00 },
331 { "47N252", KEY55_1|FIR|SERx4, 0x0e, 0x00 },
332 { "47S42X", KEY55_1|SIR|SERx4, 0x57, 0x00 },
333 { NULL }
334};
335
336#define SMSCSIO_TYPE_FDC 1
337#define SMSCSIO_TYPE_LPC 2
338#define SMSCSIO_TYPE_FLAT 4
339#define SMSCSIO_TYPE_PAGED 8
340
Dmitry Torokhovb6158d22005-09-06 15:19:20 -0700341static struct smsc_chip_address __initdata possible_addresses[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342{
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700343 { 0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
344 { 0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
345 { 0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
346 { 0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
347 { 0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
348 { 0, 0 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349};
350
351/* Globals */
352
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700353static struct smsc_ircc_cb *dev_self[] = { NULL, NULL };
354static unsigned short dev_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356static inline void register_bank(int iobase, int bank)
357{
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700358 outb(((inb(iobase + IRCC_MASTER) & 0xf0) | (bank & 0x07)),
359 iobase + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360}
361
David Brownelld94c77b2006-05-09 15:26:11 -0700362#ifdef CONFIG_PNP
363/* PNP hotplug support */
364static const struct pnp_device_id smsc_ircc_pnp_table[] = {
365 { .id = "SMCf010", .driver_data = 0 },
366 /* and presumably others */
367 { }
368};
369MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table);
370#endif
371
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
373/*******************************************************************************
374 *
375 *
376 * SMSC-ircc stuff
377 *
378 *
379 *******************************************************************************/
380
381/*
382 * Function smsc_ircc_init ()
383 *
384 * Initialize chip. Just try to find out how many chips we are dealing with
385 * and where they are
386 */
387static int __init smsc_ircc_init(void)
388{
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700389 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
391 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
392
Russell King3ae5eae2005-11-09 22:32:44 +0000393 ret = platform_driver_register(&smsc_ircc_driver);
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700394 if (ret) {
395 IRDA_ERROR("%s, Can't register driver!\n", driver_name);
396 return ret;
397 }
398
Linus Walleijc1e14a62006-04-05 22:33:59 -0700399#ifdef CONFIG_PCI
400 if (smsc_ircc_preconfigure_subsystems(ircc_cfg, ircc_fir, ircc_sir, ircc_dma, ircc_irq) < 0) {
401 /* Ignore errors from preconfiguration */
402 IRDA_ERROR("%s, Preconfiguration failed !\n", driver_name);
403 }
404#endif
405
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700406 dev_count = 0;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700407
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700408 if (ircc_fir > 0 && ircc_sir > 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
410 IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
411
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700412 if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
413 ret = -ENODEV;
414 } else {
Brice Goglin505db032005-09-06 15:19:25 -0700415 ret = -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700417 /* try user provided configuration register base address */
418 if (ircc_cfg > 0) {
419 IRDA_MESSAGE(" Overriding configuration address "
420 "0x%04x\n", ircc_cfg);
421 if (!smsc_superio_fdc(ircc_cfg))
422 ret = 0;
423 if (!smsc_superio_lpc(ircc_cfg))
424 ret = 0;
425 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700427 if (smsc_ircc_look_for_chips() > 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 ret = 0;
429 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700430
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700431 if (ret)
Russell King3ae5eae2005-11-09 22:32:44 +0000432 platform_driver_unregister(&smsc_ircc_driver);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700433
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 return ret;
435}
436
437/*
438 * Function smsc_ircc_open (firbase, sirbase, dma, irq)
439 *
440 * Try to open driver instance
441 *
442 */
443static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
444{
445 struct smsc_ircc_cb *self;
446 struct net_device *dev;
447 int err;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700448
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
450
451 err = smsc_ircc_present(fir_base, sir_base);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700452 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 goto err_out;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 err = -ENOMEM;
Dmitry Torokhova956f4c2005-09-06 15:19:20 -0700456 if (dev_count >= ARRAY_SIZE(dev_self)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__);
458 goto err_out1;
459 }
460
461 /*
462 * Allocate new instance of the driver
463 */
464 dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
465 if (!dev) {
466 IRDA_WARNING("%s() can't allocate net device\n", __FUNCTION__);
467 goto err_out1;
468 }
469
470 SET_MODULE_OWNER(dev);
471
472 dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
473#if SMSC_IRCC2_C_NET_TIMEOUT
474 dev->tx_timeout = smsc_ircc_timeout;
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700475 dev->watchdog_timeo = HZ * 2; /* Allow enough time for speed change */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476#endif
477 dev->open = smsc_ircc_net_open;
478 dev->stop = smsc_ircc_net_close;
479 dev->do_ioctl = smsc_ircc_net_ioctl;
480 dev->get_stats = smsc_ircc_net_get_stats;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700481
Dmitry Torokhovda0841a2005-09-06 15:19:23 -0700482 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 self->netdev = dev;
484
485 /* Make ifconfig display some details */
486 dev->base_addr = self->io.fir_base = fir_base;
487 dev->irq = self->io.irq = irq;
488
489 /* Need to store self somewhere */
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700490 dev_self[dev_count] = self;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 spin_lock_init(&self->lock);
492
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700493 self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
495
496 self->rx_buff.head =
497 dma_alloc_coherent(NULL, self->rx_buff.truesize,
498 &self->rx_buff_dma, GFP_KERNEL);
499 if (self->rx_buff.head == NULL) {
500 IRDA_ERROR("%s, Can't allocate memory for receive buffer!\n",
501 driver_name);
502 goto err_out2;
503 }
504
505 self->tx_buff.head =
506 dma_alloc_coherent(NULL, self->tx_buff.truesize,
507 &self->tx_buff_dma, GFP_KERNEL);
508 if (self->tx_buff.head == NULL) {
509 IRDA_ERROR("%s, Can't allocate memory for transmit buffer!\n",
510 driver_name);
511 goto err_out3;
512 }
513
514 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
515 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
516
517 self->rx_buff.in_frame = FALSE;
518 self->rx_buff.state = OUTSIDE_FRAME;
519 self->tx_buff.data = self->tx_buff.head;
520 self->rx_buff.data = self->rx_buff.head;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 smsc_ircc_setup_qos(self);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 smsc_ircc_init_chip(self);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700525
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700526 if (ircc_transceiver > 0 &&
527 ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 self->transceiver = ircc_transceiver;
529 else
530 smsc_ircc_probe_transceiver(self);
531
532 err = register_netdev(self->netdev);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700533 if (err) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 IRDA_ERROR("%s, Network device registration failed!\n",
535 driver_name);
536 goto err_out4;
537 }
538
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700539 self->pldev = platform_device_register_simple(SMSC_IRCC2_DRIVER_NAME,
540 dev_count, NULL, 0);
541 if (IS_ERR(self->pldev)) {
542 err = PTR_ERR(self->pldev);
543 goto err_out5;
544 }
Russell King3ae5eae2005-11-09 22:32:44 +0000545 platform_set_drvdata(self->pldev, self);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546
547 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700548 dev_count++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549
550 return 0;
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700551
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700552 err_out5:
553 unregister_netdev(self->netdev);
554
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 err_out4:
556 dma_free_coherent(NULL, self->tx_buff.truesize,
557 self->tx_buff.head, self->tx_buff_dma);
558 err_out3:
559 dma_free_coherent(NULL, self->rx_buff.truesize,
560 self->rx_buff.head, self->rx_buff_dma);
561 err_out2:
562 free_netdev(self->netdev);
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -0700563 dev_self[dev_count] = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 err_out1:
565 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
566 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
567 err_out:
568 return err;
569}
570
571/*
572 * Function smsc_ircc_present(fir_base, sir_base)
573 *
574 * Check the smsc-ircc chip presence
575 *
576 */
577static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
578{
579 unsigned char low, high, chip, config, dma, irq, version;
580
581 if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
582 driver_name)) {
583 IRDA_WARNING("%s: can't get fir_base of 0x%03x\n",
584 __FUNCTION__, fir_base);
585 goto out1;
586 }
587
588 if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
589 driver_name)) {
590 IRDA_WARNING("%s: can't get sir_base of 0x%03x\n",
591 __FUNCTION__, sir_base);
592 goto out2;
593 }
594
595 register_bank(fir_base, 3);
596
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700597 high = inb(fir_base + IRCC_ID_HIGH);
598 low = inb(fir_base + IRCC_ID_LOW);
599 chip = inb(fir_base + IRCC_CHIP_ID);
600 version = inb(fir_base + IRCC_VERSION);
601 config = inb(fir_base + IRCC_INTERFACE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 dma = config & IRCC_INTERFACE_DMA_MASK;
603 irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
604
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700605 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700606 IRDA_WARNING("%s(), addr 0x%04x - no device found!\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 __FUNCTION__, fir_base);
608 goto out3;
609 }
610 IRDA_MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
611 "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
612 chip & 0x0f, version, fir_base, sir_base, dma, irq);
613
614 return 0;
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700615
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 out3:
617 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
618 out2:
619 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
620 out1:
621 return -ENODEV;
622}
623
624/*
625 * Function smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq)
626 *
627 * Setup I/O
628 *
629 */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700630static void smsc_ircc_setup_io(struct smsc_ircc_cb *self,
631 unsigned int fir_base, unsigned int sir_base,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 u8 dma, u8 irq)
633{
634 unsigned char config, chip_dma, chip_irq;
635
636 register_bank(fir_base, 3);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700637 config = inb(fir_base + IRCC_INTERFACE);
638 chip_dma = config & IRCC_INTERFACE_DMA_MASK;
639 chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640
641 self->io.fir_base = fir_base;
642 self->io.sir_base = sir_base;
643 self->io.fir_ext = SMSC_IRCC2_FIR_CHIP_IO_EXTENT;
644 self->io.sir_ext = SMSC_IRCC2_SIR_CHIP_IO_EXTENT;
645 self->io.fifo_size = SMSC_IRCC2_FIFO_SIZE;
646 self->io.speed = SMSC_IRCC2_C_IRDA_FALLBACK_SPEED;
647
648 if (irq < 255) {
649 if (irq != chip_irq)
650 IRDA_MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n",
651 driver_name, chip_irq, irq);
652 self->io.irq = irq;
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700653 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 self->io.irq = chip_irq;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700655
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 if (dma < 255) {
657 if (dma != chip_dma)
658 IRDA_MESSAGE("%s, Overriding DMA - chip says %d, using %d\n",
659 driver_name, chip_dma, dma);
660 self->io.dma = dma;
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700661 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 self->io.dma = chip_dma;
663
664}
665
666/*
667 * Function smsc_ircc_setup_qos(self)
668 *
669 * Setup qos
670 *
671 */
672static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self)
673{
674 /* Initialize QoS for this device */
675 irda_init_max_qos_capabilies(&self->qos);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700676
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
678 IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
679
680 self->qos.min_turn_time.bits = SMSC_IRCC2_MIN_TURN_TIME;
681 self->qos.window_size.bits = SMSC_IRCC2_WINDOW_SIZE;
682 irda_qos_bits_to_value(&self->qos);
683}
684
685/*
686 * Function smsc_ircc_init_chip(self)
687 *
688 * Init chip
689 *
690 */
691static void smsc_ircc_init_chip(struct smsc_ircc_cb *self)
692{
Dmitry Torokhove812cb52005-10-30 15:00:14 -0800693 int iobase = self->io.fir_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694
695 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700696 outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
697 outb(0x00, iobase + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698
699 register_bank(iobase, 1);
Dmitry Torokhove812cb52005-10-30 15:00:14 -0800700 outb(((inb(iobase + IRCC_SCE_CFGA) & 0x87) | IRCC_CFGA_IRDA_SIR_A),
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700701 iobase + IRCC_SCE_CFGA);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702
703#ifdef smsc_669 /* Uses pin 88/89 for Rx/Tx */
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700704 outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
705 iobase + IRCC_SCE_CFGB);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700706#else
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700707 outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
708 iobase + IRCC_SCE_CFGB);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700709#endif
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700710 (void) inb(iobase + IRCC_FIFO_THRESHOLD);
711 outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase + IRCC_FIFO_THRESHOLD);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700712
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 register_bank(iobase, 4);
Dmitry Torokhove812cb52005-10-30 15:00:14 -0800714 outb((inb(iobase + IRCC_CONTROL) & 0x30), iobase + IRCC_CONTROL);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700715
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 register_bank(iobase, 0);
Dmitry Torokhove812cb52005-10-30 15:00:14 -0800717 outb(0, iobase + IRCC_LCR_A);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718
719 smsc_ircc_set_sir_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700720
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 /* Power on device */
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700722 outb(0x00, iobase + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723}
724
725/*
726 * Function smsc_ircc_net_ioctl (dev, rq, cmd)
727 *
728 * Process IOCTL commands for this device
729 *
730 */
731static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
732{
733 struct if_irda_req *irq = (struct if_irda_req *) rq;
734 struct smsc_ircc_cb *self;
735 unsigned long flags;
736 int ret = 0;
737
738 IRDA_ASSERT(dev != NULL, return -1;);
739
Dmitry Torokhovda0841a2005-09-06 15:19:23 -0700740 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741
742 IRDA_ASSERT(self != NULL, return -1;);
743
744 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700745
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 switch (cmd) {
747 case SIOCSBANDWIDTH: /* Set bandwidth */
748 if (!capable(CAP_NET_ADMIN))
749 ret = -EPERM;
750 else {
751 /* Make sure we are the only one touching
752 * self->io.speed and the hardware - Jean II */
753 spin_lock_irqsave(&self->lock, flags);
754 smsc_ircc_change_speed(self, irq->ifr_baudrate);
755 spin_unlock_irqrestore(&self->lock, flags);
756 }
757 break;
758 case SIOCSMEDIABUSY: /* Set media busy */
759 if (!capable(CAP_NET_ADMIN)) {
760 ret = -EPERM;
761 break;
762 }
763
764 irda_device_set_media_busy(self->netdev, TRUE);
765 break;
766 case SIOCGRECEIVING: /* Check if we are receiving right now */
767 irq->ifr_receiving = smsc_ircc_is_receiving(self);
768 break;
769 #if 0
770 case SIOCSDTRRTS:
771 if (!capable(CAP_NET_ADMIN)) {
772 ret = -EPERM;
773 break;
774 }
775 smsc_ircc_sir_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
776 break;
777 #endif
778 default:
779 ret = -EOPNOTSUPP;
780 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700781
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 return ret;
783}
784
785static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev)
786{
Dmitry Torokhovda0841a2005-09-06 15:19:23 -0700787 struct smsc_ircc_cb *self = netdev_priv(dev);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700788
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 return &self->stats;
790}
791
792#if SMSC_IRCC2_C_NET_TIMEOUT
793/*
794 * Function smsc_ircc_timeout (struct net_device *dev)
795 *
796 * The networking timeout management.
797 *
798 */
799
800static void smsc_ircc_timeout(struct net_device *dev)
801{
Dmitry Torokhovda0841a2005-09-06 15:19:23 -0700802 struct smsc_ircc_cb *self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 unsigned long flags;
804
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 IRDA_WARNING("%s: transmit timed out, changing speed to: %d\n",
806 dev->name, self->io.speed);
807 spin_lock_irqsave(&self->lock, flags);
808 smsc_ircc_sir_start(self);
809 smsc_ircc_change_speed(self, self->io.speed);
810 dev->trans_start = jiffies;
811 netif_wake_queue(dev);
812 spin_unlock_irqrestore(&self->lock, flags);
813}
814#endif
815
816/*
817 * Function smsc_ircc_hard_xmit_sir (struct sk_buff *skb, struct net_device *dev)
818 *
819 * Transmits the current frame until FIFO is full, then
820 * waits until the next transmit interrupt, and continues until the
821 * frame is transmitted.
822 */
823int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
824{
825 struct smsc_ircc_cb *self;
826 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 s32 speed;
828
829 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
830
831 IRDA_ASSERT(dev != NULL, return 0;);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700832
Dmitry Torokhovda0841a2005-09-06 15:19:23 -0700833 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 IRDA_ASSERT(self != NULL, return 0;);
835
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 netif_stop_queue(dev);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700837
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 /* Make sure test of self->io.speed & speed change are atomic */
839 spin_lock_irqsave(&self->lock, flags);
840
841 /* Check if we need to change the speed */
842 speed = irda_get_next_speed(skb);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700843 if (speed != self->io.speed && speed != -1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 /* Check for empty frame */
845 if (!skb->len) {
846 /*
847 * We send frames one by one in SIR mode (no
848 * pipelining), so at this point, if we were sending
849 * a previous frame, we just received the interrupt
850 * telling us it is finished (UART_IIR_THRI).
851 * Therefore, waiting for the transmitter to really
852 * finish draining the fifo won't take too long.
853 * And the interrupt handler is not expected to run.
854 * - Jean II */
855 smsc_ircc_sir_wait_hw_transmitter_finish(self);
856 smsc_ircc_change_speed(self, speed);
857 spin_unlock_irqrestore(&self->lock, flags);
858 dev_kfree_skb(skb);
859 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 }
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700861 self->new_speed = speed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 }
863
864 /* Init tx buffer */
865 self->tx_buff.data = self->tx_buff.head;
866
867 /* Copy skb to tx_buff while wrapping, stuffing and making CRC */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700868 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 self->tx_buff.truesize);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700870
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 self->stats.tx_bytes += self->tx_buff.len;
872
873 /* Turn on transmit finished interrupt. Will fire immediately! */
Dmitry Torokhov80a90582005-09-06 15:19:21 -0700874 outb(UART_IER_THRI, self->io.sir_base + UART_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875
876 spin_unlock_irqrestore(&self->lock, flags);
877
878 dev_kfree_skb(skb);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700879
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 return 0;
881}
882
883/*
884 * Function smsc_ircc_set_fir_speed (self, baud)
885 *
886 * Change the speed of the device
887 *
888 */
889static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed)
890{
891 int fir_base, ir_mode, ctrl, fast;
892
893 IRDA_ASSERT(self != NULL, return;);
894 fir_base = self->io.fir_base;
895
896 self->io.speed = speed;
897
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700898 switch (speed) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 default:
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700900 case 576000:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 ir_mode = IRCC_CFGA_IRDA_HDLC;
902 ctrl = IRCC_CRC;
903 fast = 0;
904 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__);
905 break;
906 case 1152000:
907 ir_mode = IRCC_CFGA_IRDA_HDLC;
908 ctrl = IRCC_1152 | IRCC_CRC;
909 fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA;
910 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n",
911 __FUNCTION__);
912 break;
913 case 4000000:
914 ir_mode = IRCC_CFGA_IRDA_4PPM;
915 ctrl = IRCC_CRC;
916 fast = IRCC_LCR_A_FAST;
917 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n",
918 __FUNCTION__);
919 break;
920 }
921 #if 0
922 Now in tranceiver!
923 /* This causes an interrupt */
924 register_bank(fir_base, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700925 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast, fir_base + IRCC_LCR_A);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 #endif
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700927
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 register_bank(fir_base, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700929 outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base + IRCC_SCE_CFGA);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700930
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 register_bank(fir_base, 4);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700932 outb((inb(fir_base + IRCC_CONTROL) & 0x30) | ctrl, fir_base + IRCC_CONTROL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933}
934
935/*
936 * Function smsc_ircc_fir_start(self)
937 *
938 * Change the speed of the device
939 *
940 */
941static void smsc_ircc_fir_start(struct smsc_ircc_cb *self)
942{
943 struct net_device *dev;
944 int fir_base;
945
946 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
947
948 IRDA_ASSERT(self != NULL, return;);
949 dev = self->netdev;
950 IRDA_ASSERT(dev != NULL, return;);
951
952 fir_base = self->io.fir_base;
953
954 /* Reset everything */
955
956 /* Install FIR transmit handler */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700957 dev->hard_start_xmit = smsc_ircc_hard_xmit_fir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958
959 /* Clear FIFO */
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700960 outb(inb(fir_base + IRCC_LCR_A) | IRCC_LCR_A_FIFO_RESET, fir_base + IRCC_LCR_A);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961
962 /* Enable interrupt */
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700963 /*outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base + IRCC_IER);*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964
965 register_bank(fir_base, 1);
966
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700967 /* Select the TX/RX interface */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968#ifdef SMSC_669 /* Uses pin 88/89 for Rx/Tx */
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700969 outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
970 fir_base + IRCC_SCE_CFGB);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700971#else
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700972 outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
973 fir_base + IRCC_SCE_CFGB);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700974#endif
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700975 (void) inb(fir_base + IRCC_FIFO_THRESHOLD);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976
977 /* Enable SCE interrupts */
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700978 outb(0, fir_base + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 register_bank(fir_base, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -0700980 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, fir_base + IRCC_IER);
981 outb(IRCC_MASTER_INT_EN, fir_base + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982}
983
984/*
985 * Function smsc_ircc_fir_stop(self, baud)
986 *
987 * Change the speed of the device
988 *
989 */
990static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self)
991{
992 int fir_base;
993
994 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -0700995
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 IRDA_ASSERT(self != NULL, return;);
997
998 fir_base = self->io.fir_base;
999 register_bank(fir_base, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001000 /*outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);*/
1001 outb(inb(fir_base + IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base + IRCC_LCR_B);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002}
1003
1004
1005/*
1006 * Function smsc_ircc_change_speed(self, baud)
1007 *
1008 * Change the speed of the device
1009 *
1010 * This function *must* be called with spinlock held, because it may
1011 * be called from the irq handler. - Jean II
1012 */
Dmitry Torokhov0fa2f492005-09-06 15:19:24 -07001013static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 struct net_device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 int last_speed_was_sir;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001017
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed);
1019
1020 IRDA_ASSERT(self != NULL, return;);
1021 dev = self->netdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022
1023 last_speed_was_sir = self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED;
1024
1025 #if 0
1026 /* Temp Hack */
1027 speed= 1152000;
1028 self->io.speed = speed;
1029 last_speed_was_sir = 0;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001030 smsc_ircc_fir_start(self);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 #endif
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001032
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001033 if (self->io.speed == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 smsc_ircc_sir_start(self);
1035
1036 #if 0
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001037 if (!last_speed_was_sir) speed = self->io.speed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 #endif
1039
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001040 if (self->io.speed != speed)
1041 smsc_ircc_set_transceiver_for_speed(self, speed);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042
1043 self->io.speed = speed;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001044
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001045 if (speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
1046 if (!last_speed_was_sir) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 smsc_ircc_fir_stop(self);
1048 smsc_ircc_sir_start(self);
1049 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001050 smsc_ircc_set_sir_speed(self, speed);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001051 } else {
1052 if (last_speed_was_sir) {
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001053 #if SMSC_IRCC2_C_SIR_STOP
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 smsc_ircc_sir_stop(self);
1055 #endif
1056 smsc_ircc_fir_start(self);
1057 }
1058 smsc_ircc_set_fir_speed(self, speed);
1059
1060 #if 0
1061 self->tx_buff.len = 10;
1062 self->tx_buff.data = self->tx_buff.head;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001063
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001064 smsc_ircc_dma_xmit(self, 4000);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 #endif
1066 /* Be ready for incoming frames */
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001067 smsc_ircc_dma_receive(self);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001069
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 netif_wake_queue(dev);
1071}
1072
1073/*
1074 * Function smsc_ircc_set_sir_speed (self, speed)
1075 *
1076 * Set speed of IrDA port to specified baudrate
1077 *
1078 */
Dmitry Torokhov0fa2f492005-09-06 15:19:24 -07001079void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080{
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001081 int iobase;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 int fcr; /* FIFO control reg */
1083 int lcr; /* Line control reg */
1084 int divisor;
1085
1086 IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __FUNCTION__, speed);
1087
1088 IRDA_ASSERT(self != NULL, return;);
1089 iobase = self->io.sir_base;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001090
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 /* Update accounting for new speed */
1092 self->io.speed = speed;
1093
1094 /* Turn off interrupts */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001095 outb(0, iobase + UART_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001097 divisor = SMSC_IRCC2_MAX_SIR_SPEED / speed;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001098
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 fcr = UART_FCR_ENABLE_FIFO;
1100
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001101 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
1103 * almost 1,7 ms at 19200 bps. At speeds above that we can just forget
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001104 * about this timeout since it will always be fast enough.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001106 fcr |= self->io.speed < 38400 ?
1107 UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001108
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 /* IrDA ports use 8N1 */
1110 lcr = UART_LCR_WLEN8;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001111
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001112 outb(UART_LCR_DLAB | lcr, iobase + UART_LCR); /* Set DLAB */
1113 outb(divisor & 0xff, iobase + UART_DLL); /* Set speed */
1114 outb(divisor >> 8, iobase + UART_DLM);
1115 outb(lcr, iobase + UART_LCR); /* Set 8N1 */
1116 outb(fcr, iobase + UART_FCR); /* Enable FIFO's */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117
1118 /* Turn on interrups */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001119 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120
1121 IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed);
1122}
1123
1124
1125/*
1126 * Function smsc_ircc_hard_xmit_fir (skb, dev)
1127 *
1128 * Transmit the frame!
1129 *
1130 */
1131static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
1132{
1133 struct smsc_ircc_cb *self;
1134 unsigned long flags;
1135 s32 speed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 int mtt;
1137
1138 IRDA_ASSERT(dev != NULL, return 0;);
Dmitry Torokhovda0841a2005-09-06 15:19:23 -07001139 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 IRDA_ASSERT(self != NULL, return 0;);
1141
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 netif_stop_queue(dev);
1143
1144 /* Make sure test of self->io.speed & speed change are atomic */
1145 spin_lock_irqsave(&self->lock, flags);
1146
1147 /* Check if we need to change the speed after this frame */
1148 speed = irda_get_next_speed(skb);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001149 if (speed != self->io.speed && speed != -1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 /* Check for empty frame */
1151 if (!skb->len) {
1152 /* Note : you should make sure that speed changes
1153 * are not going to corrupt any outgoing frame.
1154 * Look at nsc-ircc for the gory details - Jean II */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001155 smsc_ircc_change_speed(self, speed);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 spin_unlock_irqrestore(&self->lock, flags);
1157 dev_kfree_skb(skb);
1158 return 0;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001159 }
1160
1161 self->new_speed = speed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001163
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 memcpy(self->tx_buff.head, skb->data, skb->len);
1165
1166 self->tx_buff.len = skb->len;
1167 self->tx_buff.data = self->tx_buff.head;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001168
1169 mtt = irda_get_mtt(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 if (mtt) {
1171 int bofs;
1172
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001173 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 * Compute how many BOFs (STA or PA's) we need to waste the
1175 * min turn time given the speed of the link.
1176 */
1177 bofs = mtt * (self->io.speed / 1000) / 8000;
1178 if (bofs > 4095)
1179 bofs = 4095;
1180
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001181 smsc_ircc_dma_xmit(self, bofs);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 } else {
1183 /* Transmit frame */
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001184 smsc_ircc_dma_xmit(self, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 }
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001186
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 spin_unlock_irqrestore(&self->lock, flags);
1188 dev_kfree_skb(skb);
1189
1190 return 0;
1191}
1192
1193/*
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001194 * Function smsc_ircc_dma_xmit (self, bofs)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 *
1196 * Transmit data using DMA
1197 *
1198 */
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001199static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200{
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001201 int iobase = self->io.fir_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 u8 ctrl;
1203
1204 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1205#if 1
1206 /* Disable Rx */
1207 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001208 outb(0x00, iobase + IRCC_LCR_B);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209#endif
1210 register_bank(iobase, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001211 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1212 iobase + IRCC_SCE_CFGB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213
1214 self->io.direction = IO_XMIT;
1215
1216 /* Set BOF additional count for generating the min turn time */
1217 register_bank(iobase, 4);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001218 outb(bofs & 0xff, iobase + IRCC_BOF_COUNT_LO);
1219 ctrl = inb(iobase + IRCC_CONTROL) & 0xf0;
1220 outb(ctrl | ((bofs >> 8) & 0x0f), iobase + IRCC_BOF_COUNT_HI);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221
1222 /* Set max Tx frame size */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001223 outb(self->tx_buff.len >> 8, iobase + IRCC_TX_SIZE_HI);
1224 outb(self->tx_buff.len & 0xff, iobase + IRCC_TX_SIZE_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225
1226 /*outb(UART_MCR_OUT2, self->io.sir_base + UART_MCR);*/
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001227
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 /* Enable burst mode chip Tx DMA */
1229 register_bank(iobase, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001230 outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1231 IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232
1233 /* Setup DMA controller (must be done after enabling chip DMA) */
1234 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
1235 DMA_TX_MODE);
1236
1237 /* Enable interrupt */
1238
1239 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001240 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1241 outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001242
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 /* Enable transmit */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001244 outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase + IRCC_LCR_B);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245}
1246
1247/*
1248 * Function smsc_ircc_dma_xmit_complete (self)
1249 *
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001250 * The transfer of a frame in finished. This function will only be called
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 * by the interrupt handler
1252 *
1253 */
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001254static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255{
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001256 int iobase = self->io.fir_base;
1257
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1259#if 0
1260 /* Disable Tx */
1261 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001262 outb(0x00, iobase + IRCC_LCR_B);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263#endif
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001264 register_bank(iobase, 1);
1265 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1266 iobase + IRCC_SCE_CFGB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267
1268 /* Check for underrun! */
1269 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001270 if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 self->stats.tx_errors++;
1272 self->stats.tx_fifo_errors++;
1273
1274 /* Reset error condition */
1275 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001276 outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER);
1277 outb(0x00, iobase + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 } else {
1279 self->stats.tx_packets++;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001280 self->stats.tx_bytes += self->tx_buff.len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 }
1282
1283 /* Check if it's time to change the speed */
1284 if (self->new_speed) {
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001285 smsc_ircc_change_speed(self, self->new_speed);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 self->new_speed = 0;
1287 }
1288
1289 netif_wake_queue(self->netdev);
1290}
1291
1292/*
1293 * Function smsc_ircc_dma_receive(self)
1294 *
1295 * Get ready for receiving a frame. The device will initiate a DMA
1296 * if it starts to receive a frame.
1297 *
1298 */
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001299static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300{
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001301 int iobase = self->io.fir_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302#if 0
1303 /* Turn off chip DMA */
1304 register_bank(iobase, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001305 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1306 iobase + IRCC_SCE_CFGB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307#endif
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001308
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 /* Disable Tx */
1310 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001311 outb(0x00, iobase + IRCC_LCR_B);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
1313 /* Turn off chip DMA */
1314 register_bank(iobase, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001315 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1316 iobase + IRCC_SCE_CFGB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317
1318 self->io.direction = IO_RECV;
1319 self->rx_buff.data = self->rx_buff.head;
1320
1321 /* Set max Rx frame size */
1322 register_bank(iobase, 4);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001323 outb((2050 >> 8) & 0x0f, iobase + IRCC_RX_SIZE_HI);
1324 outb(2050 & 0xff, iobase + IRCC_RX_SIZE_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325
1326 /* Setup DMA controller */
1327 irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
1328 DMA_RX_MODE);
1329
1330 /* Enable burst mode chip Rx DMA */
1331 register_bank(iobase, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001332 outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1333 IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334
1335 /* Enable interrupt */
1336 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001337 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1338 outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339
1340 /* Enable receiver */
1341 register_bank(iobase, 0);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001342 outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE,
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001343 iobase + IRCC_LCR_B);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001344
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 return 0;
1346}
1347
1348/*
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001349 * Function smsc_ircc_dma_receive_complete(self)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 *
1351 * Finished with receiving frames
1352 *
1353 */
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001354static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355{
1356 struct sk_buff *skb;
1357 int len, msgcnt, lsr;
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001358 int iobase = self->io.fir_base;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001359
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 register_bank(iobase, 0);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001361
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1363#if 0
1364 /* Disable Rx */
1365 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001366 outb(0x00, iobase + IRCC_LCR_B);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367#endif
1368 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001369 outb(inb(iobase + IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase + IRCC_LSAR);
1370 lsr= inb(iobase + IRCC_LSR);
1371 msgcnt = inb(iobase + IRCC_LCR_B) & 0x08;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372
1373 IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__,
1374 get_dma_residue(self->io.dma));
1375
1376 len = self->rx_buff.truesize - get_dma_residue(self->io.dma);
1377
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001378 /* Look for errors */
1379 if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 self->stats.rx_errors++;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001381 if (lsr & IRCC_LSR_FRAME_ERROR)
1382 self->stats.rx_frame_errors++;
1383 if (lsr & IRCC_LSR_CRC_ERROR)
1384 self->stats.rx_crc_errors++;
1385 if (lsr & IRCC_LSR_SIZE_ERROR)
1386 self->stats.rx_length_errors++;
1387 if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN))
1388 self->stats.rx_length_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 return;
1390 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001392 /* Remove CRC */
1393 len -= self->io.speed < 4000000 ? 2 : 4;
1394
1395 if (len < 2 || len > 2050) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 IRDA_WARNING("%s(), bogus len=%d\n", __FUNCTION__, len);
1397 return;
1398 }
1399 IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len);
1400
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001401 skb = dev_alloc_skb(len + 1);
1402 if (!skb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 IRDA_WARNING("%s(), memory squeeze, dropping frame.\n",
1404 __FUNCTION__);
1405 return;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001406 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 /* Make sure IP header gets aligned */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001408 skb_reserve(skb, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409
1410 memcpy(skb_put(skb, len), self->rx_buff.data, len);
1411 self->stats.rx_packets++;
1412 self->stats.rx_bytes += len;
1413
1414 skb->dev = self->netdev;
Arnaldo Carvalho de Melo459a98e2007-03-19 15:30:44 -07001415 skb_reset_mac_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416 skb->protocol = htons(ETH_P_IRDA);
1417 netif_rx(skb);
1418}
1419
1420/*
1421 * Function smsc_ircc_sir_receive (self)
1422 *
1423 * Receive one frame from the infrared port
1424 *
1425 */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001426static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427{
1428 int boguscount = 0;
1429 int iobase;
1430
1431 IRDA_ASSERT(self != NULL, return;);
1432
1433 iobase = self->io.sir_base;
1434
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001435 /*
1436 * Receive all characters in Rx FIFO, unwrap and unstuff them.
1437 * async_unwrap_char will deliver all found frames
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 */
1439 do {
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001440 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff,
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001441 inb(iobase + UART_RX));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442
1443 /* Make sure we don't stay here to long */
1444 if (boguscount++ > 32) {
1445 IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__);
1446 break;
1447 }
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001448 } while (inb(iobase + UART_LSR) & UART_LSR_DR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449}
1450
1451
1452/*
1453 * Function smsc_ircc_interrupt (irq, dev_id, regs)
1454 *
1455 * An interrupt from the chip has arrived. Time to do some work
1456 *
1457 */
David Howells7d12e782006-10-05 14:55:46 +01001458static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459{
1460 struct net_device *dev = (struct net_device *) dev_id;
1461 struct smsc_ircc_cb *self;
1462 int iobase, iir, lcra, lsr;
1463 irqreturn_t ret = IRQ_NONE;
1464
1465 if (dev == NULL) {
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001466 printk(KERN_WARNING "%s: irq %d for unknown device.\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 driver_name, irq);
1468 goto irq_ret;
1469 }
Dmitry Torokhovda0841a2005-09-06 15:19:23 -07001470
1471 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 IRDA_ASSERT(self != NULL, return IRQ_NONE;);
1473
1474 /* Serialise the interrupt handler in various CPUs, stop Tx path */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001475 spin_lock(&self->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476
1477 /* Check if we should use the SIR interrupt handler */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001478 if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 ret = smsc_ircc_interrupt_sir(dev);
1480 goto irq_ret_unlock;
1481 }
1482
1483 iobase = self->io.fir_base;
1484
1485 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001486 iir = inb(iobase + IRCC_IIR);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001487 if (iir == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 goto irq_ret_unlock;
1489 ret = IRQ_HANDLED;
1490
1491 /* Disable interrupts */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001492 outb(0, iobase + IRCC_IER);
1493 lcra = inb(iobase + IRCC_LCR_A);
1494 lsr = inb(iobase + IRCC_LSR);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001495
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir);
1497
1498 if (iir & IRCC_IIR_EOM) {
1499 if (self->io.direction == IO_RECV)
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001500 smsc_ircc_dma_receive_complete(self);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 else
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001502 smsc_ircc_dma_xmit_complete(self);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001503
Dmitry Torokhov80a90582005-09-06 15:19:21 -07001504 smsc_ircc_dma_receive(self);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 }
1506
1507 if (iir & IRCC_IIR_ACTIVE_FRAME) {
1508 /*printk(KERN_WARNING "%s(): Active Frame\n", __FUNCTION__);*/
1509 }
1510
1511 /* Enable interrupts again */
1512
1513 register_bank(iobase, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001514 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515
1516 irq_ret_unlock:
1517 spin_unlock(&self->lock);
1518 irq_ret:
1519 return ret;
1520}
1521
1522/*
David Howells7d12e782006-10-05 14:55:46 +01001523 * Function irport_interrupt_sir (irq, dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 *
1525 * Interrupt handler for SIR modes
1526 */
1527static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
1528{
Dmitry Torokhovda0841a2005-09-06 15:19:23 -07001529 struct smsc_ircc_cb *self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 int boguscount = 0;
1531 int iobase;
1532 int iir, lsr;
1533
1534 /* Already locked comming here in smsc_ircc_interrupt() */
1535 /*spin_lock(&self->lock);*/
1536
1537 iobase = self->io.sir_base;
1538
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001539 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 if (iir == 0)
1541 return IRQ_NONE;
1542 while (iir) {
1543 /* Clear interrupt */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001544 lsr = inb(iobase + UART_LSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001546 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 __FUNCTION__, iir, lsr, iobase);
1548
1549 switch (iir) {
1550 case UART_IIR_RLSI:
1551 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__);
1552 break;
1553 case UART_IIR_RDI:
1554 /* Receive interrupt */
1555 smsc_ircc_sir_receive(self);
1556 break;
1557 case UART_IIR_THRI:
1558 if (lsr & UART_LSR_THRE)
1559 /* Transmitter ready for data */
1560 smsc_ircc_sir_write_wakeup(self);
1561 break;
1562 default:
1563 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n",
1564 __FUNCTION__, iir);
1565 break;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001566 }
1567
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 /* Make sure we don't stay here to long */
1569 if (boguscount++ > 100)
1570 break;
1571
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001572 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 }
1574 /*spin_unlock(&self->lock);*/
1575 return IRQ_HANDLED;
1576}
1577
1578
1579#if 0 /* unused */
1580/*
1581 * Function ircc_is_receiving (self)
1582 *
1583 * Return TRUE is we are currently receiving a frame
1584 *
1585 */
1586static int ircc_is_receiving(struct smsc_ircc_cb *self)
1587{
1588 int status = FALSE;
1589 /* int iobase; */
1590
1591 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1592
1593 IRDA_ASSERT(self != NULL, return FALSE;);
1594
1595 IRDA_DEBUG(0, "%s: dma count = %d\n", __FUNCTION__,
1596 get_dma_residue(self->io.dma));
1597
1598 status = (self->rx_buff.state != OUTSIDE_FRAME);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001599
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600 return status;
1601}
1602#endif /* unused */
1603
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001604static int smsc_ircc_request_irq(struct smsc_ircc_cb *self)
1605{
1606 int error;
1607
1608 error = request_irq(self->io.irq, smsc_ircc_interrupt, 0,
1609 self->netdev->name, self->netdev);
1610 if (error)
1611 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d, err=%d\n",
1612 __FUNCTION__, self->io.irq, error);
1613
1614 return error;
1615}
1616
1617static void smsc_ircc_start_interrupts(struct smsc_ircc_cb *self)
1618{
1619 unsigned long flags;
1620
1621 spin_lock_irqsave(&self->lock, flags);
1622
1623 self->io.speed = 0;
1624 smsc_ircc_change_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
1625
1626 spin_unlock_irqrestore(&self->lock, flags);
1627}
1628
1629static void smsc_ircc_stop_interrupts(struct smsc_ircc_cb *self)
1630{
1631 int iobase = self->io.fir_base;
1632 unsigned long flags;
1633
1634 spin_lock_irqsave(&self->lock, flags);
1635
1636 register_bank(iobase, 0);
1637 outb(0, iobase + IRCC_IER);
1638 outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
1639 outb(0x00, iobase + IRCC_MASTER);
1640
1641 spin_unlock_irqrestore(&self->lock, flags);
1642}
1643
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644
1645/*
1646 * Function smsc_ircc_net_open (dev)
1647 *
1648 * Start the device
1649 *
1650 */
1651static int smsc_ircc_net_open(struct net_device *dev)
1652{
1653 struct smsc_ircc_cb *self;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654 char hwname[16];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655
1656 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001657
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 IRDA_ASSERT(dev != NULL, return -1;);
Dmitry Torokhovda0841a2005-09-06 15:19:23 -07001659 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 IRDA_ASSERT(self != NULL, return 0;);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001661
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001662 if (self->io.suspended) {
1663 IRDA_DEBUG(0, "%s(), device is suspended\n", __FUNCTION__);
1664 return -EAGAIN;
1665 }
1666
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001667 if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 (void *) dev)) {
1669 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n",
1670 __FUNCTION__, self->io.irq);
1671 return -EAGAIN;
1672 }
1673
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001674 smsc_ircc_start_interrupts(self);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001675
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 /* Give self a hardware name */
1677 /* It would be cool to offer the chip revision here - Jean II */
1678 sprintf(hwname, "SMSC @ 0x%03x", self->io.fir_base);
1679
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001680 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681 * Open new IrLAP layer instance, now that everything should be
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001682 * initialized properly
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 */
1684 self->irlap = irlap_open(dev, &self->qos, hwname);
1685
1686 /*
1687 * Always allocate the DMA channel after the IRQ,
1688 * and clean up on failure.
1689 */
1690 if (request_dma(self->io.dma, dev->name)) {
1691 smsc_ircc_net_close(dev);
1692
1693 IRDA_WARNING("%s(), unable to allocate DMA=%d\n",
1694 __FUNCTION__, self->io.dma);
1695 return -EAGAIN;
1696 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001697
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 netif_start_queue(dev);
1699
1700 return 0;
1701}
1702
1703/*
1704 * Function smsc_ircc_net_close (dev)
1705 *
1706 * Stop the device
1707 *
1708 */
1709static int smsc_ircc_net_close(struct net_device *dev)
1710{
1711 struct smsc_ircc_cb *self;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712
1713 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001714
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715 IRDA_ASSERT(dev != NULL, return -1;);
Dmitry Torokhovda0841a2005-09-06 15:19:23 -07001716 self = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 IRDA_ASSERT(self != NULL, return 0;);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001718
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 /* Stop device */
1720 netif_stop_queue(dev);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001721
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 /* Stop and remove instance of IrLAP */
1723 if (self->irlap)
1724 irlap_close(self->irlap);
1725 self->irlap = NULL;
1726
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001727 smsc_ircc_stop_interrupts(self);
1728
1729 /* if we are called from smsc_ircc_resume we don't have IRQ reserved */
1730 if (!self->io.suspended)
1731 free_irq(self->io.irq, dev);
1732
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 disable_dma(self->io.dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 free_dma(self->io.dma);
1735
1736 return 0;
1737}
1738
Russell King3ae5eae2005-11-09 22:32:44 +00001739static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740{
Russell King3ae5eae2005-11-09 22:32:44 +00001741 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -07001742
Russell King9480e302005-10-28 09:52:56 -07001743 if (!self->io.suspended) {
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001744 IRDA_DEBUG(1, "%s, Suspending\n", driver_name);
1745
1746 rtnl_lock();
1747 if (netif_running(self->netdev)) {
1748 netif_device_detach(self->netdev);
1749 smsc_ircc_stop_interrupts(self);
1750 free_irq(self->io.irq, self->netdev);
1751 disable_dma(self->io.dma);
1752 }
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001753 self->io.suspended = 1;
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001754 rtnl_unlock();
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001755 }
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -07001756
1757 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758}
1759
Russell King3ae5eae2005-11-09 22:32:44 +00001760static int smsc_ircc_resume(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761{
Russell King3ae5eae2005-11-09 22:32:44 +00001762 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763
Russell King9480e302005-10-28 09:52:56 -07001764 if (self->io.suspended) {
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001765 IRDA_DEBUG(1, "%s, Waking up\n", driver_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001767 rtnl_lock();
1768 smsc_ircc_init_chip(self);
1769 if (netif_running(self->netdev)) {
1770 if (smsc_ircc_request_irq(self)) {
1771 /*
1772 * Don't fail resume process, just kill this
1773 * network interface
1774 */
1775 unregister_netdevice(self->netdev);
1776 } else {
1777 enable_dma(self->io.dma);
1778 smsc_ircc_start_interrupts(self);
1779 netif_device_attach(self->netdev);
1780 }
1781 }
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -07001782 self->io.suspended = 0;
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001783 rtnl_unlock();
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -07001784 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785 return 0;
1786}
1787
1788/*
1789 * Function smsc_ircc_close (self)
1790 *
1791 * Close driver instance
1792 *
1793 */
1794static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
1795{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1797
1798 IRDA_ASSERT(self != NULL, return -1;);
1799
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -07001800 platform_device_unregister(self->pldev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801
1802 /* Remove netdevice */
1803 unregister_netdev(self->netdev);
1804
Dmitry Torokhove812cb52005-10-30 15:00:14 -08001805 smsc_ircc_stop_interrupts(self);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001806
1807 /* Release the PORTS that this driver is using */
1808 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1809 self->io.fir_base);
1810
1811 release_region(self->io.fir_base, self->io.fir_ext);
1812
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001813 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 self->io.sir_base);
1815
1816 release_region(self->io.sir_base, self->io.sir_ext);
1817
1818 if (self->tx_buff.head)
1819 dma_free_coherent(NULL, self->tx_buff.truesize,
1820 self->tx_buff.head, self->tx_buff_dma);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001821
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 if (self->rx_buff.head)
1823 dma_free_coherent(NULL, self->rx_buff.truesize,
1824 self->rx_buff.head, self->rx_buff_dma);
1825
1826 free_netdev(self->netdev);
1827
1828 return 0;
1829}
1830
1831static void __exit smsc_ircc_cleanup(void)
1832{
1833 int i;
1834
1835 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1836
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001837 for (i = 0; i < 2; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 if (dev_self[i])
1839 smsc_ircc_close(dev_self[i]);
1840 }
Dmitry Torokhov6bb3b2c2005-09-06 15:19:22 -07001841
Russell King3ae5eae2005-11-09 22:32:44 +00001842 platform_driver_unregister(&smsc_ircc_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843}
1844
1845/*
1846 * Start SIR operations
1847 *
1848 * This function *must* be called with spinlock held, because it may
1849 * be called from the irq handler (via smsc_ircc_change_speed()). - Jean II
1850 */
1851void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
1852{
1853 struct net_device *dev;
1854 int fir_base, sir_base;
1855
1856 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1857
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001858 IRDA_ASSERT(self != NULL, return;);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001859 dev = self->netdev;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001860 IRDA_ASSERT(dev != NULL, return;);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001861 dev->hard_start_xmit = &smsc_ircc_hard_xmit_sir;
1862
1863 fir_base = self->io.fir_base;
1864 sir_base = self->io.sir_base;
1865
1866 /* Reset everything */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001867 outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868
1869 #if SMSC_IRCC2_C_SIR_STOP
1870 /*smsc_ircc_sir_stop(self);*/
1871 #endif
1872
1873 register_bank(fir_base, 1);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001874 outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base + IRCC_SCE_CFGA);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875
1876 /* Initialize UART */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001877 outb(UART_LCR_WLEN8, sir_base + UART_LCR); /* Reset DLAB */
1878 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base + UART_MCR);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001879
Linus Torvalds1da177e2005-04-16 15:20:36 -07001880 /* Turn on interrups */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001881 outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882
1883 IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__);
1884
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001885 outb(0x00, fir_base + IRCC_MASTER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886}
1887
1888#if SMSC_IRCC2_C_SIR_STOP
1889void smsc_ircc_sir_stop(struct smsc_ircc_cb *self)
1890{
1891 int iobase;
1892
1893 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1894 iobase = self->io.sir_base;
1895
1896 /* Reset UART */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001897 outb(0, iobase + UART_MCR);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001898
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 /* Turn off interrupts */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001900 outb(0, iobase + UART_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901}
1902#endif
1903
1904/*
1905 * Function smsc_sir_write_wakeup (self)
1906 *
1907 * Called by the SIR interrupt handler when there's room for more data.
1908 * If we have more packets to send, we send them here.
1909 *
1910 */
1911static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1912{
1913 int actual = 0;
1914 int iobase;
1915 int fcr;
1916
1917 IRDA_ASSERT(self != NULL, return;);
1918
1919 IRDA_DEBUG(4, "%s\n", __FUNCTION__);
1920
1921 iobase = self->io.sir_base;
1922
1923 /* Finished with frame? */
1924 if (self->tx_buff.len > 0) {
1925 /* Write data left in transmit buffer */
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001926 actual = smsc_ircc_sir_write(iobase, self->io.fifo_size,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 self->tx_buff.data, self->tx_buff.len);
1928 self->tx_buff.data += actual;
1929 self->tx_buff.len -= actual;
1930 } else {
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001931
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 /*if (self->tx_buff.len ==0) {*/
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001933
1934 /*
1935 * Now serial buffer is almost free & we can start
Linus Torvalds1da177e2005-04-16 15:20:36 -07001936 * transmission of another packet. But first we must check
1937 * if we need to change the speed of the hardware
1938 */
1939 if (self->new_speed) {
1940 IRDA_DEBUG(5, "%s(), Changing speed to %d.\n",
1941 __FUNCTION__, self->new_speed);
1942 smsc_ircc_sir_wait_hw_transmitter_finish(self);
1943 smsc_ircc_change_speed(self, self->new_speed);
1944 self->new_speed = 0;
1945 } else {
1946 /* Tell network layer that we want more frames */
1947 netif_wake_queue(self->netdev);
1948 }
1949 self->stats.tx_packets++;
1950
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001951 if (self->io.speed <= 115200) {
1952 /*
1953 * Reset Rx FIFO to make sure that all reflected transmit data
1954 * is discarded. This is needed for half duplex operation
1955 */
1956 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR;
1957 fcr |= self->io.speed < 38400 ?
1958 UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001959
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001960 outb(fcr, iobase + UART_FCR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001962 /* Turn on receive interrupts */
1963 outb(UART_IER_RDI, iobase + UART_IER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964 }
1965 }
1966}
1967
1968/*
1969 * Function smsc_ircc_sir_write (iobase, fifo_size, buf, len)
1970 *
1971 * Fill Tx FIFO with transmit data
1972 *
1973 */
1974static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
1975{
1976 int actual = 0;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001977
Linus Torvalds1da177e2005-04-16 15:20:36 -07001978 /* Tx FIFO should be empty! */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001979 if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001980 IRDA_WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__);
1981 return 0;
1982 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07001983
Linus Torvalds1da177e2005-04-16 15:20:36 -07001984 /* Fill FIFO with current frame */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001985 while (fifo_size-- > 0 && actual < len) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 /* Transmit next byte */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07001987 outb(buf[actual], iobase + UART_TX);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988 actual++;
1989 }
1990 return actual;
1991}
1992
1993/*
1994 * Function smsc_ircc_is_receiving (self)
1995 *
1996 * Returns true is we are currently receiving data
1997 *
1998 */
1999static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self)
2000{
2001 return (self->rx_buff.state != OUTSIDE_FRAME);
2002}
2003
2004
2005/*
2006 * Function smsc_ircc_probe_transceiver(self)
2007 *
2008 * Tries to find the used Transceiver
2009 *
2010 */
2011static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self)
2012{
2013 unsigned int i;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002014
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015 IRDA_ASSERT(self != NULL, return;);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002016
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002017 for (i = 0; smsc_transceivers[i].name != NULL; i++)
2018 if (smsc_transceivers[i].probe(self->io.fir_base)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019 IRDA_MESSAGE(" %s transceiver found\n",
2020 smsc_transceivers[i].name);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002021 self->transceiver= i + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022 return;
2023 }
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002024
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025 IRDA_MESSAGE("No transceiver found. Defaulting to %s\n",
2026 smsc_transceivers[SMSC_IRCC2_C_DEFAULT_TRANSCEIVER].name);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002027
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002028 self->transceiver = SMSC_IRCC2_C_DEFAULT_TRANSCEIVER;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029}
2030
2031
2032/*
2033 * Function smsc_ircc_set_transceiver_for_speed(self, speed)
2034 *
2035 * Set the transceiver according to the speed
2036 *
2037 */
2038static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed)
2039{
2040 unsigned int trx;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002041
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042 trx = self->transceiver;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002043 if (trx > 0)
2044 smsc_transceivers[trx - 1].set_for_speed(self->io.fir_base, speed);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002045}
2046
2047/*
2048 * Function smsc_ircc_wait_hw_transmitter_finish ()
2049 *
2050 * Wait for the real end of HW transmission
2051 *
2052 * The UART is a strict FIFO, and we get called only when we have finished
2053 * pushing data to the FIFO, so the maximum amount of time we must wait
2054 * is only for the FIFO to drain out.
2055 *
2056 * We use a simple calibrated loop. We may need to adjust the loop
2057 * delay (udelay) to balance I/O traffic and latency. And we also need to
2058 * adjust the maximum timeout.
2059 * It would probably be better to wait for the proper interrupt,
2060 * but it doesn't seem to be available.
2061 *
2062 * We can't use jiffies or kernel timers because :
2063 * 1) We are called from the interrupt handler, which disable softirqs,
2064 * so jiffies won't be increased
2065 * 2) Jiffies granularity is usually very coarse (10ms), and we don't
2066 * want to wait that long to detect stuck hardware.
2067 * Jean II
2068 */
2069
2070static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self)
2071{
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002072 int iobase = self->io.sir_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 int count = SMSC_IRCC2_HW_TRANSMITTER_TIMEOUT_US;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002074
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075 /* Calibrated busy loop */
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002076 while (count-- > 0 && !(inb(iobase + UART_LSR) & UART_LSR_TEMT))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077 udelay(1);
2078
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002079 if (count == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080 IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__);
2081}
2082
2083
2084/* PROBING
2085 *
David Brownelld94c77b2006-05-09 15:26:11 -07002086 * REVISIT we can be told about the device by PNP, and should use that info
2087 * instead of probing hardware and creating a platform_device ...
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088 */
2089
2090static int __init smsc_ircc_look_for_chips(void)
2091{
Dmitry Torokhovb6158d22005-09-06 15:19:20 -07002092 struct smsc_chip_address *address;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002093 char *type;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094 unsigned int cfg_base, found;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002095
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096 found = 0;
2097 address = possible_addresses;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002098
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002099 while (address->cfg_base) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002100 cfg_base = address->cfg_base;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002101
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __FUNCTION__, cfg_base, address->type);*/
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002103
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002104 if (address->type & SMSCSIO_TYPE_FDC) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 type = "FDC";
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002106 if (address->type & SMSCSIO_TYPE_FLAT)
2107 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, type))
2108 found++;
2109
2110 if (address->type & SMSCSIO_TYPE_PAGED)
2111 if (!smsc_superio_paged(fdc_chips_paged, cfg_base, type))
2112 found++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113 }
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002114 if (address->type & SMSCSIO_TYPE_LPC) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115 type = "LPC";
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002116 if (address->type & SMSCSIO_TYPE_FLAT)
2117 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, type))
2118 found++;
2119
2120 if (address->type & SMSCSIO_TYPE_PAGED)
2121 if (!smsc_superio_paged(lpc_chips_paged, cfg_base, type))
2122 found++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 }
2124 address++;
2125 }
2126 return found;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002127}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128
2129/*
2130 * Function smsc_superio_flat (chip, base, type)
2131 *
2132 * Try to get configuration of a smc SuperIO chip with flat register model
2133 *
2134 */
Dmitry Torokhovb6158d22005-09-06 15:19:20 -07002135static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfgbase, char *type)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136{
2137 unsigned short firbase, sirbase;
2138 u8 mode, dma, irq;
2139 int ret = -ENODEV;
2140
2141 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2142
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002143 if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 return ret;
2145
2146 outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002147 mode = inb(cfgbase + 1);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002148
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __FUNCTION__, mode);*/
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002150
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002151 if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002152 IRDA_WARNING("%s(): IrDA not enabled\n", __FUNCTION__);
2153
2154 outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002155 sirbase = inb(cfgbase + 1) << 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002157 /* FIR iobase */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 outb(SMSCSIOFLAT_FIRBASEADDR_REG, cfgbase);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002159 firbase = inb(cfgbase + 1) << 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160
2161 /* DMA */
2162 outb(SMSCSIOFLAT_FIRDMASELECT_REG, cfgbase);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002163 dma = inb(cfgbase + 1) & SMSCSIOFLAT_FIRDMASELECT_MASK;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002164
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165 /* IRQ */
2166 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002167 irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002168
2169 IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode);
2170
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002171 if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
2172 ret = 0;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002173
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 /* Exit configuration */
2175 outb(SMSCSIO_CFGEXITKEY, cfgbase);
2176
2177 return ret;
2178}
2179
2180/*
2181 * Function smsc_superio_paged (chip, base, type)
2182 *
2183 * Try to get configuration of a smc SuperIO chip with paged register model
2184 *
2185 */
Dmitry Torokhovb6158d22005-09-06 15:19:20 -07002186static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187{
2188 unsigned short fir_io, sir_io;
2189 int ret = -ENODEV;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002190
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2192
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002193 if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 return ret;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002195
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 /* Select logical device (UART2) */
2197 outb(0x07, cfg_base);
2198 outb(0x05, cfg_base + 1);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002199
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 /* SIR iobase */
2201 outb(0x60, cfg_base);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002202 sir_io = inb(cfg_base + 1) << 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 outb(0x61, cfg_base);
2204 sir_io |= inb(cfg_base + 1);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002205
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 /* Read FIR base */
2207 outb(0x62, cfg_base);
2208 fir_io = inb(cfg_base + 1) << 8;
2209 outb(0x63, cfg_base);
2210 fir_io |= inb(cfg_base + 1);
2211 outb(0x2b, cfg_base); /* ??? */
2212
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002213 if (fir_io && smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0)
2214 ret = 0;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002215
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 /* Exit configuration */
2217 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2218
2219 return ret;
2220}
2221
2222
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002223static int __init smsc_access(unsigned short cfg_base, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224{
2225 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2226
2227 outb(reg, cfg_base);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002228 return inb(cfg_base) != reg ? -1 : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229}
2230
Dmitry Torokhovb6158d22005-09-06 15:19:20 -07002231static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232{
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002233 u8 devid, xdevid, rev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234
2235 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2236
2237 /* Leave configuration */
2238
2239 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2240
2241 if (inb(cfg_base) == SMSCSIO_CFGEXITKEY) /* not a smc superio chip */
2242 return NULL;
2243
2244 outb(reg, cfg_base);
2245
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002246 xdevid = inb(cfg_base + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002247
2248 /* Enter configuration */
2249
2250 outb(SMSCSIO_CFGACCESSKEY, cfg_base);
2251
2252 #if 0
2253 if (smsc_access(cfg_base,0x55)) /* send second key and check */
2254 return NULL;
2255 #endif
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002256
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 /* probe device ID */
2258
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002259 if (smsc_access(cfg_base, reg))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 return NULL;
2261
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002262 devid = inb(cfg_base + 1);
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002263
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002264 if (devid == 0 || devid == 0xff) /* typical values for unused port */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 return NULL;
2266
2267 /* probe revision ID */
2268
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002269 if (smsc_access(cfg_base, reg + 1))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 return NULL;
2271
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002272 rev = inb(cfg_base + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002274 if (rev >= 128) /* i think this will make no sense */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 return NULL;
2276
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002277 if (devid == xdevid) /* protection against false positives */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 return NULL;
2279
2280 /* Check for expected device ID; are there others? */
2281
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002282 while (chip->devid != devid) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283
2284 chip++;
2285
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002286 if (chip->name == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287 return NULL;
2288 }
2289
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002290 IRDA_MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n",
2291 devid, rev, cfg_base, type, chip->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002293 if (chip->rev > rev) {
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002294 IRDA_MESSAGE("Revision higher than expected\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 return NULL;
2296 }
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002297
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002298 if (chip->flags & NoIRDA)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 IRDA_MESSAGE("chipset does not support IRDA\n");
2300
2301 return chip;
2302}
2303
2304static int __init smsc_superio_fdc(unsigned short cfg_base)
2305{
2306 int ret = -1;
2307
2308 if (!request_region(cfg_base, 2, driver_name)) {
2309 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2310 __FUNCTION__, cfg_base);
2311 } else {
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002312 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") ||
2313 !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC"))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 ret = 0;
2315
2316 release_region(cfg_base, 2);
2317 }
2318
2319 return ret;
2320}
2321
2322static int __init smsc_superio_lpc(unsigned short cfg_base)
2323{
2324 int ret = -1;
2325
2326 if (!request_region(cfg_base, 2, driver_name)) {
2327 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2328 __FUNCTION__, cfg_base);
2329 } else {
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002330 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") ||
2331 !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC"))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 ret = 0;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002333
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 release_region(cfg_base, 2);
2335 }
2336 return ret;
2337}
2338
Linus Walleijc1e14a62006-04-05 22:33:59 -07002339/*
2340 * Look for some specific subsystem setups that need
2341 * pre-configuration not properly done by the BIOS (especially laptops)
2342 * This code is based in part on smcinit.c, tosh1800-smcinit.c
2343 * and tosh2450-smcinit.c. The table lists the device entries
Linus Walleij08d09992006-04-14 16:03:33 -07002344 * for ISA bridges with an LPC (Low Pin Count) controller which
2345 * handles the communication with the SMSC device. After the LPC
2346 * controller is initialized through PCI, the SMSC device is initialized
2347 * through a dedicated port in the ISA port-mapped I/O area, this latter
2348 * area is used to configure the SMSC device with default
2349 * SIR and FIR I/O ports, DMA and IRQ. Different vendors have
2350 * used different sets of parameters and different control port
2351 * addresses making a subsystem device table necessary.
Linus Walleijc1e14a62006-04-05 22:33:59 -07002352 */
2353#ifdef CONFIG_PCI
2354#define PCIID_VENDOR_INTEL 0x8086
2355#define PCIID_VENDOR_ALI 0x10b9
Dmitry Torokhovc5d965c2006-07-06 23:58:27 -07002356static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __initdata = {
Linus Walleij (LD/EAB895de092006-09-27 22:49:23 -07002357 /*
2358 * Subsystems needing entries:
2359 * 0x10b9:0x1533 0x103c:0x0850 HP nx9010 family
2360 * 0x10b9:0x1533 0x0e11:0x005a Compaq nc4000 family
2361 * 0x8086:0x24cc 0x0e11:0x002a HP nx9000 family
2362 */
2363 {
2364 /* Guessed entry */
2365 .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
2366 .device = 0x24cc,
2367 .subvendor = 0x103c,
2368 .subdevice = 0x08bc,
2369 .sir_io = 0x02f8,
2370 .fir_io = 0x0130,
2371 .fir_irq = 0x05,
2372 .fir_dma = 0x03,
2373 .cfg_base = 0x004e,
2374 .preconfigure = preconfigure_through_82801,
2375 .name = "HP nx5000 family",
2376 },
Linus Walleijc1e14a62006-04-05 22:33:59 -07002377 {
2378 .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
2379 .device = 0x24cc,
2380 .subvendor = 0x103c,
2381 .subdevice = 0x088c,
Linus Walleij08d09992006-04-14 16:03:33 -07002382 /* Quite certain these are the same for nc8000 as for nc6000 */
2383 .sir_io = 0x02f8,
Linus Walleijc1e14a62006-04-05 22:33:59 -07002384 .fir_io = 0x0130,
Linus Walleij08d09992006-04-14 16:03:33 -07002385 .fir_irq = 0x05,
Linus Walleijc1e14a62006-04-05 22:33:59 -07002386 .fir_dma = 0x03,
2387 .cfg_base = 0x004e,
2388 .preconfigure = preconfigure_through_82801,
Linus Walleij (LD/EAB895de092006-09-27 22:49:23 -07002389 .name = "HP nc8000 family",
Linus Walleijc1e14a62006-04-05 22:33:59 -07002390 },
2391 {
2392 .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
2393 .device = 0x24cc,
2394 .subvendor = 0x103c,
2395 .subdevice = 0x0890,
2396 .sir_io = 0x02f8,
2397 .fir_io = 0x0130,
Linus Walleij08d09992006-04-14 16:03:33 -07002398 .fir_irq = 0x05,
Linus Walleijc1e14a62006-04-05 22:33:59 -07002399 .fir_dma = 0x03,
2400 .cfg_base = 0x004e,
2401 .preconfigure = preconfigure_through_82801,
Linus Walleij (LD/EAB895de092006-09-27 22:49:23 -07002402 .name = "HP nc6000 family",
2403 },
2404 {
2405 .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
2406 .device = 0x24cc,
2407 .subvendor = 0x0e11,
2408 .subdevice = 0x0860,
2409 /* I assume these are the same for x1000 as for the others */
2410 .sir_io = 0x02e8,
2411 .fir_io = 0x02f8,
2412 .fir_irq = 0x07,
2413 .fir_dma = 0x03,
2414 .cfg_base = 0x002e,
2415 .preconfigure = preconfigure_through_82801,
2416 .name = "Compaq x1000 family",
Linus Walleijc1e14a62006-04-05 22:33:59 -07002417 },
2418 {
Linus Walleij08d09992006-04-14 16:03:33 -07002419 /* Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge */
2420 .vendor = PCIID_VENDOR_INTEL,
Linus Walleijc1e14a62006-04-05 22:33:59 -07002421 .device = 0x24c0,
2422 .subvendor = 0x1179,
Linus Walleij08d09992006-04-14 16:03:33 -07002423 .subdevice = 0xffff, /* 0xffff is "any" */
Linus Walleijc1e14a62006-04-05 22:33:59 -07002424 .sir_io = 0x03f8,
2425 .fir_io = 0x0130,
2426 .fir_irq = 0x07,
2427 .fir_dma = 0x01,
2428 .cfg_base = 0x002e,
2429 .preconfigure = preconfigure_through_82801,
Linus Walleij08d09992006-04-14 16:03:33 -07002430 .name = "Toshiba laptop with Intel 82801DB/DBL LPC bridge",
Linus Walleijc1e14a62006-04-05 22:33:59 -07002431 },
2432 {
2433 .vendor = PCIID_VENDOR_INTEL, /* Intel 82801CAM ISA bridge */
Linus Walleij08d09992006-04-14 16:03:33 -07002434 .device = 0x248c,
Linus Walleijc1e14a62006-04-05 22:33:59 -07002435 .subvendor = 0x1179,
Linus Walleij08d09992006-04-14 16:03:33 -07002436 .subdevice = 0xffff, /* 0xffff is "any" */
Linus Walleijc1e14a62006-04-05 22:33:59 -07002437 .sir_io = 0x03f8,
2438 .fir_io = 0x0130,
2439 .fir_irq = 0x03,
2440 .fir_dma = 0x03,
2441 .cfg_base = 0x002e,
2442 .preconfigure = preconfigure_through_82801,
Linus Walleij08d09992006-04-14 16:03:33 -07002443 .name = "Toshiba laptop with Intel 82801CAM ISA bridge",
Linus Walleijc1e14a62006-04-05 22:33:59 -07002444 },
2445 {
Linus Walleij08d09992006-04-14 16:03:33 -07002446 /* 82801DBM (ICH4-M) LPC Interface Bridge */
2447 .vendor = PCIID_VENDOR_INTEL,
2448 .device = 0x24cc,
2449 .subvendor = 0x1179,
2450 .subdevice = 0xffff, /* 0xffff is "any" */
2451 .sir_io = 0x03f8,
2452 .fir_io = 0x0130,
2453 .fir_irq = 0x03,
2454 .fir_dma = 0x03,
2455 .cfg_base = 0x002e,
2456 .preconfigure = preconfigure_through_82801,
2457 .name = "Toshiba laptop with Intel 8281DBM LPC bridge",
2458 },
2459 {
2460 /* ALi M1533/M1535 PCI to ISA Bridge [Aladdin IV/V/V+] */
2461 .vendor = PCIID_VENDOR_ALI,
Linus Walleijc1e14a62006-04-05 22:33:59 -07002462 .device = 0x1533,
2463 .subvendor = 0x1179,
Linus Walleij08d09992006-04-14 16:03:33 -07002464 .subdevice = 0xffff, /* 0xffff is "any" */
Linus Walleijc1e14a62006-04-05 22:33:59 -07002465 .sir_io = 0x02e8,
2466 .fir_io = 0x02f8,
2467 .fir_irq = 0x07,
2468 .fir_dma = 0x03,
2469 .cfg_base = 0x002e,
2470 .preconfigure = preconfigure_through_ali,
Linus Walleij08d09992006-04-14 16:03:33 -07002471 .name = "Toshiba laptop with ALi ISA bridge",
Linus Walleijc1e14a62006-04-05 22:33:59 -07002472 },
2473 { } // Terminator
2474};
2475
2476
2477/*
Linus Walleij08d09992006-04-14 16:03:33 -07002478 * This sets up the basic SMSC parameters
2479 * (FIR port, SIR port, FIR DMA, FIR IRQ)
Linus Walleijc1e14a62006-04-05 22:33:59 -07002480 * through the chip configuration port.
2481 */
Linus Walleij08d09992006-04-14 16:03:33 -07002482static int __init preconfigure_smsc_chip(struct
2483 smsc_ircc_subsystem_configuration
2484 *conf)
Linus Walleijc1e14a62006-04-05 22:33:59 -07002485{
2486 unsigned short iobase = conf->cfg_base;
2487 unsigned char tmpbyte;
2488
2489 outb(LPC47N227_CFGACCESSKEY, iobase); // enter configuration state
2490 outb(SMSCSIOFLAT_DEVICEID_REG, iobase); // set for device ID
2491 tmpbyte = inb(iobase +1); // Read device ID
Linus Walleij08d09992006-04-14 16:03:33 -07002492 IRDA_DEBUG(0,
2493 "Detected Chip id: 0x%02x, setting up registers...\n",
2494 tmpbyte);
Linus Walleijc1e14a62006-04-05 22:33:59 -07002495
2496 /* Disable UART1 and set up SIR I/O port */
2497 outb(0x24, iobase); // select CR24 - UART1 base addr
2498 outb(0x00, iobase + 1); // disable UART1
2499 outb(SMSCSIOFLAT_UART2BASEADDR_REG, iobase); // select CR25 - UART2 base addr
2500 outb( (conf->sir_io >> 2), iobase + 1); // bits 2-9 of 0x3f8
2501 tmpbyte = inb(iobase + 1);
2502 if (tmpbyte != (conf->sir_io >> 2) ) {
2503 IRDA_WARNING("ERROR: could not configure SIR ioport.\n");
Linus Walleij08d09992006-04-14 16:03:33 -07002504 IRDA_WARNING("Try to supply ircc_cfg argument.\n");
Linus Walleijc1e14a62006-04-05 22:33:59 -07002505 return -ENXIO;
2506 }
2507
2508 /* Set up FIR IRQ channel for UART2 */
2509 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, iobase); // select CR28 - UART1,2 IRQ select
2510 tmpbyte = inb(iobase + 1);
2511 tmpbyte &= SMSCSIOFLAT_UART1IRQSELECT_MASK; // Do not touch the UART1 portion
2512 tmpbyte |= (conf->fir_irq & SMSCSIOFLAT_UART2IRQSELECT_MASK);
2513 outb(tmpbyte, iobase + 1);
2514 tmpbyte = inb(iobase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
2515 if (tmpbyte != conf->fir_irq) {
2516 IRDA_WARNING("ERROR: could not configure FIR IRQ channel.\n");
2517 return -ENXIO;
2518 }
2519
2520 /* Set up FIR I/O port */
2521 outb(SMSCSIOFLAT_FIRBASEADDR_REG, iobase); // CR2B - SCE (FIR) base addr
2522 outb((conf->fir_io >> 3), iobase + 1);
2523 tmpbyte = inb(iobase + 1);
2524 if (tmpbyte != (conf->fir_io >> 3) ) {
2525 IRDA_WARNING("ERROR: could not configure FIR I/O port.\n");
2526 return -ENXIO;
2527 }
2528
2529 /* Set up FIR DMA channel */
2530 outb(SMSCSIOFLAT_FIRDMASELECT_REG, iobase); // CR2C - SCE (FIR) DMA select
2531 outb((conf->fir_dma & LPC47N227_FIRDMASELECT_MASK), iobase + 1); // DMA
2532 tmpbyte = inb(iobase + 1) & LPC47N227_FIRDMASELECT_MASK;
2533 if (tmpbyte != (conf->fir_dma & LPC47N227_FIRDMASELECT_MASK)) {
2534 IRDA_WARNING("ERROR: could not configure FIR DMA channel.\n");
2535 return -ENXIO;
2536 }
2537
2538 outb(SMSCSIOFLAT_UARTMODE0C_REG, iobase); // CR0C - UART mode
2539 tmpbyte = inb(iobase + 1);
Linus Walleij08d09992006-04-14 16:03:33 -07002540 tmpbyte &= ~SMSCSIOFLAT_UART2MODE_MASK |
2541 SMSCSIOFLAT_UART2MODE_VAL_IRDA;
Linus Walleijc1e14a62006-04-05 22:33:59 -07002542 outb(tmpbyte, iobase + 1); // enable IrDA (HPSIR) mode, high speed
2543
2544 outb(LPC47N227_APMBOOTDRIVE_REG, iobase); // CR07 - Auto Pwr Mgt/boot drive sel
2545 tmpbyte = inb(iobase + 1);
2546 outb(tmpbyte | LPC47N227_UART2AUTOPWRDOWN_MASK, iobase + 1); // enable UART2 autopower down
2547
2548 /* This one was not part of tosh1800 */
2549 outb(0x0a, iobase); // CR0a - ecp fifo / ir mux
2550 tmpbyte = inb(iobase + 1);
2551 outb(tmpbyte | 0x40, iobase + 1); // send active device to ir port
2552
2553 outb(LPC47N227_UART12POWER_REG, iobase); // CR02 - UART 1,2 power
2554 tmpbyte = inb(iobase + 1);
2555 outb(tmpbyte | LPC47N227_UART2POWERDOWN_MASK, iobase + 1); // UART2 power up mode, UART1 power down
2556
2557 outb(LPC47N227_FDCPOWERVALIDCONF_REG, iobase); // CR00 - FDC Power/valid config cycle
2558 tmpbyte = inb(iobase + 1);
2559 outb(tmpbyte | LPC47N227_VALID_MASK, iobase + 1); // valid config cycle done
2560
2561 outb(LPC47N227_CFGEXITKEY, iobase); // Exit configuration
2562
2563 return 0;
2564}
2565
Linus Walleij08d09992006-04-14 16:03:33 -07002566/* 82801CAM generic registers */
Linus Walleijc1e14a62006-04-05 22:33:59 -07002567#define VID 0x00
2568#define DID 0x02
Linus Walleij08d09992006-04-14 16:03:33 -07002569#define PIRQ_A_D_ROUT 0x60
2570#define SIRQ_CNTL 0x64
2571#define PIRQ_E_H_ROUT 0x68
Linus Walleijc1e14a62006-04-05 22:33:59 -07002572#define PCI_DMA_C 0x90
Linus Walleij08d09992006-04-14 16:03:33 -07002573/* LPC-specific registers */
Linus Walleijc1e14a62006-04-05 22:33:59 -07002574#define COM_DEC 0xe0
Linus Walleij08d09992006-04-14 16:03:33 -07002575#define GEN1_DEC 0xe4
Linus Walleijc1e14a62006-04-05 22:33:59 -07002576#define LPC_EN 0xe6
2577#define GEN2_DEC 0xec
2578/*
Linus Walleij08d09992006-04-14 16:03:33 -07002579 * Sets up the I/O range using the 82801CAM ISA bridge, 82801DBM LPC bridge
2580 * or Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge.
2581 * They all work the same way!
Linus Walleijc1e14a62006-04-05 22:33:59 -07002582 */
2583static int __init preconfigure_through_82801(struct pci_dev *dev,
Linus Walleij08d09992006-04-14 16:03:33 -07002584 struct
2585 smsc_ircc_subsystem_configuration
2586 *conf)
Linus Walleijc1e14a62006-04-05 22:33:59 -07002587{
2588 unsigned short tmpword;
Linus Walleij08d09992006-04-14 16:03:33 -07002589 unsigned char tmpbyte;
Linus Walleijc1e14a62006-04-05 22:33:59 -07002590
Linus Walleij08d09992006-04-14 16:03:33 -07002591 IRDA_MESSAGE("Setting up Intel 82801 controller and SMSC device\n");
2592 /*
2593 * Select the range for the COMA COM port (SIR)
2594 * Register COM_DEC:
2595 * Bit 7: reserved
2596 * Bit 6-4, COMB decode range
2597 * Bit 3: reserved
2598 * Bit 2-0, COMA decode range
2599 *
2600 * Decode ranges:
2601 * 000 = 0x3f8-0x3ff (COM1)
2602 * 001 = 0x2f8-0x2ff (COM2)
2603 * 010 = 0x220-0x227
2604 * 011 = 0x228-0x22f
2605 * 100 = 0x238-0x23f
2606 * 101 = 0x2e8-0x2ef (COM4)
2607 * 110 = 0x338-0x33f
2608 * 111 = 0x3e8-0x3ef (COM3)
2609 */
2610 pci_read_config_byte(dev, COM_DEC, &tmpbyte);
2611 tmpbyte &= 0xf8; /* mask COMA bits */
2612 switch(conf->sir_io) {
2613 case 0x3f8:
2614 tmpbyte |= 0x00;
2615 break;
2616 case 0x2f8:
2617 tmpbyte |= 0x01;
2618 break;
2619 case 0x220:
2620 tmpbyte |= 0x02;
2621 break;
2622 case 0x228:
2623 tmpbyte |= 0x03;
2624 break;
2625 case 0x238:
2626 tmpbyte |= 0x04;
2627 break;
2628 case 0x2e8:
2629 tmpbyte |= 0x05;
2630 break;
2631 case 0x338:
2632 tmpbyte |= 0x06;
2633 break;
2634 case 0x3e8:
2635 tmpbyte |= 0x07;
2636 break;
2637 default:
2638 tmpbyte |= 0x01; /* COM2 default */
2639 }
2640 IRDA_DEBUG(1, "COM_DEC (write): 0x%02x\n", tmpbyte);
2641 pci_write_config_byte(dev, COM_DEC, tmpbyte);
Linus Walleijc1e14a62006-04-05 22:33:59 -07002642
Linus Walleij08d09992006-04-14 16:03:33 -07002643 /* Enable Low Pin Count interface */
2644 pci_read_config_word(dev, LPC_EN, &tmpword);
2645 /* These seem to be set up at all times,
2646 * just make sure it is properly set.
2647 */
2648 switch(conf->cfg_base) {
2649 case 0x04e:
2650 tmpword |= 0x2000;
2651 break;
2652 case 0x02e:
2653 tmpword |= 0x1000;
2654 break;
2655 case 0x062:
2656 tmpword |= 0x0800;
2657 break;
2658 case 0x060:
2659 tmpword |= 0x0400;
2660 break;
2661 default:
2662 IRDA_WARNING("Uncommon I/O base address: 0x%04x\n",
2663 conf->cfg_base);
2664 break;
2665 }
2666 tmpword &= 0xfffd; /* disable LPC COMB */
2667 tmpword |= 0x0001; /* set bit 0 : enable LPC COMA addr range (GEN2) */
2668 IRDA_DEBUG(1, "LPC_EN (write): 0x%04x\n", tmpword);
Linus Walleijc1e14a62006-04-05 22:33:59 -07002669 pci_write_config_word(dev, LPC_EN, tmpword);
2670
Linus Walleij08d09992006-04-14 16:03:33 -07002671 /*
2672 * Configure LPC DMA channel
2673 * PCI_DMA_C bits:
2674 * Bit 15-14: DMA channel 7 select
2675 * Bit 13-12: DMA channel 6 select
2676 * Bit 11-10: DMA channel 5 select
2677 * Bit 9-8: Reserved
2678 * Bit 7-6: DMA channel 3 select
2679 * Bit 5-4: DMA channel 2 select
2680 * Bit 3-2: DMA channel 1 select
2681 * Bit 1-0: DMA channel 0 select
2682 * 00 = Reserved value
2683 * 01 = PC/PCI DMA
2684 * 10 = Reserved value
2685 * 11 = LPC I/F DMA
2686 */
2687 pci_read_config_word(dev, PCI_DMA_C, &tmpword);
2688 switch(conf->fir_dma) {
2689 case 0x07:
2690 tmpword |= 0xc000;
2691 break;
2692 case 0x06:
2693 tmpword |= 0x3000;
2694 break;
2695 case 0x05:
2696 tmpword |= 0x0c00;
2697 break;
2698 case 0x03:
2699 tmpword |= 0x00c0;
2700 break;
2701 case 0x02:
2702 tmpword |= 0x0030;
2703 break;
2704 case 0x01:
2705 tmpword |= 0x000c;
2706 break;
2707 case 0x00:
2708 tmpword |= 0x0003;
2709 break;
2710 default:
2711 break; /* do not change settings */
2712 }
2713 IRDA_DEBUG(1, "PCI_DMA_C (write): 0x%04x\n", tmpword);
2714 pci_write_config_word(dev, PCI_DMA_C, tmpword);
2715
2716 /*
2717 * GEN2_DEC bits:
2718 * Bit 15-4: Generic I/O range
2719 * Bit 3-1: reserved (read as 0)
2720 * Bit 0: enable GEN2 range on LPC I/F
2721 */
2722 tmpword = conf->fir_io & 0xfff8;
2723 tmpword |= 0x0001;
2724 IRDA_DEBUG(1, "GEN2_DEC (write): 0x%04x\n", tmpword);
2725 pci_write_config_word(dev, GEN2_DEC, tmpword);
Linus Walleijc1e14a62006-04-05 22:33:59 -07002726
2727 /* Pre-configure chip */
Linus Walleij08d09992006-04-14 16:03:33 -07002728 return preconfigure_smsc_chip(conf);
2729}
Linus Walleijc1e14a62006-04-05 22:33:59 -07002730
Linus Walleij08d09992006-04-14 16:03:33 -07002731/*
2732 * Pre-configure a certain port on the ALi 1533 bridge.
2733 * This is based on reverse-engineering since ALi does not
2734 * provide any data sheet for the 1533 chip.
2735 */
2736static void __init preconfigure_ali_port(struct pci_dev *dev,
2737 unsigned short port)
2738{
2739 unsigned char reg;
2740 /* These bits obviously control the different ports */
2741 unsigned char mask;
2742 unsigned char tmpbyte;
2743
2744 switch(port) {
2745 case 0x0130:
2746 case 0x0178:
2747 reg = 0xb0;
2748 mask = 0x80;
2749 break;
2750 case 0x03f8:
2751 reg = 0xb4;
2752 mask = 0x80;
2753 break;
2754 case 0x02f8:
2755 reg = 0xb4;
2756 mask = 0x30;
2757 break;
2758 case 0x02e8:
2759 reg = 0xb4;
2760 mask = 0x08;
2761 break;
2762 default:
2763 IRDA_ERROR("Failed to configure unsupported port on ALi 1533 bridge: 0x%04x\n", port);
2764 return;
2765 }
2766
2767 pci_read_config_byte(dev, reg, &tmpbyte);
2768 /* Turn on the right bits */
2769 tmpbyte |= mask;
2770 pci_write_config_byte(dev, reg, tmpbyte);
2771 IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port);
2772 return;
Linus Walleijc1e14a62006-04-05 22:33:59 -07002773}
2774
2775static int __init preconfigure_through_ali(struct pci_dev *dev,
Linus Walleij08d09992006-04-14 16:03:33 -07002776 struct
2777 smsc_ircc_subsystem_configuration
2778 *conf)
Linus Walleijc1e14a62006-04-05 22:33:59 -07002779{
Linus Walleij08d09992006-04-14 16:03:33 -07002780 /* Configure the two ports on the ALi 1533 */
2781 preconfigure_ali_port(dev, conf->sir_io);
2782 preconfigure_ali_port(dev, conf->fir_io);
2783
2784 /* Pre-configure chip */
2785 return preconfigure_smsc_chip(conf);
Linus Walleijc1e14a62006-04-05 22:33:59 -07002786}
2787
2788static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
2789 unsigned short ircc_fir,
2790 unsigned short ircc_sir,
2791 unsigned char ircc_dma,
2792 unsigned char ircc_irq)
2793{
2794 struct pci_dev *dev = NULL;
2795 unsigned short ss_vendor = 0x0000;
2796 unsigned short ss_device = 0x0000;
2797 int ret = 0;
2798
2799 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
2800
2801 while (dev != NULL) {
2802 struct smsc_ircc_subsystem_configuration *conf;
2803
2804 /*
Linus Walleij08d09992006-04-14 16:03:33 -07002805 * Cache the subsystem vendor/device:
2806 * some manufacturers fail to set this for all components,
2807 * so we save it in case there is just 0x0000 0x0000 on the
2808 * device we want to check.
Linus Walleijc1e14a62006-04-05 22:33:59 -07002809 */
2810 if (dev->subsystem_vendor != 0x0000U) {
2811 ss_vendor = dev->subsystem_vendor;
2812 ss_device = dev->subsystem_device;
2813 }
2814 conf = subsystem_configurations;
2815 for( ; conf->subvendor; conf++) {
2816 if(conf->vendor == dev->vendor &&
2817 conf->device == dev->device &&
Linus Walleij08d09992006-04-14 16:03:33 -07002818 conf->subvendor == ss_vendor &&
2819 /* Sometimes these are cached values */
2820 (conf->subdevice == ss_device ||
2821 conf->subdevice == 0xffff)) {
2822 struct smsc_ircc_subsystem_configuration
2823 tmpconf;
Linus Walleijc1e14a62006-04-05 22:33:59 -07002824
Linus Walleij08d09992006-04-14 16:03:33 -07002825 memcpy(&tmpconf, conf,
2826 sizeof(struct smsc_ircc_subsystem_configuration));
Linus Walleijc1e14a62006-04-05 22:33:59 -07002827
Linus Walleij08d09992006-04-14 16:03:33 -07002828 /*
2829 * Override the default values with anything
2830 * passed in as parameter
2831 */
Linus Walleijc1e14a62006-04-05 22:33:59 -07002832 if (ircc_cfg != 0)
2833 tmpconf.cfg_base = ircc_cfg;
2834 if (ircc_fir != 0)
2835 tmpconf.fir_io = ircc_fir;
2836 if (ircc_sir != 0)
2837 tmpconf.sir_io = ircc_sir;
2838 if (ircc_dma != 0xff)
2839 tmpconf.fir_dma = ircc_dma;
2840 if (ircc_irq != 0xff)
2841 tmpconf.fir_irq = ircc_irq;
2842
2843 IRDA_MESSAGE("Detected unconfigured %s SMSC IrDA chip, pre-configuring device.\n", conf->name);
2844 if (conf->preconfigure)
2845 ret = conf->preconfigure(dev, &tmpconf);
2846 else
2847 ret = -ENODEV;
2848 }
2849 }
2850 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
2851 }
2852
2853 return ret;
2854}
2855#endif // CONFIG_PCI
2856
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857/************************************************
2858 *
2859 * Transceivers specific functions
2860 *
2861 ************************************************/
2862
2863
2864/*
2865 * Function smsc_ircc_set_transceiver_smsc_ircc_atc(fir_base, speed)
2866 *
2867 * Program transceiver through smsc-ircc ATC circuitry
2868 *
2869 */
2870
2871static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed)
2872{
2873 unsigned long jiffies_now, jiffies_timeout;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002874 u8 val;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002875
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002876 jiffies_now = jiffies;
2877 jiffies_timeout = jiffies + SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002878
Linus Torvalds1da177e2005-04-16 15:20:36 -07002879 /* ATC */
2880 register_bank(fir_base, 4);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002881 outb((inb(fir_base + IRCC_ATC) & IRCC_ATC_MASK) | IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE,
2882 fir_base + IRCC_ATC);
2883
2884 while ((val = (inb(fir_base + IRCC_ATC) & IRCC_ATC_nPROGREADY)) &&
2885 !time_after(jiffies, jiffies_timeout))
2886 /* empty */;
2887
2888 if (val)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002889 IRDA_WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__,
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002890 inb(fir_base + IRCC_ATC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002891}
2892
2893/*
2894 * Function smsc_ircc_probe_transceiver_smsc_ircc_atc(fir_base)
2895 *
2896 * Probe transceiver smsc-ircc ATC circuitry
2897 *
2898 */
2899
2900static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base)
2901{
2902 return 0;
2903}
2904
2905/*
2906 * Function smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(self, speed)
2907 *
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002908 * Set transceiver
Linus Torvalds1da177e2005-04-16 15:20:36 -07002909 *
2910 */
2911
2912static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed)
2913{
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002914 u8 fast_mode;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002915
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002916 switch (speed) {
2917 default:
2918 case 576000 :
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002919 fast_mode = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920 break;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002921 case 1152000 :
2922 case 4000000 :
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923 fast_mode = IRCC_LCR_A_FAST;
2924 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925 }
2926 register_bank(fir_base, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002927 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002928}
2929
2930/*
2931 * Function smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(fir_base)
2932 *
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002933 * Probe transceiver
Linus Torvalds1da177e2005-04-16 15:20:36 -07002934 *
2935 */
2936
2937static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base)
2938{
2939 return 0;
2940}
2941
2942/*
2943 * Function smsc_ircc_set_transceiver_toshiba_sat1800(fir_base, speed)
2944 *
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002945 * Set transceiver
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946 *
2947 */
2948
2949static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed)
2950{
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002951 u8 fast_mode;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002952
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002953 switch (speed) {
2954 default:
2955 case 576000 :
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002956 fast_mode = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957 break;
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002958 case 1152000 :
2959 case 4000000 :
Linus Torvalds1da177e2005-04-16 15:20:36 -07002960 fast_mode = /*IRCC_LCR_A_FAST |*/ IRCC_LCR_A_GP_DATA;
2961 break;
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002962
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963 }
2964 /* This causes an interrupt */
2965 register_bank(fir_base, 0);
Dmitry Torokhov98b77772005-09-06 15:19:19 -07002966 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967}
2968
2969/*
2970 * Function smsc_ircc_probe_transceiver_toshiba_sat1800(fir_base)
2971 *
Dmitry Torokhov527b6af2005-09-06 15:19:17 -07002972 * Probe transceiver
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973 *
2974 */
2975
2976static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base)
2977{
2978 return 0;
2979}
2980
2981
2982module_init(smsc_ircc_init);
2983module_exit(smsc_ircc_cleanup);