Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
[libata] Add support for the RB500 PATA CompactFlash
ahci: logical-bitwise and confusion in ahci_save_initial_config()
libata: don't allow sysfs read access to force param
ahci: add the Device IDs for nvidia MCP7B AHCI
libata-sff: handle controllers w/o ctl register
libata: allow LLDs w/o any reset method
ata: replace remaining __FUNCTION__ occurrences

+383 -28
+9
drivers/ata/Kconfig
··· 538 539 If unsure, say N. 540 541 config PATA_RZ1000 542 tristate "PC Tech RZ1000 PATA support" 543 depends on PCI
··· 538 539 If unsure, say N. 540 541 + config PATA_RB500 542 + tristate "RouterBoard 500 PATA CompactFlash support" 543 + depends on MIKROTIK_RB500 544 + help 545 + This option enables support for the RouterBoard 500 546 + PATA CompactFlash controller. 547 + 548 + If unsure, say N. 549 + 550 config PATA_RZ1000 551 tristate "PC Tech RZ1000 PATA support" 552 depends on PCI
+1
drivers/ata/Makefile
··· 55 obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o 56 obj-$(CONFIG_PATA_QDI) += pata_qdi.o 57 obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o 58 obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o 59 obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o 60 obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o
··· 55 obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o 56 obj-$(CONFIG_PATA_QDI) += pata_qdi.o 57 obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o 58 + obj-$(CONFIG_PATA_RB500) += pata_rb500_cf.o 59 obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o 60 obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o 61 obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o
+13 -1
drivers/ata/ahci.c
··· 567 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ 568 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ 569 { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ 570 571 /* SiS */ 572 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ ··· 684 cap &= ~HOST_CAP_NCQ; 685 } 686 687 - if ((cap && HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { 688 dev_printk(KERN_INFO, &pdev->dev, 689 "controller can't do PMP, turning off CAP_PMP\n"); 690 cap &= ~HOST_CAP_PMP;
··· 567 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ 568 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ 569 { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ 570 + { PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */ 571 + { PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */ 572 + { PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */ 573 + { PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */ 574 + { PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */ 575 + { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */ 576 + { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */ 577 + { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */ 578 + { PCI_VDEVICE(NVIDIA, 0x0bd0), board_ahci }, /* MCP7B */ 579 + { PCI_VDEVICE(NVIDIA, 0x0bd1), board_ahci }, /* MCP7B */ 580 + { PCI_VDEVICE(NVIDIA, 0x0bd2), board_ahci }, /* MCP7B */ 581 + { PCI_VDEVICE(NVIDIA, 0x0bd3), board_ahci }, /* MCP7B */ 582 583 /* SiS */ 584 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ ··· 672 cap &= ~HOST_CAP_NCQ; 673 } 674 675 + if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { 676 dev_printk(KERN_INFO, &pdev->dev, 677 "controller can't do PMP, turning off CAP_PMP\n"); 678 cap &= ~HOST_CAP_PMP;
+4 -4
drivers/ata/libata-acpi.c
··· 382 383 if (ata_msg_probe(ap)) 384 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 385 - __FUNCTION__, ap->port_no); 386 387 /* _GTF has no input parameters */ 388 status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); ··· 402 if (ata_msg_probe(ap)) 403 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " 404 "length or ptr is NULL (0x%llx, 0x%p)\n", 405 - __FUNCTION__, 406 (unsigned long long)output.length, 407 output.pointer); 408 rc = -EINVAL; ··· 432 if (ata_msg_probe(ap)) 433 ata_dev_printk(dev, KERN_DEBUG, 434 "%s: returning gtf=%p, gtf_count=%d\n", 435 - __FUNCTION__, *gtf, rc); 436 } 437 return rc; 438 ··· 725 726 if (ata_msg_probe(ap)) 727 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", 728 - __FUNCTION__, dev->devno, ap->port_no); 729 730 /* Give the drive Identify data to the drive via the _SDD method */ 731 /* _SDD: set up input parameters */
··· 382 383 if (ata_msg_probe(ap)) 384 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 385 + __func__, ap->port_no); 386 387 /* _GTF has no input parameters */ 388 status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); ··· 402 if (ata_msg_probe(ap)) 403 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " 404 "length or ptr is NULL (0x%llx, 0x%p)\n", 405 + __func__, 406 (unsigned long long)output.length, 407 output.pointer); 408 rc = -EINVAL; ··· 432 if (ata_msg_probe(ap)) 433 ata_dev_printk(dev, KERN_DEBUG, 434 "%s: returning gtf=%p, gtf_count=%d\n", 435 + __func__, *gtf, rc); 436 } 437 return rc; 438 ··· 725 726 if (ata_msg_probe(ap)) 727 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", 728 + __func__, dev->devno, ap->port_no); 729 730 /* Give the drive Identify data to the drive via the _SDD method */ 731 /* _SDD: set up input parameters */
+9 -8
drivers/ata/libata-core.c
··· 106 static int ata_force_tbl_size; 107 108 static char ata_force_param_buf[PAGE_SIZE] __initdata; 109 - module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0444); 110 MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); 111 112 int atapi_enabled = 1; ··· 1720 cancel_rearming_delayed_work(&ap->port_task); 1721 1722 if (ata_msg_ctl(ap)) 1723 - ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __FUNCTION__); 1724 } 1725 1726 static void ata_qc_complete_internal(struct ata_queued_cmd *qc) ··· 2057 int rc; 2058 2059 if (ata_msg_ctl(ap)) 2060 - ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 2061 2062 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ 2063 retry: ··· 2254 2255 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 2256 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", 2257 - __FUNCTION__); 2258 return 0; 2259 } 2260 2261 if (ata_msg_probe(ap)) 2262 - ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 2263 2264 /* set horkage */ 2265 dev->horkage |= ata_dev_blacklisted(dev); ··· 2280 ata_dev_printk(dev, KERN_DEBUG, 2281 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " 2282 "85:%04x 86:%04x 87:%04x 88:%04x\n", 2283 - __FUNCTION__, 2284 id[49], id[82], id[83], id[84], 2285 id[85], id[86], id[87], id[88]); 2286 ··· 2512 2513 if (ata_msg_probe(ap)) 2514 ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n", 2515 - __FUNCTION__, ata_chk_status(ap)); 2516 return 0; 2517 2518 err_out_nosup: 2519 if (ata_msg_probe(ap)) 2520 ata_dev_printk(dev, KERN_DEBUG, 2521 - "%s: EXIT, err\n", __FUNCTION__); 2522 return rc; 2523 } 2524
··· 106 static int ata_force_tbl_size; 107 108 static char ata_force_param_buf[PAGE_SIZE] __initdata; 109 + /* param_buf is thrown away after initialization, disallow read */ 110 + module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0); 111 MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); 112 113 int atapi_enabled = 1; ··· 1719 cancel_rearming_delayed_work(&ap->port_task); 1720 1721 if (ata_msg_ctl(ap)) 1722 + ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __func__); 1723 } 1724 1725 static void ata_qc_complete_internal(struct ata_queued_cmd *qc) ··· 2056 int rc; 2057 2058 if (ata_msg_ctl(ap)) 2059 + ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 2060 2061 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ 2062 retry: ··· 2253 2254 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 2255 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", 2256 + __func__); 2257 return 0; 2258 } 2259 2260 if (ata_msg_probe(ap)) 2261 + ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 2262 2263 /* set horkage */ 2264 dev->horkage |= ata_dev_blacklisted(dev); ··· 2279 ata_dev_printk(dev, KERN_DEBUG, 2280 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " 2281 "85:%04x 86:%04x 87:%04x 88:%04x\n", 2282 + __func__, 2283 id[49], id[82], id[83], id[84], 2284 id[85], id[86], id[87], id[88]); 2285 ··· 2511 2512 if (ata_msg_probe(ap)) 2513 ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n", 2514 + __func__, ata_chk_status(ap)); 2515 return 0; 2516 2517 err_out_nosup: 2518 if (ata_msg_probe(ap)) 2519 ata_dev_printk(dev, KERN_DEBUG, 2520 + "%s: EXIT, err\n", __func__); 2521 return rc; 2522 } 2523
+10
drivers/ata/libata-eh.c
··· 2150 ap->ops->set_piomode(ap, dev); 2151 } 2152 2153 /* Determine which reset to use and record in ehc->i.action. 2154 * prereset() may examine and modify it. 2155 */ ··· 2263 lflags |= ATA_LFLAG_ASSUME_ATA; 2264 } 2265 2266 ata_link_for_each_dev(dev, link) { 2267 /* After the reset, the device state is PIO 0 and the 2268 * controller state is undefined. Reset also wakes up
··· 2150 ap->ops->set_piomode(ap, dev); 2151 } 2152 2153 + if (!softreset && !hardreset) { 2154 + if (verbose) 2155 + ata_link_printk(link, KERN_INFO, "no reset method " 2156 + "available, skipping reset\n"); 2157 + if (!(lflags & ATA_LFLAG_ASSUME_CLASS)) 2158 + lflags |= ATA_LFLAG_ASSUME_ATA; 2159 + goto done; 2160 + } 2161 + 2162 /* Determine which reset to use and record in ehc->i.action. 2163 * prereset() may examine and modify it. 2164 */ ··· 2254 lflags |= ATA_LFLAG_ASSUME_ATA; 2255 } 2256 2257 + done: 2258 ata_link_for_each_dev(dev, link) { 2259 /* After the reset, the device state is PIO 0 and the 2260 * controller state is undefined. Reset also wakes up
+22 -14
drivers/ata/libata-sff.c
··· 56 ap->ctl &= ~ATA_NIEN; 57 ap->last_ctl = ap->ctl; 58 59 - iowrite8(ap->ctl, ioaddr->ctl_addr); 60 tmp = ata_wait_idle(ap); 61 62 ap->ops->irq_clear(ap); ··· 82 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 83 84 if (tf->ctl != ap->last_ctl) { 85 - iowrite8(tf->ctl, ioaddr->ctl_addr); 86 ap->last_ctl = tf->ctl; 87 ata_wait_idle(ap); 88 } 89 90 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 91 iowrite8(tf->hob_feature, ioaddr->feature_addr); 92 iowrite8(tf->hob_nsect, ioaddr->nsect_addr); 93 iowrite8(tf->hob_lbal, ioaddr->lbal_addr); ··· 170 tf->device = ioread8(ioaddr->device_addr); 171 172 if (tf->flags & ATA_TFLAG_LBA48) { 173 - iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr); 174 - tf->hob_feature = ioread8(ioaddr->error_addr); 175 - tf->hob_nsect = ioread8(ioaddr->nsect_addr); 176 - tf->hob_lbal = ioread8(ioaddr->lbal_addr); 177 - tf->hob_lbam = ioread8(ioaddr->lbam_addr); 178 - tf->hob_lbah = ioread8(ioaddr->lbah_addr); 179 - iowrite8(tf->ctl, ioaddr->ctl_addr); 180 - ap->last_ctl = tf->ctl; 181 } 182 } 183 ··· 358 ap->ctl |= ATA_NIEN; 359 ap->last_ctl = ap->ctl; 360 361 - iowrite8(ap->ctl, ioaddr->ctl_addr); 362 363 /* Under certain circumstances, some controllers raise IRQ on 364 * ATA_NIEN manipulation. Also, many controllers fail to mask ··· 466 */ 467 void ata_bmdma_error_handler(struct ata_port *ap) 468 { 469 - ata_reset_fn_t hardreset; 470 471 - hardreset = NULL; 472 if (sata_scr_valid(&ap->link)) 473 hardreset = sata_std_hardreset; 474 475 - ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, hardreset, 476 ata_std_postreset); 477 } 478
··· 56 ap->ctl &= ~ATA_NIEN; 57 ap->last_ctl = ap->ctl; 58 59 + if (ioaddr->ctl_addr) 60 + iowrite8(ap->ctl, ioaddr->ctl_addr); 61 tmp = ata_wait_idle(ap); 62 63 ap->ops->irq_clear(ap); ··· 81 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 82 83 if (tf->ctl != ap->last_ctl) { 84 + if (ioaddr->ctl_addr) 85 + iowrite8(tf->ctl, ioaddr->ctl_addr); 86 ap->last_ctl = tf->ctl; 87 ata_wait_idle(ap); 88 } 89 90 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 91 + WARN_ON(!ioaddr->ctl_addr); 92 iowrite8(tf->hob_feature, ioaddr->feature_addr); 93 iowrite8(tf->hob_nsect, ioaddr->nsect_addr); 94 iowrite8(tf->hob_lbal, ioaddr->lbal_addr); ··· 167 tf->device = ioread8(ioaddr->device_addr); 168 169 if (tf->flags & ATA_TFLAG_LBA48) { 170 + if (likely(ioaddr->ctl_addr)) { 171 + iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr); 172 + tf->hob_feature = ioread8(ioaddr->error_addr); 173 + tf->hob_nsect = ioread8(ioaddr->nsect_addr); 174 + tf->hob_lbal = ioread8(ioaddr->lbal_addr); 175 + tf->hob_lbam = ioread8(ioaddr->lbam_addr); 176 + tf->hob_lbah = ioread8(ioaddr->lbah_addr); 177 + iowrite8(tf->ctl, ioaddr->ctl_addr); 178 + ap->last_ctl = tf->ctl; 179 + } else 180 + WARN_ON(1); 181 } 182 } 183 ··· 352 ap->ctl |= ATA_NIEN; 353 ap->last_ctl = ap->ctl; 354 355 + if (ioaddr->ctl_addr) 356 + iowrite8(ap->ctl, ioaddr->ctl_addr); 357 358 /* Under certain circumstances, some controllers raise IRQ on 359 * ATA_NIEN manipulation. Also, many controllers fail to mask ··· 459 */ 460 void ata_bmdma_error_handler(struct ata_port *ap) 461 { 462 + ata_reset_fn_t softreset = NULL, hardreset = NULL; 463 464 + if (ap->ioaddr.ctl_addr) 465 + softreset = ata_std_softreset; 466 if (sata_scr_valid(&ap->link)) 467 hardreset = sata_std_hardreset; 468 469 + ata_bmdma_drive_eh(ap, ata_std_prereset, softreset, hardreset, 470 ata_std_postreset); 471 } 472
+1 -1
drivers/ata/pata_pdc2027x.c
··· 39 #undef PDC_DEBUG 40 41 #ifdef PDC_DEBUG 42 - #define PDPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 43 #else 44 #define PDPRINTK(fmt, args...) 45 #endif
··· 39 #undef PDC_DEBUG 40 41 #ifdef PDC_DEBUG 42 + #define PDPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) 43 #else 44 #define PDPRINTK(fmt, args...) 45 #endif
+314
drivers/ata/pata_rb500_cf.c
···
··· 1 + /* 2 + * A low-level PATA driver to handle a Compact Flash connected on the 3 + * Mikrotik's RouterBoard 532 board. 4 + * 5 + * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org> 6 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> 7 + * 8 + * This file was based on: drivers/ata/pata_ixp4xx_cf.c 9 + * Copyright (C) 2006-07 Tower Technologies 10 + * Author: Alessandro Zummo <a.zummo@towertech.it> 11 + * 12 + * Also was based on the driver for Linux 2.4.xx published by Mikrotik for 13 + * their RouterBoard 1xx and 5xx series devices. The original Mikrotik code 14 + * seems not to have a license. 15 + * 16 + * This program is free software; you can redistribute it and/or modify 17 + * it under the terms of the GNU General Public License version 2 as 18 + * published by the Free Software Foundation. 19 + * 20 + */ 21 + 22 + #include <linux/kernel.h> 23 + #include <linux/module.h> 24 + #include <linux/platform_device.h> 25 + 26 + #include <linux/io.h> 27 + #include <linux/interrupt.h> 28 + #include <linux/irq.h> 29 + 30 + #include <linux/libata.h> 31 + #include <scsi/scsi_host.h> 32 + 33 + #include <asm/gpio.h> 34 + 35 + #define DRV_NAME "pata-rb500-cf" 36 + #define DRV_VERSION "0.1.0" 37 + #define DRV_DESC "PATA driver for RouterBOARD 532 Compact Flash" 38 + 39 + #define RB500_CF_MAXPORTS 1 40 + #define RB500_CF_IO_DELAY 400 41 + 42 + #define RB500_CF_REG_CMD 0x0800 43 + #define RB500_CF_REG_CTRL 0x080E 44 + #define RB500_CF_REG_DATA 0x0C00 45 + 46 + struct rb500_cf_info { 47 + void __iomem *iobase; 48 + unsigned int gpio_line; 49 + int frozen; 50 + unsigned int irq; 51 + }; 52 + 53 + /* ------------------------------------------------------------------------ */ 54 + 55 + static inline void rb500_pata_finish_io(struct ata_port *ap) 56 + { 57 + struct ata_host *ah = ap->host; 58 + struct rb500_cf_info *info = ah->private_data; 59 + 60 + ata_altstatus(ap); 61 + ndelay(RB500_CF_IO_DELAY); 62 + 63 + set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH); 64 + } 65 + 66 + static void rb500_pata_exec_command(struct ata_port *ap, 67 + const struct ata_taskfile *tf) 68 + { 69 + writeb(tf->command, ap->ioaddr.command_addr); 70 + rb500_pata_finish_io(ap); 71 + } 72 + 73 + static void rb500_pata_data_xfer(struct ata_device *adev, unsigned char *buf, 74 + unsigned int buflen, int write_data) 75 + { 76 + struct ata_port *ap = adev->link->ap; 77 + void __iomem *ioaddr = ap->ioaddr.data_addr; 78 + 79 + if (write_data) { 80 + for (; buflen > 0; buflen--, buf++) 81 + writeb(*buf, ioaddr); 82 + } else { 83 + for (; buflen > 0; buflen--, buf++) 84 + *buf = readb(ioaddr); 85 + } 86 + 87 + rb500_pata_finish_io(adev->link->ap); 88 + } 89 + 90 + static void rb500_pata_freeze(struct ata_port *ap) 91 + { 92 + struct rb500_cf_info *info = ap->host->private_data; 93 + 94 + info->frozen = 1; 95 + } 96 + 97 + static void rb500_pata_thaw(struct ata_port *ap) 98 + { 99 + struct rb500_cf_info *info = ap->host->private_data; 100 + 101 + info->frozen = 0; 102 + } 103 + 104 + static irqreturn_t rb500_pata_irq_handler(int irq, void *dev_instance) 105 + { 106 + struct ata_host *ah = dev_instance; 107 + struct rb500_cf_info *info = ah->private_data; 108 + 109 + if (gpio_get_value(info->gpio_line)) { 110 + set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW); 111 + if (!info->frozen) 112 + ata_interrupt(info->irq, dev_instance); 113 + } else { 114 + set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH); 115 + } 116 + 117 + return IRQ_HANDLED; 118 + } 119 + 120 + static void rb500_pata_irq_clear(struct ata_port *ap) 121 + { 122 + } 123 + 124 + static int rb500_pata_port_start(struct ata_port *ap) 125 + { 126 + return 0; 127 + } 128 + 129 + static struct ata_port_operations rb500_pata_port_ops = { 130 + .tf_load = ata_tf_load, 131 + .tf_read = ata_tf_read, 132 + 133 + .exec_command = rb500_pata_exec_command, 134 + .check_status = ata_check_status, 135 + .dev_select = ata_std_dev_select, 136 + 137 + .data_xfer = rb500_pata_data_xfer, 138 + 139 + .qc_prep = ata_qc_prep, 140 + .qc_issue = ata_qc_issue_prot, 141 + 142 + .freeze = rb500_pata_freeze, 143 + .thaw = rb500_pata_thaw, 144 + .error_handler = ata_bmdma_error_handler, 145 + 146 + .irq_handler = rb500_pata_irq_handler, 147 + .irq_clear = rb500_pata_irq_clear, 148 + .irq_on = ata_irq_on, 149 + 150 + .port_start = rb500_pata_port_start, 151 + }; 152 + 153 + /* ------------------------------------------------------------------------ */ 154 + 155 + static struct scsi_host_template rb500_pata_sht = { 156 + .module = THIS_MODULE, 157 + .name = DRV_NAME, 158 + .ioctl = ata_scsi_ioctl, 159 + .queuecommand = ata_scsi_queuecmd, 160 + .slave_configure = ata_scsi_slave_config, 161 + .slave_destroy = ata_scsi_slave_destroy, 162 + .bios_param = ata_std_bios_param, 163 + .proc_name = DRV_NAME, 164 + 165 + .can_queue = ATA_DEF_QUEUE, 166 + .this_id = ATA_SHT_THIS_ID, 167 + .sg_tablesize = LIBATA_MAX_PRD, 168 + .dma_boundary = ATA_DMA_BOUNDARY, 169 + .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 170 + .emulated = ATA_SHT_EMULATED, 171 + .use_clustering = ATA_SHT_USE_CLUSTERING, 172 + }; 173 + 174 + /* ------------------------------------------------------------------------ */ 175 + 176 + static void rb500_pata_setup_ports(struct ata_host *ah) 177 + { 178 + struct rb500_cf_info *info = ah->private_data; 179 + struct ata_port *ap; 180 + 181 + ap = ah->ports[0]; 182 + 183 + ap->ops = &rb500_pata_port_ops; 184 + ap->pio_mask = 0x1f; /* PIO4 */ 185 + ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO; 186 + 187 + ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_CMD; 188 + ap->ioaddr.ctl_addr = info->iobase + RB500_CF_REG_CTRL; 189 + ap->ioaddr.altstatus_addr = info->iobase + RB500_CF_REG_CTRL; 190 + 191 + ata_std_ports(&ap->ioaddr); 192 + 193 + ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DATA; 194 + } 195 + 196 + static __devinit int rb500_pata_driver_probe(struct platform_device *pdev) 197 + { 198 + unsigned int irq; 199 + int gpio; 200 + struct resource *res; 201 + struct ata_host *ah; 202 + struct rb500_cf_info *info; 203 + int ret; 204 + 205 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 206 + if (!res) { 207 + dev_err(&pdev->dev, "no IOMEM resource found\n"); 208 + return -EINVAL; 209 + } 210 + 211 + irq = platform_get_irq(pdev, 0); 212 + if (irq <= 0) { 213 + dev_err(&pdev->dev, "no IRQ resource found\n"); 214 + return -ENOENT; 215 + } 216 + 217 + gpio = irq_to_gpio(irq); 218 + if (gpio < 0) { 219 + dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq); 220 + return -ENOENT; 221 + } 222 + 223 + ret = gpio_request(gpio, DRV_NAME); 224 + if (ret) { 225 + dev_err(&pdev->dev, "GPIO request failed\n"); 226 + return ret; 227 + } 228 + 229 + /* allocate host */ 230 + ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS); 231 + if (!ah) 232 + return -ENOMEM; 233 + 234 + platform_set_drvdata(pdev, ah); 235 + 236 + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 237 + if (!info) 238 + return -ENOMEM; 239 + 240 + ah->private_data = info; 241 + info->gpio_line = gpio; 242 + info->irq = irq; 243 + 244 + info->iobase = devm_ioremap_nocache(&pdev->dev, res->start, 245 + res->end - res->start + 1); 246 + if (!info->iobase) 247 + return -ENOMEM; 248 + 249 + ret = gpio_direction_input(gpio); 250 + if (ret) { 251 + dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n", 252 + ret); 253 + goto err_free_gpio; 254 + } 255 + 256 + rb500_pata_setup_ports(ah); 257 + 258 + ret = ata_host_activate(ah, irq, rb500_pata_irq_handler, 259 + IRQF_TRIGGER_LOW, &rb500_pata_sht); 260 + if (ret) 261 + goto err_free_gpio; 262 + 263 + return 0; 264 + 265 + err_free_gpio: 266 + gpio_free(gpio); 267 + 268 + return ret; 269 + } 270 + 271 + static __devexit int rb500_pata_driver_remove(struct platform_device *pdev) 272 + { 273 + struct ata_host *ah = platform_get_drvdata(pdev); 274 + struct rb500_cf_info *info = ah->private_data; 275 + 276 + ata_host_detach(ah); 277 + gpio_free(info->gpio_line); 278 + 279 + return 0; 280 + } 281 + 282 + static struct platform_driver rb500_pata_platform_driver = { 283 + .probe = rb500_pata_driver_probe, 284 + .remove = __devexit_p(rb500_pata_driver_remove), 285 + .driver = { 286 + .name = DRV_NAME, 287 + .owner = THIS_MODULE, 288 + }, 289 + }; 290 + 291 + /* ------------------------------------------------------------------------ */ 292 + 293 + #define DRV_INFO DRV_DESC " version " DRV_VERSION 294 + 295 + static int __init rb500_pata_module_init(void) 296 + { 297 + printk(KERN_INFO DRV_INFO "\n"); 298 + 299 + return platform_driver_register(&rb500_pata_platform_driver); 300 + } 301 + 302 + static void __exit rb500_pata_module_exit(void) 303 + { 304 + platform_driver_unregister(&rb500_pata_platform_driver); 305 + } 306 + 307 + MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>"); 308 + MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); 309 + MODULE_DESCRIPTION(DRV_DESC); 310 + MODULE_VERSION(DRV_VERSION); 311 + MODULE_LICENSE("GPL"); 312 + 313 + module_init(rb500_pata_module_init); 314 + module_exit(rb500_pata_module_exit);