mvmfp.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010
  4. * Marvell Semiconductor <www.marvell.com>
  5. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>,
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <mvmfp.h>
  10. #include <asm/arch/mfp.h>
  11. /*
  12. * mfp_config
  13. *
  14. * On most of Marvell SoCs (ex. ARMADA100) there is Multi-Funtion-Pin
  15. * configuration registers to configure each GPIO/Function pin on the
  16. * SoC.
  17. *
  18. * This function reads the array of values for
  19. * MFPR_X registers and programms them into respective
  20. * Multi-Function Pin registers.
  21. * It supports - Alternate Function Selection programming.
  22. *
  23. * Whereas,
  24. * The Configureation value is constructed using MFP()
  25. * array consists of 32bit values as defined in MFP(xx,xx..) macro
  26. */
  27. void mfp_config(u32 *mfp_cfgs)
  28. {
  29. u32 *p_mfpr = NULL;
  30. u32 cfg_val, val;
  31. do {
  32. cfg_val = *mfp_cfgs++;
  33. /* exit if End of configuration table detected */
  34. if (cfg_val == MFP_EOC)
  35. break;
  36. p_mfpr = (u32 *)(MV_MFPR_BASE
  37. + MFP_REG_GET_OFFSET(cfg_val));
  38. /* Write a mfg register as per configuration */
  39. val = 0;
  40. if (cfg_val & MFP_VALUE_MASK)
  41. val |= cfg_val & MFP_VALUE_MASK;
  42. writel(val, p_mfpr);
  43. } while (1);
  44. /*
  45. * perform a read-back of any MFPR register to make sure the
  46. * previous writings are finished
  47. */
  48. readl(p_mfpr);
  49. }