serial: max3107: introduce a max3107 driver
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / serial / serial_cs.c
index 8bb715a1a7a6a07609a34b363de5ce9a58960933..141c69554bd481d27863b852bbd79b364417643e 100644 (file)
@@ -45,7 +45,6 @@
 #include <asm/io.h>
 #include <asm/system.h>
 
-#include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/ciscode.h>
@@ -115,16 +114,14 @@ static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_
 
 static int quirk_post_ibm(struct pcmcia_device *link)
 {
-       conf_reg_t reg = { 0, CS_READ, 0x800, 0 };
+       u8 val;
        int ret;
 
-       ret = pcmcia_access_configuration_register(link, &reg);
+       ret = pcmcia_read_config_byte(link, 0x800, &val);
        if (ret)
                goto failed;
 
-       reg.Action = CS_WRITE;
-       reg.Value = reg.Value | 1;
-       ret = pcmcia_access_configuration_register(link, &reg);
+       ret = pcmcia_write_config_byte(link, 0x800, val | 1);
        if (ret)
                goto failed;
        return 0;
@@ -338,8 +335,8 @@ static int serial_probe(struct pcmcia_device *link)
        info->p_dev = link;
        link->priv = info;
 
-       link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-       link->io.NumPorts1 = 8;
+       link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
+       link->resource[0]->end = 8;
        link->conf.Attributes = CONF_ENABLE_IRQ;
        if (do_sound) {
                link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -427,12 +424,13 @@ static int simple_config_check(struct pcmcia_device *p_dev,
                p_dev->conf.Vpp =
                        cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
 
+       p_dev->io_lines = ((*try & 0x1) == 0) ?
+                       16 : cf->io.flags & CISTPL_IO_LINES_MASK;
+
        if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[(*try >> 1)])
            && (cf->io.win[0].base != 0)) {
-               p_dev->io.BasePort1 = cf->io.win[0].base;
-               p_dev->io.IOAddrLines = ((*try & 0x1) == 0) ?
-                       16 : cf->io.flags & CISTPL_IO_LINES_MASK;
-               if (!pcmcia_request_io(p_dev, &p_dev->io))
+               p_dev->resource[0]->start = cf->io.win[0].base;
+               if (!pcmcia_request_io(p_dev))
                        return 0;
        }
        return -EINVAL;
@@ -449,9 +447,9 @@ static int simple_config_check_notpicky(struct pcmcia_device *p_dev,
 
        if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
                for (j = 0; j < 5; j++) {
-                       p_dev->io.BasePort1 = base[j];
-                       p_dev->io.IOAddrLines = base[j] ? 16 : 3;
-                       if (!pcmcia_request_io(p_dev, &p_dev->io))
+                       p_dev->resource[0]->start = base[j];
+                       p_dev->io_lines = base[j] ? 16 : 3;
+                       if (!pcmcia_request_io(p_dev))
                                return 0;
                }
        }
@@ -466,13 +464,13 @@ static int simple_config(struct pcmcia_device *link)
        /* If the card is already configured, look up the port and irq */
        if (link->function_config) {
                unsigned int port = 0;
-               if ((link->io.BasePort2 != 0) &&
-                   (link->io.NumPorts2 == 8)) {
-                       port = link->io.BasePort2;
+               if ((link->resource[1]->end != 0) &&
+                       (resource_size(link->resource[1]) == 8)) {
+                       port = link->resource[1]->end;
                        info->slave = 1;
                } else if ((info->manfid == MANFID_OSITECH) &&
-                          (link->io.NumPorts1 == 0x40)) {
-                       port = link->io.BasePort1 + 0x28;
+                       (resource_size(link->resource[0]) == 0x40)) {
+                       port = link->resource[0]->start + 0x28;
                        info->slave = 1;
                }
                if (info->slave) {
@@ -510,7 +508,7 @@ found_port:
        i = pcmcia_request_configuration(link, &link->conf);
        if (i != 0)
                return -1;
-       return setup_serial(link, info, link->io.BasePort1, link->irq);
+       return setup_serial(link, info, link->resource[0]->start, link->irq);
 }
 
 static int multi_config_check(struct pcmcia_device *p_dev,
@@ -524,10 +522,10 @@ static int multi_config_check(struct pcmcia_device *p_dev,
        /* The quad port cards have bad CIS's, so just look for a
           window larger than 8 ports and assume it will be right */
        if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
-               p_dev->io.BasePort1 = cf->io.win[0].base;
-               p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
-               if (!pcmcia_request_io(p_dev, &p_dev->io)) {
-                       *base2 = p_dev->io.BasePort1 + 8;
+               p_dev->resource[0]->start = cf->io.win[0].base;
+               p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK;
+               if (!pcmcia_request_io(p_dev)) {
+                       *base2 = p_dev->resource[0]->start + 8;
                        return 0;
                }
        }
@@ -543,11 +541,11 @@ static int multi_config_check_notpicky(struct pcmcia_device *p_dev,
        int *base2 = priv_data;
 
        if (cf->io.nwin == 2) {
-               p_dev->io.BasePort1 = cf->io.win[0].base;
-               p_dev->io.BasePort2 = cf->io.win[1].base;
-               p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
-               if (!pcmcia_request_io(p_dev, &p_dev->io)) {
-                       *base2 = p_dev->io.BasePort2;
+               p_dev->resource[0]->start = cf->io.win[0].base;
+               p_dev->resource[1]->start = cf->io.win[1].base;
+               p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK;
+               if (!pcmcia_request_io(p_dev)) {
+                       *base2 = p_dev->resource[1]->start;
                        return 0;
                }
        }
@@ -560,10 +558,10 @@ static int multi_config(struct pcmcia_device *link)
        int i, base2 = 0;
 
        /* First, look for a generic full-sized window */
-       link->io.NumPorts1 = info->multi * 8;
+       link->resource[0]->end = info->multi * 8;
        if (pcmcia_loop_config(link, multi_config_check, &base2)) {
                /* If that didn't work, look for two windows */
-               link->io.NumPorts1 = link->io.NumPorts2 = 8;
+               link->resource[0]->end = link->resource[1]->end = 8;
                info->multi = 2;
                if (pcmcia_loop_config(link, multi_config_check_notpicky,
                                       &base2)) {
@@ -599,9 +597,9 @@ static int multi_config(struct pcmcia_device *link)
                    link->conf.ConfigIndex == 3) {
                        err = setup_serial(link, info, base2,
                                        link->irq);
-                       base2 = link->io.BasePort1;
+                       base2 = link->resource[0]->start;;
                } else {
-                       err = setup_serial(link, info, link->io.BasePort1,
+                       err = setup_serial(link, info, link->resource[0]->start,
                                        link->irq);
                }
                info->c950ctrl = base2;
@@ -616,7 +614,7 @@ static int multi_config(struct pcmcia_device *link)
                return 0;
        }
 
-       setup_serial(link, info, link->io.BasePort1, link->irq);
+       setup_serial(link, info, link->resource[0]->start, link->irq);
        for (i = 0; i < info->multi - 1; i++)
                setup_serial(link, info, base2 + (8 * i),
                                link->irq);
@@ -715,6 +713,8 @@ static struct pcmcia_device_id serial_ids[] = {
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0104, 0x000a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0d0a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0e0a),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0xea15),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0109, 0x0501),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0138, 0x110a),
@@ -724,8 +724,6 @@ static struct pcmcia_device_id serial_ids[] = {
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x016c, 0x0081),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x021b, 0x0101),
        PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x08a1, 0xc0ab),
-       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0d0a),
-       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0e0a),
        PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63),
        PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63),
        PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef),
