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/pgtable.h> 32c27d85f3SThomas Bogendoerfer #include <asm/irq.h> 33c27d85f3SThomas Bogendoerfer #include <asm/delay.h> 34c27d85f3SThomas Bogendoerfer 35c27d85f3SThomas Bogendoerfer #include <scsi/scsi_host.h> 36c27d85f3SThomas Bogendoerfer #include <scsi/scsi_device.h> 37c27d85f3SThomas Bogendoerfer #include <scsi/scsi_transport.h> 38c27d85f3SThomas Bogendoerfer #include <scsi/scsi_transport_spi.h> 39c27d85f3SThomas Bogendoerfer 40c27d85f3SThomas Bogendoerfer #include "53c700.h" 41c27d85f3SThomas Bogendoerfer 42d36b6910SAl Viro MODULE_AUTHOR("Thomas Bogendörfer"); 43c27d85f3SThomas Bogendoerfer MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver"); 44c27d85f3SThomas Bogendoerfer MODULE_LICENSE("GPL"); 45ecc1241eSKay Sievers MODULE_ALIAS("platform:snirm_53c710"); 46c27d85f3SThomas Bogendoerfer 47c27d85f3SThomas Bogendoerfer #define SNIRM710_CLOCK 32 48c27d85f3SThomas Bogendoerfer 49c27d85f3SThomas Bogendoerfer static struct scsi_host_template snirm710_template = { 50c27d85f3SThomas Bogendoerfer .name = "SNI RM SCSI 53c710", 51c27d85f3SThomas Bogendoerfer .proc_name = "snirm_53c710", 52c27d85f3SThomas Bogendoerfer .this_id = 7, 53c27d85f3SThomas Bogendoerfer .module = THIS_MODULE, 54c27d85f3SThomas Bogendoerfer }; 55c27d85f3SThomas Bogendoerfer 566f039790SGreg Kroah-Hartman static int snirm710_probe(struct platform_device *dev) 57c27d85f3SThomas Bogendoerfer { 58c27d85f3SThomas Bogendoerfer unsigned long base; 59c27d85f3SThomas Bogendoerfer struct NCR_700_Host_Parameters *hostdata; 60c27d85f3SThomas Bogendoerfer struct Scsi_Host *host; 61c27d85f3SThomas Bogendoerfer struct resource *res; 62c27d85f3SThomas Bogendoerfer 63c27d85f3SThomas Bogendoerfer res = platform_get_resource(dev, IORESOURCE_MEM, 0); 64c27d85f3SThomas Bogendoerfer if (!res) 65c27d85f3SThomas Bogendoerfer return -ENODEV; 66c27d85f3SThomas Bogendoerfer 67c27d85f3SThomas Bogendoerfer base = res->start; 68c27d85f3SThomas Bogendoerfer hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); 69*0ee62114SThomas Bogendoerfer if (!hostdata) 70c27d85f3SThomas Bogendoerfer return -ENOMEM; 71c27d85f3SThomas Bogendoerfer 72c27d85f3SThomas Bogendoerfer hostdata->dev = &dev->dev; 73284901a9SYang Hongyang dma_set_mask(&dev->dev, DMA_BIT_MASK(32)); 742da86589SThomas Bogendoerfer hostdata->base = ioremap_nocache(base, 0x100); 75c27d85f3SThomas Bogendoerfer hostdata->differential = 0; 76c27d85f3SThomas Bogendoerfer 77c27d85f3SThomas Bogendoerfer hostdata->clock = SNIRM710_CLOCK; 78c27d85f3SThomas Bogendoerfer hostdata->force_le_on_be = 1; 79c27d85f3SThomas Bogendoerfer hostdata->chip710 = 1; 80c27d85f3SThomas Bogendoerfer hostdata->burst_length = 4; 81c27d85f3SThomas Bogendoerfer 82c27d85f3SThomas Bogendoerfer host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev); 83c27d85f3SThomas Bogendoerfer if (!host) 84c27d85f3SThomas Bogendoerfer goto out_kfree; 85c27d85f3SThomas Bogendoerfer host->this_id = 7; 86c27d85f3SThomas Bogendoerfer host->base = base; 87c27d85f3SThomas Bogendoerfer host->irq = platform_get_irq(dev, 0); 882833bf68SThomas Gleixner if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) { 89c27d85f3SThomas Bogendoerfer printk(KERN_ERR "snirm710: request_irq failed!\n"); 90c27d85f3SThomas Bogendoerfer goto out_put_host; 91c27d85f3SThomas Bogendoerfer } 92c27d85f3SThomas Bogendoerfer 93c27d85f3SThomas Bogendoerfer dev_set_drvdata(&dev->dev, host); 94c27d85f3SThomas Bogendoerfer scsi_scan_host(host); 95c27d85f3SThomas Bogendoerfer 96c27d85f3SThomas Bogendoerfer return 0; 97c27d85f3SThomas Bogendoerfer 98c27d85f3SThomas Bogendoerfer out_put_host: 99c27d85f3SThomas Bogendoerfer scsi_host_put(host); 100c27d85f3SThomas Bogendoerfer out_kfree: 101c27d85f3SThomas Bogendoerfer iounmap(hostdata->base); 102c27d85f3SThomas Bogendoerfer kfree(hostdata); 103c27d85f3SThomas Bogendoerfer return -ENODEV; 104c27d85f3SThomas Bogendoerfer } 105c27d85f3SThomas Bogendoerfer 106ba21222dSDmitry Torokhov static int snirm710_driver_remove(struct platform_device *dev) 107c27d85f3SThomas Bogendoerfer { 108c27d85f3SThomas Bogendoerfer struct Scsi_Host *host = dev_get_drvdata(&dev->dev); 109c27d85f3SThomas Bogendoerfer struct NCR_700_Host_Parameters *hostdata = 110c27d85f3SThomas Bogendoerfer (struct NCR_700_Host_Parameters *)host->hostdata[0]; 111c27d85f3SThomas Bogendoerfer 112c27d85f3SThomas Bogendoerfer scsi_remove_host(host); 113c27d85f3SThomas Bogendoerfer NCR_700_release(host); 114c27d85f3SThomas Bogendoerfer free_irq(host->irq, host); 115c27d85f3SThomas Bogendoerfer iounmap(hostdata->base); 116c27d85f3SThomas Bogendoerfer kfree(hostdata); 117c27d85f3SThomas Bogendoerfer 118c27d85f3SThomas Bogendoerfer return 0; 119c27d85f3SThomas Bogendoerfer } 120c27d85f3SThomas Bogendoerfer 121c27d85f3SThomas Bogendoerfer static struct platform_driver snirm710_driver = { 122c27d85f3SThomas Bogendoerfer .probe = snirm710_probe, 1236f039790SGreg Kroah-Hartman .remove = snirm710_driver_remove, 124c27d85f3SThomas Bogendoerfer .driver = { 125c27d85f3SThomas Bogendoerfer .name = "snirm_53c710", 126c27d85f3SThomas Bogendoerfer }, 127c27d85f3SThomas Bogendoerfer }; 128c27d85f3SThomas Bogendoerfer 129c27d85f3SThomas Bogendoerfer static int __init snirm710_init(void) 130c27d85f3SThomas Bogendoerfer { 1312da86589SThomas Bogendoerfer return platform_driver_register(&snirm710_driver); 132c27d85f3SThomas Bogendoerfer } 133c27d85f3SThomas Bogendoerfer 134c27d85f3SThomas Bogendoerfer static void __exit snirm710_exit(void) 135c27d85f3SThomas Bogendoerfer { 136c27d85f3SThomas Bogendoerfer platform_driver_unregister(&snirm710_driver); 137c27d85f3SThomas Bogendoerfer } 138c27d85f3SThomas Bogendoerfer 139c27d85f3SThomas Bogendoerfer module_init(snirm710_init); 140c27d85f3SThomas Bogendoerfer module_exit(snirm710_exit); 141