174ba9207SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2c27d85f3SThomas Bogendoerfer /* -*- mode: c; c-basic-offset: 8 -*- */ 3c27d85f3SThomas Bogendoerfer 4c27d85f3SThomas Bogendoerfer /* SNI RM driver 5c27d85f3SThomas Bogendoerfer * 6c27d85f3SThomas Bogendoerfer * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com 7c27d85f3SThomas Bogendoerfer **----------------------------------------------------------------------------- 8c27d85f3SThomas Bogendoerfer ** 9c27d85f3SThomas Bogendoerfer ** 10c27d85f3SThomas Bogendoerfer **----------------------------------------------------------------------------- 11c27d85f3SThomas Bogendoerfer */ 12c27d85f3SThomas Bogendoerfer 13c27d85f3SThomas Bogendoerfer /* 14c27d85f3SThomas Bogendoerfer * Based on lasi700.c 15c27d85f3SThomas Bogendoerfer */ 16c27d85f3SThomas Bogendoerfer 17c27d85f3SThomas Bogendoerfer #include <linux/kernel.h> 18c27d85f3SThomas Bogendoerfer #include <linux/module.h> 19c27d85f3SThomas Bogendoerfer #include <linux/init.h> 20c27d85f3SThomas Bogendoerfer #include <linux/types.h> 215a0e3ad6STejun Heo #include <linux/slab.h> 22c27d85f3SThomas Bogendoerfer #include <linux/stat.h> 23c27d85f3SThomas Bogendoerfer #include <linux/mm.h> 24c27d85f3SThomas Bogendoerfer #include <linux/blkdev.h> 25c27d85f3SThomas Bogendoerfer #include <linux/sched.h> 26c27d85f3SThomas Bogendoerfer #include <linux/ioport.h> 27c27d85f3SThomas Bogendoerfer #include <linux/dma-mapping.h> 28c27d85f3SThomas Bogendoerfer #include <linux/platform_device.h> 29c27d85f3SThomas Bogendoerfer 30c27d85f3SThomas Bogendoerfer #include <asm/page.h> 31c27d85f3SThomas Bogendoerfer #include <asm/irq.h> 32c27d85f3SThomas Bogendoerfer #include <asm/delay.h> 33c27d85f3SThomas Bogendoerfer 34c27d85f3SThomas Bogendoerfer #include <scsi/scsi_host.h> 35c27d85f3SThomas Bogendoerfer #include <scsi/scsi_device.h> 36c27d85f3SThomas Bogendoerfer #include <scsi/scsi_transport.h> 37c27d85f3SThomas Bogendoerfer #include <scsi/scsi_transport_spi.h> 38c27d85f3SThomas Bogendoerfer 39c27d85f3SThomas Bogendoerfer #include "53c700.h" 40c27d85f3SThomas Bogendoerfer 41d36b6910SAl Viro MODULE_AUTHOR("Thomas Bogendörfer"); 42c27d85f3SThomas Bogendoerfer MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver"); 43c27d85f3SThomas Bogendoerfer MODULE_LICENSE("GPL"); 44ecc1241eSKay Sievers MODULE_ALIAS("platform:snirm_53c710"); 45c27d85f3SThomas Bogendoerfer 46c27d85f3SThomas Bogendoerfer #define SNIRM710_CLOCK 32 47c27d85f3SThomas Bogendoerfer 48c27d85f3SThomas Bogendoerfer static struct scsi_host_template snirm710_template = { 49c27d85f3SThomas Bogendoerfer .name = "SNI RM SCSI 53c710", 50c27d85f3SThomas Bogendoerfer .proc_name = "snirm_53c710", 51c27d85f3SThomas Bogendoerfer .this_id = 7, 52c27d85f3SThomas Bogendoerfer .module = THIS_MODULE, 53c27d85f3SThomas Bogendoerfer }; 54c27d85f3SThomas Bogendoerfer 556f039790SGreg Kroah-Hartman static int snirm710_probe(struct platform_device *dev) 56c27d85f3SThomas Bogendoerfer { 57c27d85f3SThomas Bogendoerfer unsigned long base; 58c27d85f3SThomas Bogendoerfer struct NCR_700_Host_Parameters *hostdata; 59c27d85f3SThomas Bogendoerfer struct Scsi_Host *host; 60c27d85f3SThomas Bogendoerfer struct resource *res; 61c27d85f3SThomas Bogendoerfer 62c27d85f3SThomas Bogendoerfer res = platform_get_resource(dev, IORESOURCE_MEM, 0); 63c27d85f3SThomas Bogendoerfer if (!res) 64c27d85f3SThomas Bogendoerfer return -ENODEV; 65c27d85f3SThomas Bogendoerfer 66c27d85f3SThomas Bogendoerfer base = res->start; 67c27d85f3SThomas Bogendoerfer hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); 680ee62114SThomas Bogendoerfer if (!hostdata) 69c27d85f3SThomas Bogendoerfer return -ENOMEM; 70c27d85f3SThomas Bogendoerfer 71c27d85f3SThomas Bogendoerfer hostdata->dev = &dev->dev; 72284901a9SYang Hongyang dma_set_mask(&dev->dev, DMA_BIT_MASK(32)); 734bdc0d67SChristoph Hellwig hostdata->base = ioremap(base, 0x100); 74c27d85f3SThomas Bogendoerfer hostdata->differential = 0; 75c27d85f3SThomas Bogendoerfer 76c27d85f3SThomas Bogendoerfer hostdata->clock = SNIRM710_CLOCK; 77c27d85f3SThomas Bogendoerfer hostdata->force_le_on_be = 1; 78c27d85f3SThomas Bogendoerfer hostdata->chip710 = 1; 79c27d85f3SThomas Bogendoerfer hostdata->burst_length = 4; 80c27d85f3SThomas Bogendoerfer 81c27d85f3SThomas Bogendoerfer host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev); 82c27d85f3SThomas Bogendoerfer if (!host) 83c27d85f3SThomas Bogendoerfer goto out_kfree; 84c27d85f3SThomas Bogendoerfer host->this_id = 7; 85c27d85f3SThomas Bogendoerfer host->base = base; 86c27d85f3SThomas Bogendoerfer host->irq = platform_get_irq(dev, 0); 872833bf68SThomas Gleixner if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) { 88c27d85f3SThomas Bogendoerfer printk(KERN_ERR "snirm710: request_irq failed!\n"); 89c27d85f3SThomas Bogendoerfer goto out_put_host; 90c27d85f3SThomas Bogendoerfer } 91c27d85f3SThomas Bogendoerfer 92c27d85f3SThomas Bogendoerfer dev_set_drvdata(&dev->dev, host); 93c27d85f3SThomas Bogendoerfer scsi_scan_host(host); 94c27d85f3SThomas Bogendoerfer 95c27d85f3SThomas Bogendoerfer return 0; 96c27d85f3SThomas Bogendoerfer 97c27d85f3SThomas Bogendoerfer out_put_host: 98c27d85f3SThomas Bogendoerfer scsi_host_put(host); 99c27d85f3SThomas Bogendoerfer out_kfree: 100c27d85f3SThomas Bogendoerfer iounmap(hostdata->base); 101c27d85f3SThomas Bogendoerfer kfree(hostdata); 102c27d85f3SThomas Bogendoerfer return -ENODEV; 103c27d85f3SThomas Bogendoerfer } 104c27d85f3SThomas Bogendoerfer 105ba21222dSDmitry Torokhov static int snirm710_driver_remove(struct platform_device *dev) 106c27d85f3SThomas Bogendoerfer { 107c27d85f3SThomas Bogendoerfer struct Scsi_Host *host = dev_get_drvdata(&dev->dev); 108c27d85f3SThomas Bogendoerfer struct NCR_700_Host_Parameters *hostdata = 109c27d85f3SThomas Bogendoerfer (struct NCR_700_Host_Parameters *)host->hostdata[0]; 110c27d85f3SThomas Bogendoerfer 111c27d85f3SThomas Bogendoerfer scsi_remove_host(host); 112c27d85f3SThomas Bogendoerfer NCR_700_release(host); 113c27d85f3SThomas Bogendoerfer free_irq(host->irq, host); 114c27d85f3SThomas Bogendoerfer iounmap(hostdata->base); 115c27d85f3SThomas Bogendoerfer kfree(hostdata); 116c27d85f3SThomas Bogendoerfer 117c27d85f3SThomas Bogendoerfer return 0; 118c27d85f3SThomas Bogendoerfer } 119c27d85f3SThomas Bogendoerfer 120c27d85f3SThomas Bogendoerfer static struct platform_driver snirm710_driver = { 121c27d85f3SThomas Bogendoerfer .probe = snirm710_probe, 1226f039790SGreg Kroah-Hartman .remove = snirm710_driver_remove, 123c27d85f3SThomas Bogendoerfer .driver = { 124c27d85f3SThomas Bogendoerfer .name = "snirm_53c710", 125c27d85f3SThomas Bogendoerfer }, 126c27d85f3SThomas Bogendoerfer }; 127*a3b73c96SLiu Shixin module_platform_driver(snirm710_driver); 128