1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ACPI support for PNP bus type
4 *
5 * Copyright (C) 2014, Intel Corporation
6 * Authors: Zhang Rui <rui.zhang@intel.com>
7 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 */
9
10 #include <linux/acpi.h>
11 #include <linux/module.h>
12 #include <linux/ctype.h>
13
14 #include "internal.h"
15
16 static const struct acpi_device_id acpi_pnp_device_ids[] = {
17 /* pata_isapnp */
18 {"PNP0600"}, /* Generic ESDI/IDE/ATA compatible hard disk controller */
19 /* floppy */
20 {"PNP0700"},
21 /* tpm_inf_pnp */
22 {"IFX0101"}, /* Infineon TPMs */
23 {"IFX0102"}, /* Infineon TPMs */
24 /*tpm_tis */
25 {"PNP0C31"}, /* TPM */
26 {"ATM1200"}, /* Atmel */
27 {"IFX0102"}, /* Infineon */
28 {"BCM0101"}, /* Broadcom */
29 {"BCM0102"}, /* Broadcom */
30 {"NSC1200"}, /* National */
31 {"ICO0102"}, /* Intel */
32 /* ide */
33 {"PNP0600"}, /* Generic ESDI/IDE/ATA compatible hard disk controller */
34 /* ns558 */
35 {"ASB16fd"}, /* AdLib NSC16 */
36 {"AZT3001"}, /* AZT1008 */
37 {"CDC0001"}, /* Opl3-SAx */
38 {"CSC0001"}, /* CS4232 */
39 {"CSC000f"}, /* CS4236 */
40 {"CSC0101"}, /* CS4327 */
41 {"CTL7001"}, /* SB16 */
42 {"CTL7002"}, /* AWE64 */
43 {"CTL7005"}, /* Vibra16 */
44 {"ENS2020"}, /* SoundscapeVIVO */
45 {"ESS0001"}, /* ES1869 */
46 {"ESS0005"}, /* ES1878 */
47 {"ESS6880"}, /* ES688 */
48 {"IBM0012"}, /* CS4232 */
49 {"OPT0001"}, /* OPTi Audio16 */
50 {"YMH0006"}, /* Opl3-SA */
51 {"YMH0022"}, /* Opl3-SAx */
52 {"PNPb02f"}, /* Generic */
53 /* i8042 kbd */
54 {"PNP0300"},
55 {"PNP0301"},
56 {"PNP0302"},
57 {"PNP0303"},
58 {"PNP0304"},
59 {"PNP0305"},
60 {"PNP0306"},
61 {"PNP0309"},
62 {"PNP030a"},
63 {"PNP030b"},
64 {"PNP0320"},
65 {"PNP0343"},
66 {"PNP0344"},
67 {"PNP0345"},
68 {"CPQA0D7"},
69 /* i8042 aux */
70 {"AUI0200"},
71 {"FJC6000"},
72 {"FJC6001"},
73 {"PNP0f03"},
74 {"PNP0f0b"},
75 {"PNP0f0e"},
76 {"PNP0f12"},
77 {"PNP0f13"},
78 {"PNP0f19"},
79 {"PNP0f1c"},
80 {"SYN0801"},
81 /* fcpnp */
82 {"AVM0900"},
83 /* radio-cadet */
84 {"MSM0c24"}, /* ADS Cadet AM/FM Radio Card */
85 /* radio-gemtek */
86 {"ADS7183"}, /* AOpen FX-3D/Pro Radio */
87 /* radio-sf16fmr2 */
88 {"MFRad13"}, /* tuner subdevice of SF16-FMD2 */
89 /* ene_ir */
90 {"ENE0100"},
91 {"ENE0200"},
92 {"ENE0201"},
93 {"ENE0202"},
94 /* fintek-cir */
95 {"FIT0002"}, /* CIR */
96 /* ite-cir */
97 {"ITE8704"}, /* Default model */
98 {"ITE8713"}, /* CIR found in EEEBox 1501U */
99 {"ITE8708"}, /* Bridged IT8512 */
100 {"ITE8709"}, /* SRAM-Bridged IT8512 */
101 /* nuvoton-cir */
102 {"WEC0530"}, /* CIR */
103 {"NTN0530"}, /* CIR for new chip's pnp id */
104 /* Winbond CIR */
105 {"WEC1022"},
106 /* wbsd */
107 {"WEC0517"},
108 {"WEC0518"},
109 /* Winbond CIR */
110 {"TCM5090"}, /* 3Com Etherlink III (TP) */
111 {"TCM5091"}, /* 3Com Etherlink III */
112 {"TCM5094"}, /* 3Com Etherlink III (combo) */
113 {"TCM5095"}, /* 3Com Etherlink III (TPO) */
114 {"TCM5098"}, /* 3Com Etherlink III (TPC) */
115 {"PNP80f7"}, /* 3Com Etherlink III compatible */
116 {"PNP80f8"}, /* 3Com Etherlink III compatible */
117 /* nsc-ircc */
118 {"NSC6001"},
119 {"HWPC224"},
120 {"IBM0071"},
121 /* smsc-ircc2 */
122 {"SMCf010"},
123 /* parport_pc */
124 {"PNP0400"}, /* Standard LPT Printer Port */
125 {"PNP0401"}, /* ECP Printer Port */
126 /* apple-gmux */
127 {"APP000B"},
128 /* rtc_cmos */
129 {"PNP0b00"},
130 {"PNP0b01"},
131 {"PNP0b02"},
132 /* c6xdigio */
133 {"PNP0400"}, /* Standard LPT Printer Port */
134 {"PNP0401"}, /* ECP Printer Port */
135 /* ni_atmio.c */
136 {"NIC1900"},
137 {"NIC2400"},
138 {"NIC2500"},
139 {"NIC2600"},
140 {"NIC2700"},
141 /* serial */
142 {"AAC000F"}, /* Archtek America Corp. Archtek SmartLink Modem 3334BT Plug & Play */
143 {"ADC0001"}, /* Anchor Datacomm BV. SXPro 144 External Data Fax Modem Plug & Play */
144 {"ADC0002"}, /* SXPro 288 External Data Fax Modem Plug & Play */
145 {"AEI0250"}, /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
146 {"AEI1240"}, /* Actiontec ISA PNP 56K X2 Fax Modem */
147 {"AKY1021"}, /* Rockwell 56K ACF II Fax+Data+Voice Modem */
148 {"ALI5123"}, /* ALi Fast Infrared Controller */
149 {"AZT4001"}, /* AZT3005 PnP SOUND DEVICE */
150 {"BDP3336"}, /* Best Data Products Inc. Smart One 336F PnP Modem */
151 {"BRI0A49"}, /* Boca Complete Ofc Communicator 14.4 Data-FAX */
152 {"BRI1400"}, /* Boca Research 33,600 ACF Modem */
153 {"BRI3400"}, /* Boca 33.6 Kbps Internal FD34FSVD */
154 {"CPI4050"}, /* Computer Peripherals Inc. EuroViVa CommCenter-33.6 SP PnP */
155 {"CTL3001"}, /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
156 {"CTL3011"}, /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
157 {"DAV0336"}, /* Davicom ISA 33.6K Modem */
158 {"DMB1032"}, /* Creative Modem Blaster Flash56 DI5601-1 */
159 {"DMB2001"}, /* Creative Modem Blaster V.90 DI5660 */
160 {"ETT0002"}, /* E-Tech CyberBULLET PC56RVP */
161 {"FUJ0202"}, /* Fujitsu 33600 PnP-I2 R Plug & Play */
162 {"FUJ0205"}, /* Fujitsu FMV-FX431 Plug & Play */
163 {"FUJ0206"}, /* Fujitsu 33600 PnP-I4 R Plug & Play */
164 {"FUJ0209"}, /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
165 {"GVC000F"}, /* Archtek SmartLink Modem 3334BT Plug & Play */
166 {"GVC0303"}, /* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
167 {"HAY0001"}, /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
168 {"HAY000C"}, /* Hayes Optima 336 V.34 + FAX + Voice PnP */
169 {"HAY000D"}, /* Hayes Optima 336B V.34 + FAX + Voice PnP */
170 {"HAY5670"}, /* Hayes Accura 56K Ext Fax Modem PnP */
171 {"HAY5674"}, /* Hayes Accura 56K Ext Fax Modem PnP */
172 {"HAY5675"}, /* Hayes Accura 56K Fax Modem PnP */
173 {"HAYF000"}, /* Hayes 288, V.34 + FAX */
174 {"HAYF001"}, /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
175 {"IBM0033"}, /* IBM Thinkpad 701 Internal Modem Voice */
176 {"PNP4972"}, /* Intermec CV60 touchscreen port */
177 {"IXDC801"}, /* Intertex 28k8 33k6 Voice EXT PnP */
178 {"IXDC901"}, /* Intertex 33k6 56k Voice EXT PnP */
179 {"IXDD801"}, /* Intertex 28k8 33k6 Voice SP EXT PnP */
180 {"IXDD901"}, /* Intertex 33k6 56k Voice SP EXT PnP */
181 {"IXDF401"}, /* Intertex 28k8 33k6 Voice SP INT PnP */
182 {"IXDF801"}, /* Intertex 28k8 33k6 Voice SP EXT PnP */
183 {"IXDF901"}, /* Intertex 33k6 56k Voice SP EXT PnP */
184 {"KOR4522"}, /* KORTEX 28800 Externe PnP */
185 {"KORF661"}, /* KXPro 33.6 Vocal ASVD PnP */
186 {"LAS4040"}, /* LASAT Internet 33600 PnP */
187 {"LAS4540"}, /* Lasat Safire 560 PnP */
188 {"LAS5440"}, /* Lasat Safire 336 PnP */
189 {"MNP0281"}, /* Microcom TravelPorte FAST V.34 Plug & Play */
190 {"MNP0336"}, /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
191 {"MNP0339"}, /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
192 {"MNP0342"}, /* Microcom DeskPorte 28.8P Plug & Play */
193 {"MNP0500"}, /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
194 {"MNP0501"}, /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
195 {"MNP0502"}, /* Microcom DeskPorte 28.8S Internal Plug & Play */
196 {"MOT1105"}, /* Motorola BitSURFR Plug & Play */
197 {"MOT1111"}, /* Motorola TA210 Plug & Play */
198 {"MOT1114"}, /* Motorola HMTA 200 (ISDN) Plug & Play */
199 {"MOT1115"}, /* Motorola BitSURFR Plug & Play */
200 {"MOT1190"}, /* Motorola Lifestyle 28.8 Internal */
201 {"MOT1501"}, /* Motorola V.3400 Plug & Play */
202 {"MOT1502"}, /* Motorola Lifestyle 28.8 V.34 Plug & Play */
203 {"MOT1505"}, /* Motorola Power 28.8 V.34 Plug & Play */
204 {"MOT1509"}, /* Motorola ModemSURFR External 28.8 Plug & Play */
205 {"MOT150A"}, /* Motorola Premier 33.6 Desktop Plug & Play */
206 {"MOT150F"}, /* Motorola VoiceSURFR 56K External PnP */
207 {"MOT1510"}, /* Motorola ModemSURFR 56K External PnP */
208 {"MOT1550"}, /* Motorola ModemSURFR 56K Internal PnP */
209 {"MOT1560"}, /* Motorola ModemSURFR Internal 28.8 Plug & Play */
210 {"MOT1580"}, /* Motorola Premier 33.6 Internal Plug & Play */
211 {"MOT15B0"}, /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
212 {"MOT15F0"}, /* Motorola VoiceSURFR 56K Internal PnP */
213 {"MVX00A1"}, /* Deskline K56 Phone System PnP */
214 {"MVX00F2"}, /* PC Rider K56 Phone System PnP */
215 {"nEC8241"}, /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
216 {"PMC2430"}, /* Pace 56 Voice Internal Plug & Play Modem */
217 {"PNP0500"}, /* Generic standard PC COM port */
218 {"PNP0501"}, /* Generic 16550A-compatible COM port */
219 {"PNPC000"}, /* Compaq 14400 Modem */
220 {"PNPC001"}, /* Compaq 2400/9600 Modem */
221 {"PNPC031"}, /* Dial-Up Networking Serial Cable between 2 PCs */
222 {"PNPC032"}, /* Dial-Up Networking Parallel Cable between 2 PCs */
223 {"PNPC100"}, /* Standard 9600 bps Modem */
224 {"PNPC101"}, /* Standard 14400 bps Modem */
225 {"PNPC102"}, /* Standard 28800 bps Modem */
226 {"PNPC103"}, /* Standard Modem */
227 {"PNPC104"}, /* Standard 9600 bps Modem */
228 {"PNPC105"}, /* Standard 14400 bps Modem */
229 {"PNPC106"}, /* Standard 28800 bps Modem */
230 {"PNPC107"}, /* Standard Modem */
231 {"PNPC108"}, /* Standard 9600 bps Modem */
232 {"PNPC109"}, /* Standard 14400 bps Modem */
233 {"PNPC10A"}, /* Standard 28800 bps Modem */
234 {"PNPC10B"}, /* Standard Modem */
235 {"PNPC10C"}, /* Standard 9600 bps Modem */
236 {"PNPC10D"}, /* Standard 14400 bps Modem */
237 {"PNPC10E"}, /* Standard 28800 bps Modem */
238 {"PNPC10F"}, /* Standard Modem */
239 {"PNP2000"}, /* Standard PCMCIA Card Modem */
240 {"ROK0030"}, /* Rockwell 33.6 DPF Internal PnP, Modular Technology 33.6 Internal PnP */
241 {"ROK0100"}, /* KORTEX 14400 Externe PnP */
242 {"ROK4120"}, /* Rockwell 28.8 */
243 {"ROK4920"}, /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
244 {"RSS00A0"}, /* Rockwell 33.6 DPF External PnP, BT Prologue 33.6 External PnP, Modular Technology 33.6 External PnP */
245 {"RSS0262"}, /* Viking 56K FAX INT */
246 {"RSS0250"}, /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
247 {"SUP1310"}, /* SupraExpress 28.8 Data/Fax PnP modem */
248 {"SUP1381"}, /* SupraExpress 336i PnP Voice Modem */
249 {"SUP1421"}, /* SupraExpress 33.6 Data/Fax PnP modem */
250 {"SUP1590"}, /* SupraExpress 33.6 Data/Fax PnP modem */
251 {"SUP1620"}, /* SupraExpress 336i Sp ASVD */
252 {"SUP1760"}, /* SupraExpress 33.6 Data/Fax PnP modem */
253 {"SUP2171"}, /* SupraExpress 56i Sp Intl */
254 {"TEX0011"}, /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
255 {"UAC000F"}, /* Archtek SmartLink Modem 3334BT Plug & Play */
256 {"USR0000"}, /* 3Com Corp. Gateway Telepath IIvi 33.6 */
257 {"USR0002"}, /* U.S. Robotics Sporster 33.6K Fax INT PnP */
258 {"USR0004"}, /* Sportster Vi 14.4 PnP FAX Voicemail */
259 {"USR0006"}, /* U.S. Robotics 33.6K Voice INT PnP */
260 {"USR0007"}, /* U.S. Robotics 33.6K Voice EXT PnP */
261 {"USR0009"}, /* U.S. Robotics Courier V.Everything INT PnP */
262 {"USR2002"}, /* U.S. Robotics 33.6K Voice INT PnP */
263 {"USR2070"}, /* U.S. Robotics 56K Voice INT PnP */
264 {"USR2080"}, /* U.S. Robotics 56K Voice EXT PnP */
265 {"USR3031"}, /* U.S. Robotics 56K FAX INT */
266 {"USR3050"}, /* U.S. Robotics 56K FAX INT */
267 {"USR3070"}, /* U.S. Robotics 56K Voice INT PnP */
268 {"USR3080"}, /* U.S. Robotics 56K Voice EXT PnP */
269 {"USR3090"}, /* U.S. Robotics 56K Voice INT PnP */
270 {"USR9100"}, /* U.S. Robotics 56K Message */
271 {"USR9160"}, /* U.S. Robotics 56K FAX EXT PnP */
272 {"USR9170"}, /* U.S. Robotics 56K FAX INT PnP */
273 {"USR9180"}, /* U.S. Robotics 56K Voice EXT PnP */
274 {"USR9190"}, /* U.S. Robotics 56K Voice INT PnP */
275 {"WACFXXX"}, /* Wacom tablets */
276 {"FPI2002"}, /* Compaq touchscreen */
277 {"FUJ02B2"}, /* Fujitsu Stylistic touchscreens */
278 {"FUJ02B3"},
279 {"FUJ02B4"}, /* Fujitsu Stylistic LT touchscreens */
280 {"FUJ02B6"}, /* Passive Fujitsu Stylistic touchscreens */
281 {"FUJ02B7"},
282 {"FUJ02B8"},
283 {"FUJ02B9"},
284 {"FUJ02BC"},
285 {"FUJ02E5"}, /* Fujitsu Wacom Tablet PC device */
286 {"FUJ02E6"}, /* Fujitsu P-series tablet PC device */
287 {"FUJ02E7"}, /* Fujitsu Wacom 2FGT Tablet PC device */
288 {"FUJ02E9"}, /* Fujitsu Wacom 1FGT Tablet PC device */
289 {"LTS0001"}, /* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */
290 {"WCI0003"}, /* Rockwell's (PORALiNK) 33600 INT PNP */
291 {"WEC1022"}, /* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */
292 /* scl200wdt */
293 {"NSC0800"}, /* National Semiconductor PC87307/PC97307 watchdog component */
294 /* mpu401 */
295 {"PNPb006"},
296 /* cs423x-pnpbios */
297 {"CSC0100"},
298 {"CSC0103"},
299 {"CSC0110"},
300 {"CSC0000"},
301 {"GIM0100"}, /* Guillemot Turtlebeach something appears to be cs4232 compatible */
302 /* es18xx-pnpbios */
303 {"ESS1869"},
304 {"ESS1879"},
305 /* snd-opl3sa2-pnpbios */
306 {"YMH0021"},
307 {"NMX2210"}, /* Gateway Solo 2500 */
308 {""},
309 };
310
matching_id(const char * idstr,const char * list_id)311 static bool matching_id(const char *idstr, const char *list_id)
312 {
313 int i;
314
315 if (strlen(idstr) != strlen(list_id))
316 return false;
317
318 if (memcmp(idstr, list_id, 3))
319 return false;
320
321 for (i = 3; i < 7; i++) {
322 char c = toupper(idstr[i]);
323
324 if (!isxdigit(c)
325 || (list_id[i] != 'X' && c != toupper(list_id[i])))
326 return false;
327 }
328 return true;
329 }
330
acpi_pnp_match(const char * idstr,const struct acpi_device_id ** matchid)331 static bool acpi_pnp_match(const char *idstr, const struct acpi_device_id **matchid)
332 {
333 const struct acpi_device_id *devid;
334
335 for (devid = acpi_pnp_device_ids; devid->id[0]; devid++)
336 if (matching_id(idstr, (char *)devid->id)) {
337 if (matchid)
338 *matchid = devid;
339
340 return true;
341 }
342
343 return false;
344 }
345
acpi_pnp_attach(struct acpi_device * adev,const struct acpi_device_id * id)346 static int acpi_pnp_attach(struct acpi_device *adev,
347 const struct acpi_device_id *id)
348 {
349 return true;
350 }
351
352 static struct acpi_scan_handler acpi_pnp_handler = {
353 .ids = acpi_pnp_device_ids,
354 .match = acpi_pnp_match,
355 .attach = acpi_pnp_attach,
356 };
357
358 /*
359 * For CMOS RTC devices, the PNP ACPI scan handler does not work, because
360 * there is a CMOS RTC ACPI scan handler installed already, so we need to
361 * check those devices and enumerate them to the PNP bus directly.
362 */
is_cmos_rtc_device(struct acpi_device * adev)363 static int is_cmos_rtc_device(struct acpi_device *adev)
364 {
365 static const struct acpi_device_id ids[] = {
366 { "PNP0B00" },
367 { "PNP0B01" },
368 { "PNP0B02" },
369 {""},
370 };
371 return !acpi_match_device_ids(adev, ids);
372 }
373
acpi_is_pnp_device(struct acpi_device * adev)374 bool acpi_is_pnp_device(struct acpi_device *adev)
375 {
376 return adev->handler == &acpi_pnp_handler || is_cmos_rtc_device(adev);
377 }
378 EXPORT_SYMBOL_GPL(acpi_is_pnp_device);
379
acpi_pnp_init(void)380 void __init acpi_pnp_init(void)
381 {
382 acpi_scan_add_handler(&acpi_pnp_handler);
383 }
384