1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2012 The ChromiumOS Authors.  All rights reserved.
4 */
5
6/*
7 * Chrome OS Embedded Controller interface
8 *
9 * Constants that should be defined:
10 *
11 * SIO_EC_MEMMAP_ENABLE     : Enable EC LPC memory map resources
12 * EC_LPC_ADDR_MEMMAP       : Base address of memory map range
13 * EC_MEMMAP_SIZE           : Size of memory map range
14 *
15 * SIO_EC_HOST_ENABLE       : Enable EC host command interface resources
16 * EC_LPC_ADDR_HOST_DATA    : EC host command interface data port
17 * EC_LPC_ADDR_HOST_CMD     : EC host command interface command port
18 * EC_HOST_CMD_REGION0      : EC host command buffer
19 * EC_HOST_CMD_REGION1      : EC host command buffer
20 * EC_HOST_CMD_REGION_SIZE  : EC host command buffer size
21 */
22
23// Scope is \_SB.PCI0.LPCB
24
25Device (SIO) {
26	Name (_UID, 0)
27	Name (_ADR, 0)
28
29#ifdef SIO_EC_MEMMAP_ENABLE
30	Device (ECMM) {
31		Name (_HID, EISAID ("PNP0C02"))
32		Name (_UID, 4)
33
34		Method (_STA, 0, NotSerialized) {
35			Return (0x0F)
36		}
37
38		Name (_CRS, ResourceTemplate ()
39		{
40			IO (Decode16, EC_LPC_ADDR_MEMMAP, EC_LPC_ADDR_MEMMAP,
41			    0x08, EC_MEMMAP_SIZE)
42		})
43
44		Name (_PRS, ResourceTemplate ()
45		{
46			IO (Decode16, EC_LPC_ADDR_MEMMAP, EC_LPC_ADDR_MEMMAP,
47			    0x08, EC_MEMMAP_SIZE)
48		})
49	}
50#endif
51
52#ifdef SIO_EC_HOST_ENABLE
53	Device (ECUI) {
54		Name (_HID, EISAID ("PNP0C02"))
55		Name (_UID, 3)
56
57		Method (_STA, 0, NotSerialized) {
58			Return (0x0F)
59		}
60
61		Name (_CRS, ResourceTemplate ()
62		{
63			IO (Decode16,
64			    EC_LPC_ADDR_HOST_DATA, EC_LPC_ADDR_HOST_DATA,
65			    0x01, 0x01)
66			IO (Decode16,
67			    EC_LPC_ADDR_HOST_CMD, EC_LPC_ADDR_HOST_CMD,
68			    0x01, 0x01)
69			IO (Decode16,
70			    EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION0, 0x08,
71			    EC_HOST_CMD_REGION_SIZE)
72			IO (Decode16,
73			    EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION1, 0x08,
74			    EC_HOST_CMD_REGION_SIZE)
75		})
76
77		Name (_PRS, ResourceTemplate ()
78		{
79			StartDependentFn (0, 0) {
80				IO (Decode16, EC_LPC_ADDR_HOST_DATA,
81				    EC_LPC_ADDR_HOST_DATA, 0x01, 0x01)
82				IO (Decode16, EC_LPC_ADDR_HOST_CMD,
83				    EC_LPC_ADDR_HOST_CMD, 0x01, 0x01)
84				IO (Decode16,
85				    EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION0,
86				    0x08, EC_HOST_CMD_REGION_SIZE)
87				IO (Decode16,
88				    EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION1,
89				    0x08, EC_HOST_CMD_REGION_SIZE)
90			}
91			EndDependentFn ()
92		})
93	}
94#endif
95
96#ifdef SIO_EC_ENABLE_COM1
97	Device (COM1) {
98		Name (_HID, EISAID ("PNP0501"))
99		Name (_UID, 1)
100
101		Method (_STA, 0, NotSerialized) {
102			Return (0x0F)
103		}
104
105		Name (_CRS, ResourceTemplate ()
106		{
107			IO (Decode16, 0x03F8, 0x3F8, 0x08, 0x08)
108			IRQNoFlags () {4}
109		})
110
111		Name (_PRS, ResourceTemplate ()
112		{
113			StartDependentFn (0, 0) {
114				IO (Decode16, 0x03F8, 0x3F8, 0x08, 0x08)
115				IRQNoFlags () {4}
116			}
117			EndDependentFn ()
118		})
119	}
120#endif
121}
122
123#ifdef SIO_EC_ENABLE_PS2K
124Device (PS2K)		// Keyboard
125{
126	Name (_UID, 0)
127	Name (_HID, "GOOG000A")
128	Name (_CID, Package() { EISAID("PNP0303"), EISAID("PNP030B") } )
129
130	Method (_STA, 0, NotSerialized) {
131		Return (0x0F)
132	}
133
134	Name (_CRS, ResourceTemplate()
135	{
136		IO (Decode16, 0x60, 0x60, 0x01, 0x01)
137		IO (Decode16, 0x64, 0x64, 0x01, 0x01)
138#ifdef SIO_EC_PS2K_IRQ
139		SIO_EC_PS2K_IRQ
140#else
141		IRQ (Edge, ActiveHigh, Exclusive) {1}
142#endif
143	})
144
145	Name (_PRS, ResourceTemplate()
146	{
147		StartDependentFn (0, 0) {
148			IO (Decode16, 0x60, 0x60, 0x01, 0x01)
149			IO (Decode16, 0x64, 0x64, 0x01, 0x01)
150#ifdef SIO_EC_PS2K_IRQ
151			SIO_EC_PS2K_IRQ
152#else
153			IRQ (Edge, ActiveHigh, Exclusive) {1}
154#endif
155		}
156		EndDependentFn ()
157	})
158}
159#endif
160