diff options
author | Mayuresh Kulkarni <mkulkarni@nvidia.com> | 2011-05-04 13:36:03 +0530 |
---|---|---|
committer | Niket Sirsi <nsirsi@nvidia.com> | 2011-05-25 15:14:47 -0700 |
commit | a6c93d347d1b93f08a19ca1a56741b704dbdb306 (patch) | |
tree | ac0fd3a83ab73cab59726b68d014361031fcf24d /arch/arm/mach-tegra/kfuse.c | |
parent | 7d4b75fd31d2be1f287bf97eac6e62519978b206 (diff) |
[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 <mkulkarni@nvidia.com>
Reviewed-on: http://git-master/r/30333
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Jonathan Mayo <jmayo@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/kfuse.c')
-rw-r--r-- | arch/arm/mach-tegra/kfuse.c | 23 |
1 files changed, 20 insertions, 3 deletions
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 <linux/err.h> #include <linux/string.h> #include <linux/delay.h> +#include <linux/clk.h> #include <mach/iomap.h> #include <mach/kfuse.h> +#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; } |