18674a8aaSOndrej Zary // SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
28674a8aaSOndrej Zary /*
38674a8aaSOndrej Zary * Driver for Future Domain-compatible PCMCIA SCSI cards
48674a8aaSOndrej Zary * Copyright 2019 Ondrej Zary
58674a8aaSOndrej Zary *
68674a8aaSOndrej Zary * The initial developer of the original code is David A. Hinds
78674a8aaSOndrej Zary * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
88674a8aaSOndrej Zary * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
98674a8aaSOndrej Zary */
108674a8aaSOndrej Zary
118674a8aaSOndrej Zary #include <linux/module.h>
128674a8aaSOndrej Zary #include <linux/init.h>
138674a8aaSOndrej Zary #include <scsi/scsi_host.h>
148674a8aaSOndrej Zary #include <pcmcia/cistpl.h>
158674a8aaSOndrej Zary #include <pcmcia/ds.h>
168674a8aaSOndrej Zary #include "fdomain.h"
178674a8aaSOndrej Zary
188674a8aaSOndrej Zary MODULE_AUTHOR("Ondrej Zary, David Hinds");
198674a8aaSOndrej Zary MODULE_DESCRIPTION("Future Domain PCMCIA SCSI driver");
208674a8aaSOndrej Zary MODULE_LICENSE("Dual MPL/GPL");
218674a8aaSOndrej Zary
fdomain_config_check(struct pcmcia_device * p_dev,void * priv_data)228674a8aaSOndrej Zary static int fdomain_config_check(struct pcmcia_device *p_dev, void *priv_data)
238674a8aaSOndrej Zary {
248674a8aaSOndrej Zary p_dev->io_lines = 10;
258674a8aaSOndrej Zary p_dev->resource[0]->end = FDOMAIN_REGION_SIZE;
268674a8aaSOndrej Zary p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
278674a8aaSOndrej Zary p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
288674a8aaSOndrej Zary return pcmcia_request_io(p_dev);
298674a8aaSOndrej Zary }
308674a8aaSOndrej Zary
fdomain_probe(struct pcmcia_device * link)318674a8aaSOndrej Zary static int fdomain_probe(struct pcmcia_device *link)
328674a8aaSOndrej Zary {
338674a8aaSOndrej Zary int ret;
348674a8aaSOndrej Zary struct Scsi_Host *sh;
358674a8aaSOndrej Zary
368674a8aaSOndrej Zary link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
378674a8aaSOndrej Zary link->config_regs = PRESENT_OPTION;
388674a8aaSOndrej Zary
398674a8aaSOndrej Zary ret = pcmcia_loop_config(link, fdomain_config_check, NULL);
408674a8aaSOndrej Zary if (ret)
418674a8aaSOndrej Zary return ret;
428674a8aaSOndrej Zary
438674a8aaSOndrej Zary ret = pcmcia_enable_device(link);
448674a8aaSOndrej Zary if (ret)
458674a8aaSOndrej Zary goto fail_disable;
468674a8aaSOndrej Zary
478674a8aaSOndrej Zary if (!request_region(link->resource[0]->start, FDOMAIN_REGION_SIZE,
48*632c4ae6SWei Li "fdomain_cs")) {
49*632c4ae6SWei Li ret = -EBUSY;
508674a8aaSOndrej Zary goto fail_disable;
51*632c4ae6SWei Li }
528674a8aaSOndrej Zary
538674a8aaSOndrej Zary sh = fdomain_create(link->resource[0]->start, link->irq, 7, &link->dev);
548674a8aaSOndrej Zary if (!sh) {
558674a8aaSOndrej Zary dev_err(&link->dev, "Controller initialization failed");
568674a8aaSOndrej Zary ret = -ENODEV;
578674a8aaSOndrej Zary goto fail_release;
588674a8aaSOndrej Zary }
598674a8aaSOndrej Zary
608674a8aaSOndrej Zary link->priv = sh;
618674a8aaSOndrej Zary
628674a8aaSOndrej Zary return 0;
638674a8aaSOndrej Zary
648674a8aaSOndrej Zary fail_release:
658674a8aaSOndrej Zary release_region(link->resource[0]->start, FDOMAIN_REGION_SIZE);
668674a8aaSOndrej Zary fail_disable:
678674a8aaSOndrej Zary pcmcia_disable_device(link);
688674a8aaSOndrej Zary return ret;
698674a8aaSOndrej Zary }
708674a8aaSOndrej Zary
fdomain_remove(struct pcmcia_device * link)718674a8aaSOndrej Zary static void fdomain_remove(struct pcmcia_device *link)
728674a8aaSOndrej Zary {
738674a8aaSOndrej Zary fdomain_destroy(link->priv);
748674a8aaSOndrej Zary release_region(link->resource[0]->start, FDOMAIN_REGION_SIZE);
758674a8aaSOndrej Zary pcmcia_disable_device(link);
768674a8aaSOndrej Zary }
778674a8aaSOndrej Zary
788674a8aaSOndrej Zary static const struct pcmcia_device_id fdomain_ids[] = {
798674a8aaSOndrej Zary PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88,
808674a8aaSOndrej Zary 0x859cad20),
818674a8aaSOndrej Zary PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e),
828674a8aaSOndrej Zary PCMCIA_DEVICE_PROD_ID12(" SIMPLE TECHNOLOGY Corporation",
838674a8aaSOndrej Zary "SCSI PCMCIA Credit Card Controller",
848674a8aaSOndrej Zary 0x182bdafe, 0xc80d106f),
858674a8aaSOndrej Zary PCMCIA_DEVICE_NULL,
868674a8aaSOndrej Zary };
878674a8aaSOndrej Zary MODULE_DEVICE_TABLE(pcmcia, fdomain_ids);
888674a8aaSOndrej Zary
898674a8aaSOndrej Zary static struct pcmcia_driver fdomain_cs_driver = {
908674a8aaSOndrej Zary .owner = THIS_MODULE,
918674a8aaSOndrej Zary .name = "fdomain_cs",
928674a8aaSOndrej Zary .probe = fdomain_probe,
938674a8aaSOndrej Zary .remove = fdomain_remove,
948674a8aaSOndrej Zary .id_table = fdomain_ids,
958674a8aaSOndrej Zary };
968674a8aaSOndrej Zary
978674a8aaSOndrej Zary module_pcmcia_driver(fdomain_cs_driver);
98