1c27d85f3SThomas Bogendoerfer /* -*- mode: c; c-basic-offset: 8 -*- */ 2c27d85f3SThomas Bogendoerfer 3c27d85f3SThomas Bogendoerfer /* SNI RM driver 4c27d85f3SThomas Bogendoerfer * 5c27d85f3SThomas Bogendoerfer * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com 6c27d85f3SThomas Bogendoerfer **----------------------------------------------------------------------------- 7c27d85f3SThomas Bogendoerfer ** 8c27d85f3SThomas Bogendoerfer ** This program is free software; you can redistribute it and/or modify 9c27d85f3SThomas Bogendoerfer ** it under the terms of the GNU General Public License as published by 10c27d85f3SThomas Bogendoerfer ** the Free Software Foundation; either version 2 of the License, or 11c27d85f3SThomas Bogendoerfer ** (at your option) any later version. 12c27d85f3SThomas Bogendoerfer ** 13c27d85f3SThomas Bogendoerfer ** This program is distributed in the hope that it will be useful, 14c27d85f3SThomas Bogendoerfer ** but WITHOUT ANY WARRANTY; without even the implied warranty of 15c27d85f3SThomas Bogendoerfer ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16c27d85f3SThomas Bogendoerfer ** GNU General Public License for more details. 17c27d85f3SThomas Bogendoerfer ** 18c27d85f3SThomas Bogendoerfer ** You should have received a copy of the GNU General Public License 19c27d85f3SThomas Bogendoerfer ** along with this program; if not, write to the Free Software 20c27d85f3SThomas Bogendoerfer ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21c27d85f3SThomas Bogendoerfer ** 22c27d85f3SThomas Bogendoerfer **----------------------------------------------------------------------------- 23c27d85f3SThomas Bogendoerfer */ 24c27d85f3SThomas Bogendoerfer 25c27d85f3SThomas Bogendoerfer /* 26c27d85f3SThomas Bogendoerfer * Based on lasi700.c 27c27d85f3SThomas Bogendoerfer */ 28c27d85f3SThomas Bogendoerfer 29c27d85f3SThomas Bogendoerfer #include <linux/kernel.h> 30c27d85f3SThomas Bogendoerfer #include <linux/module.h> 31c27d85f3SThomas Bogendoerfer #include <linux/init.h> 32c27d85f3SThomas Bogendoerfer #include <linux/types.h> 33c27d85f3SThomas Bogendoerfer #include <linux/stat.h> 34c27d85f3SThomas Bogendoerfer #include <linux/mm.h> 35c27d85f3SThomas Bogendoerfer #include <linux/blkdev.h> 36c27d85f3SThomas Bogendoerfer #include <linux/sched.h> 37c27d85f3SThomas Bogendoerfer #include <linux/ioport.h> 38c27d85f3SThomas Bogendoerfer #include <linux/dma-mapping.h> 39c27d85f3SThomas Bogendoerfer #include <linux/platform_device.h> 40c27d85f3SThomas Bogendoerfer 41c27d85f3SThomas Bogendoerfer #include <asm/page.h> 42c27d85f3SThomas Bogendoerfer #include <asm/pgtable.h> 43c27d85f3SThomas Bogendoerfer #include <asm/irq.h> 44c27d85f3SThomas Bogendoerfer #include <asm/delay.h> 45c27d85f3SThomas Bogendoerfer 46c27d85f3SThomas Bogendoerfer #include <scsi/scsi_host.h> 47c27d85f3SThomas Bogendoerfer #include <scsi/scsi_device.h> 48c27d85f3SThomas Bogendoerfer #include <scsi/scsi_transport.h> 49c27d85f3SThomas Bogendoerfer #include <scsi/scsi_transport_spi.h> 50c27d85f3SThomas Bogendoerfer 51c27d85f3SThomas Bogendoerfer #include "53c700.h" 52c27d85f3SThomas Bogendoerfer 53c27d85f3SThomas Bogendoerfer MODULE_AUTHOR("Thomas Bogend�rfer"); 54c27d85f3SThomas Bogendoerfer MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver"); 55c27d85f3SThomas Bogendoerfer MODULE_LICENSE("GPL"); 56c27d85f3SThomas Bogendoerfer 57c27d85f3SThomas Bogendoerfer #define SNIRM710_CLOCK 32 58c27d85f3SThomas Bogendoerfer 59c27d85f3SThomas Bogendoerfer static struct scsi_host_template snirm710_template = { 60c27d85f3SThomas Bogendoerfer .name = "SNI RM SCSI 53c710", 61c27d85f3SThomas Bogendoerfer .proc_name = "snirm_53c710", 62c27d85f3SThomas Bogendoerfer .this_id = 7, 63c27d85f3SThomas Bogendoerfer .module = THIS_MODULE, 64c27d85f3SThomas Bogendoerfer }; 65c27d85f3SThomas Bogendoerfer 66c27d85f3SThomas Bogendoerfer static int __init snirm710_probe(struct platform_device *dev) 67c27d85f3SThomas Bogendoerfer { 68c27d85f3SThomas Bogendoerfer unsigned long base; 69c27d85f3SThomas Bogendoerfer struct NCR_700_Host_Parameters *hostdata; 70c27d85f3SThomas Bogendoerfer struct Scsi_Host *host; 71c27d85f3SThomas Bogendoerfer struct resource *res; 72c27d85f3SThomas Bogendoerfer 73c27d85f3SThomas Bogendoerfer res = platform_get_resource(dev, IORESOURCE_MEM, 0); 74c27d85f3SThomas Bogendoerfer if (!res) 75c27d85f3SThomas Bogendoerfer return -ENODEV; 76c27d85f3SThomas Bogendoerfer 77c27d85f3SThomas Bogendoerfer base = res->start; 78c27d85f3SThomas Bogendoerfer hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); 79c27d85f3SThomas Bogendoerfer if (!hostdata) { 80c27d85f3SThomas Bogendoerfer printk(KERN_ERR "%s: Failed to allocate host data\n", 81c27d85f3SThomas Bogendoerfer dev->dev.bus_id); 82c27d85f3SThomas Bogendoerfer return -ENOMEM; 83c27d85f3SThomas Bogendoerfer } 84c27d85f3SThomas Bogendoerfer 85c27d85f3SThomas Bogendoerfer hostdata->dev = &dev->dev; 86c27d85f3SThomas Bogendoerfer dma_set_mask(&dev->dev, DMA_32BIT_MASK); 87*2da86589SThomas Bogendoerfer hostdata->base = ioremap_nocache(base, 0x100); 88c27d85f3SThomas Bogendoerfer hostdata->differential = 0; 89c27d85f3SThomas Bogendoerfer 90c27d85f3SThomas Bogendoerfer hostdata->clock = SNIRM710_CLOCK; 91c27d85f3SThomas Bogendoerfer hostdata->force_le_on_be = 1; 92c27d85f3SThomas Bogendoerfer hostdata->chip710 = 1; 93c27d85f3SThomas Bogendoerfer hostdata->burst_length = 4; 94c27d85f3SThomas Bogendoerfer 95c27d85f3SThomas Bogendoerfer host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev); 96c27d85f3SThomas Bogendoerfer if (!host) 97c27d85f3SThomas Bogendoerfer goto out_kfree; 98c27d85f3SThomas Bogendoerfer host->this_id = 7; 99c27d85f3SThomas Bogendoerfer host->base = base; 100c27d85f3SThomas Bogendoerfer host->irq = platform_get_irq(dev, 0); 1012833bf68SThomas Gleixner if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) { 102c27d85f3SThomas Bogendoerfer printk(KERN_ERR "snirm710: request_irq failed!\n"); 103c27d85f3SThomas Bogendoerfer goto out_put_host; 104c27d85f3SThomas Bogendoerfer } 105c27d85f3SThomas Bogendoerfer 106c27d85f3SThomas Bogendoerfer dev_set_drvdata(&dev->dev, host); 107c27d85f3SThomas Bogendoerfer scsi_scan_host(host); 108c27d85f3SThomas Bogendoerfer 109c27d85f3SThomas Bogendoerfer return 0; 110c27d85f3SThomas Bogendoerfer 111c27d85f3SThomas Bogendoerfer out_put_host: 112c27d85f3SThomas Bogendoerfer scsi_host_put(host); 113c27d85f3SThomas Bogendoerfer out_kfree: 114c27d85f3SThomas Bogendoerfer iounmap(hostdata->base); 115c27d85f3SThomas Bogendoerfer kfree(hostdata); 116c27d85f3SThomas Bogendoerfer return -ENODEV; 117c27d85f3SThomas Bogendoerfer } 118c27d85f3SThomas Bogendoerfer 119c27d85f3SThomas Bogendoerfer static int __exit snirm710_driver_remove(struct platform_device *dev) 120c27d85f3SThomas Bogendoerfer { 121c27d85f3SThomas Bogendoerfer struct Scsi_Host *host = dev_get_drvdata(&dev->dev); 122c27d85f3SThomas Bogendoerfer struct NCR_700_Host_Parameters *hostdata = 123c27d85f3SThomas Bogendoerfer (struct NCR_700_Host_Parameters *)host->hostdata[0]; 124c27d85f3SThomas Bogendoerfer 125c27d85f3SThomas Bogendoerfer scsi_remove_host(host); 126c27d85f3SThomas Bogendoerfer NCR_700_release(host); 127c27d85f3SThomas Bogendoerfer free_irq(host->irq, host); 128c27d85f3SThomas Bogendoerfer iounmap(hostdata->base); 129c27d85f3SThomas Bogendoerfer kfree(hostdata); 130c27d85f3SThomas Bogendoerfer 131c27d85f3SThomas Bogendoerfer return 0; 132c27d85f3SThomas Bogendoerfer } 133c27d85f3SThomas Bogendoerfer 134c27d85f3SThomas Bogendoerfer static struct platform_driver snirm710_driver = { 135c27d85f3SThomas Bogendoerfer .probe = snirm710_probe, 136c27d85f3SThomas Bogendoerfer .remove = __devexit_p(snirm710_driver_remove), 137c27d85f3SThomas Bogendoerfer .driver = { 138c27d85f3SThomas Bogendoerfer .name = "snirm_53c710", 139c27d85f3SThomas Bogendoerfer }, 140c27d85f3SThomas Bogendoerfer }; 141c27d85f3SThomas Bogendoerfer 142c27d85f3SThomas Bogendoerfer static int __init snirm710_init(void) 143c27d85f3SThomas Bogendoerfer { 144*2da86589SThomas Bogendoerfer return platform_driver_register(&snirm710_driver); 145c27d85f3SThomas Bogendoerfer } 146c27d85f3SThomas Bogendoerfer 147c27d85f3SThomas Bogendoerfer static void __exit snirm710_exit(void) 148c27d85f3SThomas Bogendoerfer { 149c27d85f3SThomas Bogendoerfer platform_driver_unregister(&snirm710_driver); 150c27d85f3SThomas Bogendoerfer } 151c27d85f3SThomas Bogendoerfer 152c27d85f3SThomas Bogendoerfer module_init(snirm710_init); 153c27d85f3SThomas Bogendoerfer module_exit(snirm710_exit); 154