diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/sh/kernel | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'arch/sh/kernel')
| -rw-r--r-- | arch/sh/kernel/cpu/hwblk.c | 159 | ||||
| -rw-r--r-- | arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c | 106 | ||||
| -rw-r--r-- | arch/sh/kernel/cpu/sh4a/hwblk-sh7723.c | 117 | ||||
| -rw-r--r-- | arch/sh/kernel/cpu/sh4a/hwblk-sh7724.c | 121 | ||||
| -rw-r--r-- | arch/sh/kernel/cpu/shmobile/pm_runtime.c | 319 | ||||
| -rw-r--r-- | arch/sh/kernel/init_task.c | 30 | ||||
| -rw-r--r-- | arch/sh/kernel/sys_sh64.c | 50 |
7 files changed, 902 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/hwblk.c b/arch/sh/kernel/cpu/hwblk.c new file mode 100644 index 00000000000..3e985aae5d9 --- /dev/null +++ b/arch/sh/kernel/cpu/hwblk.c | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | #include <linux/clk.h> | ||
| 2 | #include <linux/compiler.h> | ||
| 3 | #include <linux/io.h> | ||
| 4 | #include <linux/spinlock.h> | ||
| 5 | #include <asm/suspend.h> | ||
| 6 | #include <asm/hwblk.h> | ||
| 7 | #include <asm/clock.h> | ||
| 8 | |||
| 9 | static DEFINE_SPINLOCK(hwblk_lock); | ||
| 10 | |||
| 11 | static void hwblk_area_mod_cnt(struct hwblk_info *info, | ||
| 12 | int area, int counter, int value, int goal) | ||
| 13 | { | ||
| 14 | struct hwblk_area *hap = info->areas + area; | ||
| 15 | |||
| 16 | hap->cnt[counter] += value; | ||
| 17 | |||
| 18 | if (hap->cnt[counter] != goal) | ||
| 19 | return; | ||
| 20 | |||
| 21 | if (hap->flags & HWBLK_AREA_FLAG_PARENT) | ||
| 22 | hwblk_area_mod_cnt(info, hap->parent, counter, value, goal); | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | static int __hwblk_mod_cnt(struct hwblk_info *info, int hwblk, | ||
| 27 | int counter, int value, int goal) | ||
| 28 | { | ||
| 29 | struct hwblk *hp = info->hwblks + hwblk; | ||
| 30 | |||
| 31 | hp->cnt[counter] += value; | ||
| 32 | if (hp->cnt[counter] == goal) | ||
| 33 | hwblk_area_mod_cnt(info, hp->area, counter, value, goal); | ||
| 34 | |||
| 35 | return hp->cnt[counter]; | ||
| 36 | } | ||
| 37 | |||
| 38 | static void hwblk_mod_cnt(struct hwblk_info *info, int hwblk, | ||
| 39 | int counter, int value, int goal) | ||
| 40 | { | ||
| 41 | unsigned long flags; | ||
| 42 | |||
| 43 | spin_lock_irqsave(&hwblk_lock, flags); | ||
| 44 | __hwblk_mod_cnt(info, hwblk, counter, value, goal); | ||
| 45 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
| 46 | } | ||
| 47 | |||
| 48 | void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int counter) | ||
| 49 | { | ||
| 50 | hwblk_mod_cnt(info, hwblk, counter, 1, 1); | ||
| 51 | } | ||
| 52 | |||
| 53 | void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int counter) | ||
| 54 | { | ||
| 55 | hwblk_mod_cnt(info, hwblk, counter, -1, 0); | ||
| 56 | } | ||
| 57 | |||
| 58 | void hwblk_enable(struct hwblk_info *info, int hwblk) | ||
| 59 | { | ||
| 60 | struct hwblk *hp = info->hwblks + hwblk; | ||
| 61 | unsigned long tmp; | ||
| 62 | unsigned long flags; | ||
| 63 | int ret; | ||
| 64 | |||
| 65 | spin_lock_irqsave(&hwblk_lock, flags); | ||
| 66 | |||
| 67 | ret = __hwblk_mod_cnt(info, hwblk, HWBLK_CNT_USAGE, 1, 1); | ||
| 68 | if (ret == 1) { | ||
| 69 | tmp = __raw_readl(hp->mstp); | ||
| 70 | tmp &= ~(1 << hp->bit); | ||
| 71 | __raw_writel(tmp, hp->mstp); | ||
| 72 | } | ||
| 73 | |||
| 74 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
| 75 | } | ||
| 76 | |||
| 77 | void hwblk_disable(struct hwblk_info *info, int hwblk) | ||
| 78 | { | ||
| 79 | struct hwblk *hp = info->hwblks + hwblk; | ||
| 80 | unsigned long tmp; | ||
| 81 | unsigned long flags; | ||
| 82 | int ret; | ||
| 83 | |||
| 84 | spin_lock_irqsave(&hwblk_lock, flags); | ||
| 85 | |||
| 86 | ret = __hwblk_mod_cnt(info, hwblk, HWBLK_CNT_USAGE, -1, 0); | ||
| 87 | if (ret == 0) { | ||
| 88 | tmp = __raw_readl(hp->mstp); | ||
| 89 | tmp |= 1 << hp->bit; | ||
| 90 | __raw_writel(tmp, hp->mstp); | ||
| 91 | } | ||
| 92 | |||
| 93 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
| 94 | } | ||
| 95 | |||
| 96 | struct hwblk_info *hwblk_info; | ||
| 97 | |||
| 98 | int __init hwblk_register(struct hwblk_info *info) | ||
| 99 | { | ||
| 100 | hwblk_info = info; | ||
| 101 | return 0; | ||
| 102 | } | ||
| 103 | |||
| 104 | int __init __weak arch_hwblk_init(void) | ||
| 105 | { | ||
| 106 | return 0; | ||
| 107 | } | ||
| 108 | |||
| 109 | int __weak arch_hwblk_sleep_mode(void) | ||
| 110 | { | ||
| 111 | return SUSP_SH_SLEEP; | ||
| 112 | } | ||
| 113 | |||
| 114 | int __init hwblk_init(void) | ||
| 115 | { | ||
| 116 | return arch_hwblk_init(); | ||
| 117 | } | ||
| 118 | |||
| 119 | /* allow clocks to enable and disable hardware blocks */ | ||
| 120 | static int sh_hwblk_clk_enable(struct clk *clk) | ||
| 121 | { | ||
| 122 | if (!hwblk_info) | ||
| 123 | return -ENOENT; | ||
| 124 | |||
| 125 | hwblk_enable(hwblk_info, clk->arch_flags); | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | static void sh_hwblk_clk_disable(struct clk *clk) | ||
| 130 | { | ||
| 131 | if (hwblk_info) | ||
| 132 | hwblk_disable(hwblk_info, clk->arch_flags); | ||
| 133 | } | ||
| 134 | |||
| 135 | static struct clk_ops sh_hwblk_clk_ops = { | ||
| 136 | .enable = sh_hwblk_clk_enable, | ||
| 137 | .disable = sh_hwblk_clk_disable, | ||
| 138 | .recalc = followparent_recalc, | ||
| 139 | }; | ||
| 140 | |||
| 141 | int __init sh_hwblk_clk_register(struct clk *clks, int nr) | ||
| 142 | { | ||
| 143 | struct clk *clkp; | ||
| 144 | int ret = 0; | ||
| 145 | int k; | ||
| 146 | |||
| 147 | for (k = 0; !ret && (k < nr); k++) { | ||
| 148 | clkp = clks + k; | ||
| 149 | |||
| 150 | /* skip over clocks using hwblk 0 (HWBLK_UNKNOWN) */ | ||
| 151 | if (!clkp->arch_flags) | ||
| 152 | continue; | ||
| 153 | |||
| 154 | clkp->ops = &sh_hwblk_clk_ops; | ||
| 155 | ret |= clk_register(clkp); | ||
| 156 | } | ||
| 157 | |||
| 158 | return ret; | ||
| 159 | } | ||
diff --git a/arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c b/arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c new file mode 100644 index 00000000000..a288b5d9234 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c | ||
| 3 | * | ||
| 4 | * SH7722 hardware block support | ||
| 5 | * | ||
| 6 | * Copyright (C) 2009 Magnus Damm | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | */ | ||
| 21 | #include <linux/init.h> | ||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/io.h> | ||
| 24 | #include <asm/suspend.h> | ||
| 25 | #include <asm/hwblk.h> | ||
| 26 | #include <cpu/sh7722.h> | ||
| 27 | |||
| 28 | /* SH7722 registers */ | ||
| 29 | #define MSTPCR0 0xa4150030 | ||
| 30 | #define MSTPCR1 0xa4150034 | ||
| 31 | #define MSTPCR2 0xa4150038 | ||
| 32 | |||
| 33 | /* SH7722 Power Domains */ | ||
| 34 | enum { CORE_AREA, SUB_AREA, CORE_AREA_BM }; | ||
| 35 | static struct hwblk_area sh7722_hwblk_area[] = { | ||
| 36 | [CORE_AREA] = HWBLK_AREA(0, 0), | ||
| 37 | [CORE_AREA_BM] = HWBLK_AREA(HWBLK_AREA_FLAG_PARENT, CORE_AREA), | ||
| 38 | [SUB_AREA] = HWBLK_AREA(0, 0), | ||
| 39 | }; | ||
| 40 | |||
| 41 | /* Table mapping HWBLK to Module Stop Bit and Power Domain */ | ||
| 42 | static struct hwblk sh7722_hwblk[HWBLK_NR] = { | ||
| 43 | [HWBLK_TLB] = HWBLK(MSTPCR0, 31, CORE_AREA), | ||
| 44 | [HWBLK_IC] = HWBLK(MSTPCR0, 30, CORE_AREA), | ||
| 45 | [HWBLK_OC] = HWBLK(MSTPCR0, 29, CORE_AREA), | ||
| 46 | [HWBLK_URAM] = HWBLK(MSTPCR0, 28, CORE_AREA), | ||
| 47 | [HWBLK_XYMEM] = HWBLK(MSTPCR0, 26, CORE_AREA), | ||
