summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2010-04-25 00:29:45 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:34:36 -0800
commit1ae52cd40073f35c17452abc128b29dbee8bf75c (patch)
treeca015de0cb9efcc9aae7a7c4fa74003cd723f2e4
parentad117211ea3b94a22a8f0e8571403dabd93cfaa6 (diff)
[ARM] tegra: Add arch-specific udelay using TMRUS
Change-Id: If075117642a725ee2ee24a622068274e588a5bc1 Signed-off-by: Colin Cross <ccross@android.com>
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/mach-tegra/Makefile1
-rw-r--r--arch/arm/mach-tegra/delay.S50
-rw-r--r--arch/arm/mach-tegra/include/mach/delay.h41
4 files changed, 93 insertions, 0 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 82c6521d04a7..9c4d71ba4595 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -607,6 +607,7 @@ config ARCH_TEGRA
select HAVE_CLK
select HAVE_SCHED_CLOCK
select ARCH_HAS_CPUFREQ
+ select ARCH_PROVIDES_UDELAY
help
This enables support for NVIDIA Tegra based systems (Tegra APX,
Tegra 6xx and Tegra 2 series).
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index f0a3f0b728c1..52ec87c5fc48 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -6,6 +6,7 @@ obj-y += clock.o
obj-y += timer.o
obj-y += pinmux.o
obj-y += devices.o
+obj-y += delay.o
obj-y += powergate.o
obj-$(CONFIG_PM_SLEEP) += pm.o
obj-$(CONFIG_PM_SLEEP) += pm-irq.o
diff --git a/arch/arm/mach-tegra/delay.S b/arch/arm/mach-tegra/delay.S
new file mode 100644
index 000000000000..01123bfe6a0c
--- /dev/null
+++ b/arch/arm/mach-tegra/delay.S
@@ -0,0 +1,50 @@
+/*
+ * arch/arm/mach-tegra/delay.S
+ *
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Colin Cross <ccross@google.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <mach/iomap.h>
+#include <mach/io.h>
+
+ .text
+
+ENTRY(__udelay)
+ENTRY(__const_udelay)
+ ldr r3, =(IO_PPSB_VIRT + TEGRA_TMRUS_BASE - IO_PPSB_PHYS)
+ ldr r1, [r3]
+
+/* r0 - usecs to wait
+ * r1 - initial value of the counter
+ */
+loop:
+ ldr r2, [r3]
+ sub r2, r2, r1
+ cmp r2, r0
+ bls loop
+ mov pc, lr
+ENDPROC(__const_udelay)
+ENDPROC(__udelay)
+
+
+@ Delay routine
+ENTRY(__delay)
+ subs r0, r0, #1
+ bhi __delay
+ mov pc, lr
+ENDPROC(__delay)
diff --git a/arch/arm/mach-tegra/include/mach/delay.h b/arch/arm/mach-tegra/include/mach/delay.h
new file mode 100644
index 000000000000..2defb7b9b658
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/delay.h
@@ -0,0 +1,41 @@
+/*
+ * arch/arm/mach-tegra/include/mach/delay.h
+ *
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Colin Cross <ccross@google.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#ifndef __MACH_TEGRA_DELAY_H
+#define __MACH_TEGRA_DELAY_H
+
+/* needed by loops_per_jiffy calculations */
+extern void __delay(int loops);
+
+extern void __udelay(unsigned long usecs);
+extern void __const_udelay(unsigned long usecs);
+
+/* we don't have any restrictions on maximum udelay length, but we'll enforce
+ * the same restriction as the ARM default so we don't introduce any
+ * incompatibilties in drivers.
+ */
+extern void __bad_udelay(void);
+
+#define MAX_UDELAY_MS 2
+
+#define udelay(n) \
+ ((__builtin_constant_p(n) && (n) > (MAX_UDELAY_MS * 1000)) ? \
+ __bad_udelay() : \
+ __udelay(n))
+
+#endif /* defined(__MACH_TEGRA_DELAY_H) */