xref: /freebsd/sys/dev/puc/puc_cfg.h (revision 82281715ef2f08f873a19340c3d00ef7fa9bf728)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2006 Marcel Moolenaar
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _DEV_PUC_CFG_H_
30 #define	_DEV_PUC_CFG_H_
31 
32 #define	DEFAULT_RCLK	1843200
33 
34 #define	PUC_PORT_NONSTANDARD	0
35 #define	PUC_PORT_1P		1	/* 1 parallel port */
36 #define	PUC_PORT_1S		2	/* 1 serial port */
37 #define	PUC_PORT_1S1P		3	/* 1 serial + 1 parallel ports */
38 #define	PUC_PORT_1S2P		4	/* 1 serial + 2 parallel ports */
39 #define	PUC_PORT_2P		5	/* 2 parallel ports */
40 #define	PUC_PORT_2S		6	/* 2 serial ports */
41 #define	PUC_PORT_2S1P		7	/* 2 serial + 1 parallel ports */
42 #define	PUC_PORT_3S		8	/* 3 serial ports */
43 #define	PUC_PORT_4S		9	/* 4 serial ports */
44 #define	PUC_PORT_4S1P		10	/* 4 serial + 1 parallel ports */
45 #define	PUC_PORT_6S		11	/* 6 serial ports */
46 #define	PUC_PORT_8S		12	/* 8 serial ports */
47 #define	PUC_PORT_12S		13	/* 12 serial ports */
48 #define	PUC_PORT_16S		14	/* 16 serial ports */
49 
50 /* Interrupt Latch Register (ILR) types */
51 #define PUC_ILR_NONE		0
52 #define PUC_ILR_DIGI		1
53 #define PUC_ILR_QUATECH		2
54 
55 /* Configuration flags. */
56 #define	PUC_FLAGS_NO_MSI	0x01
57 
58 /* Configuration queries. */
59 enum puc_cfg_cmd {
60 	PUC_CFG_GET_CLOCK,
61 	PUC_CFG_GET_DESC,
62 	PUC_CFG_GET_ILR,
63 	PUC_CFG_GET_LEN,
64 	PUC_CFG_GET_NPORTS,
65 	PUC_CFG_GET_OFS,
66 	PUC_CFG_GET_RID,
67 	PUC_CFG_GET_TYPE,
68 	PUC_CFG_SETUP
69 };
70 
71 struct puc_softc;
72 
73 typedef int puc_config_f(struct puc_softc *, enum puc_cfg_cmd, int, intptr_t *);
74 
75 struct puc_cfg {
76 	uint16_t	vendor;
77 	uint16_t	device;
78 	uint16_t	subvendor;
79 	uint16_t	subdevice;
80 	const char	*desc;
81 	int		clock;
82 	int8_t		ports;
83 	int8_t		rid;		/* Rid of first port */
84 	int8_t		d_rid;		/* Delta rid of next ports */
85 	int8_t		d_ofs;		/* Delta offset of next ports */
86 	uint8_t		flags;		/* PUC_FLAGS_* */
87 	puc_config_f 	*config_function;
88 };
89 
90 puc_config_f puc_config;
91 
92 #endif /* _DEV_PUC_CFG_H_ */
93