This source file includes following definitions.
- jmicron_cable_detect
- jmicron_set_pio_mode
- jmicron_set_dma_mode
- jmicron_init_one
- jmicron_ide_init
- jmicron_ide_exit
1
2
3
4
5
6
7
8 #include <linux/types.h>
9 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <linux/ide.h>
12 #include <linux/init.h>
13
14 #define DRV_NAME "jmicron"
15
16 typedef enum {
17 PORT_PATA0 = 0,
18 PORT_PATA1 = 1,
19 PORT_SATA = 2,
20 } port_type;
21
22
23
24
25
26
27
28
29 static u8 jmicron_cable_detect(ide_hwif_t *hwif)
30 {
31 struct pci_dev *pdev = to_pci_dev(hwif->dev);
32
33 u32 control;
34 u32 control5;
35
36 int port = hwif->channel;
37 port_type port_map[2];
38
39 pci_read_config_dword(pdev, 0x40, &control);
40
41
42
43
44 if (control & (1 << 23)) {
45 port_map[0] = PORT_SATA;
46 port_map[1] = PORT_PATA0;
47 } else {
48 port_map[0] = PORT_SATA;
49 port_map[1] = PORT_SATA;
50 }
51
52
53
54 pci_read_config_dword(pdev, 0x80, &control5);
55 if (control5 & (1<<24))
56 port_map[0] = PORT_PATA1;
57
58
59 if (control & (1 << 22))
60 port = port ^ 1;
61
62
63
64
65
66
67 switch (port_map[port]) {
68 case PORT_PATA0:
69 if (control & (1 << 3))
70 return ATA_CBL_PATA40;
71 return ATA_CBL_PATA80;
72 case PORT_PATA1:
73 if (control5 & (1 << 19))
74 return ATA_CBL_PATA40;
75 return ATA_CBL_PATA80;
76 case PORT_SATA:
77 break;
78 }
79
80 return ATA_CBL_PATA80;
81 }
82
83 static void jmicron_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
84 {
85 }
86
87
88
89
90
91
92
93
94
95 static void jmicron_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
96 {
97 }
98
99 static const struct ide_port_ops jmicron_port_ops = {
100 .set_pio_mode = jmicron_set_pio_mode,
101 .set_dma_mode = jmicron_set_dma_mode,
102 .cable_detect = jmicron_cable_detect,
103 };
104
105 static const struct ide_port_info jmicron_chipset = {
106 .name = DRV_NAME,
107 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
108 .port_ops = &jmicron_port_ops,
109 .pio_mask = ATA_PIO5,
110 .mwdma_mask = ATA_MWDMA2,
111 .udma_mask = ATA_UDMA6,
112 };
113
114
115
116
117
118
119
120
121
122
123 static int jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
124 {
125 return ide_pci_init_one(dev, &jmicron_chipset, NULL);
126 }
127
128
129
130
131
132
133
134
135
136
137 static struct pci_device_id jmicron_pci_tbl[] = {
138 #if !defined(CONFIG_ATA) && !defined(CONFIG_ATA_MODULE)
139 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361) },
140 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363) },
141 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365) },
142 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366) },
143 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368) },
144 #endif
145 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
146 PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
147 { 0, },
148 };
149
150 MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl);
151
152 static struct pci_driver jmicron_pci_driver = {
153 .name = "JMicron IDE",
154 .id_table = jmicron_pci_tbl,
155 .probe = jmicron_init_one,
156 .remove = ide_pci_remove,
157 .suspend = ide_pci_suspend,
158 .resume = ide_pci_resume,
159 };
160
161 static int __init jmicron_ide_init(void)
162 {
163 return ide_pci_register_driver(&jmicron_pci_driver);
164 }
165
166 static void __exit jmicron_ide_exit(void)
167 {
168 pci_unregister_driver(&jmicron_pci_driver);
169 }
170
171 module_init(jmicron_ide_init);
172 module_exit(jmicron_ide_exit);
173
174 MODULE_AUTHOR("Alan Cox");
175 MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes");
176 MODULE_LICENSE("GPL");