Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-tegra/fuse.c |
| 3 | * |
| 4 | * Copyright (C) 2010 Google, Inc. |
| 5 | * |
| 6 | * Author: |
| 7 | * Colin Cross <ccross@android.com> |
| 8 | * |
| 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 |
| 11 | * may be copied, distributed, and modified under those terms. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/io.h> |
| 22 | |
| 23 | #include <mach/iomap.h> |
| 24 | |
| 25 | #include "fuse.h" |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 26 | #include "apbio.h" |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 27 | |
| 28 | #define FUSE_UID_LOW 0x108 |
| 29 | #define FUSE_UID_HIGH 0x10c |
| 30 | #define FUSE_SKU_INFO 0x110 |
| 31 | #define FUSE_SPARE_BIT 0x200 |
| 32 | |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 33 | static inline u32 tegra_fuse_readl(unsigned long offset) |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 34 | { |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 35 | return tegra_apb_readl(TEGRA_FUSE_BASE + offset); |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void tegra_init_fuse(void) |
| 39 | { |
| 40 | u32 reg = readl(IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48)); |
| 41 | reg |= 1 << 28; |
| 42 | writel(reg, IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48)); |
| 43 | |
| 44 | pr_info("Tegra SKU: %d CPU Process: %d Core Process: %d\n", |
| 45 | tegra_sku_id(), tegra_cpu_process_id(), |
| 46 | tegra_core_process_id()); |
| 47 | } |
| 48 | |
| 49 | unsigned long long tegra_chip_uid(void) |
| 50 | { |
| 51 | unsigned long long lo, hi; |
| 52 | |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 53 | lo = tegra_fuse_readl(FUSE_UID_LOW); |
| 54 | hi = tegra_fuse_readl(FUSE_UID_HIGH); |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 55 | return (hi << 32ull) | lo; |
| 56 | } |
| 57 | |
| 58 | int tegra_sku_id(void) |
| 59 | { |
| 60 | int sku_id; |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 61 | u32 reg = tegra_fuse_readl(FUSE_SKU_INFO); |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 62 | sku_id = reg & 0xFF; |
| 63 | return sku_id; |
| 64 | } |
| 65 | |
| 66 | int tegra_cpu_process_id(void) |
| 67 | { |
| 68 | int cpu_process_id; |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 69 | u32 reg = tegra_fuse_readl(FUSE_SPARE_BIT); |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 70 | cpu_process_id = (reg >> 6) & 3; |
| 71 | return cpu_process_id; |
| 72 | } |
| 73 | |
| 74 | int tegra_core_process_id(void) |
| 75 | { |
| 76 | int core_process_id; |
Olof Johansson | d262f49 | 2011-10-13 00:14:08 -0700 | [diff] [blame^] | 77 | u32 reg = tegra_fuse_readl(FUSE_SPARE_BIT); |
Colin Cross | 73625e3 | 2010-06-23 15:49:17 -0700 | [diff] [blame] | 78 | core_process_id = (reg >> 12) & 3; |
| 79 | return core_process_id; |
| 80 | } |