Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit fa0d938

Browse files
committed
Merge branches 'acpi-pmic', 'acpi-battery' and 'acpi-numa'
Merge ACPI PMIC driver changes, updates related to the ACPI battery and SBS drivers and NUMA-related ACPI updates for 6.11-rc1: - Clean up the ACPI PMIC driver in multiple ways (Andy Shevchenko, Christophe JAILLET). - Add support for charge limiting state to the ACPI battery driver and update _OSC to indicate support for it (Armin Wolf). - Clean up the sysfs interface in the ACPI battery, SBS (smart battery subsystem) and AC drivers (Thomas Weißschuh). - Coordinate header includes in the ACPI NUMA code and make it use ACCESS_COORDINATE_CPU when appropriate (Huang Ying, Thorsten Blum). * acpi-pmic: ACPI: PMIC: Constify struct pmic_table ACPI: PMIC: Replace open coded be16_to_cpu() ACPI: PMIC: Convert pr_*() to dev_*() printing macros ACPI: PMIC: Use sizeof() instead of hard coded value * acpi-battery: ACPI: bus: Indicate support for battery charge limiting thru _OSC ACPI: battery: Add support for charge limiting state ACPI: SBS: manage alarm sysfs attribute through psy core ACPI: battery: create alarm sysfs attribute atomically ACPI: battery: use sysfs_emit over sprintf ACPI: battery: constify powersupply properties ACPI: SBS: constify powersupply properties ACPI: AC: constify powersupply properties * acpi-numa: ACPI: NUMA: Consolidate header includes ACPI: HMAT: Use ACCESS_COORDINATE_CPU when appropriate
4 parents e598dd4 + cfff199 + face1c5 + 79a947b commit fa0d938

File tree

13 files changed

+74
-56
lines changed

13 files changed

+74
-56
lines changed

drivers/acpi/ac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int get_ac_property(struct power_supply *psy,
112112
return 0;
113113
}
114114

115-
static enum power_supply_property ac_props[] = {
115+
static const enum power_supply_property ac_props[] = {
116116
POWER_SUPPLY_PROP_ONLINE,
117117
};
118118

drivers/acpi/battery.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
/* Battery power unit: 0 means mW, 1 means mA */
3939
#define ACPI_BATTERY_POWER_UNIT_MA 1
4040

41-
#define ACPI_BATTERY_STATE_DISCHARGING 0x1
42-
#define ACPI_BATTERY_STATE_CHARGING 0x2
43-
#define ACPI_BATTERY_STATE_CRITICAL 0x4
41+
#define ACPI_BATTERY_STATE_DISCHARGING 0x1
42+
#define ACPI_BATTERY_STATE_CHARGING 0x2
43+
#define ACPI_BATTERY_STATE_CRITICAL 0x4
44+
#define ACPI_BATTERY_STATE_CHARGE_LIMITING 0x8
4445

4546
#define MAX_STRING_LENGTH 64
4647

@@ -155,7 +156,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery);
155156

156157
static int acpi_battery_is_charged(struct acpi_battery *battery)
157158
{
158-
/* charging, discharging or critical low */
159+
/* charging, discharging, critical low or charge limited */
159160
if (battery->state != 0)
160161
return 0;
161162

@@ -215,6 +216,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
215216
val->intval = acpi_battery_handle_discharging(battery);
216217
else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
217218
val->intval = POWER_SUPPLY_STATUS_CHARGING;
219+
else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING)
220+
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
218221
else if (acpi_battery_is_charged(battery))
219222
val->intval = POWER_SUPPLY_STATUS_FULL;
220223
else
@@ -308,7 +311,7 @@ static int acpi_battery_get_property(struct power_supply *psy,
308311
return ret;
309312
}
310313

