18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Probe for 8250/16550-type ISAPNP serial ports.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  Copyright (C) 2001 Russell King, All Rights Reserved.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci *  Ported to the Linux PnP Layer - (C) Adam Belay.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci#include <linux/module.h>
128c2ecf20Sopenharmony_ci#include <linux/pci.h>
138c2ecf20Sopenharmony_ci#include <linux/pnp.h>
148c2ecf20Sopenharmony_ci#include <linux/string.h>
158c2ecf20Sopenharmony_ci#include <linux/kernel.h>
168c2ecf20Sopenharmony_ci#include <linux/property.h>
178c2ecf20Sopenharmony_ci#include <linux/serial_core.h>
188c2ecf20Sopenharmony_ci#include <linux/bitops.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include <asm/byteorder.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include "8250.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define UNKNOWN_DEV 0x3000
258c2ecf20Sopenharmony_ci#define CIR_PORT	0x0800
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistatic const struct pnp_device_id pnp_dev_table[] = {
288c2ecf20Sopenharmony_ci	/* Archtek America Corp. */
298c2ecf20Sopenharmony_ci	/* Archtek SmartLink Modem 3334BT Plug & Play */
308c2ecf20Sopenharmony_ci	{	"AAC000F",		0	},
318c2ecf20Sopenharmony_ci	/* Anchor Datacomm BV */
328c2ecf20Sopenharmony_ci	/* SXPro 144 External Data Fax Modem Plug & Play */
338c2ecf20Sopenharmony_ci	{	"ADC0001",		0	},
348c2ecf20Sopenharmony_ci	/* SXPro 288 External Data Fax Modem Plug & Play */
358c2ecf20Sopenharmony_ci	{	"ADC0002",		0	},
368c2ecf20Sopenharmony_ci	/* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
378c2ecf20Sopenharmony_ci	{	"AEI0250",		0	},
388c2ecf20Sopenharmony_ci	/* Actiontec ISA PNP 56K X2 Fax Modem */
398c2ecf20Sopenharmony_ci	{	"AEI1240",		0	},
408c2ecf20Sopenharmony_ci	/* Rockwell 56K ACF II Fax+Data+Voice Modem */
418c2ecf20Sopenharmony_ci	{	"AKY1021",		0 /*SPCI_FL_NO_SHIRQ*/	},
428c2ecf20Sopenharmony_ci	/*
438c2ecf20Sopenharmony_ci	 * ALi Fast Infrared Controller
448c2ecf20Sopenharmony_ci	 * Native driver (ali-ircc) is broken so at least
458c2ecf20Sopenharmony_ci	 * it can be used with irtty-sir.
468c2ecf20Sopenharmony_ci	 */
478c2ecf20Sopenharmony_ci	{	"ALI5123",		0	},
488c2ecf20Sopenharmony_ci	/* AZT3005 PnP SOUND DEVICE */
498c2ecf20Sopenharmony_ci	{	"AZT4001",		0	},
508c2ecf20Sopenharmony_ci	/* Best Data Products Inc. Smart One 336F PnP Modem */
518c2ecf20Sopenharmony_ci	{	"BDP3336",		0	},
528c2ecf20Sopenharmony_ci	/*  Boca Research */
538c2ecf20Sopenharmony_ci	/* Boca Complete Ofc Communicator 14.4 Data-FAX */
548c2ecf20Sopenharmony_ci	{	"BRI0A49",		0	},
558c2ecf20Sopenharmony_ci	/* Boca Research 33,600 ACF Modem */
568c2ecf20Sopenharmony_ci	{	"BRI1400",		0	},
578c2ecf20Sopenharmony_ci	/* Boca 33.6 Kbps Internal FD34FSVD */
588c2ecf20Sopenharmony_ci	{	"BRI3400",		0	},
598c2ecf20Sopenharmony_ci	/* Boca 33.6 Kbps Internal FD34FSVD */
608c2ecf20Sopenharmony_ci	{	"BRI0A49",		0	},
618c2ecf20Sopenharmony_ci	/* Best Data Products Inc. Smart One 336F PnP Modem */
628c2ecf20Sopenharmony_ci	{	"BDP3336",		0	},
638c2ecf20Sopenharmony_ci	/* Computer Peripherals Inc */
648c2ecf20Sopenharmony_ci	/* EuroViVa CommCenter-33.6 SP PnP */
658c2ecf20Sopenharmony_ci	{	"CPI4050",		0	},
668c2ecf20Sopenharmony_ci	/* Creative Labs */
678c2ecf20Sopenharmony_ci	/* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
688c2ecf20Sopenharmony_ci	{	"CTL3001",		0	},
698c2ecf20Sopenharmony_ci	/* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
708c2ecf20Sopenharmony_ci	{	"CTL3011",		0	},
718c2ecf20Sopenharmony_ci	/* Davicom ISA 33.6K Modem */
728c2ecf20Sopenharmony_ci	{	"DAV0336",		0	},
738c2ecf20Sopenharmony_ci	/* Creative */
748c2ecf20Sopenharmony_ci	/* Creative Modem Blaster Flash56 DI5601-1 */
758c2ecf20Sopenharmony_ci	{	"DMB1032",		0	},
768c2ecf20Sopenharmony_ci	/* Creative Modem Blaster V.90 DI5660 */
778c2ecf20Sopenharmony_ci	{	"DMB2001",		0	},
788c2ecf20Sopenharmony_ci	/* E-Tech */
798c2ecf20Sopenharmony_ci	/* E-Tech CyberBULLET PC56RVP */
808c2ecf20Sopenharmony_ci	{	"ETT0002",		0	},
818c2ecf20Sopenharmony_ci	/* FUJITSU */
828c2ecf20Sopenharmony_ci	/* Fujitsu 33600 PnP-I2 R Plug & Play */
838c2ecf20Sopenharmony_ci	{	"FUJ0202",		0	},
848c2ecf20Sopenharmony_ci	/* Fujitsu FMV-FX431 Plug & Play */
858c2ecf20Sopenharmony_ci	{	"FUJ0205",		0	},
868c2ecf20Sopenharmony_ci	/* Fujitsu 33600 PnP-I4 R Plug & Play */
878c2ecf20Sopenharmony_ci	{	"FUJ0206",		0	},
888c2ecf20Sopenharmony_ci	/* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
898c2ecf20Sopenharmony_ci	{	"FUJ0209",		0	},
908c2ecf20Sopenharmony_ci	/* Archtek America Corp. */
918c2ecf20Sopenharmony_ci	/* Archtek SmartLink Modem 3334BT Plug & Play */
928c2ecf20Sopenharmony_ci	{	"GVC000F",		0	},
938c2ecf20Sopenharmony_ci	/* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
948c2ecf20Sopenharmony_ci	{	"GVC0303",		0	},
958c2ecf20Sopenharmony_ci	/* Hayes */
968c2ecf20Sopenharmony_ci	/* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
978c2ecf20Sopenharmony_ci	{	"HAY0001",		0	},
988c2ecf20Sopenharmony_ci	/* Hayes Optima 336 V.34 + FAX + Voice PnP */
998c2ecf20Sopenharmony_ci	{	"HAY000C",		0	},
1008c2ecf20Sopenharmony_ci	/* Hayes Optima 336B V.34 + FAX + Voice PnP */
1018c2ecf20Sopenharmony_ci	{	"HAY000D",		0	},
1028c2ecf20Sopenharmony_ci	/* Hayes Accura 56K Ext Fax Modem PnP */
1038c2ecf20Sopenharmony_ci	{	"HAY5670",		0	},
1048c2ecf20Sopenharmony_ci	/* Hayes Accura 56K Ext Fax Modem PnP */
1058c2ecf20Sopenharmony_ci	{	"HAY5674",		0	},
1068c2ecf20Sopenharmony_ci	/* Hayes Accura 56K Fax Modem PnP */
1078c2ecf20Sopenharmony_ci	{	"HAY5675",		0	},
1088c2ecf20Sopenharmony_ci	/* Hayes 288, V.34 + FAX */
1098c2ecf20Sopenharmony_ci	{	"HAYF000",		0	},
1108c2ecf20Sopenharmony_ci	/* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
1118c2ecf20Sopenharmony_ci	{	"HAYF001",		0	},
1128c2ecf20Sopenharmony_ci	/* IBM */
1138c2ecf20Sopenharmony_ci	/* IBM Thinkpad 701 Internal Modem Voice */
1148c2ecf20Sopenharmony_ci	{	"IBM0033",		0	},
1158c2ecf20Sopenharmony_ci	/* Intermec */
1168c2ecf20Sopenharmony_ci	/* Intermec CV60 touchscreen port */
1178c2ecf20Sopenharmony_ci	{	"PNP4972",		0	},
1188c2ecf20Sopenharmony_ci	/* Intertex */
1198c2ecf20Sopenharmony_ci	/* Intertex 28k8 33k6 Voice EXT PnP */
1208c2ecf20Sopenharmony_ci	{	"IXDC801",		0	},
1218c2ecf20Sopenharmony_ci	/* Intertex 33k6 56k Voice EXT PnP */
1228c2ecf20Sopenharmony_ci	{	"IXDC901",		0	},
1238c2ecf20Sopenharmony_ci	/* Intertex 28k8 33k6 Voice SP EXT PnP */
1248c2ecf20Sopenharmony_ci	{	"IXDD801",		0	},
1258c2ecf20Sopenharmony_ci	/* Intertex 33k6 56k Voice SP EXT PnP */
1268c2ecf20Sopenharmony_ci	{	"IXDD901",		0	},
1278c2ecf20Sopenharmony_ci	/* Intertex 28k8 33k6 Voice SP INT PnP */
1288c2ecf20Sopenharmony_ci	{	"IXDF401",		0	},
1298c2ecf20Sopenharmony_ci	/* Intertex 28k8 33k6 Voice SP EXT PnP */
1308c2ecf20Sopenharmony_ci	{	"IXDF801",		0	},
1318c2ecf20Sopenharmony_ci	/* Intertex 33k6 56k Voice SP EXT PnP */
1328c2ecf20Sopenharmony_ci	{	"IXDF901",		0	},
1338c2ecf20Sopenharmony_ci	/* Kortex International */
1348c2ecf20Sopenharmony_ci	/* KORTEX 28800 Externe PnP */
1358c2ecf20Sopenharmony_ci	{	"KOR4522",		0	},
1368c2ecf20Sopenharmony_ci	/* KXPro 33.6 Vocal ASVD PnP */
1378c2ecf20Sopenharmony_ci	{	"KORF661",		0	},
1388c2ecf20Sopenharmony_ci	/* Lasat */
1398c2ecf20Sopenharmony_ci	/* LASAT Internet 33600 PnP */
1408c2ecf20Sopenharmony_ci	{	"LAS4040",		0	},
1418c2ecf20Sopenharmony_ci	/* Lasat Safire 560 PnP */
1428c2ecf20Sopenharmony_ci	{	"LAS4540",		0	},
1438c2ecf20Sopenharmony_ci	/* Lasat Safire 336  PnP */
1448c2ecf20Sopenharmony_ci	{	"LAS5440",		0	},
1458c2ecf20Sopenharmony_ci	/* Microcom, Inc. */
1468c2ecf20Sopenharmony_ci	/* Microcom TravelPorte FAST V.34 Plug & Play */
1478c2ecf20Sopenharmony_ci	{	"MNP0281",		0	},
1488c2ecf20Sopenharmony_ci	/* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
1498c2ecf20Sopenharmony_ci	{	"MNP0336",		0	},
1508c2ecf20Sopenharmony_ci	/* Microcom DeskPorte FAST EP 28.8 Plug & Play */
1518c2ecf20Sopenharmony_ci	{	"MNP0339",		0	},
1528c2ecf20Sopenharmony_ci	/* Microcom DeskPorte 28.8P Plug & Play */
1538c2ecf20Sopenharmony_ci	{	"MNP0342",		0	},
1548c2ecf20Sopenharmony_ci	/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
1558c2ecf20Sopenharmony_ci	{	"MNP0500",		0	},
1568c2ecf20Sopenharmony_ci	/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
1578c2ecf20Sopenharmony_ci	{	"MNP0501",		0	},
1588c2ecf20Sopenharmony_ci	/* Microcom DeskPorte 28.8S Internal Plug & Play */
1598c2ecf20Sopenharmony_ci	{	"MNP0502",		0	},
1608c2ecf20Sopenharmony_ci	/* Motorola */
1618c2ecf20Sopenharmony_ci	/* Motorola BitSURFR Plug & Play */
1628c2ecf20Sopenharmony_ci	{	"MOT1105",		0	},
1638c2ecf20Sopenharmony_ci	/* Motorola TA210 Plug & Play */
1648c2ecf20Sopenharmony_ci	{	"MOT1111",		0	},
1658c2ecf20Sopenharmony_ci	/* Motorola HMTA 200 (ISDN) Plug & Play */
1668c2ecf20Sopenharmony_ci	{	"MOT1114",		0	},
1678c2ecf20Sopenharmony_ci	/* Motorola BitSURFR Plug & Play */
1688c2ecf20Sopenharmony_ci	{	"MOT1115",		0	},
1698c2ecf20Sopenharmony_ci	/* Motorola Lifestyle 28.8 Internal */
1708c2ecf20Sopenharmony_ci	{	"MOT1190",		0	},
1718c2ecf20Sopenharmony_ci	/* Motorola V.3400 Plug & Play */
1728c2ecf20Sopenharmony_ci	{	"MOT1501",		0	},
1738c2ecf20Sopenharmony_ci	/* Motorola Lifestyle 28.8 V.34 Plug & Play */
1748c2ecf20Sopenharmony_ci	{	"MOT1502",		0	},
1758c2ecf20Sopenharmony_ci	/* Motorola Power 28.8 V.34 Plug & Play */
1768c2ecf20Sopenharmony_ci	{	"MOT1505",		0	},
1778c2ecf20Sopenharmony_ci	/* Motorola ModemSURFR External 28.8 Plug & Play */
1788c2ecf20Sopenharmony_ci	{	"MOT1509",		0	},
1798c2ecf20Sopenharmony_ci	/* Motorola Premier 33.6 Desktop Plug & Play */
1808c2ecf20Sopenharmony_ci	{	"MOT150A",		0	},
1818c2ecf20Sopenharmony_ci	/* Motorola VoiceSURFR 56K External PnP */
1828c2ecf20Sopenharmony_ci	{	"MOT150F",		0	},
1838c2ecf20Sopenharmony_ci	/* Motorola ModemSURFR 56K External PnP */
1848c2ecf20Sopenharmony_ci	{	"MOT1510",		0	},
1858c2ecf20Sopenharmony_ci	/* Motorola ModemSURFR 56K Internal PnP */
1868c2ecf20Sopenharmony_ci	{	"MOT1550",		0	},
1878c2ecf20Sopenharmony_ci	/* Motorola ModemSURFR Internal 28.8 Plug & Play */
1888c2ecf20Sopenharmony_ci	{	"MOT1560",		0	},
1898c2ecf20Sopenharmony_ci	/* Motorola Premier 33.6 Internal Plug & Play */
1908c2ecf20Sopenharmony_ci	{	"MOT1580",		0	},
1918c2ecf20Sopenharmony_ci	/* Motorola OnlineSURFR 28.8 Internal Plug & Play */
1928c2ecf20Sopenharmony_ci	{	"MOT15B0",		0	},
1938c2ecf20Sopenharmony_ci	/* Motorola VoiceSURFR 56K Internal PnP */
1948c2ecf20Sopenharmony_ci	{	"MOT15F0",		0	},
1958c2ecf20Sopenharmony_ci	/* Com 1 */
1968c2ecf20Sopenharmony_ci	/*  Deskline K56 Phone System PnP */
1978c2ecf20Sopenharmony_ci	{	"MVX00A1",		0	},
1988c2ecf20Sopenharmony_ci	/* PC Rider K56 Phone System PnP */
1998c2ecf20Sopenharmony_ci	{	"MVX00F2",		0	},
2008c2ecf20Sopenharmony_ci	/* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
2018c2ecf20Sopenharmony_ci	{	"nEC8241",		0	},
2028c2ecf20Sopenharmony_ci	/* Pace 56 Voice Internal Plug & Play Modem */
2038c2ecf20Sopenharmony_ci	{	"PMC2430",		0	},
2048c2ecf20Sopenharmony_ci	/* Generic */
2058c2ecf20Sopenharmony_ci	/* Generic standard PC COM port	 */
2068c2ecf20Sopenharmony_ci	{	"PNP0500",		0	},
2078c2ecf20Sopenharmony_ci	/* Generic 16550A-compatible COM port */
2088c2ecf20Sopenharmony_ci	{	"PNP0501",		0	},
2098c2ecf20Sopenharmony_ci	/* Compaq 14400 Modem */
2108c2ecf20Sopenharmony_ci	{	"PNPC000",		0	},
2118c2ecf20Sopenharmony_ci	/* Compaq 2400/9600 Modem */
2128c2ecf20Sopenharmony_ci	{	"PNPC001",		0	},
2138c2ecf20Sopenharmony_ci	/* Dial-Up Networking Serial Cable between 2 PCs */
2148c2ecf20Sopenharmony_ci	{	"PNPC031",		0	},
2158c2ecf20Sopenharmony_ci	/* Dial-Up Networking Parallel Cable between 2 PCs */
2168c2ecf20Sopenharmony_ci	{	"PNPC032",		0	},
2178c2ecf20Sopenharmony_ci	/* Standard 9600 bps Modem */
2188c2ecf20Sopenharmony_ci	{	"PNPC100",		0	},
2198c2ecf20Sopenharmony_ci	/* Standard 14400 bps Modem */
2208c2ecf20Sopenharmony_ci	{	"PNPC101",		0	},
2218c2ecf20Sopenharmony_ci	/*  Standard 28800 bps Modem*/
2228c2ecf20Sopenharmony_ci	{	"PNPC102",		0	},
2238c2ecf20Sopenharmony_ci	/*  Standard Modem*/
2248c2ecf20Sopenharmony_ci	{	"PNPC103",		0	},
2258c2ecf20Sopenharmony_ci	/*  Standard 9600 bps Modem*/
2268c2ecf20Sopenharmony_ci	{	"PNPC104",		0	},
2278c2ecf20Sopenharmony_ci	/*  Standard 14400 bps Modem*/
2288c2ecf20Sopenharmony_ci	{	"PNPC105",		0	},
2298c2ecf20Sopenharmony_ci	/*  Standard 28800 bps Modem*/
2308c2ecf20Sopenharmony_ci	{	"PNPC106",		0	},
2318c2ecf20Sopenharmony_ci	/*  Standard Modem */
2328c2ecf20Sopenharmony_ci	{	"PNPC107",		0	},
2338c2ecf20Sopenharmony_ci	/* Standard 9600 bps Modem */
2348c2ecf20Sopenharmony_ci	{	"PNPC108",		0	},
2358c2ecf20Sopenharmony_ci	/* Standard 14400 bps Modem */
2368c2ecf20Sopenharmony_ci	{	"PNPC109",		0	},
2378c2ecf20Sopenharmony_ci	/* Standard 28800 bps Modem */
2388c2ecf20Sopenharmony_ci	{	"PNPC10A",		0	},
2398c2ecf20Sopenharmony_ci	/* Standard Modem */
2408c2ecf20Sopenharmony_ci	{	"PNPC10B",		0	},
2418c2ecf20Sopenharmony_ci	/* Standard 9600 bps Modem */
2428c2ecf20Sopenharmony_ci	{	"PNPC10C",		0	},
2438c2ecf20Sopenharmony_ci	/* Standard 14400 bps Modem */
2448c2ecf20Sopenharmony_ci	{	"PNPC10D",		0	},
2458c2ecf20Sopenharmony_ci	/* Standard 28800 bps Modem */
2468c2ecf20Sopenharmony_ci	{	"PNPC10E",		0	},
2478c2ecf20Sopenharmony_ci	/* Standard Modem */
2488c2ecf20Sopenharmony_ci	{	"PNPC10F",		0	},
2498c2ecf20Sopenharmony_ci	/* Standard PCMCIA Card Modem */
2508c2ecf20Sopenharmony_ci	{	"PNP2000",		0	},
2518c2ecf20Sopenharmony_ci	/* Rockwell */
2528c2ecf20Sopenharmony_ci	/* Modular Technology */
2538c2ecf20Sopenharmony_ci	/* Rockwell 33.6 DPF Internal PnP */
2548c2ecf20Sopenharmony_ci	/* Modular Technology 33.6 Internal PnP */
2558c2ecf20Sopenharmony_ci	{	"ROK0030",		0	},
2568c2ecf20Sopenharmony_ci	/* Kortex International */
2578c2ecf20Sopenharmony_ci	/* KORTEX 14400 Externe PnP */
2588c2ecf20Sopenharmony_ci	{	"ROK0100",		0	},
2598c2ecf20Sopenharmony_ci	/* Rockwell 28.8 */
2608c2ecf20Sopenharmony_ci	{	"ROK4120",		0	},
2618c2ecf20Sopenharmony_ci	/* Viking Components, Inc */
2628c2ecf20Sopenharmony_ci	/* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
2638c2ecf20Sopenharmony_ci	{	"ROK4920",		0	},
2648c2ecf20Sopenharmony_ci	/* Rockwell */
2658c2ecf20Sopenharmony_ci	/* British Telecom */
2668c2ecf20Sopenharmony_ci	/* Modular Technology */
2678c2ecf20Sopenharmony_ci	/* Rockwell 33.6 DPF External PnP */
2688c2ecf20Sopenharmony_ci	/* BT Prologue 33.6 External PnP */
2698c2ecf20Sopenharmony_ci	/* Modular Technology 33.6 External PnP */
2708c2ecf20Sopenharmony_ci	{	"RSS00A0",		0	},
2718c2ecf20Sopenharmony_ci	/* Viking 56K FAX INT */
2728c2ecf20Sopenharmony_ci	{	"RSS0262",		0	},
2738c2ecf20Sopenharmony_ci	/* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
2748c2ecf20Sopenharmony_ci	{       "RSS0250",              0       },
2758c2ecf20Sopenharmony_ci	/* SupraExpress 28.8 Data/Fax PnP modem */
2768c2ecf20Sopenharmony_ci	{	"SUP1310",		0	},
2778c2ecf20Sopenharmony_ci	/* SupraExpress 336i PnP Voice Modem */
2788c2ecf20Sopenharmony_ci	{	"SUP1381",		0	},
2798c2ecf20Sopenharmony_ci	/* SupraExpress 33.6 Data/Fax PnP modem */
2808c2ecf20Sopenharmony_ci	{	"SUP1421",		0	},
2818c2ecf20Sopenharmony_ci	/* SupraExpress 33.6 Data/Fax PnP modem */
2828c2ecf20Sopenharmony_ci	{	"SUP1590",		0	},
2838c2ecf20Sopenharmony_ci	/* SupraExpress 336i Sp ASVD */
2848c2ecf20Sopenharmony_ci	{	"SUP1620",		0	},
2858c2ecf20Sopenharmony_ci	/* SupraExpress 33.6 Data/Fax PnP modem */
2868c2ecf20Sopenharmony_ci	{	"SUP1760",		0	},
2878c2ecf20Sopenharmony_ci	/* SupraExpress 56i Sp Intl */
2888c2ecf20Sopenharmony_ci	{	"SUP2171",		0	},
2898c2ecf20Sopenharmony_ci	/* Phoebe Micro */
2908c2ecf20Sopenharmony_ci	/* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
2918c2ecf20Sopenharmony_ci	{	"TEX0011",		0	},
2928c2ecf20Sopenharmony_ci	/* Archtek America Corp. */
2938c2ecf20Sopenharmony_ci	/* Archtek SmartLink Modem 3334BT Plug & Play */
2948c2ecf20Sopenharmony_ci	{	"UAC000F",		0	},
2958c2ecf20Sopenharmony_ci	/* 3Com Corp. */
2968c2ecf20Sopenharmony_ci	/* Gateway Telepath IIvi 33.6 */
2978c2ecf20Sopenharmony_ci	{	"USR0000",		0	},
2988c2ecf20Sopenharmony_ci	/* U.S. Robotics Sporster 33.6K Fax INT PnP */
2998c2ecf20Sopenharmony_ci	{	"USR0002",		0	},
3008c2ecf20Sopenharmony_ci	/*  Sportster Vi 14.4 PnP FAX Voicemail */
3018c2ecf20Sopenharmony_ci	{	"USR0004",		0	},
3028c2ecf20Sopenharmony_ci	/* U.S. Robotics 33.6K Voice INT PnP */
3038c2ecf20Sopenharmony_ci	{	"USR0006",		0	},
3048c2ecf20Sopenharmony_ci	/* U.S. Robotics 33.6K Voice EXT PnP */
3058c2ecf20Sopenharmony_ci	{	"USR0007",		0	},
3068c2ecf20Sopenharmony_ci	/* U.S. Robotics Courier V.Everything INT PnP */
3078c2ecf20Sopenharmony_ci	{	"USR0009",		0	},
3088c2ecf20Sopenharmony_ci	/* U.S. Robotics 33.6K Voice INT PnP */
3098c2ecf20Sopenharmony_ci	{	"USR2002",		0	},
3108c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice INT PnP */
3118c2ecf20Sopenharmony_ci	{	"USR2070",		0	},
3128c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice EXT PnP */
3138c2ecf20Sopenharmony_ci	{	"USR2080",		0	},
3148c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K FAX INT */
3158c2ecf20Sopenharmony_ci	{	"USR3031",		0	},
3168c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K FAX INT */
3178c2ecf20Sopenharmony_ci	{	"USR3050",		0	},
3188c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice INT PnP */
3198c2ecf20Sopenharmony_ci	{	"USR3070",		0	},
3208c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice EXT PnP */
3218c2ecf20Sopenharmony_ci	{	"USR3080",		0	},
3228c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice INT PnP */
3238c2ecf20Sopenharmony_ci	{	"USR3090",		0	},
3248c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Message  */
3258c2ecf20Sopenharmony_ci	{	"USR9100",		0	},
3268c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K FAX EXT PnP*/
3278c2ecf20Sopenharmony_ci	{	"USR9160",		0	},
3288c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K FAX INT PnP*/
3298c2ecf20Sopenharmony_ci	{	"USR9170",		0	},
3308c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice EXT PnP*/
3318c2ecf20Sopenharmony_ci	{	"USR9180",		0	},
3328c2ecf20Sopenharmony_ci	/* U.S. Robotics 56K Voice INT PnP*/
3338c2ecf20Sopenharmony_ci	{	"USR9190",		0	},
3348c2ecf20Sopenharmony_ci	/* Wacom tablets */
3358c2ecf20Sopenharmony_ci	{	"WACFXXX",		0	},
3368c2ecf20Sopenharmony_ci	/* Compaq touchscreen */
3378c2ecf20Sopenharmony_ci	{       "FPI2002",              0 },
3388c2ecf20Sopenharmony_ci	/* Fujitsu Stylistic touchscreens */
3398c2ecf20Sopenharmony_ci	{       "FUJ02B2",              0 },
3408c2ecf20Sopenharmony_ci	{       "FUJ02B3",              0 },
3418c2ecf20Sopenharmony_ci	/* Fujitsu Stylistic LT touchscreens */
3428c2ecf20Sopenharmony_ci	{       "FUJ02B4",              0 },
3438c2ecf20Sopenharmony_ci	/* Passive Fujitsu Stylistic touchscreens */
3448c2ecf20Sopenharmony_ci	{       "FUJ02B6",              0 },
3458c2ecf20Sopenharmony_ci	{       "FUJ02B7",              0 },
3468c2ecf20Sopenharmony_ci	{       "FUJ02B8",              0 },
3478c2ecf20Sopenharmony_ci	{       "FUJ02B9",              0 },
3488c2ecf20Sopenharmony_ci	{       "FUJ02BC",              0 },
3498c2ecf20Sopenharmony_ci	/* Fujitsu Wacom Tablet PC device */
3508c2ecf20Sopenharmony_ci	{	"FUJ02E5",		0	},
3518c2ecf20Sopenharmony_ci	/* Fujitsu P-series tablet PC device */
3528c2ecf20Sopenharmony_ci	{	"FUJ02E6",		0	},
3538c2ecf20Sopenharmony_ci	/* Fujitsu Wacom 2FGT Tablet PC device */
3548c2ecf20Sopenharmony_ci	{	"FUJ02E7",		0	},
3558c2ecf20Sopenharmony_ci	/* Fujitsu Wacom 1FGT Tablet PC device */
3568c2ecf20Sopenharmony_ci	{	"FUJ02E9",		0	},
3578c2ecf20Sopenharmony_ci	/*
3588c2ecf20Sopenharmony_ci	 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6
3598c2ecf20Sopenharmony_ci	 * in disguise).
3608c2ecf20Sopenharmony_ci	 */
3618c2ecf20Sopenharmony_ci	{	"LTS0001",		0       },
3628c2ecf20Sopenharmony_ci	/* Rockwell's (PORALiNK) 33600 INT PNP */
3638c2ecf20Sopenharmony_ci	{	"WCI0003",		0	},
3648c2ecf20Sopenharmony_ci	/* Unknown PnP modems */
3658c2ecf20Sopenharmony_ci	{	"PNPCXXX",		UNKNOWN_DEV	},
3668c2ecf20Sopenharmony_ci	/* More unknown PnP modems */
3678c2ecf20Sopenharmony_ci	{	"PNPDXXX",		UNKNOWN_DEV	},
3688c2ecf20Sopenharmony_ci	/*
3698c2ecf20Sopenharmony_ci	 * Winbond CIR port, should not be probed. We should keep track of
3708c2ecf20Sopenharmony_ci	 * it to prevent the legacy serial driver from probing it.
3718c2ecf20Sopenharmony_ci	 */
3728c2ecf20Sopenharmony_ci	{	"WEC1022",		CIR_PORT	},
3738c2ecf20Sopenharmony_ci	/*
3748c2ecf20Sopenharmony_ci	 * SMSC IrCC SIR/FIR port, should not be probed by serial driver as
3758c2ecf20Sopenharmony_ci	 * well so its own driver can bind to it.
3768c2ecf20Sopenharmony_ci	 */
3778c2ecf20Sopenharmony_ci	{	"SMCF010",		CIR_PORT	},
3788c2ecf20Sopenharmony_ci	{	"",			0	}
3798c2ecf20Sopenharmony_ci};
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pnp, pnp_dev_table);
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_cistatic const char *modem_names[] = {
3848c2ecf20Sopenharmony_ci	"MODEM", "Modem", "modem", "FAX", "Fax", "fax",
3858c2ecf20Sopenharmony_ci	"56K", "56k", "K56", "33.6", "28.8", "14.4",
3868c2ecf20Sopenharmony_ci	"33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
3878c2ecf20Sopenharmony_ci	"33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
3888c2ecf20Sopenharmony_ci};
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_cistatic bool check_name(const char *name)
3918c2ecf20Sopenharmony_ci{
3928c2ecf20Sopenharmony_ci	const char **tmp;
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	for (tmp = modem_names; *tmp; tmp++)
3958c2ecf20Sopenharmony_ci		if (strstr(name, *tmp))
3968c2ecf20Sopenharmony_ci			return true;
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci	return false;
3998c2ecf20Sopenharmony_ci}
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_cistatic bool check_resources(struct pnp_dev *dev)
4028c2ecf20Sopenharmony_ci{
4038c2ecf20Sopenharmony_ci	static const resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
4048c2ecf20Sopenharmony_ci	unsigned int i;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(base); i++) {
4078c2ecf20Sopenharmony_ci		if (pnp_possible_config(dev, IORESOURCE_IO, base[i], 8))
4088c2ecf20Sopenharmony_ci			return true;
4098c2ecf20Sopenharmony_ci	}
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci	return false;
4128c2ecf20Sopenharmony_ci}
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci/*
4158c2ecf20Sopenharmony_ci * Given a complete unknown PnP device, try to use some heuristics to
4168c2ecf20Sopenharmony_ci * detect modems. Currently use such heuristic set:
4178c2ecf20Sopenharmony_ci *     - dev->name or dev->bus->name must contain "modem" substring;
4188c2ecf20Sopenharmony_ci *     - device must have only one IO region (8 byte long) with base address
4198c2ecf20Sopenharmony_ci *       0x2e8, 0x3e8, 0x2f8 or 0x3f8.
4208c2ecf20Sopenharmony_ci *
4218c2ecf20Sopenharmony_ci * Such detection looks very ugly, but can detect at least some of numerous
4228c2ecf20Sopenharmony_ci * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
4238c2ecf20Sopenharmony_ci * table.
4248c2ecf20Sopenharmony_ci */
4258c2ecf20Sopenharmony_cistatic int serial_pnp_guess_board(struct pnp_dev *dev)
4268c2ecf20Sopenharmony_ci{
4278c2ecf20Sopenharmony_ci	if (!(check_name(pnp_dev_name(dev)) ||
4288c2ecf20Sopenharmony_ci	    (dev->card && check_name(dev->card->name))))
4298c2ecf20Sopenharmony_ci		return -ENODEV;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	if (check_resources(dev))
4328c2ecf20Sopenharmony_ci		return 0;
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci	return -ENODEV;
4358c2ecf20Sopenharmony_ci}
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_cistatic int
4388c2ecf20Sopenharmony_ciserial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
4398c2ecf20Sopenharmony_ci{
4408c2ecf20Sopenharmony_ci	struct uart_8250_port uart, *port;
4418c2ecf20Sopenharmony_ci	int ret, line, flags = dev_id->driver_data;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	if (flags & UNKNOWN_DEV) {
4448c2ecf20Sopenharmony_ci		ret = serial_pnp_guess_board(dev);
4458c2ecf20Sopenharmony_ci		if (ret < 0)
4468c2ecf20Sopenharmony_ci			return ret;
4478c2ecf20Sopenharmony_ci	}
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	memset(&uart, 0, sizeof(uart));
4508c2ecf20Sopenharmony_ci	if (pnp_irq_valid(dev, 0))
4518c2ecf20Sopenharmony_ci		uart.port.irq = pnp_irq(dev, 0);
4528c2ecf20Sopenharmony_ci	if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) {
4538c2ecf20Sopenharmony_ci		uart.port.iobase = pnp_port_start(dev, 2);
4548c2ecf20Sopenharmony_ci		uart.port.iotype = UPIO_PORT;
4558c2ecf20Sopenharmony_ci	} else if (pnp_port_valid(dev, 0)) {
4568c2ecf20Sopenharmony_ci		uart.port.iobase = pnp_port_start(dev, 0);
4578c2ecf20Sopenharmony_ci		uart.port.iotype = UPIO_PORT;
4588c2ecf20Sopenharmony_ci	} else if (pnp_mem_valid(dev, 0)) {
4598c2ecf20Sopenharmony_ci		uart.port.mapbase = pnp_mem_start(dev, 0);
4608c2ecf20Sopenharmony_ci		uart.port.iotype = UPIO_MEM;
4618c2ecf20Sopenharmony_ci		uart.port.flags = UPF_IOREMAP;
4628c2ecf20Sopenharmony_ci	} else
4638c2ecf20Sopenharmony_ci		return -ENODEV;
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci	dev_dbg(&dev->dev,
4668c2ecf20Sopenharmony_ci		 "Setup PNP port: port %#lx, mem %#llx, irq %u, type %u\n",
4678c2ecf20Sopenharmony_ci		 uart.port.iobase, (unsigned long long)uart.port.mapbase,
4688c2ecf20Sopenharmony_ci		 uart.port.irq, uart.port.iotype);
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci	if (flags & CIR_PORT) {
4718c2ecf20Sopenharmony_ci		uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE;
4728c2ecf20Sopenharmony_ci		uart.port.type = PORT_8250_CIR;
4738c2ecf20Sopenharmony_ci	}
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci	uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
4768c2ecf20Sopenharmony_ci	if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
4778c2ecf20Sopenharmony_ci		uart.port.flags |= UPF_SHARE_IRQ;
4788c2ecf20Sopenharmony_ci	if (device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk)) {
4798c2ecf20Sopenharmony_ci		uart.port.uartclk = 1843200;
4808c2ecf20Sopenharmony_ci	}
4818c2ecf20Sopenharmony_ci	uart.port.dev = &dev->dev;
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci	line = serial8250_register_8250_port(&uart);
4848c2ecf20Sopenharmony_ci	if (line < 0 || (flags & CIR_PORT))
4858c2ecf20Sopenharmony_ci		return -ENODEV;
4868c2ecf20Sopenharmony_ci
4878c2ecf20Sopenharmony_ci	port = serial8250_get_port(line);
4888c2ecf20Sopenharmony_ci	if (uart_console(&port->port))
4898c2ecf20Sopenharmony_ci		dev->capabilities |= PNP_CONSOLE;
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci	pnp_set_drvdata(dev, (void *)((long)line + 1));
4928c2ecf20Sopenharmony_ci	return 0;
4938c2ecf20Sopenharmony_ci}
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_cistatic void serial_pnp_remove(struct pnp_dev *dev)
4968c2ecf20Sopenharmony_ci{
4978c2ecf20Sopenharmony_ci	long line = (long)pnp_get_drvdata(dev);
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci	dev->capabilities &= ~PNP_CONSOLE;
5008c2ecf20Sopenharmony_ci	if (line)
5018c2ecf20Sopenharmony_ci		serial8250_unregister_port(line - 1);
5028c2ecf20Sopenharmony_ci}
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_cistatic int __maybe_unused serial_pnp_suspend(struct device *dev)
5058c2ecf20Sopenharmony_ci{
5068c2ecf20Sopenharmony_ci	long line = (long)dev_get_drvdata(dev);
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_ci	if (!line)
5098c2ecf20Sopenharmony_ci		return -ENODEV;
5108c2ecf20Sopenharmony_ci	serial8250_suspend_port(line - 1);
5118c2ecf20Sopenharmony_ci	return 0;
5128c2ecf20Sopenharmony_ci}
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_cistatic int __maybe_unused serial_pnp_resume(struct device *dev)
5158c2ecf20Sopenharmony_ci{
5168c2ecf20Sopenharmony_ci	long line = (long)dev_get_drvdata(dev);
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	if (!line)
5198c2ecf20Sopenharmony_ci		return -ENODEV;
5208c2ecf20Sopenharmony_ci	serial8250_resume_port(line - 1);
5218c2ecf20Sopenharmony_ci	return 0;
5228c2ecf20Sopenharmony_ci}
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_cistatic SIMPLE_DEV_PM_OPS(serial_pnp_pm_ops, serial_pnp_suspend, serial_pnp_resume);
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_cistatic struct pnp_driver serial_pnp_driver = {
5278c2ecf20Sopenharmony_ci	.name		= "serial",
5288c2ecf20Sopenharmony_ci	.probe		= serial_pnp_probe,
5298c2ecf20Sopenharmony_ci	.remove		= serial_pnp_remove,
5308c2ecf20Sopenharmony_ci	.driver         = {
5318c2ecf20Sopenharmony_ci		.pm     = &serial_pnp_pm_ops,
5328c2ecf20Sopenharmony_ci	},
5338c2ecf20Sopenharmony_ci	.id_table	= pnp_dev_table,
5348c2ecf20Sopenharmony_ci};
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ciint serial8250_pnp_init(void)
5378c2ecf20Sopenharmony_ci{
5388c2ecf20Sopenharmony_ci	return pnp_register_driver(&serial_pnp_driver);
5398c2ecf20Sopenharmony_ci}
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_civoid serial8250_pnp_exit(void)
5428c2ecf20Sopenharmony_ci{
5438c2ecf20Sopenharmony_ci	pnp_unregister_driver(&serial_pnp_driver);
5448c2ecf20Sopenharmony_ci}
5458c2ecf20Sopenharmony_ci
546