Skip to content

Commit 5508f3f

Browse files
xry111MingcongBai
authored andcommitted
AOSCOS: ACPI / scan: Add pwm_lookup_entry for PWM3 on LS7A
On LoongArch laptops using LG110 GPU for display, LS7A PWM3 is used for backlight brightness control. Thus we need to call pwm_add_table() so that the loonggpu driver can find the PWM for controlling the backlight. Signed-off-by: Xi Ruoyao <[email protected]>
1 parent 8158940 commit 5508f3f

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

drivers/acpi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,4 @@ obj-$(CONFIG_ACPI_VIOT) += viot.o
134134

135135
obj-$(CONFIG_RISCV) += riscv/
136136
obj-$(CONFIG_X86) += x86/
137+
obj-$(CONFIG_LOONGARCH) += loongarch/

drivers/acpi/internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ void acpi_lpss_init(void);
7676
static inline void acpi_lpss_init(void) {}
7777
#endif
7878

79+
#if IS_ENABLED(CONFIG_PWM_LOONGSON)
80+
void acpi_ls7a_pwm_init(void);
81+
#else
82+
static inline void acpi_ls7a_pwm_init(void) {}
83+
#endif
84+
7985
void acpi_apd_init(void);
8086

8187
acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);

drivers/acpi/loongarch/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ifdef CONFIG_PWM_LOONGSON
2+
obj-y += acpi-ls7a-backlight.o
3+
endif
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2025 Xi Ruoyao <[email protected]>
4+
*
5+
* ACPI support for devices using LG110 <sarcasm>discrete</sarcasm> graphics
6+
* with LS7A PWM controlling the backlight.
7+
*/
8+
9+
#include <linux/acpi.h>
10+
#include <linux/pwm.h>
11+
12+
#include "../internal.h"
13+
14+
static struct pwm_lookup ls7a_pwm_lookup[] = {
15+
PWM_LOOKUP_WITH_MODULE("LOON0006:03", 0, NULL, "gsgpu_backlight", 0,
16+
PWM_POLARITY_NORMAL, "pwm-loongson"),
17+
};
18+
19+
static int acpi_ls7a_pwm_attach(struct acpi_device *adev,
20+
const struct acpi_device_id *id)
21+
{
22+
if (acpi_dev_uid_match(adev, 3))
23+
pwm_add_table(ls7a_pwm_lookup, ARRAY_SIZE(ls7a_pwm_lookup));
24+
25+
return 0;
26+
}
27+
28+
static const struct acpi_device_id acpi_ls7a_pwm_ids[] = {
29+
{ "LOON0006", 0 },
30+
{ },
31+
};
32+
33+
static struct acpi_scan_handler ls7a_pwm_handler = {
34+
.ids = acpi_ls7a_pwm_ids,
35+
.attach = acpi_ls7a_pwm_attach,
36+
};
37+
38+
39+
void __init acpi_ls7a_pwm_init(void)
40+
{
41+
acpi_scan_add_handler(&ls7a_pwm_handler);
42+
}

drivers/acpi/scan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,6 +2707,7 @@ void __init acpi_scan_init(void)
27072707
acpi_pnp_init();
27082708
acpi_int340x_thermal_init();
27092709
acpi_init_lpit();
2710+
acpi_ls7a_pwm_init();
27102711

27112712
acpi_scan_add_handler(&generic_device_handler);
27122713

0 commit comments

Comments
 (0)