2017-05-16 08:23:58 -06:00
|
|
|
=================================
|
2005-04-16 16:20:36 -06:00
|
|
|
Linux Plug and Play Documentation
|
2017-05-16 08:23:58 -06:00
|
|
|
=================================
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
:Author: Adam Belay <ambx1@neo.rr.com>
|
|
|
|
:Last updated: Oct. 16, 2002
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
Overview
|
|
|
|
--------
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
Plug and Play provides a means of detecting and setting resources for legacy or
|
2005-04-16 16:20:36 -06:00
|
|
|
otherwise unconfigurable devices. The Linux Plug and Play Layer provides these
|
|
|
|
services to compatible drivers.
|
|
|
|
|
|
|
|
|
|
|
|
The User Interface
|
|
|
|
------------------
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
The Linux Plug and Play user interface provides a means to activate PnP devices
|
2005-04-16 16:20:36 -06:00
|
|
|
for legacy and user level drivers that do not support Linux Plug and Play. The
|
2007-11-07 02:09:46 -07:00
|
|
|
user interface is integrated into sysfs.
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-11-07 02:09:46 -07:00
|
|
|
In addition to the standard sysfs file the following are created in each
|
2005-04-16 16:20:36 -06:00
|
|
|
device's directory:
|
2017-05-16 08:23:58 -06:00
|
|
|
- id - displays a list of support EISA IDs
|
|
|
|
- options - displays possible resource configurations
|
|
|
|
- resources - displays currently allocated resources and allows resource changes
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
activating a device
|
|
|
|
^^^^^^^^^^^^^^^^^^^
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
::
|
|
|
|
|
|
|
|
# echo "auto" > resources
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
this will invoke the automatic resource config system to activate the device
|
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
manually activating a device
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
# echo "manual <depnum> <mode>" > resources
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
<depnum> - the configuration number
|
|
|
|
<mode> - static or dynamic
|
|
|
|
static = for next boot
|
|
|
|
dynamic = now
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
disabling a device
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
::
|
|
|
|
|
|
|
|
# echo "disable" > resources
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
EXAMPLE:
|
|
|
|
|
|
|
|
Suppose you need to activate the floppy disk controller.
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
1. change to the proper directory, in my case it is
|
|
|
|
/driver/bus/pnp/devices/00:0f::
|
|
|
|
|
|
|
|
# cd /driver/bus/pnp/devices/00:0f
|
|
|
|
# cat name
|
|
|
|
PC standard floppy disk controller
|
|
|
|
|
|
|
|
2. check if the device is already active::
|
|
|
|
|
|
|
|
# cat resources
|
|
|
|
DISABLED
|
|
|
|
|
|
|
|
- Notice the string "DISABLED". This means the device is not active.
|
|
|
|
|
|
|
|
3. check the device's possible configurations (optional)::
|
|
|
|
|
|
|
|
# cat options
|
|
|
|
Dependent: 01 - Priority acceptable
|
|
|
|
port 0x3f0-0x3f0, align 0x7, size 0x6, 16-bit address decoding
|
|
|
|
port 0x3f7-0x3f7, align 0x0, size 0x1, 16-bit address decoding
|
|
|
|
irq 6
|
|
|
|
dma 2 8-bit compatible
|
|
|
|
Dependent: 02 - Priority acceptable
|
|
|
|
port 0x370-0x370, align 0x7, size 0x6, 16-bit address decoding
|
|
|
|
port 0x377-0x377, align 0x0, size 0x1, 16-bit address decoding
|
|
|
|
irq 6
|
|
|
|
dma 2 8-bit compatible
|
|
|
|
|
|
|
|
4. now activate the device::
|
|
|
|
|
|
|
|
# echo "auto" > resources
|
|
|
|
|
|
|
|
5. finally check if the device is active::
|
|
|
|
|
|
|
|
# cat resources
|
|
|
|
io 0x3f0-0x3f5
|
|
|
|
io 0x3f7-0x3f7
|
|
|
|
irq 6
|
|
|
|
dma 2
|
|
|
|
|
|
|
|
also there are a series of kernel parameters::
|
|
|
|
|
|
|
|
pnp_reserve_irq=irq1[,irq2] ....
|
|
|
|
pnp_reserve_dma=dma1[,dma2] ....
|
|
|
|
pnp_reserve_io=io1,size1[,io2,size2] ....
|
|
|
|
pnp_reserve_mem=mem1,size1[,mem2,size2] ....
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The Unified Plug and Play Layer
|
|
|
|
-------------------------------
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
All Plug and Play drivers, protocols, and services meet at a central location
|
2005-04-16 16:20:36 -06:00
|
|
|
called the Plug and Play Layer. This layer is responsible for the exchange of
|
|
|
|
information between PnP drivers and PnP protocols. Thus it automatically
|
|
|
|
forwards commands to the proper protocol. This makes writing PnP drivers
|
|
|
|
significantly easier.
|
|
|
|
|
|
|
|
The following functions are available from the Plug and Play Layer:
|
|
|
|
|
|
|
|
pnp_get_protocol
|
2017-05-16 08:23:58 -06:00
|
|
|
increments the number of uses by one
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_put_protocol
|
2017-05-16 08:23:58 -06:00
|
|
|
deincrements the number of uses by one
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_register_protocol
|
2017-05-16 08:23:58 -06:00
|
|
|
use this to register a new PnP protocol
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_unregister_protocol
|
2017-05-16 08:23:58 -06:00
|
|
|
use this function to remove a PnP protocol from the Plug and Play Layer
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_register_driver
|
2017-05-16 08:23:58 -06:00
|
|
|
adds a PnP driver to the Plug and Play Layer
|
|
|
|
|
|
|
|
this includes driver model integration
|
|
|
|
returns zero for success or a negative error number for failure; count
|
2006-03-27 02:17:08 -07:00
|
|
|
calls to the .add() method if you need to know how many devices bind to
|
|
|
|
the driver
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_unregister_driver
|
2017-05-16 08:23:58 -06:00
|
|
|
removes a PnP driver from the Plug and Play Layer
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Plug and Play Protocols
|
|
|
|
-----------------------
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
This section contains information for PnP protocol developers.
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
The following Protocols are currently available in the computing world:
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
- PNPBIOS:
|
|
|
|
used for system devices such as serial and parallel ports.
|
|
|
|
- ISAPNP:
|
|
|
|
provides PnP support for the ISA bus
|
|
|
|
- ACPI:
|
|
|
|
among its many uses, ACPI provides information about system level
|
|
|
|
devices.
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
It is meant to replace the PNPBIOS. It is not currently supported by Linux
|
|
|
|
Plug and Play but it is planned to be in the near future.
|
|
|
|
|
|
|
|
|
|
|
|
Requirements for a Linux PnP protocol:
|
2017-05-16 08:23:58 -06:00
|
|
|
1. the protocol must use EISA IDs
|
|
|
|
2. the protocol must inform the PnP Layer of a device's current configuration
|
|
|
|
|
2007-05-08 23:35:06 -06:00
|
|
|
- the ability to set resources is optional but preferred.
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
The following are PnP protocol related functions:
|
|
|
|
|
|
|
|
pnp_add_device
|
2017-05-16 08:23:58 -06:00
|
|
|
use this function to add a PnP device to the PnP layer
|
|
|
|
|
|
|
|
only call this function when all wanted values are set in the pnp_dev
|
|
|
|
structure
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_init_device
|
2017-05-16 08:23:58 -06:00
|
|
|
call this to initialize the PnP structure
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_remove_device
|
2017-05-16 08:23:58 -06:00
|
|
|
call this to remove a device from the Plug and Play Layer.
|
|
|
|
it will fail if the device is still in use.
|
|
|
|
automatically will free mem used by the device and related structures
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
pnp_add_id
|
2017-05-16 08:23:58 -06:00
|
|
|
adds an EISA ID to the list of supported IDs for the specified device
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
For more information consult the source of a protocol such as
|
|
|
|
/drivers/pnp/pnpbios/core.c.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Linux Plug and Play Drivers
|
|
|
|
---------------------------
|
2017-05-16 08:23:58 -06:00
|
|
|
|
|
|
|
This section contains information for Linux PnP driver developers.
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
The New Way
|
2017-05-16 08:23:58 -06:00
|
|
|
^^^^^^^^^^^
|
|
|
|
|
|
|
|
1. first make a list of supported EISA IDS
|
|
|
|
|
|
|
|
ex::
|
|
|
|
|
|
|
|
static const struct pnp_id pnp_dev_table[] = {
|
|
|
|
/* Standard LPT Printer Port */
|
|
|
|
{.id = "PNP0400", .driver_data = 0},
|
|
|
|
/* ECP Printer Port */
|
|
|
|
{.id = "PNP0401", .driver_data = 0},
|
|
|
|
{.id = ""}
|
|
|
|
};
|
|
|
|
|
|
|
|
Please note that the character 'X' can be used as a wild card in the function
|
|
|
|
portion (last four characters).
|
|
|
|
|
|
|
|
ex::
|
|
|
|
|
2006-11-29 20:58:40 -07:00
|
|
|
/* Unknown PnP modems */
|
2005-04-16 16:20:36 -06:00
|
|
|
{ "PNPCXXX", UNKNOWN_DEV },
|
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
Supported PnP card IDs can optionally be defined.
|
|
|
|
ex::
|
|
|
|
|
|
|
|
static const struct pnp_id pnp_card_table[] = {
|
|
|
|
{ "ANYDEVS", 0 },
|
|
|
|
{ "", 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
2. Optionally define probe and remove functions. It may make sense not to
|
|
|
|
define these functions if the driver already has a reliable method of detecting
|
|
|
|
the resources, such as the parport_pc driver.
|
|
|
|
|
|
|
|
ex::
|
|
|
|
|
|
|
|
static int
|
|
|
|
serial_pnp_probe(struct pnp_dev * dev, const struct pnp_id *card_id, const
|
|
|
|
struct pnp_id *dev_id)
|
|
|
|
{
|
|
|
|
. . .
|
|
|
|
|
|
|
|
ex::
|
|
|
|
|
|
|
|
static void serial_pnp_remove(struct pnp_dev * dev)
|
|
|
|
{
|
|
|
|
. . .
|
|
|
|
|
|
|
|
consult /drivers/serial/8250_pnp.c for more information.
|
|
|
|
|
|
|
|
3. create a driver structure
|
|
|
|
|
|
|
|
ex::
|
|
|
|
|
|
|
|
static struct pnp_driver serial_pnp_driver = {
|
|
|
|
.name = "serial",
|
|
|
|
.card_id_table = pnp_card_table,
|
|
|
|
.id_table = pnp_dev_table,
|
|
|
|
.probe = serial_pnp_probe,
|
|
|
|
.remove = serial_pnp_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
* name and id_table cannot be NULL.
|
|
|
|
|
|
|
|
4. register the driver
|
|
|
|
|
|
|
|
ex::
|
|
|
|
|
|
|
|
static int __init serial8250_pnp_init(void)
|
|
|
|
{
|
|
|
|
return pnp_register_driver(&serial_pnp_driver);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
The Old Way
|
2017-05-16 08:23:58 -06:00
|
|
|
^^^^^^^^^^^
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2010-01-17 14:26:47 -07:00
|
|
|
A series of compatibility functions have been created to make it easy to convert
|
2005-04-16 16:20:36 -06:00
|
|
|
ISAPNP drivers. They should serve as a temporary solution only.
|
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
They are as follows::
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
struct pnp_card *pnp_find_card(unsigned short vendor,
|
|
|
|
unsigned short device,
|
|
|
|
struct pnp_card *from)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-05-16 08:23:58 -06:00
|
|
|
struct pnp_dev *pnp_find_dev(struct pnp_card *card,
|
|
|
|
unsigned short vendor,
|
|
|
|
unsigned short function,
|
|
|
|
struct pnp_dev *from)
|
2005-04-16 16:20:36 -06:00
|
|
|
|