aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/razer/blade_stealth_kbl/acpi/battery.asl
blob: 8f195550eb3010c46218dfe70c8566b42b1faff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* SPDX-License-Identifier: GPL-2.0-only */

Device (BAT)
{
	Name (_HID, EisaId ("PNP0C0A"))
	Name (_UID, 1)
	Name (_PCL, Package () { \_SB })

	Name (BSTP, 0)

	Name (PBIF, Package () {
		0x00000001,  /* 0x00: Power Unit: mAh */
		0xFFFFFFFF,  /* 0x01: Design Capacity */
		0xFFFFFFFF,  /* 0x02: Last Full Charge Capacity */
		0x00000001,  /* 0x03: Battery Technology: Rechargeable */
		0xFFFFFFFF,  /* 0x04: Design Voltage */
		0x00000003,  /* 0x05: Design Capacity of Warning */
		0xFFFFFFFF,  /* 0x06: Design Capacity of Low */
		0x00000001,  /* 0x07: Capacity Granularity 1 */
		0x00000001,  /* 0x08: Capacity Granularity 2 */
		"Razer Blade Stealth",
		"SERIAL",
		"LiIon",
		"Razer"
	})


	Name (PBST, Package () {
		0x00000000,  /* 0x00: Battery State */
		0xFFFFFFFF,  /* 0x01: Battery Present Rate */
		0xFFFFFFFF,  /* 0x02: Battery Remaining Capacity */
		0xFFFFFFFF,  /* 0x03: Battery Present Voltage */
	})

	Method (_STA, 0, Serialized)
	{
		Return (0x1F)
	}

	Method (_BIF, 0, Serialized)
	{
		/* Last Full Charge Capacity */
		PBIF [2] = BFCP

		/* Design Voltage */
		PBIF [4] = BDVT

		/* Design Capacity */
		PBIF [1] = BDCP

		/* Design Capacity of Warning */
		PBIF [5] = BDCP / 50

		/* Design Capacity of Low */
		PBIF [6] = BDCP / 100

		PBIF [10] = ToString (BSER, Ones)

		Return (PBIF)
	}

	Method (_BST, 0, Serialized)
	{
		/*
		 * 0: BATTERY STATE
		 *
		 * bit 0 = discharging
		 * bit 1 = charging
		 * bit 2 = critical level
		 */

		/* Check if AC is present */
		If (ACEX) {
			/* Read battery status from EC */
			Local0 = BCST
		} Else {
			/* Always discharging when on battery power */
			Local0 = 0x01
		}

		PBST [0] = Local0

		/* Notify if battery state has changed since last time */
		If (Local0 != BSTP) {
			BSTP = Local0
			Notify (BAT, 0x80)
		}

		/*
		 * 1: BATTERY PRESENT RATE
		 */
		PBST [1] = BCRT

		/*
		 * 2: BATTERY REMAINING CAPACITY
		 */
		PBST [2] = BRCP

		/*
		 * 3: BATTERY PRESENT VOLTAGE
		 */
		PBST [3] = BCVT

		Return (PBST)
	}
}