Blame view
drivers/ide/cs5520.c
4.72 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/* * IDE tuning and bus mastering support for the CS5510/CS5520 * chipsets * * The CS5510/CS5520 are slightly unusual devices. Unlike the * typical IDE controllers they do bus mastering with the drive in * PIO mode and smarter silicon. * * The practical upshot of this is that we must always tune the * drive for the right PIO mode. We must also ignore all the blacklists * and the drive bus mastering DMA information. * * *** This driver is strictly experimental *** * * (c) Copyright Red Hat Inc 2002 * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * For the avoidance of doubt the "preferred form" of this code is one which * is in an open non patent encumbered format. Where cryptographic key signing * forms part of the process of creating an executable the information * including keys needed to generate an equivalently functional executable * are deemed to be part of the source code. * */ |
1da177e4c Linux-2.6.12-rc2 |
35 36 37 |
#include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> |
1da177e4c Linux-2.6.12-rc2 |
38 39 40 41 |
#include <linux/init.h> #include <linux/pci.h> #include <linux/ide.h> #include <linux/dma-mapping.h> |
ced3ec8aa ide: prefix messa... |
42 |
#define DRV_NAME "cs5520" |
1da177e4c Linux-2.6.12-rc2 |
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
struct pio_clocks { int address; int assert; int recovery; }; static struct pio_clocks cs5520_pio_clocks[]={ {3, 6, 11}, {2, 5, 6}, {1, 4, 3}, {1, 3, 2}, {1, 2, 1} }; |
e085b3cae ide: change ->set... |
57 |
static void cs5520_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
1da177e4c Linux-2.6.12-rc2 |
58 |
{ |
36501650e ide: keep pointer... |
59 |
struct pci_dev *pdev = to_pci_dev(hwif->dev); |
1da177e4c Linux-2.6.12-rc2 |
60 |
int controller = drive->dn > 1 ? 1 : 0; |
e085b3cae ide: change ->set... |
61 |
const u8 pio = drive->pio_mode - XFER_PIO_0; |
f212ff28f ide: move ide_rat... |
62 |
|
1da177e4c Linux-2.6.12-rc2 |
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/* 8bit CAT/CRT - 8bit command timing for channel */ pci_write_config_byte(pdev, 0x62 + controller, (cs5520_pio_clocks[pio].recovery << 4) | (cs5520_pio_clocks[pio].assert)); /* 0x64 - 16bit Primary, 0x68 - 16bit Secondary */ /* FIXME: should these use address ? */ /* Data read timing */ pci_write_config_byte(pdev, 0x64 + 4*controller + (drive->dn&1), (cs5520_pio_clocks[pio].recovery << 4) | (cs5520_pio_clocks[pio].assert)); /* Write command timing */ pci_write_config_byte(pdev, 0x66 + 4*controller + (drive->dn&1), (cs5520_pio_clocks[pio].recovery << 4) | (cs5520_pio_clocks[pio].assert)); |
326d72f43 cs5520: don't ena... |
79 |
} |
26bcb879c ide: add ide_set{... |
80 |
|
8776168ca ide: change ->set... |
81 |
static void cs5520_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
1da177e4c Linux-2.6.12-rc2 |
82 |
{ |
8f4dd2e42 ide: use only ->s... |
83 84 |
printk(KERN_ERR "cs55x0: bad ide timing. "); |
e085b3cae ide: change ->set... |
85 |
drive->pio_mode = XFER_PIO_0 + 0; |
8776168ca ide: change ->set... |
86 |
cs5520_set_pio_mode(hwif, drive); |
1da177e4c Linux-2.6.12-rc2 |
87 |
} |
ac95beedf ide: add struct i... |
88 89 90 91 |
static const struct ide_port_ops cs5520_port_ops = { .set_pio_mode = cs5520_set_pio_mode, .set_dma_mode = cs5520_set_dma_mode, }; |
ced3ec8aa ide: prefix messa... |
92 93 |
static const struct ide_port_info cyrix_chipset __devinitdata = { .name = DRV_NAME, |
24307ffab cs5520: add enabl... |
94 |
.enablebits = { { 0x60, 0x01, 0x01 }, { 0x60, 0x02, 0x02 } }, |
ced3ec8aa ide: prefix messa... |
95 96 97 |
.port_ops = &cs5520_port_ops, .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_CS5520, .pio_mask = ATA_PIO4, |
1da177e4c Linux-2.6.12-rc2 |
98 99 100 101 102 103 104 105 106 107 |
}; /* * The 5510/5520 are a bit weird. They don't quite set up the way * the PCI helper layer expects so we must do much of the set up * work longhand. */ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) { |
ced3ec8aa ide: prefix messa... |
108 |
const struct ide_port_info *d = &cyrix_chipset; |
9f36d3143 ide: remove hw_re... |
109 |
struct ide_hw hw[2], *hws[] = { NULL, NULL }; |
1da177e4c Linux-2.6.12-rc2 |
110 111 112 113 |
ide_setup_pci_noise(dev, d); /* We must not grab the entire device, it has 'ISA' space in its |
094839164 PCI: Remove users... |
114 |
* BARS too and we will freak out other bits of the kernel |
094839164 PCI: Remove users... |
115 116 |
*/ if (pci_enable_device_io(dev)) { |
1da177e4c Linux-2.6.12-rc2 |
117 118 |
printk(KERN_WARNING "%s: Unable to enable 55x0. ", d->name); |
1e39dead2 [PATCH] cs5520: f... |
119 |
return -ENODEV; |
1da177e4c Linux-2.6.12-rc2 |
120 121 |
} pci_set_master(dev); |
284901a90 dma-mapping: repl... |
122 |
if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) { |
ced3ec8aa ide: prefix messa... |
123 124 125 |
printk(KERN_WARNING "%s: No suitable DMA available. ", d->name); |
1da177e4c Linux-2.6.12-rc2 |
126 127 |
return -ENODEV; } |
1da177e4c Linux-2.6.12-rc2 |
128 129 130 131 |
/* * Now the chipset is configured we can let the core * do all the device setup for us */ |
86ccf37c6 ide: remove pciir... |
132 133 |
ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); hw[0].irq = 14; |
d7e2f36d9 ide cs5520: Initi... |
134 |
hw[1].irq = 15; |
5cbf79cdb ide: add ide_proc... |
135 |
|
dca398305 ide: pass number ... |
136 |
return ide_host_add(d, hws, 2, NULL); |
1da177e4c Linux-2.6.12-rc2 |
137 |
} |
9cbcc5e3c ide: use PCI_VDEV... |
138 139 140 |
static const struct pci_device_id cs5520_pci_tbl[] = { { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5510), 0 }, { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5520), 1 }, |
1da177e4c Linux-2.6.12-rc2 |
141 142 143 |
{ 0, }, }; MODULE_DEVICE_TABLE(pci, cs5520_pci_tbl); |
a9ab09e26 ide: use unique n... |
144 |
static struct pci_driver cs5520_pci_driver = { |
1da177e4c Linux-2.6.12-rc2 |
145 146 147 |
.name = "Cyrix_IDE", .id_table = cs5520_pci_tbl, .probe = cs5520_init_one, |
feb22b7f8 ide: add proper P... |
148 149 |
.suspend = ide_pci_suspend, .resume = ide_pci_resume, |
1da177e4c Linux-2.6.12-rc2 |
150 |
}; |
82ab1eece ide: add missing ... |
151 |
static int __init cs5520_ide_init(void) |
1da177e4c Linux-2.6.12-rc2 |
152 |
{ |
a9ab09e26 ide: use unique n... |
153 |
return ide_pci_register_driver(&cs5520_pci_driver); |
1da177e4c Linux-2.6.12-rc2 |
154 155 156 157 158 159 160 |
} module_init(cs5520_ide_init); MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("PCI driver module for Cyrix 5510/5520 IDE"); MODULE_LICENSE("GPL"); |