1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * This defines the battery charging thresholds setting methods tpacpi-bat can
5 * use. This implements what the vendor defines but is rather ugly...
8 /* SetBatteryCharge Start/Stop Capacity Threshold
11 * Bit 7-0: Charge stop capacity (Unit:%)
12 * =0: Use battery default setting
13 * =1-99: Threshold to stop charging battery (Relative capacity)
16 * = 1: Primary battery
17 * = 2: Secondary battery
18 * = Others: Reserved (0)
19 * Bit 31-10: Reserved (0)
24 * Bit 30-0: Reserved (0)
25 * Bit 31: Error status
30 #define START_THRESH_ARG 0
31 #define STOP_THRESH_ARG 1
34 Method (BCSS, 1, NotSerialized)
36 Local0 = Arg0 & 0xff // Percentage
37 Local1 = (Arg0 >> 8) & 0x3 // Battery ID
42 \_SB.PCI0.LPCB.EC.BAT0.SETT(STOP_THRESH_ARG, Local0)
43 \_SB.PCI0.LPCB.EC.BAT1.SETT(STOP_THRESH_ARG, Local0)
45 Local2 = Local0 != \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG)
46 Local3 = Local0 != \_SB.PCI0.LPCB.EC.BAT1.GETT(STOP_THRESH_ARG)
48 Return ((Local2 && Local3) << 31)
54 \_SB.PCI0.LPCB.EC.BAT0.SETT(STOP_THRESH_ARG, Local0)
56 \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG)) << 31)
62 \_SB.PCI0.LPCB.EC.BAT1.SETT(STOP_THRESH_ARG, Local0)
64 \_SB.PCI0.LPCB.EC.BAT1.GETT(STOP_THRESH_ARG)) << 31)
67 Return (1 << 31) /* Should not be reached */
70 // Set start threshold
71 Method (BCCS, 1, NotSerialized)
73 Local0 = Arg0 & 0xff // Percentage
74 Local1 = (Arg0 >> 8) & 0x3 // Battery ID
79 \_SB.PCI0.LPCB.EC.BAT0.SETT(START_THRESH_ARG, Local0)
80 \_SB.PCI0.LPCB.EC.BAT1.SETT(START_THRESH_ARG, Local0)
82 Local2 = Local0 != \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG)
83 Local3 = Local0 != \_SB.PCI0.LPCB.EC.BAT1.GETT(START_THRESH_ARG)
85 Return ((Local2 && Local3) << 31)
91 \_SB.PCI0.LPCB.EC.BAT0.SETT(START_THRESH_ARG, Local0)
93 \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG)) << 31)
99 \_SB.PCI0.LPCB.EC.BAT1.SETT(START_THRESH_ARG, Local0)
101 \_SB.PCI0.LPCB.EC.BAT1.GETT(START_THRESH_ARG)) << 31)
104 Return (1 << 31) /* Should not be reached */
108 * GetBatteryCharge Start/Stop Capacity Threshold
112 * Bit 31-8: Reserved (0)
117 * Bit 7-0: Charge stop capacity (Unit:%)
118 * =0: Use battery default setting
119 * =1-99: Threshold to stop charging battery (Relative capacity)
120 * =Others: Reserved (0)
121 * Bit 9-8: Capability of BatteryCharge Stop Capacity Threshold
122 * Bit 8:Batterycharge stop capacity threshold
123 * (0:Not support 1:Support)
124 * Bit 9: Specify every battery parameter
125 * (0:Not support(apply parameter for all battery)
126 * 1:Support(apply parameter for all battery))
127 * Bit 30-10: Reserved (0)
128 * Bit 31: Error status
133 // Get stop threshold
134 Method (BCSG, 1, NotSerialized)
139 Return (0x300 | \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG))
145 Return (0x300 | \_SB.PCI0.LPCB.EC.BAT1.GETT(STOP_THRESH_ARG))
151 // Get start threshold
152 Method (BCTG, 1, NotSerialized)
157 Return (0x300 | \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG))
163 Return (0x300 | \_SB.PCI0.LPCB.EC.BAT1.GETT(START_THRESH_ARG))