brintos

brintos / linux-shallow public Read only

0
0
Text · 6.9 KiB · 3eda081 Raw
289 lines · plain
1=================================2Linux Plug and Play Documentation3=================================4 5:Author: Adam Belay <ambx1@neo.rr.com>6:Last updated: Oct. 16, 20027 8 9Overview10--------11 12Plug and Play provides a means of detecting and setting resources for legacy or13otherwise unconfigurable devices.  The Linux Plug and Play Layer provides these 14services to compatible drivers.15 16 17The User Interface18------------------19 20The Linux Plug and Play user interface provides a means to activate PnP devices21for legacy and user level drivers that do not support Linux Plug and Play.  The 22user interface is integrated into sysfs.23 24In addition to the standard sysfs file the following are created in each25device's directory:26- id - displays a list of support EISA IDs27- options - displays possible resource configurations28- resources - displays currently allocated resources and allows resource changes29 30activating a device31^^^^^^^^^^^^^^^^^^^32 33::34 35	# echo "auto" > resources36 37this will invoke the automatic resource config system to activate the device38 39manually activating a device40^^^^^^^^^^^^^^^^^^^^^^^^^^^^41 42::43 44	# echo "manual <depnum> <mode>" > resources45 46	<depnum> - the configuration number47	<mode> - static or dynamic48		 static = for next boot49		 dynamic = now50 51disabling a device52^^^^^^^^^^^^^^^^^^53 54::55 56	# echo "disable" > resources57 58 59EXAMPLE:60 61Suppose you need to activate the floppy disk controller.62 631. change to the proper directory, in my case it is64   /driver/bus/pnp/devices/00:0f::65 66	# cd /driver/bus/pnp/devices/00:0f67	# cat name68	PC standard floppy disk controller69 702. check if the device is already active::71 72	# cat resources73	DISABLED74 75  - Notice the string "DISABLED".  This means the device is not active.76 773. check the device's possible configurations (optional)::78 79	# cat options80	Dependent: 01 - Priority acceptable81	    port 0x3f0-0x3f0, align 0x7, size 0x6, 16-bit address decoding82	    port 0x3f7-0x3f7, align 0x0, size 0x1, 16-bit address decoding83	    irq 684	    dma 2 8-bit compatible85	Dependent: 02 - Priority acceptable86	    port 0x370-0x370, align 0x7, size 0x6, 16-bit address decoding87	    port 0x377-0x377, align 0x0, size 0x1, 16-bit address decoding88	    irq 689	    dma 2 8-bit compatible90 914. now activate the device::92 93	# echo "auto" > resources94 955. finally check if the device is active::96 97	# cat resources98	io 0x3f0-0x3f599	io 0x3f7-0x3f7100	irq 6101	dma 2102 103also there are a series of kernel parameters::104 105	pnp_reserve_irq=irq1[,irq2] ....106	pnp_reserve_dma=dma1[,dma2] ....107	pnp_reserve_io=io1,size1[,io2,size2] ....108	pnp_reserve_mem=mem1,size1[,mem2,size2] ....109 110 111 112The Unified Plug and Play Layer113-------------------------------114 115All Plug and Play drivers, protocols, and services meet at a central location116called the Plug and Play Layer.  This layer is responsible for the exchange of 117information between PnP drivers and PnP protocols.  Thus it automatically 118forwards commands to the proper protocol.  This makes writing PnP drivers 119significantly easier.120 121The following functions are available from the Plug and Play Layer:122 123pnp_get_protocol124  increments the number of uses by one125 126pnp_put_protocol127  deincrements the number of uses by one128 129pnp_register_protocol130  use this to register a new PnP protocol131 132pnp_unregister_protocol133  use this function to remove a PnP protocol from the Plug and Play Layer134 135pnp_register_driver136  adds a PnP driver to the Plug and Play Layer137 138  this includes driver model integration139  returns zero for success or a negative error number for failure; count140  calls to the .add() method if you need to know how many devices bind to141  the driver142 143pnp_unregister_driver144  removes a PnP driver from the Plug and Play Layer145 146 147 148Plug and Play Protocols149-----------------------150 151This section contains information for PnP protocol developers.152 153The following Protocols are currently available in the computing world:154 155- PNPBIOS:156    used for system devices such as serial and parallel ports.157- ISAPNP:158    provides PnP support for the ISA bus159- ACPI:160    among its many uses, ACPI provides information about system level161    devices.162 163It is meant to replace the PNPBIOS.  It is not currently supported by Linux164Plug and Play but it is planned to be in the near future.165 166 167Requirements for a Linux PnP protocol:1681. the protocol must use EISA IDs1692. the protocol must inform the PnP Layer of a device's current configuration170 171- the ability to set resources is optional but preferred.172 173The following are PnP protocol related functions:174 175pnp_add_device176  use this function to add a PnP device to the PnP layer177 178  only call this function when all wanted values are set in the pnp_dev179  structure180 181pnp_init_device182  call this to initialize the PnP structure183 184pnp_remove_device185  call this to remove a device from the Plug and Play Layer.186  it will fail if the device is still in use.187  automatically will free mem used by the device and related structures188 189pnp_add_id190  adds an EISA ID to the list of supported IDs for the specified device191 192For more information consult the source of a protocol such as193/drivers/pnp/pnpbios/core.c.194 195 196 197Linux Plug and Play Drivers198---------------------------199 200This section contains information for Linux PnP driver developers.201 202The New Way203^^^^^^^^^^^204 2051. first make a list of supported EISA IDS206 207   ex::208 209	static const struct pnp_id pnp_dev_table[] = {210		/* Standard LPT Printer Port */211		{.id = "PNP0400", .driver_data = 0},212		/* ECP Printer Port */213		{.id = "PNP0401", .driver_data = 0},214		{.id = ""}215	};216 217   Please note that the character 'X' can be used as a wild card in the function218   portion (last four characters).219 220   ex::221 222	/* Unknown PnP modems */223	{	"PNPCXXX",		UNKNOWN_DEV	},224 225   Supported PnP card IDs can optionally be defined.226   ex::227 228	static const struct pnp_id pnp_card_table[] = {229		{	"ANYDEVS",		0	},230		{	"",			0	}231	};232 2332. Optionally define probe and remove functions.  It may make sense not to234   define these functions if the driver already has a reliable method of detecting235   the resources, such as the parport_pc driver.236 237   ex::238 239	static int240	serial_pnp_probe(struct pnp_dev * dev, const struct pnp_id *card_id, const241			struct pnp_id *dev_id)242	{243	. . .244 245   ex::246 247	static void serial_pnp_remove(struct pnp_dev * dev)248	{249	. . .250 251   consult /drivers/serial/8250_pnp.c for more information.252 2533. create a driver structure254 255   ex::256 257	static struct pnp_driver serial_pnp_driver = {258		.name		= "serial",259		.card_id_table	= pnp_card_table,260		.id_table	= pnp_dev_table,261		.probe		= serial_pnp_probe,262		.remove		= serial_pnp_remove,263	};264 265   * name and id_table cannot be NULL.266 2674. register the driver268 269   ex::270 271	static int __init serial8250_pnp_init(void)272	{273		return pnp_register_driver(&serial_pnp_driver);274	}275 276The Old Way277^^^^^^^^^^^278 279A series of compatibility functions have been created to make it easy to convert280ISAPNP drivers.  They should serve as a temporary solution only.281 282They are as follows::283 284	struct pnp_dev *pnp_find_dev(struct pnp_card *card,285				     unsigned short vendor,286				     unsigned short function,287				     struct pnp_dev *from)288 289