fuse.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include <linux/kernel.h>
  20. #include <linux/io.h>
  21. #include <mach/iomap.h>
  22. #include "fuse.h"
  23. #define FUSE_UID_LOW 0x108
  24. #define FUSE_UID_HIGH 0x10c
  25. #define FUSE_SKU_INFO 0x110
  26. #define FUSE_SPARE_BIT 0x200
  27. static inline u32 fuse_readl(unsigned long offset)
  28. {
  29. return readl(IO_TO_VIRT(TEGRA_FUSE_BASE + offset));
  30. }
  31. static inline void fuse_writel(u32 value, unsigned long offset)
  32. {
  33. writel(value, IO_TO_VIRT(TEGRA_FUSE_BASE + offset));
  34. }
  35. void tegra_init_fuse(void)
  36. {
  37. u32 reg = readl(IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48));
  38. reg |= 1 << 28;
  39. writel(reg, IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48));
  40. pr_info("Tegra SKU: %d CPU Process: %d Core Process: %d\n",
  41. tegra_sku_id(), tegra_cpu_process_id(),
  42. tegra_core_process_id());
  43. }
  44. unsigned long long tegra_chip_uid(void)
  45. {
  46. unsigned long long lo, hi;
  47. lo = fuse_readl(FUSE_UID_LOW);
  48. hi = fuse_readl(FUSE_UID_HIGH);
  49. return (hi << 32ull) | lo;
  50. }
  51. int tegra_sku_id(void)
  52. {
  53. int sku_id;
  54. u32 reg = fuse_readl(FUSE_SKU_INFO);
  55. sku_id = reg & 0xFF;
  56. return sku_id;
  57. }
  58. int tegra_cpu_process_id(void)
  59. {
  60. int cpu_process_id;
  61. u32 reg = fuse_readl(FUSE_SPARE_BIT);
  62. cpu_process_id = (reg >> 6) & 3;
  63. return cpu_process_id;
  64. }
  65. int tegra_core_process_id(void)
  66. {
  67. int core_process_id;
  68. u32 reg = fuse_readl(FUSE_SPARE_BIT);
  69. core_process_id = (reg >> 12) & 3;
  70. return core_process_id;
  71. }