Skip to content

Commit a24e16b

Browse files
committed
Merge branches 'pm-pci', 'acpi-pm', 'pm-sleep' and 'pm-avs'
* pm-pci: PCI / PM: Clean up outdated comments in pci_target_state() PCI / PM: Do not clear state_saved for devices that remain suspended * acpi-pm: ACPI: EC: Dispatch the EC GPE directly on s2idle wake ACPICA: Introduce acpi_dispatch_gpe() * pm-sleep: PM / hibernate: Fix oops at snapshot_write() PM / wakeup: Make s2idle_lock a RAW_SPINLOCK PM / s2idle: Make s2idle_wait_head swait based PM / wakeup: Make events_lock a RAW_SPINLOCK PM / suspend: Prevent might sleep splats * pm-avs: PM / AVS: rockchip-io: add io selectors and supplies for PX30
5 parents 601ef1f + 60ee031 + 68e2201 + fc14eeb + b8281fa commit a24e16b

File tree

16 files changed

+171
-26
lines changed

16 files changed

+171
-26
lines changed

Documentation/devicetree/bindings/power/rockchip-io-domain.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ SoC is on the same page.
3131

3232
Required properties:
3333
- compatible: should be one of:
34+
- "rockchip,px30-io-voltage-domain" for px30
35+
- "rockchip,px30-pmu-io-voltage-domain" for px30 pmu-domains
3436
- "rockchip,rk3188-io-voltage-domain" for rk3188
3537
- "rockchip,rk3228-io-voltage-domain" for rk3228
3638
- "rockchip,rk3288-io-voltage-domain" for rk3288
@@ -51,6 +53,19 @@ a phandle the relevant regulator. All specified supplies must be able
5153
to report their voltage. The IO Voltage Domain for any non-specified
5254
supplies will be not be touched.
5355

56+
Possible supplies for PX30:
57+
- vccio6-supply: The supply connected to VCCIO6.
58+
- vccio1-supply: The supply connected to VCCIO1.
59+
- vccio2-supply: The supply connected to VCCIO2.
60+
- vccio3-supply: The supply connected to VCCIO3.
61+
- vccio4-supply: The supply connected to VCCIO4.
62+
- vccio5-supply: The supply connected to VCCIO5.
63+
- vccio-oscgpi-supply: The supply connected to VCCIO_OSCGPI.
64+
65+
Possible supplies for PX30 pmu-domains:
66+
- pmuio1-supply: The supply connected to PMUIO1.
67+
- pmuio2-supply: The supply connected to PMUIO2.
68+
5469
Possible supplies for rk3188:
5570
- ap0-supply: The supply connected to AP0_VCC.
5671
- ap1-supply: The supply connected to AP1_VCC.

