File Index
Files and directories
Sign in
FILE

pnp.rst

File preview with syntax highlighting.

linux-6.19.14/Documentation/admin-guide/pnp.rst RESTRUCTUREDTEXT
  1=================================
  2Linux Plug and Play Documentation
  3=================================
  4
  5:Author: Adam Belay <ambx1@neo.rr.com>
  6:Last updated: Oct. 16, 2002
  7
  8
  9Overview
 10--------
 11
 12Plug and Play provides a means of detecting and setting resources for legacy or
 13otherwise unconfigurable devices.  The Linux Plug and Play Layer provides these 
 14services to compatible drivers.
 15
 16
 17The User Interface
 18------------------
 19
 20The Linux Plug and Play user interface provides a means to activate PnP devices
 21for 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 each
 25device's directory:
 26- id - displays a list of support EISA IDs
 27- options - displays possible resource configurations
 28- resources - displays currently allocated resources and allows resource changes
 29
 30activating a device
 31^^^^^^^^^^^^^^^^^^^
 32
 33::
 34
 35	# echo "auto" > resources
 36
 37this will invoke the automatic resource config system to activate the device
 38
 39manually activating a device
 40^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 41
 42::
 43
 44	# echo "manual <depnum> <mode>" > resources
 45
 46	<depnum> - the configuration number
 47	<mode> - static or dynamic
 48		 static = for next boot
 49		 dynamic = now
 50
 51disabling a device
 52^^^^^^^^^^^^^^^^^^
 53
 54::
 55
 56	# echo "disable" > resources
 57
 58
 59EXAMPLE:
 60
 61Suppose you need to activate the floppy disk controller.
 62
 631. change to the proper directory, in my case it is
 64   /driver/bus/pnp/devices/00:0f::
 65
 66	# cd /driver/bus/pnp/devices/00:0f
 67	# cat name
 68	PC standard floppy disk controller
 69
 702. check if the device is already active::
 71
 72	# cat resources
 73	DISABLED
 74
 75  - Notice the string "DISABLED".  This means the device is not active.
 76
 773. check the device's possible configurations (optional)::
 78
 79	# cat options
 80	Dependent: 01 - Priority acceptable
 81	    port 0x3f0-0x3f0, align 0x7, size 0x6, 16-bit address decoding
 82	    port 0x3f7-0x3f7, align 0x0, size 0x1, 16-bit address decoding
 83	    irq 6
 84	    dma 2 8-bit compatible
 85	Dependent: 02 - Priority acceptable
 86	    port 0x370-0x370, align 0x7, size 0x6, 16-bit address decoding
 87	    port 0x377-0x377, align 0x0, size 0x1, 16-bit address decoding
 88	    irq 6
 89	    dma 2 8-bit compatible
 90
 914. now activate the device::
 92
 93	# echo "auto" > resources
 94
 955. finally check if the device is active::
 96
 97	# cat resources
 98	io 0x3f0-0x3f5
 99	io 0x3f7-0x3f7
100	irq 6
101	dma 2
102
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 Layer
113-------------------------------
114
115All Plug and Play drivers, protocols, and services meet at a central location
116called 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_protocol
124  increments the number of uses by one
125
126pnp_put_protocol
127  deincrements the number of uses by one
128
129pnp_register_protocol
130  use this to register a new PnP protocol
131
132pnp_register_driver
133  adds a PnP driver to the Plug and Play Layer
134
135  this includes driver model integration
136  returns zero for success or a negative error number for failure; count
137  calls to the .add() method if you need to know how many devices bind to
138  the driver
139
140pnp_unregister_driver
141  removes a PnP driver from the Plug and Play Layer
142
143
144
145Plug and Play Protocols
146-----------------------
147
148This section contains information for PnP protocol developers.
149
150The following Protocols are currently available in the computing world:
151
152- PNPBIOS:
153    used for system devices such as serial and parallel ports.
154- ISAPNP:
155    provides PnP support for the ISA bus
156- ACPI:
157    among its many uses, ACPI provides information about system level
158    devices.
159
160It is meant to replace the PNPBIOS.  It is not currently supported by Linux
161Plug and Play but it is planned to be in the near future.
162
163
164Requirements for a Linux PnP protocol:
1651. the protocol must use EISA IDs
1662. the protocol must inform the PnP Layer of a device's current configuration
167
168- the ability to set resources is optional but preferred.
169
170The following are PnP protocol related functions:
171
172pnp_add_device
173  use this function to add a PnP device to the PnP layer
174
175  only call this function when all wanted values are set in the pnp_dev
176  structure
177
178pnp_init_device
179  call this to initialize the PnP structure
180
181pnp_remove_device
182  call this to remove a device from the Plug and Play Layer.
183  it will fail if the device is still in use.
184  automatically will free mem used by the device and related structures
185
186pnp_add_id
187  adds an EISA ID to the list of supported IDs for the specified device
188
189For more information consult the source of a protocol such as
190/drivers/pnp/pnpbios/core.c.
191
192
193
194Linux Plug and Play Drivers
195---------------------------
196
197This section contains information for Linux PnP driver developers.
198
199The New Way
200^^^^^^^^^^^
201
2021. first make a list of supported EISA IDS
203
204   ex::
205
206	static const struct pnp_id pnp_dev_table[] = {
207		/* Standard LPT Printer Port */
208		{.id = "PNP0400", .driver_data = 0},
209		/* ECP Printer Port */
210		{.id = "PNP0401", .driver_data = 0},
211		{.id = ""}
212	};
213
214   Please note that the character 'X' can be used as a wild card in the function
215   portion (last four characters).
216
217   ex::
218
219	/* Unknown PnP modems */
220	{	"PNPCXXX",		UNKNOWN_DEV	},
221
222   Supported PnP card IDs can optionally be defined.
223   ex::
224
225	static const struct pnp_id pnp_card_table[] = {
226		{	"ANYDEVS",		0	},
227		{	"",			0	}
228	};
229
2302. Optionally define probe and remove functions.  It may make sense not to
231   define these functions if the driver already has a reliable method of detecting
232   the resources, such as the parport_pc driver.
233
234   ex::
235
236	static int
237	serial_pnp_probe(struct pnp_dev * dev, const struct pnp_id *card_id, const
238			struct pnp_id *dev_id)
239	{
240	. . .
241
242   ex::
243
244	static void serial_pnp_remove(struct pnp_dev * dev)
245	{
246	. . .
247
248   consult /drivers/serial/8250_pnp.c for more information.
249
2503. create a driver structure
251
252   ex::
253
254	static struct pnp_driver serial_pnp_driver = {
255		.name		= "serial",
256		.card_id_table	= pnp_card_table,
257		.id_table	= pnp_dev_table,
258		.probe		= serial_pnp_probe,
259		.remove		= serial_pnp_remove,
260	};
261
262   * name and id_table cannot be NULL.
263
2644. register the driver
265
266   ex::
267
268	static int __init serial8250_pnp_init(void)
269	{
270		return pnp_register_driver(&serial_pnp_driver);
271	}
272
273The Old Way
274^^^^^^^^^^^
275
276A series of compatibility functions have been created to make it easy to convert
277ISAPNP drivers.  They should serve as a temporary solution only.
278
279They are as follows::
280
281	struct pnp_dev *pnp_find_dev(struct pnp_card *card,
282				     unsigned short vendor,
283				     unsigned short function,
284				     struct pnp_dev *from)
285
~/ Read-only file preview.