hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/arm/mach-omap2/pm34xx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * OMAP3 Power Management Routines
34 *
....@@ -12,25 +13,20 @@
1213 * Richard Woodruff <r-woodruff2@ti.com>
1314 *
1415 * Based on pm.c for omap1
15
- *
16
- * This program is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License version 2 as
18
- * published by the Free Software Foundation.
1916 */
2017
18
+#include <linux/cpu_pm.h>
2119 #include <linux/pm.h>
2220 #include <linux/suspend.h>
2321 #include <linux/interrupt.h>
2422 #include <linux/module.h>
2523 #include <linux/list.h>
2624 #include <linux/err.h>
27
-#include <linux/gpio.h>
2825 #include <linux/clk.h>
2926 #include <linux/delay.h>
3027 #include <linux/slab.h>
31
-#include <linux/omap-dma.h>
28
+#include <linux/of.h>
3229 #include <linux/omap-gpmc.h>
33
-#include <linux/platform_data/gpio-omap.h>
3430
3531 #include <trace/events/power.h>
3632
....@@ -89,7 +85,6 @@
8985 omap3_gpmc_save_context();
9086 /* Save the system control module context, padconf already save above*/
9187 omap3_control_save_context();
92
- omap_dma_global_context_save();
9388 }
9489
9590 static void omap3_core_restore_context(void)
....@@ -100,7 +95,6 @@
10095 omap3_gpmc_restore_context();
10196 /* Restore the interrupt controller context */
10297 omap_intc_restore_context();
103
- omap_dma_global_context_restore();
10498 }
10599
106100 /*
....@@ -197,8 +191,8 @@
197191 int mpu_next_state = PWRDM_POWER_ON;
198192 int per_next_state = PWRDM_POWER_ON;
199193 int core_next_state = PWRDM_POWER_ON;
200
- int per_going_off;
201194 u32 sdrc_pwr = 0;
195
+ int error;
202196
203197 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
204198 switch (mpu_next_state) {
....@@ -227,9 +221,10 @@
227221 pwrdm_pre_transition(NULL);
228222
229223 /* PER */
230
- if (per_next_state < PWRDM_POWER_ON) {
231
- per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
232
- omap2_gpio_prepare_for_idle(per_going_off);
224
+ if (per_next_state == PWRDM_POWER_OFF) {
225
+ error = cpu_cluster_pm_enter();
226
+ if (error)
227
+ return;
233228 }
234229
235230 /* CORE */
....@@ -295,8 +290,8 @@
295290 pwrdm_post_transition(NULL);
296291
297292 /* PER */
298
- if (per_next_state < PWRDM_POWER_ON)
299
- omap2_gpio_resume_after_idle();
293
+ if (per_next_state == PWRDM_POWER_OFF)
294
+ cpu_cluster_pm_exit();
300295 }
301296
302297 static void omap3_pm_idle(void)
....@@ -304,11 +299,7 @@
304299 if (omap_irq_pending())
305300 return;
306301
307
- trace_cpu_idle_rcuidle(1, smp_processor_id());
308
-
309302 omap_sram_idle();
310
-
311
- trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
312303 }
313304
314305 #ifdef CONFIG_SUSPEND
....@@ -420,7 +411,12 @@
420411 if (!pwrst)
421412 return -ENOMEM;
422413 pwrst->pwrdm = pwrdm;
423
- pwrst->next_state = PWRDM_POWER_RET;
414
+
415
+ if (enable_off_mode)
416
+ pwrst->next_state = PWRDM_POWER_OFF;
417
+ else
418
+ pwrst->next_state = PWRDM_POWER_RET;
419
+
424420 list_add(&pwrst->node, &pwrst_list);
425421
426422 if (pwrdm_has_hdwr_sar(pwrdm))
....@@ -451,6 +447,22 @@
451447 PM_PER_MEMORIES_ERRATUM_i582);
452448 } else if (cpu_is_omap34xx()) {
453449 pm34xx_errata |= PM_PER_MEMORIES_ERRATUM_i582;
450
+ }
451
+}
452
+
453
+static void __init omap3_pm_check_pmic(void)
454
+{
455
+ struct device_node *np;
456
+
457
+ np = of_find_compatible_node(NULL, NULL, "ti,twl4030-power-idle");
458
+ if (!np)
459
+ np = of_find_compatible_node(NULL, NULL, "ti,twl4030-power-idle-osc-off");
460
+
461
+ if (np) {
462
+ of_node_put(np);
463
+ enable_off_mode = 1;
464
+ } else {
465
+ enable_off_mode = 0;
454466 }
455467 }
456468
....@@ -486,6 +498,8 @@
486498 pr_err("pm: Failed to request pm_io irq\n");
487499 goto err2;
488500 }
501
+
502
+ omap3_pm_check_pmic();
489503
490504 ret = pwrdm_for_each(pwrdms_setup, NULL);
491505 if (ret) {
....@@ -554,9 +568,7 @@
554568
555569 local_irq_disable();
556570
557
- omap_dma_global_context_save();
558571 omap3_save_secure_ram_context();
559
- omap_dma_global_context_restore();
560572
561573 local_irq_enable();
562574 }