Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * r8a7740 power management support |
| 3 | * |
| 4 | * Copyright (C) 2012 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file "COPYING" in the main directory of this archive |
| 9 | * for more details. |
| 10 | */ |
Kuninori Morimoto | 802a563 | 2012-07-05 01:26:31 -0700 | [diff] [blame] | 11 | #include <linux/console.h> |
Bastian Hecht | 895d3b5 | 2012-12-05 12:13:07 +0000 | [diff] [blame] | 12 | #include <linux/suspend.h> |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 13 | #include <mach/pm-rmobile.h> |
Bastian Hecht | 895d3b5 | 2012-12-05 12:13:07 +0000 | [diff] [blame] | 14 | #include <mach/common.h> |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 15 | |
| 16 | #ifdef CONFIG_PM |
| 17 | static int r8a7740_pd_a4s_suspend(void) |
| 18 | { |
| 19 | /* |
| 20 | * The A4S domain contains the CPU core and therefore it should |
| 21 | * only be turned off if the CPU is in use. |
| 22 | */ |
| 23 | return -EBUSY; |
| 24 | } |
| 25 | |
Kuninori Morimoto | 802a563 | 2012-07-05 01:26:31 -0700 | [diff] [blame] | 26 | static int r8a7740_pd_a3sp_suspend(void) |
| 27 | { |
| 28 | /* |
| 29 | * Serial consoles make use of SCIF hardware located in A3SP, |
| 30 | * keep such power domain on if "no_console_suspend" is set. |
| 31 | */ |
| 32 | return console_suspend_enabled ? 0 : -EBUSY; |
| 33 | } |
| 34 | |
Rafael J. Wysocki | 7b56740 | 2012-08-07 01:13:37 +0200 | [diff] [blame] | 35 | static struct rmobile_pm_domain r8a7740_pm_domains[] = { |
| 36 | { |
| 37 | .genpd.name = "A4S", |
| 38 | .bit_shift = 10, |
| 39 | .gov = &pm_domain_always_on_gov, |
| 40 | .no_debug = true, |
| 41 | .suspend = r8a7740_pd_a4s_suspend, |
| 42 | }, |
| 43 | { |
| 44 | .genpd.name = "A3SP", |
| 45 | .bit_shift = 11, |
| 46 | .gov = &pm_domain_always_on_gov, |
| 47 | .no_debug = true, |
| 48 | .suspend = r8a7740_pd_a3sp_suspend, |
| 49 | }, |
| 50 | { |
| 51 | .genpd.name = "A4LC", |
| 52 | .bit_shift = 1, |
| 53 | }, |
Kuninori Morimoto | 802a563 | 2012-07-05 01:26:31 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Rafael J. Wysocki | 7b56740 | 2012-08-07 01:13:37 +0200 | [diff] [blame] | 56 | void __init r8a7740_init_pm_domains(void) |
| 57 | { |
| 58 | rmobile_init_domains(r8a7740_pm_domains, ARRAY_SIZE(r8a7740_pm_domains)); |
| 59 | pm_genpd_add_subdomain_names("A4S", "A3SP"); |
| 60 | } |
Kuninori Morimoto | a330ce3 | 2012-07-05 01:26:53 -0700 | [diff] [blame] | 61 | |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 62 | #endif /* CONFIG_PM */ |
Bastian Hecht | 895d3b5 | 2012-12-05 12:13:07 +0000 | [diff] [blame] | 63 | |
| 64 | #ifdef CONFIG_SUSPEND |
| 65 | static int r8a7740_enter_suspend(suspend_state_t suspend_state) |
| 66 | { |
| 67 | cpu_do_idle(); |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | static void r8a7740_suspend_init(void) |
| 72 | { |
| 73 | shmobile_suspend_ops.enter = r8a7740_enter_suspend; |
| 74 | } |
| 75 | #else |
| 76 | static void r8a7740_suspend_init(void) {} |
| 77 | #endif |
| 78 | |
| 79 | void __init r8a7740_pm_init(void) |
| 80 | { |
| 81 | r8a7740_suspend_init(); |
| 82 | } |