aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_cs5530.c
diff options
context:
space:
mode:
authorAlan <alan@lxorguk.ukuu.org.uk>2006-11-22 12:21:03 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-01 22:46:43 -0500
commitf7e37ba83fd3e92411dfc97d08eaf9d85dfac2ee (patch)
tree006f16b753f1e56a14958ce195142445e251143d /drivers/ata/pata_cs5530.c
parent54083f114efad2d4fa993c52024f8973c70b9edb (diff)
[PATCH] pata_cs5530: suspend/resume support
The 5530 needs various set up performing both at init time and resume time. To keep the code clean the common setup code is moved into a new function and called from both handlers. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_cs5530.c')
-rw-r--r--drivers/ata/pata_cs5530.c99
1 files changed, 62 insertions, 37 deletions
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 981f49223469..265012b16bbb 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -35,7 +35,7 @@
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36 36
37#define DRV_NAME "pata_cs5530" 37#define DRV_NAME "pata_cs5530"
38#define DRV_VERSION "0.6" 38#define DRV_VERSION "0.7.1"
39 39
40/** 40/**
41 * cs5530_set_piomode - PIO setup 41 * cs5530_set_piomode - PIO setup
@@ -182,6 +182,8 @@ static struct scsi_host_template cs5530_sht = {
182 .slave_configure = ata_scsi_slave_config, 182 .slave_configure = ata_scsi_slave_config,
183 .slave_destroy = ata_scsi_slave_destroy, 183 .slave_destroy = ata_scsi_slave_destroy,
184 .bios_param = ata_std_bios_param, 184 .bios_param = ata_std_bios_param,
185 .resume = ata_scsi_device_resume,
186 .suspend = ata_scsi_device_suspend,
185}; 187};
186 188
187static struct ata_port_operations cs5530_port_ops = { 189static struct ata_port_operations cs5530_port_ops = {
@@ -239,38 +241,18 @@ static int cs5530_is_palmax(void)
239 return 0; 241 return 0;
240} 242}
241 243
244
242/** 245/**
243 * cs5530_init_one - Initialise a CS5530 246 * cs5530_init_chip - Chipset init
244 * @dev: PCI device
245 * @id: Entry in match table
246 * 247 *
247 * Install a driver for the newly found CS5530 companion chip. Most of 248 * Perform the chip initialisation work that is shared between both
248 * this is just housekeeping. We have to set the chip up correctly and 249 * setup and resume paths
249 * turn off various bits of emulation magic.
250 */ 250 */
251 251
252static int cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id) 252static int cs5530_init_chip(void)
253{ 253{
254 int compiler_warning_pointless_fix; 254 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL, *dev = NULL;
255 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
256 static struct ata_port_info info = {
257 .sht = &cs5530_sht,
258 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
259 .pio_mask = 0x1f,
260 .mwdma_mask = 0x07,
261 .udma_mask = 0x07,
262 .port_ops = &cs5530_port_ops
263 };
264 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
265 static struct ata_port_info info_palmax_secondary = {
266 .sht = &cs5530_sht,
267 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
268 .pio_mask = 0x1f,
269 .port_ops = &cs5530_port_ops
270 };
271 static struct ata_port_info *port_info[2] = { &info, &info };
272 255
273 dev = NULL;
274 while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) { 256 while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) {
275 switch (dev->device) { 257 switch (dev->device) {
276 case PCI_DEVICE_ID_CYRIX_PCI_MASTER: 258 case PCI_DEVICE_ID_CYRIX_PCI_MASTER:
@@ -291,7 +273,7 @@ static int cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
291 } 273 }
292 274
293 pci_set_master(cs5530_0); 275 pci_set_master(cs5530_0);
294 compiler_warning_pointless_fix = pci_set_mwi(cs5530_0); 276 pci_set_mwi(cs5530_0);
295 277
296 /* 278 /*
297 * Set PCI CacheLineSize to 16-bytes: 279 * Set PCI CacheLineSize to 16-bytes:
@@ -339,13 +321,7 @@ static int cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
339 321
340 pci_dev_put(master_0); 322 pci_dev_put(master_0);
341 pci_dev_put(cs5530_0); 323 pci_dev_put(cs5530_0);
342 324 return 0;
343 if (cs5530_is_palmax())
344 port_info[1] = &info_palmax_secondary;
345
346 /* Now kick off ATA set up */
347 return ata_pci_init_one(dev, port_info, 2);
348
349fail_put: 325fail_put:
350 if (master_0) 326 if (master_0)
351 pci_dev_put(master_0); 327 pci_dev_put(master_0);
@@ -354,6 +330,53 @@ fail_put:
354 return -ENODEV; 330 return -ENODEV;
355} 331}
356 332
333/**
334 * cs5530_init_one - Initialise a CS5530
335 * @dev: PCI device
336 * @id: Entry in match table
337 *
338 * Install a driver for the newly found CS5530 companion chip. Most of
339 * this is just housekeeping. We have to set the chip up correctly and
340 * turn off various bits of emulation magic.
341 */
342
343static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
344{
345 static struct ata_port_info info = {
346 .sht = &cs5530_sht,
347 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
348 .pio_mask = 0x1f,
349 .mwdma_mask = 0x07,
350 .udma_mask = 0x07,
351 .port_ops = &cs5530_port_ops
352 };
353 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
354 static struct ata_port_info info_palmax_secondary = {
355 .sht = &cs5530_sht,
356 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
357 .pio_mask = 0x1f,
358 .port_ops = &cs5530_port_ops
359 };
360 static struct ata_port_info *port_info[2] = { &info, &info };
361
362 /* Chip initialisation */
363 if (cs5530_init_chip())
364 return -ENODEV;
365
366 if (cs5530_is_palmax())
367 port_info[1] = &info_palmax_secondary;
368
369 /* Now kick off ATA set up */
370 return ata_pci_init_one(pdev, port_info, 2);
371}
372
373static int cs5530_reinit_one(struct pci_dev *pdev)
374{
375 /* If we fail on resume we are doomed */
376 BUG_ON(cs5530_init_chip());
377 return ata_pci_device_resume(pdev);
378}
379
357static const struct pci_device_id cs5530[] = { 380static const struct pci_device_id cs5530[] = {
358 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), }, 381 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), },
359 382
@@ -364,7 +387,9 @@ static struct pci_driver cs5530_pci_driver = {
364 .name = DRV_NAME, 387 .name = DRV_NAME,
365 .id_table = cs5530, 388 .id_table = cs5530,
366 .probe = cs5530_init_one, 389 .probe = cs5530_init_one,
367 .remove = ata_pci_remove_one 390 .remove = ata_pci_remove_one,
391 .suspend = ata_pci_device_suspend,
392 .resume = cs5530_reinit_one,
368}; 393};
369 394
370static int __init cs5530_init(void) 395static int __init cs5530_init(void)