blob: 4938010fcac78d821f828434a44e84389eff4539 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Rich Townsend3f86b832006-07-01 11:36:54 -04002/*
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +04003 * sbs.c - ACPI Smart Battery System Driver ($Revision: 2.0 $)
Rich Townsend3f86b832006-07-01 11:36:54 -04004 *
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +04005 * Copyright (c) 2007 Alexey Starikovskiy <astarikovskiy@suse.de>
6 * Copyright (c) 2005-2007 Vladimir Lebedev <vladimir.p.lebedev@intel.com>
Rich Townsend3f86b832006-07-01 11:36:54 -04007 * Copyright (c) 2005 Rich Townsend <rhdt@bartol.udel.edu>
Rich Townsend3f86b832006-07-01 11:36:54 -04008 */
9
Hanjun Guof7e02c82021-06-02 16:54:38 +080010#define pr_fmt(fmt) "ACPI: " fmt
11
Rich Townsend3f86b832006-07-01 11:36:54 -040012#include <linux/init.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Rich Townsend3f86b832006-07-01 11:36:54 -040014#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/kernel.h>
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +040017
Rich Townsend3f86b832006-07-01 11:36:54 -040018#include <linux/acpi.h>
Vladimir Lebedev6d157022007-03-19 17:45:50 +030019#include <linux/timer.h>
Vladimir Lebedev72206232007-03-19 17:45:50 +030020#include <linux/jiffies.h>
Rich Townsend3f86b832006-07-01 11:36:54 -040021#include <linux/delay.h>
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +040022#include <linux/power_supply.h>
Lukas Wunner630b3af2017-08-01 14:10:41 +020023#include <linux/platform_data/x86/apple.h>
Ognjen Galicfa938542018-02-07 15:58:13 +010024#include <acpi/battery.h>
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +040025
Alexey Starikovskiy91087df2007-09-26 19:43:28 +040026#include "sbshc.h"
27
Rich Townsend3f86b832006-07-01 11:36:54 -040028#define ACPI_SBS_CLASS "sbs"
29#define ACPI_AC_CLASS "ac_adapter"
Rich Townsend3f86b832006-07-01 11:36:54 -040030#define ACPI_SBS_DEVICE_NAME "Smart Battery System"
Rich Townsend3f86b832006-07-01 11:36:54 -040031#define ACPI_BATTERY_DIR_NAME "BAT%i"
32#define ACPI_AC_DIR_NAME "AC0"
Rich Townsend3f86b832006-07-01 11:36:54 -040033
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040034#define ACPI_SBS_NOTIFY_STATUS 0x80
35#define ACPI_SBS_NOTIFY_INFO 0x81
Rich Townsend3f86b832006-07-01 11:36:54 -040036
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040037MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
Rich Townsend3f86b832006-07-01 11:36:54 -040038MODULE_DESCRIPTION("Smart Battery System ACPI interface driver");
39MODULE_LICENSE("GPL");
40
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040041static unsigned int cache_time = 1000;
42module_param(cache_time, uint, 0644);
43MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
Vladimir Lebedev6d157022007-03-19 17:45:50 +030044
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040045#define MAX_SBS_BAT 4
Vladimir Lebedev6d157022007-03-19 17:45:50 +030046#define ACPI_SBS_BLOCK_MAX 32
47
Thomas Renninger1ba90e32007-07-23 14:44:41 +020048static const struct acpi_device_id sbs_device_ids[] = {
Alexey Starikovskiy91087df2007-09-26 19:43:28 +040049 {"ACPI0002", 0},
Thomas Renninger1ba90e32007-07-23 14:44:41 +020050 {"", 0},
51};
52MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
53
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040054struct acpi_battery {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010055 struct power_supply *bat;
56 struct power_supply_desc bat_desc;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040057 struct acpi_sbs *sbs;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040058 unsigned long update_time;
59 char name[8];
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040060 char manufacturer_name[ACPI_SBS_BLOCK_MAX];
61 char device_name[ACPI_SBS_BLOCK_MAX];
62 char device_chemistry[ACPI_SBS_BLOCK_MAX];
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +040063 u16 alarm_capacity;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040064 u16 full_charge_capacity;
65 u16 design_capacity;
66 u16 design_voltage;
67 u16 serial_number;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040068 u16 cycle_count;
69 u16 temp_now;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040070 u16 voltage_now;
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -040071 s16 rate_now;
72 s16 rate_avg;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040073 u16 capacity_now;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040074 u16 state_of_charge;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040075 u16 state;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040076 u16 mode;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040077 u16 spec;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040078 u8 id;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040079 u8 present:1;
Jeff Garzik037cbc62007-11-18 00:32:31 +030080 u8 have_sysfs_alarm:1;
Rich Townsend3f86b832006-07-01 11:36:54 -040081};
82
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010083#define to_acpi_battery(x) power_supply_get_drvdata(x)
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +040084
Rich Townsend3f86b832006-07-01 11:36:54 -040085struct acpi_sbs {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010086 struct power_supply *charger;
Rich Townsend3f86b832006-07-01 11:36:54 -040087 struct acpi_device *device;
Alexey Starikovskiy91087df2007-09-26 19:43:28 +040088 struct acpi_smb_hc *hc;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040089 struct mutex lock;
Rich Townsend3f86b832006-07-01 11:36:54 -040090 struct acpi_battery battery[MAX_SBS_BAT];
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +040091 u8 batteries_supported:4;
Alexey Starikovskiy89862e32007-09-26 19:43:35 +040092 u8 manager_present:1;
93 u8 charger_present:1;
Matthew Garrett3031cdd2014-09-20 13:19:45 +020094 u8 charger_exists:1;
Rich Townsend3f86b832006-07-01 11:36:54 -040095};
96
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010097#define to_acpi_sbs(x) power_supply_get_drvdata(x)
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +040098
Rafael J. Wysocki51fac832013-01-24 00:24:48 +010099static int acpi_sbs_remove(struct acpi_device *device);
Lan Tianyu1dd5c712011-07-01 16:03:15 +0800100static int acpi_battery_get_state(struct acpi_battery *battery);
101
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400102static inline int battery_scale(int log)
Vladimir Lebedev72206232007-03-19 17:45:50 +0300103{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400104 int scale = 1;
105 while (log--)
106 scale *= 10;
107 return scale;
Vladimir Lebedev72206232007-03-19 17:45:50 +0300108}
109
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400110static inline int acpi_battery_vscale(struct acpi_battery *battery)
Vladimir Lebedev72206232007-03-19 17:45:50 +0300111{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400112 return battery_scale((battery->spec & 0x0f00) >> 8);
Vladimir Lebedev72206232007-03-19 17:45:50 +0300113}
114
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400115static inline int acpi_battery_ipscale(struct acpi_battery *battery)
Vladimir Lebedev72206232007-03-19 17:45:50 +0300116{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400117 return battery_scale((battery->spec & 0xf000) >> 12);
118}
119
120static inline int acpi_battery_mode(struct acpi_battery *battery)
121{
122 return (battery->mode & 0x8000);
123}
124
125static inline int acpi_battery_scale(struct acpi_battery *battery)
126{
127 return (acpi_battery_mode(battery) ? 10 : 1) *
128 acpi_battery_ipscale(battery);
Vladimir Lebedev72206232007-03-19 17:45:50 +0300129}
130
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400131static int sbs_get_ac_property(struct power_supply *psy,
132 enum power_supply_property psp,
133 union power_supply_propval *val)
134{
135 struct acpi_sbs *sbs = to_acpi_sbs(psy);
136 switch (psp) {
137 case POWER_SUPPLY_PROP_ONLINE:
138 val->intval = sbs->charger_present;
139 break;
140 default:
141 return -EINVAL;
142 }
143 return 0;
144}
145
146static int acpi_battery_technology(struct acpi_battery *battery)
147{
148 if (!strcasecmp("NiCd", battery->device_chemistry))
149 return POWER_SUPPLY_TECHNOLOGY_NiCd;
150 if (!strcasecmp("NiMH", battery->device_chemistry))
151 return POWER_SUPPLY_TECHNOLOGY_NiMH;
152 if (!strcasecmp("LION", battery->device_chemistry))
153 return POWER_SUPPLY_TECHNOLOGY_LION;
154 if (!strcasecmp("LiP", battery->device_chemistry))
155 return POWER_SUPPLY_TECHNOLOGY_LIPO;
156 return POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
157}
158
159static int acpi_sbs_battery_get_property(struct power_supply *psy,
160 enum power_supply_property psp,
161 union power_supply_propval *val)
162{
163 struct acpi_battery *battery = to_acpi_battery(psy);
164
165 if ((!battery->present) && psp != POWER_SUPPLY_PROP_PRESENT)
166 return -ENODEV;
Lan Tianyu1dd5c712011-07-01 16:03:15 +0800167
168 acpi_battery_get_state(battery);
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400169 switch (psp) {
170 case POWER_SUPPLY_PROP_STATUS:
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400171 if (battery->rate_now < 0)
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400172 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400173 else if (battery->rate_now > 0)
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400174 val->intval = POWER_SUPPLY_STATUS_CHARGING;
175 else
176 val->intval = POWER_SUPPLY_STATUS_FULL;
177 break;
178 case POWER_SUPPLY_PROP_PRESENT:
179 val->intval = battery->present;
180 break;
181 case POWER_SUPPLY_PROP_TECHNOLOGY:
182 val->intval = acpi_battery_technology(battery);
183 break;
Alexey Starikovskiy16698852009-10-15 14:31:37 +0400184 case POWER_SUPPLY_PROP_CYCLE_COUNT:
185 val->intval = battery->cycle_count;
186 break;
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400187 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
188 val->intval = battery->design_voltage *
189 acpi_battery_vscale(battery) * 1000;
190 break;
191 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
192 val->intval = battery->voltage_now *
193 acpi_battery_vscale(battery) * 1000;
194 break;
195 case POWER_SUPPLY_PROP_CURRENT_NOW:
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400196 case POWER_SUPPLY_PROP_POWER_NOW:
197 val->intval = abs(battery->rate_now) *
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400198 acpi_battery_ipscale(battery) * 1000;
Lan Tianyue4108292011-07-01 16:03:39 +0800199 val->intval *= (acpi_battery_mode(battery)) ?
200 (battery->voltage_now *
201 acpi_battery_vscale(battery) / 1000) : 1;
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400202 break;
203 case POWER_SUPPLY_PROP_CURRENT_AVG:
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400204 case POWER_SUPPLY_PROP_POWER_AVG:
205 val->intval = abs(battery->rate_avg) *
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400206 acpi_battery_ipscale(battery) * 1000;
Lan Tianyue4108292011-07-01 16:03:39 +0800207 val->intval *= (acpi_battery_mode(battery)) ?
208 (battery->voltage_now *
209 acpi_battery_vscale(battery) / 1000) : 1;
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400210 break;
211 case POWER_SUPPLY_PROP_CAPACITY:
212 val->intval = battery->state_of_charge;
213 break;
214 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
215 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
216 val->intval = battery->design_capacity *
217 acpi_battery_scale(battery) * 1000;
218 break;
219 case POWER_SUPPLY_PROP_CHARGE_FULL:
220 case POWER_SUPPLY_PROP_ENERGY_FULL:
221 val->intval = battery->full_charge_capacity *
222 acpi_battery_scale(battery) * 1000;
223 break;
224 case POWER_SUPPLY_PROP_CHARGE_NOW:
225 case POWER_SUPPLY_PROP_ENERGY_NOW:
226 val->intval = battery->capacity_now *
227 acpi_battery_scale(battery) * 1000;
228 break;
229 case POWER_SUPPLY_PROP_TEMP:
230 val->intval = battery->temp_now - 2730; // dK -> dC
231 break;
232 case POWER_SUPPLY_PROP_MODEL_NAME:
233 val->strval = battery->device_name;
234 break;
235 case POWER_SUPPLY_PROP_MANUFACTURER:
236 val->strval = battery->manufacturer_name;
237 break;
238 default:
239 return -EINVAL;
240 }
241 return 0;
242}
243
244static enum power_supply_property sbs_ac_props[] = {
245 POWER_SUPPLY_PROP_ONLINE,
246};
247
248static enum power_supply_property sbs_charge_battery_props[] = {
249 POWER_SUPPLY_PROP_STATUS,
250 POWER_SUPPLY_PROP_PRESENT,
251 POWER_SUPPLY_PROP_TECHNOLOGY,
Alexey Starikovskiy16698852009-10-15 14:31:37 +0400252 POWER_SUPPLY_PROP_CYCLE_COUNT,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400253 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
254 POWER_SUPPLY_PROP_VOLTAGE_NOW,
255 POWER_SUPPLY_PROP_CURRENT_NOW,
256 POWER_SUPPLY_PROP_CURRENT_AVG,
257 POWER_SUPPLY_PROP_CAPACITY,
258 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
259 POWER_SUPPLY_PROP_CHARGE_FULL,
260 POWER_SUPPLY_PROP_CHARGE_NOW,
261 POWER_SUPPLY_PROP_TEMP,
262 POWER_SUPPLY_PROP_MODEL_NAME,
263 POWER_SUPPLY_PROP_MANUFACTURER,
264};
265
266static enum power_supply_property sbs_energy_battery_props[] = {
267 POWER_SUPPLY_PROP_STATUS,
268 POWER_SUPPLY_PROP_PRESENT,
269 POWER_SUPPLY_PROP_TECHNOLOGY,
270 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
271 POWER_SUPPLY_PROP_VOLTAGE_NOW,
272 POWER_SUPPLY_PROP_CURRENT_NOW,
273 POWER_SUPPLY_PROP_CURRENT_AVG,
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400274 POWER_SUPPLY_PROP_POWER_NOW,
275 POWER_SUPPLY_PROP_POWER_AVG,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400276 POWER_SUPPLY_PROP_CAPACITY,
277 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
278 POWER_SUPPLY_PROP_ENERGY_FULL,
279 POWER_SUPPLY_PROP_ENERGY_NOW,
280 POWER_SUPPLY_PROP_TEMP,
281 POWER_SUPPLY_PROP_MODEL_NAME,
282 POWER_SUPPLY_PROP_MANUFACTURER,
283};
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400284
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100285static const struct power_supply_desc acpi_sbs_charger_desc = {
286 .name = "sbs-charger",
287 .type = POWER_SUPPLY_TYPE_MAINS,
288 .properties = sbs_ac_props,
289 .num_properties = ARRAY_SIZE(sbs_ac_props),
290 .get_property = sbs_get_ac_property,
291};
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400292
Rich Townsend3f86b832006-07-01 11:36:54 -0400293/* --------------------------------------------------------------------------
294 Smart Battery System Management
295 -------------------------------------------------------------------------- */
296
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400297struct acpi_battery_reader {
298 u8 command; /* command for battery */
299 u8 mode; /* word or block? */
300 size_t offset; /* offset inside struct acpi_sbs_battery */
301};
Vladimir Lebedev72206232007-03-19 17:45:50 +0300302
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400303static struct acpi_battery_reader info_readers[] = {
304 {0x01, SMBUS_READ_WORD, offsetof(struct acpi_battery, alarm_capacity)},
305 {0x03, SMBUS_READ_WORD, offsetof(struct acpi_battery, mode)},
306 {0x10, SMBUS_READ_WORD, offsetof(struct acpi_battery, full_charge_capacity)},
307 {0x17, SMBUS_READ_WORD, offsetof(struct acpi_battery, cycle_count)},
308 {0x18, SMBUS_READ_WORD, offsetof(struct acpi_battery, design_capacity)},
309 {0x19, SMBUS_READ_WORD, offsetof(struct acpi_battery, design_voltage)},
310 {0x1a, SMBUS_READ_WORD, offsetof(struct acpi_battery, spec)},
311 {0x1c, SMBUS_READ_WORD, offsetof(struct acpi_battery, serial_number)},
312 {0x20, SMBUS_READ_BLOCK, offsetof(struct acpi_battery, manufacturer_name)},
313 {0x21, SMBUS_READ_BLOCK, offsetof(struct acpi_battery, device_name)},
314 {0x22, SMBUS_READ_BLOCK, offsetof(struct acpi_battery, device_chemistry)},
315};
Rich Townsend3f86b832006-07-01 11:36:54 -0400316
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400317static struct acpi_battery_reader state_readers[] = {
318 {0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)},
319 {0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)},
Alexey Starikovskiy7faa1442009-03-27 22:23:52 -0400320 {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_now)},
321 {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_avg)},
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400322 {0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)},
323 {0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)},
324 {0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)},
325};
Rich Townsend3f86b832006-07-01 11:36:54 -0400326
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400327static int acpi_manager_get_info(struct acpi_sbs *sbs)
Rich Townsend3f86b832006-07-01 11:36:54 -0400328{
Rich Townsend3f86b832006-07-01 11:36:54 -0400329 int result = 0;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400330 u16 battery_system_info;
Rich Townsend3f86b832006-07-01 11:36:54 -0400331
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400332 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400333 0x04, (u8 *)&battery_system_info);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400334 if (!result)
335 sbs->batteries_supported = battery_system_info & 0x000f;
Len Brown635227e2006-07-01 16:48:23 -0400336 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400337}
338
339static int acpi_battery_get_info(struct acpi_battery *battery)
340{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400341 int i, result = 0;
Rich Townsend3f86b832006-07-01 11:36:54 -0400342
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400343 for (i = 0; i < ARRAY_SIZE(info_readers); ++i) {
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400344 result = acpi_smbus_read(battery->sbs->hc,
345 info_readers[i].mode,
346 ACPI_SBS_BATTERY,
347 info_readers[i].command,
348 (u8 *) battery +
349 info_readers[i].offset);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400350 if (result)
351 break;
Rich Townsend3f86b832006-07-01 11:36:54 -0400352 }
Len Brown635227e2006-07-01 16:48:23 -0400353 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400354}
355
Rich Townsend3f86b832006-07-01 11:36:54 -0400356static int acpi_battery_get_state(struct acpi_battery *battery)
357{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400358 int i, result = 0;
Rich Townsend3f86b832006-07-01 11:36:54 -0400359
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400360 if (battery->update_time &&
361 time_before(jiffies, battery->update_time +
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400362 msecs_to_jiffies(cache_time)))
363 return 0;
364 for (i = 0; i < ARRAY_SIZE(state_readers); ++i) {
365 result = acpi_smbus_read(battery->sbs->hc,
366 state_readers[i].mode,
367 ACPI_SBS_BATTERY,
368 state_readers[i].command,
Maximilian Luzc6237b22020-11-05 03:06:00 +0100369 (u8 *)battery +
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400370 state_readers[i].offset);
371 if (result)
372 goto end;
Rich Townsend3f86b832006-07-01 11:36:54 -0400373 }
Rich Townsend3f86b832006-07-01 11:36:54 -0400374 end:
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400375 battery->update_time = jiffies;
Len Brown635227e2006-07-01 16:48:23 -0400376 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400377}
378
379static int acpi_battery_get_alarm(struct acpi_battery *battery)
380{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400381 return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD,
382 ACPI_SBS_BATTERY, 0x01,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400383 (u8 *)&battery->alarm_capacity);
Rich Townsend3f86b832006-07-01 11:36:54 -0400384}
385
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400386static int acpi_battery_set_alarm(struct acpi_battery *battery)
Rich Townsend3f86b832006-07-01 11:36:54 -0400387{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400388 struct acpi_sbs *sbs = battery->sbs;
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400389 u16 value, sel = 1 << (battery->id + 12);
390
391 int ret;
392
Rich Townsend3f86b832006-07-01 11:36:54 -0400393
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400394 if (sbs->manager_present) {
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400395 ret = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER,
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400396 0x01, (u8 *)&value);
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400397 if (ret)
398 goto end;
399 if ((value & 0xf000) != sel) {
400 value &= 0x0fff;
401 value |= sel;
Colin Ian Kinga84bc8c2016-01-01 23:53:45 +0000402 ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400403 ACPI_SBS_MANAGER,
404 0x01, (u8 *)&value, 2);
Colin Ian Kinga84bc8c2016-01-01 23:53:45 +0000405 if (ret)
406 goto end;
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400407 }
Rich Townsend3f86b832006-07-01 11:36:54 -0400408 }
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400409 ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ACPI_SBS_BATTERY,
410 0x01, (u8 *)&battery->alarm_capacity, 2);
411 end:
412 return ret;
Rich Townsend3f86b832006-07-01 11:36:54 -0400413}
414
415static int acpi_ac_get_present(struct acpi_sbs *sbs)
416{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400417 int result;
418 u16 status;
Rich Townsend3f86b832006-07-01 11:36:54 -0400419
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400420 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_CHARGER,
421 0x13, (u8 *) & status);
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200422
423 if (result)
424 return result;
425
426 /*
427 * The spec requires that bit 4 always be 1. If it's not set, assume
Ronald Tschalärca1721c52018-09-30 19:52:51 -0700428 * that the implementation doesn't support an SBS charger.
429 *
430 * And on some MacBooks a status of 0xffff is always returned, no
431 * matter whether the charger is plugged in or not, which is also
432 * wrong, so ignore the SBS charger for those too.
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200433 */
Ronald Tschalärca1721c52018-09-30 19:52:51 -0700434 if (!((status >> 4) & 0x1) || status == 0xffff)
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200435 return -ENODEV;
436
437 sbs->charger_present = (status >> 15) & 0x1;
438 return 0;
Rich Townsend3f86b832006-07-01 11:36:54 -0400439}
440
Alexey Starikovskiy8bd95532007-09-26 19:44:00 +0400441static ssize_t acpi_battery_alarm_show(struct device *dev,
442 struct device_attribute *attr,
443 char *buf)
444{
445 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
446 acpi_battery_get_alarm(battery);
447 return sprintf(buf, "%d\n", battery->alarm_capacity *
448 acpi_battery_scale(battery) * 1000);
449}
450
451static ssize_t acpi_battery_alarm_store(struct device *dev,
452 struct device_attribute *attr,
453 const char *buf, size_t count)
454{
455 unsigned long x;
456 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
Luis G.F32a90512014-02-10 11:36:42 +0100457 if (sscanf(buf, "%lu\n", &x) == 1)
Alexey Starikovskiy8bd95532007-09-26 19:44:00 +0400458 battery->alarm_capacity = x /
459 (1000 * acpi_battery_scale(battery));
460 if (battery->present)
461 acpi_battery_set_alarm(battery);
462 return count;
463}
464
Bhumika Goyal82d2b612017-08-21 17:13:07 +0530465static const struct device_attribute alarm_attr = {
Parag Warudkar01e8ef12008-10-18 20:28:50 -0700466 .attr = {.name = "alarm", .mode = 0644},
Alexey Starikovskiy8bd95532007-09-26 19:44:00 +0400467 .show = acpi_battery_alarm_show,
468 .store = acpi_battery_alarm_store,
469};
470
Rich Townsend3f86b832006-07-01 11:36:54 -0400471/* --------------------------------------------------------------------------
Rich Townsend3f86b832006-07-01 11:36:54 -0400472 Driver Interface
473 -------------------------------------------------------------------------- */
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400474static int acpi_battery_read(struct acpi_battery *battery)
475{
476 int result = 0, saved_present = battery->present;
477 u16 state;
478
479 if (battery->sbs->manager_present) {
480 result = acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD,
481 ACPI_SBS_MANAGER, 0x01, (u8 *)&state);
482 if (!result)
483 battery->present = state & (1 << battery->id);
484 state &= 0x0fff;
485 state |= 1 << (battery->id + 12);
486 acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD,
487 ACPI_SBS_MANAGER, 0x01, (u8 *)&state, 2);
488 } else if (battery->id == 0)
489 battery->present = 1;
Matthew Garrett9faf6132014-09-20 13:19:46 +0200490
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400491 if (result || !battery->present)
492 return result;
493
494 if (saved_present != battery->present) {
495 battery->update_time = 0;
496 result = acpi_battery_get_info(battery);
Matthew Garrett9faf6132014-09-20 13:19:46 +0200497 if (result) {
498 battery->present = 0;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400499 return result;
Matthew Garrett9faf6132014-09-20 13:19:46 +0200500 }
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400501 }
502 result = acpi_battery_get_state(battery);
Matthew Garrett9faf6132014-09-20 13:19:46 +0200503 if (result)
504 battery->present = 0;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400505 return result;
506}
507
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400508/* Smart Battery */
Rich Townsend3f86b832006-07-01 11:36:54 -0400509static int acpi_battery_add(struct acpi_sbs *sbs, int id)
510{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400511 struct acpi_battery *battery = &sbs->battery[id];
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100512 struct power_supply_config psy_cfg = { .drv_data = battery, };
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400513 int result;
514
Rich Townsend3f86b832006-07-01 11:36:54 -0400515 battery->id = id;
516 battery->sbs = sbs;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400517 result = acpi_battery_read(battery);
518 if (result)
519 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400520
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400521 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100522 battery->bat_desc.name = battery->name;
523 battery->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY;
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400524 if (!acpi_battery_mode(battery)) {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100525 battery->bat_desc.properties = sbs_charge_battery_props;
526 battery->bat_desc.num_properties =
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400527 ARRAY_SIZE(sbs_charge_battery_props);
528 } else {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100529 battery->bat_desc.properties = sbs_energy_battery_props;
530 battery->bat_desc.num_properties =
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400531 ARRAY_SIZE(sbs_energy_battery_props);
532 }
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100533 battery->bat_desc.get_property = acpi_sbs_battery_get_property;
534 battery->bat = power_supply_register(&sbs->device->dev,
535 &battery->bat_desc, &psy_cfg);
536 if (IS_ERR(battery->bat)) {
537 result = PTR_ERR(battery->bat);
538 battery->bat = NULL;
Jeff Garzik037cbc62007-11-18 00:32:31 +0300539 goto end;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100540 }
Matthew Garrett9faf6132014-09-20 13:19:46 +0200541
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100542 result = device_create_file(&battery->bat->dev, &alarm_attr);
Jeff Garzik037cbc62007-11-18 00:32:31 +0300543 if (result)
544 goto end;
545 battery->have_sysfs_alarm = 1;
546 end:
Hanjun Guof7e02c82021-06-02 16:54:38 +0800547 pr_info("%s [%s]: Battery Slot [%s] (battery %s)\n",
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400548 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
Alexey Starikovskiybbafbec2008-02-09 03:22:13 -0500549 battery->name, battery->present ? "present" : "absent");
Len Brown635227e2006-07-01 16:48:23 -0400550 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400551}
552
553static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
554{
Jeff Garzik037cbc62007-11-18 00:32:31 +0300555 struct acpi_battery *battery = &sbs->battery[id];
Rakib Mullickc19bdb62010-01-03 19:27:56 +0600556
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100557 if (battery->bat) {
Jeff Garzik037cbc62007-11-18 00:32:31 +0300558 if (battery->have_sysfs_alarm)
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100559 device_remove_file(&battery->bat->dev, &alarm_attr);
560 power_supply_unregister(battery->bat);
Rich Townsend3f86b832006-07-01 11:36:54 -0400561 }
562}
563
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400564static int acpi_charger_add(struct acpi_sbs *sbs)
Rich Townsend3f86b832006-07-01 11:36:54 -0400565{
566 int result;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100567 struct power_supply_config psy_cfg = { .drv_data = sbs, };
Rich Townsend3f86b832006-07-01 11:36:54 -0400568
Rich Townsend3f86b832006-07-01 11:36:54 -0400569 result = acpi_ac_get_present(sbs);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400570 if (result)
Rich Townsend3f86b832006-07-01 11:36:54 -0400571 goto end;
Lan Tianyu2a68b992013-10-11 09:54:09 +0800572
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200573 sbs->charger_exists = 1;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100574 sbs->charger = power_supply_register(&sbs->device->dev,
575 &acpi_sbs_charger_desc, &psy_cfg);
576 if (IS_ERR(sbs->charger)) {
577 result = PTR_ERR(sbs->charger);
578 sbs->charger = NULL;
579 }
Hanjun Guof7e02c82021-06-02 16:54:38 +0800580 pr_info("%s [%s]: AC Adapter [%s] (%s)\n",
Vladimir Lebedev72206232007-03-19 17:45:50 +0300581 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
Alexey Starikovskiy89862e32007-09-26 19:43:35 +0400582 ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line");
Hanjun Guof7e02c82021-06-02 16:54:38 +0800583end:
Len Brown635227e2006-07-01 16:48:23 -0400584 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400585}
586
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400587static void acpi_charger_remove(struct acpi_sbs *sbs)
Rich Townsend3f86b832006-07-01 11:36:54 -0400588{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100589 if (sbs->charger)
590 power_supply_unregister(sbs->charger);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400591}
592
Adrian Bunke5685b92007-10-24 18:24:42 +0200593static void acpi_sbs_callback(void *context)
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400594{
595 int id;
596 struct acpi_sbs *sbs = context;
597 struct acpi_battery *bat;
598 u8 saved_charger_state = sbs->charger_present;
599 u8 saved_battery_state;
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200600
601 if (sbs->charger_exists) {
602 acpi_ac_get_present(sbs);
603 if (sbs->charger_present != saved_charger_state)
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100604 kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE);
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200605 }
Thomas Renninger1696d9d2013-07-15 10:15:09 +0200606
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400607 if (sbs->manager_present) {
608 for (id = 0; id < MAX_SBS_BAT; ++id) {
609 if (!(sbs->batteries_supported & (1 << id)))
610 continue;
611 bat = &sbs->battery[id];
612 saved_battery_state = bat->present;
613 acpi_battery_read(bat);
614 if (saved_battery_state == bat->present)
615 continue;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100616 kobject_uevent(&bat->bat->dev.kobj, KOBJ_CHANGE);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400617 }
Rich Townsend3f86b832006-07-01 11:36:54 -0400618 }
619}
620
Rich Townsend3f86b832006-07-01 11:36:54 -0400621static int acpi_sbs_add(struct acpi_device *device)
622{
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400623 struct acpi_sbs *sbs;
624 int result = 0;
Vladimir Lebedev6d157022007-03-19 17:45:50 +0300625 int id;
Rich Townsend3f86b832006-07-01 11:36:54 -0400626
Burman Yan36bcbec2006-12-19 12:56:11 -0800627 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL);
Rich Townsend3f86b832006-07-01 11:36:54 -0400628 if (!sbs) {
Vladimir Lebedev72206232007-03-19 17:45:50 +0300629 result = -ENOMEM;
630 goto end;
Rich Townsend3f86b832006-07-01 11:36:54 -0400631 }
Rich Townsend3f86b832006-07-01 11:36:54 -0400632
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400633 mutex_init(&sbs->lock);
Vladimir Lebedev72206232007-03-19 17:45:50 +0300634
Alexey Starikovskiy91087df2007-09-26 19:43:28 +0400635 sbs->hc = acpi_driver_data(device->parent);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400636 sbs->device = device;
Rich Townsend3f86b832006-07-01 11:36:54 -0400637 strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
638 strcpy(acpi_device_class(device), ACPI_SBS_CLASS);
Pavel Machekdb89b4f2008-09-22 14:37:34 -0700639 device->driver_data = sbs;
Rich Townsend3f86b832006-07-01 11:36:54 -0400640
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400641 result = acpi_charger_add(sbs);
Matthew Garrett3031cdd2014-09-20 13:19:45 +0200642 if (result && result != -ENODEV)
Vladimir Lebedev72206232007-03-19 17:45:50 +0300643 goto end;
Rich Townsend3f86b832006-07-01 11:36:54 -0400644
Matthew Garrett9faf6132014-09-20 13:19:46 +0200645 result = 0;
646
Lukas Wunner630b3af2017-08-01 14:10:41 +0200647 if (!x86_apple_machine) {
Matthew Garrett9faf6132014-09-20 13:19:46 +0200648 result = acpi_manager_get_info(sbs);
649 if (!result) {
Chris Bainbridge61f8ff62015-04-22 16:40:21 +0100650 sbs->manager_present = 1;
Matthew Garrett9faf6132014-09-20 13:19:46 +0200651 for (id = 0; id < MAX_SBS_BAT; ++id)
652 if ((sbs->batteries_supported & (1 << id)))
653 acpi_battery_add(sbs, id);
654 }
655 }
656
657 if (!sbs->manager_present)
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400658 acpi_battery_add(sbs, 0);
Matthew Garrett9faf6132014-09-20 13:19:46 +0200659
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400660 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs);
Hanjun Guof7e02c82021-06-02 16:54:38 +0800661end:
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400662 if (result)
Rafael J. Wysocki51fac832013-01-24 00:24:48 +0100663 acpi_sbs_remove(device);
Len Brown635227e2006-07-01 16:48:23 -0400664 return result;
Rich Townsend3f86b832006-07-01 11:36:54 -0400665}
666
Rafael J. Wysocki51fac832013-01-24 00:24:48 +0100667static int acpi_sbs_remove(struct acpi_device *device)
Rich Townsend3f86b832006-07-01 11:36:54 -0400668{
Len Browncece9012006-12-16 01:04:27 -0500669 struct acpi_sbs *sbs;
Rich Townsend3f86b832006-07-01 11:36:54 -0400670 int id;
671
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400672 if (!device)
Lebedev, Vladimir P963497c2006-09-05 19:49:13 +0400673 return -EINVAL;
Vladimir Lebedev72206232007-03-19 17:45:50 +0300674 sbs = acpi_driver_data(device);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400675 if (!sbs)
Len Brown635227e2006-07-01 16:48:23 -0400676 return -EINVAL;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400677 mutex_lock(&sbs->lock);
678 acpi_smbus_unregister_callback(sbs->hc);
679 for (id = 0; id < MAX_SBS_BAT; ++id)
Rich Townsend3f86b832006-07-01 11:36:54 -0400680 acpi_battery_remove(sbs, id);
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400681 acpi_charger_remove(sbs);
682 mutex_unlock(&sbs->lock);
683 mutex_destroy(&sbs->lock);
Rich Townsend3f86b832006-07-01 11:36:54 -0400684 kfree(sbs);
Len Brown635227e2006-07-01 16:48:23 -0400685 return 0;
Rich Townsend3f86b832006-07-01 11:36:54 -0400686}
687
Rafael J. Wysocki90692402012-08-09 23:00:02 +0200688#ifdef CONFIG_PM_SLEEP
Rafael J. Wysockid202f772012-06-27 23:27:07 +0200689static int acpi_sbs_resume(struct device *dev)
Vladimir Lebedev72206232007-03-19 17:45:50 +0300690{
691 struct acpi_sbs *sbs;
Rafael J. Wysockid202f772012-06-27 23:27:07 +0200692 if (!dev)
Vladimir Lebedev72206232007-03-19 17:45:50 +0300693 return -EINVAL;
Rafael J. Wysockid202f772012-06-27 23:27:07 +0200694 sbs = to_acpi_device(dev)->driver_data;
Alexey Starikovskiydb1c2912007-09-26 19:43:41 +0400695 acpi_sbs_callback(sbs);
Vladimir Lebedev72206232007-03-19 17:45:50 +0300696 return 0;
697}
Shuah Khan15029dd2014-02-12 20:19:09 -0700698#else
699#define acpi_sbs_resume NULL
Rafael J. Wysocki90692402012-08-09 23:00:02 +0200700#endif
Vladimir Lebedev72206232007-03-19 17:45:50 +0300701
Rafael J. Wysockid202f772012-06-27 23:27:07 +0200702static SIMPLE_DEV_PM_OPS(acpi_sbs_pm, NULL, acpi_sbs_resume);
703
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400704static struct acpi_driver acpi_sbs_driver = {
705 .name = "sbs",
706 .class = ACPI_SBS_CLASS,
707 .ids = sbs_device_ids,
708 .ops = {
709 .add = acpi_sbs_add,
710 .remove = acpi_sbs_remove,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400711 },
Rafael J. Wysockid202f772012-06-27 23:27:07 +0200712 .drv.pm = &acpi_sbs_pm,
Alexey Starikovskiy94f6c082007-09-26 19:43:48 +0400713};
Hanjun Guoe882b092020-11-13 10:25:11 +0800714module_acpi_driver(acpi_sbs_driver);