X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fide%2Fpci%2Fsc1200.c;h=8d762d323f8b654504a7fe85ffe499a2a14efc38;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=4cd5d013f5b44b984724496889ad3bc34914b234;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 4cd5d013f..8d762d323 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c @@ -11,7 +11,6 @@ * Available from National Semiconductor */ -#include #include #include #include @@ -67,61 +66,12 @@ static unsigned short sc1200_get_pci_clock (void) return pci_clock; } -#define DISPLAY_SC1200_TIMINGS - -#if defined(DISPLAY_SC1200_TIMINGS) && defined(CONFIG_PROC_FS) -#include -#include - -static int sc1200_get_info(char *, char **, off_t, int); -extern int (*sc1200_display_info)(char *, char **, off_t, int); /* ide-proc.c */ -extern char *ide_media_verbose(ide_drive_t *); -static u8 sc1200_proc = 0; - -static struct pci_dev *bmide_dev; - -static int sc1200_get_info (char *buffer, char **addr, off_t offset, int count) -{ - char *p = buffer; - unsigned long bibma = pci_resource_start(bmide_dev, 4); - int len; - u8 c0 = 0, c1 = 0; - - /* - * at that point bibma+0x2 et bibma+0xa are byte registers - * to investigate: - */ - - c0 = inb_p(bibma + 0x02); - c1 = inb_p(bibma + 0x0a); - - p += sprintf(p, "\n National SCx200 Chipset.\n"); - p += sprintf(p, "--------------- Primary Channel ---------------- Secondary Channel -------------\n"); - p += sprintf(p, " %sabled %sabled\n", - (c0&0x80) ? "dis" : " en", - (c1&0x80) ? "dis" : " en"); - p += sprintf(p, "--------------- drive0 --------- drive1 -------- drive0 ---------- drive1 ------\n"); - p += sprintf(p, "DMA enabled: %s %s %s %s\n", - (c0&0x20) ? "yes" : "no ", (c0&0x40) ? "yes" : "no ", - (c1&0x20) ? "yes" : "no ", (c1&0x40) ? "yes" : "no " ); - - p += sprintf(p, "UDMA\n"); - p += sprintf(p, "DMA\n"); - p += sprintf(p, "PIO\n"); - - len = (p - buffer) - offset; - *addr = buffer + offset; - - return len > count ? count : len; -} -#endif /* DISPLAY_SC1200_TIMINGS && CONFIG_PROC_FS */ - extern char *ide_xfer_verbose (byte xfer_rate); /* * Set a new transfer mode at the drive */ -int sc1200_set_xfer_mode (ide_drive_t *drive, byte mode) +static int sc1200_set_xfer_mode (ide_drive_t *drive, byte mode) { printk("%s: sc1200_set_xfer_mode(%s)\n", drive->name, ide_xfer_verbose(mode)); return ide_config_drive_speed(drive, mode); @@ -312,7 +262,7 @@ static int sc1200_config_dma (ide_drive_t *drive) * * returns 1 on error, 0 otherwise */ -int sc1200_ide_dma_end (ide_drive_t *drive) +static int sc1200_ide_dma_end (ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); unsigned long dma_base = hwif->dma_base; @@ -373,6 +323,7 @@ static void sc1200_tuneproc (ide_drive_t *drive, byte pio) /* mode=255 means "au } } +#ifdef CONFIG_PM static ide_hwif_t *lookup_pci_dev (ide_hwif_t *prev, struct pci_dev *dev) { int h; @@ -395,13 +346,13 @@ typedef struct sc1200_saved_state_s { } sc1200_saved_state_t; -static int sc1200_suspend (struct pci_dev *dev, u32 state) +static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) { ide_hwif_t *hwif = NULL; - printk("SC1200: suspend(%u)\n", state); + printk("SC1200: suspend(%u)\n", state.event); - if (state == 0) { + if (state.event == PM_EVENT_ON) { // we only save state when going from full power to less // @@ -435,8 +386,8 @@ static int sc1200_suspend (struct pci_dev *dev, u32 state) /* You don't need to iterate over disks -- sysfs should have done that for you already */ pci_disable_device(dev); - pci_set_power_state(dev,state); - dev->current_state = state; + pci_set_power_state(dev, pci_choose_state(dev, state)); + dev->current_state = state.event; return 0; } @@ -444,9 +395,8 @@ static int sc1200_resume (struct pci_dev *dev) { ide_hwif_t *hwif = NULL; -printk("SC1200: resume\n"); - pci_set_power_state(dev,0); // bring chip back from sleep state - dev->current_state = 0; + pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state + dev->current_state = PM_EVENT_ON; pci_enable_device(dev); // // loop over all interfaces that are part of this pci device: @@ -454,7 +404,6 @@ printk("SC1200: resume\n"); while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) { unsigned int basereg, r, d, format; sc1200_saved_state_t *ss = (sc1200_saved_state_t *)hwif->config_data; -printk("%s: SC1200: resume\n", hwif->name); // // Restore timing registers: this may be unnecessary if BIOS also does it @@ -503,27 +452,13 @@ printk("%s: SC1200: resume\n", hwif->name); } return 0; } - -/* - * Initialize the sc1200 bridge for reliable IDE DMA operation. - */ -static unsigned int __init init_chipset_sc1200 (struct pci_dev *dev, const char *name) -{ -#if defined(DISPLAY_SC1200_TIMINGS) && defined(CONFIG_PROC_FS) - if (!bmide_dev) { - sc1200_proc = 1; - bmide_dev = dev; - ide_pci_create_host_proc("sc1200", sc1200_get_info); - } -#endif /* DISPLAY_SC1200_TIMINGS && CONFIG_PROC_FS */ - return 0; -} +#endif /* * This gets invoked by the IDE driver once for each channel, * and performs channel-specific pre-initialization before drive probing. */ -static void __init init_hwif_sc1200 (ide_hwif_t *hwif) +static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) { if (hwif->mate) hwif->serialized = hwif->mate->serialized = 1; @@ -545,7 +480,6 @@ static void __init init_hwif_sc1200 (ide_hwif_t *hwif) static ide_pci_device_t sc1200_chipset __devinitdata = { .name = "SC1200", - .init_chipset = init_chipset_sc1200, .init_hwif = init_hwif_sc1200, .channels = 2, .autodma = AUTODMA, @@ -554,12 +488,11 @@ static ide_pci_device_t sc1200_chipset __devinitdata = { static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - ide_setup_pci_device(dev, &sc1200_chipset); - return 0; + return ide_setup_pci_device(dev, &sc1200_chipset); } static struct pci_device_id sc1200_pci_tbl[] = { - { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE), 0}, { 0, }, }; MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl); @@ -568,11 +501,13 @@ static struct pci_driver driver = { .name = "SC1200_IDE", .id_table = sc1200_pci_tbl, .probe = sc1200_init_one, +#ifdef CONFIG_PM .suspend = sc1200_suspend, .resume = sc1200_resume, +#endif }; -static int sc1200_ide_init(void) +static int __init sc1200_ide_init(void) { return ide_pci_register_driver(&driver); }