iomux.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Based on Linux i.MX iomux-v3.h file:
  3. * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
  4. * <armlinux@phytec.de>
  5. *
  6. * Copyright (C) 2016 Freescale Semiconductor, Inc.
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #ifndef __MACH_IOMUX_H__
  11. #define __MACH_IOMUX_H__
  12. /*
  13. * build IOMUX_PAD structure
  14. *
  15. * This iomux scheme is based around pads, which are the physical balls
  16. * on the processor.
  17. *
  18. * - Each pad has a pad control register (IOMUXC_SW_PAD_CTRL_x) which controls
  19. * things like driving strength and pullup/pulldown.
  20. * - Each pad can have but not necessarily does have an output routing register
  21. * (IOMUXC_SW_MUX_CTL_PAD_x).
  22. * - Each pad can have but not necessarily does have an input routing register
  23. * (IOMUXC_x_SELECT_INPUT)
  24. *
  25. * The three register sets do not have a fixed offset to each other,
  26. * hence we order this table by pad control registers (which all pads
  27. * have) and put the optional i/o routing registers into additional
  28. * fields.
  29. *
  30. * The naming convention for the pad modes is SOC_PAD_<padname>__<padmode>
  31. * If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num>
  32. *
  33. * IOMUX/PAD Bit field definitions
  34. *
  35. * MUX_CTRL_OFS: 0..15 (16)
  36. * SEL_INPUT_OFS: 16..31 (16)
  37. * MUX_MODE: 32..37 (6)
  38. * SEL_INP: 38..41 (4)
  39. * PAD_CTRL + NO_PAD_CTRL: 42..60 (19)
  40. * reserved: 61-63 (3)
  41. */
  42. typedef u64 iomux_cfg_t;
  43. #define MUX_CTRL_OFS_SHIFT 0
  44. #define MUX_CTRL_OFS_MASK ((iomux_cfg_t)0xffff << MUX_CTRL_OFS_SHIFT)
  45. #define MUX_SEL_INPUT_OFS_SHIFT 16
  46. #define MUX_SEL_INPUT_OFS_MASK ((iomux_cfg_t)0xffff << \
  47. MUX_SEL_INPUT_OFS_SHIFT)
  48. #define MUX_MODE_SHIFT 32
  49. #define MUX_MODE_MASK ((iomux_cfg_t)0x3f << MUX_MODE_SHIFT)
  50. #define MUX_SEL_INPUT_SHIFT 38
  51. #define MUX_SEL_INPUT_MASK ((iomux_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
  52. #define MUX_PAD_CTRL_SHIFT 42
  53. #define MUX_PAD_CTRL_MASK ((iomux_cfg_t)0x7ffff << MUX_PAD_CTRL_SHIFT)
  54. #define MUX_PAD_CTRL(x) ((iomux_cfg_t)(x) << MUX_PAD_CTRL_SHIFT)
  55. #define IOMUX_PAD(pad_ctrl_ofs, mux_ctrl_ofs, mux_mode, sel_input_ofs, \
  56. sel_input, pad_ctrl) \
  57. (((iomux_cfg_t)(mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) | \
  58. ((iomux_cfg_t)(mux_mode) << MUX_MODE_SHIFT) | \
  59. ((iomux_cfg_t)(pad_ctrl) << MUX_PAD_CTRL_SHIFT) | \
  60. ((iomux_cfg_t)(sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT)| \
  61. ((iomux_cfg_t)(sel_input) << MUX_SEL_INPUT_SHIFT))
  62. #define NEW_PAD_CTRL(cfg, pad) (((cfg) & ~MUX_PAD_CTRL_MASK) | \
  63. MUX_PAD_CTRL(pad))
  64. #define IOMUX_CONFIG_MPORTS 0x20
  65. #define MUX_MODE_MPORTS ((iomux_v3_cfg_t)IOMUX_CONFIG_MPORTS << \
  66. MUX_MODE_SHIFT)
  67. /* Bit definition below needs to be fixed acccording to ulp rm */
  68. #define NO_PAD_CTRL (1 << 18)
  69. #define PAD_CTL_OBE_ENABLE (1 << 17)
  70. #define PAD_CTL_IBE_ENABLE (1 << 16)
  71. #define PAD_CTL_DSE (1 << 6)
  72. #define PAD_CTL_ODE (1 << 5)
  73. #define PAD_CTL_SRE_FAST (0 << 2)
  74. #define PAD_CTL_SRE_SLOW (1 << 2)
  75. #define PAD_CTL_PUE (1 << 1)
  76. #define PAD_CTL_PUS_UP ((1 << 0) | PAD_CTL_PUE)
  77. #define PAD_CTL_PUS_DOWN ((0 << 0) | PAD_CTL_PUE)
  78. void mx7ulp_iomux_setup_pad(iomux_cfg_t pad);
  79. void mx7ulp_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list,
  80. unsigned count);
  81. #endif /* __MACH_IOMUX_H__*/