1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2015 Google Inc.
4 */
5
6Scope (\_SB)
7{
8	/*
9	 * Chrome EC Keyboard Backlight interface
10	 */
11	Device (KBLT)
12	{
13		Name (_HID, "GOOG0002")
14		Name (_UID, 1)
15
16		/* Ask EC if we even have a backlight
17		 * Return 0xf (present, enabled, show in UI, functioning) or 0
18		 *
19		 * With older EC codebases that don't support the Device
20		 * Features bitfield, this reports the keyboard backlight as
21		 * enabled since reads to undefined addresses in EC address
22		 * space return 0xff and so KBLE will be 1.
23		 */
24		Method (_STA, 0, NotSerialized)
25		{
26			/* If query is unsupported, but this code is compiled
27			 * in, assume the backlight exists physically.
28			 */
29			If (LEqual (1, \_SB.PCI0.LPCB.EC0.DFUD)) {
30				Return (0xf)
31			}
32			/* If EC reports that backlight exists, trust it */
33			If (LEqual (1, \_SB.PCI0.LPCB.EC0.KBLE)) {
34				Return (0xf)
35			}
36			/* Otherwise: no device -> disable */
37			Return (0)
38		}
39
40		/* Read current backlight value */
41		Method (KBQC, 0, NotSerialized)
42		{
43			Return (\_SB.PCI0.LPCB.EC0.KBLV)
44		}
45
46		/* Write new backlight value */
47		Method (KBCM, 1, NotSerialized)
48		{
49			Store (Arg0, \_SB.PCI0.LPCB.EC0.KBLV)
50		}
51	}
52}
53