pinmux.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2015 Linaro
  4. * Peter Griffin <peter.griffin@linaro.org>
  5. */
  6. #ifndef __ASM_ARM_ARCH_PINMUX_H
  7. #define __ASM_ARM_ARCH_PINMUX_H
  8. #include "periph.h"
  9. /* iomg bit definition */
  10. #define MUX_M0 0
  11. #define MUX_M1 1
  12. #define MUX_M2 2
  13. #define MUX_M3 3
  14. #define MUX_M4 4
  15. #define MUX_M5 5
  16. #define MUX_M6 6
  17. #define MUX_M7 7
  18. /* iocg bit definition */
  19. #define PULL_MASK (3)
  20. #define PULL_DIS (0)
  21. #define PULL_UP (1 << 0)
  22. #define PULL_DOWN (1 << 1)
  23. /* drive strength definition */
  24. #define DRIVE_MASK (7 << 4)
  25. #define DRIVE1_02MA (0 << 4)
  26. #define DRIVE1_04MA (1 << 4)
  27. #define DRIVE1_08MA (2 << 4)
  28. #define DRIVE1_10MA (3 << 4)
  29. #define DRIVE2_02MA (0 << 4)
  30. #define DRIVE2_04MA (1 << 4)
  31. #define DRIVE2_08MA (2 << 4)
  32. #define DRIVE2_10MA (3 << 4)
  33. #define DRIVE3_04MA (0 << 4)
  34. #define DRIVE3_08MA (1 << 4)
  35. #define DRIVE3_12MA (2 << 4)
  36. #define DRIVE3_16MA (3 << 4)
  37. #define DRIVE3_20MA (4 << 4)
  38. #define DRIVE3_24MA (5 << 4)
  39. #define DRIVE3_32MA (6 << 4)
  40. #define DRIVE3_40MA (7 << 4)
  41. #define DRIVE4_02MA (0 << 4)
  42. #define DRIVE4_04MA (2 << 4)
  43. #define DRIVE4_08MA (4 << 4)
  44. #define DRIVE4_10MA (6 << 4)
  45. #define HI6220_PINMUX0_BASE 0xf7010000
  46. #define HI6220_PINMUX1_BASE 0xf7010800
  47. #ifndef __ASSEMBLY__
  48. /* maybe more registers, but highest used is 123 */
  49. #define REG_NUM 123
  50. struct hi6220_pinmux0_regs {
  51. uint32_t iomg[REG_NUM];
  52. };
  53. struct hi6220_pinmux1_regs {
  54. uint32_t iocfg[REG_NUM];
  55. };
  56. #endif
  57. /**
  58. * Configures the pinmux for a particular peripheral.
  59. *
  60. * This function will configure the peripheral pinmux along with
  61. * pull-up/down and drive strength.
  62. *
  63. * @param peripheral peripheral to be configured
  64. * Return: 0 if ok, -1 on error (e.g. unsupported peripheral)
  65. */
  66. int hi6220_pinmux_config(int peripheral);
  67. #endif