fuse.c 1.9 KB

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