aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sata_uli.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-24 11:19:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-24 11:19:51 -0500
commite93252faca2eb1a14b44369705be7c79eba2f037 (patch)
tree35ae4fde7c0b082388272f2154bfabc4bdf4500a /drivers/scsi/sata_uli.c
parentf125b56113be4956867cc9bd098bb99b1b9bb93f (diff)
parent2f1f610b62bce36d6d50857859091b8989c70267 (diff)
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev: [PATCH] libata: Remove dependence on host_set->dev for SAS [PATCH] libata: ata_scsi_ioctl cleanup [PATCH] libata: ata_scsi_queuecmd cleanup [libata] export ata_dev_pair; trim trailing whitespace [PATCH] libata: add ata_dev_pair helper [PATCH] Make libata not powerdown drivers on PM_EVENT_FREEZE. [PATCH] libata: make ata_set_mode() responsible for failure handling [PATCH] libata: use ata_dev_disable() in ata_bus_probe() [PATCH] libata: implement ata_dev_disable() [PATCH] libata: check if port is disabled after internal command [PATCH] libata: make per-dev transfer mode limits per-dev [PATCH] libata: add per-dev pio/mwdma/udma_mask [PATCH] libata: implement ata_unpack_xfermask() [libata] Move some bmdma-specific code to libata-bmdma.c [libata sata_uli] kill scr_addr abuse [libata sata_nv] eliminate duplicate codepaths with iomap [libata sata_nv] cleanups: convert #defines to enums; remove in-file history [libata sata_sil24] cleanups: use pci_iomap(), kzalloc()
Diffstat (limited to 'drivers/scsi/sata_uli.c')
-rw-r--r--drivers/scsi/sata_uli.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 8f5025733def..7ac5a5f5a905 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -44,6 +44,8 @@ enum {
44 uli_5287 = 1, 44 uli_5287 = 1,
45 uli_5281 = 2, 45 uli_5281 = 2,
46 46
47 uli_max_ports = 4,
48
47 /* PCI configuration registers */ 49 /* PCI configuration registers */
48 ULI5287_BASE = 0x90, /* sata0 phy SCR registers */ 50 ULI5287_BASE = 0x90, /* sata0 phy SCR registers */
49 ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */ 51 ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */
@@ -51,6 +53,10 @@ enum {
51 ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */ 53 ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */
52}; 54};
53 55
56struct uli_priv {
57 unsigned int scr_cfg_addr[uli_max_ports];
58};
59
54static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 60static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
55static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg); 61static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg);
56static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 62static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
@@ -137,7 +143,8 @@ MODULE_VERSION(DRV_VERSION);
137 143
138static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) 144static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
139{ 145{
140 return ap->ioaddr.scr_addr + (4 * sc_reg); 146 struct uli_priv *hpriv = ap->host_set->private_data;
147 return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg);
141} 148}
142 149
143static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) 150static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
@@ -182,6 +189,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
182 int rc; 189 int rc;
183 unsigned int board_idx = (unsigned int) ent->driver_data; 190 unsigned int board_idx = (unsigned int) ent->driver_data;
184 int pci_dev_busy = 0; 191 int pci_dev_busy = 0;
192 struct uli_priv *hpriv;
185 193
186 if (!printed_version++) 194 if (!printed_version++)
187 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 195 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
@@ -210,10 +218,18 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
210 goto err_out_regions; 218 goto err_out_regions;
211 } 219 }
212 220
221 hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
222 if (!hpriv) {
223 rc = -ENOMEM;
224 goto err_out_probe_ent;
225 }
226
227 probe_ent->private_data = hpriv;
228
213 switch (board_idx) { 229 switch (board_idx) {
214 case uli_5287: 230 case uli_5287:
215 probe_ent->port[0].scr_addr = ULI5287_BASE; 231 hpriv->scr_cfg_addr[0] = ULI5287_BASE;
216 probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS; 232 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
217 probe_ent->n_ports = 4; 233 probe_ent->n_ports = 4;
218 234
219 probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8; 235 probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8;
@@ -221,27 +237,27 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
221 probe_ent->port[2].ctl_addr = 237 probe_ent->port[2].ctl_addr =
222 (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4; 238 (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4;
223 probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16; 239 probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16;
224 probe_ent->port[2].scr_addr = ULI5287_BASE + ULI5287_OFFS*4; 240 hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4;
225 241
226 probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8; 242 probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8;
227 probe_ent->port[3].altstatus_addr = 243 probe_ent->port[3].altstatus_addr =
228 probe_ent->port[3].ctl_addr = 244 probe_ent->port[3].ctl_addr =
229 (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4; 245 (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4;
230 probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24; 246 probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24;
231 probe_ent->port[3].scr_addr = ULI5287_BASE + ULI5287_OFFS*5; 247 hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5;
232 248
233 ata_std_ports(&probe_ent->port[2]); 249 ata_std_ports(&probe_ent->port[2]);
234 ata_std_ports(&probe_ent->port[3]); 250 ata_std_ports(&probe_ent->port[3]);
235 break; 251 break;
236 252
237 case uli_5289: 253 case uli_5289:
238 probe_ent->port[0].scr_addr = ULI5287_BASE; 254 hpriv->scr_cfg_addr[0] = ULI5287_BASE;
239 probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS; 255 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
240 break; 256 break;
241 257
242 case uli_5281: 258 case uli_5281:
243 probe_ent->port[0].scr_addr = ULI5281_BASE; 259 hpriv->scr_cfg_addr[0] = ULI5281_BASE;
244 probe_ent->port[1].scr_addr = ULI5281_BASE + ULI5281_OFFS; 260 hpriv->scr_cfg_addr[1] = ULI5281_BASE + ULI5281_OFFS;
245 break; 261 break;
246 262
247 default: 263 default:
@@ -258,9 +274,10 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
258 274
259 return 0; 275 return 0;
260 276
277err_out_probe_ent:
278 kfree(probe_ent);
261err_out_regions: 279err_out_regions:
262 pci_release_regions(pdev); 280 pci_release_regions(pdev);
263
264err_out: 281err_out:
265 if (!pci_dev_busy) 282 if (!pci_dev_busy)
266 pci_disable_device(pdev); 283 pci_disable_device(pdev);