@@ -768,17 +766,26 @@ static struct pcmcia_device_id serial_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x0276),
        PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0039),
        PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0006),
+       PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0101), /* TDK DF2814 */
+       PCMCIA_DEVICE_MANF_CARD(0x0105, 0x100a), /* Xircom CM-56G */
+       PCMCIA_DEVICE_MANF_CARD(0x0105, 0x3e0a), /* TDK DF5660 */
        PCMCIA_DEVICE_MANF_CARD(0x0105, 0x410a),
+       PCMCIA_DEVICE_MANF_CARD(0x0107, 0x0002), /* USRobotics 14,400 */
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d50),
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d51),
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d52),
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d53),
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0xd180),
+       PCMCIA_DEVICE_MANF_CARD(0x0115, 0x3330), /* USRobotics/SUN 14,400 */
+       PCMCIA_DEVICE_MANF_CARD(0x0124, 0x0100), /* Nokia DTP-2 ver II */
+       PCMCIA_DEVICE_MANF_CARD(0x0134, 0x5600), /* LASAT COMMUNICATIONS A/S */
        PCMCIA_DEVICE_MANF_CARD(0x0137, 0x000e),
        PCMCIA_DEVICE_MANF_CARD(0x0137, 0x001b),
        PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0025),
        PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0045),
        PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0052),
