mvmfp.c 1.3 KB

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