1/* $NetBSD: wbsioreg.h,v 1.11 2022/12/16 00:02:28 msaitoh Exp $ */
2
3/* $OpenBSD: wbsioreg.h,v 1.4 2015/01/02 23:02:54 chris Exp $ */
4/*
5 * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20/*
21 * Winbond LPC Super I/O driver registers
22 */
23
24/* ISA bus registers */
25#define WBSIO_INDEX		0x00	/* Configuration Index Register */
26#define WBSIO_DATA		0x01	/* Configuration Data Register */
27
28#define WBSIO_IOSIZE		0x02	/* ISA I/O space size */
29
30#define WBSIO_CONF_EN_MAGIC	0x87	/* enable configuration mode */
31#define WBSIO_CONF_DS_MAGIC	0xaa	/* disable configuration mode */
32
33/* Configuration Space Registers */
34#define WBSIO_LDN		0x07	/* Logical Device Number */
35#define WBSIO_MFS0		0x1A	/* Multi Function Selection 0 */
36#define WBSIO_MFS1		0x1B	/* Multi Function Selection 1 */
37#define WBSIO_MFS2		0x1C	/* Multi Function Selection 2 */
38#define WBSIO_MFS3		0x1D	/* Multi Function Selection 3 */
39#define WBSIO_ID		0x20	/* Device ID */
40#define WBSIO_REV		0x21	/* Device Revision */
41#define WBSIO_GOPT0		0x24	/* Global Option 0 */
42#define WBSIO_GOPT1		0x26	/* Global Option 1 */
43#define WBSIO_GOPT2		0x27	/* Global Option 2 */
44#define WBSIO_GOPT3		0x28	/* Global Option 3 */
45#define WBSIO_MFS4		0x2A	/* Multi Function Selection 4 */
46#define WBSIO_MFS5		0x2B	/* Multi Function Selection 5 */
47#define WBSIO_MFS6		0x2C	/* Multi Function Selection 6 */
48#define WBSIO_SFR		0x2F	/* Strapping Function Result */
49
50
51#define WBSIO_ID_W83627HF	0x52	/* 8bits */
52#define WBSIO_ID_W83697HF	0x60
53#define WBSIO_ID_W83637HF	0x70
54#define WBSIO_ID_W83627THF	0x82
55#define WBSIO_ID_W83687THF	0x85
56#define WBSIO_ID_W83627SF	0x595	/* 12bits */
57#define WBSIO_ID_W83697UG	0x681
58#define WBSIO_ID_W83627EHF_A	0x885
59#define WBSIO_ID_W83627EHF	0x886
60#define WBSIO_ID_W83627DHG	0xa02
61#define WBSIO_ID_W83627UHG	0xa23
62#define WBSIO_ID_W83667HG	0xa51
63#define WBSIO_ID_W83627DHGP	0xb07
64#define WBSIO_ID_W83667HGB	0xb35
65#define WBSIO_ID_NCT6775F	0xb47
66#define WBSIO_ID_NCT6776F	0xc33
67#define WBSIO_ID_NCT5104D	0xc45	/* 610[246]D */
68#define WBSIO_ID_NCT6779D	0xc56
69#define WBSIO_ID_NCT6791D	0xc80
70#define WBSIO_ID_NCT6792D	0xc91
71#define WBSIO_ID_NCT6793D	0xd12
72#define WBSIO_ID_NCT6795D	0xd35
73#define WBSIO_ID_NCT6796D	0xd420	/* 13bits */
74#define WBSIO_ID_NCT6797D	0xd450
75#define WBSIO_ID_NCT6798D	0xd428
76#define WBSIO_ID_NCT6799D	0xd800
77
78/* Make the above WBSIO_ID_* vaue from WBSIO_ID, WBSIO_REV and IDbits */
79#define WBSIO_MAKEID(id, rev, bits)					\
80	(((bits) == 13) ? (((uint16_t)(id) << 8) | ((rev) & 0xf8)) :	\
81	    ((bits) == 12) ? (((uint16_t)(id) << 4) | ((rev) >> 4)) : (id))
82
83#define WBSIO_MAKEREV(rev, bits)					     \
84	(((bits) == 13) ? ((rev) & 0x07) : ((bits) == 12) ? ((rev) & 0x0f) : \
85	    (rev))
86
87/* Strapping Function Result */
88#define WBSIO_SFR_24M48M	0x01
89#define WBSIO_SFR_LPT		0x02
90#define WBSIO_SFR_TEST		0x04
91#define WBSIO_SFR_DSW		0x08
92#define WBSIO_SFR_AMDPWR	0x20
93#define WBSIO_SFR_UARTP80	0x40
94
95/* Logical Device Number (LDN) Assignments */
96#define WBSIO_LDN_HM		0x0b
97#define WBSIO_LDN_GPIO0		0x08	/* WDT, GPIO 0 */
98#define WBSIO_LDN_GPIO1		0x09	/* GPIO 1 to GPIO 8 */
99
100/* Hardware Monitor Control Registers (LDN B) */
101#define WBSIO_HM_ADDR_MSB	0x60	/* Address [15:8] */
102#define WBSIO_HM_ADDR_LSB	0x61	/* Address [7:0] */
103#define WBSIO_HM_CONF		0xE4	/* Configuration Register */
104#define WBSIO_HM_CONF_RSTOUT4	0x02	/* RSTOUT4# bit */
105#define WBSIO_HM_CONF_RSTOUT3	0x04	/* RSTOUT3# bit */
106#define WBSIO_HM_CONF_PWROK	0x08	/* Power OK Bit */
107
108/* GPIO Registers */
109#define WBSIO_GPIO_ADDR_MSB	0x60	/* Address [15:8] */
110#define WBSIO_GPIO_ADDR_LSB	0x61	/* Address [7:0] */
111#define WBSIO_GPIO_CONF		0x30	/* GPIO0, WDT1 config */
112#define WBSIO_WDT_MODE		0xF5	/* WDT1 Control Mode */
113#define WBSIO_WDT_CNTR		0xF6	/* WDT1 Counter */
114#define WBSIO_WDT_STAT		0xF7	/* WDT1 Control & Status */
115#define WBSIO_GPIO4_MFS		0xEE	/* GPIO4 Multi-Function Select */
116
117#define WBSIO_GPIO0_WDT1	__BIT(0)
118#define WBSIO_GPIO0_ENABLE	__BIT(1)
119
120						/* Reserved */
121#define WBSIO_GPIO_BASEADDR	__BIT(3)	/* Base address mode */
122#define WBSIO_GPIO1_ENABLE	__BIT(1)
123#define WBSIO_GPIO2_ENABLE	__BIT(2)
124#define WBSIO_GPIO3_ENABLE	__BIT(3)
125#define WBSIO_GPIO4_ENABLE	__BIT(4)
126#define WBSIO_GPIO5_ENABLE	__BIT(5)
127#define WBSIO_GPIO6_ENABLE	__BIT(6)
128#define WBSIO_GPIO7_ENABLE	__BIT(7)
129#define WBSIO_GPIO8_ENABLE	__BIT(0)
130
131#define WBSIO_GPIO_NPINS	64
132#define WBSIO_GPIO_IOSIZE	0x06	/* GPIO register table size */
133
134#define WBSIO_GPIO_GSR		0x00	/* GPIO Select Register */
135#define WBSIO_GPIO_IOR		0x01	/* I/O direction */
136#define WBSIO_GPIO_DAT		0x02	/* Data */
137#define WBSIO_GPIO_INV		0x03	/* Inversion */
138#define WBSIO_GPIO_DST		0x04	/* Event Status */
139					/* WDT1 Control Mode */
140					/* WDT1 control */
141#define WBSIO_WDT_MODE_LEVEL	__BIT(0)
142					/* enable/disable KBRST */
143#define WBSIO_WDT_MODE_KBCRST	__BIT(2)
144#define WBSIO_WDT_MODE_MINUTES	__BIT(3)
145#define WBSIO_WDT_MODE_FASTER	__BIT(4)
146
147#define WBSIO_WDT_CNTR_STOP	0
148#define WBSIO_WDT_CNTR_MAX	255
149
150#define WBSIO_WDT_STAT_TIMEOUT	__BIT(4)
151#define WBSIO_WDT_STAT_EVENT	__BIT(5)
152
153
154/* NCT6779D */
155#define WBSIO_NCT6779D_MFS2_GP00	__BIT(0)
156#define WBSIO_NCT6779D_MFS2_GP01	__BIT(1)
157#define WBSIO_NCT6779D_MFS2_GP02	__BIT(2)
158#define WBSIO_NCT6779D_MFS2_GP03_MASK	(__BIT(3)|__BIT(4))
159#define WBSIO_NCT6779D_MFS2_GP04	__BIT(5)
160#define WBSIO_NCT6779D_MFS2_GP05	__BIT(6)
161#define WBSIO_NCT6779D_MFS2_GP06	__BIT(7)
162#define WBSIO_NCT6779D_MFS3_GP07_MASK	__BIT(0)
163#define WBSIO_NCT6779D_MFS4_GP10_GP17	__BIT(6)
164#define WBSIO_NCT6779D_MFS4_GP20_GP21	__BIT(0)
165#define WBSIO_NCT6779D_MFS4_GP22_GP23	__BIT(1)
166#define WBSIO_NCT6779D_MFS1_GP24_MASK	__BIT(4)
167#define WBSIO_NCT6779D_GOPT2_GP24_MASK	__BIT(3)
168#define WBSIO_NCT6779D_MFS4_GP25_MASK	__BIT(3)
169#define WBSIO_NCT6779D_GOPT2_GP25_MASK	__BIT(3)
170#define WBSIO_NCT6779D_MFS6_GP26	__BIT(0)
171#define WBSIO_NCT6779D_MFS6_GP27_MASK	(__BIT(3)|__BIT(4))
172#define WBSIO_NCT6779D_MFS0_GP30	__BIT(6)
173#define WBSIO_NCT6779D_MFS0_GP30_MASK	__BIT(7)
174#define WBSIO_NCT6779D_MFS0_GP31	__BIT(5)
175#define WBSIO_NCT6779D_MFS1_GP31_MASK	__BIT(0)
176#define WBSIO_NCT6779D_MFS0_GP32	__BIT(4)
177#define WBSIO_NCT6779D_MFS1_GP32_MASK	__BIT(0)
178#define WBSIO_NCT6779D_MFS6_GP33	__BIT(7)
179#define WBSIO_NCT6779D_MFS6_GP33_MASK	__BIT(6)
180#define WBSIO_NCT6779D_MFS1_GP40	__BIT(3)
181#define WBSIO_NCT6779D_MFS0_GP41	__BIT(3)
182#define WBSIO_NCT6779D_MFS0_GP41_MASK	__BIT(2)
183#define WBSIO_NCT6779D_MFS1_GP42	(__BIT(1)|__BIT(2))
184#define WBSIO_NCT6779D_GOPT2_GP43	__BIT(4)
185#define WBSIO_NCT6779D_MFS1_GP44_GP45_MASK	__BIT(6)
186#define WBSIO_NCT6779D_GOPT2_GP46_MASK	__BIT(5)
187#define WBSIO_NCT6779D_MFS1_GP47	__BIT(7)
188#define WBSIO_NCT6779D_HM_GP50_MASK	__BIT(2)
189#define WBSIO_NCT6779D_HM_GP52_MASK	__BIT(1)
190#define WBSIO_NCT6779D_HM_GP55_MASK	__BIT(3)
191#define WBSIO_NCT6779D_MFS5_GP74	__BIT(5)
192#define WBSIO_NCT6779D_MFS5_GP75	__BIT(6)
193#define WBSIO_NCT6779D_MFS5_GP76	__BIT(7)
194#define WBSIO_NCT6779D_GPIO4_WDTO	__BIT(4)
195