This source file includes following definitions.
- radisys_set_piomode
- radisys_set_dmamode
- radisys_qc_issue
- radisys_init_one
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/pci.h>
19 #include <linux/blkdev.h>
20 #include <linux/delay.h>
21 #include <linux/device.h>
22 #include <scsi/scsi_host.h>
23 #include <linux/libata.h>
24 #include <linux/ata.h>
25
26 #define DRV_NAME "pata_radisys"
27 #define DRV_VERSION "0.4.4"
28
29
30
31
32
33
34
35
36
37
38
39
40 static void radisys_set_piomode (struct ata_port *ap, struct ata_device *adev)
41 {
42 unsigned int pio = adev->pio_mode - XFER_PIO_0;
43 struct pci_dev *dev = to_pci_dev(ap->host->dev);
44 u16 idetm_data;
45 int control = 0;
46
47
48
49
50
51
52
53
54 static const
55 u8 timings[][2] = { { 0, 0 },
56 { 0, 0 },
57 { 1, 1 },
58 { 2, 2 },
59 { 3, 3 }, };
60
61 if (pio > 0)
62 control |= 1;
63 if (ata_pio_need_iordy(adev))
64 control |= 2;
65
66 pci_read_config_word(dev, 0x40, &idetm_data);
67
68
69
70 idetm_data &= 0xCCCC;
71 idetm_data |= (control << (4 * adev->devno));
72 idetm_data |= (timings[pio][0] << 12) |
73 (timings[pio][1] << 8);
74 pci_write_config_word(dev, 0x40, idetm_data);
75
76
77 ap->private_data = adev;
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91 static void radisys_set_dmamode (struct ata_port *ap, struct ata_device *adev)
92 {
93 struct pci_dev *dev = to_pci_dev(ap->host->dev);
94 u16 idetm_data;
95 u8 udma_enable;
96
97 static const
98 u8 timings[][2] = { { 0, 0 },
99 { 0, 0 },
100 { 1, 1 },
101 { 2, 2 },
102 { 3, 3 }, };
103
104
105
106
107
108
109 pci_read_config_word(dev, 0x40, &idetm_data);
110 pci_read_config_byte(dev, 0x48, &udma_enable);
111
112 if (adev->dma_mode < XFER_UDMA_0) {
113 unsigned int mwdma = adev->dma_mode - XFER_MW_DMA_0;
114 const unsigned int needed_pio[3] = {
115 XFER_PIO_0, XFER_PIO_3, XFER_PIO_4
116 };
117 int pio = needed_pio[mwdma] - XFER_PIO_0;
118 int control = 3;
119
120
121
122
123 if (adev->pio_mode < needed_pio[mwdma])
124 control = 1;
125
126
127
128
129 idetm_data &= 0xCCCC;
130 idetm_data |= control << (4 * adev->devno);
131 idetm_data |= (timings[pio][0] << 12) | (timings[pio][1] << 8);
132
133 udma_enable &= ~(1 << adev->devno);
134 } else {
135 u8 udma_mode;
136
137
138
139 pci_read_config_byte(dev, 0x4A, &udma_mode);
140
141 if (adev->xfer_mode == XFER_UDMA_2)
142 udma_mode &= ~(2 << (adev->devno * 4));
143 else
144 udma_mode |= (2 << (adev->devno * 4));
145
146 pci_write_config_byte(dev, 0x4A, udma_mode);
147
148 udma_enable |= (1 << adev->devno);
149 }
150 pci_write_config_word(dev, 0x40, idetm_data);
151 pci_write_config_byte(dev, 0x48, udma_enable);
152
153
154 ap->private_data = adev;
155 }
156
157
158
159
160
161
162
163
164
165
166
167
168 static unsigned int radisys_qc_issue(struct ata_queued_cmd *qc)
169 {
170 struct ata_port *ap = qc->ap;
171 struct ata_device *adev = qc->dev;
172
173 if (adev != ap->private_data) {
174
175 if (adev->dma_mode < XFER_UDMA_0) {
176 if (adev->dma_mode)
177 radisys_set_dmamode(ap, adev);
178 else if (adev->pio_mode)
179 radisys_set_piomode(ap, adev);
180 }
181 }
182 return ata_bmdma_qc_issue(qc);
183 }
184
185
186 static struct scsi_host_template radisys_sht = {
187 ATA_BMDMA_SHT(DRV_NAME),
188 };
189
190 static struct ata_port_operations radisys_pata_ops = {
191 .inherits = &ata_bmdma_port_ops,
192 .qc_issue = radisys_qc_issue,
193 .cable_detect = ata_cable_unknown,
194 .set_piomode = radisys_set_piomode,
195 .set_dmamode = radisys_set_dmamode,
196 };
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
215 {
216 static const struct ata_port_info info = {
217 .flags = ATA_FLAG_SLAVE_POSS,
218 .pio_mask = ATA_PIO4,
219 .mwdma_mask = ATA_MWDMA12_ONLY,
220 .udma_mask = ATA_UDMA24_ONLY,
221 .port_ops = &radisys_pata_ops,
222 };
223 const struct ata_port_info *ppi[] = { &info, NULL };
224
225 ata_print_version_once(&pdev->dev, DRV_VERSION);
226
227 return ata_pci_bmdma_init_one(pdev, ppi, &radisys_sht, NULL, 0);
228 }
229
230 static const struct pci_device_id radisys_pci_tbl[] = {
231 { PCI_VDEVICE(RADISYS, 0x8201), },
232
233 { }
234 };
235
236 static struct pci_driver radisys_pci_driver = {
237 .name = DRV_NAME,
238 .id_table = radisys_pci_tbl,
239 .probe = radisys_init_one,
240 .remove = ata_pci_remove_one,
241 #ifdef CONFIG_PM_SLEEP
242 .suspend = ata_pci_device_suspend,
243 .resume = ata_pci_device_resume,
244 #endif
245 };
246
247 module_pci_driver(radisys_pci_driver);
248
249 MODULE_AUTHOR("Alan Cox");
250 MODULE_DESCRIPTION("SCSI low-level driver for Radisys R82600 controllers");
251 MODULE_LICENSE("GPL");
252 MODULE_DEVICE_TABLE(pci, radisys_pci_tbl);
253 MODULE_VERSION(DRV_VERSION);