blob: bab2d10631f00dd88d702a5d836d7b637ffbacb4 [file] [log] [blame]
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03001=================================
Linus Torvalds1da177e2005-04-16 15:20:36 -07002Linux Plug and Play Documentation
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03003=================================
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03005:Author: Adam Belay <ambx1@neo.rr.com>
6:Last updated: Oct. 16, 2002
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8
9Overview
10--------
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030011
12Plug and Play provides a means of detecting and setting resources for legacy or
Linus Torvalds1da177e2005-04-16 15:20:36 -070013otherwise unconfigurable devices. The Linux Plug and Play Layer provides these
14services to compatible drivers.
15
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017The User Interface
18------------------
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030019
20The Linux Plug and Play user interface provides a means to activate PnP devices
Linus Torvalds1da177e2005-04-16 15:20:36 -070021for legacy and user level drivers that do not support Linux Plug and Play. The
Robert P. J. Dayb1c71922007-11-07 04:09:46 -050022user interface is integrated into sysfs.
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Robert P. J. Dayb1c71922007-11-07 04:09:46 -050024In addition to the standard sysfs file the following are created in each
Linus Torvalds1da177e2005-04-16 15:20:36 -070025device's directory:
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030026- id - displays a list of support EISA IDs
27- options - displays possible resource configurations
28- resources - displays currently allocated resources and allows resource changes
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030030activating a device
31^^^^^^^^^^^^^^^^^^^
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030033::
34
35 # echo "auto" > resources
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37this will invoke the automatic resource config system to activate the device
38
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030039manually activating a device
40^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030042::
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030044 # echo "manual <depnum> <mode>" > resources
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030046 <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
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58
59EXAMPLE:
60
61Suppose you need to activate the floppy disk controller.
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300631. change to the proper directory, in my case it is
64 /driver/bus/pnp/devices/00:0f::
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030066 # cd /driver/bus/pnp/devices/00:0f
67 # cat name
68 PC standard floppy disk controller
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300702. check if the device is already active::
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030072 # cat resources
73 DISABLED
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -030075 - Notice the string "DISABLED". This means the device is not active.
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300773. 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] ....
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110
111
112The Unified Plug and Play Layer
113-------------------------------
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300114
115All Plug and Play drivers, protocols, and services meet at a central location
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116called 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
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300124 increments the number of uses by one
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126pnp_put_protocol
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300127 deincrements the number of uses by one
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129pnp_register_protocol
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300130 use this to register a new PnP protocol
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132pnp_unregister_protocol
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300133 use this function to remove a PnP protocol from the Plug and Play Layer
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
135pnp_register_driver
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300136 adds a PnP driver to the Plug and Play Layer
137
138 this includes driver model integration
139 returns zero for success or a negative error number for failure; count
Bjorn Helgaas982c6092006-03-27 01:17:08 -0800140 calls to the .add() method if you need to know how many devices bind to
141 the driver
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143pnp_unregister_driver
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300144 removes a PnP driver from the Plug and Play Layer
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146
147
148Plug and Play Protocols
149-----------------------
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300150
151This section contains information for PnP protocol developers.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153The following Protocols are currently available in the computing world:
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300154
155- PNPBIOS:
156 used for system devices such as serial and parallel ports.
157- ISAPNP:
158 provides PnP support for the ISA bus
159- ACPI:
160 among its many uses, ACPI provides information about system level
161 devices.
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163It is meant to replace the PNPBIOS. It is not currently supported by Linux
164Plug and Play but it is planned to be in the near future.
165
166
167Requirements for a Linux PnP protocol:
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03001681. the protocol must use EISA IDs
1692. the protocol must inform the PnP Layer of a device's current configuration
170
Matt LaPlantea982ac02007-05-09 07:35:06 +0200171- the ability to set resources is optional but preferred.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173The following are PnP protocol related functions:
174
175pnp_add_device
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300176 use this function to add a PnP device to the PnP layer
177
178 only call this function when all wanted values are set in the pnp_dev
179 structure
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181pnp_init_device
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300182 call this to initialize the PnP structure
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184pnp_remove_device
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300185 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 structures
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189pnp_add_id
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300190 adds an EISA ID to the list of supported IDs for the specified device
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192For more information consult the source of a protocol such as
193/drivers/pnp/pnpbios/core.c.
194
195
196
197Linux Plug and Play Drivers
198---------------------------
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300199
200This section contains information for Linux PnP driver developers.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202The New Way
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300203^^^^^^^^^^^
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03002051. first make a list of supported EISA IDS
206
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 function
218 portion (last four characters).
219
220 ex::
221
Matt LaPlante4ae0edc2006-11-30 04:58:40 +0100222 /* Unknown PnP modems */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 { "PNPCXXX", UNKNOWN_DEV },
224
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300225 Supported PnP card IDs can optionally be defined.
226 ex::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300228 static const struct pnp_id pnp_card_table[] = {
229 { "ANYDEVS", 0 },
230 { "", 0 }
231 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03002332. Optionally define probe and remove functions. It may make sense not to
234 define these functions if the driver already has a reliable method of detecting
235 the resources, such as the parport_pc driver.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300237 ex::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300239 static int
240 serial_pnp_probe(struct pnp_dev * dev, const struct pnp_id *card_id, const
241 struct pnp_id *dev_id)
242 {
243 . . .
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300245 ex::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300247 static void serial_pnp_remove(struct pnp_dev * dev)
248 {
249 . . .
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300251 consult /drivers/serial/8250_pnp.c for more information.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -03002533. create a driver structure
254
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 driver
268
269 ex::
270
271 static int __init serial8250_pnp_init(void)
272 {
273 return pnp_register_driver(&serial_pnp_driver);
274 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
276The Old Way
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300277^^^^^^^^^^^
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Thadeu Lima de Souza Cascardoa64061e2010-01-17 19:26:47 -0200279A series of compatibility functions have been created to make it easy to convert
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280ISAPNP drivers. They should serve as a temporary solution only.
281
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300282They are as follows::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300284 struct pnp_card *pnp_find_card(unsigned short vendor,
285 unsigned short device,
286 struct pnp_card *from)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Mauro Carvalho Chehab9a4aa7b2017-05-16 11:23:58 -0300288 struct pnp_dev *pnp_find_dev(struct pnp_card *card,
289 unsigned short vendor,
290 unsigned short function,
291 struct pnp_dev *from)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292