iopin.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * (C) Copyright 2008
  3. * Martha J Marx, Silicon Turnkey Express, mmarx@silicontkx.com
  4. * mpc512x I/O pin/pad initialization for the ADS5121 board
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <linux/types.h>
  25. #include "iopin.h"
  26. /* IO pin fields */
  27. #define IO_PIN_FMUX(v) ((v) << 7) /* pin function */
  28. #define IO_PIN_HOLD(v) ((v) << 5) /* hold time, pci only */
  29. #define IO_PIN_PUD(v) ((v) << 4) /* if PUE, 0=pull-down, 1=pull-up */
  30. #define IO_PIN_PUE(v) ((v) << 3) /* pull up/down enable */
  31. #define IO_PIN_ST(v) ((v) << 2) /* schmitt trigger */
  32. #define IO_PIN_DS(v) ((v)) /* slew rate */
  33. static struct iopin_t {
  34. int p_offset; /* offset from IOCTL_MEM_OFFSET */
  35. int nr_pins; /* number of pins to set this way */
  36. int bit_or; /* or in the value instead of overwrite */
  37. u_long val; /* value to write or or */
  38. } ioregs_init[] = {
  39. /* FUNC1=FEC_RX_DV Sets Next 3 to FEC pads */
  40. {
  41. IOCTL_SPDIF_TXCLK, 3, 0,
  42. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  43. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  44. },
  45. /* Set highest Slew on 9 PATA pins */
  46. {
  47. IOCTL_PATA_CE1, 9, 1,
  48. IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  49. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  50. },
  51. /* FUNC1=FEC_COL Sets Next 15 to FEC pads */
  52. {
  53. IOCTL_PSC0_0, 15, 0,
  54. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  55. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  56. },
  57. /* FUNC1=SPDIF_TXCLK */
  58. {
  59. IOCTL_LPC_CS1, 1, 0,
  60. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  61. IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3)
  62. },
  63. /* FUNC2=SPDIF_TX and sets Next pin to SPDIF_RX */
  64. {
  65. IOCTL_I2C1_SCL, 2, 0,
  66. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  67. IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3)
  68. },
  69. /* FUNC2=DIU CLK */
  70. {
  71. IOCTL_PSC6_0, 1, 0,
  72. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  73. IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3)
  74. },
  75. /* FUNC2=DIU_HSYNC */
  76. {
  77. IOCTL_PSC6_1, 1, 0,
  78. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  79. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  80. },
  81. /* FUNC2=DIUVSYNC Sets Next 26 to DIU Pads */
  82. {
  83. IOCTL_PSC6_4, 26, 0,
  84. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  85. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  86. }
  87. };
  88. void iopin_initialize(void)
  89. {
  90. short i, j, n, p;
  91. u_long *reg;
  92. immap_t *im = (immap_t *)CFG_IMMR;
  93. reg = (u_long *)&(im->io_ctrl.regs[0]);
  94. if (sizeof(ioregs_init) == 0)
  95. return;
  96. n = sizeof(ioregs_init) / sizeof(ioregs_init[0]);
  97. for (i = 0; i < n; i++) {
  98. for (p = 0, j = ioregs_init[i].p_offset / sizeof(u_long);
  99. p < ioregs_init[i].nr_pins; p++, j++) {
  100. if (ioregs_init[i].bit_or)
  101. reg[j] |= ioregs_init[i].val;
  102. else
  103. reg[j] = ioregs_init[i].val;
  104. }
  105. }
  106. return;
  107. }