Blame view
drivers/ide/slc90e66.c
4.87 KB
09c434b8a treewide: Add SPD... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
1da177e4c Linux-2.6.12-rc2 |
2 |
/* |
1da177e4c Linux-2.6.12-rc2 |
3 |
* Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> |
07af42760 piix/slc90e66: mo... |
4 |
* Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> |
1da177e4c Linux-2.6.12-rc2 |
5 |
* |
44854add6 [PATCH] PIIX/SLC9... |
6 |
* This is a look-alike variation of the ICH0 PIIX4 Ultra-66, |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 |
* but this keeps the ISA-Bridge and slots alive. * */ |
1da177e4c Linux-2.6.12-rc2 |
10 11 12 |
#include <linux/types.h> #include <linux/module.h> #include <linux/kernel.h> |
1da177e4c Linux-2.6.12-rc2 |
13 |
#include <linux/pci.h> |
1da177e4c Linux-2.6.12-rc2 |
14 |
#include <linux/ide.h> |
1da177e4c Linux-2.6.12-rc2 |
15 |
#include <linux/init.h> |
ced3ec8aa ide: prefix messa... |
16 |
#define DRV_NAME "slc90e66" |
a482958bf slc90e66: fix dea... |
17 |
static DEFINE_SPINLOCK(slc90e66_lock); |
e085b3cae ide: change ->set... |
18 |
static void slc90e66_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
1da177e4c Linux-2.6.12-rc2 |
19 |
{ |
36501650e ide: keep pointer... |
20 |
struct pci_dev *dev = to_pci_dev(hwif->dev); |
24e6458d9 slc90e66: carry o... |
21 |
int is_slave = drive->dn & 1; |
1da177e4c Linux-2.6.12-rc2 |
22 23 24 25 26 |
int master_port = hwif->channel ? 0x42 : 0x40; int slave_port = 0x44; unsigned long flags; u16 master_data; u8 slave_data; |
5749c8474 IDE: Coding Style... |
27 |
int control = 0; |
e085b3cae ide: change ->set... |
28 |
const u8 pio = drive->pio_mode - XFER_PIO_0; |
24e6458d9 slc90e66: carry o... |
29 |
/* ISP RTC */ |
5749c8474 IDE: Coding Style... |
30 |
static const u8 timings[][2] = { |
24e6458d9 slc90e66: carry o... |
31 32 33 34 35 |
{ 0, 0 }, { 0, 0 }, { 1, 0 }, { 2, 1 }, { 2, 3 }, }; |
1da177e4c Linux-2.6.12-rc2 |
36 |
|
a482958bf slc90e66: fix dea... |
37 |
spin_lock_irqsave(&slc90e66_lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
38 |
pci_read_config_word(dev, master_port, &master_data); |
24e6458d9 slc90e66: carry o... |
39 40 41 42 43 |
if (pio > 1) control |= 1; /* Programmable timing on */ if (drive->media == ide_disk) control |= 4; /* Prefetch, post write */ |
c9ef59ff0 ide: IORDY handli... |
44 |
if (ide_pio_need_iordy(drive, pio)) |
24e6458d9 slc90e66: carry o... |
45 |
control |= 2; /* IORDY */ |
1da177e4c Linux-2.6.12-rc2 |
46 |
if (is_slave) { |
24e6458d9 slc90e66: carry o... |
47 48 49 |
master_data |= 0x4000; master_data &= ~0x0070; if (pio > 1) { |
07af42760 piix/slc90e66: mo... |
50 51 |
/* Set PPE, IE and TIME */ master_data |= control << 4; |
24e6458d9 slc90e66: carry o... |
52 |
} |
1da177e4c Linux-2.6.12-rc2 |
53 |
pci_read_config_byte(dev, slave_port, &slave_data); |
07af42760 piix/slc90e66: mo... |
54 55 56 |
slave_data &= hwif->channel ? 0x0f : 0xf0; slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (hwif->channel ? 4 : 0); |
1da177e4c Linux-2.6.12-rc2 |
57 |
} else { |
24e6458d9 slc90e66: carry o... |
58 59 |
master_data &= ~0x3307; if (pio > 1) { |
1da177e4c Linux-2.6.12-rc2 |
60 |
/* enable PPE, IE and TIME */ |
07af42760 piix/slc90e66: mo... |
61 |
master_data |= control; |
24e6458d9 slc90e66: carry o... |
62 |
} |
07af42760 piix/slc90e66: mo... |
63 |
master_data |= (timings[pio][0] << 12) | (timings[pio][1] << 8); |
1da177e4c Linux-2.6.12-rc2 |
64 65 66 67 |
} pci_write_config_word(dev, master_port, master_data); if (is_slave) pci_write_config_byte(dev, slave_port, slave_data); |
a482958bf slc90e66: fix dea... |
68 |
spin_unlock_irqrestore(&slc90e66_lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
69 |
} |
8776168ca ide: change ->set... |
70 |
static void slc90e66_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
1da177e4c Linux-2.6.12-rc2 |
71 |
{ |
36501650e ide: keep pointer... |
72 |
struct pci_dev *dev = to_pci_dev(hwif->dev); |
1da177e4c Linux-2.6.12-rc2 |
73 |
u8 maslave = hwif->channel ? 0x42 : 0x40; |
1da177e4c Linux-2.6.12-rc2 |
74 75 76 |
int sitre = 0, a_speed = 7 << (drive->dn * 4); int u_speed = 0, u_flag = 1 << drive->dn; u16 reg4042, reg44, reg48, reg4a; |
8776168ca ide: change ->set... |
77 |
const u8 speed = drive->dma_mode; |
1da177e4c Linux-2.6.12-rc2 |
78 79 80 81 82 83 |
pci_read_config_word(dev, maslave, ®4042); sitre = (reg4042 & 0x4000) ? 1 : 0; pci_read_config_word(dev, 0x44, ®44); pci_read_config_word(dev, 0x48, ®48); pci_read_config_word(dev, 0x4a, ®4a); |
1da177e4c Linux-2.6.12-rc2 |
84 |
if (speed >= XFER_UDMA_0) { |
4db90a145 ide: add IDE_HFLA... |
85 |
u_speed = (speed - XFER_UDMA_0) << (drive->dn * 4); |
1da177e4c Linux-2.6.12-rc2 |
86 87 |
if (!(reg48 & u_flag)) pci_write_config_word(dev, 0x48, reg48|u_flag); |
ee31527a0 slc90e66: fix UDM... |
88 |
if ((reg4a & a_speed) != u_speed) { |
1da177e4c Linux-2.6.12-rc2 |
89 90 91 92 93 |
pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); pci_read_config_word(dev, 0x4a, ®4a); pci_write_config_word(dev, 0x4a, reg4a|u_speed); } } else { |
8c91abf86 it8213/piix/slc90... |
94 |
const u8 mwdma_to_pio[] = { 0, 3, 4 }; |
1da177e4c Linux-2.6.12-rc2 |
95 96 97 98 |
if (reg48 & u_flag) pci_write_config_word(dev, 0x48, reg48 & ~u_flag); if (reg4a & a_speed) pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); |
8c91abf86 it8213/piix/slc90... |
99 100 |
if (speed >= XFER_MW_DMA_0) |
e085b3cae ide: change ->set... |
101 102 |
drive->pio_mode = mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0; |
8c91abf86 it8213/piix/slc90... |
103 |
else |
e085b3cae ide: change ->set... |
104 |
drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */ |
1da177e4c Linux-2.6.12-rc2 |
105 |
|
e085b3cae ide: change ->set... |
106 |
slc90e66_set_pio_mode(hwif, drive); |
1c54a93d4 it8213/piix/slc90... |
107 |
} |
1da177e4c Linux-2.6.12-rc2 |
108 |
} |
f454cbe8c ide: ->cable_dete... |
109 |
static u8 slc90e66_cable_detect(ide_hwif_t *hwif) |
1da177e4c Linux-2.6.12-rc2 |
110 |
{ |
36501650e ide: keep pointer... |
111 |
struct pci_dev *dev = to_pci_dev(hwif->dev); |
bfa14b42a ide: add ->cable_... |
112 |
u8 reg47 = 0, mask = hwif->channel ? 0x01 : 0x02; |
1da177e4c Linux-2.6.12-rc2 |
113 |
|
36501650e ide: keep pointer... |
114 |
pci_read_config_byte(dev, 0x47, ®47); |
1da177e4c Linux-2.6.12-rc2 |
115 |
|
bfa14b42a ide: add ->cable_... |
116 117 118 |
/* bit[0(1)]: 0:80, 1:40 */ return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; } |
ac95beedf ide: add struct i... |
119 120 121 122 123 |
static const struct ide_port_ops slc90e66_port_ops = { .set_pio_mode = slc90e66_set_pio_mode, .set_dma_mode = slc90e66_set_dma_mode, .cable_detect = slc90e66_cable_detect, }; |
1da177e4c Linux-2.6.12-rc2 |
124 |
|
fe31edc8a Drivers: ide: rem... |
125 |
static const struct ide_port_info slc90e66_chipset = { |
ced3ec8aa ide: prefix messa... |
126 |
.name = DRV_NAME, |
5749c8474 IDE: Coding Style... |
127 |
.enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, |
ac95beedf ide: add struct i... |
128 |
.port_ops = &slc90e66_port_ops, |
4099d1432 ide: add PIO masks |
129 |
.pio_mask = ATA_PIO4, |
5f8b6c348 ide: add ->mwdma_... |
130 131 132 |
.swdma_mask = ATA_SWDMA2_ONLY, .mwdma_mask = ATA_MWDMA12_ONLY, .udma_mask = ATA_UDMA4, |
1da177e4c Linux-2.6.12-rc2 |
133 |
}; |
fe31edc8a Drivers: ide: rem... |
134 135 |
static int slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
1da177e4c Linux-2.6.12-rc2 |
136 |
{ |
6cdf6eb35 ide: add ->dev an... |
137 |
return ide_pci_init_one(dev, &slc90e66_chipset, NULL); |
1da177e4c Linux-2.6.12-rc2 |
138 |
} |
9cbcc5e3c ide: use PCI_VDEV... |
139 140 |
static const struct pci_device_id slc90e66_pci_tbl[] = { { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1), 0 }, |
1da177e4c Linux-2.6.12-rc2 |
141 142 143 |
{ 0, }, }; MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl); |
a9ab09e26 ide: use unique n... |
144 |
static struct pci_driver slc90e66_pci_driver = { |
1da177e4c Linux-2.6.12-rc2 |
145 146 147 |
.name = "SLC90e66_IDE", .id_table = slc90e66_pci_tbl, .probe = slc90e66_init_one, |
64b0fed31 slc90e66: add ->r... |
148 |
.remove = ide_pci_remove, |
feb22b7f8 ide: add proper P... |
149 150 |
.suspend = ide_pci_suspend, .resume = ide_pci_resume, |
1da177e4c Linux-2.6.12-rc2 |
151 |
}; |
82ab1eece ide: add missing ... |
152 |
static int __init slc90e66_ide_init(void) |
1da177e4c Linux-2.6.12-rc2 |
153 |
{ |
a9ab09e26 ide: use unique n... |
154 |
return ide_pci_register_driver(&slc90e66_pci_driver); |
1da177e4c Linux-2.6.12-rc2 |
155 |
} |
64b0fed31 slc90e66: add ->r... |
156 157 |
static void __exit slc90e66_ide_exit(void) { |
a9ab09e26 ide: use unique n... |
158 |
pci_unregister_driver(&slc90e66_pci_driver); |
64b0fed31 slc90e66: add ->r... |
159 |
} |
1da177e4c Linux-2.6.12-rc2 |
160 |
module_init(slc90e66_ide_init); |
64b0fed31 slc90e66: add ->r... |
161 |
module_exit(slc90e66_ide_exit); |
1da177e4c Linux-2.6.12-rc2 |
162 163 164 165 |
MODULE_AUTHOR("Andre Hedrick"); MODULE_DESCRIPTION("PCI driver module for SLC90E66 IDE"); MODULE_LICENSE("GPL"); |