From a6c93d347d1b93f08a19ca1a56741b704dbdb306 Mon Sep 17 00:00:00 2001 From: Mayuresh Kulkarni Date: Wed, 4 May 2011 13:36:03 +0530 Subject: [ARM]: tegra: kfuse: enable/disable kfuse clock when needed clock to kfuse is turned ON during boot-up which is not needed. hence turn it on when needed and turn it off after use. for bug 819505 Change-Id: I3b0bd3ee295b4998d6d6f747a946ca28bd9550a5 Signed-off-by: Mayuresh Kulkarni Reviewed-on: http://git-master/r/30333 Reviewed-by: Bharat Nihalani Reviewed-by: Jonathan Mayo --- arch/arm/mach-tegra/kfuse.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'arch/arm/mach-tegra/kfuse.c') diff --git a/arch/arm/mach-tegra/kfuse.c b/arch/arm/mach-tegra/kfuse.c index f5de828bb508..e5f55b5882d4 100644 --- a/arch/arm/mach-tegra/kfuse.c +++ b/arch/arm/mach-tegra/kfuse.c @@ -23,19 +23,23 @@ #include #include #include +#include #include #include +#include "clock.h" #include "apbio.h" +static struct clk *kfuse_clk = NULL; + /* register definition */ -#define KFUSE_STATE 0x80 +#define KFUSE_STATE 0x80 #define KFUSE_STATE_DONE (1u << 16) #define KFUSE_STATE_CRCPASS (1u << 17) -#define KFUSE_KEYADDR 0x88 +#define KFUSE_KEYADDR 0x88 #define KFUSE_KEYADDR_AUTOINC (1u << 16) -#define KFUSE_KEYS 0x8c +#define KFUSE_KEYS 0x8c static inline u32 tegra_kfuse_readl(unsigned long offset) { @@ -71,11 +75,22 @@ int tegra_kfuse_read(void *dest, size_t len) if (len > KFUSE_DATA_SZ) return -EINVAL; + if (kfuse_clk == NULL) { + kfuse_clk = tegra_get_clock_by_name("kfuse"); + if (IS_ERR_OR_NULL(kfuse_clk)) { + pr_err("kfuse: can't get kfuse clock\n"); + return -EINVAL; + } + } + + clk_enable(kfuse_clk); + tegra_kfuse_writel(KFUSE_KEYADDR_AUTOINC, KFUSE_KEYADDR); wait_for_done(); if ((tegra_kfuse_readl(KFUSE_STATE) & KFUSE_STATE_CRCPASS) == 0) { pr_err("kfuse: crc failed\n"); + clk_disable(kfuse_clk); return -EIO; } @@ -84,5 +99,7 @@ int tegra_kfuse_read(void *dest, size_t len) memcpy(dest + cnt, &v, sizeof v); } + clk_disable(kfuse_clk); + return 0; } -- cgit v1.2.3