Lines 41-50
Link Here
|
41 |
|
41 |
|
42 |
MODULE_DEVICE_TABLE(pci, pci_ids); |
42 |
MODULE_DEVICE_TABLE(pci, pci_ids); |
43 |
|
43 |
|
|
|
44 |
static int ricoh_mmc_disable(struct pci_dev *fw_dev) |
45 |
{ |
46 |
u8 write_enable; |
47 |
u8 write_target; |
48 |
u8 disable; |
49 |
|
50 |
if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) { |
51 |
/* via RL5C476 */ |
52 |
|
53 |
pci_read_config_byte(fw_dev, 0xB7, &disable); |
54 |
if (disable & 0x02) { |
55 |
printk(KERN_INFO DRIVER_NAME |
56 |
": Controller already disabled. " \ |
57 |
"Nothing to do.\n"); |
58 |
return -ENODEV; |
59 |
} |
60 |
|
61 |
pci_read_config_byte(fw_dev, 0x8E, &write_enable); |
62 |
pci_write_config_byte(fw_dev, 0x8E, 0xAA); |
63 |
pci_read_config_byte(fw_dev, 0x8D, &write_target); |
64 |
pci_write_config_byte(fw_dev, 0x8D, 0xB7); |
65 |
pci_write_config_byte(fw_dev, 0xB7, disable | 0x02); |
66 |
pci_write_config_byte(fw_dev, 0x8E, write_enable); |
67 |
pci_write_config_byte(fw_dev, 0x8D, write_target); |
68 |
} else { |
69 |
/* via R5C832 */ |
70 |
|
71 |
pci_read_config_byte(fw_dev, 0xCB, &disable); |
72 |
if (disable & 0x02) { |
73 |
printk(KERN_INFO DRIVER_NAME |
74 |
": Controller already disabled. " \ |
75 |
"Nothing to do.\n"); |
76 |
return -ENODEV; |
77 |
} |
78 |
|
79 |
pci_read_config_byte(fw_dev, 0xCA, &write_enable); |
80 |
pci_write_config_byte(fw_dev, 0xCA, 0x57); |
81 |
pci_write_config_byte(fw_dev, 0xCB, disable | 0x02); |
82 |
pci_write_config_byte(fw_dev, 0xCA, write_enable); |
83 |
} |
84 |
|
85 |
printk(KERN_INFO DRIVER_NAME |
86 |
": Controller is now disabled.\n"); |
87 |
|
88 |
return 0; |
89 |
} |
90 |
|
91 |
static int ricoh_mmc_enable(struct pci_dev *fw_dev) |
92 |
{ |
93 |
u8 write_enable; |
94 |
u8 write_target; |
95 |
u8 disable; |
96 |
|
97 |
if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) { |
98 |
/* via RL5C476 */ |
99 |
|
100 |
pci_read_config_byte(fw_dev, 0x8E, &write_enable); |
101 |
pci_write_config_byte(fw_dev, 0x8E, 0xAA); |
102 |
pci_read_config_byte(fw_dev, 0x8D, &write_target); |
103 |
pci_write_config_byte(fw_dev, 0x8D, 0xB7); |
104 |
pci_read_config_byte(fw_dev, 0xB7, &disable); |
105 |
pci_write_config_byte(fw_dev, 0xB7, disable & ~0x02); |
106 |
pci_write_config_byte(fw_dev, 0x8E, write_enable); |
107 |
pci_write_config_byte(fw_dev, 0x8D, write_target); |
108 |
} else { |
109 |
/* via R5C832 */ |
110 |
|
111 |
pci_read_config_byte(fw_dev, 0xCA, &write_enable); |
112 |
pci_read_config_byte(fw_dev, 0xCB, &disable); |
113 |
pci_write_config_byte(fw_dev, 0xCA, 0x57); |
114 |
pci_write_config_byte(fw_dev, 0xCB, disable & ~0x02); |
115 |
pci_write_config_byte(fw_dev, 0xCA, write_enable); |
116 |
} |
117 |
|
118 |
printk(KERN_INFO DRIVER_NAME |
119 |
": Controller is now re-enabled.\n"); |
120 |
|
121 |
return 0; |
122 |
} |
123 |
|
44 |
static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, |
124 |
static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, |
45 |
const struct pci_device_id *ent) |
125 |
const struct pci_device_id *ent) |
46 |
{ |
126 |
{ |
47 |
u8 rev; |
127 |
u8 rev; |
|
|
128 |
u8 ctrlfound = 0; |
48 |
|
129 |
|
49 |
struct pci_dev *fw_dev = NULL; |
130 |
struct pci_dev *fw_dev = NULL; |
50 |
|
131 |
|
Lines 58-91
Link Here
|
58 |
pci_name(pdev), (int)pdev->vendor, (int)pdev->device, |
139 |
pci_name(pdev), (int)pdev->vendor, (int)pdev->device, |
59 |
(int)rev); |
140 |
(int)rev); |
60 |
|
141 |
|
61 |
while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { |
142 |
while ((fw_dev = |
|
|
143 |
pci_get_device(PCI_VENDOR_ID_RICOH, |
144 |
PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { |
62 |
if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
145 |
if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
63 |
pdev->bus == fw_dev->bus) { |
146 |
pdev->bus == fw_dev->bus) { |
64 |
u8 write_enable; |
147 |
if (ricoh_mmc_disable(fw_dev) != 0) |
65 |
u8 disable; |
|
|
66 |
|
67 |
pci_read_config_byte(fw_dev, 0xCB, &disable); |
68 |
if (disable & 0x02) { |
69 |
printk(KERN_INFO DRIVER_NAME |
70 |
": Controller already disabled. Nothing to do.\n"); |
71 |
return -ENODEV; |
148 |
return -ENODEV; |
72 |
} |
|
|
73 |
|
74 |
pci_read_config_byte(fw_dev, 0xCA, &write_enable); |
75 |
pci_write_config_byte(fw_dev, 0xCA, 0x57); |
76 |
pci_write_config_byte(fw_dev, 0xCB, disable | 0x02); |
77 |
pci_write_config_byte(fw_dev, 0xCA, write_enable); |
78 |
|
149 |
|
79 |
pci_set_drvdata(pdev, fw_dev); |
150 |
pci_set_drvdata(pdev, fw_dev); |
80 |
|
151 |
|
81 |
printk(KERN_INFO DRIVER_NAME |
152 |
++ctrlfound; |
82 |
": Controller is now disabled.\n"); |
|
|
83 |
|
84 |
break; |
153 |
break; |
85 |
} |
154 |
} |
86 |
} |
155 |
} |
87 |
|
156 |
|
88 |
if (pci_get_drvdata(pdev) == NULL) { |
157 |
fw_dev = NULL; |
|
|
158 |
|
159 |
while (!ctrlfound && |
160 |
(fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, |
161 |
PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { |
162 |
if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
163 |
pdev->bus == fw_dev->bus) { |
164 |
if (ricoh_mmc_disable(fw_dev) != 0) |
165 |
return -ENODEV; |
166 |
|
167 |
pci_set_drvdata(pdev, fw_dev); |
168 |
|
169 |
++ctrlfound; |
170 |
} |
171 |
} |
172 |
|
173 |
if (!ctrlfound) { |
89 |
printk(KERN_WARNING DRIVER_NAME |
174 |
printk(KERN_WARNING DRIVER_NAME |
90 |
": Main firewire function not found. Cannot disable controller.\n"); |
175 |
": Main firewire function not found. Cannot disable controller.\n"); |
91 |
return -ENODEV; |
176 |
return -ENODEV; |
Lines 96-125
Link Here
|
96 |
|
181 |
|
97 |
static void __devexit ricoh_mmc_remove(struct pci_dev *pdev) |
182 |
static void __devexit ricoh_mmc_remove(struct pci_dev *pdev) |
98 |
{ |
183 |
{ |
99 |
u8 write_enable; |
|
|
100 |
u8 disable; |
101 |
struct pci_dev *fw_dev = NULL; |
184 |
struct pci_dev *fw_dev = NULL; |
102 |
|
185 |
|
103 |
fw_dev = pci_get_drvdata(pdev); |
186 |
fw_dev = pci_get_drvdata(pdev); |
104 |
BUG_ON(fw_dev == NULL); |
187 |
BUG_ON(fw_dev == NULL); |
105 |
|
188 |
|
106 |
pci_read_config_byte(fw_dev, 0xCA, &write_enable); |
189 |
ricoh_mmc_enable(fw_dev); |
107 |
pci_read_config_byte(fw_dev, 0xCB, &disable); |
|
|
108 |
pci_write_config_byte(fw_dev, 0xCA, 0x57); |
109 |
pci_write_config_byte(fw_dev, 0xCB, disable & ~0x02); |
110 |
pci_write_config_byte(fw_dev, 0xCA, write_enable); |
111 |
|
112 |
printk(KERN_INFO DRIVER_NAME |
113 |
": Controller is now re-enabled.\n"); |
114 |
|
190 |
|
115 |
pci_set_drvdata(pdev, NULL); |
191 |
pci_set_drvdata(pdev, NULL); |
116 |
} |
192 |
} |
117 |
|
193 |
|
|
|
194 |
static int ricoh_mmc_suspend(struct pci_dev *pdev, pm_message_t state) |
195 |
{ |
196 |
struct pci_dev *fw_dev = NULL; |
197 |
|
198 |
fw_dev = pci_get_drvdata(pdev); |
199 |
BUG_ON(fw_dev == NULL); |
200 |
|
201 |
printk(KERN_INFO DRIVER_NAME ": Suspending.\n"); |
202 |
|
203 |
ricoh_mmc_enable(fw_dev); |
204 |
|
205 |
return 0; |
206 |
} |
207 |
|
208 |
static int ricoh_mmc_resume(struct pci_dev *pdev) |
209 |
{ |
210 |
struct pci_dev *fw_dev = NULL; |
211 |
|
212 |
fw_dev = pci_get_drvdata(pdev); |
213 |
BUG_ON(fw_dev == NULL); |
214 |
|
215 |
printk(KERN_INFO DRIVER_NAME ": Resuming.\n"); |
216 |
|
217 |
ricoh_mmc_disable(fw_dev); |
218 |
|
219 |
return 0; |
220 |
} |
221 |
|
118 |
static struct pci_driver ricoh_mmc_driver = { |
222 |
static struct pci_driver ricoh_mmc_driver = { |
119 |
.name = DRIVER_NAME, |
223 |
.name = DRIVER_NAME, |
120 |
.id_table = pci_ids, |
224 |
.id_table = pci_ids, |
121 |
.probe = ricoh_mmc_probe, |
225 |
.probe = ricoh_mmc_probe, |
122 |
.remove = __devexit_p(ricoh_mmc_remove), |
226 |
.remove = __devexit_p(ricoh_mmc_remove), |
|
|
227 |
.suspend = ricoh_mmc_suspend, |
228 |
.resume = ricoh_mmc_resume, |
123 |
}; |
229 |
}; |
124 |
|
230 |
|
125 |
/*****************************************************************************\ |
231 |
/*****************************************************************************\ |