drivers/acpi/acpica/evgpe.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,12 @@ acpi_ev_detect_gpe(struct acpi_namespace_node *gpe_device,
634634

635635
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
636636

637+
if (!gpe_event_info) {
638+
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
639+
if (!gpe_event_info)
640+
goto error_exit;
641+
}
642+
637643
/* Get the info block for the entire GPE register */
638644

639645
gpe_register_info = gpe_event_info->register_info;

drivers/acpi/acpica/evxfgpe.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,28 @@ acpi_get_gpe_status(acpi_handle gpe_device,
637637

638638
ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
639639

640+
/*******************************************************************************
641+
*
642+
* FUNCTION: acpi_gispatch_gpe
643+
*
644+
* PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
645+
* gpe_number - GPE level within the GPE block
646+
*
647+
* RETURN: None
648+
*
649+
* DESCRIPTION: Detect and dispatch a General Purpose Event to either a function
650+
* (e.g. EC) or method (e.g. _Lxx/_Exx) handler.
651+
*
652+
******************************************************************************/
653+
void acpi_dispatch_gpe(acpi_handle gpe_device, u32 gpe_number)
654+
{
655+
ACPI_FUNCTION_TRACE(acpi_dispatch_gpe);
656+
657+
acpi_ev_detect_gpe(gpe_device, NULL, gpe_number);
658+
}
659+
660+
ACPI_EXPORT_SYMBOL(acpi_dispatch_gpe)
661+
640662
/*******************************************************************************
641663
*
642664
* FUNCTION: acpi_finish_gpe

drivers/acpi/ec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,12 @@ void acpi_ec_unblock_transactions(void)
10341034
acpi_ec_start(first_ec, true);
10351035
}
10361036

1037+
void acpi_ec_dispatch_gpe(void)
1038+
{
1039+
if (first_ec)
1040+
acpi_dispatch_gpe(NULL, first_ec->gpe);
1041+
}
1042+
10371043
/* --------------------------------------------------------------------------
10381044
Event Management
10391045
-------------------------------------------------------------------------- */

drivers/acpi/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ int acpi_ec_ecdt_probe(void);
188188
int acpi_ec_dsdt_probe(void);
189189
void acpi_ec_block_transactions(void);
190190
void acpi_ec_unblock_transactions(void);
191+
void acpi_ec_dispatch_gpe(void);
191192
int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
192193
acpi_handle handle, acpi_ec_query_func func,
193194
void *data);

drivers/acpi/sleep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,13 @@ static void acpi_s2idle_wake(void)
989989
!irqd_is_wakeup_armed(irq_get_irq_data(acpi_sci_irq))) {
990990
pm_system_cancel_wakeup();
991991
s2idle_wakeup = true;
992+
/*
993+
* On some platforms with the LPS0 _DSM device noirq resume
994+
* takes too much time for EC wakeup events to survive, so look
995+
* for them now.
996+
*/
997+
if (lps0_device_handle)
998+
acpi_ec_dispatch_gpe();
992999
}
9931000
}
9941001

drivers/base/power/wakeup.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void split_counters(unsigned int *cnt, unsigned int *inpr)
5757
/* A preserved old value of the events counter. */
5858
static unsigned int saved_count;
5959

60-
static DEFINE_SPINLOCK(events_lock);
60+
static DEFINE_RAW_SPINLOCK(events_lock);
6161

6262
static void pm_wakeup_timer_fn(struct timer_list *t);
6363

@@ -184,9 +184,9 @@ void wakeup_source_add(struct wakeup_source *ws)
184184
timer_setup(&ws->timer, pm_wakeup_timer_fn, 0);
185185
ws->active = false;
186186

187-
spin_lock_irqsave(&events_lock, flags);
187+
raw_spin_lock_irqsave(&events_lock, flags);
188188
list_add_rcu(&ws->entry, &wakeup_sources);
189-
spin_unlock_irqrestore(&events_lock, flags);
189+
raw_spin_unlock_irqrestore(&events_lock, flags);
190190
}
191191
EXPORT_SYMBOL_GPL(wakeup_source_add);
192192

@@ -201,9 +201,9 @@ void wakeup_source_remove(struct wakeup_source *ws)
201201
if (WARN_ON(!ws))
202202
return;
203203

204-
spin_lock_irqsave(&events_lock, flags);
204+
raw_spin_lock_irqsave(&events_lock, flags);
205205
list_del_rcu(&ws->entry);
206-
spin_unlock_irqrestore(&events_lock, flags);
206+
raw_spin_unlock_irqrestore(&events_lock, flags);
207207
synchronize_srcu(&wakeup_srcu);
208208
}
209209
EXPORT_SYMBOL_GPL(wakeup_source_remove);
@@ -842,15 +842,15 @@ bool pm_wakeup_pending(void)
842842
unsigned long flags;
843843
bool ret = false;
844844

845-
spin_lock_irqsave(&events_lock, flags);
845+
raw_spin_lock_irqsave(&events_lock, flags);
846846
if (events_check_enabled) {
847847
unsigned int cnt, inpr;
848848

849849
split_counters(&cnt, &inpr);
850850
ret = (cnt != saved_count || inpr > 0);
851851
events_check_enabled = !ret;
852852
}
853-
spin_unlock_irqrestore(&events_lock, flags);
853+
raw_spin_unlock_irqrestore(&events_lock, flags);
854854

