diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/char/pcmcia | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/char/pcmcia')
-rw-r--r-- | drivers/char/pcmcia/Kconfig | 4 | ||||
-rw-r--r-- | drivers/char/pcmcia/Makefile | 2 | ||||
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 54 | ||||
-rw-r--r-- | drivers/char/pcmcia/cm4040_cs.c | 49 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/Makefile | 10 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/hardware.c | 1764 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/hardware.h | 62 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/main.c | 370 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/main.h | 73 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/network.c | 507 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/network.h | 53 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/setup_protocol.h | 108 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/tty.c | 679 | ||||
-rw-r--r-- | drivers/char/pcmcia/ipwireless/tty.h | 46 | ||||
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 126 |
15 files changed, 79 insertions, 3828 deletions
diff --git a/drivers/char/pcmcia/Kconfig b/drivers/char/pcmcia/Kconfig index ffa0efce0aed..6614416a8623 100644 --- a/drivers/char/pcmcia/Kconfig +++ b/drivers/char/pcmcia/Kconfig | |||
@@ -28,7 +28,7 @@ config CARDMAN_4000 | |||
28 | 28 | ||
29 | This kernel driver requires additional userspace support, either | 29 | This kernel driver requires additional userspace support, either |
30 | by the vendor-provided PC/SC ifd_handler (http://www.omnikey.com/), | 30 | by the vendor-provided PC/SC ifd_handler (http://www.omnikey.com/), |
31 | or via the cm4000 backend of OpenCT (http://www.opensc.com/). | 31 | or via the cm4000 backend of OpenCT (http://www.opensc-project.org/opensc). |
32 | 32 | ||
33 | config CARDMAN_4040 | 33 | config CARDMAN_4040 |
34 | tristate "Omnikey CardMan 4040 support" | 34 | tristate "Omnikey CardMan 4040 support" |
@@ -41,7 +41,7 @@ config CARDMAN_4040 | |||
41 | in I/O space. To use the kernel driver, you will need either the | 41 | in I/O space. To use the kernel driver, you will need either the |
42 | PC/SC ifdhandler provided from the Omnikey homepage | 42 | PC/SC ifdhandler provided from the Omnikey homepage |
43 | (http://www.omnikey.com/), or a current development version of OpenCT | 43 | (http://www.omnikey.com/), or a current development version of OpenCT |
44 | (http://www.opensc.org/). | 44 | (http://www.opensc-project.org/opensc). |
45 | 45 | ||
46 | config IPWIRELESS | 46 | config IPWIRELESS |
47 | tristate "IPWireless 3G UMTS PCMCIA card support" | 47 | tristate "IPWireless 3G UMTS PCMCIA card support" |
diff --git a/drivers/char/pcmcia/Makefile b/drivers/char/pcmcia/Makefile index be8f287aa398..0aae20985d57 100644 --- a/drivers/char/pcmcia/Makefile +++ b/drivers/char/pcmcia/Makefile | |||
@@ -4,8 +4,6 @@ | |||
4 | # Makefile for the Linux PCMCIA char device drivers. | 4 | # Makefile for the Linux PCMCIA char device drivers. |
5 | # | 5 | # |
6 | 6 | ||
7 | obj-y += ipwireless/ | ||
8 | |||
9 | obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o | 7 | obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o |
10 | obj-$(CONFIG_CARDMAN_4000) += cm4000_cs.o | 8 | obj-$(CONFIG_CARDMAN_4000) += cm4000_cs.o |
11 | obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o | 9 | obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o |
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index ec73d9f6d9ed..a7584860e9a7 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -30,11 +30,10 @@ | |||
30 | #include <linux/fs.h> | 30 | #include <linux/fs.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/bitrev.h> | 32 | #include <linux/bitrev.h> |
33 | #include <linux/smp_lock.h> | 33 | #include <linux/mutex.h> |
34 | #include <linux/uaccess.h> | 34 | #include <linux/uaccess.h> |
35 | #include <linux/io.h> | 35 | #include <linux/io.h> |
36 | 36 | ||
37 | #include <pcmcia/cs.h> | ||
38 | #include <pcmcia/cistpl.h> | 37 | #include <pcmcia/cistpl.h> |
39 | #include <pcmcia/cisreg.h> | 38 | #include <pcmcia/cisreg.h> |
40 | #include <pcmcia/ciscode.h> | 39 | #include <pcmcia/ciscode.h> |
@@ -55,7 +54,7 @@ | |||
55 | __func__ , ## args); \ | 54 | __func__ , ## args); \ |
56 | } while (0) | 55 | } while (0) |
57 | 56 | ||
58 | static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte"; | 57 | static DEFINE_MUTEX(cmm_mutex); |
59 | 58 | ||
60 | #define T_1SEC (HZ) | 59 | #define T_1SEC (HZ) |
61 | #define T_10MSEC msecs_to_jiffies(10) | 60 | #define T_10MSEC msecs_to_jiffies(10) |
@@ -807,7 +806,7 @@ static void monitor_card(unsigned long p) | |||
807 | dev->flags1 = 0x01; | 806 | dev->flags1 = 0x01; |
808 | xoutb(dev->flags1, REG_FLAGS1(iobase)); | 807 | xoutb(dev->flags1, REG_FLAGS1(iobase)); |
809 | 808 | ||
810 | /* atr is present (which doesnt mean it's valid) */ | 809 | /* atr is present (which doesn't mean it's valid) */ |
811 | set_bit(IS_ATR_PRESENT, &dev->flags); | 810 | set_bit(IS_ATR_PRESENT, &dev->flags); |
812 | if (dev->atr[0] == 0x03) | 811 | if (dev->atr[0] == 0x03) |
813 | str_invert_revert(dev->atr, dev->atr_len); | 812 | str_invert_revert(dev->atr, dev->atr_len); |
@@ -831,8 +830,7 @@ static void monitor_card(unsigned long p) | |||
831 | test_bit(IS_ANY_T1, &dev->flags))) { | 830 | test_bit(IS_ANY_T1, &dev->flags))) { |
832 | DEBUGP(4, dev, "Perform AUTOPPS\n"); | 831 | DEBUGP(4, dev, "Perform AUTOPPS\n"); |
833 | set_bit(IS_AUTOPPS_ACT, &dev->flags); | 832 | set_bit(IS_AUTOPPS_ACT, &dev->flags); |
834 | ptsreq.protocol = ptsreq.protocol = | 833 | ptsreq.protocol = (0x01 << dev->proto); |
835 | (0x01 << dev->proto); | ||
836 | ptsreq.flags = 0x01; | 834 | ptsreq.flags = 0x01; |
837 | ptsreq.pts1 = 0x00; | 835 | ptsreq.pts1 = 0x00; |
838 | ptsreq.pts2 = 0x00; | 836 | ptsreq.pts2 = 0x00; |
@@ -980,8 +978,9 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count, | |||
980 | if (dev->flags0 & 1) { | 978 | if (dev->flags0 & 1) { |
981 | set_bit(IS_CMM_ABSENT, &dev->flags); | 979 | set_bit(IS_CMM_ABSENT, &dev->flags); |
982 | rc = -ENODEV; | 980 | rc = -ENODEV; |
981 | } else { | ||
982 | rc = -EIO; | ||
983 | } | 983 | } |
984 | rc = -EIO; | ||
985 | goto release_io; | 984 | goto release_io; |
986 | } | 985 | } |
987 | 986 | ||
@@ -1418,7 +1417,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
1418 | iminor(inode), ioctl_names[_IOC_NR(cmd)]); | 1417 | iminor(inode), ioctl_names[_IOC_NR(cmd)]); |
1419 | #endif | 1418 | #endif |
1420 | 1419 | ||
1421 | lock_kernel(); | 1420 | mutex_lock(&cmm_mutex); |
1422 | rc = -ENODEV; | 1421 | rc = -ENODEV; |
1423 | link = dev_table[iminor(inode)]; | 1422 | link = dev_table[iminor(inode)]; |
1424 | if (!pcmcia_dev_present(link)) { | 1423 | if (!pcmcia_dev_present(link)) { |
@@ -1626,7 +1625,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
1626 | rc = -ENOTTY; | 1625 | rc = -ENOTTY; |
1627 | } | 1626 | } |
1628 | out: | 1627 | out: |
1629 | unlock_kernel(); | 1628 | mutex_unlock(&cmm_mutex); |
1630 | return rc; | 1629 | return rc; |
1631 | } | 1630 | } |
1632 | 1631 | ||
@@ -1640,7 +1639,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1640 | if (minor >= CM4000_MAX_DEV) | 1639 | if (minor >= CM4000_MAX_DEV) |
1641 | return -ENODEV; | 1640 | return -ENODEV; |
1642 | 1641 | ||
1643 | lock_kernel(); | 1642 | mutex_lock(&cmm_mutex); |
1644 | link = dev_table[minor]; | 1643 | link = dev_table[minor]; |
1645 | if (link == NULL || !pcmcia_dev_present(link)) { | 1644 | if (link == NULL || !pcmcia_dev_present(link)) { |
1646 | ret = -ENODEV; | 1645 | ret = -ENODEV; |
@@ -1667,7 +1666,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1667 | /* opening will always block since the | 1666 | /* opening will always block since the |
1668 | * monitor will be started by open, which | 1667 | * monitor will be started by open, which |
1669 | * means we have to wait for ATR becoming | 1668 | * means we have to wait for ATR becoming |
1670 | * vaild = block until valid (or card | 1669 | * valid = block until valid (or card |
1671 | * inserted) | 1670 | * inserted) |
1672 | */ | 1671 | */ |
1673 | if (filp->f_flags & O_NONBLOCK) { | 1672 | if (filp->f_flags & O_NONBLOCK) { |
@@ -1685,7 +1684,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1685 | DEBUGP(2, dev, "<- cmm_open\n"); | 1684 | DEBUGP(2, dev, "<- cmm_open\n"); |
1686 | ret = nonseekable_open(inode, filp); | 1685 | ret = nonseekable_open(inode, filp); |
1687 | out: | 1686 | out: |
1688 | unlock_kernel(); | 1687 | mutex_unlock(&cmm_mutex); |
1689 | return ret; | 1688 | return ret; |
1690 | } | 1689 | } |
1691 | 1690 | ||
@@ -1742,20 +1741,8 @@ static void cmm_cm4000_release(struct pcmcia_device * link) | |||
1742 | 1741 | ||
1743 | /*==== Interface to PCMCIA Layer =======================================*/ | 1742 | /*==== Interface to PCMCIA Layer =======================================*/ |
1744 | 1743 | ||
1745 | static int cm4000_config_check(struct pcmcia_device *p_dev, | 1744 | static int cm4000_config_check(struct pcmcia_device *p_dev, void *priv_data) |
1746 | cistpl_cftable_entry_t *cfg, | ||
1747 | cistpl_cftable_entry_t *dflt, | ||
1748 | unsigned int vcc, | ||
1749 | void *priv_data) | ||
1750 | { | 1745 | { |
1751 | if (!cfg->io.nwin) | ||
1752 | return -ENODEV; | ||
1753 | |||
1754 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
1755 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
1756 | p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); | ||
1757 | p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
1758 | |||
1759 | return pcmcia_request_io(p_dev); | 1746 | return pcmcia_request_io(p_dev); |
1760 | } | 1747 | } |
1761 | 1748 | ||
@@ -1763,13 +1750,13 @@ static int cm4000_config(struct pcmcia_device * link, int devno) | |||
1763 | { | 1750 | { |
1764 | struct cm4000_dev *dev; | 1751 | struct cm4000_dev *dev; |
1765 | 1752 | ||
1753 | link->config_flags |= CONF_AUTO_SET_IO; | ||
1754 | |||
1766 | /* read the config-tuples */ | 1755 | /* read the config-tuples */ |
1767 | if (pcmcia_loop_config(link, cm4000_config_check, NULL)) | 1756 | if (pcmcia_loop_config(link, cm4000_config_check, NULL)) |
1768 | goto cs_release; | 1757 | goto cs_release; |
1769 | 1758 | ||
1770 | link->conf.IntType = 00000002; | 1759 | if (pcmcia_enable_device(link)) |
1771 | |||
1772 | if (pcmcia_request_configuration(link, &link->conf)) | ||
1773 | goto cs_release; | 1760 | goto cs_release; |
1774 | 1761 | ||
1775 | dev = link->priv; | 1762 | dev = link->priv; |
@@ -1829,7 +1816,6 @@ static int cm4000_probe(struct pcmcia_device *link) | |||
1829 | 1816 | ||
1830 | dev->p_dev = link; | 1817 | dev->p_dev = link; |
1831 | link->priv = dev; | 1818 | link->priv = dev; |
1832 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
1833 | dev_table[i] = link; | 1819 | dev_table[i] = link; |
1834 | 1820 | ||
1835 | init_waitqueue_head(&dev->devq); | 1821 | init_waitqueue_head(&dev->devq); |
@@ -1880,9 +1866,10 @@ static const struct file_operations cm4000_fops = { | |||
1880 | .unlocked_ioctl = cmm_ioctl, | 1866 | .unlocked_ioctl = cmm_ioctl, |
1881 | .open = cmm_open, | 1867 | .open = cmm_open, |
1882 | .release= cmm_close, | 1868 | .release= cmm_close, |
1869 | .llseek = no_llseek, | ||
1883 | }; | 1870 | }; |
1884 | 1871 | ||
1885 | static struct pcmcia_device_id cm4000_ids[] = { | 1872 | static const struct pcmcia_device_id cm4000_ids[] = { |
1886 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002), | 1873 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002), |
1887 | PCMCIA_DEVICE_PROD_ID12("CardMan", "4000", 0x2FB368CA, 0xA2BD8C39), | 1874 | PCMCIA_DEVICE_PROD_ID12("CardMan", "4000", 0x2FB368CA, 0xA2BD8C39), |
1888 | PCMCIA_DEVICE_NULL, | 1875 | PCMCIA_DEVICE_NULL, |
@@ -1891,9 +1878,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4000_ids); | |||
1891 | 1878 | ||
1892 | static struct pcmcia_driver cm4000_driver = { | 1879 | static struct pcmcia_driver cm4000_driver = { |
1893 | .owner = THIS_MODULE, | 1880 | .owner = THIS_MODULE, |
1894 | .drv = { | 1881 | .name = "cm4000_cs", |
1895 | .name = "cm4000_cs", | ||
1896 | }, | ||
1897 | .probe = cm4000_probe, | 1882 | .probe = cm4000_probe, |
1898 | .remove = cm4000_detach, | 1883 | .remove = cm4000_detach, |
1899 | .suspend = cm4000_suspend, | 1884 | .suspend = cm4000_suspend, |
@@ -1905,8 +1890,6 @@ static int __init cmm_init(void) | |||
1905 | { | 1890 | { |
1906 | int rc; | 1891 | int rc; |
1907 | 1892 | ||
1908 | printk(KERN_INFO "%s\n", version); | ||
1909 | |||
1910 | cmm_class = class_create(THIS_MODULE, "cardman_4000"); | 1893 | cmm_class = class_create(THIS_MODULE, "cardman_4000"); |
1911 | if (IS_ERR(cmm_class)) | 1894 | if (IS_ERR(cmm_class)) |
1912 | return PTR_ERR(cmm_class); | 1895 | return PTR_ERR(cmm_class); |
@@ -1931,7 +1914,6 @@ static int __init cmm_init(void) | |||
1931 | 1914 | ||
1932 | static void __exit cmm_exit(void) | 1915 | static void __exit cmm_exit(void) |
1933 | { | 1916 | { |
1934 | printk(KERN_INFO MODULE_NAME ": unloading\n"); | ||
1935 | pcmcia_unregister_driver(&cm4000_driver); | 1917 | pcmcia_unregister_driver(&cm4000_driver); |
1936 | unregister_chrdev(major, DEVICE_NAME); | 1918 | unregister_chrdev(major, DEVICE_NAME); |
1937 | class_destroy(cmm_class); | 1919 | class_destroy(cmm_class); |
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 815cde1d0570..8dd48a2be911 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c | |||
@@ -24,12 +24,11 @@ | |||
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/poll.h> | 26 | #include <linux/poll.h> |
27 | #include <linux/smp_lock.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/wait.h> | 28 | #include <linux/wait.h> |
29 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | 31 | ||
32 | #include <pcmcia/cs.h> | ||
33 | #include <pcmcia/cistpl.h> | 32 | #include <pcmcia/cistpl.h> |
34 | #include <pcmcia/cisreg.h> | 33 | #include <pcmcia/cisreg.h> |
35 | #include <pcmcia/ciscode.h> | 34 | #include <pcmcia/ciscode.h> |
@@ -49,8 +48,7 @@ | |||
49 | __func__ , ## args); \ | 48 | __func__ , ## args); \ |
50 | } while (0) | 49 | } while (0) |
51 | 50 | ||
52 | static char *version = | 51 | static DEFINE_MUTEX(cm4040_mutex); |
53 | "OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte"; | ||
54 | 52 | ||
55 | #define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) | 53 | #define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) |
56 | #define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) | 54 | #define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) |
@@ -444,7 +442,7 @@ static int cm4040_open(struct inode *inode, struct file *filp) | |||
444 | if (minor >= CM_MAX_DEV) | 442 | if (minor >= CM_MAX_DEV) |
445 | return -ENODEV; | 443 | return -ENODEV; |
446 | 444 | ||
447 | lock_kernel(); | 445 | mutex_lock(&cm4040_mutex); |
448 | link = dev_table[minor]; | 446 | link = dev_table[minor]; |
449 | if (link == NULL || !pcmcia_dev_present(link)) { | 447 | if (link == NULL || !pcmcia_dev_present(link)) { |
450 | ret = -ENODEV; | 448 | ret = -ENODEV; |
@@ -473,7 +471,7 @@ static int cm4040_open(struct inode *inode, struct file *filp) | |||
473 | DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); | 471 | DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); |
474 | ret = nonseekable_open(inode, filp); | 472 | ret = nonseekable_open(inode, filp); |
475 | out: | 473 | out: |
476 | unlock_kernel(); | 474 | mutex_unlock(&cm4040_mutex); |
477 | return ret; | 475 | return ret; |
478 | } | 476 | } |
479 | 477 | ||
@@ -516,26 +514,9 @@ static void cm4040_reader_release(struct pcmcia_device *link) | |||
516 | return; | 514 | return; |
517 | } | 515 | } |
518 | 516 | ||
519 | static int cm4040_config_check(struct pcmcia_device *p_dev, | 517 | static int cm4040_config_check(struct pcmcia_device *p_dev, void *priv_data) |
520 | cistpl_cftable_entry_t *cfg, | ||
521 | cistpl_cftable_entry_t *dflt, | ||
522 | unsigned int vcc, | ||
523 | void *priv_data) | ||
524 | { | 518 | { |
525 | int rc; | 519 | return pcmcia_request_io(p_dev); |
526 | if (!cfg->io.nwin) | ||
527 | return -ENODEV; | ||
528 | |||
529 | /* Get the IOaddr */ | ||
530 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
531 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
532 | p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); | ||
533 | p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
534 | rc = pcmcia_request_io(p_dev); | ||
535 | |||
536 | dev_printk(KERN_INFO, &p_dev->dev, | ||
537 | "pcmcia_request_io returned 0x%x\n", rc); | ||
538 | return rc; | ||
539 | } | 520 | } |
540 | 521 | ||
541 | 522 | ||
@@ -544,15 +525,15 @@ static int reader_config(struct pcmcia_device *link, int devno) | |||
544 | struct reader_dev *dev; | 525 | struct reader_dev *dev; |
545 | int fail_rc; | 526 | int fail_rc; |
546 | 527 | ||
528 | link->config_flags |= CONF_AUTO_SET_IO; | ||
529 | |||
547 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) | 530 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) |
548 | goto cs_release; | 531 | goto cs_release; |
549 | 532 | ||
550 | link->conf.IntType = 00000002; | 533 | fail_rc = pcmcia_enable_device(link); |
551 | |||
552 | fail_rc = pcmcia_request_configuration(link, &link->conf); | ||
553 | if (fail_rc != 0) { | 534 | if (fail_rc != 0) { |
554 | dev_printk(KERN_INFO, &link->dev, | 535 | dev_printk(KERN_INFO, &link->dev, |
555 | "pcmcia_request_configuration failed 0x%x\n", | 536 | "pcmcia_enable_device failed 0x%x\n", |
556 | fail_rc); | 537 | fail_rc); |
557 | goto cs_release; | 538 | goto cs_release; |
558 | } | 539 | } |
@@ -599,7 +580,6 @@ static int reader_probe(struct pcmcia_device *link) | |||
599 | link->priv = dev; | 580 | link->priv = dev; |
600 | dev->p_dev = link; | 581 | dev->p_dev = link; |
601 | 582 | ||
602 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
603 | dev_table[i] = link; | 583 | dev_table[i] = link; |
604 | 584 | ||
605 | init_waitqueue_head(&dev->devq); | 585 | init_waitqueue_head(&dev->devq); |
@@ -650,9 +630,10 @@ static const struct file_operations reader_fops = { | |||
650 | .open = cm4040_open, | 630 | .open = cm4040_open, |
651 | .release = cm4040_close, | 631 | .release = cm4040_close, |
652 | .poll = cm4040_poll, | 632 | .poll = cm4040_poll, |
633 | .llseek = no_llseek, | ||
653 | }; | 634 | }; |
654 | 635 | ||
655 | static struct pcmcia_device_id cm4040_ids[] = { | 636 | static const struct pcmcia_device_id cm4040_ids[] = { |
656 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200), | 637 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200), |
657 | PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040", | 638 | PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040", |
658 | 0xE32CDD8C, 0x8F23318B), | 639 | 0xE32CDD8C, 0x8F23318B), |
@@ -662,9 +643,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4040_ids); | |||
662 | 643 | ||
663 | static struct pcmcia_driver reader_driver = { | 644 | static struct pcmcia_driver reader_driver = { |
664 | .owner = THIS_MODULE, | 645 | .owner = THIS_MODULE, |
665 | .drv = { | 646 | .name = "cm4040_cs", |
666 | .name = "cm4040_cs", | ||
667 | }, | ||
668 | .probe = reader_probe, | 647 | .probe = reader_probe, |
669 | .remove = reader_detach, | 648 | .remove = reader_detach, |
670 | .id_table = cm4040_ids, | 649 | .id_table = cm4040_ids, |
@@ -674,7 +653,6 @@ static int __init cm4040_init(void) | |||
674 | { | 653 | { |
675 | int rc; | 654 | int rc; |
676 | 655 | ||
677 | printk(KERN_INFO "%s\n", version); | ||
678 | cmx_class = class_create(THIS_MODULE, "cardman_4040"); | 656 | cmx_class = class_create(THIS_MODULE, "cardman_4040"); |
679 | if (IS_ERR(cmx_class)) | 657 | if (IS_ERR(cmx_class)) |
680 | return PTR_ERR(cmx_class); | 658 | return PTR_ERR(cmx_class); |
@@ -699,7 +677,6 @@ static int __init cm4040_init(void) | |||
699 | 677 | ||
700 | static void __exit cm4040_exit(void) | 678 | static void __exit cm4040_exit(void) |
701 | { | 679 | { |
702 | printk(KERN_INFO MODULE_NAME ": unloading\n"); | ||
703 | pcmcia_unregister_driver(&reader_driver); | 680 | pcmcia_unregister_driver(&reader_driver); |
704 | unregister_chrdev(major, DEVICE_NAME); | 681 | unregister_chrdev(major, DEVICE_NAME); |
705 | class_destroy(cmx_class); | 682 | class_destroy(cmx_class); |
diff --git a/drivers/char/pcmcia/ipwireless/Makefile b/drivers/char/pcmcia/ipwireless/Makefile deleted file mode 100644 index b71eb593643d..000000000000 --- a/drivers/char/pcmcia/ipwireless/Makefile +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | # | ||
2 | # drivers/char/pcmcia/ipwireless/Makefile | ||
3 | # | ||
4 | # Makefile for the IPWireless driver | ||
5 | # | ||
6 | |||
7 | obj-$(CONFIG_IPWIRELESS) += ipwireless.o | ||
8 | |||
9 | ipwireless-objs := hardware.o main.o network.o tty.o | ||
10 | |||
diff --git a/drivers/char/pcmcia/ipwireless/hardware.c b/drivers/char/pcmcia/ipwireless/hardware.c deleted file mode 100644 index 99cffdab1056..000000000000 --- a/drivers/char/pcmcia/ipwireless/hardware.c +++ /dev/null | |||
@@ -1,1764 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/irq.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/list.h> | ||
23 | #include <linux/slab.h> | ||
24 | |||
25 | #include "hardware.h" | ||
26 | #include "setup_protocol.h" | ||
27 | #include "network.h" | ||
28 | #include "main.h" | ||
29 | |||
30 | static void ipw_send_setup_packet(struct ipw_hardware *hw); | ||
31 | static void handle_received_SETUP_packet(struct ipw_hardware *ipw, | ||
32 | unsigned int address, | ||
33 | const unsigned char *data, int len, | ||
34 | int is_last); | ||
35 | static void ipwireless_setup_timer(unsigned long data); | ||
36 | static void handle_received_CTRL_packet(struct ipw_hardware *hw, | ||
37 | unsigned int channel_idx, const unsigned char *data, int len); | ||
38 | |||
39 | /*#define TIMING_DIAGNOSTICS*/ | ||
40 | |||
41 | #ifdef TIMING_DIAGNOSTICS | ||
42 | |||
43 | static struct timing_stats { | ||
44 | unsigned long last_report_time; | ||
45 | unsigned long read_time; | ||
46 | unsigned long write_time; | ||
47 | unsigned long read_bytes; | ||
48 | unsigned long write_bytes; | ||
49 | unsigned long start_time; | ||
50 | }; | ||
51 | |||
52 | static void start_timing(void) | ||
53 | { | ||
54 | timing_stats.start_time = jiffies; | ||
55 | } | ||
56 | |||
57 | static void end_read_timing(unsigned length) | ||
58 | { | ||
59 | timing_stats.read_time += (jiffies - start_time); | ||
60 | timing_stats.read_bytes += length + 2; | ||
61 | report_timing(); | ||
62 | } | ||
63 | |||
64 | static void end_write_timing(unsigned length) | ||
65 | { | ||
66 | timing_stats.write_time += (jiffies - start_time); | ||
67 | timing_stats.write_bytes += length + 2; | ||
68 | report_timing(); | ||
69 | } | ||
70 | |||
71 | static void report_timing(void) | ||
72 | { | ||
73 | unsigned long since = jiffies - timing_stats.last_report_time; | ||
74 | |||
75 | /* If it's been more than one second... */ | ||
76 | if (since >= HZ) { | ||
77 | int first = (timing_stats.last_report_time == 0); | ||
78 | |||
79 | timing_stats.last_report_time = jiffies; | ||
80 | if (!first) | ||
81 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
82 | ": %u us elapsed - read %lu bytes in %u us, wrote %lu bytes in %u us\n", | ||
83 | jiffies_to_usecs(since), | ||
84 | timing_stats.read_bytes, | ||
85 | jiffies_to_usecs(timing_stats.read_time), | ||
86 | timing_stats.write_bytes, | ||
87 | jiffies_to_usecs(timing_stats.write_time)); | ||
88 | |||
89 | timing_stats.read_time = 0; | ||
90 | timing_stats.write_time = 0; | ||
91 | timing_stats.read_bytes = 0; | ||
92 | timing_stats.write_bytes = 0; | ||
93 | } | ||
94 | } | ||
95 | #else | ||
96 | static void start_timing(void) { } | ||
97 | static void end_read_timing(unsigned length) { } | ||
98 | static void end_write_timing(unsigned length) { } | ||
99 | #endif | ||
100 | |||
101 | /* Imported IPW definitions */ | ||
102 | |||
103 | #define LL_MTU_V1 318 | ||
104 | #define LL_MTU_V2 250 | ||
105 | #define LL_MTU_MAX (LL_MTU_V1 > LL_MTU_V2 ? LL_MTU_V1 : LL_MTU_V2) | ||
106 | |||
107 | #define PRIO_DATA 2 | ||
108 | #define PRIO_CTRL 1 | ||
109 | #define PRIO_SETUP 0 | ||
110 | |||
111 | /* Addresses */ | ||
112 | #define ADDR_SETUP_PROT 0 | ||
113 | |||
114 | /* Protocol ids */ | ||
115 | enum { | ||
116 | /* Identifier for the Com Data protocol */ | ||
117 | TL_PROTOCOLID_COM_DATA = 0, | ||
118 | |||
119 | /* Identifier for the Com Control protocol */ | ||
120 | TL_PROTOCOLID_COM_CTRL = 1, | ||
121 | |||
122 | /* Identifier for the Setup protocol */ | ||
123 | TL_PROTOCOLID_SETUP = 2 | ||
124 | }; | ||
125 | |||
126 | /* Number of bytes in NL packet header (cannot do | ||
127 | * sizeof(nl_packet_header) since it's a bitfield) */ | ||
128 | #define NL_FIRST_PACKET_HEADER_SIZE 3 | ||
129 | |||
130 | /* Number of bytes in NL packet header (cannot do | ||
131 | * sizeof(nl_packet_header) since it's a bitfield) */ | ||
132 | #define NL_FOLLOWING_PACKET_HEADER_SIZE 1 | ||
133 | |||
134 | struct nl_first_packet_header { | ||
135 | unsigned char protocol:3; | ||
136 | unsigned char address:3; | ||
137 | unsigned char packet_rank:2; | ||
138 | unsigned char length_lsb; | ||
139 | unsigned char length_msb; | ||
140 | }; | ||
141 | |||
142 | struct nl_packet_header { | ||
143 | unsigned char protocol:3; | ||
144 | unsigned char address:3; | ||
145 | unsigned char packet_rank:2; | ||
146 | }; | ||
147 | |||
148 | /* Value of 'packet_rank' above */ | ||
149 | #define NL_INTERMEDIATE_PACKET 0x0 | ||
150 | #define NL_LAST_PACKET 0x1 | ||
151 | #define NL_FIRST_PACKET 0x2 | ||
152 | |||
153 | union nl_packet { | ||
154 | /* Network packet header of the first packet (a special case) */ | ||
155 | struct nl_first_packet_header hdr_first; | ||
156 | /* Network packet header of the following packets (if any) */ | ||
157 | struct nl_packet_header hdr; | ||
158 | /* Complete network packet (header + data) */ | ||
159 | unsigned char rawpkt[LL_MTU_MAX]; | ||
160 | } __attribute__ ((__packed__)); | ||
161 | |||
162 | #define HW_VERSION_UNKNOWN -1 | ||
163 | #define HW_VERSION_1 1 | ||
164 | #define HW_VERSION_2 2 | ||
165 | |||
166 | /* IPW I/O ports */ | ||
167 | #define IOIER 0x00 /* Interrupt Enable Register */ | ||
168 | #define IOIR 0x02 /* Interrupt Source/ACK register */ | ||
169 | #define IODCR 0x04 /* Data Control Register */ | ||
170 | #define IODRR 0x06 /* Data Read Register */ | ||
171 | #define IODWR 0x08 /* Data Write Register */ | ||
172 | #define IOESR 0x0A /* Embedded Driver Status Register */ | ||
173 | #define IORXR 0x0C /* Rx Fifo Register (Host to Embedded) */ | ||
174 | #define IOTXR 0x0E /* Tx Fifo Register (Embedded to Host) */ | ||
175 | |||
176 | /* I/O ports and bit definitions for version 1 of the hardware */ | ||
177 | |||
178 | /* IER bits*/ | ||
179 | #define IER_RXENABLED 0x1 | ||
180 | #define IER_TXENABLED 0x2 | ||
181 | |||
182 | /* ISR bits */ | ||
183 | #define IR_RXINTR 0x1 | ||
184 | #define IR_TXINTR 0x2 | ||
185 | |||
186 | /* DCR bits */ | ||
187 | #define DCR_RXDONE 0x1 | ||
188 | #define DCR_TXDONE 0x2 | ||
189 | #define DCR_RXRESET 0x4 | ||
190 | #define DCR_TXRESET 0x8 | ||
191 | |||
192 | /* I/O ports and bit definitions for version 2 of the hardware */ | ||
193 | |||
194 | struct MEMCCR { | ||
195 | unsigned short reg_config_option; /* PCCOR: Configuration Option Register */ | ||
196 | unsigned short reg_config_and_status; /* PCCSR: Configuration and Status Register */ | ||
197 | unsigned short reg_pin_replacement; /* PCPRR: Pin Replacemant Register */ | ||
198 | unsigned short reg_socket_and_copy; /* PCSCR: Socket and Copy Register */ | ||
199 | unsigned short reg_ext_status; /* PCESR: Extendend Status Register */ | ||
200 | unsigned short reg_io_base; /* PCIOB: I/O Base Register */ | ||
201 | }; | ||
202 | |||
203 | struct MEMINFREG { | ||
204 | unsigned short memreg_tx_old; /* TX Register (R/W) */ | ||
205 | unsigned short pad1; | ||
206 | unsigned short memreg_rx_done; /* RXDone Register (R/W) */ | ||
207 | unsigned short pad2; | ||
208 | unsigned short memreg_rx; /* RX Register (R/W) */ | ||
209 | unsigned short pad3; | ||
210 | unsigned short memreg_pc_interrupt_ack; /* PC intr Ack Register (W) */ | ||
211 | unsigned short pad4; | ||
212 | unsigned long memreg_card_present;/* Mask for Host to check (R) for | ||
213 | * CARD_PRESENT_VALUE */ | ||
214 | unsigned short memreg_tx_new; /* TX2 (new) Register (R/W) */ | ||
215 | }; | ||
216 | |||
217 | #define CARD_PRESENT_VALUE (0xBEEFCAFEUL) | ||
218 | |||
219 | #define MEMTX_TX 0x0001 | ||
220 | #define MEMRX_RX 0x0001 | ||
221 | #define MEMRX_RX_DONE 0x0001 | ||
222 | #define MEMRX_PCINTACKK 0x0001 | ||
223 | |||
224 | #define NL_NUM_OF_PRIORITIES 3 | ||
225 | #define NL_NUM_OF_PROTOCOLS 3 | ||
226 | #define NL_NUM_OF_ADDRESSES NO_OF_IPW_CHANNELS | ||
227 | |||
228 | struct ipw_hardware { | ||
229 | unsigned int base_port; | ||
230 | short hw_version; | ||
231 | unsigned short ll_mtu; | ||
232 | spinlock_t lock; | ||
233 | |||
234 | int initializing; | ||
235 | int init_loops; | ||
236 | struct timer_list setup_timer; | ||
237 | |||
238 | /* Flag if hw is ready to send next packet */ | ||
239 | int tx_ready; | ||
240 | /* Count of pending packets to be sent */ | ||
241 | int tx_queued; | ||
242 | struct list_head tx_queue[NL_NUM_OF_PRIORITIES]; | ||
243 | |||
244 | int rx_bytes_queued; | ||
245 | struct list_head rx_queue; | ||
246 | /* Pool of rx_packet structures that are not currently used. */ | ||
247 | struct list_head rx_pool; | ||
248 | int rx_pool_size; | ||
249 | /* True if reception of data is blocked while userspace processes it. */ | ||
250 | int blocking_rx; | ||
251 | /* True if there is RX data ready on the hardware. */ | ||
252 | int rx_ready; | ||
253 | unsigned short last_memtx_serial; | ||
254 | /* | ||
255 | * Newer versions of the V2 card firmware send serial numbers in the | ||
256 | * MemTX register. 'serial_number_detected' is set true when we detect | ||
257 | * a non-zero serial number (indicating the new firmware). Thereafter, | ||
258 | * the driver can safely ignore the Timer Recovery re-sends to avoid | ||
259 | * out-of-sync problems. | ||
260 | */ | ||
261 | int serial_number_detected; | ||
262 | struct work_struct work_rx; | ||
263 | |||
264 | /* True if we are to send the set-up data to the hardware. */ | ||
265 | int to_setup; | ||
266 | |||
267 | /* Card has been removed */ | ||
268 | int removed; | ||
269 | /* Saved irq value when we disable the interrupt. */ | ||
270 | int irq; | ||
271 | /* True if this driver is shutting down. */ | ||
272 | int shutting_down; | ||
273 | /* Modem control lines */ | ||
274 | unsigned int control_lines[NL_NUM_OF_ADDRESSES]; | ||
275 | struct ipw_rx_packet *packet_assembler[NL_NUM_OF_ADDRESSES]; | ||
276 | |||
277 | struct tasklet_struct tasklet; | ||
278 | |||
279 | /* The handle for the network layer, for the sending of events to it. */ | ||
280 | struct ipw_network *network; | ||
281 | struct MEMINFREG __iomem *memory_info_regs; | ||
282 | struct MEMCCR __iomem *memregs_CCR; | ||
283 | void (*reboot_callback) (void *data); | ||
284 | void *reboot_callback_data; | ||
285 | |||
286 | unsigned short __iomem *memreg_tx; | ||
287 | }; | ||
288 | |||
289 | /* | ||
290 | * Packet info structure for tx packets. | ||
291 | * Note: not all the fields defined here are required for all protocols | ||
292 | */ | ||
293 | struct ipw_tx_packet { | ||
294 | struct list_head queue; | ||
295 | /* channel idx + 1 */ | ||
296 | unsigned char dest_addr; | ||
297 | /* SETUP, CTRL or DATA */ | ||
298 | unsigned char protocol; | ||
299 | /* Length of data block, which starts at the end of this structure */ | ||
300 | unsigned short length; | ||
301 | /* Sending state */ | ||
302 | /* Offset of where we've sent up to so far */ | ||
303 | unsigned long offset; | ||
304 | /* Count of packet fragments, starting at 0 */ | ||
305 | int fragment_count; | ||
306 | |||
307 | /* Called after packet is sent and before is freed */ | ||
308 | void (*packet_callback) (void *cb_data, unsigned int packet_length); | ||
309 | void *callback_data; | ||
310 | }; | ||
311 | |||
312 | /* Signals from DTE */ | ||
313 | #define COMCTRL_RTS 0 | ||
314 | #define COMCTRL_DTR 1 | ||
315 | |||
316 | /* Signals from DCE */ | ||
317 | #define COMCTRL_CTS 2 | ||
318 | #define COMCTRL_DCD 3 | ||
319 | #define COMCTRL_DSR 4 | ||
320 | #define COMCTRL_RI 5 | ||
321 | |||
322 | struct ipw_control_packet_body { | ||
323 | /* DTE signal or DCE signal */ | ||
324 | unsigned char sig_no; | ||
325 | /* 0: set signal, 1: clear signal */ | ||
326 | unsigned char value; | ||
327 | } __attribute__ ((__packed__)); | ||
328 | |||
329 | struct ipw_control_packet { | ||
330 | struct ipw_tx_packet header; | ||
331 | struct ipw_control_packet_body body; | ||
332 | }; | ||
333 | |||
334 | struct ipw_rx_packet { | ||
335 | struct list_head queue; | ||
336 | unsigned int capacity; | ||
337 | unsigned int length; | ||
338 | unsigned int protocol; | ||
339 | unsigned int channel_idx; | ||
340 | }; | ||
341 | |||
342 | static char *data_type(const unsigned char *buf, unsigned length) | ||
343 | { | ||
344 | struct nl_packet_header *hdr = (struct nl_packet_header *) buf; | ||
345 | |||
346 | if (length == 0) | ||
347 | return " "; | ||
348 | |||
349 | if (hdr->packet_rank & NL_FIRST_PACKET) { | ||
350 | switch (hdr->protocol) { | ||
351 | case TL_PROTOCOLID_COM_DATA: return "DATA "; | ||
352 | case TL_PROTOCOLID_COM_CTRL: return "CTRL "; | ||
353 | case TL_PROTOCOLID_SETUP: return "SETUP"; | ||
354 | default: return "???? "; | ||
355 | } | ||
356 | } else | ||
357 | return " "; | ||
358 | } | ||
359 | |||
360 | #define DUMP_MAX_BYTES 64 | ||
361 | |||
362 | static void dump_data_bytes(const char *type, const unsigned char *data, | ||
363 | unsigned length) | ||
364 | { | ||
365 | char prefix[56]; | ||
366 | |||
367 | sprintf(prefix, IPWIRELESS_PCCARD_NAME ": %s %s ", | ||
368 | type, data_type(data, length)); | ||
369 | print_hex_dump_bytes(prefix, 0, (void *)data, | ||
370 | length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES); | ||
371 | } | ||
372 | |||
373 | static void swap_packet_bitfield_to_le(unsigned char *data) | ||
374 | { | ||
375 | #ifdef __BIG_ENDIAN_BITFIELD | ||
376 | unsigned char tmp = *data, ret = 0; | ||
377 | |||
378 | /* | ||
379 | * transform bits from aa.bbb.ccc to ccc.bbb.aa | ||
380 | */ | ||
381 | ret |= tmp & 0xc0 >> 6; | ||
382 | ret |= tmp & 0x38 >> 1; | ||
383 | ret |= tmp & 0x07 << 5; | ||
384 | *data = ret & 0xff; | ||
385 | #endif | ||
386 | } | ||
387 | |||
388 | static void swap_packet_bitfield_from_le(unsigned char *data) | ||
389 | { | ||
390 | #ifdef __BIG_ENDIAN_BITFIELD | ||
391 | unsigned char tmp = *data, ret = 0; | ||
392 | |||
393 | /* | ||
394 | * transform bits from ccc.bbb.aa to aa.bbb.ccc | ||
395 | */ | ||
396 | ret |= tmp & 0xe0 >> 5; | ||
397 | ret |= tmp & 0x1c << 1; | ||
398 | ret |= tmp & 0x03 << 6; | ||
399 | *data = ret & 0xff; | ||
400 | #endif | ||
401 | } | ||
402 | |||
403 | static void do_send_fragment(struct ipw_hardware *hw, unsigned char *data, | ||
404 | unsigned length) | ||
405 | { | ||
406 | unsigned i; | ||
407 | unsigned long flags; | ||
408 | |||
409 | start_timing(); | ||
410 | BUG_ON(length > hw->ll_mtu); | ||
411 | |||
412 | if (ipwireless_debug) | ||
413 | dump_data_bytes("send", data, length); | ||
414 | |||
415 | spin_lock_irqsave(&hw->lock, flags); | ||
416 | |||
417 | hw->tx_ready = 0; | ||
418 | swap_packet_bitfield_to_le(data); | ||
419 | |||
420 | if (hw->hw_version == HW_VERSION_1) { | ||
421 | outw((unsigned short) length, hw->base_port + IODWR); | ||
422 | |||
423 | for (i = 0; i < length; i += 2) { | ||
424 | unsigned short d = data[i]; | ||
425 | __le16 raw_data; | ||
426 | |||
427 | if (i + 1 < length) | ||
428 | d |= data[i + 1] << 8; | ||
429 | raw_data = cpu_to_le16(d); | ||
430 | outw(raw_data, hw->base_port + IODWR); | ||
431 | } | ||
432 | |||
433 | outw(DCR_TXDONE, hw->base_port + IODCR); | ||
434 | } else if (hw->hw_version == HW_VERSION_2) { | ||
435 | outw((unsigned short) length, hw->base_port); | ||
436 | |||
437 | for (i = 0; i < length; i += 2) { | ||
438 | unsigned short d = data[i]; | ||
439 | __le16 raw_data; | ||
440 | |||
441 | if (i + 1 < length) | ||
442 | d |= data[i + 1] << 8; | ||
443 | raw_data = cpu_to_le16(d); | ||
444 | outw(raw_data, hw->base_port); | ||
445 | } | ||
446 | while ((i & 3) != 2) { | ||
447 | outw((unsigned short) 0xDEAD, hw->base_port); | ||
448 | i += 2; | ||
449 | } | ||
450 | writew(MEMRX_RX, &hw->memory_info_regs->memreg_rx); | ||
451 | } | ||
452 | |||
453 | spin_unlock_irqrestore(&hw->lock, flags); | ||
454 | |||
455 | end_write_timing(length); | ||
456 | } | ||
457 | |||
458 | static void do_send_packet(struct ipw_hardware *hw, struct ipw_tx_packet *packet) | ||
459 | { | ||
460 | unsigned short fragment_data_len; | ||
461 | unsigned short data_left = packet->length - packet->offset; | ||
462 | unsigned short header_size; | ||
463 | union nl_packet pkt; | ||
464 | |||
465 | header_size = | ||
466 | (packet->fragment_count == 0) | ||
467 | ? NL_FIRST_PACKET_HEADER_SIZE | ||
468 | : NL_FOLLOWING_PACKET_HEADER_SIZE; | ||
469 | fragment_data_len = hw->ll_mtu - header_size; | ||
470 | if (data_left < fragment_data_len) | ||
471 | fragment_data_len = data_left; | ||
472 | |||
473 | /* | ||
474 | * hdr_first is now in machine bitfield order, which will be swapped | ||
475 | * to le just before it goes to hw | ||
476 | */ | ||
477 | pkt.hdr_first.protocol = packet->protocol; | ||
478 | pkt.hdr_first.address = packet->dest_addr; | ||
479 | pkt.hdr_first.packet_rank = 0; | ||
480 | |||
481 | /* First packet? */ | ||
482 | if (packet->fragment_count == 0) { | ||
483 | pkt.hdr_first.packet_rank |= NL_FIRST_PACKET; | ||
484 | pkt.hdr_first.length_lsb = (unsigned char) packet->length; | ||
485 | pkt.hdr_first.length_msb = | ||
486 | (unsigned char) (packet->length >> 8); | ||
487 | } | ||
488 | |||
489 | memcpy(pkt.rawpkt + header_size, | ||
490 | ((unsigned char *) packet) + sizeof(struct ipw_tx_packet) + | ||
491 | packet->offset, fragment_data_len); | ||
492 | packet->offset += fragment_data_len; | ||
493 | packet->fragment_count++; | ||
494 | |||
495 | /* Last packet? (May also be first packet.) */ | ||
496 | if (packet->offset == packet->length) | ||
497 | pkt.hdr_first.packet_rank |= NL_LAST_PACKET; | ||
498 | do_send_fragment(hw, pkt.rawpkt, header_size + fragment_data_len); | ||
499 | |||
500 | /* If this packet has unsent data, then re-queue it. */ | ||
501 | if (packet->offset < packet->length) { | ||
502 | /* | ||
503 | * Re-queue it at the head of the highest priority queue so | ||
504 | * it goes before all other packets | ||
505 | */ | ||
506 | unsigned long flags; | ||
507 | |||
508 | spin_lock_irqsave(&hw->lock, flags); | ||
509 | list_add(&packet->queue, &hw->tx_queue[0]); | ||
510 | hw->tx_queued++; | ||
511 | spin_unlock_irqrestore(&hw->lock, flags); | ||
512 | } else { | ||
513 | if (packet->packet_callback) | ||
514 | packet->packet_callback(packet->callback_data, | ||
515 | packet->length); | ||
516 | kfree(packet); | ||
517 | } | ||
518 | } | ||
519 | |||
520 | static void ipw_setup_hardware(struct ipw_hardware *hw) | ||
521 | { | ||
522 | unsigned long flags; | ||
523 | |||
524 | spin_lock_irqsave(&hw->lock, flags); | ||
525 | if (hw->hw_version == HW_VERSION_1) { | ||
526 | /* Reset RX FIFO */ | ||
527 | outw(DCR_RXRESET, hw->base_port + IODCR); | ||
528 | /* SB: Reset TX FIFO */ | ||
529 | outw(DCR_TXRESET, hw->base_port + IODCR); | ||
530 | |||
531 | /* Enable TX and RX interrupts. */ | ||
532 | outw(IER_TXENABLED | IER_RXENABLED, hw->base_port + IOIER); | ||
533 | } else { | ||
534 | /* | ||
535 | * Set INTRACK bit (bit 0), which means we must explicitly | ||
536 | * acknowledge interrupts by clearing bit 2 of reg_config_and_status. | ||
537 | */ | ||
538 | unsigned short csr = readw(&hw->memregs_CCR->reg_config_and_status); | ||
539 | |||
540 | csr |= 1; | ||
541 | writew(csr, &hw->memregs_CCR->reg_config_and_status); | ||
542 | } | ||
543 | spin_unlock_irqrestore(&hw->lock, flags); | ||
544 | } | ||
545 | |||
546 | /* | ||
547 | * If 'packet' is NULL, then this function allocates a new packet, setting its | ||
548 | * length to 0 and ensuring it has the specified minimum amount of free space. | ||
549 | * | ||
550 | * If 'packet' is not NULL, then this function enlarges it if it doesn't | ||
551 | * have the specified minimum amount of free space. | ||
552 | * | ||
553 | */ | ||
554 | static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw, | ||
555 | struct ipw_rx_packet *packet, | ||
556 | int minimum_free_space) | ||
557 | { | ||
558 | |||
559 | if (!packet) { | ||
560 | unsigned long flags; | ||
561 | |||
562 | spin_lock_irqsave(&hw->lock, flags); | ||
563 | if (!list_empty(&hw->rx_pool)) { | ||
564 | packet = list_first_entry(&hw->rx_pool, | ||
565 | struct ipw_rx_packet, queue); | ||
566 | hw->rx_pool_size--; | ||
567 | spin_unlock_irqrestore(&hw->lock, flags); | ||
568 | list_del(&packet->queue); | ||
569 | } else { | ||
570 | const int min_capacity = | ||
571 | ipwireless_ppp_mru(hw->network) + 2; | ||
572 | int new_capacity; | ||
573 | |||
574 | spin_unlock_irqrestore(&hw->lock, flags); | ||
575 | new_capacity = | ||
576 | (minimum_free_space > min_capacity | ||
577 | ? minimum_free_space | ||
578 | : min_capacity); | ||
579 | packet = kmalloc(sizeof(struct ipw_rx_packet) | ||
580 | + new_capacity, GFP_ATOMIC); | ||
581 | if (!packet) | ||
582 | return NULL; | ||
583 | packet->capacity = new_capacity; | ||
584 | } | ||
585 | packet->length = 0; | ||
586 | } | ||
587 | |||
588 | if (packet->length + minimum_free_space > packet->capacity) { | ||
589 | struct ipw_rx_packet *old_packet = packet; | ||
590 | |||
591 | packet = kmalloc(sizeof(struct ipw_rx_packet) + | ||
592 | old_packet->length + minimum_free_space, | ||
593 | GFP_ATOMIC); | ||
594 | if (!packet) { | ||
595 | kfree(old_packet); | ||
596 | return NULL; | ||
597 | } | ||
598 | memcpy(packet, old_packet, | ||
599 | sizeof(struct ipw_rx_packet) | ||
600 | + old_packet->length); | ||
601 | packet->capacity = old_packet->length + minimum_free_space; | ||
602 | kfree(old_packet); | ||
603 | } | ||
604 | |||
605 | return packet; | ||
606 | } | ||
607 | |||
608 | static void pool_free(struct ipw_hardware *hw, struct ipw_rx_packet *packet) | ||
609 | { | ||
610 | if (hw->rx_pool_size > 6) | ||
611 | kfree(packet); | ||
612 | else { | ||
613 | hw->rx_pool_size++; | ||
614 | list_add(&packet->queue, &hw->rx_pool); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | static void queue_received_packet(struct ipw_hardware *hw, | ||
619 | unsigned int protocol, | ||
620 | unsigned int address, | ||
621 | const unsigned char *data, int length, | ||
622 | int is_last) | ||
623 | { | ||
624 | unsigned int channel_idx = address - 1; | ||
625 | struct ipw_rx_packet *packet = NULL; | ||
626 | unsigned long flags; | ||
627 | |||
628 | /* Discard packet if channel index is out of range. */ | ||
629 | if (channel_idx >= NL_NUM_OF_ADDRESSES) { | ||
630 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
631 | ": data packet has bad address %u\n", address); | ||
632 | return; | ||
633 | } | ||
634 | |||
635 | /* | ||
636 | * ->packet_assembler is safe to touch unlocked, this is the only place | ||
637 | */ | ||
638 | if (protocol == TL_PROTOCOLID_COM_DATA) { | ||
639 | struct ipw_rx_packet **assem = | ||
640 | &hw->packet_assembler[channel_idx]; | ||
641 | |||
642 | /* | ||
643 | * Create a new packet, or assembler already contains one | ||
644 | * enlarge it by 'length' bytes. | ||
645 | */ | ||
646 | (*assem) = pool_allocate(hw, *assem, length); | ||
647 | if (!(*assem)) { | ||
648 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
649 | ": no memory for incomming data packet, dropped!\n"); | ||
650 | return; | ||
651 | } | ||
652 | (*assem)->protocol = protocol; | ||
653 | (*assem)->channel_idx = channel_idx; | ||
654 | |||
655 | /* Append this packet data onto existing data. */ | ||
656 | memcpy((unsigned char *)(*assem) + | ||
657 | sizeof(struct ipw_rx_packet) | ||
658 | + (*assem)->length, data, length); | ||
659 | (*assem)->length += length; | ||
660 | if (is_last) { | ||
661 | packet = *assem; | ||
662 | *assem = NULL; | ||
663 | /* Count queued DATA bytes only */ | ||
664 | spin_lock_irqsave(&hw->lock, flags); | ||
665 | hw->rx_bytes_queued += packet->length; | ||
666 | spin_unlock_irqrestore(&hw->lock, flags); | ||
667 | } | ||
668 | } else { | ||
669 | /* If it's a CTRL packet, don't assemble, just queue it. */ | ||
670 | packet = pool_allocate(hw, NULL, length); | ||
671 | if (!packet) { | ||
672 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
673 | ": no memory for incomming ctrl packet, dropped!\n"); | ||
674 | return; | ||
675 | } | ||
676 | packet->protocol = protocol; | ||
677 | packet->channel_idx = channel_idx; | ||
678 | memcpy((unsigned char *)packet + sizeof(struct ipw_rx_packet), | ||
679 | data, length); | ||
680 | packet->length = length; | ||
681 | } | ||
682 | |||
683 | /* | ||
684 | * If this is the last packet, then send the assembled packet on to the | ||
685 | * network layer. | ||
686 | */ | ||
687 | if (packet) { | ||
688 | spin_lock_irqsave(&hw->lock, flags); | ||
689 | list_add_tail(&packet->queue, &hw->rx_queue); | ||
690 | /* Block reception of incoming packets if queue is full. */ | ||
691 | hw->blocking_rx = | ||
692 | (hw->rx_bytes_queued >= IPWIRELESS_RX_QUEUE_SIZE); | ||
693 | |||
694 | spin_unlock_irqrestore(&hw->lock, flags); | ||
695 | schedule_work(&hw->work_rx); | ||
696 | } | ||
697 | } | ||
698 | |||
699 | /* | ||
700 | * Workqueue callback | ||
701 | */ | ||
702 | static void ipw_receive_data_work(struct work_struct *work_rx) | ||
703 | { | ||
704 | struct ipw_hardware *hw = | ||
705 | container_of(work_rx, struct ipw_hardware, work_rx); | ||
706 | unsigned long flags; | ||
707 | |||
708 | spin_lock_irqsave(&hw->lock, flags); | ||
709 | while (!list_empty(&hw->rx_queue)) { | ||
710 | struct ipw_rx_packet *packet = | ||
711 | list_first_entry(&hw->rx_queue, | ||
712 | struct ipw_rx_packet, queue); | ||
713 | |||
714 | if (hw->shutting_down) | ||
715 | break; | ||
716 | list_del(&packet->queue); | ||
717 | |||
718 | /* | ||
719 | * Note: ipwireless_network_packet_received must be called in a | ||
720 | * process context (i.e. via schedule_work) because the tty | ||
721 | * output code can sleep in the tty_flip_buffer_push call. | ||
722 | */ | ||
723 | if (packet->protocol == TL_PROTOCOLID_COM_DATA) { | ||
724 | if (hw->network != NULL) { | ||
725 | /* If the network hasn't been disconnected. */ | ||
726 | spin_unlock_irqrestore(&hw->lock, flags); | ||
727 | /* | ||
728 | * This must run unlocked due to tty processing | ||
729 | * and mutex locking | ||
730 | */ | ||
731 | ipwireless_network_packet_received( | ||
732 | hw->network, | ||
733 | packet->channel_idx, | ||
734 | (unsigned char *)packet | ||
735 | + sizeof(struct ipw_rx_packet), | ||
736 | packet->length); | ||
737 | spin_lock_irqsave(&hw->lock, flags); | ||
738 | } | ||
739 | /* Count queued DATA bytes only */ | ||
740 | hw->rx_bytes_queued -= packet->length; | ||
741 | } else { | ||
742 | /* | ||
743 | * This is safe to be called locked, callchain does | ||
744 | * not block | ||
745 | */ | ||
746 | handle_received_CTRL_packet(hw, packet->channel_idx, | ||
747 | (unsigned char *)packet | ||
748 | + sizeof(struct ipw_rx_packet), | ||
749 | packet->length); | ||
750 | } | ||
751 | pool_free(hw, packet); | ||
752 | /* | ||
753 | * Unblock reception of incoming packets if queue is no longer | ||
754 | * full. | ||
755 | */ | ||
756 | hw->blocking_rx = | ||
757 | hw->rx_bytes_queued >= IPWIRELESS_RX_QUEUE_SIZE; | ||
758 | if (hw->shutting_down) | ||
759 | break; | ||
760 | } | ||
761 | spin_unlock_irqrestore(&hw->lock, flags); | ||
762 | } | ||
763 | |||
764 | static void handle_received_CTRL_packet(struct ipw_hardware *hw, | ||
765 | unsigned int channel_idx, | ||
766 | const unsigned char *data, int len) | ||
767 | { | ||
768 | const struct ipw_control_packet_body *body = | ||
769 | (const struct ipw_control_packet_body *) data; | ||
770 | unsigned int changed_mask; | ||
771 | |||
772 | if (len != sizeof(struct ipw_control_packet_body)) { | ||
773 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
774 | ": control packet was %d bytes - wrong size!\n", | ||
775 | len); | ||
776 | return; | ||
777 | } | ||
778 | |||
779 | switch (body->sig_no) { | ||
780 | case COMCTRL_CTS: | ||
781 | changed_mask = IPW_CONTROL_LINE_CTS; | ||
782 | break; | ||
783 | case COMCTRL_DCD: | ||
784 | changed_mask = IPW_CONTROL_LINE_DCD; | ||
785 | break; | ||
786 | case COMCTRL_DSR: | ||
787 | changed_mask = IPW_CONTROL_LINE_DSR; | ||
788 | break; | ||
789 | case COMCTRL_RI: | ||
790 | changed_mask = IPW_CONTROL_LINE_RI; | ||
791 | break; | ||
792 | default: | ||
793 | changed_mask = 0; | ||
794 | } | ||
795 | |||
796 | if (changed_mask != 0) { | ||
797 | if (body->value) | ||
798 | hw->control_lines[channel_idx] |= changed_mask; | ||
799 | else | ||
800 | hw->control_lines[channel_idx] &= ~changed_mask; | ||
801 | if (hw->network) | ||
802 | ipwireless_network_notify_control_line_change( | ||
803 | hw->network, | ||
804 | channel_idx, | ||
805 | hw->control_lines[channel_idx], | ||
806 | changed_mask); | ||
807 | } | ||
808 | } | ||
809 | |||
810 | static void handle_received_packet(struct ipw_hardware *hw, | ||
811 | const union nl_packet *packet, | ||
812 | unsigned short len) | ||
813 | { | ||
814 | unsigned int protocol = packet->hdr.protocol; | ||
815 | unsigned int address = packet->hdr.address; | ||
816 | unsigned int header_length; | ||
817 | const unsigned char *data; | ||
818 | unsigned int data_len; | ||
819 | int is_last = packet->hdr.packet_rank & NL_LAST_PACKET; | ||
820 | |||
821 | if (packet->hdr.packet_rank & NL_FIRST_PACKET) | ||
822 | header_length = NL_FIRST_PACKET_HEADER_SIZE; | ||
823 | else | ||
824 | header_length = NL_FOLLOWING_PACKET_HEADER_SIZE; | ||
825 | |||
826 | data = packet->rawpkt + header_length; | ||
827 | data_len = len - header_length; | ||
828 | switch (protocol) { | ||
829 | case TL_PROTOCOLID_COM_DATA: | ||
830 | case TL_PROTOCOLID_COM_CTRL: | ||
831 | queue_received_packet(hw, protocol, address, data, data_len, | ||
832 | is_last); | ||
833 | break; | ||
834 | case TL_PROTOCOLID_SETUP: | ||
835 | handle_received_SETUP_packet(hw, address, data, data_len, | ||
836 | is_last); | ||
837 | break; | ||
838 | } | ||
839 | } | ||
840 | |||
841 | static void acknowledge_data_read(struct ipw_hardware *hw) | ||
842 | { | ||
843 | if (hw->hw_version == HW_VERSION_1) | ||
844 | outw(DCR_RXDONE, hw->base_port + IODCR); | ||
845 | else | ||
846 | writew(MEMRX_PCINTACKK, | ||
847 | &hw->memory_info_regs->memreg_pc_interrupt_ack); | ||
848 | } | ||
849 | |||
850 | /* | ||
851 | * Retrieve a packet from the IPW hardware. | ||
852 | */ | ||
853 | static void do_receive_packet(struct ipw_hardware *hw) | ||
854 | { | ||
855 | unsigned len; | ||
856 | unsigned i; | ||
857 | unsigned char pkt[LL_MTU_MAX]; | ||
858 | |||
859 | start_timing(); | ||
860 | |||
861 | if (hw->hw_version == HW_VERSION_1) { | ||
862 | len = inw(hw->base_port + IODRR); | ||
863 | if (len > hw->ll_mtu) { | ||
864 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
865 | ": received a packet of %u bytes - longer than the MTU!\n", len); | ||
866 | outw(DCR_RXDONE | DCR_RXRESET, hw->base_port + IODCR); | ||
867 | return; | ||
868 | } | ||
869 | |||
870 | for (i = 0; i < len; i += 2) { | ||
871 | __le16 raw_data = inw(hw->base_port + IODRR); | ||
872 | unsigned short data = le16_to_cpu(raw_data); | ||
873 | |||
874 | pkt[i] = (unsigned char) data; | ||
875 | pkt[i + 1] = (unsigned char) (data >> 8); | ||
876 | } | ||
877 | } else { | ||
878 | len = inw(hw->base_port); | ||
879 | if (len > hw->ll_mtu) { | ||
880 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
881 | ": received a packet of %u bytes - longer than the MTU!\n", len); | ||
882 | writew(MEMRX_PCINTACKK, | ||
883 | &hw->memory_info_regs->memreg_pc_interrupt_ack); | ||
884 | return; | ||
885 | } | ||
886 | |||
887 | for (i = 0; i < len; i += 2) { | ||
888 | __le16 raw_data = inw(hw->base_port); | ||
889 | unsigned short data = le16_to_cpu(raw_data); | ||
890 | |||
891 | pkt[i] = (unsigned char) data; | ||
892 | pkt[i + 1] = (unsigned char) (data >> 8); | ||
893 | } | ||
894 | |||
895 | while ((i & 3) != 2) { | ||
896 | inw(hw->base_port); | ||
897 | i += 2; | ||
898 | } | ||
899 | } | ||
900 | |||
901 | acknowledge_data_read(hw); | ||
902 | |||
903 | swap_packet_bitfield_from_le(pkt); | ||
904 | |||
905 | if (ipwireless_debug) | ||
906 | dump_data_bytes("recv", pkt, len); | ||
907 | |||
908 | handle_received_packet(hw, (union nl_packet *) pkt, len); | ||
909 | |||
910 | end_read_timing(len); | ||
911 | } | ||
912 | |||
913 | static int get_current_packet_priority(struct ipw_hardware *hw) | ||
914 | { | ||
915 | /* | ||
916 | * If we're initializing, don't send anything of higher priority than | ||
917 | * PRIO_SETUP. The network layer therefore need not care about | ||
918 | * hardware initialization - any of its stuff will simply be queued | ||
919 | * until setup is complete. | ||
920 | */ | ||
921 | return (hw->to_setup || hw->initializing | ||
922 | ? PRIO_SETUP + 1 : NL_NUM_OF_PRIORITIES); | ||
923 | } | ||
924 | |||
925 | /* | ||
926 | * return 1 if something has been received from hw | ||
927 | */ | ||
928 | static int get_packets_from_hw(struct ipw_hardware *hw) | ||
929 | { | ||
930 | int received = 0; | ||
931 | unsigned long flags; | ||
932 | |||
933 | spin_lock_irqsave(&hw->lock, flags); | ||
934 | while (hw->rx_ready && !hw->blocking_rx) { | ||
935 | received = 1; | ||
936 | hw->rx_ready--; | ||
937 | spin_unlock_irqrestore(&hw->lock, flags); | ||
938 | |||
939 | do_receive_packet(hw); | ||
940 | |||
941 | spin_lock_irqsave(&hw->lock, flags); | ||
942 | } | ||
943 | spin_unlock_irqrestore(&hw->lock, flags); | ||
944 | |||
945 | return received; | ||
946 | } | ||
947 | |||
948 | /* | ||
949 | * Send pending packet up to given priority, prioritize SETUP data until | ||
950 | * hardware is fully setup. | ||
951 | * | ||
952 | * return 1 if more packets can be sent | ||
953 | */ | ||
954 | static int send_pending_packet(struct ipw_hardware *hw, int priority_limit) | ||
955 | { | ||
956 | int more_to_send = 0; | ||
957 | unsigned long flags; | ||
958 | |||
959 | spin_lock_irqsave(&hw->lock, flags); | ||
960 | if (hw->tx_queued && hw->tx_ready) { | ||
961 | int priority; | ||
962 | struct ipw_tx_packet *packet = NULL; | ||
963 | |||
964 | /* Pick a packet */ | ||
965 | for (priority = 0; priority < priority_limit; priority++) { | ||
966 | if (!list_empty(&hw->tx_queue[priority])) { | ||
967 | packet = list_first_entry( | ||
968 | &hw->tx_queue[priority], | ||
969 | struct ipw_tx_packet, | ||
970 | queue); | ||
971 | |||
972 | hw->tx_queued--; | ||
973 | list_del(&packet->queue); | ||
974 | |||
975 | break; | ||
976 | } | ||
977 | } | ||
978 | if (!packet) { | ||
979 | hw->tx_queued = 0; | ||
980 | spin_unlock_irqrestore(&hw->lock, flags); | ||
981 | return 0; | ||
982 | } | ||
983 | |||
984 | spin_unlock_irqrestore(&hw->lock, flags); | ||
985 | |||
986 | /* Send */ | ||
987 | do_send_packet(hw, packet); | ||
988 | |||
989 | /* Check if more to send */ | ||
990 | spin_lock_irqsave(&hw->lock, flags); | ||
991 | for (priority = 0; priority < priority_limit; priority++) | ||
992 | if (!list_empty(&hw->tx_queue[priority])) { | ||
993 | more_to_send = 1; | ||
994 | break; | ||
995 | } | ||
996 | |||
997 | if (!more_to_send) | ||
998 | hw->tx_queued = 0; | ||
999 | } | ||
1000 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1001 | |||
1002 | return more_to_send; | ||
1003 | } | ||
1004 | |||
1005 | /* | ||
1006 | * Send and receive all queued packets. | ||
1007 | */ | ||
1008 | static void ipwireless_do_tasklet(unsigned long hw_) | ||
1009 | { | ||
1010 | struct ipw_hardware *hw = (struct ipw_hardware *) hw_; | ||
1011 | unsigned long flags; | ||
1012 | |||
1013 | spin_lock_irqsave(&hw->lock, flags); | ||
1014 | if (hw->shutting_down) { | ||
1015 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1016 | return; | ||
1017 | } | ||
1018 | |||
1019 | if (hw->to_setup == 1) { | ||
1020 | /* | ||
1021 | * Initial setup data sent to hardware | ||
1022 | */ | ||
1023 | hw->to_setup = 2; | ||
1024 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1025 | |||
1026 | ipw_setup_hardware(hw); | ||
1027 | ipw_send_setup_packet(hw); | ||
1028 | |||
1029 | send_pending_packet(hw, PRIO_SETUP + 1); | ||
1030 | get_packets_from_hw(hw); | ||
1031 | } else { | ||
1032 | int priority_limit = get_current_packet_priority(hw); | ||
1033 | int again; | ||
1034 | |||
1035 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1036 | |||
1037 | do { | ||
1038 | again = send_pending_packet(hw, priority_limit); | ||
1039 | again |= get_packets_from_hw(hw); | ||
1040 | } while (again); | ||
1041 | } | ||
1042 | } | ||
1043 | |||
1044 | /* | ||
1045 | * return true if the card is physically present. | ||
1046 | */ | ||
1047 | static int is_card_present(struct ipw_hardware *hw) | ||
1048 | { | ||
1049 | if (hw->hw_version == HW_VERSION_1) | ||
1050 | return inw(hw->base_port + IOIR) != 0xFFFF; | ||
1051 | else | ||
1052 | return readl(&hw->memory_info_regs->memreg_card_present) == | ||
1053 | CARD_PRESENT_VALUE; | ||
1054 | } | ||
1055 | |||
1056 | static irqreturn_t ipwireless_handle_v1_interrupt(int irq, | ||
1057 | struct ipw_hardware *hw) | ||
1058 | { | ||
1059 | unsigned short irqn; | ||
1060 | |||
1061 | irqn = inw(hw->base_port + IOIR); | ||
1062 | |||
1063 | /* Check if card is present */ | ||
1064 | if (irqn == 0xFFFF) | ||
1065 | return IRQ_NONE; | ||
1066 | else if (irqn != 0) { | ||
1067 | unsigned short ack = 0; | ||
1068 | unsigned long flags; | ||
1069 | |||
1070 | /* Transmit complete. */ | ||
1071 | if (irqn & IR_TXINTR) { | ||
1072 | ack |= IR_TXINTR; | ||
1073 | spin_lock_irqsave(&hw->lock, flags); | ||
1074 | hw->tx_ready = 1; | ||
1075 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1076 | } | ||
1077 | /* Received data */ | ||
1078 | if (irqn & IR_RXINTR) { | ||
1079 | ack |= IR_RXINTR; | ||
1080 | spin_lock_irqsave(&hw->lock, flags); | ||
1081 | hw->rx_ready++; | ||
1082 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1083 | } | ||
1084 | if (ack != 0) { | ||
1085 | outw(ack, hw->base_port + IOIR); | ||
1086 | tasklet_schedule(&hw->tasklet); | ||
1087 | } | ||
1088 | return IRQ_HANDLED; | ||
1089 | } | ||
1090 | return IRQ_NONE; | ||
1091 | } | ||
1092 | |||
1093 | static void acknowledge_pcmcia_interrupt(struct ipw_hardware *hw) | ||
1094 | { | ||
1095 | unsigned short csr = readw(&hw->memregs_CCR->reg_config_and_status); | ||
1096 | |||
1097 | csr &= 0xfffd; | ||
1098 | writew(csr, &hw->memregs_CCR->reg_config_and_status); | ||
1099 | } | ||
1100 | |||
1101 | static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq, | ||
1102 | struct ipw_hardware *hw) | ||
1103 | { | ||
1104 | int tx = 0; | ||
1105 | int rx = 0; | ||
1106 | int rx_repeat = 0; | ||
1107 | int try_mem_tx_old; | ||
1108 | unsigned long flags; | ||
1109 | |||
1110 | do { | ||
1111 | |||
1112 | unsigned short memtx = readw(hw->memreg_tx); | ||
1113 | unsigned short memtx_serial; | ||
1114 | unsigned short memrxdone = | ||
1115 | readw(&hw->memory_info_regs->memreg_rx_done); | ||
1116 | |||
1117 | try_mem_tx_old = 0; | ||
1118 | |||
1119 | /* check whether the interrupt was generated by ipwireless card */ | ||
1120 | if (!(memtx & MEMTX_TX) && !(memrxdone & MEMRX_RX_DONE)) { | ||
1121 | |||
1122 | /* check if the card uses memreg_tx_old register */ | ||
1123 | if (hw->memreg_tx == &hw->memory_info_regs->memreg_tx_new) { | ||
1124 | memtx = readw(&hw->memory_info_regs->memreg_tx_old); | ||
1125 | if (memtx & MEMTX_TX) { | ||
1126 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1127 | ": Using memreg_tx_old\n"); | ||
1128 | hw->memreg_tx = | ||
1129 | &hw->memory_info_regs->memreg_tx_old; | ||
1130 | } else { | ||
1131 | return IRQ_NONE; | ||
1132 | } | ||
1133 | } else | ||
1134 | return IRQ_NONE; | ||
1135 | } | ||
1136 | |||
1137 | /* | ||
1138 | * See if the card is physically present. Note that while it is | ||
1139 | * powering up, it appears not to be present. | ||
1140 | */ | ||
1141 | if (!is_card_present(hw)) { | ||
1142 | acknowledge_pcmcia_interrupt(hw); | ||
1143 | return IRQ_HANDLED; | ||
1144 | } | ||
1145 | |||
1146 | memtx_serial = memtx & (unsigned short) 0xff00; | ||
1147 | if (memtx & MEMTX_TX) { | ||
1148 | writew(memtx_serial, hw->memreg_tx); | ||
1149 | |||
1150 | if (hw->serial_number_detected) { | ||
1151 | if (memtx_serial != hw->last_memtx_serial) { | ||
1152 | hw->last_memtx_serial = memtx_serial; | ||
1153 | spin_lock_irqsave(&hw->lock, flags); | ||
1154 | hw->rx_ready++; | ||
1155 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1156 | rx = 1; | ||
1157 | } else | ||
1158 | /* Ignore 'Timer Recovery' duplicates. */ | ||
1159 | rx_repeat = 1; | ||
1160 | } else { | ||
1161 | /* | ||
1162 | * If a non-zero serial number is seen, then enable | ||
1163 | * serial number checking. | ||
1164 | */ | ||
1165 | if (memtx_serial != 0) { | ||
1166 | hw->serial_number_detected = 1; | ||
1167 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME | ||
1168 | ": memreg_tx serial num detected\n"); | ||
1169 | |||
1170 | spin_lock_irqsave(&hw->lock, flags); | ||
1171 | hw->rx_ready++; | ||
1172 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1173 | } | ||
1174 | rx = 1; | ||
1175 | } | ||
1176 | } | ||
1177 | if (memrxdone & MEMRX_RX_DONE) { | ||
1178 | writew(0, &hw->memory_info_regs->memreg_rx_done); | ||
1179 | spin_lock_irqsave(&hw->lock, flags); | ||
1180 | hw->tx_ready = 1; | ||
1181 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1182 | tx = 1; | ||
1183 | } | ||
1184 | if (tx) | ||
1185 | writew(MEMRX_PCINTACKK, | ||
1186 | &hw->memory_info_regs->memreg_pc_interrupt_ack); | ||
1187 | |||
1188 | acknowledge_pcmcia_interrupt(hw); | ||
1189 | |||
1190 | if (tx || rx) | ||
1191 | tasklet_schedule(&hw->tasklet); | ||
1192 | else if (!rx_repeat) { | ||
1193 | if (hw->memreg_tx == &hw->memory_info_regs->memreg_tx_new) { | ||
1194 | if (hw->serial_number_detected) | ||
1195 | printk(KERN_WARNING IPWIRELESS_PCCARD_NAME | ||
1196 | ": spurious interrupt - new_tx mode\n"); | ||
1197 | else { | ||
1198 | printk(KERN_WARNING IPWIRELESS_PCCARD_NAME | ||
1199 | ": no valid memreg_tx value - switching to the old memreg_tx\n"); | ||
1200 | hw->memreg_tx = | ||
1201 | &hw->memory_info_regs->memreg_tx_old; | ||
1202 | try_mem_tx_old = 1; | ||
1203 | } | ||
1204 | } else | ||
1205 | printk(KERN_WARNING IPWIRELESS_PCCARD_NAME | ||
1206 | ": spurious interrupt - old_tx mode\n"); | ||
1207 | } | ||
1208 | |||
1209 | } while (try_mem_tx_old == 1); | ||
1210 | |||
1211 | return IRQ_HANDLED; | ||
1212 | } | ||
1213 | |||
1214 | irqreturn_t ipwireless_interrupt(int irq, void *dev_id) | ||
1215 | { | ||
1216 | struct ipw_dev *ipw = dev_id; | ||
1217 | |||
1218 | if (ipw->hardware->hw_version == HW_VERSION_1) | ||
1219 | return ipwireless_handle_v1_interrupt(irq, ipw->hardware); | ||
1220 | else | ||
1221 | return ipwireless_handle_v2_v3_interrupt(irq, ipw->hardware); | ||
1222 | } | ||
1223 | |||
1224 | static void flush_packets_to_hw(struct ipw_hardware *hw) | ||
1225 | { | ||
1226 | int priority_limit; | ||
1227 | unsigned long flags; | ||
1228 | |||
1229 | spin_lock_irqsave(&hw->lock, flags); | ||
1230 | priority_limit = get_current_packet_priority(hw); | ||
1231 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1232 | |||
1233 | while (send_pending_packet(hw, priority_limit)); | ||
1234 | } | ||
1235 | |||
1236 | static void send_packet(struct ipw_hardware *hw, int priority, | ||
1237 | struct ipw_tx_packet *packet) | ||
1238 | { | ||
1239 | unsigned long flags; | ||
1240 | |||
1241 | spin_lock_irqsave(&hw->lock, flags); | ||
1242 | list_add_tail(&packet->queue, &hw->tx_queue[priority]); | ||
1243 | hw->tx_queued++; | ||
1244 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1245 | |||
1246 | flush_packets_to_hw(hw); | ||
1247 | } | ||
1248 | |||
1249 | /* Create data packet, non-atomic allocation */ | ||
1250 | static void *alloc_data_packet(int data_size, | ||
1251 | unsigned char dest_addr, | ||
1252 | unsigned char protocol) | ||
1253 | { | ||
1254 | struct ipw_tx_packet *packet = kzalloc( | ||
1255 | sizeof(struct ipw_tx_packet) + data_size, | ||
1256 | GFP_ATOMIC); | ||
1257 | |||
1258 | if (!packet) | ||
1259 | return NULL; | ||
1260 | |||
1261 | INIT_LIST_HEAD(&packet->queue); | ||
1262 | packet->dest_addr = dest_addr; | ||
1263 | packet->protocol = protocol; | ||
1264 | packet->length = data_size; | ||
1265 | |||
1266 | return packet; | ||
1267 | } | ||
1268 | |||
1269 | static void *alloc_ctrl_packet(int header_size, | ||
1270 | unsigned char dest_addr, | ||
1271 | unsigned char protocol, | ||
1272 | unsigned char sig_no) | ||
1273 | { | ||
1274 | /* | ||
1275 | * sig_no is located right after ipw_tx_packet struct in every | ||
1276 | * CTRL or SETUP packets, we can use ipw_control_packet as a | ||
1277 | * common struct | ||
1278 | */ | ||
1279 | struct ipw_control_packet *packet = kzalloc(header_size, GFP_ATOMIC); | ||
1280 | |||
1281 | if (!packet) | ||
1282 | return NULL; | ||
1283 | |||
1284 | INIT_LIST_HEAD(&packet->header.queue); | ||
1285 | packet->header.dest_addr = dest_addr; | ||
1286 | packet->header.protocol = protocol; | ||
1287 | packet->header.length = header_size - sizeof(struct ipw_tx_packet); | ||
1288 | packet->body.sig_no = sig_no; | ||
1289 | |||
1290 | return packet; | ||
1291 | } | ||
1292 | |||
1293 | int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx, | ||
1294 | const unsigned char *data, unsigned int length, | ||
1295 | void (*callback) (void *cb, unsigned int length), | ||
1296 | void *callback_data) | ||
1297 | { | ||
1298 | struct ipw_tx_packet *packet; | ||
1299 | |||
1300 | packet = alloc_data_packet(length, (channel_idx + 1), | ||
1301 | TL_PROTOCOLID_COM_DATA); | ||
1302 | if (!packet) | ||
1303 | return -ENOMEM; | ||
1304 | packet->packet_callback = callback; | ||
1305 | packet->callback_data = callback_data; | ||
1306 | memcpy((unsigned char *) packet + sizeof(struct ipw_tx_packet), data, | ||
1307 | length); | ||
1308 | |||
1309 | send_packet(hw, PRIO_DATA, packet); | ||
1310 | return 0; | ||
1311 | } | ||
1312 | |||
1313 | static int set_control_line(struct ipw_hardware *hw, int prio, | ||
1314 | unsigned int channel_idx, int line, int state) | ||
1315 | { | ||
1316 | struct ipw_control_packet *packet; | ||
1317 | int protocolid = TL_PROTOCOLID_COM_CTRL; | ||
1318 | |||
1319 | if (prio == PRIO_SETUP) | ||
1320 | protocolid = TL_PROTOCOLID_SETUP; | ||
1321 | |||
1322 | packet = alloc_ctrl_packet(sizeof(struct ipw_control_packet), | ||
1323 | (channel_idx + 1), protocolid, line); | ||
1324 | if (!packet) | ||
1325 | return -ENOMEM; | ||
1326 | packet->header.length = sizeof(struct ipw_control_packet_body); | ||
1327 | packet->body.value = (state == 0 ? 0 : 1); | ||
1328 | send_packet(hw, prio, &packet->header); | ||
1329 | return 0; | ||
1330 | } | ||
1331 | |||
1332 | |||
1333 | static int set_DTR(struct ipw_hardware *hw, int priority, | ||
1334 | unsigned int channel_idx, int state) | ||
1335 | { | ||
1336 | if (state != 0) | ||
1337 | hw->control_lines[channel_idx] |= IPW_CONTROL_LINE_DTR; | ||
1338 | else | ||
1339 | hw->control_lines[channel_idx] &= ~IPW_CONTROL_LINE_DTR; | ||
1340 | |||
1341 | return set_control_line(hw, priority, channel_idx, COMCTRL_DTR, state); | ||
1342 | } | ||
1343 | |||
1344 | static int set_RTS(struct ipw_hardware *hw, int priority, | ||
1345 | unsigned int channel_idx, int state) | ||
1346 | { | ||
1347 | if (state != 0) | ||
1348 | hw->control_lines[channel_idx] |= IPW_CONTROL_LINE_RTS; | ||
1349 | else | ||
1350 | hw->control_lines[channel_idx] &= ~IPW_CONTROL_LINE_RTS; | ||
1351 | |||
1352 | return set_control_line(hw, priority, channel_idx, COMCTRL_RTS, state); | ||
1353 | } | ||
1354 | |||
1355 | int ipwireless_set_DTR(struct ipw_hardware *hw, unsigned int channel_idx, | ||
1356 | int state) | ||
1357 | { | ||
1358 | return set_DTR(hw, PRIO_CTRL, channel_idx, state); | ||
1359 | } | ||
1360 | |||
1361 | int ipwireless_set_RTS(struct ipw_hardware *hw, unsigned int channel_idx, | ||
1362 | int state) | ||
1363 | { | ||
1364 | return set_RTS(hw, PRIO_CTRL, channel_idx, state); | ||
1365 | } | ||
1366 | |||
1367 | struct ipw_setup_get_version_query_packet { | ||
1368 | struct ipw_tx_packet header; | ||
1369 | struct tl_setup_get_version_qry body; | ||
1370 | }; | ||
1371 | |||
1372 | struct ipw_setup_config_packet { | ||
1373 | struct ipw_tx_packet header; | ||
1374 | struct tl_setup_config_msg body; | ||
1375 | }; | ||
1376 | |||
1377 | struct ipw_setup_config_done_packet { | ||
1378 | struct ipw_tx_packet header; | ||
1379 | struct tl_setup_config_done_msg body; | ||
1380 | }; | ||
1381 | |||
1382 | struct ipw_setup_open_packet { | ||
1383 | struct ipw_tx_packet header; | ||
1384 | struct tl_setup_open_msg body; | ||
1385 | }; | ||
1386 | |||
1387 | struct ipw_setup_info_packet { | ||
1388 | struct ipw_tx_packet header; | ||
1389 | struct tl_setup_info_msg body; | ||
1390 | }; | ||
1391 | |||
1392 | struct ipw_setup_reboot_msg_ack { | ||
1393 | struct ipw_tx_packet header; | ||
1394 | struct TlSetupRebootMsgAck body; | ||
1395 | }; | ||
1396 | |||
1397 | /* This handles the actual initialization of the card */ | ||
1398 | static void __handle_setup_get_version_rsp(struct ipw_hardware *hw) | ||
1399 | { | ||
1400 | struct ipw_setup_config_packet *config_packet; | ||
1401 | struct ipw_setup_config_done_packet *config_done_packet; | ||
1402 | struct ipw_setup_open_packet *open_packet; | ||
1403 | struct ipw_setup_info_packet *info_packet; | ||
1404 | int port; | ||
1405 | unsigned int channel_idx; | ||
1406 | |||
1407 | /* generate config packet */ | ||
1408 | for (port = 1; port <= NL_NUM_OF_ADDRESSES; port++) { | ||
1409 | config_packet = alloc_ctrl_packet( | ||
1410 | sizeof(struct ipw_setup_config_packet), | ||
1411 | ADDR_SETUP_PROT, | ||
1412 | TL_PROTOCOLID_SETUP, | ||
1413 | TL_SETUP_SIGNO_CONFIG_MSG); | ||
1414 | if (!config_packet) | ||
1415 | goto exit_nomem; | ||
1416 | config_packet->header.length = sizeof(struct tl_setup_config_msg); | ||
1417 | config_packet->body.port_no = port; | ||
1418 | config_packet->body.prio_data = PRIO_DATA; | ||
1419 | config_packet->body.prio_ctrl = PRIO_CTRL; | ||
1420 | send_packet(hw, PRIO_SETUP, &config_packet->header); | ||
1421 | } | ||
1422 | config_done_packet = alloc_ctrl_packet( | ||
1423 | sizeof(struct ipw_setup_config_done_packet), | ||
1424 | ADDR_SETUP_PROT, | ||
1425 | TL_PROTOCOLID_SETUP, | ||
1426 | TL_SETUP_SIGNO_CONFIG_DONE_MSG); | ||
1427 | if (!config_done_packet) | ||
1428 | goto exit_nomem; | ||
1429 | config_done_packet->header.length = sizeof(struct tl_setup_config_done_msg); | ||
1430 | send_packet(hw, PRIO_SETUP, &config_done_packet->header); | ||
1431 | |||
1432 | /* generate open packet */ | ||
1433 | for (port = 1; port <= NL_NUM_OF_ADDRESSES; port++) { | ||
1434 | open_packet = alloc_ctrl_packet( | ||
1435 | sizeof(struct ipw_setup_open_packet), | ||
1436 | ADDR_SETUP_PROT, | ||
1437 | TL_PROTOCOLID_SETUP, | ||
1438 | TL_SETUP_SIGNO_OPEN_MSG); | ||
1439 | if (!open_packet) | ||
1440 | goto exit_nomem; | ||
1441 | open_packet->header.length = sizeof(struct tl_setup_open_msg); | ||
1442 | open_packet->body.port_no = port; | ||
1443 | send_packet(hw, PRIO_SETUP, &open_packet->header); | ||
1444 | } | ||
1445 | for (channel_idx = 0; | ||
1446 | channel_idx < NL_NUM_OF_ADDRESSES; channel_idx++) { | ||
1447 | int ret; | ||
1448 | |||
1449 | ret = set_DTR(hw, PRIO_SETUP, channel_idx, | ||
1450 | (hw->control_lines[channel_idx] & | ||
1451 | IPW_CONTROL_LINE_DTR) != 0); | ||
1452 | if (ret) { | ||
1453 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
1454 | ": error setting DTR (%d)\n", ret); | ||
1455 | return; | ||
1456 | } | ||
1457 | |||
1458 | set_RTS(hw, PRIO_SETUP, channel_idx, | ||
1459 | (hw->control_lines [channel_idx] & | ||
1460 | IPW_CONTROL_LINE_RTS) != 0); | ||
1461 | if (ret) { | ||
1462 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
1463 | ": error setting RTS (%d)\n", ret); | ||
1464 | return; | ||
1465 | } | ||
1466 | } | ||
1467 | /* | ||
1468 | * For NDIS we assume that we are using sync PPP frames, for COM async. | ||
1469 | * This driver uses NDIS mode too. We don't bother with translation | ||
1470 | * from async -> sync PPP. | ||
1471 | */ | ||
1472 | info_packet = alloc_ctrl_packet(sizeof(struct ipw_setup_info_packet), | ||
1473 | ADDR_SETUP_PROT, | ||
1474 | TL_PROTOCOLID_SETUP, | ||
1475 | TL_SETUP_SIGNO_INFO_MSG); | ||
1476 | if (!info_packet) | ||
1477 | goto exit_nomem; | ||
1478 | info_packet->header.length = sizeof(struct tl_setup_info_msg); | ||
1479 | info_packet->body.driver_type = NDISWAN_DRIVER; | ||
1480 | info_packet->body.major_version = NDISWAN_DRIVER_MAJOR_VERSION; | ||
1481 | info_packet->body.minor_version = NDISWAN_DRIVER_MINOR_VERSION; | ||
1482 | send_packet(hw, PRIO_SETUP, &info_packet->header); | ||
1483 | |||
1484 | /* Initialization is now complete, so we clear the 'to_setup' flag */ | ||
1485 | hw->to_setup = 0; | ||
1486 | |||
1487 | return; | ||
1488 | |||
1489 | exit_nomem: | ||
1490 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
1491 | ": not enough memory to alloc control packet\n"); | ||
1492 | hw->to_setup = -1; | ||
1493 | } | ||
1494 | |||
1495 | static void handle_setup_get_version_rsp(struct ipw_hardware *hw, | ||
1496 | unsigned char vers_no) | ||
1497 | { | ||
1498 | del_timer(&hw->setup_timer); | ||
1499 | hw->initializing = 0; | ||
1500 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": card is ready.\n"); | ||
1501 | |||
1502 | if (vers_no == TL_SETUP_VERSION) | ||
1503 | __handle_setup_get_version_rsp(hw); | ||
1504 | else | ||
1505 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
1506 | ": invalid hardware version no %u\n", | ||
1507 | (unsigned int) vers_no); | ||
1508 | } | ||
1509 | |||
1510 | static void ipw_send_setup_packet(struct ipw_hardware *hw) | ||
1511 | { | ||
1512 | struct ipw_setup_get_version_query_packet *ver_packet; | ||
1513 | |||
1514 | ver_packet = alloc_ctrl_packet( | ||
1515 | sizeof(struct ipw_setup_get_version_query_packet), | ||
1516 | ADDR_SETUP_PROT, TL_PROTOCOLID_SETUP, | ||
1517 | TL_SETUP_SIGNO_GET_VERSION_QRY); | ||
1518 | ver_packet->header.length = sizeof(struct tl_setup_get_version_qry); | ||
1519 | |||
1520 | /* | ||
1521 | * Response is handled in handle_received_SETUP_packet | ||
1522 | */ | ||
1523 | send_packet(hw, PRIO_SETUP, &ver_packet->header); | ||
1524 | } | ||
1525 | |||
1526 | static void handle_received_SETUP_packet(struct ipw_hardware *hw, | ||
1527 | unsigned int address, | ||
1528 | const unsigned char *data, int len, | ||
1529 | int is_last) | ||
1530 | { | ||
1531 | const union ipw_setup_rx_msg *rx_msg = (const union ipw_setup_rx_msg *) data; | ||
1532 | |||
1533 | if (address != ADDR_SETUP_PROT) { | ||
1534 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1535 | ": setup packet has bad address %d\n", address); | ||
1536 | return; | ||
1537 | } | ||
1538 | |||
1539 | switch (rx_msg->sig_no) { | ||
1540 | case TL_SETUP_SIGNO_GET_VERSION_RSP: | ||
1541 | if (hw->to_setup) | ||
1542 | handle_setup_get_version_rsp(hw, | ||
1543 | rx_msg->version_rsp_msg.version); | ||
1544 | break; | ||
1545 | |||
1546 | case TL_SETUP_SIGNO_OPEN_MSG: | ||
1547 | if (ipwireless_debug) { | ||
1548 | unsigned int channel_idx = rx_msg->open_msg.port_no - 1; | ||
1549 | |||
1550 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1551 | ": OPEN_MSG [channel %u] reply received\n", | ||
1552 | channel_idx); | ||
1553 | } | ||
1554 | break; | ||
1555 | |||
1556 | case TL_SETUP_SIGNO_INFO_MSG_ACK: | ||
1557 | if (ipwireless_debug) | ||
1558 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME | ||
1559 | ": card successfully configured as NDISWAN\n"); | ||
1560 | break; | ||
1561 | |||
1562 | case TL_SETUP_SIGNO_REBOOT_MSG: | ||
1563 | if (hw->to_setup) | ||
1564 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME | ||
1565 | ": Setup not completed - ignoring reboot msg\n"); | ||
1566 | else { | ||
1567 | struct ipw_setup_reboot_msg_ack *packet; | ||
1568 | |||
1569 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME | ||
1570 | ": Acknowledging REBOOT message\n"); | ||
1571 | packet = alloc_ctrl_packet( | ||
1572 | sizeof(struct ipw_setup_reboot_msg_ack), | ||
1573 | ADDR_SETUP_PROT, TL_PROTOCOLID_SETUP, | ||
1574 | TL_SETUP_SIGNO_REBOOT_MSG_ACK); | ||
1575 | packet->header.length = | ||
1576 | sizeof(struct TlSetupRebootMsgAck); | ||
1577 | send_packet(hw, PRIO_SETUP, &packet->header); | ||
1578 | if (hw->reboot_callback) | ||
1579 | hw->reboot_callback(hw->reboot_callback_data); | ||
1580 | } | ||
1581 | break; | ||
1582 | |||
1583 | default: | ||
1584 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1585 | ": unknown setup message %u received\n", | ||
1586 | (unsigned int) rx_msg->sig_no); | ||
1587 | } | ||
1588 | } | ||
1589 | |||
1590 | static void do_close_hardware(struct ipw_hardware *hw) | ||
1591 | { | ||
1592 | unsigned int irqn; | ||
1593 | |||
1594 | if (hw->hw_version == HW_VERSION_1) { | ||
1595 | /* Disable TX and RX interrupts. */ | ||
1596 | outw(0, hw->base_port + IOIER); | ||
1597 | |||
1598 | /* Acknowledge any outstanding interrupt requests */ | ||
1599 | irqn = inw(hw->base_port + IOIR); | ||
1600 | if (irqn & IR_TXINTR) | ||
1601 | outw(IR_TXINTR, hw->base_port + IOIR); | ||
1602 | if (irqn & IR_RXINTR) | ||
1603 | outw(IR_RXINTR, hw->base_port + IOIR); | ||
1604 | |||
1605 | synchronize_irq(hw->irq); | ||
1606 | } | ||
1607 | } | ||
1608 | |||
1609 | struct ipw_hardware *ipwireless_hardware_create(void) | ||
1610 | { | ||
1611 | int i; | ||
1612 | struct ipw_hardware *hw = | ||
1613 | kzalloc(sizeof(struct ipw_hardware), GFP_KERNEL); | ||
1614 | |||
1615 | if (!hw) | ||
1616 | return NULL; | ||
1617 | |||
1618 | hw->irq = -1; | ||
1619 | hw->initializing = 1; | ||
1620 | hw->tx_ready = 1; | ||
1621 | hw->rx_bytes_queued = 0; | ||
1622 | hw->rx_pool_size = 0; | ||
1623 | hw->last_memtx_serial = (unsigned short) 0xffff; | ||
1624 | for (i = 0; i < NL_NUM_OF_PRIORITIES; i++) | ||
1625 | INIT_LIST_HEAD(&hw->tx_queue[i]); | ||
1626 | |||
1627 | INIT_LIST_HEAD(&hw->rx_queue); | ||
1628 | INIT_LIST_HEAD(&hw->rx_pool); | ||
1629 | spin_lock_init(&hw->lock); | ||
1630 | tasklet_init(&hw->tasklet, ipwireless_do_tasklet, (unsigned long) hw); | ||
1631 | INIT_WORK(&hw->work_rx, ipw_receive_data_work); | ||
1632 | setup_timer(&hw->setup_timer, ipwireless_setup_timer, | ||
1633 | (unsigned long) hw); | ||
1634 | |||
1635 | return hw; | ||
1636 | } | ||
1637 | |||
1638 | void ipwireless_init_hardware_v1(struct ipw_hardware *hw, | ||
1639 | unsigned int base_port, | ||
1640 | void __iomem *attr_memory, | ||
1641 | void __iomem *common_memory, | ||
1642 | int is_v2_card, | ||
1643 | void (*reboot_callback) (void *data), | ||
1644 | void *reboot_callback_data) | ||
1645 | { | ||
1646 | if (hw->removed) { | ||
1647 | hw->removed = 0; | ||
1648 | enable_irq(hw->irq); | ||
1649 | } | ||
1650 | hw->base_port = base_port; | ||
1651 | hw->hw_version = (is_v2_card ? HW_VERSION_2 : HW_VERSION_1); | ||
1652 | hw->ll_mtu = (hw->hw_version == HW_VERSION_1 ? LL_MTU_V1 : LL_MTU_V2); | ||
1653 | hw->memregs_CCR = (struct MEMCCR __iomem *) | ||
1654 | ((unsigned short __iomem *) attr_memory + 0x200); | ||
1655 | hw->memory_info_regs = (struct MEMINFREG __iomem *) common_memory; | ||
1656 | hw->memreg_tx = &hw->memory_info_regs->memreg_tx_new; | ||
1657 | hw->reboot_callback = reboot_callback; | ||
1658 | hw->reboot_callback_data = reboot_callback_data; | ||
1659 | } | ||
1660 | |||
1661 | void ipwireless_init_hardware_v2_v3(struct ipw_hardware *hw) | ||
1662 | { | ||
1663 | hw->initializing = 1; | ||
1664 | hw->init_loops = 0; | ||
1665 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1666 | ": waiting for card to start up...\n"); | ||
1667 | ipwireless_setup_timer((unsigned long) hw); | ||
1668 | } | ||
1669 | |||
1670 | static void ipwireless_setup_timer(unsigned long data) | ||
1671 | { | ||
1672 | struct ipw_hardware *hw = (struct ipw_hardware *) data; | ||
1673 | |||
1674 | hw->init_loops++; | ||
1675 | |||
1676 | if (hw->init_loops == TL_SETUP_MAX_VERSION_QRY && | ||
1677 | hw->hw_version == HW_VERSION_2 && | ||
1678 | hw->memreg_tx == &hw->memory_info_regs->memreg_tx_new) { | ||
1679 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1680 | ": failed to startup using TX2, trying TX\n"); | ||
1681 | |||
1682 | hw->memreg_tx = &hw->memory_info_regs->memreg_tx_old; | ||
1683 | hw->init_loops = 0; | ||
1684 | } | ||
1685 | /* Give up after a certain number of retries */ | ||
1686 | if (hw->init_loops == TL_SETUP_MAX_VERSION_QRY) { | ||
1687 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
1688 | ": card failed to start up!\n"); | ||
1689 | hw->initializing = 0; | ||
1690 | } else { | ||
1691 | /* Do not attempt to write to the board if it is not present. */ | ||
1692 | if (is_card_present(hw)) { | ||
1693 | unsigned long flags; | ||
1694 | |||
1695 | spin_lock_irqsave(&hw->lock, flags); | ||
1696 | hw->to_setup = 1; | ||
1697 | hw->tx_ready = 1; | ||
1698 | spin_unlock_irqrestore(&hw->lock, flags); | ||
1699 | tasklet_schedule(&hw->tasklet); | ||
1700 | } | ||
1701 | |||
1702 | mod_timer(&hw->setup_timer, | ||
1703 | jiffies + msecs_to_jiffies(TL_SETUP_VERSION_QRY_TMO)); | ||
1704 | } | ||
1705 | } | ||
1706 | |||
1707 | /* | ||
1708 | * Stop any interrupts from executing so that, once this function returns, | ||
1709 | * other layers of the driver can be sure they won't get any more callbacks. | ||
1710 | * Thus must be called on a proper process context. | ||
1711 | */ | ||
1712 | void ipwireless_stop_interrupts(struct ipw_hardware *hw) | ||
1713 | { | ||
1714 | if (!hw->shutting_down) { | ||
1715 | /* Tell everyone we are going down. */ | ||
1716 | hw->shutting_down = 1; | ||
1717 | del_timer(&hw->setup_timer); | ||
1718 | |||
1719 | /* Prevent the hardware from sending any more interrupts */ | ||
1720 | do_close_hardware(hw); | ||
1721 | } | ||
1722 | } | ||
1723 | |||
1724 | void ipwireless_hardware_free(struct ipw_hardware *hw) | ||
1725 | { | ||
1726 | int i; | ||
1727 | struct ipw_rx_packet *rp, *rq; | ||
1728 | struct ipw_tx_packet *tp, *tq; | ||
1729 | |||
1730 | ipwireless_stop_interrupts(hw); | ||
1731 | |||
1732 | flush_scheduled_work(); | ||
1733 | |||
1734 | for (i = 0; i < NL_NUM_OF_ADDRESSES; i++) | ||
1735 | if (hw->packet_assembler[i] != NULL) | ||
1736 | kfree(hw->packet_assembler[i]); | ||
1737 | |||
1738 | for (i = 0; i < NL_NUM_OF_PRIORITIES; i++) | ||
1739 | list_for_each_entry_safe(tp, tq, &hw->tx_queue[i], queue) { | ||
1740 | list_del(&tp->queue); | ||
1741 | kfree(tp); | ||
1742 | } | ||
1743 | |||
1744 | list_for_each_entry_safe(rp, rq, &hw->rx_queue, queue) { | ||
1745 | list_del(&rp->queue); | ||
1746 | kfree(rp); | ||
1747 | } | ||
1748 | |||
1749 | list_for_each_entry_safe(rp, rq, &hw->rx_pool, queue) { | ||
1750 | list_del(&rp->queue); | ||
1751 | kfree(rp); | ||
1752 | } | ||
1753 | kfree(hw); | ||
1754 | } | ||
1755 | |||
1756 | /* | ||
1757 | * Associate the specified network with this hardware, so it will receive events | ||
1758 | * from it. | ||
1759 | */ | ||
1760 | void ipwireless_associate_network(struct ipw_hardware *hw, | ||
1761 | struct ipw_network *network) | ||
1762 | { | ||
1763 | hw->network = network; | ||
1764 | } | ||
diff --git a/drivers/char/pcmcia/ipwireless/hardware.h b/drivers/char/pcmcia/ipwireless/hardware.h deleted file mode 100644 index 90a8590e43b0..000000000000 --- a/drivers/char/pcmcia/ipwireless/hardware.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #ifndef _IPWIRELESS_CS_HARDWARE_H_ | ||
19 | #define _IPWIRELESS_CS_HARDWARE_H_ | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #define IPW_CONTROL_LINE_CTS 0x0001 | ||
26 | #define IPW_CONTROL_LINE_DCD 0x0002 | ||
27 | #define IPW_CONTROL_LINE_DSR 0x0004 | ||
28 | #define IPW_CONTROL_LINE_RI 0x0008 | ||
29 | #define IPW_CONTROL_LINE_DTR 0x0010 | ||
30 | #define IPW_CONTROL_LINE_RTS 0x0020 | ||
31 | |||
32 | struct ipw_hardware; | ||
33 | struct ipw_network; | ||
34 | |||
35 | struct ipw_hardware *ipwireless_hardware_create(void); | ||
36 | void ipwireless_hardware_free(struct ipw_hardware *hw); | ||
37 | irqreturn_t ipwireless_interrupt(int irq, void *dev_id); | ||
38 | int ipwireless_set_DTR(struct ipw_hardware *hw, unsigned int channel_idx, | ||
39 | int state); | ||
40 | int ipwireless_set_RTS(struct ipw_hardware *hw, unsigned int channel_idx, | ||
41 | int state); | ||
42 | int ipwireless_send_packet(struct ipw_hardware *hw, | ||
43 | unsigned int channel_idx, | ||
44 | const unsigned char *data, | ||
45 | unsigned int length, | ||
46 | void (*packet_sent_callback) (void *cb, | ||
47 | unsigned int length), | ||
48 | void *sent_cb_data); | ||
49 | void ipwireless_associate_network(struct ipw_hardware *hw, | ||
50 | struct ipw_network *net); | ||
51 | void ipwireless_stop_interrupts(struct ipw_hardware *hw); | ||
52 | void ipwireless_init_hardware_v1(struct ipw_hardware *hw, | ||
53 | unsigned int base_port, | ||
54 | void __iomem *attr_memory, | ||
55 | void __iomem *common_memory, | ||
56 | int is_v2_card, | ||
57 | void (*reboot_cb) (void *data), | ||
58 | void *reboot_cb_data); | ||
59 | void ipwireless_init_hardware_v2_v3(struct ipw_hardware *hw); | ||
60 | void ipwireless_sleep(unsigned int tenths); | ||
61 | |||
62 | #endif | ||
diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c deleted file mode 100644 index 67bdb05798b1..000000000000 --- a/drivers/char/pcmcia/ipwireless/main.c +++ /dev/null | |||
@@ -1,370 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #include "hardware.h" | ||
19 | #include "network.h" | ||
20 | #include "main.h" | ||
21 | #include "tty.h" | ||
22 | |||
23 | #include <linux/delay.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/sched.h> | ||
29 | #include <linux/slab.h> | ||
30 | |||
31 | #include <pcmcia/cisreg.h> | ||
32 | #include <pcmcia/device_id.h> | ||
33 | #include <pcmcia/ss.h> | ||
34 | #include <pcmcia/ds.h> | ||
35 | #include <pcmcia/cs.h> | ||
36 | |||
37 | static struct pcmcia_device_id ipw_ids[] = { | ||
38 | PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100), | ||
39 | PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0200), | ||
40 | PCMCIA_DEVICE_NULL | ||
41 | }; | ||
42 | MODULE_DEVICE_TABLE(pcmcia, ipw_ids); | ||
43 | |||
44 | static void ipwireless_detach(struct pcmcia_device *link); | ||
45 | |||
46 | /* | ||
47 | * Module params | ||
48 | */ | ||
49 | /* Debug mode: more verbose, print sent/recv bytes */ | ||
50 | int ipwireless_debug; | ||
51 | int ipwireless_loopback; | ||
52 | int ipwireless_out_queue = 10; | ||
53 | |||
54 | module_param_named(debug, ipwireless_debug, int, 0); | ||
55 | module_param_named(loopback, ipwireless_loopback, int, 0); | ||
56 | module_param_named(out_queue, ipwireless_out_queue, int, 0); | ||
57 | MODULE_PARM_DESC(debug, "switch on debug messages [0]"); | ||
58 | MODULE_PARM_DESC(loopback, | ||
59 | "debug: enable ras_raw channel [0]"); | ||
60 | MODULE_PARM_DESC(out_queue, "debug: set size of outgoing PPP queue [10]"); | ||
61 | |||
62 | /* Executes in process context. */ | ||
63 | static void signalled_reboot_work(struct work_struct *work_reboot) | ||
64 | { | ||
65 | struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev, | ||
66 | work_reboot); | ||
67 | struct pcmcia_device *link = ipw->link; | ||
68 | pcmcia_reset_card(link->socket); | ||
69 | } | ||
70 | |||
71 | static void signalled_reboot_callback(void *callback_data) | ||
72 | { | ||
73 | struct ipw_dev *ipw = (struct ipw_dev *) callback_data; | ||
74 | |||
75 | /* Delegate to process context. */ | ||
76 | schedule_work(&ipw->work_reboot); | ||
77 | } | ||
78 | |||
79 | static int ipwireless_probe(struct pcmcia_device *p_dev, | ||
80 | cistpl_cftable_entry_t *cfg, | ||
81 | cistpl_cftable_entry_t *dflt, | ||
82 | unsigned int vcc, | ||
83 | void *priv_data) | ||
84 | { | ||
85 | struct ipw_dev *ipw = priv_data; | ||
86 | struct resource *io_resource; | ||
87 | int ret; | ||
88 | |||
89 | p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; | ||
90 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
91 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
92 | |||
93 | /* 0x40 causes it to generate level mode interrupts. */ | ||
94 | /* 0x04 enables IREQ pin. */ | ||
95 | p_dev->conf.ConfigIndex = cfg->index | 0x44; | ||
96 | p_dev->io_lines = 16; | ||
97 | ret = pcmcia_request_io(p_dev); | ||
98 | if (ret) | ||
99 | return ret; | ||
100 | |||
101 | io_resource = request_region(p_dev->resource[0]->start, | ||
102 | resource_size(p_dev->resource[0]), | ||
103 | IPWIRELESS_PCCARD_NAME); | ||
104 | |||
105 | if (cfg->mem.nwin == 0) | ||
106 | return 0; | ||
107 | |||
108 | ipw->request_common_memory.Attributes = | ||
109 | WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE; | ||
110 | ipw->request_common_memory.Base = cfg->mem.win[0].host_addr; | ||
111 | ipw->request_common_memory.Size = cfg->mem.win[0].len; | ||
112 | if (ipw->request_common_memory.Size < 0x1000) | ||
113 | ipw->request_common_memory.Size = 0x1000; | ||
114 | ipw->request_common_memory.AccessSpeed = 0; | ||
115 | |||
116 | ret = pcmcia_request_window(p_dev, &ipw->request_common_memory, | ||
117 | &ipw->handle_common_memory); | ||
118 | |||
119 | if (ret != 0) | ||
120 | goto exit1; | ||
121 | |||
122 | ret = pcmcia_map_mem_page(p_dev, ipw->handle_common_memory, | ||
123 | cfg->mem.win[0].card_addr); | ||
124 | |||
125 | if (ret != 0) | ||
126 | goto exit2; | ||
127 | |||
128 | ipw->is_v2_card = cfg->mem.win[0].len == 0x100; | ||
129 | |||
130 | ipw->common_memory = ioremap(ipw->request_common_memory.Base, | ||
131 | ipw->request_common_memory.Size); | ||
132 | request_mem_region(ipw->request_common_memory.Base, | ||
133 | ipw->request_common_memory.Size, | ||
134 | IPWIRELESS_PCCARD_NAME); | ||
135 | |||
136 | ipw->request_attr_memory.Attributes = | ||
137 | WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM | WIN_ENABLE; | ||
138 | ipw->request_attr_memory.Base = 0; | ||
139 | ipw->request_attr_memory.Size = 0; /* this used to be 0x1000 */ | ||
140 | ipw->request_attr_memory.AccessSpeed = 0; | ||
141 | |||
142 | ret = pcmcia_request_window(p_dev, &ipw->request_attr_memory, | ||
143 | &ipw->handle_attr_memory); | ||
144 | |||
145 | if (ret != 0) | ||
146 | goto exit2; | ||
147 | |||
148 | ret = pcmcia_map_mem_page(p_dev, ipw->handle_attr_memory, 0); | ||
149 | if (ret != 0) | ||
150 | goto exit3; | ||
151 | |||
152 | ipw->attr_memory = ioremap(ipw->request_attr_memory.Base, | ||
153 | ipw->request_attr_memory.Size); | ||
154 | request_mem_region(ipw->request_attr_memory.Base, | ||
155 | ipw->request_attr_memory.Size, IPWIRELESS_PCCARD_NAME); | ||
156 | |||
157 | return 0; | ||
158 | |||
159 | exit3: | ||
160 | exit2: | ||
161 | if (ipw->common_memory) { | ||
162 | release_mem_region(ipw->request_common_memory.Base, | ||
163 | ipw->request_common_memory.Size); | ||
164 | iounmap(ipw->common_memory); | ||
165 | } | ||
166 | exit1: | ||
167 | release_resource(io_resource); | ||
168 | pcmcia_disable_device(p_dev); | ||
169 | return -1; | ||
170 | } | ||
171 | |||
172 | static int config_ipwireless(struct ipw_dev *ipw) | ||
173 | { | ||
174 | struct pcmcia_device *link = ipw->link; | ||
175 | int ret = 0; | ||
176 | |||
177 | ipw->is_v2_card = 0; | ||
178 | |||
179 | ret = pcmcia_loop_config(link, ipwireless_probe, ipw); | ||
180 | if (ret != 0) | ||
181 | return ret; | ||
182 | |||
183 | link->conf.Attributes = CONF_ENABLE_IRQ; | ||
184 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
185 | |||
186 | INIT_WORK(&ipw->work_reboot, signalled_reboot_work); | ||
187 | |||
188 | ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start, | ||
189 | ipw->attr_memory, ipw->common_memory, | ||
190 | ipw->is_v2_card, signalled_reboot_callback, | ||
191 | ipw); | ||
192 | |||
193 | ret = pcmcia_request_irq(link, ipwireless_interrupt); | ||
194 | if (ret != 0) | ||
195 | goto exit; | ||
196 | |||
197 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n", | ||
198 | ipw->is_v2_card ? "V2/V3" : "V1"); | ||
199 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
200 | ": I/O ports %pR, irq %d\n", link->resource[0], | ||
201 | (unsigned int) link->irq); | ||
202 | if (ipw->attr_memory && ipw->common_memory) | ||
203 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
204 | ": attr memory 0x%08lx-0x%08lx, common memory 0x%08lx-0x%08lx\n", | ||
205 | ipw->request_attr_memory.Base, | ||
206 | ipw->request_attr_memory.Base | ||
207 | + ipw->request_attr_memory.Size - 1, | ||
208 | ipw->request_common_memory.Base, | ||
209 | ipw->request_common_memory.Base | ||
210 | + ipw->request_common_memory.Size - 1); | ||
211 | |||
212 | ipw->network = ipwireless_network_create(ipw->hardware); | ||
213 | if (!ipw->network) | ||
214 | goto exit; | ||
215 | |||
216 | ipw->tty = ipwireless_tty_create(ipw->hardware, ipw->network); | ||
217 | if (!ipw->tty) | ||
218 | goto exit; | ||
219 | |||
220 | ipwireless_init_hardware_v2_v3(ipw->hardware); | ||
221 | |||
222 | /* | ||
223 | * Do the RequestConfiguration last, because it enables interrupts. | ||
224 | * Then we don't get any interrupts before we're ready for them. | ||
225 | */ | ||
226 | ret = pcmcia_request_configuration(link, &link->conf); | ||
227 | |||
228 | if (ret != 0) | ||
229 | goto exit; | ||
230 | |||
231 | return 0; | ||
232 | |||
233 | exit: | ||
234 | if (ipw->attr_memory) { | ||
235 | release_mem_region(ipw->request_attr_memory.Base, | ||
236 | ipw->request_attr_memory.Size); | ||
237 | iounmap(ipw->attr_memory); | ||
238 | |||
239 | } | ||
240 | if (ipw->common_memory) { | ||
241 | release_mem_region(ipw->request_common_memory.Base, | ||
242 | ipw->request_common_memory.Size); | ||
243 | iounmap(ipw->common_memory); | ||
244 | } | ||
245 | pcmcia_disable_device(link); | ||
246 | return -1; | ||
247 | } | ||
248 | |||
249 | static void release_ipwireless(struct ipw_dev *ipw) | ||
250 | { | ||
251 | if (ipw->common_memory) { | ||
252 | release_mem_region(ipw->request_common_memory.Base, | ||
253 | ipw->request_common_memory.Size); | ||
254 | iounmap(ipw->common_memory); | ||
255 | } | ||
256 | if (ipw->attr_memory) { | ||
257 | release_mem_region(ipw->request_attr_memory.Base, | ||
258 | ipw->request_attr_memory.Size); | ||
259 | iounmap(ipw->attr_memory); | ||
260 | } | ||
261 | pcmcia_disable_device(ipw->link); | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * ipwireless_attach() creates an "instance" of the driver, allocating | ||
266 | * local data structures for one device (one interface). The device | ||
267 | * is registered with Card Services. | ||
268 | * | ||
269 | * The pcmcia_device structure is initialized, but we don't actually | ||
270 | * configure the card at this point -- we wait until we receive a | ||
271 | * card insertion event. | ||
272 | */ | ||
273 | static int ipwireless_attach(struct pcmcia_device *link) | ||
274 | { | ||
275 | struct ipw_dev *ipw; | ||
276 | int ret; | ||
277 | |||
278 | ipw = kzalloc(sizeof(struct ipw_dev), GFP_KERNEL); | ||
279 | if (!ipw) | ||
280 | return -ENOMEM; | ||
281 | |||
282 | ipw->link = link; | ||
283 | link->priv = ipw; | ||
284 | |||
285 | ipw->hardware = ipwireless_hardware_create(); | ||
286 | if (!ipw->hardware) { | ||
287 | kfree(ipw); | ||
288 | return -ENOMEM; | ||
289 | } | ||
290 | /* RegisterClient will call config_ipwireless */ | ||
291 | |||
292 | ret = config_ipwireless(ipw); | ||
293 | |||
294 | if (ret != 0) { | ||
295 | ipwireless_detach(link); | ||
296 | return ret; | ||
297 | } | ||
298 | |||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * This deletes a driver "instance". The device is de-registered with | ||
304 | * Card Services. If it has been released, all local data structures | ||
305 | * are freed. Otherwise, the structures will be freed when the device | ||
306 | * is released. | ||
307 | */ | ||
308 | static void ipwireless_detach(struct pcmcia_device *link) | ||
309 | { | ||
310 | struct ipw_dev *ipw = link->priv; | ||
311 | |||
312 | release_ipwireless(ipw); | ||
313 | |||
314 | if (ipw->tty != NULL) | ||
315 | ipwireless_tty_free(ipw->tty); | ||
316 | if (ipw->network != NULL) | ||
317 | ipwireless_network_free(ipw->network); | ||
318 | if (ipw->hardware != NULL) | ||
319 | ipwireless_hardware_free(ipw->hardware); | ||
320 | kfree(ipw); | ||
321 | } | ||
322 | |||
323 | static struct pcmcia_driver me = { | ||
324 | .owner = THIS_MODULE, | ||
325 | .probe = ipwireless_attach, | ||
326 | .remove = ipwireless_detach, | ||
327 | .drv = { .name = IPWIRELESS_PCCARD_NAME }, | ||
328 | .id_table = ipw_ids | ||
329 | }; | ||
330 | |||
331 | /* | ||
332 | * Module insertion : initialisation of the module. | ||
333 | * Register the card with cardmgr... | ||
334 | */ | ||
335 | static int __init init_ipwireless(void) | ||
336 | { | ||
337 | int ret; | ||
338 | |||
339 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME " " | ||
340 | IPWIRELESS_PCMCIA_VERSION " by " IPWIRELESS_PCMCIA_AUTHOR "\n"); | ||
341 | |||
342 | ret = ipwireless_tty_init(); | ||
343 | if (ret != 0) | ||
344 | return ret; | ||
345 | |||
346 | ret = pcmcia_register_driver(&me); | ||
347 | if (ret != 0) | ||
348 | ipwireless_tty_release(); | ||
349 | |||
350 | return ret; | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * Module removal | ||
355 | */ | ||
356 | static void __exit exit_ipwireless(void) | ||
357 | { | ||
358 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME " " | ||
359 | IPWIRELESS_PCMCIA_VERSION " removed\n"); | ||
360 | |||
361 | pcmcia_unregister_driver(&me); | ||
362 | ipwireless_tty_release(); | ||
363 | } | ||
364 | |||
365 | module_init(init_ipwireless); | ||
366 | module_exit(exit_ipwireless); | ||
367 | |||
368 | MODULE_AUTHOR(IPWIRELESS_PCMCIA_AUTHOR); | ||
369 | MODULE_DESCRIPTION(IPWIRELESS_PCCARD_NAME " " IPWIRELESS_PCMCIA_VERSION); | ||
370 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/char/pcmcia/ipwireless/main.h b/drivers/char/pcmcia/ipwireless/main.h deleted file mode 100644 index c207be87b597..000000000000 --- a/drivers/char/pcmcia/ipwireless/main.h +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #ifndef _IPWIRELESS_CS_H_ | ||
19 | #define _IPWIRELESS_CS_H_ | ||
20 | |||
21 | #include <linux/sched.h> | ||
22 | #include <linux/types.h> | ||
23 | |||
24 | #include <pcmcia/cs.h> | ||
25 | #include <pcmcia/cistpl.h> | ||
26 | #include <pcmcia/ds.h> | ||
27 | |||
28 | #include "hardware.h" | ||
29 | |||
30 | #define IPWIRELESS_PCCARD_NAME "ipwireless" | ||
31 | #define IPWIRELESS_PCMCIA_VERSION "1.1" | ||
32 | #define IPWIRELESS_PCMCIA_AUTHOR \ | ||
33 | "Stephen Blackheath, Ben Martel, Jiri Kosina and David Sterba" | ||
34 | |||
35 | #define IPWIRELESS_TX_QUEUE_SIZE 262144 | ||
36 | #define IPWIRELESS_RX_QUEUE_SIZE 262144 | ||
37 | |||
38 | #define IPWIRELESS_STATE_DEBUG | ||
39 | |||
40 | struct ipw_hardware; | ||
41 | struct ipw_network; | ||
42 | struct ipw_tty; | ||
43 | |||
44 | struct ipw_dev { | ||
45 | struct pcmcia_device *link; | ||
46 | int is_v2_card; | ||
47 | |||
48 | window_handle_t handle_attr_memory; | ||
49 | void __iomem *attr_memory; | ||
50 | win_req_t request_attr_memory; | ||
51 | |||
52 | window_handle_t handle_common_memory; | ||
53 | void __iomem *common_memory; | ||
54 | win_req_t request_common_memory; | ||
55 | |||
56 | /* Reference to attribute memory, containing CIS data */ | ||
57 | void *attribute_memory; | ||
58 | |||
59 | /* Hardware context */ | ||
60 | struct ipw_hardware *hardware; | ||
61 | /* Network layer context */ | ||
62 | struct ipw_network *network; | ||
63 | /* TTY device context */ | ||
64 | struct ipw_tty *tty; | ||
65 | struct work_struct work_reboot; | ||
66 | }; | ||
67 | |||
68 | /* Module parametres */ | ||
69 | extern int ipwireless_debug; | ||
70 | extern int ipwireless_loopback; | ||
71 | extern int ipwireless_out_queue; | ||
72 | |||
73 | #endif | ||
diff --git a/drivers/char/pcmcia/ipwireless/network.c b/drivers/char/pcmcia/ipwireless/network.c deleted file mode 100644 index 9fe538347932..000000000000 --- a/drivers/char/pcmcia/ipwireless/network.c +++ /dev/null | |||
@@ -1,507 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/mutex.h> | ||
21 | #include <linux/netdevice.h> | ||
22 | #include <linux/ppp_channel.h> | ||
23 | #include <linux/ppp_defs.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/if_ppp.h> | ||
26 | #include <linux/skbuff.h> | ||
27 | |||
28 | #include "network.h" | ||
29 | #include "hardware.h" | ||
30 | #include "main.h" | ||
31 | #include "tty.h" | ||
32 | |||
33 | #define MAX_ASSOCIATED_TTYS 2 | ||
34 | |||
35 | #define SC_RCV_BITS (SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP) | ||
36 | |||
37 | struct ipw_network { | ||
38 | /* Hardware context, used for calls to hardware layer. */ | ||
39 | struct ipw_hardware *hardware; | ||
40 | /* Context for kernel 'generic_ppp' functionality */ | ||
41 | struct ppp_channel *ppp_channel; | ||
42 | /* tty context connected with IPW console */ | ||
43 | struct ipw_tty *associated_ttys[NO_OF_IPW_CHANNELS][MAX_ASSOCIATED_TTYS]; | ||
44 | /* True if ppp needs waking up once we're ready to xmit */ | ||
45 | int ppp_blocked; | ||
46 | /* Number of packets queued up in hardware module. */ | ||
47 | int outgoing_packets_queued; | ||
48 | /* Spinlock to avoid interrupts during shutdown */ | ||
49 | spinlock_t lock; | ||
50 | struct mutex close_lock; | ||
51 | |||
52 | /* PPP ioctl data, not actually used anywere */ | ||
53 | unsigned int flags; | ||
54 | unsigned int rbits; | ||
55 | u32 xaccm[8]; | ||
56 | u32 raccm; | ||
57 | int mru; | ||
58 | |||
59 | int shutting_down; | ||
60 | unsigned int ras_control_lines; | ||
61 | |||
62 | struct work_struct work_go_online; | ||
63 | struct work_struct work_go_offline; | ||
64 | }; | ||
65 | |||
66 | static void notify_packet_sent(void *callback_data, unsigned int packet_length) | ||
67 | { | ||
68 | struct ipw_network *network = callback_data; | ||
69 | unsigned long flags; | ||
70 | |||
71 | spin_lock_irqsave(&network->lock, flags); | ||
72 | network->outgoing_packets_queued--; | ||
73 | if (network->ppp_channel != NULL) { | ||
74 | if (network->ppp_blocked) { | ||
75 | network->ppp_blocked = 0; | ||
76 | spin_unlock_irqrestore(&network->lock, flags); | ||
77 | ppp_output_wakeup(network->ppp_channel); | ||
78 | if (ipwireless_debug) | ||
79 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME | ||
80 | ": ppp unblocked\n"); | ||
81 | } else | ||
82 | spin_unlock_irqrestore(&network->lock, flags); | ||
83 | } else | ||
84 | spin_unlock_irqrestore(&network->lock, flags); | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Called by the ppp system when it has a packet to send to the hardware. | ||
89 | */ | ||
90 | static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel, | ||
91 | struct sk_buff *skb) | ||
92 | { | ||
93 | struct ipw_network *network = ppp_channel->private; | ||
94 | unsigned long flags; | ||
95 | |||
96 | spin_lock_irqsave(&network->lock, flags); | ||
97 | if (network->outgoing_packets_queued < ipwireless_out_queue) { | ||
98 | unsigned char *buf; | ||
99 | static unsigned char header[] = { | ||
100 | PPP_ALLSTATIONS, /* 0xff */ | ||
101 | PPP_UI, /* 0x03 */ | ||
102 | }; | ||
103 | int ret; | ||
104 | |||
105 | network->outgoing_packets_queued++; | ||
106 | spin_unlock_irqrestore(&network->lock, flags); | ||
107 | |||
108 | /* | ||
109 | * If we have the requested amount of headroom in the skb we | ||
110 | * were handed, then we can add the header efficiently. | ||
111 | */ | ||
112 | if (skb_headroom(skb) >= 2) { | ||
113 | memcpy(skb_push(skb, 2), header, 2); | ||
114 | ret = ipwireless_send_packet(network->hardware, | ||
115 | IPW_CHANNEL_RAS, skb->data, | ||
116 | skb->len, | ||
117 | notify_packet_sent, | ||
118 | network); | ||
119 | if (ret == -1) { | ||
120 | skb_pull(skb, 2); | ||
121 | return 0; | ||
122 | } | ||
123 | } else { | ||
124 | /* Otherwise (rarely) we do it inefficiently. */ | ||
125 | buf = kmalloc(skb->len + 2, GFP_ATOMIC); | ||
126 | if (!buf) | ||
127 | return 0; | ||
128 | memcpy(buf + 2, skb->data, skb->len); | ||
129 | memcpy(buf, header, 2); | ||
130 | ret = ipwireless_send_packet(network->hardware, | ||
131 | IPW_CHANNEL_RAS, buf, | ||
132 | skb->len + 2, | ||
133 | notify_packet_sent, | ||
134 | network); | ||
135 | kfree(buf); | ||
136 | if (ret == -1) | ||
137 | return 0; | ||
138 | } | ||
139 | kfree_skb(skb); | ||
140 | return 1; | ||
141 | } else { | ||
142 | /* | ||
143 | * Otherwise reject the packet, and flag that the ppp system | ||
144 | * needs to be unblocked once we are ready to send. | ||
145 | */ | ||
146 | network->ppp_blocked = 1; | ||
147 | spin_unlock_irqrestore(&network->lock, flags); | ||
148 | if (ipwireless_debug) | ||
149 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME ": ppp blocked\n"); | ||
150 | return 0; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | /* Handle an ioctl call that has come in via ppp. (copy of ppp_async_ioctl() */ | ||
155 | static int ipwireless_ppp_ioctl(struct ppp_channel *ppp_channel, | ||
156 | unsigned int cmd, unsigned long arg) | ||
157 | { | ||
158 | struct ipw_network *network = ppp_channel->private; | ||
159 | int err, val; | ||
160 | u32 accm[8]; | ||
161 | int __user *user_arg = (int __user *) arg; | ||
162 | |||
163 | err = -EFAULT; | ||
164 | switch (cmd) { | ||
165 | case PPPIOCGFLAGS: | ||
166 | val = network->flags | network->rbits; | ||
167 | if (put_user(val, user_arg)) | ||
168 | break; | ||
169 | err = 0; | ||
170 | break; | ||
171 | |||
172 | case PPPIOCSFLAGS: | ||
173 | if (get_user(val, user_arg)) | ||
174 | break; | ||
175 | network->flags = val & ~SC_RCV_BITS; | ||
176 | network->rbits = val & SC_RCV_BITS; | ||
177 | err = 0; | ||
178 | break; | ||
179 | |||
180 | case PPPIOCGASYNCMAP: | ||
181 | if (put_user(network->xaccm[0], user_arg)) | ||
182 | break; | ||
183 | err = 0; | ||
184 | break; | ||
185 | |||
186 | case PPPIOCSASYNCMAP: | ||
187 | if (get_user(network->xaccm[0], user_arg)) | ||
188 | break; | ||
189 | err = 0; | ||
190 | break; | ||
191 | |||
192 | case PPPIOCGRASYNCMAP: | ||
193 | if (put_user(network->raccm, user_arg)) | ||
194 | break; | ||
195 | err = 0; | ||
196 | break; | ||
197 | |||
198 | case PPPIOCSRASYNCMAP: | ||
199 | if (get_user(network->raccm, user_arg)) | ||
200 | break; | ||
201 | err = 0; | ||
202 | break; | ||
203 | |||
204 | case PPPIOCGXASYNCMAP: | ||
205 | if (copy_to_user((void __user *) arg, network->xaccm, | ||
206 | sizeof(network->xaccm))) | ||
207 | break; | ||
208 | err = 0; | ||
209 | break; | ||
210 | |||
211 | case PPPIOCSXASYNCMAP: | ||
212 | if (copy_from_user(accm, (void __user *) arg, sizeof(accm))) | ||
213 | break; | ||
214 | accm[2] &= ~0x40000000U; /* can't escape 0x5e */ | ||
215 | accm[3] |= 0x60000000U; /* must escape 0x7d, 0x7e */ | ||
216 | memcpy(network->xaccm, accm, sizeof(network->xaccm)); | ||
217 | err = 0; | ||
218 | break; | ||
219 | |||
220 | case PPPIOCGMRU: | ||
221 | if (put_user(network->mru, user_arg)) | ||
222 | break; | ||
223 | err = 0; | ||
224 | break; | ||
225 | |||
226 | case PPPIOCSMRU: | ||
227 | if (get_user(val, user_arg)) | ||
228 | break; | ||
229 | if (val < PPP_MRU) | ||
230 | val = PPP_MRU; | ||
231 | network->mru = val; | ||
232 | err = 0; | ||
233 | break; | ||
234 | |||
235 | default: | ||
236 | err = -ENOTTY; | ||
237 | } | ||
238 | |||
239 | return err; | ||
240 | } | ||
241 | |||
242 | static const struct ppp_channel_ops ipwireless_ppp_channel_ops = { | ||
243 | .start_xmit = ipwireless_ppp_start_xmit, | ||
244 | .ioctl = ipwireless_ppp_ioctl | ||
245 | }; | ||
246 | |||
247 | static void do_go_online(struct work_struct *work_go_online) | ||
248 | { | ||
249 | struct ipw_network *network = | ||
250 | container_of(work_go_online, struct ipw_network, | ||
251 | work_go_online); | ||
252 | unsigned long flags; | ||
253 | |||
254 | spin_lock_irqsave(&network->lock, flags); | ||
255 | if (!network->ppp_channel) { | ||
256 | struct ppp_channel *channel; | ||
257 | |||
258 | spin_unlock_irqrestore(&network->lock, flags); | ||
259 | channel = kzalloc(sizeof(struct ppp_channel), GFP_KERNEL); | ||
260 | if (!channel) { | ||
261 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
262 | ": unable to allocate PPP channel\n"); | ||
263 | return; | ||
264 | } | ||
265 | channel->private = network; | ||
266 | channel->mtu = 16384; /* Wild guess */ | ||
267 | channel->hdrlen = 2; | ||
268 | channel->ops = &ipwireless_ppp_channel_ops; | ||
269 | |||
270 | network->flags = 0; | ||
271 | network->rbits = 0; | ||
272 | network->mru = PPP_MRU; | ||
273 | memset(network->xaccm, 0, sizeof(network->xaccm)); | ||
274 | network->xaccm[0] = ~0U; | ||
275 | network->xaccm[3] = 0x60000000U; | ||
276 | network->raccm = ~0U; | ||
277 | ppp_register_channel(channel); | ||
278 | spin_lock_irqsave(&network->lock, flags); | ||
279 | network->ppp_channel = channel; | ||
280 | } | ||
281 | spin_unlock_irqrestore(&network->lock, flags); | ||
282 | } | ||
283 | |||
284 | static void do_go_offline(struct work_struct *work_go_offline) | ||
285 | { | ||
286 | struct ipw_network *network = | ||
287 | container_of(work_go_offline, struct ipw_network, | ||
288 | work_go_offline); | ||
289 | unsigned long flags; | ||
290 | |||
291 | mutex_lock(&network->close_lock); | ||
292 | spin_lock_irqsave(&network->lock, flags); | ||
293 | if (network->ppp_channel != NULL) { | ||
294 | struct ppp_channel *channel = network->ppp_channel; | ||
295 | |||
296 | network->ppp_channel = NULL; | ||
297 | spin_unlock_irqrestore(&network->lock, flags); | ||
298 | mutex_unlock(&network->close_lock); | ||
299 | ppp_unregister_channel(channel); | ||
300 | } else { | ||
301 | spin_unlock_irqrestore(&network->lock, flags); | ||
302 | mutex_unlock(&network->close_lock); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | void ipwireless_network_notify_control_line_change(struct ipw_network *network, | ||
307 | unsigned int channel_idx, | ||
308 | unsigned int control_lines, | ||
309 | unsigned int changed_mask) | ||
310 | { | ||
311 | int i; | ||
312 | |||
313 | if (channel_idx == IPW_CHANNEL_RAS) | ||
314 | network->ras_control_lines = control_lines; | ||
315 | |||
316 | for (i = 0; i < MAX_ASSOCIATED_TTYS; i++) { | ||
317 | struct ipw_tty *tty = | ||
318 | network->associated_ttys[channel_idx][i]; | ||
319 | |||
320 | /* | ||
321 | * If it's associated with a tty (other than the RAS channel | ||
322 | * when we're online), then send the data to that tty. The RAS | ||
323 | * channel's data is handled above - it always goes through | ||
324 | * ppp_generic. | ||
325 | */ | ||
326 | if (tty) | ||
327 | ipwireless_tty_notify_control_line_change(tty, | ||
328 | channel_idx, | ||
329 | control_lines, | ||
330 | changed_mask); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * Some versions of firmware stuff packets with 0xff 0x03 (PPP: ALLSTATIONS, UI) | ||
336 | * bytes, which are required on sent packet, but not always present on received | ||
337 | * packets | ||
338 | */ | ||
339 | static struct sk_buff *ipw_packet_received_skb(unsigned char *data, | ||
340 | unsigned int length) | ||
341 | { | ||
342 | struct sk_buff *skb; | ||
343 | |||
344 | if (length > 2 && data[0] == PPP_ALLSTATIONS && data[1] == PPP_UI) { | ||
345 | length -= 2; | ||
346 | data += 2; | ||
347 | } | ||
348 | |||
349 | skb = dev_alloc_skb(length + 4); | ||
350 | skb_reserve(skb, 2); | ||
351 | memcpy(skb_put(skb, length), data, length); | ||
352 | |||
353 | return skb; | ||
354 | } | ||
355 | |||
356 | void ipwireless_network_packet_received(struct ipw_network *network, | ||
357 | unsigned int channel_idx, | ||
358 | unsigned char *data, | ||
359 | unsigned int length) | ||
360 | { | ||
361 | int i; | ||
362 | unsigned long flags; | ||
363 | |||
364 | for (i = 0; i < MAX_ASSOCIATED_TTYS; i++) { | ||
365 | struct ipw_tty *tty = network->associated_ttys[channel_idx][i]; | ||
366 | |||
367 | if (!tty) | ||
368 | continue; | ||
369 | |||
370 | /* | ||
371 | * If it's associated with a tty (other than the RAS channel | ||
372 | * when we're online), then send the data to that tty. The RAS | ||
373 | * channel's data is handled above - it always goes through | ||
374 | * ppp_generic. | ||
375 | */ | ||
376 | if (channel_idx == IPW_CHANNEL_RAS | ||
377 | && (network->ras_control_lines & | ||
378 | IPW_CONTROL_LINE_DCD) != 0 | ||
379 | && ipwireless_tty_is_modem(tty)) { | ||
380 | /* | ||
381 | * If data came in on the RAS channel and this tty is | ||
382 | * the modem tty, and we are online, then we send it to | ||
383 | * the PPP layer. | ||
384 | */ | ||
385 | mutex_lock(&network->close_lock); | ||
386 | spin_lock_irqsave(&network->lock, flags); | ||
387 | if (network->ppp_channel != NULL) { | ||
388 | struct sk_buff *skb; | ||
389 | |||
390 | spin_unlock_irqrestore(&network->lock, | ||
391 | flags); | ||
392 | |||
393 | /* Send the data to the ppp_generic module. */ | ||
394 | skb = ipw_packet_received_skb(data, length); | ||
395 | ppp_input(network->ppp_channel, skb); | ||
396 | } else | ||
397 | spin_unlock_irqrestore(&network->lock, | ||
398 | flags); | ||
399 | mutex_unlock(&network->close_lock); | ||
400 | } | ||
401 | /* Otherwise we send it out the tty. */ | ||
402 | else | ||
403 | ipwireless_tty_received(tty, data, length); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw) | ||
408 | { | ||
409 | struct ipw_network *network = | ||
410 | kzalloc(sizeof(struct ipw_network), GFP_ATOMIC); | ||
411 | |||
412 | if (!network) | ||
413 | return NULL; | ||
414 | |||
415 | spin_lock_init(&network->lock); | ||
416 | mutex_init(&network->close_lock); | ||
417 | |||
418 | network->hardware = hw; | ||
419 | |||
420 | INIT_WORK(&network->work_go_online, do_go_online); | ||
421 | INIT_WORK(&network->work_go_offline, do_go_offline); | ||
422 | |||
423 | ipwireless_associate_network(hw, network); | ||
424 | |||
425 | return network; | ||
426 | } | ||
427 | |||
428 | void ipwireless_network_free(struct ipw_network *network) | ||
429 | { | ||
430 | network->shutting_down = 1; | ||
431 | |||
432 | ipwireless_ppp_close(network); | ||
433 | flush_scheduled_work(); | ||
434 | |||
435 | ipwireless_stop_interrupts(network->hardware); | ||
436 | ipwireless_associate_network(network->hardware, NULL); | ||
437 | |||
438 | kfree(network); | ||
439 | } | ||
440 | |||
441 | void ipwireless_associate_network_tty(struct ipw_network *network, | ||
442 | unsigned int channel_idx, | ||
443 | struct ipw_tty *tty) | ||
444 | { | ||
445 | int i; | ||
446 | |||
447 | for (i = 0; i < MAX_ASSOCIATED_TTYS; i++) | ||
448 | if (network->associated_ttys[channel_idx][i] == NULL) { | ||
449 | network->associated_ttys[channel_idx][i] = tty; | ||
450 | break; | ||
451 | } | ||
452 | } | ||
453 | |||
454 | void ipwireless_disassociate_network_ttys(struct ipw_network *network, | ||
455 | unsigned int channel_idx) | ||
456 | { | ||
457 | int i; | ||
458 | |||
459 | for (i = 0; i < MAX_ASSOCIATED_TTYS; i++) | ||
460 | network->associated_ttys[channel_idx][i] = NULL; | ||
461 | } | ||
462 | |||
463 | void ipwireless_ppp_open(struct ipw_network *network) | ||
464 | { | ||
465 | if (ipwireless_debug) | ||
466 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME ": online\n"); | ||
467 | schedule_work(&network->work_go_online); | ||
468 | } | ||
469 | |||
470 | void ipwireless_ppp_close(struct ipw_network *network) | ||
471 | { | ||
472 | /* Disconnect from the wireless network. */ | ||
473 | if (ipwireless_debug) | ||
474 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME ": offline\n"); | ||
475 | schedule_work(&network->work_go_offline); | ||
476 | } | ||
477 | |||
478 | int ipwireless_ppp_channel_index(struct ipw_network *network) | ||
479 | { | ||
480 | int ret = -1; | ||
481 | unsigned long flags; | ||
482 | |||
483 | spin_lock_irqsave(&network->lock, flags); | ||
484 | if (network->ppp_channel != NULL) | ||
485 | ret = ppp_channel_index(network->ppp_channel); | ||
486 | spin_unlock_irqrestore(&network->lock, flags); | ||
487 | |||
488 | return ret; | ||
489 | } | ||
490 | |||
491 | int ipwireless_ppp_unit_number(struct ipw_network *network) | ||
492 | { | ||
493 | int ret = -1; | ||
494 | unsigned long flags; | ||
495 | |||
496 | spin_lock_irqsave(&network->lock, flags); | ||
497 | if (network->ppp_channel != NULL) | ||
498 | ret = ppp_unit_number(network->ppp_channel); | ||
499 | spin_unlock_irqrestore(&network->lock, flags); | ||
500 | |||
501 | return ret; | ||
502 | } | ||
503 | |||
504 | int ipwireless_ppp_mru(const struct ipw_network *network) | ||
505 | { | ||
506 | return network->mru; | ||
507 | } | ||
diff --git a/drivers/char/pcmcia/ipwireless/network.h b/drivers/char/pcmcia/ipwireless/network.h deleted file mode 100644 index 561f765b3334..000000000000 --- a/drivers/char/pcmcia/ipwireless/network.h +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #ifndef _IPWIRELESS_CS_NETWORK_H_ | ||
19 | #define _IPWIRELESS_CS_NETWORK_H_ | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | |||
23 | struct ipw_network; | ||
24 | struct ipw_tty; | ||
25 | struct ipw_hardware; | ||
26 | |||
27 | /* Definitions of the different channels on the PCMCIA UE */ | ||
28 | #define IPW_CHANNEL_RAS 0 | ||
29 | #define IPW_CHANNEL_DIALLER 1 | ||
30 | #define IPW_CHANNEL_CONSOLE 2 | ||
31 | #define NO_OF_IPW_CHANNELS 5 | ||
32 | |||
33 | void ipwireless_network_notify_control_line_change(struct ipw_network *net, | ||
34 | unsigned int channel_idx, unsigned int control_lines, | ||
35 | unsigned int control_mask); | ||
36 | void ipwireless_network_packet_received(struct ipw_network *net, | ||
37 | unsigned int channel_idx, unsigned char *data, | ||
38 | unsigned int length); | ||
39 | struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw); | ||
40 | void ipwireless_network_free(struct ipw_network *net); | ||
41 | void ipwireless_associate_network_tty(struct ipw_network *net, | ||
42 | unsigned int channel_idx, struct ipw_tty *tty); | ||
43 | void ipwireless_disassociate_network_ttys(struct ipw_network *net, | ||
44 | unsigned int channel_idx); | ||
45 | |||
46 | void ipwireless_ppp_open(struct ipw_network *net); | ||
47 | |||
48 | void ipwireless_ppp_close(struct ipw_network *net); | ||
49 | int ipwireless_ppp_channel_index(struct ipw_network *net); | ||
50 | int ipwireless_ppp_unit_number(struct ipw_network *net); | ||
51 | int ipwireless_ppp_mru(const struct ipw_network *net); | ||
52 | |||
53 | #endif | ||
diff --git a/drivers/char/pcmcia/ipwireless/setup_protocol.h b/drivers/char/pcmcia/ipwireless/setup_protocol.h deleted file mode 100644 index 9d6bcc77c73c..000000000000 --- a/drivers/char/pcmcia/ipwireless/setup_protocol.h +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #ifndef _IPWIRELESS_CS_SETUP_PROTOCOL_H_ | ||
19 | #define _IPWIRELESS_CS_SETUP_PROTOCOL_H_ | ||
20 | |||
21 | /* Version of the setup protocol and transport protocols */ | ||
22 | #define TL_SETUP_VERSION 1 | ||
23 | |||
24 | #define TL_SETUP_VERSION_QRY_TMO 1000 | ||
25 | #define TL_SETUP_MAX_VERSION_QRY 30 | ||
26 | |||
27 | /* Message numbers 0-9 are obsoleted and must not be reused! */ | ||
28 | #define TL_SETUP_SIGNO_GET_VERSION_QRY 10 | ||
29 | #define TL_SETUP_SIGNO_GET_VERSION_RSP 11 | ||
30 | #define TL_SETUP_SIGNO_CONFIG_MSG 12 | ||
31 | #define TL_SETUP_SIGNO_CONFIG_DONE_MSG 13 | ||
32 | #define TL_SETUP_SIGNO_OPEN_MSG 14 | ||
33 | #define TL_SETUP_SIGNO_CLOSE_MSG 15 | ||
34 | |||
35 | #define TL_SETUP_SIGNO_INFO_MSG 20 | ||
36 | #define TL_SETUP_SIGNO_INFO_MSG_ACK 21 | ||
37 | |||
38 | #define TL_SETUP_SIGNO_REBOOT_MSG 22 | ||
39 | #define TL_SETUP_SIGNO_REBOOT_MSG_ACK 23 | ||
40 | |||
41 | /* Synchronous start-messages */ | ||
42 | struct tl_setup_get_version_qry { | ||
43 | unsigned char sig_no; /* TL_SETUP_SIGNO_GET_VERSION_QRY */ | ||
44 | } __attribute__ ((__packed__)); | ||
45 | |||
46 | struct tl_setup_get_version_rsp { | ||
47 | unsigned char sig_no; /* TL_SETUP_SIGNO_GET_VERSION_RSP */ | ||
48 | unsigned char version; /* TL_SETUP_VERSION */ | ||
49 | } __attribute__ ((__packed__)); | ||
50 | |||
51 | struct tl_setup_config_msg { | ||
52 | unsigned char sig_no; /* TL_SETUP_SIGNO_CONFIG_MSG */ | ||
53 | unsigned char port_no; | ||
54 | unsigned char prio_data; | ||
55 | unsigned char prio_ctrl; | ||
56 | } __attribute__ ((__packed__)); | ||
57 | |||
58 | struct tl_setup_config_done_msg { | ||
59 | unsigned char sig_no; /* TL_SETUP_SIGNO_CONFIG_DONE_MSG */ | ||
60 | } __attribute__ ((__packed__)); | ||
61 | |||
62 | /* Asyncronous messages */ | ||
63 | struct tl_setup_open_msg { | ||
64 | unsigned char sig_no; /* TL_SETUP_SIGNO_OPEN_MSG */ | ||
65 | unsigned char port_no; | ||
66 | } __attribute__ ((__packed__)); | ||
67 | |||
68 | struct tl_setup_close_msg { | ||
69 | unsigned char sig_no; /* TL_SETUP_SIGNO_CLOSE_MSG */ | ||
70 | unsigned char port_no; | ||
71 | } __attribute__ ((__packed__)); | ||
72 | |||
73 | /* Driver type - for use in tl_setup_info_msg.driver_type */ | ||
74 | #define COMM_DRIVER 0 | ||
75 | #define NDISWAN_DRIVER 1 | ||
76 | #define NDISWAN_DRIVER_MAJOR_VERSION 2 | ||
77 | #define NDISWAN_DRIVER_MINOR_VERSION 0 | ||
78 | |||
79 | /* | ||
80 | * It should not matter when this message comes over as we just store the | ||
81 | * results and send the ACK. | ||
82 | */ | ||
83 | struct tl_setup_info_msg { | ||
84 | unsigned char sig_no; /* TL_SETUP_SIGNO_INFO_MSG */ | ||
85 | unsigned char driver_type; | ||
86 | unsigned char major_version; | ||
87 | unsigned char minor_version; | ||
88 | } __attribute__ ((__packed__)); | ||
89 | |||
90 | struct tl_setup_info_msgAck { | ||
91 | unsigned char sig_no; /* TL_SETUP_SIGNO_INFO_MSG_ACK */ | ||
92 | } __attribute__ ((__packed__)); | ||
93 | |||
94 | struct TlSetupRebootMsgAck { | ||
95 | unsigned char sig_no; /* TL_SETUP_SIGNO_REBOOT_MSG_ACK */ | ||
96 | } __attribute__ ((__packed__)); | ||
97 | |||
98 | /* Define a union of all the msgs that the driver can receive from the card.*/ | ||
99 | union ipw_setup_rx_msg { | ||
100 | unsigned char sig_no; | ||
101 | struct tl_setup_get_version_rsp version_rsp_msg; | ||
102 | struct tl_setup_open_msg open_msg; | ||
103 | struct tl_setup_close_msg close_msg; | ||
104 | struct tl_setup_info_msg InfoMsg; | ||
105 | struct tl_setup_info_msgAck info_msg_ack; | ||
106 | } __attribute__ ((__packed__)); | ||
107 | |||
108 | #endif /* _IPWIRELESS_CS_SETUP_PROTOCOL_H_ */ | ||
diff --git a/drivers/char/pcmcia/ipwireless/tty.c b/drivers/char/pcmcia/ipwireless/tty.c deleted file mode 100644 index 1a2c2c3b068f..000000000000 --- a/drivers/char/pcmcia/ipwireless/tty.c +++ /dev/null | |||
@@ -1,679 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #include <linux/init.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/mutex.h> | ||
22 | #include <linux/ppp_defs.h> | ||
23 | #include <linux/if.h> | ||
24 | #include <linux/if_ppp.h> | ||
25 | #include <linux/sched.h> | ||
26 | #include <linux/serial.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/tty.h> | ||
29 | #include <linux/tty_driver.h> | ||
30 | #include <linux/tty_flip.h> | ||
31 | #include <linux/uaccess.h> | ||
32 | |||
33 | #include "tty.h" | ||
34 | #include "network.h" | ||
35 | #include "hardware.h" | ||
36 | #include "main.h" | ||
37 | |||
38 | #define IPWIRELESS_PCMCIA_START (0) | ||
39 | #define IPWIRELESS_PCMCIA_MINORS (24) | ||
40 | #define IPWIRELESS_PCMCIA_MINOR_RANGE (8) | ||
41 | |||
42 | #define TTYTYPE_MODEM (0) | ||
43 | #define TTYTYPE_MONITOR (1) | ||
44 | #define TTYTYPE_RAS_RAW (2) | ||
45 | |||
46 | struct ipw_tty { | ||
47 | int index; | ||
48 | struct ipw_hardware *hardware; | ||
49 | unsigned int channel_idx; | ||
50 | unsigned int secondary_channel_idx; | ||
51 | int tty_type; | ||
52 | struct ipw_network *network; | ||
53 | struct tty_struct *linux_tty; | ||
54 | int open_count; | ||
55 | unsigned int control_lines; | ||
56 | struct mutex ipw_tty_mutex; | ||
57 | int tx_bytes_queued; | ||
58 | int closing; | ||
59 | }; | ||
60 | |||
61 | static struct ipw_tty *ttys[IPWIRELESS_PCMCIA_MINORS]; | ||
62 | |||
63 | static struct tty_driver *ipw_tty_driver; | ||
64 | |||
65 | static char *tty_type_name(int tty_type) | ||
66 | { | ||
67 | static char *channel_names[] = { | ||
68 | "modem", | ||
69 | "monitor", | ||
70 | "RAS-raw" | ||
71 | }; | ||
72 | |||
73 | return channel_names[tty_type]; | ||
74 | } | ||
75 | |||
76 | static void report_registering(struct ipw_tty *tty) | ||
77 | { | ||
78 | char *iftype = tty_type_name(tty->tty_type); | ||
79 | |||
80 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
81 | ": registering %s device ttyIPWp%d\n", iftype, tty->index); | ||
82 | } | ||
83 | |||
84 | static void report_deregistering(struct ipw_tty *tty) | ||
85 | { | ||
86 | char *iftype = tty_type_name(tty->tty_type); | ||
87 | |||
88 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | ||
89 | ": deregistering %s device ttyIPWp%d\n", iftype, | ||
90 | tty->index); | ||
91 | } | ||
92 | |||
93 | static struct ipw_tty *get_tty(int minor) | ||
94 | { | ||
95 | if (minor < ipw_tty_driver->minor_start | ||
96 | || minor >= ipw_tty_driver->minor_start + | ||
97 | IPWIRELESS_PCMCIA_MINORS) | ||
98 | return NULL; | ||
99 | else { | ||
100 | int minor_offset = minor - ipw_tty_driver->minor_start; | ||
101 | |||
102 | /* | ||
103 | * The 'ras_raw' channel is only available when 'loopback' mode | ||
104 | * is enabled. | ||
105 | * Number of minor starts with 16 (_RANGE * _RAS_RAW). | ||
106 | */ | ||
107 | if (!ipwireless_loopback && | ||
108 | minor_offset >= | ||
109 | IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW) | ||
110 | return NULL; | ||
111 | |||
112 | return ttys[minor_offset]; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | static int ipw_open(struct tty_struct *linux_tty, struct file *filp) | ||
117 | { | ||
118 | int minor = linux_tty->index; | ||
119 | struct ipw_tty *tty = get_tty(minor); | ||
120 | |||
121 | if (!tty) | ||
122 | return -ENODEV; | ||
123 | |||
124 | mutex_lock(&tty->ipw_tty_mutex); | ||
125 | |||
126 | if (tty->closing) { | ||
127 | mutex_unlock(&tty->ipw_tty_mutex); | ||
128 | return -ENODEV; | ||
129 | } | ||
130 | if (tty->open_count == 0) | ||
131 | tty->tx_bytes_queued = 0; | ||
132 | |||
133 | tty->open_count++; | ||
134 | |||
135 | tty->linux_tty = linux_tty; | ||
136 | linux_tty->driver_data = tty; | ||
137 | linux_tty->low_latency = 1; | ||
138 | |||
139 | if (tty->tty_type == TTYTYPE_MODEM) | ||
140 | ipwireless_ppp_open(tty->network); | ||
141 | |||
142 | mutex_unlock(&tty->ipw_tty_mutex); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | static void do_ipw_close(struct ipw_tty *tty) | ||
148 | { | ||
149 | tty->open_count--; | ||
150 | |||
151 | if (tty->open_count == 0) { | ||
152 | struct tty_struct *linux_tty = tty->linux_tty; | ||
153 | |||
154 | if (linux_tty != NULL) { | ||
155 | tty->linux_tty = NULL; | ||
156 | linux_tty->driver_data = NULL; | ||
157 | |||
158 | if (tty->tty_type == TTYTYPE_MODEM) | ||
159 | ipwireless_ppp_close(tty->network); | ||
160 | } | ||
161 | } | ||
162 | } | ||
163 | |||
164 | static void ipw_hangup(struct tty_struct *linux_tty) | ||
165 | { | ||
166 | struct ipw_tty *tty = linux_tty->driver_data; | ||
167 | |||
168 | if (!tty) | ||
169 | return; | ||
170 | |||
171 | mutex_lock(&tty->ipw_tty_mutex); | ||
172 | if (tty->open_count == 0) { | ||
173 | mutex_unlock(&tty->ipw_tty_mutex); | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | do_ipw_close(tty); | ||
178 | |||
179 | mutex_unlock(&tty->ipw_tty_mutex); | ||
180 | } | ||
181 | |||
182 | static void ipw_close(struct tty_struct *linux_tty, struct file *filp) | ||
183 | { | ||
184 | ipw_hangup(linux_tty); | ||
185 | } | ||
186 | |||
187 | /* Take data received from hardware, and send it out the tty */ | ||
188 | void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, | ||
189 | unsigned int length) | ||
190 | { | ||
191 | struct tty_struct *linux_tty; | ||
192 | int work = 0; | ||
193 | |||
194 | mutex_lock(&tty->ipw_tty_mutex); | ||
195 | linux_tty = tty->linux_tty; | ||
196 | if (linux_tty == NULL) { | ||
197 | mutex_unlock(&tty->ipw_tty_mutex); | ||
198 | return; | ||
199 | } | ||
200 | |||
201 | if (!tty->open_count) { | ||
202 | mutex_unlock(&tty->ipw_tty_mutex); | ||
203 | return; | ||
204 | } | ||
205 | mutex_unlock(&tty->ipw_tty_mutex); | ||
206 | |||
207 | work = tty_insert_flip_string(linux_tty, data, length); | ||
208 | |||
209 | if (work != length) | ||
210 | printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME | ||
211 | ": %d chars not inserted to flip buffer!\n", | ||
212 | length - work); | ||
213 | |||
214 | /* | ||
215 | * This may sleep if ->low_latency is set | ||
216 | */ | ||
217 | if (work) | ||
218 | tty_flip_buffer_push(linux_tty); | ||
219 | } | ||
220 | |||
221 | static void ipw_write_packet_sent_callback(void *callback_data, | ||
222 | unsigned int packet_length) | ||
223 | { | ||
224 | struct ipw_tty *tty = callback_data; | ||
225 | |||
226 | /* | ||
227 | * Packet has been sent, so we subtract the number of bytes from our | ||
228 | * tally of outstanding TX bytes. | ||
229 | */ | ||
230 | tty->tx_bytes_queued -= packet_length; | ||
231 | } | ||
232 | |||
233 | static int ipw_write(struct tty_struct *linux_tty, | ||
234 | const unsigned char *buf, int count) | ||
235 | { | ||
236 | struct ipw_tty *tty = linux_tty->driver_data; | ||
237 | int room, ret; | ||
238 | |||
239 | if (!tty) | ||
240 | return -ENODEV; | ||
241 | |||
242 | mutex_lock(&tty->ipw_tty_mutex); | ||
243 | if (!tty->open_count) { | ||
244 | mutex_unlock(&tty->ipw_tty_mutex); | ||
245 | return -EINVAL; | ||
246 | } | ||
247 | |||
248 | room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued; | ||
249 | if (room < 0) | ||
250 | room = 0; | ||
251 | /* Don't allow caller to write any more than we have room for */ | ||
252 | if (count > room) | ||
253 | count = room; | ||
254 | |||
255 | if (count == 0) { | ||
256 | mutex_unlock(&tty->ipw_tty_mutex); | ||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS, | ||
261 | buf, count, | ||
262 | ipw_write_packet_sent_callback, tty); | ||
263 | if (ret == -1) { | ||
264 | mutex_unlock(&tty->ipw_tty_mutex); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | tty->tx_bytes_queued += count; | ||
269 | mutex_unlock(&tty->ipw_tty_mutex); | ||
270 | |||
271 | return count; | ||
272 | } | ||
273 | |||
274 | static int ipw_write_room(struct tty_struct *linux_tty) | ||
275 | { | ||
276 | struct ipw_tty *tty = linux_tty->driver_data; | ||
277 | int room; | ||
278 | |||
279 | /* FIXME: Exactly how is the tty object locked here .. */ | ||
280 | if (!tty) | ||
281 | return -ENODEV; | ||
282 | |||
283 | if (!tty->open_count) | ||
284 | return -EINVAL; | ||
285 | |||
286 | room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued; | ||
287 | if (room < 0) | ||
288 | room = 0; | ||
289 | |||
290 | return room; | ||
291 | } | ||
292 | |||
293 | static int ipwireless_get_serial_info(struct ipw_tty *tty, | ||
294 | struct serial_struct __user *retinfo) | ||
295 | { | ||
296 | struct serial_struct tmp; | ||
297 | |||
298 | if (!retinfo) | ||
299 | return (-EFAULT); | ||
300 | |||
301 | memset(&tmp, 0, sizeof(tmp)); | ||
302 | tmp.type = PORT_UNKNOWN; | ||
303 | tmp.line = tty->index; | ||
304 | tmp.port = 0; | ||
305 | tmp.irq = 0; | ||
306 | tmp.flags = 0; | ||
307 | tmp.baud_base = 115200; | ||
308 | tmp.close_delay = 0; | ||
309 | tmp.closing_wait = 0; | ||
310 | tmp.custom_divisor = 0; | ||
311 | tmp.hub6 = 0; | ||
312 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | ||
313 | return -EFAULT; | ||
314 | |||
315 | return 0; | ||
316 | } | ||
317 | |||
318 | static int ipw_chars_in_buffer(struct tty_struct *linux_tty) | ||
319 | { | ||
320 | struct ipw_tty *tty = linux_tty->driver_data; | ||
321 | |||
322 | if (!tty) | ||
323 | return 0; | ||
324 | |||
325 | if (!tty->open_count) | ||
326 | return 0; | ||
327 | |||
328 | return tty->tx_bytes_queued; | ||
329 | } | ||
330 | |||
331 | static int get_control_lines(struct ipw_tty *tty) | ||
332 | { | ||
333 | unsigned int my = tty->control_lines; | ||
334 | unsigned int out = 0; | ||
335 | |||
336 | if (my & IPW_CONTROL_LINE_RTS) | ||
337 | out |= TIOCM_RTS; | ||
338 | if (my & IPW_CONTROL_LINE_DTR) | ||
339 | out |= TIOCM_DTR; | ||
340 | if (my & IPW_CONTROL_LINE_CTS) | ||
341 | out |= TIOCM_CTS; | ||
342 | if (my & IPW_CONTROL_LINE_DSR) | ||
343 | out |= TIOCM_DSR; | ||
344 | if (my & IPW_CONTROL_LINE_DCD) | ||
345 | out |= TIOCM_CD; | ||
346 | |||
347 | return out; | ||
348 | } | ||
349 | |||
350 | static int set_control_lines(struct ipw_tty *tty, unsigned int set, | ||
351 | unsigned int clear) | ||
352 | { | ||
353 | int ret; | ||
354 | |||
355 | if (set & TIOCM_RTS) { | ||
356 | ret = ipwireless_set_RTS(tty->hardware, tty->channel_idx, 1); | ||
357 | if (ret) | ||
358 | return ret; | ||
359 | if (tty->secondary_channel_idx != -1) { | ||
360 | ret = ipwireless_set_RTS(tty->hardware, | ||
361 | tty->secondary_channel_idx, 1); | ||
362 | if (ret) | ||
363 | return ret; | ||
364 | } | ||
365 | } | ||
366 | if (set & TIOCM_DTR) { | ||
367 | ret = ipwireless_set_DTR(tty->hardware, tty->channel_idx, 1); | ||
368 | if (ret) | ||
369 | return ret; | ||
370 | if (tty->secondary_channel_idx != -1) { | ||
371 | ret = ipwireless_set_DTR(tty->hardware, | ||
372 | tty->secondary_channel_idx, 1); | ||
373 | if (ret) | ||
374 | return ret; | ||
375 | } | ||
376 | } | ||
377 | if (clear & TIOCM_RTS) { | ||
378 | ret = ipwireless_set_RTS(tty->hardware, tty->channel_idx, 0); | ||
379 | if (tty->secondary_channel_idx != -1) { | ||
380 | ret = ipwireless_set_RTS(tty->hardware, | ||
381 | tty->secondary_channel_idx, 0); | ||
382 | if (ret) | ||
383 | return ret; | ||
384 | } | ||
385 | } | ||
386 | if (clear & TIOCM_DTR) { | ||
387 | ret = ipwireless_set_DTR(tty->hardware, tty->channel_idx, 0); | ||
388 | if (tty->secondary_channel_idx != -1) { | ||
389 | ret = ipwireless_set_DTR(tty->hardware, | ||
390 | tty->secondary_channel_idx, 0); | ||
391 | if (ret) | ||
392 | return ret; | ||
393 | } | ||
394 | } | ||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | static int ipw_tiocmget(struct tty_struct *linux_tty, struct file *file) | ||
399 | { | ||
400 | struct ipw_tty *tty = linux_tty->driver_data; | ||
401 | /* FIXME: Exactly how is the tty object locked here .. */ | ||
402 | |||
403 | if (!tty) | ||
404 | return -ENODEV; | ||
405 | |||
406 | if (!tty->open_count) | ||
407 | return -EINVAL; | ||
408 | |||
409 | return get_control_lines(tty); | ||
410 | } | ||
411 | |||
412 | static int | ||
413 | ipw_tiocmset(struct tty_struct *linux_tty, struct file *file, | ||
414 | unsigned int set, unsigned int clear) | ||
415 | { | ||
416 | struct ipw_tty *tty = linux_tty->driver_data; | ||
417 | /* FIXME: Exactly how is the tty object locked here .. */ | ||
418 | |||
419 | if (!tty) | ||
420 | return -ENODEV; | ||
421 | |||
422 | if (!tty->open_count) | ||
423 | return -EINVAL; | ||
424 | |||
425 | return set_control_lines(tty, set, clear); | ||
426 | } | ||
427 | |||
428 | static int ipw_ioctl(struct tty_struct *linux_tty, struct file *file, | ||
429 | unsigned int cmd, unsigned long arg) | ||
430 | { | ||
431 | struct ipw_tty *tty = linux_tty->driver_data; | ||
432 | |||
433 | if (!tty) | ||
434 | return -ENODEV; | ||
435 | |||
436 | if (!tty->open_count) | ||
437 | return -EINVAL; | ||
438 | |||
439 | /* FIXME: Exactly how is the tty object locked here .. */ | ||
440 | |||
441 | switch (cmd) { | ||
442 | case TIOCGSERIAL: | ||
443 | return ipwireless_get_serial_info(tty, (void __user *) arg); | ||
444 | |||
445 | case TIOCSSERIAL: | ||
446 | return 0; /* Keeps the PCMCIA scripts happy. */ | ||
447 | } | ||
448 | |||
449 | if (tty->tty_type == TTYTYPE_MODEM) { | ||
450 | switch (cmd) { | ||
451 | case PPPIOCGCHAN: | ||
452 | { | ||
453 | int chan = ipwireless_ppp_channel_index( | ||
454 | tty->network); | ||
455 | |||
456 | if (chan < 0) | ||
457 | return -ENODEV; | ||
458 | if (put_user(chan, (int __user *) arg)) | ||
459 | return -EFAULT; | ||
460 | } | ||
461 | return 0; | ||
462 | |||
463 | case PPPIOCGUNIT: | ||
464 | { | ||
465 | int unit = ipwireless_ppp_unit_number( | ||
466 | tty->network); | ||
467 | |||
468 | if (unit < 0) | ||
469 | return -ENODEV; | ||
470 | if (put_user(unit, (int __user *) arg)) | ||
471 | return -EFAULT; | ||
472 | } | ||
473 | return 0; | ||
474 | |||
475 | case FIONREAD: | ||
476 | { | ||
477 | int val = 0; | ||
478 | |||
479 | if (put_user(val, (int __user *) arg)) | ||
480 | return -EFAULT; | ||
481 | } | ||
482 | return 0; | ||
483 | case TCFLSH: | ||
484 | return tty_perform_flush(linux_tty, arg); | ||
485 | } | ||
486 | } | ||
487 | return tty_mode_ioctl(linux_tty, file, cmd , arg); | ||
488 | } | ||
489 | |||
490 | static int add_tty(int j, | ||
491 | struct ipw_hardware *hardware, | ||
492 | struct ipw_network *network, int channel_idx, | ||
493 | int secondary_channel_idx, int tty_type) | ||
494 | { | ||
495 | ttys[j] = kzalloc(sizeof(struct ipw_tty), GFP_KERNEL); | ||
496 | if (!ttys[j]) | ||
497 | return -ENOMEM; | ||
498 | ttys[j]->index = j; | ||
499 | ttys[j]->hardware = hardware; | ||
500 | ttys[j]->channel_idx = channel_idx; | ||
501 | ttys[j]->secondary_channel_idx = secondary_channel_idx; | ||
502 | ttys[j]->network = network; | ||
503 | ttys[j]->tty_type = tty_type; | ||
504 | mutex_init(&ttys[j]->ipw_tty_mutex); | ||
505 | |||
506 | tty_register_device(ipw_tty_driver, j, NULL); | ||
507 | ipwireless_associate_network_tty(network, channel_idx, ttys[j]); | ||
508 | |||
509 | if (secondary_channel_idx != -1) | ||
510 | ipwireless_associate_network_tty(network, | ||
511 | secondary_channel_idx, | ||
512 | ttys[j]); | ||
513 | if (get_tty(j + ipw_tty_driver->minor_start) == ttys[j]) | ||
514 | report_registering(ttys[j]); | ||
515 | return 0; | ||
516 | } | ||
517 | |||
518 | struct ipw_tty *ipwireless_tty_create(struct ipw_hardware *hardware, | ||
519 | struct ipw_network *network) | ||
520 | { | ||
521 | int i, j; | ||
522 | |||
523 | for (i = 0; i < IPWIRELESS_PCMCIA_MINOR_RANGE; i++) { | ||
524 | int allfree = 1; | ||
525 | |||
526 | for (j = i; j < IPWIRELESS_PCMCIA_MINORS; | ||
527 | j += IPWIRELESS_PCMCIA_MINOR_RANGE) | ||
528 | if (ttys[j] != NULL) { | ||
529 | allfree = 0; | ||
530 | break; | ||
531 | } | ||
532 | |||
533 | if (allfree) { | ||
534 | j = i; | ||
535 | |||
536 | if (add_tty(j, hardware, network, | ||
537 | IPW_CHANNEL_DIALLER, IPW_CHANNEL_RAS, | ||
538 | TTYTYPE_MODEM)) | ||
539 | return NULL; | ||
540 | |||
541 | j += IPWIRELESS_PCMCIA_MINOR_RANGE; | ||
542 | if (add_tty(j, hardware, network, | ||
543 | IPW_CHANNEL_DIALLER, -1, | ||
544 | TTYTYPE_MONITOR)) | ||
545 | return NULL; | ||
546 | |||
547 | j += IPWIRELESS_PCMCIA_MINOR_RANGE; | ||
548 | if (add_tty(j, hardware, network, | ||
549 | IPW_CHANNEL_RAS, -1, | ||
550 | TTYTYPE_RAS_RAW)) | ||
551 | return NULL; | ||
552 | |||
553 | return ttys[i]; | ||
554 | } | ||
555 | } | ||
556 | return NULL; | ||
557 | } | ||
558 | |||
559 | /* | ||
560 | * Must be called before ipwireless_network_free(). | ||
561 | */ | ||
562 | void ipwireless_tty_free(struct ipw_tty *tty) | ||
563 | { | ||
564 | int j; | ||
565 | struct ipw_network *network = ttys[tty->index]->network; | ||
566 | |||
567 | for (j = tty->index; j < IPWIRELESS_PCMCIA_MINORS; | ||
568 | j += IPWIRELESS_PCMCIA_MINOR_RANGE) { | ||
569 | struct ipw_tty *ttyj = ttys[j]; | ||
570 | |||
571 | if (ttyj) { | ||
572 | mutex_lock(&ttyj->ipw_tty_mutex); | ||
573 | if (get_tty(j + ipw_tty_driver->minor_start) == ttyj) | ||
574 | report_deregistering(ttyj); | ||
575 | ttyj->closing = 1; | ||
576 | if (ttyj->linux_tty != NULL) { | ||
577 | mutex_unlock(&ttyj->ipw_tty_mutex); | ||
578 | tty_hangup(ttyj->linux_tty); | ||
579 | /* Wait till the tty_hangup has completed */ | ||
580 | flush_scheduled_work(); | ||
581 | /* FIXME: Exactly how is the tty object locked here | ||
582 | against a parallel ioctl etc */ | ||
583 | mutex_lock(&ttyj->ipw_tty_mutex); | ||
584 | } | ||
585 | while (ttyj->open_count) | ||
586 | do_ipw_close(ttyj); | ||
587 | ipwireless_disassociate_network_ttys(network, | ||
588 | ttyj->channel_idx); | ||
589 | tty_unregister_device(ipw_tty_driver, j); | ||
590 | ttys[j] = NULL; | ||
591 | mutex_unlock(&ttyj->ipw_tty_mutex); | ||
592 | kfree(ttyj); | ||
593 | } | ||
594 | } | ||
595 | } | ||
596 | |||
597 | static const struct tty_operations tty_ops = { | ||
598 | .open = ipw_open, | ||
599 | .close = ipw_close, | ||
600 | .hangup = ipw_hangup, | ||
601 | .write = ipw_write, | ||
602 | .write_room = ipw_write_room, | ||
603 | .ioctl = ipw_ioctl, | ||
604 | .chars_in_buffer = ipw_chars_in_buffer, | ||
605 | .tiocmget = ipw_tiocmget, | ||
606 | .tiocmset = ipw_tiocmset, | ||
607 | }; | ||
608 | |||
609 | int ipwireless_tty_init(void) | ||
610 | { | ||
611 | int result; | ||
612 | |||
613 | ipw_tty_driver = alloc_tty_driver(IPWIRELESS_PCMCIA_MINORS); | ||
614 | if (!ipw_tty_driver) | ||
615 | return -ENOMEM; | ||
616 | |||
617 | ipw_tty_driver->owner = THIS_MODULE; | ||
618 | ipw_tty_driver->driver_name = IPWIRELESS_PCCARD_NAME; | ||
619 | ipw_tty_driver->name = "ttyIPWp"; | ||
620 | ipw_tty_driver->major = 0; | ||
621 | ipw_tty_driver->minor_start = IPWIRELESS_PCMCIA_START; | ||
622 | ipw_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; | ||
623 | ipw_tty_driver->subtype = SERIAL_TYPE_NORMAL; | ||
624 | ipw_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | ||
625 | ipw_tty_driver->init_termios = tty_std_termios; | ||
626 | ipw_tty_driver->init_termios.c_cflag = | ||
627 | B9600 | CS8 | CREAD | HUPCL | CLOCAL; | ||
628 | ipw_tty_driver->init_termios.c_ispeed = 9600; | ||
629 | ipw_tty_driver->init_termios.c_ospeed = 9600; | ||
630 | tty_set_operations(ipw_tty_driver, &tty_ops); | ||
631 | result = tty_register_driver(ipw_tty_driver); | ||
632 | if (result) { | ||
633 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
634 | ": failed to register tty driver\n"); | ||
635 | put_tty_driver(ipw_tty_driver); | ||
636 | return result; | ||
637 | } | ||
638 | |||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | void ipwireless_tty_release(void) | ||
643 | { | ||
644 | int ret; | ||
645 | |||
646 | ret = tty_unregister_driver(ipw_tty_driver); | ||
647 | put_tty_driver(ipw_tty_driver); | ||
648 | if (ret != 0) | ||
649 | printk(KERN_ERR IPWIRELESS_PCCARD_NAME | ||
650 | ": tty_unregister_driver failed with code %d\n", ret); | ||
651 | } | ||
652 | |||
653 | int ipwireless_tty_is_modem(struct ipw_tty *tty) | ||
654 | { | ||
655 | return tty->tty_type == TTYTYPE_MODEM; | ||
656 | } | ||
657 | |||
658 | void | ||
659 | ipwireless_tty_notify_control_line_change(struct ipw_tty *tty, | ||
660 | unsigned int channel_idx, | ||
661 | unsigned int control_lines, | ||
662 | unsigned int changed_mask) | ||
663 | { | ||
664 | unsigned int old_control_lines = tty->control_lines; | ||
665 | |||
666 | tty->control_lines = (tty->control_lines & ~changed_mask) | ||
667 | | (control_lines & changed_mask); | ||
668 | |||
669 | /* | ||
670 | * If DCD is de-asserted, we close the tty so pppd can tell that we | ||
671 | * have gone offline. | ||
672 | */ | ||
673 | if ((old_control_lines & IPW_CONTROL_LINE_DCD) | ||
674 | && !(tty->control_lines & IPW_CONTROL_LINE_DCD) | ||
675 | && tty->linux_tty) { | ||
676 | tty_hangup(tty->linux_tty); | ||
677 | } | ||
678 | } | ||
679 | |||
diff --git a/drivers/char/pcmcia/ipwireless/tty.h b/drivers/char/pcmcia/ipwireless/tty.h deleted file mode 100644 index 3e163d4cab15..000000000000 --- a/drivers/char/pcmcia/ipwireless/tty.h +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | /* | ||
2 | * IPWireless 3G PCMCIA Network Driver | ||
3 | * | ||
4 | * Original code | ||
5 | * by Stephen Blackheath <stephen@blacksapphire.com>, | ||
6 | * Ben Martel <benm@symmetric.co.nz> | ||
7 | * | ||
8 | * Copyrighted as follows: | ||
9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) | ||
10 | * | ||
11 | * Various driver changes and rewrites, port to new kernels | ||
12 | * Copyright (C) 2006-2007 Jiri Kosina | ||
13 | * | ||
14 | * Misc code cleanups and updates | ||
15 | * Copyright (C) 2007 David Sterba | ||
16 | */ | ||
17 | |||
18 | #ifndef _IPWIRELESS_CS_TTY_H_ | ||
19 | #define _IPWIRELESS_CS_TTY_H_ | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | #include <linux/sched.h> | ||
23 | |||
24 | #include <pcmcia/cs.h> | ||
25 | #include <pcmcia/cistpl.h> | ||
26 | #include <pcmcia/ds.h> | ||
27 | |||
28 | struct ipw_tty; | ||
29 | struct ipw_network; | ||
30 | struct ipw_hardware; | ||
31 | |||
32 | int ipwireless_tty_init(void); | ||
33 | void ipwireless_tty_release(void); | ||
34 | |||
35 | struct ipw_tty *ipwireless_tty_create(struct ipw_hardware *hw, | ||
36 | struct ipw_network *net); | ||
37 | void ipwireless_tty_free(struct ipw_tty *tty); | ||
38 | void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, | ||
39 | unsigned int length); | ||
40 | int ipwireless_tty_is_modem(struct ipw_tty *tty); | ||
41 | void ipwireless_tty_notify_control_line_change(struct ipw_tty *tty, | ||
42 | unsigned int channel_idx, | ||
43 | unsigned int control_lines, | ||
44 | unsigned int changed_mask); | ||
45 | |||
46 | #endif | ||
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 9ecd6bef5d3b..15781396af25 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -70,7 +70,6 @@ | |||
70 | #include <linux/workqueue.h> | 70 | #include <linux/workqueue.h> |
71 | #include <linux/hdlc.h> | 71 | #include <linux/hdlc.h> |
72 | 72 | ||
73 | #include <pcmcia/cs.h> | ||
74 | #include <pcmcia/cistpl.h> | 73 | #include <pcmcia/cistpl.h> |
75 | #include <pcmcia/cisreg.h> | 74 | #include <pcmcia/cisreg.h> |
76 | #include <pcmcia/ds.h> | 75 | #include <pcmcia/ds.h> |
@@ -419,9 +418,9 @@ static void bh_status(MGSLPC_INFO *info); | |||
419 | /* | 418 | /* |
420 | * ioctl handlers | 419 | * ioctl handlers |
421 | */ | 420 | */ |
422 | static int tiocmget(struct tty_struct *tty, struct file *file); | 421 | static int tiocmget(struct tty_struct *tty); |
423 | static int tiocmset(struct tty_struct *tty, struct file *file, | 422 | static int tiocmset(struct tty_struct *tty, |
424 | unsigned int set, unsigned int clear); | 423 | unsigned int set, unsigned int clear); |
425 | static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount); | 424 | static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount); |
426 | static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params); | 425 | static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params); |
427 | static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty); | 426 | static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty); |
@@ -550,9 +549,6 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
550 | 549 | ||
551 | /* Initialize the struct pcmcia_device structure */ | 550 | /* Initialize the struct pcmcia_device structure */ |
552 | 551 | ||
553 | link->conf.Attributes = 0; | ||
554 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
555 | |||
556 | ret = mgslpc_config(link); | 552 | ret = mgslpc_config(link); |
557 | if (ret) | 553 | if (ret) |
558 | return ret; | 554 | return ret; |
@@ -565,20 +561,8 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
565 | /* Card has been inserted. | 561 | /* Card has been inserted. |
566 | */ | 562 | */ |
567 | 563 | ||
568 | static int mgslpc_ioprobe(struct pcmcia_device *p_dev, | 564 | static int mgslpc_ioprobe(struct pcmcia_device *p_dev, void *priv_data) |
569 | cistpl_cftable_entry_t *cfg, | ||
570 | cistpl_cftable_entry_t *dflt, | ||
571 | unsigned int vcc, | ||
572 | void *priv_data) | ||
573 | { | 565 | { |
574 | if (!cfg->io.nwin) | ||
575 | return -ENODEV; | ||
576 | |||
577 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
578 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
579 | p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); | ||
580 | p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
581 | |||
582 | return pcmcia_request_io(p_dev); | 566 | return pcmcia_request_io(p_dev); |
583 | } | 567 | } |
584 | 568 | ||
@@ -590,32 +574,24 @@ static int mgslpc_config(struct pcmcia_device *link) | |||
590 | if (debug_level >= DEBUG_LEVEL_INFO) | 574 | if (debug_level >= DEBUG_LEVEL_INFO) |
591 | printk("mgslpc_config(0x%p)\n", link); | 575 | printk("mgslpc_config(0x%p)\n", link); |
592 | 576 | ||
577 | link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; | ||
578 | |||
593 | ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); | 579 | ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); |
594 | if (ret != 0) | 580 | if (ret != 0) |
595 | goto failed; | 581 | goto failed; |
596 | 582 | ||
597 | link->conf.Attributes = CONF_ENABLE_IRQ; | 583 | link->config_index = 8; |
598 | link->conf.IntType = INT_MEMORY_AND_IO; | 584 | link->config_regs = PRESENT_OPTION; |
599 | link->conf.ConfigIndex = 8; | ||
600 | link->conf.Present = PRESENT_OPTION; | ||
601 | 585 | ||
602 | ret = pcmcia_request_irq(link, mgslpc_isr); | 586 | ret = pcmcia_request_irq(link, mgslpc_isr); |
603 | if (ret) | 587 | if (ret) |
604 | goto failed; | 588 | goto failed; |
605 | ret = pcmcia_request_configuration(link, &link->conf); | 589 | ret = pcmcia_enable_device(link); |
606 | if (ret) | 590 | if (ret) |
607 | goto failed; | 591 | goto failed; |
608 | 592 | ||
609 | info->io_base = link->resource[0]->start; | 593 | info->io_base = link->resource[0]->start; |
610 | info->irq_level = link->irq; | 594 | info->irq_level = link->irq; |
611 | |||
612 | dev_info(&link->dev, "index 0x%02x:", | ||
613 | link->conf.ConfigIndex); | ||
614 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | ||
615 | printk(", irq %d", link->irq); | ||
616 | if (link->resource[0]) | ||
617 | printk(", io %pR", link->resource[0]); | ||
618 | printk("\n"); | ||
619 | return 0; | 595 | return 0; |
620 | 596 | ||
621 | failed: | 597 | failed: |
@@ -1314,7 +1290,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) | |||
1314 | /* Allocate and claim adapter resources */ | 1290 | /* Allocate and claim adapter resources */ |
1315 | retval = claim_resources(info); | 1291 | retval = claim_resources(info); |
1316 | 1292 | ||
1317 | /* perform existance check and diagnostics */ | 1293 | /* perform existence check and diagnostics */ |
1318 | if ( !retval ) | 1294 | if ( !retval ) |
1319 | retval = adapter_test(info); | 1295 | retval = adapter_test(info); |
1320 | 1296 | ||
@@ -2138,7 +2114,7 @@ static int modem_input_wait(MGSLPC_INFO *info,int arg) | |||
2138 | 2114 | ||
2139 | /* return the state of the serial control and status signals | 2115 | /* return the state of the serial control and status signals |
2140 | */ | 2116 | */ |
2141 | static int tiocmget(struct tty_struct *tty, struct file *file) | 2117 | static int tiocmget(struct tty_struct *tty) |
2142 | { | 2118 | { |
2143 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; | 2119 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; |
2144 | unsigned int result; | 2120 | unsigned int result; |
@@ -2163,7 +2139,7 @@ static int tiocmget(struct tty_struct *tty, struct file *file) | |||
2163 | 2139 | ||
2164 | /* set modem control signals (DTR/RTS) | 2140 | /* set modem control signals (DTR/RTS) |
2165 | */ | 2141 | */ |
2166 | static int tiocmset(struct tty_struct *tty, struct file *file, | 2142 | static int tiocmset(struct tty_struct *tty, |
2167 | unsigned int set, unsigned int clear) | 2143 | unsigned int set, unsigned int clear) |
2168 | { | 2144 | { |
2169 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; | 2145 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; |
@@ -2215,26 +2191,47 @@ static int mgslpc_break(struct tty_struct *tty, int break_state) | |||
2215 | return 0; | 2191 | return 0; |
2216 | } | 2192 | } |
2217 | 2193 | ||
2194 | static int mgslpc_get_icount(struct tty_struct *tty, | ||
2195 | struct serial_icounter_struct *icount) | ||
2196 | { | ||
2197 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; | ||
2198 | struct mgsl_icount cnow; /* kernel counter temps */ | ||
2199 | unsigned long flags; | ||
2200 | |||
2201 | spin_lock_irqsave(&info->lock,flags); | ||
2202 | cnow = info->icount; | ||
2203 | spin_unlock_irqrestore(&info->lock,flags); | ||
2204 | |||
2205 | icount->cts = cnow.cts; | ||
2206 | icount->dsr = cnow.dsr; | ||
2207 | icount->rng = cnow.rng; | ||
2208 | icount->dcd = cnow.dcd; | ||
2209 | icount->rx = cnow.rx; | ||
2210 | icount->tx = cnow.tx; | ||
2211 | icount->frame = cnow.frame; | ||
2212 | icount->overrun = cnow.overrun; | ||
2213 | icount->parity = cnow.parity; | ||
2214 | icount->brk = cnow.brk; | ||
2215 | icount->buf_overrun = cnow.buf_overrun; | ||
2216 | |||
2217 | return 0; | ||
2218 | } | ||
2219 | |||
2218 | /* Service an IOCTL request | 2220 | /* Service an IOCTL request |
2219 | * | 2221 | * |
2220 | * Arguments: | 2222 | * Arguments: |
2221 | * | 2223 | * |
2222 | * tty pointer to tty instance data | 2224 | * tty pointer to tty instance data |
2223 | * file pointer to associated file object for device | ||
2224 | * cmd IOCTL command code | 2225 | * cmd IOCTL command code |
2225 | * arg command argument/context | 2226 | * arg command argument/context |
2226 | * | 2227 | * |
2227 | * Return Value: 0 if success, otherwise error code | 2228 | * Return Value: 0 if success, otherwise error code |
2228 | */ | 2229 | */ |
2229 | static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | 2230 | static int mgslpc_ioctl(struct tty_struct *tty, |
2230 | unsigned int cmd, unsigned long arg) | 2231 | unsigned int cmd, unsigned long arg) |
2231 | { | 2232 | { |
2232 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; | 2233 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; |
2233 | int error; | ||
2234 | struct mgsl_icount cnow; /* kernel counter temps */ | ||
2235 | struct serial_icounter_struct __user *p_cuser; /* user space */ | ||
2236 | void __user *argp = (void __user *)arg; | 2234 | void __user *argp = (void __user *)arg; |
2237 | unsigned long flags; | ||
2238 | 2235 | ||
2239 | if (debug_level >= DEBUG_LEVEL_INFO) | 2236 | if (debug_level >= DEBUG_LEVEL_INFO) |
2240 | printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, | 2237 | printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, |
@@ -2244,7 +2241,7 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | |||
2244 | return -ENODEV; | 2241 | return -ENODEV; |
2245 | 2242 | ||
2246 | if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && | 2243 | if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && |
2247 | (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { | 2244 | (cmd != TIOCMIWAIT)) { |
2248 | if (tty->flags & (1 << TTY_IO_ERROR)) | 2245 | if (tty->flags & (1 << TTY_IO_ERROR)) |
2249 | return -EIO; | 2246 | return -EIO; |
2250 | } | 2247 | } |
@@ -2274,34 +2271,6 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | |||
2274 | return wait_events(info, argp); | 2271 | return wait_events(info, argp); |
2275 | case TIOCMIWAIT: | 2272 | case TIOCMIWAIT: |
2276 | return modem_input_wait(info,(int)arg); | 2273 | return modem_input_wait(info,(int)arg); |
2277 | case TIOCGICOUNT: | ||
2278 | spin_lock_irqsave(&info->lock,flags); | ||
2279 | cnow = info->icount; | ||
2280 | spin_unlock_irqrestore(&info->lock,flags); | ||
2281 | p_cuser = argp; | ||
2282 | PUT_USER(error,cnow.cts, &p_cuser->cts); | ||
2283 | if (error) return error; | ||
2284 | PUT_USER(error,cnow.dsr, &p_cuser->dsr); | ||
2285 | if (error) return error; | ||
2286 | PUT_USER(error,cnow.rng, &p_cuser->rng); | ||
2287 | if (error) return error; | ||
2288 | PUT_USER(error,cnow.dcd, &p_cuser->dcd); | ||
2289 | if (error) return error; | ||
2290 | PUT_USER(error,cnow.rx, &p_cuser->rx); | ||
2291 | if (error) return error; | ||
2292 | PUT_USER(error,cnow.tx, &p_cuser->tx); | ||
2293 | if (error) return error; | ||
2294 | PUT_USER(error,cnow.frame, &p_cuser->frame); | ||
2295 | if (error) return error; | ||
2296 | PUT_USER(error,cnow.overrun, &p_cuser->overrun); | ||
2297 | if (error) return error; | ||
2298 | PUT_USER(error,cnow.parity, &p_cuser->parity); | ||
2299 | if (error) return error; | ||
2300 | PUT_USER(error,cnow.brk, &p_cuser->brk); | ||
2301 | if (error) return error; | ||
2302 | PUT_USER(error,cnow.buf_overrun, &p_cuser->buf_overrun); | ||
2303 | if (error) return error; | ||
2304 | return 0; | ||
2305 | default: | 2274 | default: |
2306 | return -ENOIOCTLCMD; | 2275 | return -ENOIOCTLCMD; |
2307 | } | 2276 | } |
@@ -2711,7 +2680,7 @@ static void rx_free_buffers(MGSLPC_INFO *info) | |||
2711 | static int claim_resources(MGSLPC_INFO *info) | 2680 | static int claim_resources(MGSLPC_INFO *info) |
2712 | { | 2681 | { |
2713 | if (rx_alloc_buffers(info) < 0 ) { | 2682 | if (rx_alloc_buffers(info) < 0 ) { |
2714 | printk( "Cant allocate rx buffer %s\n", info->device_name); | 2683 | printk( "Can't allocate rx buffer %s\n", info->device_name); |
2715 | release_resources(info); | 2684 | release_resources(info); |
2716 | return -ENODEV; | 2685 | return -ENODEV; |
2717 | } | 2686 | } |
@@ -2789,7 +2758,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info) | |||
2789 | } | 2758 | } |
2790 | } | 2759 | } |
2791 | 2760 | ||
2792 | static struct pcmcia_device_id mgslpc_ids[] = { | 2761 | static const struct pcmcia_device_id mgslpc_ids[] = { |
2793 | PCMCIA_DEVICE_MANF_CARD(0x02c5, 0x0050), | 2762 | PCMCIA_DEVICE_MANF_CARD(0x02c5, 0x0050), |
2794 | PCMCIA_DEVICE_NULL | 2763 | PCMCIA_DEVICE_NULL |
2795 | }; | 2764 | }; |
@@ -2797,9 +2766,7 @@ MODULE_DEVICE_TABLE(pcmcia, mgslpc_ids); | |||
2797 | 2766 | ||
2798 | static struct pcmcia_driver mgslpc_driver = { | 2767 | static struct pcmcia_driver mgslpc_driver = { |
2799 | .owner = THIS_MODULE, | 2768 | .owner = THIS_MODULE, |
2800 | .drv = { | 2769 | .name = "synclink_cs", |
2801 | .name = "synclink_cs", | ||
2802 | }, | ||
2803 | .probe = mgslpc_probe, | 2770 | .probe = mgslpc_probe, |
2804 | .remove = mgslpc_detach, | 2771 | .remove = mgslpc_detach, |
2805 | .id_table = mgslpc_ids, | 2772 | .id_table = mgslpc_ids, |
@@ -2828,6 +2795,7 @@ static const struct tty_operations mgslpc_ops = { | |||
2828 | .hangup = mgslpc_hangup, | 2795 | .hangup = mgslpc_hangup, |
2829 | .tiocmget = tiocmget, | 2796 | .tiocmget = tiocmget, |
2830 | .tiocmset = tiocmset, | 2797 | .tiocmset = tiocmset, |
2798 | .get_icount = mgslpc_get_icount, | ||
2831 | .proc_fops = &mgslpc_proc_fops, | 2799 | .proc_fops = &mgslpc_proc_fops, |
2832 | }; | 2800 | }; |
2833 | 2801 | ||
@@ -2835,8 +2803,6 @@ static void synclink_cs_cleanup(void) | |||
2835 | { | 2803 | { |
2836 | int rc; | 2804 | int rc; |
2837 | 2805 | ||
2838 | printk("Unloading %s: version %s\n", driver_name, driver_version); | ||
2839 | |||
2840 | while(mgslpc_device_list) | 2806 | while(mgslpc_device_list) |
2841 | mgslpc_remove_device(mgslpc_device_list); | 2807 | mgslpc_remove_device(mgslpc_device_list); |
2842 | 2808 | ||
@@ -2859,8 +2825,6 @@ static int __init synclink_cs_init(void) | |||
2859 | BREAKPOINT(); | 2825 | BREAKPOINT(); |
2860 | } | 2826 | } |
2861 | 2827 | ||
2862 | printk("%s %s\n", driver_name, driver_version); | ||
2863 | |||
2864 | if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) | 2828 | if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) |
2865 | return rc; | 2829 | return rc; |
2866 | 2830 | ||
@@ -4127,6 +4091,8 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
4127 | if (cmd != SIOCWANDEV) | 4091 | if (cmd != SIOCWANDEV) |
4128 | return hdlc_ioctl(dev, ifr, cmd); | 4092 | return hdlc_ioctl(dev, ifr, cmd); |
4129 | 4093 | ||
4094 | memset(&new_line, 0, size); | ||
4095 | |||
4130 | switch(ifr->ifr_settings.type) { | 4096 | switch(ifr->ifr_settings.type) { |
4131 | case IF_GET_IFACE: /* return current sync_serial_settings */ | 4097 | case IF_GET_IFACE: /* return current sync_serial_settings */ |
4132 | 4098 | ||