2005-04-17 00:20:36 +02:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Filename: ali-ircc.h
|
|
|
|
* Version: 0.5
|
|
|
|
* Description: Driver for the ALI M1535D and M1543C FIR Controller
|
|
|
|
* Status: Experimental.
|
|
|
|
* Author: Benjamin Kong <benjamin_kong@ali.com.tw>
|
|
|
|
* Created at: 2000/10/16 03:46PM
|
|
|
|
* Modified at: 2001/1/3 02:55PM
|
|
|
|
* Modified by: Benjamin Kong <benjamin_kong@ali.com.tw>
|
|
|
|
* Modified at: 2003/11/6 and support for ALi south-bridge chipsets M1563
|
|
|
|
* Modified by: Clear Zhang <clear_zhang@ali.com.tw>
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000 Benjamin Kong <benjamin_kong@ali.com.tw>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/gfp.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
2011-06-06 12:43:46 +02:00
|
|
|
#include <linux/interrupt.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
#include <linux/serial_reg.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
2006-05-26 01:21:10 +02:00
|
|
|
#include <linux/platform_device.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
|
|
|
#include <net/irda/wrapper.h>
|
|
|
|
#include <net/irda/irda.h>
|
|
|
|
#include <net/irda/irda_device.h>
|
|
|
|
|
|
|
|
#include "ali-ircc.h"
|
|
|
|
|
|
|
|
#define CHIP_IO_EXTENT 8
|
|
|
|
#define BROKEN_DONGLE_ID
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
#define ALI_IRCC_DRIVER_NAME "ali-ircc"
|
|
|
|
|
|
|
|
/* Power Management */
|
|
|
|
static int ali_ircc_suspend(struct platform_device *dev, pm_message_t state);
|
|
|
|
static int ali_ircc_resume(struct platform_device *dev);
|
|
|
|
|
|
|
|
static struct platform_driver ali_ircc_driver = {
|
|
|
|
.suspend = ali_ircc_suspend,
|
|
|
|
.resume = ali_ircc_resume,
|
|
|
|
.driver = {
|
|
|
|
.name = ALI_IRCC_DRIVER_NAME,
|
2008-04-18 22:50:44 +02:00
|
|
|
.owner = THIS_MODULE,
|
2006-05-26 01:21:10 +02:00
|
|
|
},
|
|
|
|
};
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Module parameters */
|
|
|
|
static int qos_mtt_bits = 0x07; /* 1 ms or more */
|
|
|
|
|
|
|
|
/* Use BIOS settions by default, but user may supply module parameters */
|
|
|
|
static unsigned int io[] = { ~0, ~0, ~0, ~0 };
|
|
|
|
static unsigned int irq[] = { 0, 0, 0, 0 };
|
|
|
|
static unsigned int dma[] = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
static int ali_ircc_probe_53(ali_chip_t *chip, chipio_t *info);
|
|
|
|
static int ali_ircc_init_43(ali_chip_t *chip, chipio_t *info);
|
|
|
|
static int ali_ircc_init_53(ali_chip_t *chip, chipio_t *info);
|
|
|
|
|
2011-03-31 03:57:33 +02:00
|
|
|
/* These are the currently known ALi south-bridge chipsets, the only one difference
|
2005-04-17 00:20:36 +02:00
|
|
|
* is that M1543C doesn't support HP HDSL-3600
|
|
|
|
*/
|
|
|
|
static ali_chip_t chips[] =
|
|
|
|
{
|
|
|
|
{ "M1543", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x43, ali_ircc_probe_53, ali_ircc_init_43 },
|
|
|
|
{ "M1535", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x53, ali_ircc_probe_53, ali_ircc_init_53 },
|
|
|
|
{ "M1563", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x63, ali_ircc_probe_53, ali_ircc_init_53 },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Max 4 instances for now */
|
|
|
|
static struct ali_ircc_cb *dev_self[] = { NULL, NULL, NULL, NULL };
|
|
|
|
|
|
|
|
/* Dongle Types */
|
|
|
|
static char *dongle_types[] = {
|
|
|
|
"TFDS6000",
|
|
|
|
"HP HSDL-3600",
|
|
|
|
"HP HSDL-1100",
|
|
|
|
"No dongle connected",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Some prototypes */
|
|
|
|
static int ali_ircc_open(int i, chipio_t *info);
|
|
|
|
|
|
|
|
static int ali_ircc_close(struct ali_ircc_cb *self);
|
|
|
|
|
|
|
|
static int ali_ircc_setup(chipio_t *info);
|
|
|
|
static int ali_ircc_is_receiving(struct ali_ircc_cb *self);
|
|
|
|
static int ali_ircc_net_open(struct net_device *dev);
|
|
|
|
static int ali_ircc_net_close(struct net_device *dev);
|
|
|
|
static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
|
|
|
|
static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud);
|
|
|
|
|
|
|
|
/* SIR function */
|
2009-08-31 21:50:50 +02:00
|
|
|
static netdev_tx_t ali_ircc_sir_hard_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
static irqreturn_t ali_ircc_sir_interrupt(struct ali_ircc_cb *self);
|
|
|
|
static void ali_ircc_sir_receive(struct ali_ircc_cb *self);
|
|
|
|
static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self);
|
|
|
|
static int ali_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
|
|
|
|
static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed);
|
|
|
|
|
|
|
|
/* FIR function */
|
2009-08-31 21:50:50 +02:00
|
|
|
static netdev_tx_t ali_ircc_fir_hard_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 speed);
|
|
|
|
static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self);
|
|
|
|
static int ali_ircc_dma_receive(struct ali_ircc_cb *self);
|
|
|
|
static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self);
|
|
|
|
static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self);
|
|
|
|
static void ali_ircc_dma_xmit(struct ali_ircc_cb *self);
|
|
|
|
|
|
|
|
/* My Function */
|
|
|
|
static int ali_ircc_read_dongle_id (int i, chipio_t *info);
|
|
|
|
static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed);
|
|
|
|
|
|
|
|
/* ALi chip function */
|
|
|
|
static void SIR2FIR(int iobase);
|
|
|
|
static void FIR2SIR(int iobase);
|
|
|
|
static void SetCOMInterrupts(struct ali_ircc_cb *self , unsigned char enable);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_init ()
|
|
|
|
*
|
|
|
|
* Initialize chip. Find out whay kinds of chips we are dealing with
|
2010-09-23 11:46:48 +02:00
|
|
|
* and their configuration registers address
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static int __init ali_ircc_init(void)
|
|
|
|
{
|
|
|
|
ali_chip_t *chip;
|
|
|
|
chipio_t info;
|
2006-07-08 22:33:28 +02:00
|
|
|
int ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
int cfg, cfg_base;
|
|
|
|
int reg, revision;
|
|
|
|
int i = 0;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2006-05-26 01:21:10 +02:00
|
|
|
|
|
|
|
ret = platform_driver_register(&ali_ircc_driver);
|
|
|
|
if (ret) {
|
|
|
|
IRDA_ERROR("%s, Can't register driver!\n",
|
|
|
|
ALI_IRCC_DRIVER_NAME);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-07-08 22:33:28 +02:00
|
|
|
ret = -ENODEV;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Probe for all the ALi chipsets we know about */
|
|
|
|
for (chip= chips; chip->name; chip++, i++)
|
|
|
|
{
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), Probing for %s ...\n", __func__, chip->name);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Try all config registers for this chip */
|
|
|
|
for (cfg=0; cfg<2; cfg++)
|
|
|
|
{
|
|
|
|
cfg_base = chip->cfg[cfg];
|
|
|
|
if (!cfg_base)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
memset(&info, 0, sizeof(chipio_t));
|
|
|
|
info.cfg_base = cfg_base;
|
|
|
|
info.fir_base = io[i];
|
|
|
|
info.dma = dma[i];
|
|
|
|
info.irq = irq[i];
|
|
|
|
|
|
|
|
|
|
|
|
/* Enter Configuration */
|
|
|
|
outb(chip->entr1, cfg_base);
|
|
|
|
outb(chip->entr2, cfg_base);
|
|
|
|
|
|
|
|
/* Select Logical Device 5 Registers (UART2) */
|
|
|
|
outb(0x07, cfg_base);
|
|
|
|
outb(0x05, cfg_base+1);
|
|
|
|
|
|
|
|
/* Read Chip Identification Register */
|
|
|
|
outb(chip->cid_index, cfg_base);
|
|
|
|
reg = inb(cfg_base+1);
|
|
|
|
|
|
|
|
if (reg == chip->cid_value)
|
|
|
|
{
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), Chip found at 0x%03x\n", __func__, cfg_base);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
outb(0x1F, cfg_base);
|
|
|
|
revision = inb(cfg_base+1);
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), Found %s chip, revision=%d\n", __func__,
|
2005-04-17 00:20:36 +02:00
|
|
|
chip->name, revision);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the user supplies the base address, then
|
|
|
|
* we init the chip, if not we probe the values
|
|
|
|
* set by the BIOS
|
|
|
|
*/
|
|
|
|
if (io[i] < 2000)
|
|
|
|
{
|
|
|
|
chip->init(chip, &info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chip->probe(chip, &info);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ali_ircc_open(i, &info) == 0)
|
|
|
|
ret = 0;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), No %s chip at 0x%03x\n", __func__, chip->name, cfg_base);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
/* Exit configuration */
|
|
|
|
outb(0xbb, cfg_base);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
|
2006-05-26 01:21:10 +02:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
platform_driver_unregister(&ali_ircc_driver);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_cleanup ()
|
|
|
|
*
|
|
|
|
* Close all configured chips
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void __exit ali_ircc_cleanup(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-08-15 09:05:38 +02:00
|
|
|
for (i=0; i < ARRAY_SIZE(dev_self); i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
if (dev_self[i])
|
|
|
|
ali_ircc_close(dev_self[i]);
|
|
|
|
}
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
platform_driver_unregister(&ali_ircc_driver);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-03-20 20:35:40 +01:00
|
|
|
static const struct net_device_ops ali_ircc_sir_ops = {
|
|
|
|
.ndo_open = ali_ircc_net_open,
|
|
|
|
.ndo_stop = ali_ircc_net_close,
|
|
|
|
.ndo_start_xmit = ali_ircc_sir_hard_xmit,
|
|
|
|
.ndo_do_ioctl = ali_ircc_net_ioctl,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct net_device_ops ali_ircc_fir_ops = {
|
|
|
|
.ndo_open = ali_ircc_net_open,
|
|
|
|
.ndo_stop = ali_ircc_net_close,
|
|
|
|
.ndo_start_xmit = ali_ircc_fir_hard_xmit,
|
|
|
|
.ndo_do_ioctl = ali_ircc_net_ioctl,
|
|
|
|
};
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Function ali_ircc_open (int i, chipio_t *inf)
|
|
|
|
*
|
|
|
|
* Open driver instance
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_open(int i, chipio_t *info)
|
|
|
|
{
|
|
|
|
struct net_device *dev;
|
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
int dongle_id;
|
|
|
|
int err;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2006-08-15 09:05:38 +02:00
|
|
|
|
|
|
|
if (i >= ARRAY_SIZE(dev_self)) {
|
|
|
|
IRDA_ERROR("%s(), maximum number of supported chips reached!\n",
|
2008-07-31 02:20:18 +02:00
|
|
|
__func__);
|
2006-08-15 09:05:38 +02:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Set FIR FIFO and DMA Threshold */
|
|
|
|
if ((ali_ircc_setup(info)) == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
dev = alloc_irdadev(sizeof(*self));
|
|
|
|
if (dev == NULL) {
|
|
|
|
IRDA_ERROR("%s(), can't allocate memory for control block!\n",
|
2008-07-31 02:20:18 +02:00
|
|
|
__func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
self->netdev = dev;
|
|
|
|
spin_lock_init(&self->lock);
|
|
|
|
|
|
|
|
/* Need to store self somewhere */
|
|
|
|
dev_self[i] = self;
|
|
|
|
self->index = i;
|
|
|
|
|
|
|
|
/* Initialize IO */
|
|
|
|
self->io.cfg_base = info->cfg_base; /* In ali_ircc_probe_53 assign */
|
|
|
|
self->io.fir_base = info->fir_base; /* info->sir_base = info->fir_base */
|
|
|
|
self->io.sir_base = info->sir_base; /* ALi SIR and FIR use the same address */
|
|
|
|
self->io.irq = info->irq;
|
|
|
|
self->io.fir_ext = CHIP_IO_EXTENT;
|
|
|
|
self->io.dma = info->dma;
|
|
|
|
self->io.fifo_size = 16; /* SIR: 16, FIR: 32 Benjamin 2000/11/1 */
|
|
|
|
|
|
|
|
/* Reserve the ioports that we need */
|
2006-05-26 01:21:10 +02:00
|
|
|
if (!request_region(self->io.fir_base, self->io.fir_ext,
|
|
|
|
ALI_IRCC_DRIVER_NAME)) {
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", __func__,
|
2005-04-17 00:20:36 +02:00
|
|
|
self->io.fir_base);
|
|
|
|
err = -ENODEV;
|
|
|
|
goto err_out1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize QoS for this device */
|
|
|
|
irda_init_max_qos_capabilies(&self->qos);
|
|
|
|
|
|
|
|
/* The only value we must override it the baudrate */
|
|
|
|
self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
|
|
|
|
IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8); // benjamin 2000/11/8 05:27PM
|
|
|
|
|
|
|
|
self->qos.min_turn_time.bits = qos_mtt_bits;
|
|
|
|
|
|
|
|
irda_qos_bits_to_value(&self->qos);
|
|
|
|
|
|
|
|
/* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
|
|
|
|
self->rx_buff.truesize = 14384;
|
|
|
|
self->tx_buff.truesize = 14384;
|
|
|
|
|
|
|
|
/* Allocate memory if needed */
|
|
|
|
self->rx_buff.head =
|
2013-08-27 07:45:23 +02:00
|
|
|
dma_zalloc_coherent(NULL, self->rx_buff.truesize,
|
|
|
|
&self->rx_buff_dma, GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (self->rx_buff.head == NULL) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->tx_buff.head =
|
2013-08-27 07:45:23 +02:00
|
|
|
dma_zalloc_coherent(NULL, self->tx_buff.truesize,
|
|
|
|
&self->tx_buff_dma, GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (self->tx_buff.head == NULL) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_out3;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->rx_buff.in_frame = FALSE;
|
|
|
|
self->rx_buff.state = OUTSIDE_FRAME;
|
|
|
|
self->tx_buff.data = self->tx_buff.head;
|
|
|
|
self->rx_buff.data = self->rx_buff.head;
|
|
|
|
|
|
|
|
/* Reset Tx queue info */
|
|
|
|
self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
|
|
|
|
self->tx_fifo.tail = self->tx_buff.head;
|
|
|
|
|
|
|
|
/* Override the network functions we need to use */
|
2009-03-20 20:35:40 +01:00
|
|
|
dev->netdev_ops = &ali_ircc_sir_ops;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
err = register_netdev(dev);
|
|
|
|
if (err) {
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_ERROR("%s(), register_netdev() failed!\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
goto err_out4;
|
|
|
|
}
|
|
|
|
IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
|
|
|
|
|
|
|
|
/* Check dongle id */
|
|
|
|
dongle_id = ali_ircc_read_dongle_id(i, info);
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_MESSAGE("%s(), %s, Found dongle: %s\n", __func__,
|
2006-05-26 01:21:10 +02:00
|
|
|
ALI_IRCC_DRIVER_NAME, dongle_types[dongle_id]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
self->io.dongle_id = dongle_id;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_out4:
|
|
|
|
dma_free_coherent(NULL, self->tx_buff.truesize,
|
|
|
|
self->tx_buff.head, self->tx_buff_dma);
|
|
|
|
err_out3:
|
|
|
|
dma_free_coherent(NULL, self->rx_buff.truesize,
|
|
|
|
self->rx_buff.head, self->rx_buff_dma);
|
|
|
|
err_out2:
|
|
|
|
release_region(self->io.fir_base, self->io.fir_ext);
|
|
|
|
err_out1:
|
|
|
|
dev_self[i] = NULL;
|
|
|
|
free_netdev(dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_close (self)
|
|
|
|
*
|
|
|
|
* Close driver instance
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int __exit ali_ircc_close(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int iobase;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
/* Remove netdevice */
|
|
|
|
unregister_netdev(self->netdev);
|
|
|
|
|
|
|
|
/* Release the PORT that this driver is using */
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(4, "%s(), Releasing Region %03x\n", __func__, self->io.fir_base);
|
2005-04-17 00:20:36 +02:00
|
|
|
release_region(self->io.fir_base, self->io.fir_ext);
|
|
|
|
|
|
|
|
if (self->tx_buff.head)
|
|
|
|
dma_free_coherent(NULL, self->tx_buff.truesize,
|
|
|
|
self->tx_buff.head, self->tx_buff_dma);
|
|
|
|
|
|
|
|
if (self->rx_buff.head)
|
|
|
|
dma_free_coherent(NULL, self->rx_buff.truesize,
|
|
|
|
self->rx_buff.head, self->rx_buff_dma);
|
|
|
|
|
|
|
|
dev_self[self->index] = NULL;
|
|
|
|
free_netdev(self->netdev);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_init_43 (chip, info)
|
|
|
|
*
|
|
|
|
* Initialize the ALi M1543 chip.
|
|
|
|
*/
|
|
|
|
static int ali_ircc_init_43(ali_chip_t *chip, chipio_t *info)
|
|
|
|
{
|
|
|
|
/* All controller information like I/O address, DMA channel, IRQ
|
|
|
|
* are set by BIOS
|
|
|
|
*/
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_init_53 (chip, info)
|
|
|
|
*
|
|
|
|
* Initialize the ALi M1535 chip.
|
|
|
|
*/
|
|
|
|
static int ali_ircc_init_53(ali_chip_t *chip, chipio_t *info)
|
|
|
|
{
|
|
|
|
/* All controller information like I/O address, DMA channel, IRQ
|
|
|
|
* are set by BIOS
|
|
|
|
*/
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_probe_53 (chip, info)
|
|
|
|
*
|
|
|
|
* Probes for the ALi M1535D or M1535
|
|
|
|
*/
|
|
|
|
static int ali_ircc_probe_53(ali_chip_t *chip, chipio_t *info)
|
|
|
|
{
|
|
|
|
int cfg_base = info->cfg_base;
|
|
|
|
int hi, low, reg;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Enter Configuration */
|
|
|
|
outb(chip->entr1, cfg_base);
|
|
|
|
outb(chip->entr2, cfg_base);
|
|
|
|
|
|
|
|
/* Select Logical Device 5 Registers (UART2) */
|
|
|
|
outb(0x07, cfg_base);
|
|
|
|
outb(0x05, cfg_base+1);
|
|
|
|
|
|
|
|
/* Read address control register */
|
|
|
|
outb(0x60, cfg_base);
|
|
|
|
hi = inb(cfg_base+1);
|
|
|
|
outb(0x61, cfg_base);
|
|
|
|
low = inb(cfg_base+1);
|
|
|
|
info->fir_base = (hi<<8) + low;
|
|
|
|
|
|
|
|
info->sir_base = info->fir_base;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), probing fir_base=0x%03x\n", __func__, info->fir_base);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Read IRQ control register */
|
|
|
|
outb(0x70, cfg_base);
|
|
|
|
reg = inb(cfg_base+1);
|
|
|
|
info->irq = reg & 0x0f;
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), probing irq=%d\n", __func__, info->irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Read DMA channel */
|
|
|
|
outb(0x74, cfg_base);
|
|
|
|
reg = inb(cfg_base+1);
|
|
|
|
info->dma = reg & 0x07;
|
|
|
|
|
|
|
|
if(info->dma == 0x04)
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_WARNING("%s(), No DMA channel assigned !\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
else
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), probing dma=%d\n", __func__, info->dma);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Read Enabled Status */
|
|
|
|
outb(0x30, cfg_base);
|
|
|
|
reg = inb(cfg_base+1);
|
|
|
|
info->enabled = (reg & 0x80) && (reg & 0x01);
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), probing enabled=%d\n", __func__, info->enabled);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Read Power Status */
|
|
|
|
outb(0x22, cfg_base);
|
|
|
|
reg = inb(cfg_base+1);
|
|
|
|
info->suspended = (reg & 0x20);
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), probing suspended=%d\n", __func__, info->suspended);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Exit configuration */
|
|
|
|
outb(0xbb, cfg_base);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_setup (info)
|
|
|
|
*
|
|
|
|
* Set FIR FIFO and DMA Threshold
|
|
|
|
* Returns non-negative on success.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_setup(chipio_t *info)
|
|
|
|
{
|
|
|
|
unsigned char tmp;
|
|
|
|
int version;
|
|
|
|
int iobase = info->fir_base;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Locking comments :
|
|
|
|
* Most operations here need to be protected. We are called before
|
|
|
|
* the device instance is created in ali_ircc_open(), therefore
|
|
|
|
* nobody can bother us - Jean II */
|
|
|
|
|
|
|
|
/* Switch to FIR space */
|
|
|
|
SIR2FIR(iobase);
|
|
|
|
|
|
|
|
/* Master Reset */
|
|
|
|
outb(0x40, iobase+FIR_MCR); // benjamin 2000/11/30 11:45AM
|
|
|
|
|
|
|
|
/* Read FIR ID Version Register */
|
|
|
|
switch_bank(iobase, BANK3);
|
|
|
|
version = inb(iobase+FIR_ID_VR);
|
|
|
|
|
|
|
|
/* Should be 0x00 in the M1535/M1535D */
|
|
|
|
if(version != 0x00)
|
|
|
|
{
|
2006-05-26 01:21:10 +02:00
|
|
|
IRDA_ERROR("%s, Wrong chip version %02x\n",
|
|
|
|
ALI_IRCC_DRIVER_NAME, version);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set FIR FIFO Threshold Register */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(RX_FIFO_Threshold, iobase+FIR_FIFO_TR);
|
|
|
|
|
|
|
|
/* Set FIR DMA Threshold Register */
|
|
|
|
outb(RX_DMA_Threshold, iobase+FIR_DMA_TR);
|
|
|
|
|
|
|
|
/* CRC enable */
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(inb(iobase+FIR_IRDA_CR) | IRDA_CR_CRC, iobase+FIR_IRDA_CR);
|
|
|
|
|
|
|
|
/* NDIS driver set TX Length here BANK2 Alias 3, Alias4*/
|
|
|
|
|
|
|
|
/* Switch to Bank 0 */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
|
|
|
|
tmp = inb(iobase+FIR_LCR_B);
|
|
|
|
tmp &=~0x20; // disable SIP
|
|
|
|
tmp |= 0x80; // these two steps make RX mode
|
|
|
|
tmp &= 0xbf;
|
|
|
|
outb(tmp, iobase+FIR_LCR_B);
|
|
|
|
|
|
|
|
/* Disable Interrupt */
|
|
|
|
outb(0x00, iobase+FIR_IER);
|
|
|
|
|
|
|
|
|
|
|
|
/* Switch to SIR space */
|
|
|
|
FIR2SIR(iobase);
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
IRDA_MESSAGE("%s, driver loaded (Benjamin Kong)\n",
|
|
|
|
ALI_IRCC_DRIVER_NAME);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Enable receive interrupts */
|
|
|
|
// outb(UART_IER_RDI, iobase+UART_IER); //benjamin 2000/11/23 01:25PM
|
|
|
|
// Turn on the interrupts in ali_ircc_net_open
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_read_dongle_id (int index, info)
|
|
|
|
*
|
2013-10-12 01:29:46 +02:00
|
|
|
* Try to read dongle identification. This procedure needs to be executed
|
2005-04-17 00:20:36 +02:00
|
|
|
* once after power-on/reset. It also needs to be used whenever you suspect
|
|
|
|
* that the user may have plugged/unplugged the IrDA Dongle.
|
|
|
|
*/
|
|
|
|
static int ali_ircc_read_dongle_id (int i, chipio_t *info)
|
|
|
|
{
|
|
|
|
int dongle_id, reg;
|
|
|
|
int cfg_base = info->cfg_base;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Enter Configuration */
|
|
|
|
outb(chips[i].entr1, cfg_base);
|
|
|
|
outb(chips[i].entr2, cfg_base);
|
|
|
|
|
|
|
|
/* Select Logical Device 5 Registers (UART2) */
|
|
|
|
outb(0x07, cfg_base);
|
|
|
|
outb(0x05, cfg_base+1);
|
|
|
|
|
|
|
|
/* Read Dongle ID */
|
|
|
|
outb(0xf0, cfg_base);
|
|
|
|
reg = inb(cfg_base+1);
|
|
|
|
dongle_id = ((reg>>6)&0x02) | ((reg>>5)&0x01);
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), probing dongle_id=%d, dongle_types=%s\n", __func__,
|
2005-04-17 00:20:36 +02:00
|
|
|
dongle_id, dongle_types[dongle_id]);
|
|
|
|
|
|
|
|
/* Exit configuration */
|
|
|
|
outb(0xbb, cfg_base);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return dongle_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_interrupt (irq, dev_id, regs)
|
|
|
|
*
|
|
|
|
* An interrupt from the chip has arrived. Time to do some work
|
|
|
|
*
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 15:55:46 +02:00
|
|
|
static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-10-06 20:56:04 +02:00
|
|
|
struct net_device *dev = dev_id;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
int ret;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_lock(&self->lock);
|
|
|
|
|
|
|
|
/* Dispatch interrupt handler for the current speed */
|
|
|
|
if (self->io.speed > 115200)
|
|
|
|
ret = ali_ircc_fir_interrupt(self);
|
|
|
|
else
|
|
|
|
ret = ali_ircc_sir_interrupt(self);
|
|
|
|
|
|
|
|
spin_unlock(&self->lock);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_fir_interrupt(irq, struct ali_ircc_cb *self)
|
|
|
|
*
|
|
|
|
* Handle MIR/FIR interrupt
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
__u8 eir, OldMessageCount;
|
|
|
|
int iobase, tmp;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
self->InterruptID = inb(iobase+FIR_IIR);
|
|
|
|
self->BusStatus = inb(iobase+FIR_BSR);
|
|
|
|
|
|
|
|
OldMessageCount = (self->LineStatus + 1) & 0x07;
|
|
|
|
self->LineStatus = inb(iobase+FIR_LSR);
|
|
|
|
//self->ier = inb(iobase+FIR_IER); 2000/12/1 04:32PM
|
|
|
|
eir = self->InterruptID & self->ier; /* Mask out the interesting ones */
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), self->InterruptID = %x\n", __func__,self->InterruptID);
|
|
|
|
IRDA_DEBUG(1, "%s(), self->LineStatus = %x\n", __func__,self->LineStatus);
|
|
|
|
IRDA_DEBUG(1, "%s(), self->ier = %x\n", __func__,self->ier);
|
|
|
|
IRDA_DEBUG(1, "%s(), eir = %x\n", __func__,eir);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Disable interrupts */
|
|
|
|
SetCOMInterrupts(self, FALSE);
|
|
|
|
|
|
|
|
/* Tx or Rx Interrupt */
|
|
|
|
|
|
|
|
if (eir & IIR_EOM)
|
|
|
|
{
|
|
|
|
if (self->io.direction == IO_XMIT) /* TX */
|
|
|
|
{
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Tx) *******\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if(ali_ircc_dma_xmit_complete(self))
|
|
|
|
{
|
|
|
|
if (irda_device_txqueue_empty(self->netdev))
|
|
|
|
{
|
|
|
|
/* Prepare for receive */
|
|
|
|
ali_ircc_dma_receive(self);
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else /* RX */
|
|
|
|
{
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Rx) *******\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if(OldMessageCount > ((self->LineStatus+1) & 0x07))
|
|
|
|
{
|
|
|
|
self->rcvFramesOverflow = TRUE;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ********\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ali_ircc_dma_receive_complete(self))
|
|
|
|
{
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* receive complete ********\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* Not receive complete ********\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
self->ier = IER_EOM | IER_TIMER;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Timer Interrupt */
|
|
|
|
else if (eir & IIR_TIMER)
|
|
|
|
{
|
|
|
|
if(OldMessageCount > ((self->LineStatus+1) & 0x07))
|
|
|
|
{
|
|
|
|
self->rcvFramesOverflow = TRUE;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE *******\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
/* Disable Timer */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
tmp = inb(iobase+FIR_CR);
|
|
|
|
outb( tmp& ~CR_TIMER_EN, iobase+FIR_CR);
|
|
|
|
|
|
|
|
/* Check if this is a Tx timer interrupt */
|
|
|
|
if (self->io.direction == IO_XMIT)
|
|
|
|
{
|
|
|
|
ali_ircc_dma_xmit(self);
|
|
|
|
|
|
|
|
/* Interrupt on EOM */
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
|
|
|
|
}
|
|
|
|
else /* Rx */
|
|
|
|
{
|
|
|
|
if(ali_ircc_dma_receive_complete(self))
|
|
|
|
{
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->ier = IER_EOM | IER_TIMER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore Interrupt */
|
|
|
|
SetCOMInterrupts(self, TRUE);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ---------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
return IRQ_RETVAL(eir);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_sir_interrupt (irq, self, eir)
|
|
|
|
*
|
|
|
|
* Handle SIR interrupt
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static irqreturn_t ali_ircc_sir_interrupt(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int iobase;
|
|
|
|
int iir, lsr;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.sir_base;
|
|
|
|
|
|
|
|
iir = inb(iobase+UART_IIR) & UART_IIR_ID;
|
|
|
|
if (iir) {
|
|
|
|
/* Clear interrupt */
|
|
|
|
lsr = inb(iobase+UART_LSR);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", __func__,
|
2005-04-17 00:20:36 +02:00
|
|
|
iir, lsr, iobase);
|
|
|
|
|
|
|
|
switch (iir)
|
|
|
|
{
|
|
|
|
case UART_IIR_RLSI:
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), RLSI\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
case UART_IIR_RDI:
|
|
|
|
/* Receive interrupt */
|
|
|
|
ali_ircc_sir_receive(self);
|
|
|
|
break;
|
|
|
|
case UART_IIR_THRI:
|
|
|
|
if (lsr & UART_LSR_THRE)
|
|
|
|
{
|
|
|
|
/* Transmitter ready for data */
|
|
|
|
ali_ircc_sir_write_wakeup(self);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n", __func__, iir);
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return IRQ_RETVAL(iir);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_sir_receive (self)
|
|
|
|
*
|
|
|
|
* Receive one frame from the infrared port
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void ali_ircc_sir_receive(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int boguscount = 0;
|
|
|
|
int iobase;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
IRDA_ASSERT(self != NULL, return;);
|
|
|
|
|
|
|
|
iobase = self->io.sir_base;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive all characters in Rx FIFO, unwrap and unstuff them.
|
|
|
|
* async_unwrap_char will deliver all found frames
|
|
|
|
*/
|
|
|
|
do {
|
2009-01-06 19:40:43 +01:00
|
|
|
async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
|
2005-04-17 00:20:36 +02:00
|
|
|
inb(iobase+UART_RX));
|
|
|
|
|
|
|
|
/* Make sure we don't stay here too long */
|
|
|
|
if (boguscount++ > 32) {
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2,"%s(), breaking!\n", __func__);
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (inb(iobase+UART_LSR) & UART_LSR_DR);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_sir_write_wakeup (tty)
|
|
|
|
*
|
|
|
|
* Called by the driver when there's room for more data. If we have
|
|
|
|
* more packets to send, we send them here.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int actual = 0;
|
|
|
|
int iobase;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return;);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.sir_base;
|
|
|
|
|
|
|
|
/* Finished with frame? */
|
|
|
|
if (self->tx_buff.len > 0)
|
|
|
|
{
|
|
|
|
/* Write data left in transmit buffer */
|
|
|
|
actual = ali_ircc_sir_write(iobase, self->io.fifo_size,
|
|
|
|
self->tx_buff.data, self->tx_buff.len);
|
|
|
|
self->tx_buff.data += actual;
|
|
|
|
self->tx_buff.len -= actual;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (self->new_speed)
|
|
|
|
{
|
|
|
|
/* We must wait until all data are gone */
|
|
|
|
while(!(inb(iobase+UART_LSR) & UART_LSR_TEMT))
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), UART_LSR_THRE\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), Changing speed! self->new_speed = %d\n", __func__ , self->new_speed);
|
2005-04-17 00:20:36 +02:00
|
|
|
ali_ircc_change_speed(self, self->new_speed);
|
|
|
|
self->new_speed = 0;
|
|
|
|
|
|
|
|
// benjamin 2000/11/10 06:32PM
|
|
|
|
if (self->io.speed > 115200)
|
|
|
|
{
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(2, "%s(), ali_ircc_change_speed from UART_LSR_TEMT\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
// SetCOMInterrupts(self, TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
netif_wake_queue(self->netdev);
|
|
|
|
}
|
|
|
|
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.tx_packets++;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Turn on receive interrupts */
|
|
|
|
outb(UART_IER_RDI, iobase+UART_IER);
|
|
|
|
}
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud)
|
|
|
|
{
|
|
|
|
struct net_device *dev = self->netdev;
|
|
|
|
int iobase;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(2, "%s(), setting speed = %d\n", __func__ , baud);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* This function *must* be called with irq off and spin-lock.
|
|
|
|
* - Jean II */
|
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
SetCOMInterrupts(self, FALSE); // 2000/11/24 11:43AM
|
|
|
|
|
|
|
|
/* Go to MIR, FIR Speed */
|
|
|
|
if (baud > 115200)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
ali_ircc_fir_change_speed(self, baud);
|
|
|
|
|
|
|
|
/* Install FIR xmit handler*/
|
2009-03-20 20:35:40 +01:00
|
|
|
dev->netdev_ops = &ali_ircc_fir_ops;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Enable Interuupt */
|
|
|
|
self->ier = IER_EOM; // benjamin 2000/11/20 07:24PM
|
|
|
|
|
2012-12-27 17:33:02 +01:00
|
|
|
/* Be ready for incoming frames */
|
2005-04-17 00:20:36 +02:00
|
|
|
ali_ircc_dma_receive(self); // benajmin 2000/11/8 07:46PM not complete
|
|
|
|
}
|
|
|
|
/* Go to SIR Speed */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ali_ircc_sir_change_speed(self, baud);
|
|
|
|
|
|
|
|
/* Install SIR xmit handler*/
|
2009-03-20 20:35:40 +01:00
|
|
|
dev->netdev_ops = &ali_ircc_sir_ops;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetCOMInterrupts(self, TRUE); // 2000/11/24 11:43AM
|
|
|
|
|
|
|
|
netif_wake_queue(self->netdev);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud)
|
|
|
|
{
|
|
|
|
|
|
|
|
int iobase;
|
2012-06-04 14:44:18 +02:00
|
|
|
struct ali_ircc_cb *self = priv;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct net_device *dev;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return;);
|
|
|
|
|
|
|
|
dev = self->netdev;
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), self->io.speed = %d, change to speed = %d\n", __func__ ,self->io.speed,baud);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Come from SIR speed */
|
|
|
|
if(self->io.speed <=115200)
|
|
|
|
{
|
|
|
|
SIR2FIR(iobase);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update accounting for new speed */
|
|
|
|
self->io.speed = baud;
|
|
|
|
|
|
|
|
// Set Dongle Speed mode
|
|
|
|
ali_ircc_change_dongle_speed(self, baud);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_sir_change_speed (self, speed)
|
|
|
|
*
|
|
|
|
* Set speed of IrDA port to specified baudrate
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
|
|
|
|
{
|
2012-06-04 14:44:18 +02:00
|
|
|
struct ali_ircc_cb *self = priv;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
int iobase;
|
|
|
|
int fcr; /* FIFO control reg */
|
|
|
|
int lcr; /* Line control reg */
|
|
|
|
int divisor;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), Setting speed to: %d\n", __func__ , speed);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return;);
|
|
|
|
|
|
|
|
iobase = self->io.sir_base;
|
|
|
|
|
|
|
|
/* Come from MIR or FIR speed */
|
|
|
|
if(self->io.speed >115200)
|
|
|
|
{
|
|
|
|
// Set Dongle Speed mode first
|
|
|
|
ali_ircc_change_dongle_speed(self, speed);
|
|
|
|
|
|
|
|
FIR2SIR(iobase);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear Line and Auxiluary status registers 2000/11/24 11:47AM
|
|
|
|
|
|
|
|
inb(iobase+UART_LSR);
|
|
|
|
inb(iobase+UART_SCR);
|
|
|
|
|
|
|
|
/* Update accounting for new speed */
|
|
|
|
self->io.speed = speed;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&self->lock, flags);
|
|
|
|
|
|
|
|
divisor = 115200/speed;
|
|
|
|
|
|
|
|
fcr = UART_FCR_ENABLE_FIFO;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
|
|
|
|
* almost 1,7 ms at 19200 bps. At speeds above that we can just forget
|
|
|
|
* about this timeout since it will always be fast enough.
|
|
|
|
*/
|
|
|
|
if (self->io.speed < 38400)
|
|
|
|
fcr |= UART_FCR_TRIGGER_1;
|
|
|
|
else
|
|
|
|
fcr |= UART_FCR_TRIGGER_14;
|
|
|
|
|
|
|
|
/* IrDA ports use 8N1 */
|
|
|
|
lcr = UART_LCR_WLEN8;
|
|
|
|
|
|
|
|
outb(UART_LCR_DLAB | lcr, iobase+UART_LCR); /* Set DLAB */
|
|
|
|
outb(divisor & 0xff, iobase+UART_DLL); /* Set speed */
|
|
|
|
outb(divisor >> 8, iobase+UART_DLM);
|
|
|
|
outb(lcr, iobase+UART_LCR); /* Set 8N1 */
|
|
|
|
outb(fcr, iobase+UART_FCR); /* Enable FIFO's */
|
|
|
|
|
2011-03-31 03:57:33 +02:00
|
|
|
/* without this, the connection will be broken after come back from FIR speed,
|
2005-04-17 00:20:36 +02:00
|
|
|
but with this, the SIR connection is harder to established */
|
|
|
|
outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase+UART_MCR);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed)
|
|
|
|
{
|
|
|
|
|
2012-06-04 14:44:18 +02:00
|
|
|
struct ali_ircc_cb *self = priv;
|
2005-04-17 00:20:36 +02:00
|
|
|
int iobase,dongle_id;
|
|
|
|
int tmp = 0;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.fir_base; /* or iobase = self->io.sir_base; */
|
|
|
|
dongle_id = self->io.dongle_id;
|
|
|
|
|
|
|
|
/* We are already locked, no need to do it again */
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), Set Speed for %s , Speed = %d\n", __func__ , dongle_types[dongle_id], speed);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
tmp = inb(iobase+FIR_IRDA_CR);
|
|
|
|
|
|
|
|
/* IBM type dongle */
|
|
|
|
if(dongle_id == 0)
|
|
|
|
{
|
|
|
|
if(speed == 4000000)
|
|
|
|
{
|
|
|
|
// __ __
|
|
|
|
// SD/MODE __| |__ __
|
|
|
|
// __ __
|
|
|
|
// IRTX __ __| |__
|
|
|
|
// T1 T2 T3 T4 T5
|
|
|
|
|
|
|
|
tmp &= ~IRDA_CR_HDLC; // HDLC=0
|
|
|
|
tmp |= IRDA_CR_CRC; // CRC=1
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
|
|
|
|
// T1 -> SD/MODE:0 IRTX:0
|
|
|
|
tmp &= ~0x09;
|
|
|
|
tmp |= 0x02;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// T2 -> SD/MODE:1 IRTX:0
|
|
|
|
tmp &= ~0x01;
|
|
|
|
tmp |= 0x0a;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// T3 -> SD/MODE:1 IRTX:1
|
|
|
|
tmp |= 0x0b;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// T4 -> SD/MODE:0 IRTX:1
|
|
|
|
tmp &= ~0x08;
|
|
|
|
tmp |= 0x03;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// T5 -> SD/MODE:0 IRTX:0
|
|
|
|
tmp &= ~0x09;
|
|
|
|
tmp |= 0x02;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// reset -> Normal TX output Signal
|
|
|
|
outb(tmp & ~0x02, iobase+FIR_IRDA_CR);
|
|
|
|
}
|
|
|
|
else /* speed <=1152000 */
|
|
|
|
{
|
|
|
|
// __
|
|
|
|
// SD/MODE __| |__
|
|
|
|
//
|
|
|
|
// IRTX ________
|
|
|
|
// T1 T2 T3
|
|
|
|
|
|
|
|
/* MIR 115200, 57600 */
|
|
|
|
if (speed==1152000)
|
|
|
|
{
|
|
|
|
tmp |= 0xA0; //HDLC=1, 1.152Mbps=1
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp &=~0x80; //HDLC 0.576Mbps
|
|
|
|
tmp |= 0x20; //HDLC=1,
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp |= IRDA_CR_CRC; // CRC=1
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
|
|
|
|
/* MIR 115200, 57600 */
|
|
|
|
|
|
|
|
//switch_bank(iobase, BANK2);
|
|
|
|
// T1 -> SD/MODE:0 IRTX:0
|
|
|
|
tmp &= ~0x09;
|
|
|
|
tmp |= 0x02;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// T2 -> SD/MODE:1 IRTX:0
|
|
|
|
tmp &= ~0x01;
|
|
|
|
tmp |= 0x0a;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
|
|
|
|
// T3 -> SD/MODE:0 IRTX:0
|
|
|
|
tmp &= ~0x09;
|
|
|
|
tmp |= 0x02;
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
// reset -> Normal TX output Signal
|
|
|
|
outb(tmp & ~0x02, iobase+FIR_IRDA_CR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dongle_id == 1) /* HP HDSL-3600 */
|
|
|
|
{
|
|
|
|
switch(speed)
|
|
|
|
{
|
|
|
|
case 4000000:
|
|
|
|
tmp &= ~IRDA_CR_HDLC; // HDLC=0
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1152000:
|
|
|
|
tmp |= 0xA0; // HDLC=1, 1.152Mbps=1
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 576000:
|
|
|
|
tmp &=~0x80; // HDLC 0.576Mbps
|
|
|
|
tmp |= 0x20; // HDLC=1,
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp |= IRDA_CR_CRC; // CRC=1
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
}
|
|
|
|
else /* HP HDSL-1100 */
|
|
|
|
{
|
|
|
|
if(speed <= 115200) /* SIR */
|
|
|
|
{
|
|
|
|
|
|
|
|
tmp &= ~IRDA_CR_FIR_SIN; // HP sin select = 0
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
}
|
|
|
|
else /* MIR FIR */
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(speed)
|
|
|
|
{
|
|
|
|
case 4000000:
|
|
|
|
tmp &= ~IRDA_CR_HDLC; // HDLC=0
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1152000:
|
|
|
|
tmp |= 0xA0; // HDLC=1, 1.152Mbps=1
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 576000:
|
|
|
|
tmp &=~0x80; // HDLC 0.576Mbps
|
|
|
|
tmp |= 0x20; // HDLC=1,
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp |= IRDA_CR_CRC; // CRC=1
|
|
|
|
tmp |= IRDA_CR_FIR_SIN; // HP sin select = 1
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(tmp, iobase+FIR_IRDA_CR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_sir_write (driver)
|
|
|
|
*
|
|
|
|
* Fill Tx FIFO with transmit data
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
|
|
|
|
{
|
|
|
|
int actual = 0;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Tx FIFO should be empty! */
|
|
|
|
if (!(inb(iobase+UART_LSR) & UART_LSR_THRE)) {
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(0, "%s(), failed, fifo not empty!\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill FIFO with current frame */
|
|
|
|
while ((fifo_size-- > 0) && (actual < len)) {
|
|
|
|
/* Transmit next byte */
|
|
|
|
outb(buf[actual], iobase+UART_TX);
|
|
|
|
|
|
|
|
actual++;
|
|
|
|
}
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
return actual;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_net_open (dev)
|
|
|
|
*
|
|
|
|
* Start the device
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_net_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
int iobase;
|
|
|
|
char hwname[32];
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(dev != NULL, return -1;);
|
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return 0;);
|
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
/* Request IRQ and install Interrupt Handler */
|
|
|
|
if (request_irq(self->io.irq, ali_ircc_interrupt, 0, dev->name, dev))
|
|
|
|
{
|
2006-05-26 01:21:10 +02:00
|
|
|
IRDA_WARNING("%s, unable to allocate irq=%d\n",
|
|
|
|
ALI_IRCC_DRIVER_NAME,
|
2005-04-17 00:20:36 +02:00
|
|
|
self->io.irq);
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Always allocate the DMA channel after the IRQ, and clean up on
|
|
|
|
* failure.
|
|
|
|
*/
|
|
|
|
if (request_dma(self->io.dma, dev->name)) {
|
2006-05-26 01:21:10 +02:00
|
|
|
IRDA_WARNING("%s, unable to allocate dma=%d\n",
|
|
|
|
ALI_IRCC_DRIVER_NAME,
|
2005-04-17 00:20:36 +02:00
|
|
|
self->io.dma);
|
2012-03-11 12:49:02 +01:00
|
|
|
free_irq(self->io.irq, dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn on interrups */
|
|
|
|
outb(UART_IER_RDI , iobase+UART_IER);
|
|
|
|
|
|
|
|
/* Ready to play! */
|
|
|
|
netif_start_queue(dev); //benjamin by irport
|
|
|
|
|
|
|
|
/* Give self a hardware name */
|
|
|
|
sprintf(hwname, "ALI-FIR @ 0x%03x", self->io.fir_base);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open new IrLAP layer instance, now that everything should be
|
|
|
|
* initialized properly
|
|
|
|
*/
|
|
|
|
self->irlap = irlap_open(dev, &self->qos, hwname);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_net_close (dev)
|
|
|
|
*
|
|
|
|
* Stop the device
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_net_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
//int iobase;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(dev != NULL, return -1;);
|
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
IRDA_ASSERT(self != NULL, return 0;);
|
|
|
|
|
|
|
|
/* Stop device */
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
/* Stop and remove instance of IrLAP */
|
|
|
|
if (self->irlap)
|
|
|
|
irlap_close(self->irlap);
|
|
|
|
self->irlap = NULL;
|
|
|
|
|
|
|
|
disable_dma(self->io.dma);
|
|
|
|
|
|
|
|
/* Disable interrupts */
|
|
|
|
SetCOMInterrupts(self, FALSE);
|
|
|
|
|
|
|
|
free_irq(self->io.irq, dev);
|
|
|
|
free_dma(self->io.dma);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_fir_hard_xmit (skb, dev)
|
|
|
|
*
|
|
|
|
* Transmit the frame
|
|
|
|
*
|
|
|
|
*/
|
2009-08-31 21:50:50 +02:00
|
|
|
static netdev_tx_t ali_ircc_fir_hard_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
unsigned long flags;
|
|
|
|
int iobase;
|
|
|
|
__u32 speed;
|
|
|
|
int mtt, diff;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
/* Make sure tests *& speed change are atomic */
|
|
|
|
spin_lock_irqsave(&self->lock, flags);
|
|
|
|
|
|
|
|
/* Note : you should make sure that speed changes are not going
|
|
|
|
* to corrupt any outgoing frame. Look at nsc-ircc for the gory
|
|
|
|
* details - Jean II */
|
|
|
|
|
|
|
|
/* Check if we need to change the speed */
|
|
|
|
speed = irda_get_next_speed(skb);
|
|
|
|
if ((speed != self->io.speed) && (speed != -1)) {
|
|
|
|
/* Check for empty frame */
|
|
|
|
if (!skb->len) {
|
|
|
|
ali_ircc_change_speed(self, speed);
|
|
|
|
dev->trans_start = jiffies;
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
dev_kfree_skb(skb);
|
2009-06-23 08:03:08 +02:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-17 00:20:36 +02:00
|
|
|
} else
|
|
|
|
self->new_speed = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register and copy this frame to DMA memory */
|
|
|
|
self->tx_fifo.queue[self->tx_fifo.free].start = self->tx_fifo.tail;
|
|
|
|
self->tx_fifo.queue[self->tx_fifo.free].len = skb->len;
|
|
|
|
self->tx_fifo.tail += skb->len;
|
|
|
|
|
2009-01-06 19:40:43 +01:00
|
|
|
dev->stats.tx_bytes += skb->len;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-03-27 23:55:52 +02:00
|
|
|
skb_copy_from_linear_data(skb, self->tx_fifo.queue[self->tx_fifo.free].start,
|
|
|
|
skb->len);
|
2005-04-17 00:20:36 +02:00
|
|
|
self->tx_fifo.len++;
|
|
|
|
self->tx_fifo.free++;
|
|
|
|
|
|
|
|
/* Start transmit only if there is currently no transmit going on */
|
|
|
|
if (self->tx_fifo.len == 1)
|
|
|
|
{
|
|
|
|
/* Check if we must wait the min turn time or not */
|
|
|
|
mtt = irda_get_mtt(skb);
|
|
|
|
|
|
|
|
if (mtt)
|
|
|
|
{
|
|
|
|
/* Check how much time we have used already */
|
|
|
|
do_gettimeofday(&self->now);
|
|
|
|
|
|
|
|
diff = self->now.tv_usec - self->stamp.tv_usec;
|
|
|
|
/* self->stamp is set from ali_ircc_dma_receive_complete() */
|
|
|
|
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), ******* diff = %d *******\n", __func__ , diff);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (diff < 0)
|
|
|
|
diff += 1000000;
|
|
|
|
|
|
|
|
/* Check if the mtt is larger than the time we have
|
|
|
|
* already used by all the protocol processing
|
|
|
|
*/
|
|
|
|
if (mtt > diff)
|
|
|
|
{
|
|
|
|
mtt -= diff;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use timer if delay larger than 1000 us, and
|
|
|
|
* use udelay for smaller values which should
|
|
|
|
* be acceptable
|
|
|
|
*/
|
|
|
|
if (mtt > 500)
|
|
|
|
{
|
|
|
|
/* Adjust for timer resolution */
|
|
|
|
mtt = (mtt+250) / 500; /* 4 discard, 5 get advanced, Let's round off */
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ************** mtt = %d ***********\n", __func__ , mtt);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Setup timer */
|
|
|
|
if (mtt == 1) /* 500 us */
|
|
|
|
{
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(TIMER_IIR_500, iobase+FIR_TIMER_IIR);
|
|
|
|
}
|
|
|
|
else if (mtt == 2) /* 1 ms */
|
|
|
|
{
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(TIMER_IIR_1ms, iobase+FIR_TIMER_IIR);
|
|
|
|
}
|
|
|
|
else /* > 2ms -> 4ms */
|
|
|
|
{
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(TIMER_IIR_2ms, iobase+FIR_TIMER_IIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Start timer */
|
|
|
|
outb(inb(iobase+FIR_CR) | CR_TIMER_EN, iobase+FIR_CR);
|
|
|
|
self->io.direction = IO_XMIT;
|
|
|
|
|
|
|
|
/* Enable timer interrupt */
|
|
|
|
self->ier = IER_TIMER;
|
|
|
|
SetCOMInterrupts(self, TRUE);
|
|
|
|
|
|
|
|
/* Timer will take care of the rest */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
udelay(mtt);
|
|
|
|
} // if (if (mtt > diff)
|
|
|
|
}// if (mtt)
|
|
|
|
|
|
|
|
/* Enable EOM interrupt */
|
|
|
|
self->ier = IER_EOM;
|
|
|
|
SetCOMInterrupts(self, TRUE);
|
|
|
|
|
|
|
|
/* Transmit frame */
|
|
|
|
ali_ircc_dma_xmit(self);
|
|
|
|
} // if (self->tx_fifo.len == 1)
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
/* Not busy transmitting anymore if window is not full */
|
|
|
|
if (self->tx_fifo.free < MAX_TX_WINDOW)
|
|
|
|
netif_wake_queue(self->netdev);
|
|
|
|
|
|
|
|
/* Restore bank register */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
|
|
|
|
dev->trans_start = jiffies;
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2009-06-23 08:03:08 +02:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ali_ircc_dma_xmit(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int iobase, tmp;
|
|
|
|
unsigned char FIFO_OPTI, Hi, Lo;
|
|
|
|
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
/* FIFO threshold , this method comes from NDIS5 code */
|
|
|
|
|
|
|
|
if(self->tx_fifo.queue[self->tx_fifo.ptr].len < TX_FIFO_Threshold)
|
|
|
|
FIFO_OPTI = self->tx_fifo.queue[self->tx_fifo.ptr].len-1;
|
|
|
|
else
|
|
|
|
FIFO_OPTI = TX_FIFO_Threshold;
|
|
|
|
|
|
|
|
/* Disable DMA */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(inb(iobase+FIR_CR) & ~CR_DMA_EN, iobase+FIR_CR);
|
|
|
|
|
|
|
|
self->io.direction = IO_XMIT;
|
|
|
|
|
|
|
|
irda_setup_dma(self->io.dma,
|
|
|
|
((u8 *)self->tx_fifo.queue[self->tx_fifo.ptr].start -
|
|
|
|
self->tx_buff.head) + self->tx_buff_dma,
|
|
|
|
self->tx_fifo.queue[self->tx_fifo.ptr].len,
|
|
|
|
DMA_TX_MODE);
|
|
|
|
|
|
|
|
/* Reset Tx FIFO */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
outb(LCR_A_FIFO_RESET, iobase+FIR_LCR_A);
|
|
|
|
|
|
|
|
/* Set Tx FIFO threshold */
|
|
|
|
if (self->fifo_opti_buf!=FIFO_OPTI)
|
|
|
|
{
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(FIFO_OPTI, iobase+FIR_FIFO_TR) ;
|
|
|
|
self->fifo_opti_buf=FIFO_OPTI;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Tx DMA threshold */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(TX_DMA_Threshold, iobase+FIR_DMA_TR);
|
|
|
|
|
|
|
|
/* Set max Tx frame size */
|
|
|
|
Hi = (self->tx_fifo.queue[self->tx_fifo.ptr].len >> 8) & 0x0f;
|
|
|
|
Lo = self->tx_fifo.queue[self->tx_fifo.ptr].len & 0xff;
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
outb(Hi, iobase+FIR_TX_DSR_HI);
|
|
|
|
outb(Lo, iobase+FIR_TX_DSR_LO);
|
|
|
|
|
|
|
|
/* Disable SIP , Disable Brick Wall (we don't support in TX mode), Change to TX mode */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
tmp = inb(iobase+FIR_LCR_B);
|
|
|
|
tmp &= ~0x20; // Disable SIP
|
|
|
|
outb(((unsigned char)(tmp & 0x3f) | LCR_B_TX_MODE) & ~LCR_B_BW, iobase+FIR_LCR_B);
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), *** Change to TX mode: FIR_LCR_B = 0x%x ***\n", __func__ , inb(iobase+FIR_LCR_B));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
outb(0, iobase+FIR_LSR);
|
|
|
|
|
|
|
|
/* Enable DMA and Burst Mode */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(inb(iobase+FIR_CR) | CR_DMA_EN | CR_DMA_BURST, iobase+FIR_CR);
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int iobase;
|
|
|
|
int ret = TRUE;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
/* Disable DMA */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(inb(iobase+FIR_CR) & ~CR_DMA_EN, iobase+FIR_CR);
|
|
|
|
|
|
|
|
/* Check for underrun! */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
if((inb(iobase+FIR_LSR) & LSR_FRAME_ABORT) == LSR_FRAME_ABORT)
|
|
|
|
|
|
|
|
{
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_ERROR("%s(), ********* LSR_FRAME_ABORT *********\n", __func__);
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.tx_errors++;
|
|
|
|
self->netdev->stats.tx_fifo_errors++;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.tx_packets++;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we need to change the speed */
|
|
|
|
if (self->new_speed)
|
|
|
|
{
|
|
|
|
ali_ircc_change_speed(self, self->new_speed);
|
|
|
|
self->new_speed = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finished with this frame, so prepare for next */
|
|
|
|
self->tx_fifo.ptr++;
|
|
|
|
self->tx_fifo.len--;
|
|
|
|
|
|
|
|
/* Any frames to be sent back-to-back? */
|
|
|
|
if (self->tx_fifo.len)
|
|
|
|
{
|
|
|
|
ali_ircc_dma_xmit(self);
|
|
|
|
|
|
|
|
/* Not finished yet! */
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* Reset Tx FIFO info */
|
|
|
|
self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
|
|
|
|
self->tx_fifo.tail = self->tx_buff.head;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure we have room for more frames */
|
|
|
|
if (self->tx_fifo.free < MAX_TX_WINDOW) {
|
|
|
|
/* Not busy transmitting anymore */
|
|
|
|
/* Tell the network layer, that we can accept more frames */
|
|
|
|
netif_wake_queue(self->netdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_dma_receive (self)
|
|
|
|
*
|
|
|
|
* Get ready for receiving a frame. The device will initiate a DMA
|
|
|
|
* if it starts to receive a frame.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_dma_receive(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
int iobase, tmp;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
/* Reset Tx FIFO info */
|
|
|
|
self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
|
|
|
|
self->tx_fifo.tail = self->tx_buff.head;
|
|
|
|
|
|
|
|
/* Disable DMA */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(inb(iobase+FIR_CR) & ~CR_DMA_EN, iobase+FIR_CR);
|
|
|
|
|
|
|
|
/* Reset Message Count */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
outb(0x07, iobase+FIR_LSR);
|
|
|
|
|
|
|
|
self->rcvFramesOverflow = FALSE;
|
|
|
|
|
|
|
|
self->LineStatus = inb(iobase+FIR_LSR) ;
|
|
|
|
|
|
|
|
/* Reset Rx FIFO info */
|
|
|
|
self->io.direction = IO_RECV;
|
|
|
|
self->rx_buff.data = self->rx_buff.head;
|
|
|
|
|
|
|
|
/* Reset Rx FIFO */
|
|
|
|
// switch_bank(iobase, BANK0);
|
|
|
|
outb(LCR_A_FIFO_RESET, iobase+FIR_LCR_A);
|
|
|
|
|
|
|
|
self->st_fifo.len = self->st_fifo.pending_bytes = 0;
|
|
|
|
self->st_fifo.tail = self->st_fifo.head = 0;
|
|
|
|
|
|
|
|
irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
|
|
|
|
DMA_RX_MODE);
|
|
|
|
|
|
|
|
/* Set Receive Mode,Brick Wall */
|
|
|
|
//switch_bank(iobase, BANK0);
|
|
|
|
tmp = inb(iobase+FIR_LCR_B);
|
|
|
|
outb((unsigned char)(tmp &0x3f) | LCR_B_RX_MODE | LCR_B_BW , iobase + FIR_LCR_B); // 2000/12/1 05:16PM
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(1, "%s(), *** Change To RX mode: FIR_LCR_B = 0x%x ***\n", __func__ , inb(iobase+FIR_LCR_B));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Set Rx Threshold */
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(RX_FIFO_Threshold, iobase+FIR_FIFO_TR);
|
|
|
|
outb(RX_DMA_Threshold, iobase+FIR_DMA_TR);
|
|
|
|
|
|
|
|
/* Enable DMA and Burst Mode */
|
|
|
|
// switch_bank(iobase, BANK1);
|
|
|
|
outb(CR_DMA_EN | CR_DMA_BURST, iobase+FIR_CR);
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
struct st_fifo *st_fifo;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
__u8 status, MessageCount;
|
|
|
|
int len, i, iobase, val;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
st_fifo = &self->st_fifo;
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
MessageCount = inb(iobase+ FIR_LSR)&0x07;
|
|
|
|
|
|
|
|
if (MessageCount > 0)
|
2011-05-10 10:16:21 +02:00
|
|
|
IRDA_DEBUG(0, "%s(), Message count = %d,\n", __func__ , MessageCount);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
for (i=0; i<=MessageCount; i++)
|
|
|
|
{
|
|
|
|
/* Bank 0 */
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
status = inb(iobase+FIR_LSR);
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK2);
|
|
|
|
len = inb(iobase+FIR_RX_DSR_HI) & 0x0f;
|
|
|
|
len = len << 8;
|
|
|
|
len |= inb(iobase+FIR_RX_DSR_LO);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), RX Length = 0x%.2x,\n", __func__ , len);
|
|
|
|
IRDA_DEBUG(1, "%s(), RX Status = 0x%.2x,\n", __func__ , status);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (st_fifo->tail >= MAX_RX_WINDOW) {
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(0, "%s(), window is full!\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
st_fifo->entries[st_fifo->tail].status = status;
|
|
|
|
st_fifo->entries[st_fifo->tail].len = len;
|
|
|
|
st_fifo->pending_bytes += len;
|
|
|
|
st_fifo->tail++;
|
|
|
|
st_fifo->len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<=MessageCount; i++)
|
|
|
|
{
|
|
|
|
/* Get first entry */
|
|
|
|
status = st_fifo->entries[st_fifo->head].status;
|
|
|
|
len = st_fifo->entries[st_fifo->head].len;
|
|
|
|
st_fifo->pending_bytes -= len;
|
|
|
|
st_fifo->head++;
|
|
|
|
st_fifo->len--;
|
|
|
|
|
|
|
|
/* Check for errors */
|
|
|
|
if ((status & 0xd8) || self->rcvFramesOverflow || (len==0))
|
|
|
|
{
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0,"%s(), ************* RX Errors ************\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Skip frame */
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_errors++;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
self->rx_buff.data += len;
|
|
|
|
|
|
|
|
if (status & LSR_FIFO_UR)
|
|
|
|
{
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_frame_errors++;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
if (status & LSR_FRAME_ERROR)
|
|
|
|
{
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_frame_errors++;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status & LSR_CRC_ERROR)
|
|
|
|
{
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_crc_errors++;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0,"%s(), ************* CRC Errors ************\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(self->rcvFramesOverflow)
|
|
|
|
{
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_frame_errors++;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
if(len == 0)
|
|
|
|
{
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_frame_errors++;
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 *********\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
if (st_fifo->pending_bytes < 32)
|
|
|
|
{
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
val = inb(iobase+FIR_BSR);
|
|
|
|
if ((val& BSR_FIFO_NOT_EMPTY)== 0x80)
|
|
|
|
{
|
2010-03-24 08:57:30 +01:00
|
|
|
IRDA_DEBUG(0, "%s(), ************* BSR_FIFO_NOT_EMPTY ************\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Put this entry back in fifo */
|
|
|
|
st_fifo->head--;
|
|
|
|
st_fifo->len++;
|
|
|
|
st_fifo->pending_bytes += len;
|
|
|
|
st_fifo->entries[st_fifo->head].status = status;
|
|
|
|
st_fifo->entries[st_fifo->head].len = len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DMA not finished yet, so try again
|
|
|
|
* later, set timer value, resolution
|
|
|
|
* 500 us
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
outb(TIMER_IIR_500, iobase+FIR_TIMER_IIR); // 2001/1/2 05:07PM
|
|
|
|
|
|
|
|
/* Enable Timer */
|
|
|
|
outb(inb(iobase+FIR_CR) | CR_TIMER_EN, iobase+FIR_CR);
|
|
|
|
|
|
|
|
return FALSE; /* I'll be back! */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remember the time we received this frame, so we can
|
|
|
|
* reduce the min turn time a bit since we will know
|
|
|
|
* how much time we have used for protocol processing
|
|
|
|
*/
|
|
|
|
do_gettimeofday(&self->stamp);
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(len+1);
|
|
|
|
if (skb == NULL)
|
|
|
|
{
|
|
|
|
IRDA_WARNING("%s(), memory squeeze, "
|
|
|
|
"dropping frame.\n",
|
2008-07-31 02:20:18 +02:00
|
|
|
__func__);
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_dropped++;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure IP header gets aligned */
|
|
|
|
skb_reserve(skb, 1);
|
|
|
|
|
|
|
|
/* Copy frame without CRC, CRC is removed by hardware*/
|
|
|
|
skb_put(skb, len);
|
2007-03-31 16:55:19 +02:00
|
|
|
skb_copy_to_linear_data(skb, self->rx_buff.data, len);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Move to next frame */
|
|
|
|
self->rx_buff.data += len;
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.rx_bytes += len;
|
|
|
|
self->netdev->stats.rx_packets++;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
skb->dev = self->netdev;
|
2007-03-19 23:30:44 +01:00
|
|
|
skb_reset_mac_header(skb);
|
2005-04-17 00:20:36 +02:00
|
|
|
skb->protocol = htons(ETH_P_IRDA);
|
|
|
|
netif_rx(skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_sir_hard_xmit (skb, dev)
|
|
|
|
*
|
|
|
|
* Transmit the frame!
|
|
|
|
*
|
|
|
|
*/
|
2009-08-31 21:50:50 +02:00
|
|
|
static netdev_tx_t ali_ircc_sir_hard_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
unsigned long flags;
|
|
|
|
int iobase;
|
|
|
|
__u32 speed;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-07-06 04:23:38 +02:00
|
|
|
IRDA_ASSERT(dev != NULL, return NETDEV_TX_OK;);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2009-07-06 04:23:38 +02:00
|
|
|
IRDA_ASSERT(self != NULL, return NETDEV_TX_OK;);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
iobase = self->io.sir_base;
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
/* Make sure tests *& speed change are atomic */
|
|
|
|
spin_lock_irqsave(&self->lock, flags);
|
|
|
|
|
|
|
|
/* Note : you should make sure that speed changes are not going
|
|
|
|
* to corrupt any outgoing frame. Look at nsc-ircc for the gory
|
|
|
|
* details - Jean II */
|
|
|
|
|
|
|
|
/* Check if we need to change the speed */
|
|
|
|
speed = irda_get_next_speed(skb);
|
|
|
|
if ((speed != self->io.speed) && (speed != -1)) {
|
|
|
|
/* Check for empty frame */
|
|
|
|
if (!skb->len) {
|
|
|
|
ali_ircc_change_speed(self, speed);
|
|
|
|
dev->trans_start = jiffies;
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
dev_kfree_skb(skb);
|
2009-06-23 08:03:08 +02:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-17 00:20:36 +02:00
|
|
|
} else
|
|
|
|
self->new_speed = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init tx buffer */
|
|
|
|
self->tx_buff.data = self->tx_buff.head;
|
|
|
|
|
|
|
|
/* Copy skb to tx_buff while wrapping, stuffing and making CRC */
|
|
|
|
self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
|
|
|
|
self->tx_buff.truesize);
|
|
|
|
|
2009-01-06 19:40:43 +01:00
|
|
|
self->netdev->stats.tx_bytes += self->tx_buff.len;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Turn on transmit finished interrupt. Will fire immediately! */
|
|
|
|
outb(UART_IER_THRI, iobase+UART_IER);
|
|
|
|
|
|
|
|
dev->trans_start = jiffies;
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-06-23 08:03:08 +02:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_net_ioctl (dev, rq, cmd)
|
|
|
|
*
|
|
|
|
* Process IOCTL commands for this device
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
|
|
|
struct if_irda_req *irq = (struct if_irda_req *) rq;
|
|
|
|
struct ali_ircc_cb *self;
|
|
|
|
unsigned long flags;
|
|
|
|
int ret = 0;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(dev != NULL, return -1;);
|
|
|
|
|
2008-11-13 08:38:14 +01:00
|
|
|
self = netdev_priv(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCSBANDWIDTH: /* Set bandwidth */
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), SIOCSBANDWIDTH\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* This function will also be used by IrLAP to change the
|
|
|
|
* speed, so we still must allow for speed change within
|
|
|
|
* interrupt context.
|
|
|
|
*/
|
|
|
|
if (!in_interrupt() && !capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&self->lock, flags);
|
|
|
|
ali_ircc_change_speed(self, irq->ifr_baudrate);
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
break;
|
|
|
|
case SIOCSMEDIABUSY: /* Set media busy */
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), SIOCSMEDIABUSY\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
irda_device_set_media_busy(self->netdev, TRUE);
|
|
|
|
break;
|
|
|
|
case SIOCGRECEIVING: /* Check if we are receiving right now */
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), SIOCGRECEIVING\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
/* This is protected */
|
|
|
|
irq->ifr_receiving = ali_ircc_is_receiving(self);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ali_ircc_is_receiving (self)
|
|
|
|
*
|
|
|
|
* Return TRUE is we are currently receiving a frame
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ali_ircc_is_receiving(struct ali_ircc_cb *self)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int status = FALSE;
|
|
|
|
int iobase;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ---------------- Start -----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return FALSE;);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&self->lock, flags);
|
|
|
|
|
|
|
|
if (self->io.speed > 115200)
|
|
|
|
{
|
|
|
|
iobase = self->io.fir_base;
|
|
|
|
|
|
|
|
switch_bank(iobase, BANK1);
|
|
|
|
if((inb(iobase+FIR_FIFO_FR) & 0x3f) != 0)
|
|
|
|
{
|
|
|
|
/* We are receiving something */
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), We are receiving something\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
status = TRUE;
|
|
|
|
}
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = (self->rx_buff.state != OUTSIDE_FRAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&self->lock, flags);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
static int ali_ircc_suspend(struct platform_device *dev, pm_message_t state)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-05-26 01:21:10 +02:00
|
|
|
struct ali_ircc_cb *self = platform_get_drvdata(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
IRDA_MESSAGE("%s, Suspending\n", ALI_IRCC_DRIVER_NAME);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (self->io.suspended)
|
2006-05-26 01:21:10 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
ali_ircc_net_close(self->netdev);
|
|
|
|
|
|
|
|
self->io.suspended = 1;
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
static int ali_ircc_resume(struct platform_device *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-05-26 01:21:10 +02:00
|
|
|
struct ali_ircc_cb *self = platform_get_drvdata(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (!self->io.suspended)
|
2006-05-26 01:21:10 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
ali_ircc_net_open(self->netdev);
|
|
|
|
|
2006-05-26 01:21:10 +02:00
|
|
|
IRDA_MESSAGE("%s, Waking up\n", ALI_IRCC_DRIVER_NAME);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
self->io.suspended = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ALi Chip Function */
|
|
|
|
|
|
|
|
static void SetCOMInterrupts(struct ali_ircc_cb *self , unsigned char enable)
|
|
|
|
{
|
|
|
|
|
|
|
|
unsigned char newMask;
|
|
|
|
|
|
|
|
int iobase = self->io.fir_base; /* or sir_base */
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), -------- Start -------- ( Enable = %d )\n", __func__ , enable);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Enable the interrupt which we wish to */
|
|
|
|
if (enable){
|
|
|
|
if (self->io.direction == IO_XMIT)
|
|
|
|
{
|
|
|
|
if (self->io.speed > 115200) /* FIR, MIR */
|
|
|
|
{
|
|
|
|
newMask = self->ier;
|
|
|
|
}
|
|
|
|
else /* SIR */
|
|
|
|
{
|
|
|
|
newMask = UART_IER_THRI | UART_IER_RDI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (self->io.speed > 115200) /* FIR, MIR */
|
|
|
|
{
|
|
|
|
newMask = self->ier;
|
|
|
|
}
|
|
|
|
else /* SIR */
|
|
|
|
{
|
|
|
|
newMask = UART_IER_RDI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Disable all the interrupts */
|
|
|
|
{
|
|
|
|
newMask = 0x00;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//SIR and FIR has different registers
|
|
|
|
if (self->io.speed > 115200)
|
|
|
|
{
|
|
|
|
switch_bank(iobase, BANK0);
|
|
|
|
outb(newMask, iobase+FIR_IER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
outb(newMask, iobase+UART_IER);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SIR2FIR(int iobase)
|
|
|
|
{
|
|
|
|
//unsigned char tmp;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Already protected (change_speed() or setup()), no need to lock.
|
|
|
|
* Jean II */
|
|
|
|
|
|
|
|
outb(0x28, iobase+UART_MCR);
|
|
|
|
outb(0x68, iobase+UART_MCR);
|
|
|
|
outb(0x88, iobase+UART_MCR);
|
|
|
|
|
|
|
|
outb(0x60, iobase+FIR_MCR); /* Master Reset */
|
|
|
|
outb(0x20, iobase+FIR_MCR); /* Master Interrupt Enable */
|
|
|
|
|
|
|
|
//tmp = inb(iobase+FIR_LCR_B); /* SIP enable */
|
|
|
|
//tmp |= 0x20;
|
|
|
|
//outb(tmp, iobase+FIR_LCR_B);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void FIR2SIR(int iobase)
|
|
|
|
{
|
|
|
|
unsigned char val;
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Already protected (change_speed() or setup()), no need to lock.
|
|
|
|
* Jean II */
|
|
|
|
|
|
|
|
outb(0x20, iobase+FIR_MCR); /* IRQ to low */
|
|
|
|
outb(0x00, iobase+UART_IER);
|
|
|
|
|
|
|
|
outb(0xA0, iobase+FIR_MCR); /* Don't set master reset */
|
|
|
|
outb(0x00, iobase+UART_FCR);
|
|
|
|
outb(0x07, iobase+UART_FCR);
|
|
|
|
|
|
|
|
val = inb(iobase+UART_RX);
|
|
|
|
val = inb(iobase+UART_LSR);
|
|
|
|
val = inb(iobase+UART_MSR);
|
|
|
|
|
2008-07-31 02:20:18 +02:00
|
|
|
IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Benjamin Kong <benjamin_kong@ali.com.tw>");
|
|
|
|
MODULE_DESCRIPTION("ALi FIR Controller Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-18 22:50:44 +02:00
|
|
|
MODULE_ALIAS("platform:" ALI_IRCC_DRIVER_NAME);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
module_param_array(io, int, NULL, 0);
|
|
|
|
MODULE_PARM_DESC(io, "Base I/O addresses");
|
|
|
|
module_param_array(irq, int, NULL, 0);
|
|
|
|
MODULE_PARM_DESC(irq, "IRQ lines");
|
|
|
|
module_param_array(dma, int, NULL, 0);
|
|
|
|
MODULE_PARM_DESC(dma, "DMA channels");
|
|
|
|
|
|
|
|
module_init(ali_ircc_init);
|
|
|
|
module_exit(ali_ircc_cleanup);
|