mvmfp.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * (C) Copyright 2010
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22. * MA 02110-1301 USA
  23. */
  24. #ifndef __MVMFP_H
  25. #define __MVMFP_H
  26. /*
  27. * Header file for MultiFunctionPin (MFP) Configururation framework
  28. *
  29. * Processors Supported:
  30. * 1. Marvell ARMADA100 Processors
  31. *
  32. * processor to be supported should be added here
  33. */
  34. /*
  35. * MFP configuration is represented by a 32-bit unsigned integer
  36. */
  37. #define MFP(_off, _pull, _pF, _drv, _dF, _edge, _eF, _afn, _aF) ( \
  38. /* bits 31..16 - MFP Register Offset */ (((_off) & 0xffff) << 16) | \
  39. /* bits 15..13 - Run Mode Pull State */ (((_pull) & 0x7) << 13) | \
  40. /* bit 12 - Unused */ \
  41. /* bits 11..10 - Driver Strength */ (((_drv) & 0x3) << 10) | \
  42. /* bit 09 - Pull State flag */ (((_pF) & 0x1) << 9) | \
  43. /* bit 08 - Drv-strength flag */ (((_dF) & 0x1) << 8) | \
  44. /* bit 07 - Edge-det flag */ (((_eF) & 0x1) << 7) | \
  45. /* bits 06..04 - Edge Detection */ (((_edge) & 0x7) << 4) | \
  46. /* bits 03..00 - Alt-fun flag */ (((_aF) & 0x1) << 3) | \
  47. /* bits Alternate-fun select */ ((_afn) & 0x7))
  48. /*
  49. * to facilitate the definition, the following macros are provided
  50. *
  51. * offset, pull,pF, drv,dF, edge,eF ,afn,aF
  52. */
  53. #define MFP_OFFSET_MASK MFP(0xffff, 0,0, 0,0, 0,0, 0,0)
  54. #define MFP_REG(x) MFP(x, 0,0, 0,0, 0,0, 0,0)
  55. #define MFP_REG_GET_OFFSET(x) ((x & MFP_OFFSET_MASK) >> 16)
  56. #define MFP_AF_FLAG MFP(0x0000, 0,0, 0,0, 0,0, 0,1)
  57. #define MFP_DRIVE_FLAG MFP(0x0000, 0,0, 0,1, 0,0, 0,0)
  58. #define MFP_EDGE_FLAG MFP(0x0000, 0,0, 0,0, 0,1, 0,0)
  59. #define MFP_PULL_FLAG MFP(0x0000, 0,1, 0,0, 0,0, 0,0)
  60. #define MFP_AF0 MFP(0x0000, 0,0, 0,0, 0,0, 0,1)
  61. #define MFP_AF1 MFP(0x0000, 0,0, 0,0, 0,0, 1,1)
  62. #define MFP_AF2 MFP(0x0000, 0,0, 0,0, 0,0, 2,1)
  63. #define MFP_AF3 MFP(0x0000, 0,0, 0,0, 0,0, 3,1)
  64. #define MFP_AF4 MFP(0x0000, 0,0, 0,0, 0,0, 4,1)
  65. #define MFP_AF5 MFP(0x0000, 0,0, 0,0, 0,0, 5,1)
  66. #define MFP_AF6 MFP(0x0000, 0,0, 0,0, 0,0, 6,1)
  67. #define MFP_AF7 MFP(0x0000, 0,0, 0,0, 0,0, 7,1)
  68. #define MFP_AF_MASK MFP(0x0000, 0,0, 0,0, 0,0, 7,0)
  69. #define MFP_LPM_EDGE_NONE MFP(0x0000, 0,0, 0,0, 0,1, 0,0)
  70. #define MFP_LPM_EDGE_RISE MFP(0x0000, 0,0, 0,0, 1,1, 0,0)
  71. #define MFP_LPM_EDGE_FALL MFP(0x0000, 0,0, 0,0, 2,1, 0,0)
  72. #define MFP_LPM_EDGE_BOTH MFP(0x0000, 0,0, 0,0, 3,1, 0,0)
  73. #define MFP_LPM_EDGE_MASK MFP(0x0000, 0,0, 0,0, 3,0, 0,0)
  74. #define MFP_DRIVE_VERY_SLOW MFP(0x0000, 0,0, 0,1, 0,0, 0,0)
  75. #define MFP_DRIVE_SLOW MFP(0x0000, 0,0, 1,1, 0,0, 0,0)
  76. #define MFP_DRIVE_MEDIUM MFP(0x0000, 0,0, 2,1, 0,0, 0,0)
  77. #define MFP_DRIVE_FAST MFP(0x0000, 0,0, 3,1, 0,0, 0,0)
  78. #define MFP_DRIVE_MASK MFP(0x0000, 0,0, 3,0, 0,0, 0,0)
  79. #define MFP_PULL_NONE MFP(0x0000, 0,1, 0,0, 0,0, 0,0)
  80. #define MFP_PULL_LOW MFP(0x0000, 1,1, 0,0, 0,0, 0,0)
  81. #define MFP_PULL_HIGH MFP(0x0000, 2,1, 0,0, 0,0, 0,0)
  82. #define MFP_PULL_BOTH MFP(0x0000, 3,1, 0,0, 0,0, 0,0)
  83. #define MFP_PULL_FLOAT MFP(0x0000, 4,1, 0,0, 0,0, 0,0)
  84. #define MFP_PULL_MASK MFP(0x0000, 7,0, 0,0, 0,0, 0,0)
  85. #define MFP_EOC 0xffffffff /* indicates end-of-conf */
  86. /* Functions */
  87. void mfp_config(u32 *mfp_cfgs);
  88. #endif /* __MVMFP_H */