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#include <linux/config.h>
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/pci.h>
29#include <linux/init.h>
30#include <linux/blkdev.h>
31#include <linux/delay.h>
32#include "scsi.h"
33#include "hosts.h"
34#include <linux/libata.h>
35
36#define DRV_NAME "sata_via"
37#define DRV_VERSION "0.11"
38
39enum {
40 via_sata = 0,
41};
42
43static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
44static void svia_sata_phy_reset(struct ata_port *ap);
45static void svia_port_disable(struct ata_port *ap);
46static void svia_set_piomode (struct ata_port *ap, struct ata_device *adev,
47 unsigned int pio);
48static void svia_set_udmamode (struct ata_port *ap, struct ata_device *adev,
49 unsigned int udma);
50
51static unsigned int in_module_init = 1;
52
53static struct pci_device_id svia_pci_tbl[] = {
54 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, via_sata },
55
56 { }
57};
58
59static struct pci_driver svia_pci_driver = {
60 .name = DRV_NAME,
61 .id_table = svia_pci_tbl,
62 .probe = svia_init_one,
63 .remove = ata_pci_remove_one,
64};
65
66static Scsi_Host_Template svia_sht = {
67 .module = THIS_MODULE,
68 .name = DRV_NAME,
69 .queuecommand = ata_scsi_queuecmd,
70 .eh_strategy_handler = ata_scsi_error,
71 .can_queue = ATA_DEF_QUEUE,
72 .this_id = ATA_SHT_THIS_ID,
73 .sg_tablesize = ATA_MAX_PRD,
74 .max_sectors = ATA_MAX_SECTORS,
75 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
76 .emulated = ATA_SHT_EMULATED,
77 .use_clustering = ATA_SHT_USE_CLUSTERING,
78 .proc_name = DRV_NAME,
79 .dma_boundary = ATA_DMA_BOUNDARY,
80 .slave_configure = ata_scsi_slave_config,
81};
82
83static struct ata_port_operations svia_sata_ops = {
84 .port_disable = svia_port_disable,
85 .set_piomode = svia_set_piomode,
86 .set_udmamode = svia_set_udmamode,
87
88 .tf_load = ata_tf_load_pio,
89 .tf_read = ata_tf_read_pio,
90 .check_status = ata_check_status_pio,
91 .exec_command = ata_exec_command_pio,
92
93 .phy_reset = svia_sata_phy_reset,
94 .phy_config = pata_phy_config,
95
96 .bmdma_start = ata_bmdma_start_pio,
97 .fill_sg = ata_fill_sg,
98 .eng_timeout = ata_eng_timeout,
99
100 .irq_handler = ata_interrupt,
101
102 .port_start = ata_port_start,
103 .port_stop = ata_port_stop,
104};
105
106static struct ata_port_info svia_port_info[] = {
107
108 {
109 .sht = &svia_sht,
110 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY
111 | ATA_FLAG_SRST,
112 .pio_mask = 0x03,
113 .udma_mask = 0x7f,
114 .port_ops = &svia_sata_ops,
115 },
116};
117
118static struct pci_bits svia_enable_bits[] = {
119 { 0x40U, 1U, 0x02UL, 0x02UL },
120 { 0x40U, 1U, 0x01UL, 0x01UL },
121};
122
123
124MODULE_AUTHOR("Jeff Garzik");
125MODULE_DESCRIPTION("SCSI low-level driver for VIA SATA controllers");
126MODULE_LICENSE("GPL");
127MODULE_DEVICE_TABLE(pci, svia_pci_tbl);
128
129
130
131
132
133
134
135
136
137static void svia_sata_phy_reset(struct ata_port *ap)
138{
139 if (!pci_test_config_bits(ap->host_set->pdev,
140 &svia_enable_bits[ap->port_no])) {
141 ata_port_disable(ap);
142 printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
143 return;
144 }
145
146 ata_port_probe(ap);
147 if (ap->flags & ATA_FLAG_PORT_DISABLED)
148 return;
149
150 ata_bus_reset(ap);
151}
152
153
154
155
156
157
158
159
160
161static void svia_port_disable(struct ata_port *ap)
162{
163 ata_port_disable(ap);
164
165
166}
167
168
169
170
171
172
173
174
175
176
177
178static void svia_set_piomode (struct ata_port *ap, struct ata_device *adev,
179 unsigned int pio)
180{
181
182}
183
184
185
186
187
188
189
190
191
192
193
194static void svia_set_udmamode (struct ata_port *ap, struct ata_device *adev,
195 unsigned int udma)
196{
197
198}
199
200
201
202
203
204
205
206
207
208
209
210
211static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
212{
213 static int printed_version;
214 struct ata_port_info *port_info[1];
215 unsigned int n_ports = 1;
216
217 if (!printed_version++)
218 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
219
220
221 if (!in_module_init)
222 return -ENODEV;
223
224 port_info[0] = &svia_port_info[ent->driver_data];
225
226 return ata_pci_init_one(pdev, port_info, n_ports);
227}
228
229
230
231
232
233
234
235
236
237
238static int __init svia_init(void)
239{
240 int rc;
241
242 DPRINTK("pci_module_init\n");
243 rc = pci_module_init(&svia_pci_driver);
244 if (rc)
245 return rc;
246
247 in_module_init = 0;
248
249 DPRINTK("done\n");
250 return 0;
251}
252
253
254
255
256
257
258
259
260static void __exit svia_exit(void)
261{
262 pci_unregister_driver(&svia_pci_driver);
263}
264
265module_init(svia_init);
266module_exit(svia_exit);
267
268