Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
0002 /*
0003  * Driver for Future Domain-compatible PCMCIA SCSI cards
0004  * Copyright 2019 Ondrej Zary
0005  *
0006  * The initial developer of the original code is David A. Hinds
0007  * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
0008  * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
0009  */
0010 
0011 #include <linux/module.h>
0012 #include <linux/init.h>
0013 #include <scsi/scsi_host.h>
0014 #include <pcmcia/cistpl.h>
0015 #include <pcmcia/ds.h>
0016 #include "fdomain.h"
0017 
0018 MODULE_AUTHOR("Ondrej Zary, David Hinds");
0019 MODULE_DESCRIPTION("Future Domain PCMCIA SCSI driver");
0020 MODULE_LICENSE("Dual MPL/GPL");
0021 
0022 static int fdomain_config_check(struct pcmcia_device *p_dev, void *priv_data)
0023 {
0024     p_dev->io_lines = 10;
0025     p_dev->resource[0]->end = FDOMAIN_REGION_SIZE;
0026     p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
0027     p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
0028     return pcmcia_request_io(p_dev);
0029 }
0030 
0031 static int fdomain_probe(struct pcmcia_device *link)
0032 {
0033     int ret;
0034     struct Scsi_Host *sh;
0035 
0036     link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
0037     link->config_regs = PRESENT_OPTION;
0038 
0039     ret = pcmcia_loop_config(link, fdomain_config_check, NULL);
0040     if (ret)
0041         return ret;
0042 
0043     ret = pcmcia_enable_device(link);
0044     if (ret)
0045         goto fail_disable;
0046 
0047     if (!request_region(link->resource[0]->start, FDOMAIN_REGION_SIZE,
0048                 "fdomain_cs")) {
0049         ret = -EBUSY;
0050         goto fail_disable;
0051     }
0052 
0053     sh = fdomain_create(link->resource[0]->start, link->irq, 7, &link->dev);
0054     if (!sh) {
0055         dev_err(&link->dev, "Controller initialization failed");
0056         ret = -ENODEV;
0057         goto fail_release;
0058     }
0059 
0060     link->priv = sh;
0061 
0062     return 0;
0063 
0064 fail_release:
0065     release_region(link->resource[0]->start, FDOMAIN_REGION_SIZE);
0066 fail_disable:
0067     pcmcia_disable_device(link);
0068     return ret;
0069 }
0070 
0071 static void fdomain_remove(struct pcmcia_device *link)
0072 {
0073     fdomain_destroy(link->priv);
0074     release_region(link->resource[0]->start, FDOMAIN_REGION_SIZE);
0075     pcmcia_disable_device(link);
0076 }
0077 
0078 static const struct pcmcia_device_id fdomain_ids[] = {
0079     PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88,
0080                 0x859cad20),
0081     PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e),
0082     PCMCIA_DEVICE_PROD_ID12(" SIMPLE TECHNOLOGY Corporation",
0083                 "SCSI PCMCIA Credit Card Controller",
0084                 0x182bdafe, 0xc80d106f),
0085     PCMCIA_DEVICE_NULL,
0086 };
0087 MODULE_DEVICE_TABLE(pcmcia, fdomain_ids);
0088 
0089 static struct pcmcia_driver fdomain_cs_driver = {
0090     .owner      = THIS_MODULE,
0091     .name       = "fdomain_cs",
0092     .probe      = fdomain_probe,
0093     .remove     = fdomain_remove,
0094     .id_table       = fdomain_ids,
0095 };
0096 
0097 module_pcmcia_driver(fdomain_cs_driver);