14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
17 #include <linux/slab.h>
18 #include <linux/pci.h>
25 #define DRV_NAME "sc1200"
27 #define SC1200_REV_A 0x00
28 #define SC1200_REV_B1 0x01
29 #define SC1200_REV_B3 0x02
30 #define SC1200_REV_C1 0x03
31 #define SC1200_REV_D1 0x04
33 #define PCI_CLK_33 0x00
34 #define PCI_CLK_48 0x01
35 #define PCI_CLK_66 0x02
36 #define PCI_CLK_33A 0x03
38 static unsigned short sc1200_get_pci_clock (
void)
40 unsigned char chip_id, silicon_revision;
41 unsigned int pci_clock;
46 chip_id =
inb (0x903c);
47 silicon_revision =
inb (0x903d);
56 pci_clock =
inw (0x901e);
70 static const unsigned int sc1200_pio_timings[4][5] =
71 {{0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010},
72 {0xd1329172, 0x71212171, 0x30200080, 0x20102010, 0x00100010},
73 {0xfaa3f4f3, 0xc23232b2, 0x513101c1, 0x31213121, 0x10211021},
74 {0xfff4fff4, 0xf35353d3, 0x814102f1, 0x42314231, 0x11311131}};
85 unsigned int basereg = hwif->
channel ? 0x50 : 0x40,
format = 0;
87 pci_read_config_dword(pdev, basereg + 4, &
format);
90 format += sc1200_get_pci_clock();
91 pci_write_config_dword(pdev, basereg + ((drive->
dn & 1) << 3),
92 sc1200_pio_timings[
format][pio]);
130 unsigned short pci_clock;
131 unsigned int basereg = hwif->
channel ? 0x50 : 0x40;
134 static const u32 udma_timing[3][3] = {
135 { 0x00921250, 0x00911140, 0x00911030 },
136 { 0x00932470, 0x00922260, 0x00922140 },
137 { 0x009436a1, 0x00933481, 0x00923261 },
140 static const u32 mwdma_timing[3][3] = {
141 { 0x00077771, 0x00012121, 0x00002020 },
142 { 0x000bbbb2, 0x00024241, 0x00013131 },
143 { 0x000ffff3, 0x00035352, 0x00015151 },
146 pci_clock = sc1200_get_pci_clock();
154 timings = udma_timing[pci_clock][mode -
XFER_UDMA_0];
158 if ((drive->
dn & 1) == 0) {
159 pci_read_config_dword(dev, basereg + 4, ®);
160 timings |= reg & 0x80000000;
161 pci_write_config_dword(dev, basereg + 4, timings);
163 pci_write_config_dword(dev, basereg + 12, timings);
174 unsigned long dma_base = hwif->
dma_base;
177 dma_stat =
inb(dma_base+2);
180 printk(
" ide_dma_end dma_stat=%0x err=%x newerr=%x\n",
181 dma_stat, ((dma_stat&7)!=4), ((dma_stat&2)==2));
183 outb(dma_stat|0x1b, dma_base+2);
184 outb(
inb(dma_base)&~1, dma_base);
186 return (dma_stat & 7) != 4;
214 printk(
"SC1200: %s: changing (U)DMA mode\n", drive->
name);
218 hwif->
dma_ops->dma_host_set(drive, 1);
222 sc1200_tunepio(drive, pio);
226 struct sc1200_saved_state {
246 for (r = 0; r < 8; r++)
247 pci_read_config_dword(dev, 0x40 + r * 4, &ss->regs[r]);
255 static int sc1200_resume (
struct pci_dev *dev)
257 struct ide_host *host = pci_get_drvdata(dev);
258 struct sc1200_saved_state *ss = host->
host_priv;
270 for (r = 0; r < 8; r++)
271 pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
278 .set_pio_mode = sc1200_set_pio_mode,
279 .set_dma_mode = sc1200_set_dma_mode,
280 .udma_filter = sc1200_udma_filter,
287 .dma_end = sc1200_dma_end,
296 .port_ops = &sc1200_port_ops,
297 .dma_ops = &sc1200_dma_ops,
308 struct sc1200_saved_state *ss =
NULL;
329 static struct pci_driver sc1200_pci_driver = {
330 .name =
"SC1200_IDE",
331 .id_table = sc1200_pci_tbl,
332 .probe = sc1200_init_one,
335 .suspend = sc1200_suspend,
336 .resume = sc1200_resume,
340 static int __init sc1200_ide_init(
void)
345 static void __exit sc1200_ide_exit(
void)