Blame view

Documentation/pnp.txt 7.02 KB
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
1
  =================================
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  Linux Plug and Play Documentation
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
3
  =================================
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
5
6
  :Author: Adam Belay <ambx1@neo.rr.com>
  :Last updated: Oct. 16, 2002
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
  
  
  Overview
  --------
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
11
12
  
  Plug and Play provides a means of detecting and setting resources for legacy or
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
14
  otherwise unconfigurable devices.  The Linux Plug and Play Layer provides these 
  services to compatible drivers.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
16
  The User Interface
  ------------------
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
17
18
  
  The Linux Plug and Play user interface provides a means to activate PnP devices
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
  for legacy and user level drivers that do not support Linux Plug and Play.  The 
b1c7192df   Robert P. J. Day   Documentation: Re...
20
  user interface is integrated into sysfs.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21

b1c7192df   Robert P. J. Day   Documentation: Re...
22
  In addition to the standard sysfs file the following are created in each
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
  device's directory:
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
24
25
26
  - id - displays a list of support EISA IDs
  - options - displays possible resource configurations
  - resources - displays currently allocated resources and allows resource changes
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
28
29
  activating a device
  ^^^^^^^^^^^^^^^^^^^
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
31
32
33
  ::
  
  	# echo "auto" > resources
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
  
  this will invoke the automatic resource config system to activate the device
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
36
37
38
39
40
41
  manually activating a device
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  ::
  
  	# echo "manual <depnum> <mode>" > resources
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
43
44
45
46
  	<depnum> - the configuration number
  	<mode> - static or dynamic
  		 static = for next boot
  		 dynamic = now
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
48
49
  disabling a device
  ^^^^^^^^^^^^^^^^^^
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
51
52
53
  ::
  
  	# echo "disable" > resources
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
56
57
58
  
  
  EXAMPLE:
  
  Suppose you need to activate the floppy disk controller.
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  
  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] ....
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
107
108
109
110
  
  
  
  The Unified Plug and Play Layer
  -------------------------------
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
111
112
  
  All Plug and Play drivers, protocols, and services meet at a central location
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
114
115
116
117
118
119
120
  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
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
121
    increments the number of uses by one
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
122
123
  
  pnp_put_protocol
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
124
    deincrements the number of uses by one
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
125
126
  
  pnp_register_protocol
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
127
    use this to register a new PnP protocol
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
129
  
  pnp_unregister_protocol
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
130
    use this function to remove a PnP protocol from the Plug and Play Layer
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
131
132
  
  pnp_register_driver
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
133
134
135
136
    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
982c60944   Bjorn Helgaas   [PATCH] pnp: PNP:...
137
138
    calls to the .add() method if you need to know how many devices bind to
    the driver
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
140
  
  pnp_unregister_driver
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
141
    removes a PnP driver from the Plug and Play Layer
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
143
144
145
146
  
  
  
  Plug and Play Protocols
  -----------------------
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
147
148
  
  This section contains information for PnP protocol developers.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
150
  
  The following Protocols are currently available in the computing world:
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
151
152
153
154
155
156
157
158
  
  - 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.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
159
160
161
162
163
  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:
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
164
165
  1. the protocol must use EISA IDs
  2. the protocol must inform the PnP Layer of a device's current configuration
a982ac06b   Matt LaPlante   misc doc and kcon...
166
  - the ability to set resources is optional but preferred.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
167
168
169
170
  
  The following are PnP protocol related functions:
  
  pnp_add_device
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
171
172
173
174
    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
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
175
176
  
  pnp_init_device
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
177
    call this to initialize the PnP structure
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
178
179
  
  pnp_remove_device
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
180
181
182
    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
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
183
184
  
  pnp_add_id
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
185
    adds an EISA ID to the list of supported IDs for the specified device
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
186
187
188
189
190
191
192
193
  
  For more information consult the source of a protocol such as
  /drivers/pnp/pnpbios/core.c.
  
  
  
  Linux Plug and Play Drivers
  ---------------------------
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
194
195
  
  This section contains information for Linux PnP driver developers.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
196
197
  
  The New Way
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
  ^^^^^^^^^^^
  
  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::
4ae0edc21   Matt LaPlante   Fix typos in /Doc...
216
  	/* Unknown PnP modems */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
217
  	{	"PNPCXXX",		UNKNOWN_DEV	},
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
     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);
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
268
269
  
  The Old Way
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
270
  ^^^^^^^^^^^
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
271

a64061e10   Thadeu Lima de Souza Cascardo   doc: capitalizati...
272
  A series of compatibility functions have been created to make it easy to convert
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
273
  ISAPNP drivers.  They should serve as a temporary solution only.
9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
274
  They are as follows::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
275

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
276
277
278
  	struct pnp_card *pnp_find_card(unsigned short vendor,
  				       unsigned short device,
  				       struct pnp_card *from)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279

9a4aa7bfc   Mauro Carvalho Chehab   pnp.txt: standard...
280
281
282
283
  	struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  				     unsigned short vendor,
  				     unsigned short function,
  				     struct pnp_dev *from)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
284