311-
static enum power_supply_property charge_battery_props[] = {
314+
static const enum power_supply_property charge_battery_props[] = {
312315
POWER_SUPPLY_PROP_STATUS,
313316
POWER_SUPPLY_PROP_PRESENT,
314317
POWER_SUPPLY_PROP_TECHNOLOGY,
@@ -326,7 +329,7 @@ static enum power_supply_property charge_battery_props[] = {
326329
POWER_SUPPLY_PROP_SERIAL_NUMBER,
327330
};
328331

329-
static enum power_supply_property charge_battery_full_cap_broken_props[] = {
332+
static const enum power_supply_property charge_battery_full_cap_broken_props[] = {
330333
POWER_SUPPLY_PROP_STATUS,
331334
POWER_SUPPLY_PROP_PRESENT,
332335
POWER_SUPPLY_PROP_TECHNOLOGY,
@@ -340,7 +343,7 @@ static enum power_supply_property charge_battery_full_cap_broken_props[] = {
340343
POWER_SUPPLY_PROP_SERIAL_NUMBER,
341344
};
342345

343-
static enum power_supply_property energy_battery_props[] = {
346+
static const enum power_supply_property energy_battery_props[] = {
344347
POWER_SUPPLY_PROP_STATUS,
345348
POWER_SUPPLY_PROP_PRESENT,
346349
POWER_SUPPLY_PROP_TECHNOLOGY,
@@ -358,7 +361,7 @@ static enum power_supply_property energy_battery_props[] = {
358361
POWER_SUPPLY_PROP_SERIAL_NUMBER,
359362
};
360363

361-
static enum power_supply_property energy_battery_full_cap_broken_props[] = {
364+
static const enum power_supply_property energy_battery_full_cap_broken_props[] = {
362365
POWER_SUPPLY_PROP_STATUS,
363366
POWER_SUPPLY_PROP_PRESENT,
364367
POWER_SUPPLY_PROP_TECHNOLOGY,
@@ -661,7 +664,7 @@ static ssize_t acpi_battery_alarm_show(struct device *dev,
661664
{
662665
struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
663666

664-
return sprintf(buf, "%d\n", battery->alarm * 1000);
667+
return sysfs_emit(buf, "%d\n", battery->alarm * 1000);
665668
}
666669

667670
static ssize_t acpi_battery_alarm_store(struct device *dev,
@@ -678,12 +681,18 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,
678681
return count;
679682
}
680683

681-
static const struct device_attribute alarm_attr = {
684+
static struct device_attribute alarm_attr = {
682685
.attr = {.name = "alarm", .mode = 0644},
683686
.show = acpi_battery_alarm_show,
684687
.store = acpi_battery_alarm_store,
685688
};
686689

690+
static struct attribute *acpi_battery_attrs[] = {
691+
&alarm_attr.attr,
692+
NULL
693+
};
694+
ATTRIBUTE_GROUPS(acpi_battery);
695+
687696
/*
688697
* The Battery Hooking API
689698
*
@@ -823,7 +832,10 @@ static void __exit battery_hook_exit(void)
823832

824833
static int sysfs_add_battery(struct acpi_battery *battery)
825834
{
826-
struct power_supply_config psy_cfg = { .drv_data = battery, };
835+
struct power_supply_config psy_cfg = {
836+
.drv_data = battery,
837+
.attr_grp = acpi_battery_groups,
838+
};
827839
bool full_cap_broken = false;
828840

829841
if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) &&
@@ -868,7 +880,7 @@ static int sysfs_add_battery(struct acpi_battery *battery)
868880
return result;
869881
}
870882
battery_hook_add_battery(battery);
871-
return device_create_file(&battery->bat->dev, &alarm_attr);
883+
return 0;
872884
}
873885

874886
static void sysfs_remove_battery(struct acpi_battery *battery)
@@ -879,7 +891,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
879891
return;
880892
}
881893
battery_hook_remove_battery(battery);
882-
device_remove_file(&battery->bat->dev, &alarm_attr);
883894
power_supply_unregister(battery->bat);
884895
battery->bat = NULL;
885896
mutex_unlock(&battery->sysfs_lock);

drivers/acpi/bus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ static void acpi_bus_osc_negotiate_platform_control(void)
329329
capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT;
330330
if (IS_ENABLED(CONFIG_ACPI_THERMAL))
331331
capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT;
332+
if (IS_ENABLED(CONFIG_ACPI_BATTERY))
333+
capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT;
332334

333335
capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT;
334336
capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PCLPI_SUPPORT;

drivers/acpi/numa/hmat.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_px
408408
if (target && target->processor_pxm == init_pxm) {
409409
hmat_update_target_access(target, type, value,
410410
ACCESS_COORDINATE_LOCAL);
411-
/* If the node has a CPU, update access 1 */
411+
/* If the node has a CPU, update access ACCESS_COORDINATE_CPU */
412412
if (node_state(pxm_to_node(init_pxm), N_CPU))
413413
hmat_update_target_access(target, type, value,
414414
ACCESS_COORDINATE_CPU);
@@ -948,7 +948,7 @@ static int hmat_set_default_dram_perf(void)
948948
target = find_mem_target(pxm);
949949
if (!target)
950950
continue;
951-
attrs = &target->coord[1];
951+
attrs = &target->coord[ACCESS_COORDINATE_CPU];
952952
rc = mt_set_default_dram_perf(nid, attrs, "ACPI HMAT");
953953
if (rc)
954954
return rc;
@@ -975,7 +975,7 @@ static int hmat_calculate_adistance(struct notifier_block *self,
975975
hmat_update_target_attrs(target, p_nodes, ACCESS_COORDINATE_CPU);
976976
mutex_unlock(&target_lock);
977977

978-
perf = &target->coord[1];
978+
perf = &target->coord[ACCESS_COORDINATE_CPU];
979979

980980
if (mt_perf_to_adistance(perf, adist))
981981
return NOTIFY_OK;

drivers/acpi/pmic/intel_pmic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct intel_pmic_opregion {
3131

3232
static struct intel_pmic_opregion *intel_pmic_opregion;
3333

34-
static int pmic_get_reg_bit(int address, struct pmic_table *table,
34+
static int pmic_get_reg_bit(int address, const struct pmic_table *table,
3535
int count, int *reg, int *bit)
3636
{
3737
int i;

drivers/acpi/pmic/intel_pmic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct intel_pmic_opregion_data {
2121
u32 reg_address, u32 value, u32 mask);
2222
int (*lpat_raw_to_temp)(struct acpi_lpat_conversion_table *lpat_table,
2323
int raw);
24-
struct pmic_table *power_table;
24+
const struct pmic_table *power_table;
2525
int power_table_count;
26-
struct pmic_table *thermal_table;
26+
const struct pmic_table *thermal_table;
2727
int thermal_table_count;
2828
/* For generic exec_mipi_pmic_seq_element handling */
2929
int pmic_i2c_address;

drivers/acpi/pmic/intel_pmic_bxtwc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define VSWITCH1_OUTPUT BIT(4)
2525
#define VUSBPHY_CHARGE BIT(1)
2626

27-
static struct pmic_table power_table[] = {
27+
static const struct pmic_table power_table[] = {
2828
{
2929
.address = 0x0,
3030
.reg = 0x63,
@@ -177,7 +177,7 @@ static struct pmic_table power_table[] = {
177177
} /* MOFF -> MODEMCTRL Bit 0 */
178178
};
179179

180-
static struct pmic_table thermal_table[] = {
180+
static const struct pmic_table thermal_table[] = {
181181
{
182182
.address = 0x00,
183183
.reg = 0x4F39

drivers/acpi/pmic/intel_pmic_bytcrc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#define PMIC_A0LOCK_REG 0xc5
1818

19-
static struct pmic_table power_table[] = {
19+
static const struct pmic_table power_table[] = {
2020
/* {
2121
.address = 0x00,
2222
.reg = ??,
@@ -134,7 +134,7 @@ static struct pmic_table power_table[] = {
134134
}, /* V105 -> V1P05S, L2 SRAM */
135135
};
136136

137-
static struct pmic_table thermal_table[] = {
137+
static const struct pmic_table thermal_table[] = {
138138
{
139139
.address = 0x00,
140140
.reg = 0x75

drivers/acpi/pmic/intel_pmic_chtdc_ti.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@
88
*/
99

1010
#include <linux/acpi.h>
11+
#include <linux/bits.h>
1112
#include <linux/init.h>
1213
#include <linux/mfd/intel_soc_pmic.h>
1314
#include <linux/platform_device.h>
15+
#include <asm/byteorder.h>
1416
#include "intel_pmic.h"
1517

1618
/* registers stored in 16bit BE (high:low, total 10bit) */
19+
#define PMIC_REG_MASK GENMASK(9, 0)
20+
1721
#define CHTDC_TI_VBAT 0x54
1822
#define CHTDC_TI_DIETEMP 0x56
1923
#define CHTDC_TI_BPTHERM 0x58
2024
#define CHTDC_TI_GPADC 0x5a
2125

22-
static struct pmic_table chtdc_ti_power_table[] = {
26+
static const struct pmic_table chtdc_ti_power_table[] = {
2327
{ .address = 0x00, .reg = 0x41 }, /* LDO1 */
2428
{ .address = 0x04, .reg = 0x42 }, /* LDO2 */
2529
{ .address = 0x08, .reg = 0x43 }, /* LDO3 */
@@ -35,7 +39,7 @@ static struct pmic_table chtdc_ti_power_table[] = {
3539
{ .address = 0x30, .reg = 0x4e }, /* LD14 */
3640
};
3741

38-
static struct pmic_table chtdc_ti_thermal_table[] = {
42+
static const struct pmic_table chtdc_ti_thermal_table[] = {
3943
{
4044
.address = 0x00,
4145
.reg = CHTDC_TI_GPADC
@@ -73,7 +77,7 @@ static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit,
7377
if (regmap_read(regmap, reg, &data))
7478
return -EIO;
7579

76-
*value = data & 1;
80+
*value = data & BIT(0);
7781
return 0;
7882
}
7983

@@ -85,13 +89,12 @@ static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
8589

8690
static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
8791
{
88-
u8 buf[2];
92+
__be16 buf;
8993

90-
if (regmap_bulk_read(regmap, reg, buf, 2))
94+
if (regmap_bulk_read(regmap, reg, &buf, sizeof(buf)))
9195
return -EIO;
9296

93-
/* stored in big-endian */
94-
return ((buf[0] & 0x03) << 8) | buf[1];
97+
return be16_to_cpu(buf) & PMIC_REG_MASK;
9598
}
9699

97100
static const struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {

drivers/acpi/pmic/intel_pmic_chtwc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
* "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support"
7171
* https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch
7272
*/
73-
static struct pmic_table power_table[] = {
73+
static const struct pmic_table power_table[] = {
7474
{
7575
.address = 0x0,
7676
.reg = CHT_WC_V1P8A_CTRL,
@@ -236,11 +236,12 @@ static int intel_cht_wc_exec_mipi_pmic_seq_element(struct regmap *regmap,
236236
u32 reg_address,
237237
u32 value, u32 mask)
238238
{
239+
struct device *dev = regmap_get_device(regmap);
239240
u32 address;
240241

241242
if (i2c_client_address > 0xff || reg_address > 0xff) {
242-
pr_warn("%s warning addresses too big client 0x%x reg 0x%x\n",
243-
__func__, i2c_client_address, reg_address);
243+
dev_warn(dev, "warning addresses too big client 0x%x reg 0x%x\n",
244+
i2c_client_address, reg_address);
244245
return -ERANGE;
245246
}
246247

0 commit comments

Comments
 (0)