+       PCMCIA_DEVICE_MANF_CARD(0x016c, 0x0006), /* Psion 56K+Fax */
+       PCMCIA_DEVICE_MANF_CARD(0x0200, 0x0001), /* MultiMobile */
        PCMCIA_DEVICE_PROD_ID134("ADV", "TECH", "COMpad-32/85", 0x67459937, 0x916d02ba, 0x8fbe92ae),
        PCMCIA_DEVICE_PROD_ID124("GATEWAY2000", "CC3144", "PCMCIA MODEM", 0x506bccae, 0xcb3685f1, 0xbd6c43ef),
        PCMCIA_DEVICE_PROD_ID14("MEGAHERTZ", "PCMCIA MODEM", 0xf510db04, 0xbd6c43ef),
@@ -792,16 +799,21 @@ static struct pcmcia_device_id serial_ids[] = {
        PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 33600 FAX/DATA MODEM", 0xa3a3062c, 0x5a00ce95),
        PCMCIA_DEVICE_PROD_ID12("Computerboards, Inc.", "PCM-COM422", 0xd0b78f51, 0x7e2d49ed),
        PCMCIA_DEVICE_PROD_ID12("Dr. Neuhaus", "FURY CARD 14K4", 0x76942813, 0x8b96ce65),
+       PCMCIA_DEVICE_PROD_ID12("IBM", "ISDN/56K/GSM", 0xb569a6e5, 0xfee5297b),
        PCMCIA_DEVICE_PROD_ID12("Intelligent", "ANGIA FAX/MODEM", 0xb496e65e, 0xf31602a6),
        PCMCIA_DEVICE_PROD_ID12("Intel", "MODEM 2400+", 0x816cc815, 0x412729fb),
+       PCMCIA_DEVICE_PROD_ID12("Intertex", "IX34-PCMCIA", 0xf8a097e3, 0x97880447),
        PCMCIA_DEVICE_PROD_ID12("IOTech Inc ", "PCMCIA Dual RS-232 Serial Port Card", 0x3bd2d898, 0x92abc92f),
        PCMCIA_DEVICE_PROD_ID12("MACRONIX", "FAX/MODEM", 0x668388b3, 0x3f9bdf2f),
        PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT1432LT", 0x5f73be51, 0x0b3e2383),
        PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e),
        PCMCIA_DEVICE_PROD_ID12("OEM      ", "C288MX     ", 0xb572d360, 0xd2385b7a),
+       PCMCIA_DEVICE_PROD_ID12("Option International", "V34bis GSM/PSTN Data/Fax Modem", 0x9d7cd6f5, 0x5cb8bf41),
        PCMCIA_DEVICE_PROD_ID12("PCMCIA   ", "C336MX     ", 0x99bcafe9, 0xaa25bcab),
        PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f),
        PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d),
+       PCMCIA_DEVICE_PROD_ID12("Telia", "SurfinBird 560P/A+", 0xe2cdd5e, 0xc9314b38),
+       PCMCIA_DEVICE_PROD_ID1("Smart Serial Port", 0x2d8ce292),
        PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"),
        PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"),
        PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"),