28 #include <linux/errno.h>
29 #include <linux/module.h>
30 #include <linux/pci.h>
33 #include <linux/slab.h>
35 #include <linux/time.h>
45 #define IOC4_CALIBRATE_COUNT 63
46 #define IOC4_CALIBRATE_CYCLES 256
47 #define IOC4_CALIBRATE_DISCARD 2
48 #define IOC4_CALIBRATE_LOW_MHZ 25
49 #define IOC4_CALIBRATE_HIGH_MHZ 75
50 #define IOC4_CALIBRATE_DEFAULT_MHZ 66
68 list_add(&is->
is_list, &ioc4_submodules);
77 "%s: IOC4 submodule %s probe failed "
104 "%s: IOC4 submodule %s remove failed "
118 #define IOC4_CALIBRATE_LOW_LIMIT \
119 (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_LOW_MHZ)
120 #define IOC4_CALIBRATE_HIGH_LIMIT \
121 (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_HIGH_MHZ)
122 #define IOC4_CALIBRATE_DEFAULT \
123 (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_DEFAULT_MHZ)
125 #define IOC4_CALIBRATE_END \
126 (IOC4_CALIBRATE_CYCLES + IOC4_CALIBRATE_DISCARD)
128 #define IOC4_INT_OUT_MODE_TOGGLE 0x7
145 union ioc4_int_out int_out;
146 union ioc4_gpcr gpcr;
147 unsigned int state, last_state = 1;
150 unsigned int count = 0;
155 gpcr.fields.int_out_en = 1;
166 int_out.fields.diag = 0;
173 state = int_out.fields.int_out;
174 if (!last_state && state) {
197 period = (end -
start) /
204 "IOC4 %s: Clock calibration failed. Assuming"
205 "PCI clock is %d ns.\n",
214 "IOC4 %s: PCI clock is %llu ns.\n",
215 pci_name(idd->
idd_pdev), (
unsigned long long)ns);
248 }
while (pdev && !found);
263 }
while (pdev && !found);
276 request_module(
"sgiioc4");
279 static DECLARE_WORK(ioc4_load_modules_work, ioc4_load_modules);
293 "%s: Failed to enable IOC4 device for pci_dev %s.\n",
294 __func__, pci_name(pdev));
303 "%s: Failed to allocate IOC4 data for pci_dev %s.\n",
304 __func__, pci_name(pdev));
317 "%s: Unable to find IOC4 misc resource "
326 "%s: Unable to request IOC4 misc region "
336 "%s: Unable to remap IOC4 misc region "
340 goto out_misc_region;
358 ioc4_clock_calibrate(idd);
373 pci_set_drvdata(idd->
idd_pdev, idd);
382 "%s: IOC4 submodule 0x%s probe failed "
419 ioc4_remove(
struct pci_dev *pdev)
424 idd = pci_get_drvdata(pdev);
431 "%s: IOC4 submodule 0x%s remove failed "
443 "%s: Unable to get IOC4 misc mapping for pci_dev %s. "
444 "Device removal may be incomplete.\n",
467 .id_table = ioc4_id_table,
482 return pci_register_driver(&ioc4_driver);