diff options
Diffstat (limited to 'arch/arm/mach-tegra')
-rw-r--r-- | arch/arm/mach-tegra/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-tegra/common.c | 5 | ||||
-rw-r--r-- | arch/arm/mach-tegra/cpuidle-tegra20.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/cpuidle-tegra30.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/fuse.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-tegra/fuse.h | 7 | ||||
-rw-r--r-- | arch/arm/mach-tegra/irq.c | 96 | ||||
-rw-r--r-- | arch/arm/mach-tegra/irq.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/platsmp.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-tegra/pm.c | 131 | ||||
-rw-r--r-- | arch/arm/mach-tegra/pm.h | 17 | ||||
-rw-r--r-- | arch/arm/mach-tegra/pmc.c | 162 | ||||
-rw-r--r-- | arch/arm/mach-tegra/pmc.h | 14 | ||||
-rw-r--r-- | arch/arm/mach-tegra/tegra.c | 29 | ||||
-rw-r--r-- | arch/arm/mach-tegra/tegra114_speedo.c | 104 |
15 files changed, 532 insertions, 64 deletions
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index c1970005f805..b78f0d71b328 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile | |||
@@ -27,6 +27,7 @@ obj-$(CONFIG_SMP) += platsmp.o headsmp.o | |||
27 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 27 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
28 | obj-$(CONFIG_TEGRA_PCI) += pcie.o | 28 | obj-$(CONFIG_TEGRA_PCI) += pcie.o |
29 | 29 | ||
30 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += tegra114_speedo.o | ||
30 | ifeq ($(CONFIG_CPU_IDLE),y) | 31 | ifeq ($(CONFIG_CPU_IDLE),y) |
31 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += cpuidle-tegra114.o | 32 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += cpuidle-tegra114.o |
32 | endif | 33 | endif |
diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c index f0315c95c76d..eb1f3c8c74cc 100644 --- a/arch/arm/mach-tegra/common.c +++ b/arch/arm/mach-tegra/common.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "common.h" | 33 | #include "common.h" |
34 | #include "fuse.h" | 34 | #include "fuse.h" |
35 | #include "iomap.h" | 35 | #include "iomap.h" |
36 | #include "irq.h" | ||
36 | #include "pmc.h" | 37 | #include "pmc.h" |
37 | #include "apbio.h" | 38 | #include "apbio.h" |
38 | #include "sleep.h" | 39 | #include "sleep.h" |
@@ -61,8 +62,10 @@ u32 tegra_uart_config[4] = { | |||
61 | void __init tegra_dt_init_irq(void) | 62 | void __init tegra_dt_init_irq(void) |
62 | { | 63 | { |
63 | tegra_clocks_init(); | 64 | tegra_clocks_init(); |
65 | tegra_pmc_init(); | ||
64 | tegra_init_irq(); | 66 | tegra_init_irq(); |
65 | irqchip_init(); | 67 | irqchip_init(); |
68 | tegra_legacy_irq_syscore_init(); | ||
66 | } | 69 | } |
67 | #endif | 70 | #endif |
68 | 71 | ||
@@ -100,12 +103,12 @@ void __init tegra_init_early(void) | |||
100 | tegra_apb_io_init(); | 103 | tegra_apb_io_init(); |
101 | tegra_init_fuse(); | 104 | tegra_init_fuse(); |
102 | tegra_init_cache(); | 105 | tegra_init_cache(); |
103 | tegra_pmc_init(); | ||
104 | tegra_powergate_init(); | 106 | tegra_powergate_init(); |
105 | tegra_hotplug_init(); | 107 | tegra_hotplug_init(); |
106 | } | 108 | } |
107 | 109 | ||
108 | void __init tegra_init_late(void) | 110 | void __init tegra_init_late(void) |
109 | { | 111 | { |
112 | tegra_init_suspend(); | ||
110 | tegra_powergate_debugfs_init(); | 113 | tegra_powergate_debugfs_init(); |
111 | } | 114 | } |
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c index 590ec25855dd..0cdba8de8c77 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c | |||
@@ -131,10 +131,6 @@ static bool tegra20_cpu_cluster_power_down(struct cpuidle_device *dev, | |||
131 | struct cpuidle_driver *drv, | 131 | struct cpuidle_driver *drv, |
132 | int index) | 132 | int index) |
133 | { | 133 | { |
134 | struct cpuidle_state *state = &drv->states[index]; | ||
135 | u32 cpu_on_time = state->exit_latency; | ||
136 | u32 cpu_off_time = state->target_residency - state->exit_latency; | ||
137 | |||
138 | while (tegra20_cpu_is_resettable_soon()) | 134 | while (tegra20_cpu_is_resettable_soon()) |
139 | cpu_relax(); | 135 | cpu_relax(); |
140 | 136 | ||
@@ -143,7 +139,7 @@ static bool tegra20_cpu_cluster_power_down(struct cpuidle_device *dev, | |||
143 | 139 | ||
144 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu); | 140 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu); |
145 | 141 | ||
146 | tegra_idle_lp2_last(cpu_on_time, cpu_off_time); | 142 | tegra_idle_lp2_last(); |
147 | 143 | ||
148 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); | 144 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); |
149 | 145 | ||
diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c index 9387daeeadc8..3cf9aca5f3ea 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra30.c +++ b/arch/arm/mach-tegra/cpuidle-tegra30.c | |||
@@ -69,10 +69,6 @@ static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev, | |||
69 | struct cpuidle_driver *drv, | 69 | struct cpuidle_driver *drv, |
70 | int index) | 70 | int index) |
71 | { | 71 | { |
72 | struct cpuidle_state *state = &drv->states[index]; | ||
73 | u32 cpu_on_time = state->exit_latency; | ||
74 | u32 cpu_off_time = state->target_residency - state->exit_latency; | ||
75 | |||
76 | /* All CPUs entering LP2 is not working. | 72 | /* All CPUs entering LP2 is not working. |
77 | * Don't let CPU0 enter LP2 when any secondary CPU is online. | 73 | * Don't let CPU0 enter LP2 when any secondary CPU is online. |
78 | */ | 74 | */ |
@@ -83,7 +79,7 @@ static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev, | |||
83 | 79 | ||
84 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu); | 80 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu); |
85 | 81 | ||
86 | tegra_idle_lp2_last(cpu_on_time, cpu_off_time); | 82 | tegra_idle_lp2_last(); |
87 | 83 | ||
88 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); | 84 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); |
89 | 85 | ||
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c index f7db0782a6b6..e035cd284a6e 100644 --- a/arch/arm/mach-tegra/fuse.c +++ b/arch/arm/mach-tegra/fuse.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * arch/arm/mach-tegra/fuse.c | 2 | * arch/arm/mach-tegra/fuse.c |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Google, Inc. | 4 | * Copyright (C) 2010 Google, Inc. |
5 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | 6 | * |
6 | * Author: | 7 | * Author: |
7 | * Colin Cross <ccross@android.com> | 8 | * Colin Cross <ccross@android.com> |
@@ -137,6 +138,9 @@ void tegra_init_fuse(void) | |||
137 | tegra_fuse_spare_bit = TEGRA30_FUSE_SPARE_BIT; | 138 | tegra_fuse_spare_bit = TEGRA30_FUSE_SPARE_BIT; |
138 | tegra_init_speedo_data = &tegra30_init_speedo_data; | 139 | tegra_init_speedo_data = &tegra30_init_speedo_data; |
139 | break; | 140 | break; |
141 | case TEGRA114: | ||
142 | tegra_init_speedo_data = &tegra114_init_speedo_data; | ||
143 | break; | ||
140 | default: | 144 | default: |
141 | pr_warn("Tegra: unknown chip id %d\n", tegra_chip_id); | 145 | pr_warn("Tegra: unknown chip id %d\n", tegra_chip_id); |
142 | tegra_fuse_spare_bit = TEGRA20_FUSE_SPARE_BIT; | 146 | tegra_fuse_spare_bit = TEGRA20_FUSE_SPARE_BIT; |
diff --git a/arch/arm/mach-tegra/fuse.h b/arch/arm/mach-tegra/fuse.h index da78434678c7..aacc00d05980 100644 --- a/arch/arm/mach-tegra/fuse.h +++ b/arch/arm/mach-tegra/fuse.h | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2010 Google, Inc. | 2 | * Copyright (C) 2010 Google, Inc. |
3 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | 4 | * |
4 | * Author: | 5 | * Author: |
5 | * Colin Cross <ccross@android.com> | 6 | * Colin Cross <ccross@android.com> |
@@ -66,4 +67,10 @@ void tegra30_init_speedo_data(void); | |||
66 | static inline void tegra30_init_speedo_data(void) {} | 67 | static inline void tegra30_init_speedo_data(void) {} |
67 | #endif | 68 | #endif |
68 | 69 | ||
70 | #ifdef CONFIG_ARCH_TEGRA_114_SOC | ||
71 | void tegra114_init_speedo_data(void); | ||
72 | #else | ||
73 | static inline void tegra114_init_speedo_data(void) {} | ||
74 | #endif | ||
75 | |||
69 | #endif | 76 | #endif |
diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c index 1952e82797cc..0de4eed1493d 100644 --- a/arch/arm/mach-tegra/irq.c +++ b/arch/arm/mach-tegra/irq.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Author: | 4 | * Author: |
5 | * Colin Cross <ccross@android.com> | 5 | * Colin Cross <ccross@android.com> |
6 | * | 6 | * |
7 | * Copyright (C) 2010, NVIDIA Corporation | 7 | * Copyright (C) 2010,2013, NVIDIA Corporation |
8 | * | 8 | * |
9 | * This software is licensed under the terms of the GNU General Public | 9 | * This software is licensed under the terms of the GNU General Public |
10 | * License version 2, as published by the Free Software Foundation, and | 10 | * License version 2, as published by the Free Software Foundation, and |
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/of.h> | 24 | #include <linux/of.h> |
25 | #include <linux/irqchip/arm-gic.h> | 25 | #include <linux/irqchip/arm-gic.h> |
26 | #include <linux/syscore_ops.h> | ||
26 | 27 | ||
27 | #include "board.h" | 28 | #include "board.h" |
28 | #include "iomap.h" | 29 | #include "iomap.h" |
@@ -43,6 +44,7 @@ | |||
43 | #define ICTLR_COP_IEP_CLASS 0x3c | 44 | #define ICTLR_COP_IEP_CLASS 0x3c |
44 | 45 | ||
45 | #define FIRST_LEGACY_IRQ 32 | 46 | #define FIRST_LEGACY_IRQ 32 |
47 | #define TEGRA_MAX_NUM_ICTLRS 5 | ||
46 | 48 | ||
47 | #define SGI_MASK 0xFFFF | 49 | #define SGI_MASK 0xFFFF |
48 | 50 | ||
@@ -56,6 +58,15 @@ static void __iomem *ictlr_reg_base[] = { | |||
56 | IO_ADDRESS(TEGRA_QUINARY_ICTLR_BASE), | 58 | IO_ADDRESS(TEGRA_QUINARY_ICTLR_BASE), |
57 | }; | 59 | }; |
58 | 60 | ||
61 | #ifdef CONFIG_PM_SLEEP | ||
62 | static u32 cop_ier[TEGRA_MAX_NUM_ICTLRS]; | ||
63 | static u32 cop_iep[TEGRA_MAX_NUM_ICTLRS]; | ||
64 | static u32 cpu_ier[TEGRA_MAX_NUM_ICTLRS]; | ||
65 | static u32 cpu_iep[TEGRA_MAX_NUM_ICTLRS]; | ||
66 | |||
67 | static u32 ictlr_wake_mask[TEGRA_MAX_NUM_ICTLRS]; | ||
68 | #endif | ||
69 | |||
59 | bool tegra_pending_sgi(void) | 70 | bool tegra_pending_sgi(void) |
60 | { | 71 | { |
61 | u32 pending_set; | 72 | u32 pending_set; |
@@ -125,6 +136,87 @@ static int tegra_retrigger(struct irq_data *d) | |||
125 | return 1; | 136 | return 1; |
126 | } | 137 | } |
127 | 138 | ||
139 | #ifdef CONFIG_PM_SLEEP | ||
140 | static int tegra_set_wake(struct irq_data *d, unsigned int enable) | ||
141 | { | ||
142 | u32 irq = d->irq; | ||
143 | u32 index, mask; | ||
144 | |||
145 | if (irq < FIRST_LEGACY_IRQ || | ||
146 | irq >= FIRST_LEGACY_IRQ + num_ictlrs * 32) | ||
147 | return -EINVAL; | ||
148 | |||
149 | index = ((irq - FIRST_LEGACY_IRQ) / 32); | ||
150 | mask = BIT((irq - FIRST_LEGACY_IRQ) % 32); | ||
151 | if (enable) | ||
152 | ictlr_wake_mask[index] |= mask; | ||
153 | else | ||
154 | ictlr_wake_mask[index] &= ~mask; | ||
155 | |||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int tegra_legacy_irq_suspend(void) | ||
160 | { | ||
161 | unsigned long flags; | ||
162 | int i; | ||
163 | |||
164 | local_irq_save(flags); | ||
165 | for (i = 0; i < num_ictlrs; i++) { | ||
166 | void __iomem *ictlr = ictlr_reg_base[i]; | ||
167 | /* Save interrupt state */ | ||
168 | cpu_ier[i] = readl_relaxed(ictlr + ICTLR_CPU_IER); | ||
169 | cpu_iep[i] = readl_relaxed(ictlr + ICTLR_CPU_IEP_CLASS); | ||
170 | cop_ier[i] = readl_relaxed(ictlr + ICTLR_COP_IER); | ||
171 | cop_iep[i] = readl_relaxed(ictlr + ICTLR_COP_IEP_CLASS); | ||
172 | |||
173 | /* Disable COP interrupts */ | ||
174 | writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR); | ||
175 | |||
176 | /* Disable CPU interrupts */ | ||
177 | writel_relaxed(~0ul, ictlr + ICTLR_CPU_IER_CLR); | ||
178 | |||
179 | /* Enable the wakeup sources of ictlr */ | ||
180 | writel_relaxed(ictlr_wake_mask[i], ictlr + ICTLR_CPU_IER_SET); | ||
181 | } | ||
182 | local_irq_restore(flags); | ||
183 | |||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | static void tegra_legacy_irq_resume(void) | ||
188 | { | ||
189 | unsigned long flags; | ||
190 | int i; | ||
191 | |||
192 | local_irq_save(flags); | ||
193 | for (i = 0; i < num_ictlrs; i++) { | ||
194 | void __iomem *ictlr = ictlr_reg_base[i]; | ||
195 | writel_relaxed(cpu_iep[i], ictlr + ICTLR_CPU_IEP_CLASS); | ||
196 | writel_relaxed(~0ul, ictlr + ICTLR_CPU_IER_CLR); | ||
197 | writel_relaxed(cpu_ier[i], ictlr + ICTLR_CPU_IER_SET); | ||
198 | writel_relaxed(cop_iep[i], ictlr + ICTLR_COP_IEP_CLASS); | ||
199 | writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR); | ||
200 | writel_relaxed(cop_ier[i], ictlr + ICTLR_COP_IER_SET); | ||
201 | } | ||
202 | local_irq_restore(flags); | ||
203 | } | ||
204 | |||
205 | static struct syscore_ops tegra_legacy_irq_syscore_ops = { | ||
206 | .suspend = tegra_legacy_irq_suspend, | ||
207 | .resume = tegra_legacy_irq_resume, | ||
208 | }; | ||
209 | |||
210 | int tegra_legacy_irq_syscore_init(void) | ||
211 | { | ||
212 | register_syscore_ops(&tegra_legacy_irq_syscore_ops); | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | #else | ||
217 | #define tegra_set_wake NULL | ||
218 | #endif | ||
219 | |||
128 | void __init tegra_init_irq(void) | 220 | void __init tegra_init_irq(void) |
129 | { | 221 | { |
130 | int i; | 222 | int i; |
@@ -150,6 +242,8 @@ void __init tegra_init_irq(void) | |||
150 | gic_arch_extn.irq_mask = tegra_mask; | 242 | gic_arch_extn.irq_mask = tegra_mask; |
151 | gic_arch_extn.irq_unmask = tegra_unmask; | 243 | gic_arch_extn.irq_unmask = tegra_unmask; |
152 | gic_arch_extn.irq_retrigger = tegra_retrigger; | 244 | gic_arch_extn.irq_retrigger = tegra_retrigger; |
245 | gic_arch_extn.irq_set_wake = tegra_set_wake; | ||
246 | gic_arch_extn.flags = IRQCHIP_MASK_ON_SUSPEND; | ||
153 | 247 | ||
154 | /* | 248 | /* |
155 | * Check if there is a devicetree present, since the GIC will be | 249 | * Check if there is a devicetree present, since the GIC will be |
diff --git a/arch/arm/mach-tegra/irq.h b/arch/arm/mach-tegra/irq.h index 5142649bba05..bc05ce5613fb 100644 --- a/arch/arm/mach-tegra/irq.h +++ b/arch/arm/mach-tegra/irq.h | |||
@@ -19,4 +19,10 @@ | |||
19 | 19 | ||
20 | bool tegra_pending_sgi(void); | 20 | bool tegra_pending_sgi(void); |
21 | 21 | ||
22 | #ifdef CONFIG_PM_SLEEP | ||
23 | int tegra_legacy_irq_syscore_init(void); | ||
24 | #else | ||
25 | static inline int tegra_legacy_irq_syscore_init(void) { return 0; } | ||
26 | #endif | ||
27 | |||
22 | #endif | 28 | #endif |
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c index c31db797e199..0c4963bd4b44 100644 --- a/arch/arm/mach-tegra/platsmp.c +++ b/arch/arm/mach-tegra/platsmp.c | |||
@@ -138,6 +138,12 @@ remove_clamps: | |||
138 | return 0; | 138 | return 0; |
139 | } | 139 | } |
140 | 140 | ||
141 | static int tegra114_boot_secondary(unsigned int cpu, struct task_struct *idle) | ||
142 | { | ||
143 | cpu = cpu_logical_map(cpu); | ||
144 | return tegra_pmc_cpu_power_on(cpu); | ||
145 | } | ||
146 | |||
141 | static int __cpuinit tegra_boot_secondary(unsigned int cpu, | 147 | static int __cpuinit tegra_boot_secondary(unsigned int cpu, |
142 | struct task_struct *idle) | 148 | struct task_struct *idle) |
143 | { | 149 | { |
@@ -145,6 +151,8 @@ static int __cpuinit tegra_boot_secondary(unsigned int cpu, | |||
145 | return tegra20_boot_secondary(cpu, idle); | 151 | return tegra20_boot_secondary(cpu, idle); |
146 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_chip_id == TEGRA30) | 152 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_chip_id == TEGRA30) |
147 | return tegra30_boot_secondary(cpu, idle); | 153 | return tegra30_boot_secondary(cpu, idle); |
154 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_chip_id == TEGRA114) | ||
155 | return tegra114_boot_secondary(cpu, idle); | ||
148 | 156 | ||
149 | return -EINVAL; | 157 | return -EINVAL; |
150 | } | 158 | } |
diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 891fb70d0aa7..45cf52c7e528 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/cpumask.h> | 22 | #include <linux/cpumask.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/cpu_pm.h> | 24 | #include <linux/cpu_pm.h> |
25 | #include <linux/clk.h> | 25 | #include <linux/suspend.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/clk/tegra.h> | 27 | #include <linux/clk/tegra.h> |
28 | 28 | ||
@@ -37,52 +37,13 @@ | |||
37 | #include "reset.h" | 37 | #include "reset.h" |
38 | #include "flowctrl.h" | 38 | #include "flowctrl.h" |
39 | #include "fuse.h" | 39 | #include "fuse.h" |
40 | #include "pmc.h" | ||
40 | #include "sleep.h" | 41 | #include "sleep.h" |
41 | 42 | ||
42 | #define TEGRA_POWER_CPU_PWRREQ_OE (1 << 16) /* CPU pwr req enable */ | ||
43 | |||
44 | #define PMC_CTRL 0x0 | ||
45 | #define PMC_CPUPWRGOOD_TIMER 0xc8 | ||
46 | #define PMC_CPUPWROFF_TIMER 0xcc | ||
47 | |||
48 | #ifdef CONFIG_PM_SLEEP | 43 | #ifdef CONFIG_PM_SLEEP |
49 | static DEFINE_SPINLOCK(tegra_lp2_lock); | 44 | static DEFINE_SPINLOCK(tegra_lp2_lock); |
50 | static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); | ||
51 | static struct clk *tegra_pclk; | ||
52 | void (*tegra_tear_down_cpu)(void); | 45 | void (*tegra_tear_down_cpu)(void); |
53 | 46 | ||
54 | static void set_power_timers(unsigned long us_on, unsigned long us_off) | ||
55 | { | ||
56 | unsigned long long ticks; | ||
57 | unsigned long long pclk; | ||
58 | unsigned long rate; | ||
59 | static unsigned long tegra_last_pclk; | ||
60 | |||
61 | if (tegra_pclk == NULL) { | ||
62 | tegra_pclk = clk_get_sys(NULL, "pclk"); | ||
63 | WARN_ON(IS_ERR(tegra_pclk)); | ||
64 | } | ||
65 | |||
66 | rate = clk_get_rate(tegra_pclk); | ||
67 | |||
68 | if (WARN_ON_ONCE(rate <= 0)) | ||
69 | pclk = 100000000; | ||
70 | else | ||
71 | pclk = rate; | ||
72 | |||
73 | if ((rate != tegra_last_pclk)) { | ||
74 | ticks = (us_on * pclk) + 999999ull; | ||
75 | do_div(ticks, 1000000); | ||
76 | writel((unsigned long)ticks, pmc + PMC_CPUPWRGOOD_TIMER); | ||
77 | |||
78 | ticks = (us_off * pclk) + 999999ull; | ||
79 | do_div(ticks, 1000000); | ||
80 | writel((unsigned long)ticks, pmc + PMC_CPUPWROFF_TIMER); | ||
81 | wmb(); | ||
82 | } | ||
83 | tegra_last_pclk = pclk; | ||
84 | } | ||
85 | |||
86 | /* | 47 | /* |
87 | * restore_cpu_complex | 48 | * restore_cpu_complex |
88 | * | 49 | * |
@@ -178,16 +139,9 @@ static int tegra_sleep_cpu(unsigned long v2p) | |||
178 | return 0; | 139 | return 0; |
179 | } | 140 | } |
180 | 141 | ||
181 | void tegra_idle_lp2_last(u32 cpu_on_time, u32 cpu_off_time) | 142 | void tegra_idle_lp2_last(void) |
182 | { | 143 | { |
183 | u32 mode; | 144 | tegra_pmc_pm_set(TEGRA_SUSPEND_LP2); |
184 | |||
185 | /* Only the last cpu down does the final suspend steps */ | ||
186 | mode = readl(pmc + PMC_CTRL); | ||
187 | mode |= TEGRA_POWER_CPU_PWRREQ_OE; | ||
188 | writel(mode, pmc + PMC_CTRL); | ||
189 | |||
190 | set_power_timers(cpu_on_time, cpu_off_time); | ||
191 | 145 | ||
192 | cpu_cluster_pm_enter(); | 146 | cpu_cluster_pm_enter(); |
193 | suspend_cpu_complex(); | 147 | suspend_cpu_complex(); |
@@ -197,4 +151,81 @@ void tegra_idle_lp2_last(u32 cpu_on_time, u32 cpu_off_time) | |||
197 | restore_cpu_complex(); | 151 | restore_cpu_complex(); |
198 | cpu_cluster_pm_exit(); | 152 | cpu_cluster_pm_exit(); |
199 | } | 153 | } |
154 | |||
155 | enum tegra_suspend_mode tegra_pm_validate_suspend_mode( | ||
156 | enum tegra_suspend_mode mode) | ||
157 | { | ||
158 | /* Tegra114 didn't support any suspending mode yet. */ | ||
159 | if (tegra_chip_id == TEGRA114) | ||
160 | return TEGRA_SUSPEND_NONE; | ||
161 | |||
162 | /* | ||
163 | * The Tegra devices only support suspending to LP2 currently. | ||
164 | */ | ||
165 | if (mode > TEGRA_SUSPEND_LP2) | ||
166 | return TEGRA_SUSPEND_LP2; | ||
167 | |||
168 | return mode; | ||
169 | } | ||
170 | |||
171 | static const char *lp_state[TEGRA_MAX_SUSPEND_MODE] = { | ||
172 | [TEGRA_SUSPEND_NONE] = "none", | ||
173 | [TEGRA_SUSPEND_LP2] = "LP2", | ||
174 | [TEGRA_SUSPEND_LP1] = "LP1", | ||
175 | [TEGRA_SUSPEND_LP0] = "LP0", | ||
176 | }; | ||
177 | |||
178 | static int __cpuinit tegra_suspend_enter(suspend_state_t state) | ||
179 | { | ||
180 | enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode(); | ||
181 | |||
182 | if (WARN_ON(mode < TEGRA_SUSPEND_NONE || | ||
183 | mode >= TEGRA_MAX_SUSPEND_MODE)) | ||
184 | return -EINVAL; | ||
185 | |||
186 | pr_info("Entering suspend state %s\n", lp_state[mode]); | ||
187 | |||
188 | tegra_pmc_pm_set(mode); | ||
189 | |||
190 | local_fiq_disable(); | ||
191 | |||
192 | suspend_cpu_complex(); | ||
193 | switch (mode) { | ||
194 | case TEGRA_SUSPEND_LP2: | ||
195 | tegra_set_cpu_in_lp2(0); | ||
196 | break; | ||
197 | default: | ||
198 | break; | ||
199 | } | ||
200 | |||
201 | cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); | ||
202 | |||
203 | switch (mode) { | ||
204 | case TEGRA_SUSPEND_LP2: | ||
205 | tegra_clear_cpu_in_lp2(0); | ||
206 | break; | ||
207 | default: | ||
208 | break; | ||
209 | } | ||
210 | restore_cpu_complex(); | ||
211 | |||
212 | local_fiq_enable(); | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | static const struct platform_suspend_ops tegra_suspend_ops = { | ||
218 | .valid = suspend_valid_only_mem, | ||
219 | .enter = tegra_suspend_enter, | ||
220 | }; | ||
221 | |||
222 | void __init tegra_init_suspend(void) | ||
223 | { | ||
224 | if (tegra_pmc_get_suspend_mode() == TEGRA_SUSPEND_NONE) | ||
225 | return; | ||
226 | |||
227 | tegra_pmc_suspend_init(); | ||
228 | |||
229 | suspend_set_ops(&tegra_suspend_ops); | ||
230 | } | ||
200 | #endif | 231 | #endif |
diff --git a/arch/arm/mach-tegra/pm.h b/arch/arm/mach-tegra/pm.h index 787335cc964c..778a4aa7c3fa 100644 --- a/arch/arm/mach-tegra/pm.h +++ b/arch/arm/mach-tegra/pm.h | |||
@@ -21,6 +21,8 @@ | |||
21 | #ifndef _MACH_TEGRA_PM_H_ | 21 | #ifndef _MACH_TEGRA_PM_H_ |
22 | #define _MACH_TEGRA_PM_H_ | 22 | #define _MACH_TEGRA_PM_H_ |
23 | 23 | ||
24 | #include "pmc.h" | ||
25 | |||
24 | extern unsigned long l2x0_saved_regs_addr; | 26 | extern unsigned long l2x0_saved_regs_addr; |
25 | 27 | ||
26 | void save_cpu_arch_register(void); | 28 | void save_cpu_arch_register(void); |
@@ -29,7 +31,20 @@ void restore_cpu_arch_register(void); | |||
29 | void tegra_clear_cpu_in_lp2(int phy_cpu_id); | 31 | void tegra_clear_cpu_in_lp2(int phy_cpu_id); |
30 | bool tegra_set_cpu_in_lp2(int phy_cpu_id); | 32 | bool tegra_set_cpu_in_lp2(int phy_cpu_id); |
31 | 33 | ||
32 | void tegra_idle_lp2_last(u32 cpu_on_time, u32 cpu_off_time); | 34 | void tegra_idle_lp2_last(void); |
33 | extern void (*tegra_tear_down_cpu)(void); | 35 | extern void (*tegra_tear_down_cpu)(void); |
34 | 36 | ||
37 | #ifdef CONFIG_PM_SLEEP | ||
38 | enum tegra_suspend_mode tegra_pm_validate_suspend_mode( | ||
39 | enum tegra_suspend_mode mode); | ||
40 | void tegra_init_suspend(void); | ||
41 | #else | ||
42 | static inline enum tegra_suspend_mode tegra_pm_validate_suspend_mode( | ||
43 | enum tegra_suspend_mode mode) | ||
44 | { | ||
45 | return TEGRA_SUSPEND_NONE; | ||
46 | } | ||
47 | static inline void tegra_init_suspend(void) {} | ||
48 | #endif | ||
49 | |||
35 | #endif /* _MACH_TEGRA_PM_H_ */ | 50 | #endif /* _MACH_TEGRA_PM_H_ */ |
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c index b30e921cc3a9..32360e540ce6 100644 --- a/arch/arm/mach-tegra/pmc.c +++ b/arch/arm/mach-tegra/pmc.c | |||
@@ -16,10 +16,20 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/clk.h> | ||
19 | #include <linux/io.h> | 20 | #include <linux/io.h> |
20 | #include <linux/of.h> | 21 | #include <linux/of.h> |
21 | #include <linux/of_address.h> | 22 | #include <linux/of_address.h> |
22 | 23 | ||
24 | #include "fuse.h" | ||
25 | #include "pm.h" | ||
26 | #include "pmc.h" | ||
27 | #include "sleep.h" | ||
28 | |||
29 | #define TEGRA_POWER_EFFECT_LP0 (1 << 14) /* LP0 when CPU pwr gated */ | ||
30 | #define TEGRA_POWER_CPU_PWRREQ_POLARITY (1 << 15) /* CPU pwr req polarity */ | ||
31 | #define TEGRA_POWER_CPU_PWRREQ_OE (1 << 16) /* CPU pwr req enable */ | ||
32 | |||
23 | #define PMC_CTRL 0x0 | 33 | #define PMC_CTRL 0x0 |
24 | #define PMC_CTRL_INTR_LOW (1 << 17) | 34 | #define PMC_CTRL_INTR_LOW (1 << 17) |
25 | #define PMC_PWRGATE_TOGGLE 0x30 | 35 | #define PMC_PWRGATE_TOGGLE 0x30 |
@@ -27,6 +37,9 @@ | |||
27 | #define PMC_REMOVE_CLAMPING 0x34 | 37 | #define PMC_REMOVE_CLAMPING 0x34 |
28 | #define PMC_PWRGATE_STATUS 0x38 | 38 | #define PMC_PWRGATE_STATUS 0x38 |
29 | 39 | ||
40 | #define PMC_CPUPWRGOOD_TIMER 0xc8 | ||
41 | #define PMC_CPUPWROFF_TIMER 0xcc | ||
42 | |||
30 | #define TEGRA_POWERGATE_PCIE 3 | 43 | #define TEGRA_POWERGATE_PCIE 3 |
31 | #define TEGRA_POWERGATE_VDEC 4 | 44 | #define TEGRA_POWERGATE_VDEC 4 |
32 | #define TEGRA_POWERGATE_CPU1 9 | 45 | #define TEGRA_POWERGATE_CPU1 9 |
@@ -43,6 +56,23 @@ static DEFINE_SPINLOCK(tegra_powergate_lock); | |||
43 | 56 | ||
44 | static void __iomem *tegra_pmc_base; | 57 | static void __iomem *tegra_pmc_base; |
45 | static bool tegra_pmc_invert_interrupt; | 58 | static bool tegra_pmc_invert_interrupt; |
59 | static struct clk *tegra_pclk; | ||
60 | |||
61 | struct pmc_pm_data { | ||
62 | u32 cpu_good_time; /* CPU power good time in uS */ | ||
63 | u32 cpu_off_time; /* CPU power off time in uS */ | ||
64 | u32 core_osc_time; /* Core power good osc time in uS */ | ||
65 | u32 core_pmu_time; /* Core power good pmu time in uS */ | ||
66 | u32 core_off_time; /* Core power off time in uS */ | ||
67 | bool corereq_high; /* Core power request active-high */ | ||
68 | bool sysclkreq_high; /* System clock request active-high */ | ||
69 | bool combined_req; /* Combined pwr req for CPU & Core */ | ||
70 | bool cpu_pwr_good_en; /* CPU power good signal is enabled */ | ||
71 | u32 lp0_vec_phy_addr; /* The phy addr of LP0 warm boot code */ | ||
72 | u32 lp0_vec_size; /* The size of LP0 warm boot code */ | ||
73 | enum tegra_suspend_mode suspend_mode; | ||
74 | }; | ||
75 | static struct pmc_pm_data pmc_pm_data; | ||
46 | 76 | ||
47 | static inline u32 tegra_pmc_readl(u32 reg) | 77 | static inline u32 tegra_pmc_readl(u32 reg) |
48 | { | 78 | { |
@@ -133,6 +163,70 @@ int tegra_pmc_cpu_remove_clamping(int cpuid) | |||
133 | return tegra_pmc_powergate_remove_clamping(id); | 163 | return tegra_pmc_powergate_remove_clamping(id); |
134 | } | 164 | } |
135 | 165 | ||
166 | #ifdef CONFIG_PM_SLEEP | ||
167 | static void set_power_timers(u32 us_on, u32 us_off, unsigned long rate) | ||
168 | { | ||
169 | unsigned long long ticks; | ||
170 | unsigned long long pclk; | ||
171 | static unsigned long tegra_last_pclk; | ||
172 | |||
173 | if (WARN_ON_ONCE(rate <= 0)) | ||
174 | pclk = 100000000; | ||
175 | else | ||
176 | pclk = rate; | ||
177 | |||
178 | if ((rate != tegra_last_pclk)) { | ||
179 | ticks = (us_on * pclk) + 999999ull; | ||
180 | do_div(ticks, 1000000); | ||
181 | tegra_pmc_writel((unsigned long)ticks, PMC_CPUPWRGOOD_TIMER); | ||
182 | |||
183 | ticks = (us_off * pclk) + 999999ull; | ||
184 | do_div(ticks, 1000000); | ||
185 | tegra_pmc_writel((unsigned long)ticks, PMC_CPUPWROFF_TIMER); | ||
186 | wmb(); | ||
187 | } | ||
188 | tegra_last_pclk = pclk; | ||
189 | } | ||
190 | |||
191 | enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void) | ||
192 | { | ||
193 | return pmc_pm_data.suspend_mode; | ||
194 | } | ||
195 | |||
196 | void tegra_pmc_pm_set(enum tegra_suspend_mode mode) | ||
197 | { | ||
198 | u32 reg; | ||
199 | unsigned long rate = 0; | ||
200 | |||
201 | reg = tegra_pmc_readl(PMC_CTRL); | ||
202 | reg |= TEGRA_POWER_CPU_PWRREQ_OE; | ||
203 | reg &= ~TEGRA_POWER_EFFECT_LP0; | ||
204 | |||
205 | switch (mode) { | ||
206 | case TEGRA_SUSPEND_LP2: | ||
207 | rate = clk_get_rate(tegra_pclk); | ||
208 | break; | ||
209 | default: | ||
210 | break; | ||
211 | } | ||
212 | |||
213 | set_power_timers(pmc_pm_data.cpu_good_time, pmc_pm_data.cpu_off_time, | ||
214 | rate); | ||
215 | |||
216 | tegra_pmc_writel(reg, PMC_CTRL); | ||
217 | } | ||
218 | |||
219 | void tegra_pmc_suspend_init(void) | ||
220 | { | ||
221 | u32 reg; | ||
222 | |||
223 | /* Always enable CPU power request */ | ||
224 | reg = tegra_pmc_readl(PMC_CTRL); | ||
225 | reg |= TEGRA_POWER_CPU_PWRREQ_OE; | ||
226 | tegra_pmc_writel(reg, PMC_CTRL); | ||
227 | } | ||
228 | #endif | ||
229 | |||
136 | static const struct of_device_id matches[] __initconst = { | 230 | static const struct of_device_id matches[] __initconst = { |
137 | { .compatible = "nvidia,tegra114-pmc" }, | 231 | { .compatible = "nvidia,tegra114-pmc" }, |
138 | { .compatible = "nvidia,tegra30-pmc" }, | 232 | { .compatible = "nvidia,tegra30-pmc" }, |
@@ -143,6 +237,10 @@ static const struct of_device_id matches[] __initconst = { | |||
143 | static void tegra_pmc_parse_dt(void) | 237 | static void tegra_pmc_parse_dt(void) |
144 | { | 238 | { |
145 | struct device_node *np; | 239 | struct device_node *np; |
240 | u32 prop; | ||
241 | enum tegra_suspend_mode suspend_mode; | ||
242 | u32 core_good_time[2] = {0, 0}; | ||
243 | u32 lp0_vec[2] = {0, 0}; | ||
146 | 244 | ||
147 | np = of_find_matching_node(NULL, matches); | 245 | np = of_find_matching_node(NULL, matches); |
148 | BUG_ON(!np); | 246 | BUG_ON(!np); |
@@ -151,6 +249,70 @@ static void tegra_pmc_parse_dt(void) | |||
151 | 249 | ||
152 | tegra_pmc_invert_interrupt = of_property_read_bool(np, | 250 | tegra_pmc_invert_interrupt = of_property_read_bool(np, |
153 | "nvidia,invert-interrupt"); | 251 | "nvidia,invert-interrupt"); |
252 | tegra_pclk = of_clk_get_by_name(np, "pclk"); | ||
253 | WARN_ON(IS_ERR(tegra_pclk)); | ||
254 | |||
255 | /* Grabbing the power management configurations */ | ||
256 | if (of_property_read_u32(np, "nvidia,suspend-mode", &prop)) { | ||
257 | suspend_mode = TEGRA_SUSPEND_NONE; | ||
258 | } else { | ||
259 | switch (prop) { | ||
260 | case 0: | ||
261 | suspend_mode = TEGRA_SUSPEND_LP0; | ||
262 | break; | ||
263 | case 1: | ||
264 | suspend_mode = TEGRA_SUSPEND_LP1; | ||
265 | break; | ||
266 | case 2: | ||
267 | suspend_mode = TEGRA_SUSPEND_LP2; | ||
268 | break; | ||
269 | default: | ||
270 | suspend_mode = TEGRA_SUSPEND_NONE; | ||
271 | break; | ||
272 | } | ||
273 | } | ||
274 | suspend_mode = tegra_pm_validate_suspend_mode(suspend_mode); | ||
275 | |||
276 | if (of_property_read_u32(np, "nvidia,cpu-pwr-good-time", &prop)) | ||
277 | suspend_mode = TEGRA_SUSPEND_NONE; | ||
278 | pmc_pm_data.cpu_good_time = prop; | ||
279 | |||
280 | if (of_property_read_u32(np, "nvidia,cpu-pwr-off-time", &prop)) | ||
281 | suspend_mode = TEGRA_SUSPEND_NONE; | ||
282 | pmc_pm_data.cpu_off_time = prop; | ||
283 | |||
284 | if (of_property_read_u32_array(np, "nvidia,core-pwr-good-time", | ||
285 | core_good_time, ARRAY_SIZE(core_good_time))) | ||
286 | suspend_mode = TEGRA_SUSPEND_NONE; | ||
287 | pmc_pm_data.core_osc_time = core_good_time[0]; | ||
288 | pmc_pm_data.core_pmu_time = core_good_time[1]; | ||
289 | |||
290 | if (of_property_read_u32(np, "nvidia,core-pwr-off-time", | ||
291 | &prop)) | ||
292 | suspend_mode = TEGRA_SUSPEND_NONE; | ||
293 | pmc_pm_data.core_off_time = prop; | ||
294 | |||
295 | pmc_pm_data.corereq_high = of_property_read_bool(np, | ||
296 | "nvidia,core-power-req-active-high"); | ||
297 | |||
298 | pmc_pm_data.sysclkreq_high = of_property_read_bool(np, | ||
299 | "nvidia,sys-clock-req-active-high"); | ||
300 | |||
301 | pmc_pm_data.combined_req = of_property_read_bool(np, | ||
302 | "nvidia,combined-power-req"); | ||
303 | |||
304 | pmc_pm_data.cpu_pwr_good_en = of_property_read_bool(np, | ||
305 | "nvidia,cpu-pwr-good-en"); | ||
306 | |||
307 | if (of_property_read_u32_array(np, "nvidia,lp0-vec", lp0_vec, | ||
308 | ARRAY_SIZE(lp0_vec))) | ||
309 | if (suspend_mode == TEGRA_SUSPEND_LP0) | ||
310 | suspend_mode = TEGRA_SUSPEND_LP1; | ||
311 | |||
312 | pmc_pm_data.lp0_vec_phy_addr = lp0_vec[0]; | ||
313 | pmc_pm_data.lp0_vec_size = lp0_vec[1]; | ||
314 | |||
315 | pmc_pm_data.suspend_mode = suspend_mode; | ||
154 | } | 316 | } |
155 | 317 | ||
156 | void __init tegra_pmc_init(void) | 318 | void __init tegra_pmc_init(void) |
diff --git a/arch/arm/mach-tegra/pmc.h b/arch/arm/mach-tegra/pmc.h index 7d44710368be..e1c2df272f7d 100644 --- a/arch/arm/mach-tegra/pmc.h +++ b/arch/arm/mach-tegra/pmc.h | |||
@@ -18,6 +18,20 @@ | |||
18 | #ifndef __MACH_TEGRA_PMC_H | 18 | #ifndef __MACH_TEGRA_PMC_H |
19 | #define __MACH_TEGRA_PMC_H | 19 | #define __MACH_TEGRA_PMC_H |
20 | 20 | ||
21 | enum tegra_suspend_mode { | ||
22 | TEGRA_SUSPEND_NONE = 0, | ||
23 | TEGRA_SUSPEND_LP2, /* CPU voltage off */ | ||
24 | TEGRA_SUSPEND_LP1, /* CPU voltage off, DRAM self-refresh */ | ||
25 | TEGRA_SUSPEND_LP0, /* CPU + core voltage off, DRAM self-refresh */ | ||
26 | TEGRA_MAX_SUSPEND_MODE, | ||
27 | }; | ||
28 | |||
29 | #ifdef CONFIG_PM_SLEEP | ||
30 | enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void); | ||
31 | void tegra_pmc_pm_set(enum tegra_suspend_mode mode); | ||
32 | void tegra_pmc_suspend_init(void); | ||
33 | #endif | ||
34 | |||
21 | bool tegra_pmc_cpu_is_powered(int cpuid); | 35 | bool tegra_pmc_cpu_is_powered(int cpuid); |
22 | int tegra_pmc_cpu_power_on(int cpuid); | 36 | int tegra_pmc_cpu_power_on(int cpuid); |
23 | int tegra_pmc_cpu_remove_clamping(int cpuid); | 37 | int tegra_pmc_cpu_remove_clamping(int cpuid); |
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 27232c901a22..84deeab23ee7 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
35 | #include <linux/i2c-tegra.h> | 35 | #include <linux/i2c-tegra.h> |
36 | #include <linux/slab.h> | ||
37 | #include <linux/sys_soc.h> | ||
36 | #include <linux/usb/tegra_usb_phy.h> | 38 | #include <linux/usb/tegra_usb_phy.h> |
37 | 39 | ||
38 | #include <asm/mach-types.h> | 40 | #include <asm/mach-types.h> |
@@ -42,6 +44,7 @@ | |||
42 | 44 | ||
43 | #include "board.h" | 45 | #include "board.h" |
44 | #include "common.h" | 46 | #include "common.h" |
47 | #include "fuse.h" | ||
45 | #include "iomap.h" | 48 | #include "iomap.h" |
46 | 49 | ||
47 | static struct tegra_ehci_platform_data tegra_ehci1_pdata = { | 50 | static struct tegra_ehci_platform_data tegra_ehci1_pdata = { |
@@ -80,12 +83,36 @@ static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = { | |||
80 | 83 | ||
81 | static void __init tegra_dt_init(void) | 84 | static void __init tegra_dt_init(void) |
82 | { | 85 | { |
86 | struct soc_device_attribute *soc_dev_attr; | ||
87 | struct soc_device *soc_dev; | ||
88 | struct device *parent = NULL; | ||
89 | |||
90 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); | ||
91 | if (!soc_dev_attr) | ||
92 | goto out; | ||
93 | |||
94 | soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra"); | ||
95 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision); | ||
96 | soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id); | ||
97 | |||
98 | soc_dev = soc_device_register(soc_dev_attr); | ||
99 | if (IS_ERR(soc_dev)) { | ||
100 | kfree(soc_dev_attr->family); | ||
101 | kfree(soc_dev_attr->revision); | ||
102 | kfree(soc_dev_attr->soc_id); | ||
103 | kfree(soc_dev_attr); | ||
104 | goto out; | ||
105 | } | ||
106 | |||
107 | parent = soc_device_to_device(soc_dev); | ||
108 | |||
83 | /* | 109 | /* |
84 | * Finished with the static registrations now; fill in the missing | 110 | * Finished with the static registrations now; fill in the missing |
85 | * devices | 111 | * devices |
86 | */ | 112 | */ |
113 | out: | ||
87 | of_platform_populate(NULL, of_default_bus_match_table, | 114 | of_platform_populate(NULL, of_default_bus_match_table, |
88 | tegra20_auxdata_lookup, NULL); | 115 | tegra20_auxdata_lookup, parent); |
89 | } | 116 | } |
90 | 117 | ||
91 | static void __init trimslice_init(void) | 118 | static void __init trimslice_init(void) |
diff --git a/arch/arm/mach-tegra/tegra114_speedo.c b/arch/arm/mach-tegra/tegra114_speedo.c new file mode 100644 index 000000000000..5218d4853cd3 --- /dev/null +++ b/arch/arm/mach-tegra/tegra114_speedo.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/bug.h> | ||
19 | |||
20 | #include "fuse.h" | ||
21 | |||
22 | #define CORE_PROCESS_CORNERS_NUM 2 | ||
23 | #define CPU_PROCESS_CORNERS_NUM 2 | ||
24 | |||
25 | enum { | ||
26 | THRESHOLD_INDEX_0, | ||
27 | THRESHOLD_INDEX_1, | ||
28 | THRESHOLD_INDEX_COUNT, | ||
29 | }; | ||
30 | |||
31 | static const u32 core_process_speedos[][CORE_PROCESS_CORNERS_NUM] = { | ||
32 | {1123, UINT_MAX}, | ||
33 | {0, UINT_MAX}, | ||
34 | }; | ||
35 | |||
36 | static const u32 cpu_process_speedos[][CPU_PROCESS_CORNERS_NUM] = { | ||
37 | {1695, UINT_MAX}, | ||
38 | {0, UINT_MAX}, | ||
39 | }; | ||
40 | |||
41 | static void rev_sku_to_speedo_ids(int rev, int sku, int *threshold) | ||
42 | { | ||
43 | u32 tmp; | ||
44 | |||
45 | switch (sku) { | ||
46 | case 0x00: | ||
47 | case 0x10: | ||
48 | case 0x05: | ||
49 | case 0x06: | ||
50 | tegra_cpu_speedo_id = 1; | ||
51 | tegra_soc_speedo_id = 0; | ||
52 | *threshold = THRESHOLD_INDEX_0; | ||
53 | break; | ||
54 | |||
55 | case 0x03: | ||
56 | case 0x04: | ||
57 | tegra_cpu_speedo_id = 2; | ||
58 | tegra_soc_speedo_id = 1; | ||
59 | *threshold = THRESHOLD_INDEX_1; | ||
60 | break; | ||
61 | |||
62 | default: | ||
63 | pr_err("Tegra114 Unknown SKU %d\n", sku); | ||
64 | tegra_cpu_speedo_id = 0; | ||
65 | tegra_soc_speedo_id = 0; | ||
66 | *threshold = THRESHOLD_INDEX_0; | ||
67 | break; | ||
68 | } | ||
69 | |||
70 | if (rev == TEGRA_REVISION_A01) { | ||
71 | tmp = tegra_fuse_readl(0x270) << 1; | ||
72 | tmp |= tegra_fuse_readl(0x26c); | ||
73 | if (!tmp) | ||
74 | tegra_cpu_speedo_id = 0; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | void tegra114_init_speedo_data(void) | ||
79 | { | ||
80 | u32 cpu_speedo_val; | ||
81 | u32 core_speedo_val; | ||
82 | int threshold; | ||
83 | int i; | ||
84 | |||
85 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != | ||
86 | THRESHOLD_INDEX_COUNT); | ||
87 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != | ||
88 | THRESHOLD_INDEX_COUNT); | ||
89 | |||
90 | rev_sku_to_speedo_ids(tegra_revision, tegra_sku_id, &threshold); | ||
91 | |||
92 | cpu_speedo_val = tegra_fuse_readl(0x12c) + 1024; | ||
93 | core_speedo_val = tegra_fuse_readl(0x134); | ||
94 | |||
95 | for (i = 0; i < CPU_PROCESS_CORNERS_NUM; i++) | ||
96 | if (cpu_speedo_val < cpu_process_speedos[threshold][i]) | ||
97 | break; | ||
98 | tegra_cpu_process_id = i; | ||
99 | |||
100 | for (i = 0; i < CORE_PROCESS_CORNERS_NUM; i++) | ||
101 | if (core_speedo_val < core_process_speedos[threshold][i]) | ||
102 | break; | ||
103 | tegra_core_process_id = i; | ||
104 | } | ||