855855
if (ret) {
856856
pr_debug("PM: Wakeup pending, aborting suspend\n");
@@ -939,13 +939,13 @@ bool pm_save_wakeup_count(unsigned int count)
939939
unsigned long flags;
940940

941941
events_check_enabled = false;
942-
spin_lock_irqsave(&events_lock, flags);
942+
raw_spin_lock_irqsave(&events_lock, flags);
943943
split_counters(&cnt, &inpr);
944944
if (cnt == count && inpr == 0) {
945945
saved_count = count;
946946
events_check_enabled = true;
947947
}
948-
spin_unlock_irqrestore(&events_lock, flags);
948+
raw_spin_unlock_irqrestore(&events_lock, flags);
949949
return events_check_enabled;
950950
}
951951

drivers/pci/pci-driver.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,11 @@ static int pci_pm_suspend(struct device *dev)
753753
* better to resume the device from runtime suspend here.
754754
*/
755755
if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND) ||
756-
!pci_dev_keep_suspended(pci_dev))
756+
!pci_dev_keep_suspended(pci_dev)) {
757757
pm_runtime_resume(dev);
758+
pci_dev->state_saved = false;
759+
}
758760

759-
pci_dev->state_saved = false;
760761
if (pm->suspend) {
761762
pci_power_t prev = pci_dev->current_state;
762763
int error;

drivers/pci/pci.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,8 +2025,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
20252025

20262026
if (platform_pci_power_manageable(dev)) {
20272027
/*
2028-
* Call the platform to choose the target state of the device
2029-
* and enable wake-up from this state if supported.
2028+
* Call the platform to find the target state for the device.
20302029
*/
20312030
pci_power_t state = platform_pci_choose_state(dev);
20322031

@@ -2059,8 +2058,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
20592058
if (wakeup) {
20602059
/*
20612060
* Find the deepest state from which the device can generate
2062-
* wake-up events, make it the target state and enable device
2063-
* to generate PME#.
2061+
* PME#.
20642062
*/
20652063
if (dev->pme_support) {
20662064
while (target_state

drivers/power/avs/rockchip-io-domain.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#define MAX_VOLTAGE_1_8 1980000
4040
#define MAX_VOLTAGE_3_3 3600000
4141

42+
#define PX30_IO_VSEL 0x180
43+
#define PX30_IO_VSEL_VCCIO6_SRC BIT(0)
44+
#define PX30_IO_VSEL_VCCIO6_SUPPLY_NUM 1
45+
4246
#define RK3288_SOC_CON2 0x24c
4347
#define RK3288_SOC_CON2_FLASH0 BIT(7)
4448
#define RK3288_SOC_FLASH_SUPPLY_NUM 2
@@ -151,6 +155,25 @@ static int rockchip_iodomain_notify(struct notifier_block *nb,
151155
return NOTIFY_OK;
152156
}
153157

158+
static void px30_iodomain_init(struct rockchip_iodomain *iod)
159+
{
160+
int ret;
161+
u32 val;
162+
163+
/* if no VCCIO0 supply we should leave things alone */
164+
if (!iod->supplies[PX30_IO_VSEL_VCCIO6_SUPPLY_NUM].reg)
165+
return;
166+
167+
/*
168+
* set vccio0 iodomain to also use this framework
169+
* instead of a special gpio.
170+
*/
171+
val = PX30_IO_VSEL_VCCIO6_SRC | (PX30_IO_VSEL_VCCIO6_SRC << 16);
172+
ret = regmap_write(iod->grf, PX30_IO_VSEL, val);
173+
if (ret < 0)
174+
dev_warn(iod->dev, "couldn't update vccio0 ctrl\n");
175+
}
176+
154177
static void rk3288_iodomain_init(struct rockchip_iodomain *iod)
155178
{
156179
int ret;
@@ -227,6 +250,43 @@ static void rk3399_pmu_iodomain_init(struct rockchip_iodomain *iod)
227250
dev_warn(iod->dev, "couldn't update pmu io iodomain ctrl\n");
228251
}
229252

253+
static const struct rockchip_iodomain_soc_data soc_data_px30 = {
254+
.grf_offset = 0x180,
255+
.supply_names = {
256+
NULL,
257+
"vccio6",
258+
"vccio1",
259+
"vccio2",
260+
"vccio3",
261+
"vccio4",
262+
"vccio5",
263+
"vccio-oscgpi",
264+
},
265+
.init = px30_iodomain_init,
266+
};
267+
268+
static const struct rockchip_iodomain_soc_data soc_data_px30_pmu = {
269+
.grf_offset = 0x100,
270+
.supply_names = {
271+
NULL,
272+
NULL,
273+
NULL,
274+
NULL,
275+
NULL,
276+
NULL,
277+
NULL,
278+
NULL,
279+
NULL,
280+
NULL,
281+
NULL,
282+
NULL,
283+
NULL,
284+
NULL,
285+
"pmuio1",
286+
"pmuio2",
287+
},
288+
};
289+
230290
/*
231291
* On the rk3188 the io-domains are handled by a shared register with the
232292
* lower 8 bits being still being continuing drive-strength settings.
@@ -380,6 +440,14 @@ static const struct rockchip_iodomain_soc_data soc_data_rv1108_pmu = {
380440
};
381441

382442
static const struct of_device_id rockchip_iodomain_match[] = {
443+
{
444+
.compatible = "rockchip,px30-io-voltage-domain",
445+
.data = (void *)&soc_data_px30
446+
},
447+
{
448+
.compatible = "rockchip,px30-pmu-io-voltage-domain",
449+
.data = (void *)&soc_data_px30_pmu
450+
},
383451
{
384452
.compatible = "rockchip,rk3188-io-voltage-domain",
385453
.data = &soc_data_rk3188

include/acpi/acpixf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
753753
u32 gpe_number,
754754
acpi_event_status
755755
*event_status))
756+
ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_dispatch_gpe(acpi_handle gpe_device, u32 gpe_number))
756757
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void))
757758
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void))
758759
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void))

include/linux/kernel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ extern enum system_states {
542542
SYSTEM_HALT,
543543
SYSTEM_POWER_OFF,
544544
SYSTEM_RESTART,
545+
SYSTEM_SUSPEND,
545546
} system_state;
546547

547548
/* This cannot be an enum because some may be used in assembly source. */

kernel/power/hibernate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ static int create_image(int platform_mode)
287287

288288
local_irq_disable();
289289

290+
system_state = SYSTEM_SUSPEND;
291+
290292
error = syscore_suspend();
291293
if (error) {
292294
pr_err("Some system devices failed to power down, aborting hibernation\n");
@@ -317,6 +319,7 @@ static int create_image(int platform_mode)
317319
syscore_resume();
318320

319321
Enable_irqs:
322+
system_state = SYSTEM_RUNNING;
320323
local_irq_enable();
321324

322325
Enable_cpus:
@@ -445,6 +448,7 @@ static int resume_target_kernel(bool platform_mode)
445448
goto Enable_cpus;
446449

447450
local_irq_disable();
451+
system_state = SYSTEM_SUSPEND;
448452

449453
error = syscore_suspend();
450454
if (error)
@@ -478,6 +482,7 @@ static int resume_target_kernel(bool platform_mode)
478482
syscore_resume();
479483

480484
Enable_irqs:
485+
system_state = SYSTEM_RUNNING;
481486
local_irq_enable();
482487

483488
Enable_cpus:
@@ -563,6 +568,7 @@ int hibernation_platform_enter(void)
563568
goto Enable_cpus;
564569

565570
local_irq_disable();
571+
system_state = SYSTEM_SUSPEND;
566572
syscore_suspend();
567573
if (pm_wakeup_pending()) {
568574
error = -EAGAIN;
@@ -575,6 +581,7 @@ int hibernation_platform_enter(void)
575581

576582
Power_up:
577583
syscore_resume();
584+
system_state = SYSTEM_RUNNING;
578585
local_irq_enable();
579586

580587
Enable_cpus:

0 commit comments

Comments
 (0)