abb.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Adaptive Body Bias programming sequence for OMAP5 family
  4. *
  5. * (C) Copyright 2013
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Andrii Tseglytskyi <andrii.tseglytskyi@ti.com>
  9. */
  10. #include <common.h>
  11. #include <asm/omap_common.h>
  12. #include <asm/io.h>
  13. #include <linux/bitops.h>
  14. /*
  15. * Setup LDOVBB for OMAP5.
  16. * On OMAP5+ some ABB settings are fused. They are handled
  17. * in the following way:
  18. *
  19. * 1. corresponding EFUSE register contains ABB enable bit
  20. * and VSET value
  21. * 2. If ABB enable bit is set to 1, than ABB should be
  22. * enabled, otherwise ABB should be disabled
  23. * 3. If ABB is enabled, than VSET value should be copied
  24. * to corresponding MUX control register
  25. */
  26. s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb)
  27. {
  28. u32 vset;
  29. u32 fuse_enable_mask = OMAP5_PROD_ABB_FUSE_ENABLE_MASK;
  30. u32 fuse_vset_mask = OMAP5_PROD_ABB_FUSE_VSET_MASK;
  31. if (!is_omap54xx()) {
  32. /* DRA7 */
  33. fuse_enable_mask = DRA7_ABB_FUSE_ENABLE_MASK;
  34. fuse_vset_mask = DRA7_ABB_FUSE_VSET_MASK;
  35. }
  36. /*
  37. * ABB parameters must be properly fused
  38. * otherwise ABB should be disabled
  39. */
  40. vset = readl(fuse);
  41. if (!(vset & fuse_enable_mask))
  42. return -1;
  43. /* prepare VSET value for LDOVBB mux register */
  44. vset &= fuse_vset_mask;
  45. vset >>= ffs(fuse_vset_mask) - 1;
  46. vset <<= ffs(OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK) - 1;
  47. vset |= OMAP5_ABB_LDOVBBMPU_MUX_CTRL_MASK;
  48. /* setup LDOVBB using fused value */
  49. clrsetbits_le32(ldovbb, OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK, vset);
  50. return 0;
  51. }