sata_uli.c (6f366c1c751454df3d1c0f25f15ee0164821112a) | sata_uli.c (9a829ccfc833269bdb85751f5048288ab93678ac) |
---|---|
1/* 2 * sata_uli.c - ULi Electronics SATA 3 * 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2, or (at your option) 8 * any later version. --- 101 unchanged lines hidden (view full) --- 110 .qc_issue = ata_qc_issue_prot, 111 .data_xfer = ata_data_xfer, 112 113 .freeze = ata_bmdma_freeze, 114 .thaw = ata_bmdma_thaw, 115 .error_handler = ata_bmdma_error_handler, 116 .post_internal_cmd = ata_bmdma_post_internal_cmd, 117 | 1/* 2 * sata_uli.c - ULi Electronics SATA 3 * 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2, or (at your option) 8 * any later version. --- 101 unchanged lines hidden (view full) --- 110 .qc_issue = ata_qc_issue_prot, 111 .data_xfer = ata_data_xfer, 112 113 .freeze = ata_bmdma_freeze, 114 .thaw = ata_bmdma_thaw, 115 .error_handler = ata_bmdma_error_handler, 116 .post_internal_cmd = ata_bmdma_post_internal_cmd, 117 |
118 .irq_handler = ata_interrupt, | |
119 .irq_clear = ata_bmdma_irq_clear, 120 .irq_on = ata_irq_on, 121 .irq_ack = ata_irq_ack, 122 123 .scr_read = uli_scr_read, 124 .scr_write = uli_scr_write, 125 126 .port_start = ata_port_start, 127}; 128 129static struct ata_port_info uli_port_info = { | 118 .irq_clear = ata_bmdma_irq_clear, 119 .irq_on = ata_irq_on, 120 .irq_ack = ata_irq_ack, 121 122 .scr_read = uli_scr_read, 123 .scr_write = uli_scr_write, 124 125 .port_start = ata_port_start, 126}; 127 128static struct ata_port_info uli_port_info = { |
130 .sht = &uli_sht, | |
131 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 132 ATA_FLAG_IGN_SIMPLEX, 133 .pio_mask = 0x1f, /* pio0-4 */ 134 .udma_mask = 0x7f, /* udma0-6 */ 135 .port_ops = &uli_ops, 136}; 137 138 --- 41 unchanged lines hidden (view full) --- 180 return; 181 182 uli_scr_cfg_write(ap, sc_reg, val); 183} 184 185static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 186{ 187 static int printed_version; | 129 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 130 ATA_FLAG_IGN_SIMPLEX, 131 .pio_mask = 0x1f, /* pio0-4 */ 132 .udma_mask = 0x7f, /* udma0-6 */ 133 .port_ops = &uli_ops, 134}; 135 136 --- 41 unchanged lines hidden (view full) --- 178 return; 179 180 uli_scr_cfg_write(ap, sc_reg, val); 181} 182 183static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 184{ 185 static int printed_version; |
188 struct ata_probe_ent *probe_ent; 189 struct ata_port_info *ppi[2]; 190 int rc; | 186 const struct ata_port_info *ppi[] = { &uli_port_info, NULL }; |
191 unsigned int board_idx = (unsigned int) ent->driver_data; | 187 unsigned int board_idx = (unsigned int) ent->driver_data; |
188 struct ata_host *host; |
|
192 struct uli_priv *hpriv; 193 void __iomem * const *iomap; | 189 struct uli_priv *hpriv; 190 void __iomem * const *iomap; |
191 struct ata_ioports *ioaddr; 192 int n_ports, rc; |
|
194 195 if (!printed_version++) 196 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 197 198 rc = pcim_enable_device(pdev); 199 if (rc) 200 return rc; 201 | 193 194 if (!printed_version++) 195 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 196 197 rc = pcim_enable_device(pdev); 198 if (rc) 199 return rc; 200 |
202 rc = pci_request_regions(pdev, DRV_NAME); 203 if (rc) { 204 pcim_pin_device(pdev); 205 return rc; 206 } 207 208 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 201 n_ports = 2; 202 if (board_idx == uli_5287) 203 n_ports = 4; 204 rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); |
209 if (rc) 210 return rc; | 205 if (rc) 206 return rc; |
211 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); 212 if (rc) 213 return rc; | |
214 | 207 |
215 ppi[0] = ppi[1] = &uli_port_info; 216 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 217 if (!probe_ent) 218 return -ENOMEM; 219 | |
220 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); 221 if (!hpriv) 222 return -ENOMEM; | 208 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); 209 if (!hpriv) 210 return -ENOMEM; |
211 host->private_data = hpriv; |
|
223 | 212 |
224 probe_ent->private_data = hpriv; | 213 iomap = host->iomap; |
225 | 214 |
226 iomap = pcim_iomap_table(pdev); 227 | |
228 switch (board_idx) { 229 case uli_5287: 230 hpriv->scr_cfg_addr[0] = ULI5287_BASE; 231 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; | 215 switch (board_idx) { 216 case uli_5287: 217 hpriv->scr_cfg_addr[0] = ULI5287_BASE; 218 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; |
232 probe_ent->n_ports = 4; | |
233 | 219 |
234 probe_ent->port[2].cmd_addr = iomap[0] + 8; 235 probe_ent->port[2].altstatus_addr = 236 probe_ent->port[2].ctl_addr = (void __iomem *) | 220 ioaddr = &host->ports[2]->ioaddr; 221 ioaddr->cmd_addr = iomap[0] + 8; 222 ioaddr->altstatus_addr = 223 ioaddr->ctl_addr = (void __iomem *) |
237 ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS) + 4; | 224 ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS) + 4; |
238 probe_ent->port[2].bmdma_addr = iomap[4] + 16; | 225 ioaddr->bmdma_addr = iomap[4] + 16; |
239 hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4; | 226 hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4; |
227 ata_std_ports(ioaddr); |
|
240 | 228 |
241 probe_ent->port[3].cmd_addr = iomap[2] + 8; 242 probe_ent->port[3].altstatus_addr = 243 probe_ent->port[3].ctl_addr = (void __iomem *) | 229 ioaddr = &host->ports[3]->ioaddr; 230 ioaddr->cmd_addr = iomap[2] + 8; 231 ioaddr->altstatus_addr = 232 ioaddr->ctl_addr = (void __iomem *) |
244 ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS) + 4; | 233 ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS) + 4; |
245 probe_ent->port[3].bmdma_addr = iomap[4] + 24; | 234 ioaddr->bmdma_addr = iomap[4] + 24; |
246 hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5; | 235 hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5; |
247 248 ata_std_ports(&probe_ent->port[2]); 249 ata_std_ports(&probe_ent->port[3]); | 236 ata_std_ports(ioaddr); |
250 break; 251 252 case uli_5289: 253 hpriv->scr_cfg_addr[0] = ULI5287_BASE; 254 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; 255 break; 256 257 case uli_5281: 258 hpriv->scr_cfg_addr[0] = ULI5281_BASE; 259 hpriv->scr_cfg_addr[1] = ULI5281_BASE + ULI5281_OFFS; 260 break; 261 262 default: 263 BUG(); 264 break; 265 } 266 267 pci_set_master(pdev); 268 pci_intx(pdev, 1); | 237 break; 238 239 case uli_5289: 240 hpriv->scr_cfg_addr[0] = ULI5287_BASE; 241 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; 242 break; 243 244 case uli_5281: 245 hpriv->scr_cfg_addr[0] = ULI5281_BASE; 246 hpriv->scr_cfg_addr[1] = ULI5281_BASE + ULI5281_OFFS; 247 break; 248 249 default: 250 BUG(); 251 break; 252 } 253 254 pci_set_master(pdev); 255 pci_intx(pdev, 1); |
269 270 if (!ata_device_add(probe_ent)) 271 return -ENODEV; 272 273 devm_kfree(&pdev->dev, probe_ent); 274 return 0; | 256 return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED, 257 &uli_sht); |
275} 276 277static int __init uli_init(void) 278{ 279 return pci_register_driver(&uli_pci_driver); 280} 281 282static void __exit uli_exit(void) 283{ 284 pci_unregister_driver(&uli_pci_driver); 285} 286 287 288module_init(uli_init); 289module_exit(uli_exit); | 258} 259 260static int __init uli_init(void) 261{ 262 return pci_register_driver(&uli_pci_driver); 263} 264 265static void __exit uli_exit(void) 266{ 267 pci_unregister_driver(&uli_pci_driver); 268} 269 270 271module_init(uli_init); 272module_exit(uli_exit); |