PCI device search.
Hi,
I have a device driver (drivers/char/sonypi in this case) which can handle two cases:
- on older hardware, it gets attached to a specific PCI device
- on newer hardware, when the previous PCI device is missing, it just uses a predefined set of ioports to access the hardware. There is no PCI device involved here.
I am wondering what is the cleanest way to program this. As I see it, I have two distinct choices:
1. Create a PCI driver (pci_device_id, struct pci_driver etc) and in init_module call pci_module_init. If it fails, assume the driver deals with newer hardware and call 'by hand' the 'probe' routine from pci_driver struct.
2. Not use the PCI driver infrastructure, and in init_module just call pci_find_device manually searching for older hardware, if it is present go further, if it fails assume newer hardware and go further.
What is considered to be the best way to do it ?
(this is _not_ a hotplug device if it matters).
Thanks,
Stelian.
Signature · 4 lines
Stelian Pop <[email protected]> |---------------- Free Software Engineer -----------------| | Alcôve - http://www.alcove.com - Tel: +33 1 49 22 68 00 | |------------- Alcôve, liberating software ---------------|
Quoted 6 lines · Stelian Pop
1. Create a PCI driver (
pci_device_id, structpci_driveretc) and ininit_modulecallpci_module_init. If it fails, assume the driver deals with newer hardware and call 'by hand' the 'probe' routine frompci_driverstruct.
Quoted 7 lines
2. Not use the PCI driver infrastructure, and in
init_modulejust callpci_find_devicemanually searching for older hardware, if it is present go further, if it fails assume newer hardware and go further.What is considered to be the best way to do it ?
(this is _not_ a hotplug device if it matters).
I'd say 1. If a device is hotpluggable or not does not matter. For 2.5, the boot process will be able to load modules for all PCI devices seen in the system. In order for that to happen, they need to use the MODULE_DEVICE structure and the 2.4 pci driver subsystem.
(which it looks like almost none of the current SCSI driver do...)
thanks,
greg k-h
Quoted 6 lines · Greg KH
Quoted 4 lines · Stelian Pop
1. Create a PCI driver (
pci_device_id, structpci_driveretc) and ininit_modulecallpci_module_init. If it fails, assume the driver deals with newer hardware and call 'by hand' the 'probe' routine frompci_driverstruct.
Quoted 7 lines
Quoted 2 lines
What is considered to be the best way to do it ?
(this is _not_ a hotplug device if it matters).I'd say 1. If a device is hotpluggable or not does not matter. For 2.5, the boot process will be able to load modules for all PCI devices seen in the system. In order for that to happen, they need to use the
MODULE_DEVICEstructure and the 2.4 pci driver subsystem.
I'd say 1.5. :) For the "newer hardware" consider using the PCI host bridge or ISA bridge for your "container" PCI device.
Jeff
Quoted 7 lines · Jeff Garzik
Quoted 4 lines
I'd say 1. If a device is hotpluggable or not does not matter. For 2.5, the boot process will be able to load modules for all PCI devices seen in the system. In order for that to happen, they need to use the
MODULE_DEVICEstructure and the 2.4 pci driver subsystem.I'd say 1.5. :) For the "newer hardware" consider using the PCI host bridge or ISA bridge for your "container" PCI device.
You mean putting PCI_CLASS_BRIDGE_PCI as pattern in the pci search table, yes ?
Thanks.
Stelian.
Signature · 4 lines
Stelian Pop <[email protected]> |---------------- Free Software Engineer -----------------| | Alcôve - http://www.alcove.com - Tel: +33 1 49 22 68 00 | |------------- Alcôve, liberating software ---------------|
Quoted 7 lines · Stelian Pop
Quoted 5 lines · Jeff Garzik
Quoted 4 lines
I'd say 1. If a device is hotpluggable or not does not matter. For 2.5, the boot process will be able to load modules for all PCI devices seen in the system. In order for that to happen, they need to use the
MODULE_DEVICEstructure and the 2.4 pci driver subsystem.
Quoted 5 lines
Quoted 2 lines
I'd say 1.5. :) For the "newer hardware" consider using the PCI host bridge or ISA bridge for your "container" PCI device.
You mean putting
PCI_CLASS_BRIDGE_PCIas pattern in the pci search table, yes ?
Close but not quite. Look at drivers/char/i810_rng.c. It uses PCI ids for Intel PCI bridge to search for, since the RNG itself doesn't have a PCI id.
Jeff