2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Bluetooth driver for the Anycom BlueCard (LSE039/LSE041)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-2002 Marcel Holtmann <marcel@holtmann.org>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation;
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The initial developer of the original code is David A. Hinds
|
|
|
|
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
|
|
|
|
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
|
|
|
|
#include <linux/skbuff.h>
|
2010-07-02 04:27:44 +00:00
|
|
|
#include <linux/io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <pcmcia/cistpl.h>
|
|
|
|
#include <pcmcia/ciscode.h>
|
|
|
|
#include <pcmcia/ds.h>
|
|
|
|
#include <pcmcia/cisreg.h>
|
|
|
|
|
|
|
|
#include <net/bluetooth/bluetooth.h>
|
|
|
|
#include <net/bluetooth/hci_core.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== Module parameters ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
|
|
|
|
MODULE_DESCRIPTION("Bluetooth driver for the Anycom BlueCard (LSE039/LSE041)");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== Local structures ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct bluecard_info_t {
|
2006-03-05 09:45:09 +00:00
|
|
|
struct pcmcia_device *p_dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
struct hci_dev *hdev;
|
|
|
|
|
|
|
|
spinlock_t lock; /* For serializing operations */
|
|
|
|
struct timer_list timer; /* For LED control */
|
|
|
|
|
|
|
|
struct sk_buff_head txq;
|
|
|
|
unsigned long tx_state;
|
|
|
|
|
|
|
|
unsigned long rx_state;
|
|
|
|
unsigned long rx_count;
|
|
|
|
struct sk_buff *rx_skb;
|
|
|
|
|
|
|
|
unsigned char ctrl_reg;
|
|
|
|
unsigned long hw_state; /* Status of the hardware and LED control */
|
|
|
|
} bluecard_info_t;
|
|
|
|
|
|
|
|
|
2006-03-31 15:26:06 +00:00
|
|
|
static int bluecard_config(struct pcmcia_device *link);
|
2006-03-31 15:21:06 +00:00
|
|
|
static void bluecard_release(struct pcmcia_device *link);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-14 20:23:14 +00:00
|
|
|
static void bluecard_detach(struct pcmcia_device *p_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Default baud rate: 57600, 115200, 230400 or 460800 */
|
|
|
|
#define DEFAULT_BAUD_RATE 230400
|
|
|
|
|
|
|
|
|
|
|
|
/* Hardware states */
|
|
|
|
#define CARD_READY 1
|
|
|
|
#define CARD_HAS_PCCARD_ID 4
|
|
|
|
#define CARD_HAS_POWER_LED 5
|
|
|
|
#define CARD_HAS_ACTIVITY_LED 6
|
|
|
|
|
|
|
|
/* Transmit states */
|
|
|
|
#define XMIT_SENDING 1
|
|
|
|
#define XMIT_WAKEUP 2
|
|
|
|
#define XMIT_BUFFER_NUMBER 5 /* unset = buffer one, set = buffer two */
|
|
|
|
#define XMIT_BUF_ONE_READY 6
|
|
|
|
#define XMIT_BUF_TWO_READY 7
|
|
|
|
#define XMIT_SENDING_READY 8
|
|
|
|
|
|
|
|
/* Receiver states */
|
|
|
|
#define RECV_WAIT_PACKET_TYPE 0
|
|
|
|
#define RECV_WAIT_EVENT_HEADER 1
|
|
|
|
#define RECV_WAIT_ACL_HEADER 2
|
|
|
|
#define RECV_WAIT_SCO_HEADER 3
|
|
|
|
#define RECV_WAIT_DATA 4
|
|
|
|
|
|
|
|
/* Special packet types */
|
|
|
|
#define PKT_BAUD_RATE_57600 0x80
|
|
|
|
#define PKT_BAUD_RATE_115200 0x81
|
|
|
|
#define PKT_BAUD_RATE_230400 0x82
|
|
|
|
#define PKT_BAUD_RATE_460800 0x83
|
|
|
|
|
|
|
|
|
|
|
|
/* These are the register offsets */
|
|
|
|
#define REG_COMMAND 0x20
|
|
|
|
#define REG_INTERRUPT 0x21
|
|
|
|
#define REG_CONTROL 0x22
|
|
|
|
#define REG_RX_CONTROL 0x24
|
|
|
|
#define REG_CARD_RESET 0x30
|
|
|
|
#define REG_LED_CTRL 0x30
|
|
|
|
|
|
|
|
/* REG_COMMAND */
|
|
|
|
#define REG_COMMAND_TX_BUF_ONE 0x01
|
|
|
|
#define REG_COMMAND_TX_BUF_TWO 0x02
|
|
|
|
#define REG_COMMAND_RX_BUF_ONE 0x04
|
|
|
|
#define REG_COMMAND_RX_BUF_TWO 0x08
|
|
|
|
#define REG_COMMAND_RX_WIN_ONE 0x00
|
|
|
|
#define REG_COMMAND_RX_WIN_TWO 0x10
|
|
|
|
|
|
|
|
/* REG_CONTROL */
|
|
|
|
#define REG_CONTROL_BAUD_RATE_57600 0x00
|
|
|
|
#define REG_CONTROL_BAUD_RATE_115200 0x01
|
|
|
|
#define REG_CONTROL_BAUD_RATE_230400 0x02
|
|
|
|
#define REG_CONTROL_BAUD_RATE_460800 0x03
|
|
|
|
#define REG_CONTROL_RTS 0x04
|
|
|
|
#define REG_CONTROL_BT_ON 0x08
|
|
|
|
#define REG_CONTROL_BT_RESET 0x10
|
|
|
|
#define REG_CONTROL_BT_RES_PU 0x20
|
|
|
|
#define REG_CONTROL_INTERRUPT 0x40
|
|
|
|
#define REG_CONTROL_CARD_RESET 0x80
|
|
|
|
|
|
|
|
/* REG_RX_CONTROL */
|
|
|
|
#define RTS_LEVEL_SHIFT_BITS 0x02
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== LED handling routines ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
static void bluecard_activity_led_timeout(u_long arg)
|
|
|
|
{
|
|
|
|
bluecard_info_t *info = (bluecard_info_t *)arg;
|
2010-07-24 13:58:54 +00:00
|
|
|
unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (test_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state))) {
|
|
|
|
/* Disable activity LED */
|
|
|
|
outb(0x08 | 0x20, iobase + 0x30);
|
|
|
|
} else {
|
|
|
|
/* Disable power LED */
|
|
|
|
outb(0x00, iobase + 0x30);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void bluecard_enable_activity_led(bluecard_info_t *info)
|
|
|
|
{
|
2010-07-24 13:58:54 +00:00
|
|
|
unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (test_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state))) {
|
|
|
|
/* Enable activity LED */
|
|
|
|
outb(0x10 | 0x40, iobase + 0x30);
|
|
|
|
|
|
|
|
/* Stop the LED after HZ/4 */
|
|
|
|
mod_timer(&(info->timer), jiffies + HZ / 4);
|
|
|
|
} else {
|
|
|
|
/* Enable power LED */
|
|
|
|
outb(0x08 | 0x20, iobase + 0x30);
|
|
|
|
|
|
|
|
/* Stop the LED after HZ/2 */
|
|
|
|
mod_timer(&(info->timer), jiffies + HZ / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== Interrupt handling ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_write(unsigned int iobase, unsigned int offset, __u8 *buf, int len)
|
|
|
|
{
|
|
|
|
int i, actual;
|
|
|
|
|
|
|
|
actual = (len > 15) ? 15 : len;
|
|
|
|
|
|
|
|
outb_p(actual, iobase + offset);
|
|
|
|
|
|
|
|
for (i = 0; i < actual; i++)
|
|
|
|
outb_p(buf[i], iobase + offset + i + 1);
|
|
|
|
|
|
|
|
return actual;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void bluecard_write_wakeup(bluecard_info_t *info)
|
|
|
|
{
|
|
|
|
if (!info) {
|
|
|
|
BT_ERR("Unknown device");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(XMIT_SENDING_READY, &(info->tx_state)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) {
|
|
|
|
set_bit(XMIT_WAKEUP, &(info->tx_state));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2010-07-24 13:58:54 +00:00
|
|
|
register unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
register unsigned int offset;
|
|
|
|
register unsigned char command;
|
|
|
|
register unsigned long ready_bit;
|
|
|
|
register struct sk_buff *skb;
|
|
|
|
register int len;
|
|
|
|
|
|
|
|
clear_bit(XMIT_WAKEUP, &(info->tx_state));
|
|
|
|
|
2006-03-01 23:09:29 +00:00
|
|
|
if (!pcmcia_dev_present(info->p_dev))
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) {
|
|
|
|
if (!test_bit(XMIT_BUF_TWO_READY, &(info->tx_state)))
|
|
|
|
break;
|
|
|
|
offset = 0x10;
|
|
|
|
command = REG_COMMAND_TX_BUF_TWO;
|
|
|
|
ready_bit = XMIT_BUF_TWO_READY;
|
|
|
|
} else {
|
|
|
|
if (!test_bit(XMIT_BUF_ONE_READY, &(info->tx_state)))
|
|
|
|
break;
|
|
|
|
offset = 0x00;
|
|
|
|
command = REG_COMMAND_TX_BUF_ONE;
|
|
|
|
ready_bit = XMIT_BUF_ONE_READY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(skb = skb_dequeue(&(info->txq))))
|
|
|
|
break;
|
|
|
|
|
2005-08-10 03:30:28 +00:00
|
|
|
if (bt_cb(skb)->pkt_type & 0x80) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Disable RTS */
|
|
|
|
info->ctrl_reg |= REG_CONTROL_RTS;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Activate LED */
|
|
|
|
bluecard_enable_activity_led(info);
|
|
|
|
|
|
|
|
/* Send frame */
|
|
|
|
len = bluecard_write(iobase, offset, skb->data, skb->len);
|
|
|
|
|
|
|
|
/* Tell the FPGA to send the data */
|
|
|
|
outb_p(command, iobase + REG_COMMAND);
|
|
|
|
|
|
|
|
/* Mark the buffer as dirty */
|
|
|
|
clear_bit(ready_bit, &(info->tx_state));
|
|
|
|
|
2005-08-10 03:30:28 +00:00
|
|
|
if (bt_cb(skb)->pkt_type & 0x80) {
|
2006-10-30 06:46:36 +00:00
|
|
|
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
|
2005-04-16 22:20:36 +00:00
|
|
|
DEFINE_WAIT(wait);
|
|
|
|
|
|
|
|
unsigned char baud_reg;
|
|
|
|
|
2005-08-10 03:30:28 +00:00
|
|
|
switch (bt_cb(skb)->pkt_type) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case PKT_BAUD_RATE_460800:
|
|
|
|
baud_reg = REG_CONTROL_BAUD_RATE_460800;
|
|
|
|
break;
|
|
|
|
case PKT_BAUD_RATE_230400:
|
|
|
|
baud_reg = REG_CONTROL_BAUD_RATE_230400;
|
|
|
|
break;
|
|
|
|
case PKT_BAUD_RATE_115200:
|
|
|
|
baud_reg = REG_CONTROL_BAUD_RATE_115200;
|
|
|
|
break;
|
|
|
|
case PKT_BAUD_RATE_57600:
|
|
|
|
/* Fall through... */
|
|
|
|
default:
|
|
|
|
baud_reg = REG_CONTROL_BAUD_RATE_57600;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait until the command reaches the baseband */
|
|
|
|
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
|
|
|
|
schedule_timeout(HZ/10);
|
|
|
|
finish_wait(&wq, &wait);
|
|
|
|
|
|
|
|
/* Set baud on baseband */
|
|
|
|
info->ctrl_reg &= ~0x03;
|
|
|
|
info->ctrl_reg |= baud_reg;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Enable RTS */
|
|
|
|
info->ctrl_reg &= ~REG_CONTROL_RTS;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Wait before the next HCI packet can be send */
|
|
|
|
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
|
|
|
|
schedule_timeout(HZ);
|
|
|
|
finish_wait(&wq, &wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len == skb->len) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
} else {
|
|
|
|
skb_pull(skb, len);
|
|
|
|
skb_queue_head(&(info->txq), skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
info->hdev->stat.byte_tx += len;
|
|
|
|
|
|
|
|
/* Change buffer */
|
|
|
|
change_bit(XMIT_BUFFER_NUMBER, &(info->tx_state));
|
|
|
|
|
|
|
|
} while (test_bit(XMIT_WAKEUP, &(info->tx_state)));
|
|
|
|
|
|
|
|
clear_bit(XMIT_SENDING, &(info->tx_state));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_read(unsigned int iobase, unsigned int offset, __u8 *buf, int size)
|
|
|
|
{
|
|
|
|
int i, n, len;
|
|
|
|
|
|
|
|
outb(REG_COMMAND_RX_WIN_ONE, iobase + REG_COMMAND);
|
|
|
|
|
|
|
|
len = inb(iobase + offset);
|
|
|
|
n = 0;
|
|
|
|
i = 1;
|
|
|
|
|
|
|
|
while (n < len) {
|
|
|
|
|
|
|
|
if (i == 16) {
|
|
|
|
outb(REG_COMMAND_RX_WIN_TWO, iobase + REG_COMMAND);
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[n] = inb(iobase + offset + i);
|
|
|
|
|
|
|
|
n++;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
|
|
|
|
{
|
|
|
|
unsigned int iobase;
|
|
|
|
unsigned char buf[31];
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
if (!info) {
|
|
|
|
BT_ERR("Unknown device");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-24 13:58:54 +00:00
|
|
|
iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (test_bit(XMIT_SENDING_READY, &(info->tx_state)))
|
|
|
|
bluecard_enable_activity_led(info);
|
|
|
|
|
|
|
|
len = bluecard_read(iobase, offset, buf, sizeof(buf));
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
|
|
|
/* Allocate packet */
|
|
|
|
if (info->rx_skb == NULL) {
|
|
|
|
info->rx_state = RECV_WAIT_PACKET_TYPE;
|
|
|
|
info->rx_count = 0;
|
|
|
|
if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
|
|
|
|
BT_ERR("Can't allocate mem for new packet");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
|
|
|
|
|
|
|
|
info->rx_skb->dev = (void *) info->hdev;
|
2005-08-10 03:30:28 +00:00
|
|
|
bt_cb(info->rx_skb)->pkt_type = buf[i];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-10 03:30:28 +00:00
|
|
|
switch (bt_cb(info->rx_skb)->pkt_type) {
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
case 0x00:
|
|
|
|
/* init packet */
|
|
|
|
if (offset != 0x00) {
|
|
|
|
set_bit(XMIT_BUF_ONE_READY, &(info->tx_state));
|
|
|
|
set_bit(XMIT_BUF_TWO_READY, &(info->tx_state));
|
|
|
|
set_bit(XMIT_SENDING_READY, &(info->tx_state));
|
|
|
|
bluecard_write_wakeup(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree_skb(info->rx_skb);
|
|
|
|
info->rx_skb = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCI_EVENT_PKT:
|
|
|
|
info->rx_state = RECV_WAIT_EVENT_HEADER;
|
|
|
|
info->rx_count = HCI_EVENT_HDR_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCI_ACLDATA_PKT:
|
|
|
|
info->rx_state = RECV_WAIT_ACL_HEADER;
|
|
|
|
info->rx_count = HCI_ACL_HDR_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCI_SCODATA_PKT:
|
|
|
|
info->rx_state = RECV_WAIT_SCO_HEADER;
|
|
|
|
info->rx_count = HCI_SCO_HDR_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* unknown packet */
|
2005-08-10 03:30:28 +00:00
|
|
|
BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
|
2005-04-16 22:20:36 +00:00
|
|
|
info->hdev->stat.err_rx++;
|
|
|
|
|
|
|
|
kfree_skb(info->rx_skb);
|
|
|
|
info->rx_skb = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
*skb_put(info->rx_skb, 1) = buf[i];
|
|
|
|
info->rx_count--;
|
|
|
|
|
|
|
|
if (info->rx_count == 0) {
|
|
|
|
|
|
|
|
int dlen;
|
|
|
|
struct hci_event_hdr *eh;
|
|
|
|
struct hci_acl_hdr *ah;
|
|
|
|
struct hci_sco_hdr *sh;
|
|
|
|
|
|
|
|
switch (info->rx_state) {
|
|
|
|
|
|
|
|
case RECV_WAIT_EVENT_HEADER:
|
2007-03-27 21:38:07 +00:00
|
|
|
eh = hci_event_hdr(info->rx_skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
info->rx_state = RECV_WAIT_DATA;
|
|
|
|
info->rx_count = eh->plen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECV_WAIT_ACL_HEADER:
|
2007-03-27 21:38:07 +00:00
|
|
|
ah = hci_acl_hdr(info->rx_skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
dlen = __le16_to_cpu(ah->dlen);
|
|
|
|
info->rx_state = RECV_WAIT_DATA;
|
|
|
|
info->rx_count = dlen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECV_WAIT_SCO_HEADER:
|
2007-03-27 21:38:07 +00:00
|
|
|
sh = hci_sco_hdr(info->rx_skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
info->rx_state = RECV_WAIT_DATA;
|
|
|
|
info->rx_count = sh->dlen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECV_WAIT_DATA:
|
|
|
|
hci_recv_frame(info->rx_skb);
|
|
|
|
info->rx_skb = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
info->hdev->stat.byte_rx += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 13:55:46 +00:00
|
|
|
static irqreturn_t bluecard_interrupt(int irq, void *dev_inst)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
bluecard_info_t *info = dev_inst;
|
|
|
|
unsigned int iobase;
|
|
|
|
unsigned char reg;
|
|
|
|
|
2009-09-14 17:43:49 +00:00
|
|
|
if (!info || !info->hdev)
|
|
|
|
/* our irq handler is shared */
|
|
|
|
return IRQ_NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!test_bit(CARD_READY, &(info->hw_state)))
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
|
2010-07-24 13:58:54 +00:00
|
|
|
iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock(&(info->lock));
|
|
|
|
|
|
|
|
/* Disable interrupt */
|
|
|
|
info->ctrl_reg &= ~REG_CONTROL_INTERRUPT;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
reg = inb(iobase + REG_INTERRUPT);
|
|
|
|
|
|
|
|
if ((reg != 0x00) && (reg != 0xff)) {
|
|
|
|
|
|
|
|
if (reg & 0x04) {
|
|
|
|
bluecard_receive(info, 0x00);
|
|
|
|
outb(0x04, iobase + REG_INTERRUPT);
|
|
|
|
outb(REG_COMMAND_RX_BUF_ONE, iobase + REG_COMMAND);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reg & 0x08) {
|
|
|
|
bluecard_receive(info, 0x10);
|
|
|
|
outb(0x08, iobase + REG_INTERRUPT);
|
|
|
|
outb(REG_COMMAND_RX_BUF_TWO, iobase + REG_COMMAND);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reg & 0x01) {
|
|
|
|
set_bit(XMIT_BUF_ONE_READY, &(info->tx_state));
|
|
|
|
outb(0x01, iobase + REG_INTERRUPT);
|
|
|
|
bluecard_write_wakeup(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reg & 0x02) {
|
|
|
|
set_bit(XMIT_BUF_TWO_READY, &(info->tx_state));
|
|
|
|
outb(0x02, iobase + REG_INTERRUPT);
|
|
|
|
bluecard_write_wakeup(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable interrupt */
|
|
|
|
info->ctrl_reg |= REG_CONTROL_INTERRUPT;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
spin_unlock(&(info->lock));
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== Device specific HCI commands ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)
|
|
|
|
{
|
|
|
|
bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data);
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
/* Ericsson baud rate command */
|
|
|
|
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x09, 0xfc, 0x01, 0x03 };
|
|
|
|
|
|
|
|
if (!(skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
|
|
|
|
BT_ERR("Can't allocate mem for new packet");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (baud) {
|
|
|
|
case 460800:
|
|
|
|
cmd[4] = 0x00;
|
2005-08-10 03:30:28 +00:00
|
|
|
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_460800;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 230400:
|
|
|
|
cmd[4] = 0x01;
|
2005-08-10 03:30:28 +00:00
|
|
|
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_230400;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 115200:
|
|
|
|
cmd[4] = 0x02;
|
2005-08-10 03:30:28 +00:00
|
|
|
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_115200;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 57600:
|
|
|
|
/* Fall through... */
|
|
|
|
default:
|
|
|
|
cmd[4] = 0x03;
|
2005-08-10 03:30:28 +00:00
|
|
|
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_57600;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
|
|
|
|
|
|
|
|
skb_queue_tail(&(info->txq), skb);
|
|
|
|
|
|
|
|
bluecard_write_wakeup(info);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== HCI interface ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_hci_flush(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data);
|
|
|
|
|
|
|
|
/* Drop TX queue */
|
|
|
|
skb_queue_purge(&(info->txq));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_hci_open(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data);
|
2010-07-24 13:58:54 +00:00
|
|
|
unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
|
|
|
|
bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE);
|
|
|
|
|
|
|
|
if (test_and_set_bit(HCI_RUNNING, &(hdev->flags)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) {
|
|
|
|
/* Enable LED */
|
|
|
|
outb(0x08 | 0x20, iobase + 0x30);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_hci_close(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data);
|
2010-07-24 13:58:54 +00:00
|
|
|
unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bluecard_hci_flush(hdev);
|
|
|
|
|
|
|
|
if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) {
|
|
|
|
/* Disable LED */
|
|
|
|
outb(0x00, iobase + 0x30);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_hci_send_frame(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
bluecard_info_t *info;
|
|
|
|
struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
|
|
|
|
|
|
|
|
if (!hdev) {
|
|
|
|
BT_ERR("Frame for unknown HCI device (hdev=NULL)");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = (bluecard_info_t *)(hdev->driver_data);
|
|
|
|
|
2005-08-10 03:30:28 +00:00
|
|
|
switch (bt_cb(skb)->pkt_type) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case HCI_COMMAND_PKT:
|
|
|
|
hdev->stat.cmd_tx++;
|
|
|
|
break;
|
|
|
|
case HCI_ACLDATA_PKT:
|
|
|
|
hdev->stat.acl_tx++;
|
|
|
|
break;
|
|
|
|
case HCI_SCODATA_PKT:
|
|
|
|
hdev->stat.sco_tx++;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Prepend skb with frame type */
|
2005-08-10 03:30:28 +00:00
|
|
|
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
skb_queue_tail(&(info->txq), skb);
|
|
|
|
|
|
|
|
bluecard_write_wakeup(info);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void bluecard_hci_destruct(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
|
|
|
|
{
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================== Card services HCI interaction ======================== */
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_open(bluecard_info_t *info)
|
|
|
|
{
|
2010-07-24 13:58:54 +00:00
|
|
|
unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct hci_dev *hdev;
|
|
|
|
unsigned char id;
|
|
|
|
|
|
|
|
spin_lock_init(&(info->lock));
|
|
|
|
|
|
|
|
init_timer(&(info->timer));
|
|
|
|
info->timer.function = &bluecard_activity_led_timeout;
|
|
|
|
info->timer.data = (u_long)info;
|
|
|
|
|
|
|
|
skb_queue_head_init(&(info->txq));
|
|
|
|
|
|
|
|
info->rx_state = RECV_WAIT_PACKET_TYPE;
|
|
|
|
info->rx_count = 0;
|
|
|
|
info->rx_skb = NULL;
|
|
|
|
|
|
|
|
/* Initialize HCI device */
|
|
|
|
hdev = hci_alloc_dev();
|
|
|
|
if (!hdev) {
|
|
|
|
BT_ERR("Can't allocate HCI device");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->hdev = hdev;
|
|
|
|
|
2010-02-08 14:27:07 +00:00
|
|
|
hdev->bus = HCI_PCCARD;
|
2005-04-16 22:20:36 +00:00
|
|
|
hdev->driver_data = info;
|
2006-07-03 08:02:37 +00:00
|
|
|
SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
hdev->open = bluecard_hci_open;
|
|
|
|
hdev->close = bluecard_hci_close;
|
|
|
|
hdev->flush = bluecard_hci_flush;
|
|
|
|
hdev->send = bluecard_hci_send_frame;
|
|
|
|
hdev->destruct = bluecard_hci_destruct;
|
|
|
|
hdev->ioctl = bluecard_hci_ioctl;
|
|
|
|
|
|
|
|
hdev->owner = THIS_MODULE;
|
|
|
|
|
|
|
|
id = inb(iobase + 0x30);
|
|
|
|
|
|
|
|
if ((id & 0x0f) == 0x02)
|
|
|
|
set_bit(CARD_HAS_PCCARD_ID, &(info->hw_state));
|
|
|
|
|
|
|
|
if (id & 0x10)
|
|
|
|
set_bit(CARD_HAS_POWER_LED, &(info->hw_state));
|
|
|
|
|
|
|
|
if (id & 0x20)
|
|
|
|
set_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state));
|
|
|
|
|
|
|
|
/* Reset card */
|
|
|
|
info->ctrl_reg = REG_CONTROL_BT_RESET | REG_CONTROL_CARD_RESET;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Turn FPGA off */
|
|
|
|
outb(0x80, iobase + 0x30);
|
|
|
|
|
|
|
|
/* Wait some time */
|
|
|
|
msleep(10);
|
|
|
|
|
|
|
|
/* Turn FPGA on */
|
|
|
|
outb(0x00, iobase + 0x30);
|
|
|
|
|
|
|
|
/* Activate card */
|
|
|
|
info->ctrl_reg = REG_CONTROL_BT_ON | REG_CONTROL_BT_RES_PU;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Enable interrupt */
|
|
|
|
outb(0xff, iobase + REG_INTERRUPT);
|
|
|
|
info->ctrl_reg |= REG_CONTROL_INTERRUPT;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
if ((id & 0x0f) == 0x03) {
|
|
|
|
/* Disable RTS */
|
|
|
|
info->ctrl_reg |= REG_CONTROL_RTS;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Set baud rate */
|
|
|
|
info->ctrl_reg |= 0x03;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Enable RTS */
|
|
|
|
info->ctrl_reg &= ~REG_CONTROL_RTS;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
set_bit(XMIT_BUF_ONE_READY, &(info->tx_state));
|
|
|
|
set_bit(XMIT_BUF_TWO_READY, &(info->tx_state));
|
|
|
|
set_bit(XMIT_SENDING_READY, &(info->tx_state));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start the RX buffers */
|
|
|
|
outb(REG_COMMAND_RX_BUF_ONE, iobase + REG_COMMAND);
|
|
|
|
outb(REG_COMMAND_RX_BUF_TWO, iobase + REG_COMMAND);
|
|
|
|
|
|
|
|
/* Signal that the hardware is ready */
|
|
|
|
set_bit(CARD_READY, &(info->hw_state));
|
|
|
|
|
|
|
|
/* Drop TX queue */
|
|
|
|
skb_queue_purge(&(info->txq));
|
|
|
|
|
|
|
|
/* Control the point at which RTS is enabled */
|
|
|
|
outb((0x0f << RTS_LEVEL_SHIFT_BITS) | 1, iobase + REG_RX_CONTROL);
|
|
|
|
|
|
|
|
/* Timeout before it is safe to send the first HCI packet */
|
|
|
|
msleep(1250);
|
|
|
|
|
|
|
|
/* Register HCI device */
|
|
|
|
if (hci_register_dev(hdev) < 0) {
|
|
|
|
BT_ERR("Can't register HCI device");
|
|
|
|
info->hdev = NULL;
|
|
|
|
hci_free_dev(hdev);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bluecard_close(bluecard_info_t *info)
|
|
|
|
{
|
2010-07-24 13:58:54 +00:00
|
|
|
unsigned int iobase = info->p_dev->resource[0]->start;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct hci_dev *hdev = info->hdev;
|
|
|
|
|
|
|
|
if (!hdev)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
bluecard_hci_close(hdev);
|
|
|
|
|
|
|
|
clear_bit(CARD_READY, &(info->hw_state));
|
|
|
|
|
|
|
|
/* Reset card */
|
|
|
|
info->ctrl_reg = REG_CONTROL_BT_RESET | REG_CONTROL_CARD_RESET;
|
|
|
|
outb(info->ctrl_reg, iobase + REG_CONTROL);
|
|
|
|
|
|
|
|
/* Turn FPGA off */
|
|
|
|
outb(0x80, iobase + 0x30);
|
|
|
|
|
2011-10-26 08:43:18 +00:00
|
|
|
hci_unregister_dev(hdev);
|
2005-04-16 22:20:36 +00:00
|
|
|
hci_free_dev(hdev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-31 15:26:06 +00:00
|
|
|
static int bluecard_probe(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
bluecard_info_t *info;
|
|
|
|
|
|
|
|
/* Create new info device */
|
2005-11-07 09:01:26 +00:00
|
|
|
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!info)
|
2005-11-14 20:25:51 +00:00
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
info->p_dev = link;
|
2005-04-16 22:20:36 +00:00
|
|
|
link->priv = info;
|
|
|
|
|
2010-07-29 17:27:09 +00:00
|
|
|
link->config_flags |= CONF_ENABLE_IRQ;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-03-31 15:26:06 +00:00
|
|
|
return bluecard_config(link);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
static void bluecard_detach(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
bluecard_info_t *info = link->priv;
|
|
|
|
|
2006-03-01 23:09:29 +00:00
|
|
|
bluecard_release(link);
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-31 15:26:06 +00:00
|
|
|
static int bluecard_config(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
bluecard_info_t *info = link->priv;
|
2006-10-26 01:49:27 +00:00
|
|
|
int i, n;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-07-29 16:35:47 +00:00
|
|
|
link->config_index = 0x20;
|
2010-07-24 15:23:51 +00:00
|
|
|
|
|
|
|
link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
|
|
|
|
link->resource[0]->end = 64;
|
|
|
|
link->io_lines = 6;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (n = 0; n < 0x400; n += 0x40) {
|
2010-07-24 15:23:51 +00:00
|
|
|
link->resource[0]->start = n ^ 0x300;
|
|
|
|
i = pcmcia_request_io(link);
|
2008-08-03 08:07:45 +00:00
|
|
|
if (i == 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-10-24 13:45:06 +00:00
|
|
|
if (i != 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto failed;
|
|
|
|
|
2010-03-07 11:21:16 +00:00
|
|
|
i = pcmcia_request_irq(link, bluecard_interrupt);
|
2009-10-24 13:45:06 +00:00
|
|
|
if (i != 0)
|
2010-03-07 11:21:16 +00:00
|
|
|
goto failed;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-07-29 17:27:09 +00:00
|
|
|
i = pcmcia_enable_device(link);
|
2009-10-24 13:45:06 +00:00
|
|
|
if (i != 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto failed;
|
|
|
|
|
|
|
|
if (bluecard_open(info) != 0)
|
|
|
|
goto failed;
|
|
|
|
|
2006-03-31 15:26:06 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
failed:
|
|
|
|
bluecard_release(link);
|
2006-03-31 15:26:06 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
static void bluecard_release(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
bluecard_info_t *info = link->priv;
|
|
|
|
|
2006-03-01 23:09:29 +00:00
|
|
|
bluecard_close(info);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
del_timer(&(info->timer));
|
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
pcmcia_disable_device(link);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-05-04 02:29:01 +00:00
|
|
|
static const struct pcmcia_device_id bluecard_ids[] = {
|
2005-06-27 23:28:35 +00:00
|
|
|
PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e),
|
|
|
|
PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c),
|
|
|
|
PCMCIA_DEVICE_PROD_ID12("WSS", "LSE039", 0x0a0736ec, 0x24e6dfab),
|
|
|
|
PCMCIA_DEVICE_NULL
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pcmcia, bluecard_ids);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct pcmcia_driver bluecard_driver = {
|
|
|
|
.owner = THIS_MODULE,
|
2010-08-08 09:36:26 +00:00
|
|
|
.name = "bluecard_cs",
|
2006-03-31 15:26:06 +00:00
|
|
|
.probe = bluecard_probe,
|
2005-11-14 20:23:14 +00:00
|
|
|
.remove = bluecard_detach,
|
2005-06-27 23:28:35 +00:00
|
|
|
.id_table = bluecard_ids,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_bluecard_cs(void)
|
|
|
|
{
|
|
|
|
return pcmcia_register_driver(&bluecard_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void __exit exit_bluecard_cs(void)
|
|
|
|
{
|
|
|
|
pcmcia_unregister_driver(&bluecard_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_bluecard_cs);
|
|
|
|
module_exit(exit_bluecard_cs);
|