m527x.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/527x/config.c
  4. *
  5. * Sub-architcture dependent initialization code for the Freescale
  6. * 5270/5271 CPUs.
  7. *
  8. * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
  9. * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
  10. */
  11. /***************************************************************************/
  12. #include <linux/kernel.h>
  13. #include <linux/param.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <asm/machdep.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfuart.h>
  20. #include <asm/mcfgpio.h>
  21. /***************************************************************************/
  22. struct mcf_gpio_chip mcf_gpio_chips[] = {
  23. #if defined(CONFIG_M5271)
  24. MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
  25. MCFGPF(ADDR, 13, 3),
  26. MCFGPF(DATAH, 16, 8),
  27. MCFGPF(DATAL, 24, 8),
  28. MCFGPF(BUSCTL, 32, 8),
  29. MCFGPF(BS, 40, 4),
  30. MCFGPF(CS, 49, 7),
  31. MCFGPF(SDRAM, 56, 6),
  32. MCFGPF(FECI2C, 64, 4),
  33. MCFGPF(UARTH, 72, 2),
  34. MCFGPF(UARTL, 80, 8),
  35. MCFGPF(QSPI, 88, 5),
  36. MCFGPF(TIMER, 96, 8),
  37. #elif defined(CONFIG_M5275)
  38. MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
  39. MCFGPF(BUSCTL, 8, 8),
  40. MCFGPF(ADDR, 21, 3),
  41. MCFGPF(CS, 25, 7),
  42. MCFGPF(FEC0H, 32, 8),
  43. MCFGPF(FEC0L, 40, 8),
  44. MCFGPF(FECI2C, 48, 6),
  45. MCFGPF(QSPI, 56, 7),
  46. MCFGPF(SDRAM, 64, 8),
  47. MCFGPF(TIMERH, 72, 4),
  48. MCFGPF(TIMERL, 80, 4),
  49. MCFGPF(UARTL, 88, 8),
  50. MCFGPF(FEC1H, 96, 8),
  51. MCFGPF(FEC1L, 104, 8),
  52. MCFGPF(BS, 114, 2),
  53. MCFGPF(IRQ, 121, 7),
  54. MCFGPF(USBH, 128, 1),
  55. MCFGPF(USBL, 136, 8),
  56. MCFGPF(UARTH, 144, 4),
  57. #endif
  58. };
  59. unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
  60. /***************************************************************************/
  61. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  62. static void __init m527x_qspi_init(void)
  63. {
  64. #if defined(CONFIG_M5271)
  65. u16 par;
  66. /* setup QSPS pins for QSPI with gpio CS control */
  67. writeb(0x1f, MCFGPIO_PAR_QSPI);
  68. /* and CS2 & CS3 as gpio */
  69. par = readw(MCFGPIO_PAR_TIMER);
  70. par &= 0x3f3f;
  71. writew(par, MCFGPIO_PAR_TIMER);
  72. #elif defined(CONFIG_M5275)
  73. /* setup QSPS pins for QSPI with gpio CS control */
  74. writew(0x003e, MCFGPIO_PAR_QSPI);
  75. #endif
  76. }
  77. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  78. /***************************************************************************/
  79. static void __init m527x_uarts_init(void)
  80. {
  81. u16 sepmask;
  82. /*
  83. * External Pin Mask Setting & Enable External Pin for Interface
  84. */
  85. sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  86. sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK;
  87. writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  88. }
  89. /***************************************************************************/
  90. static void __init m527x_fec_init(void)
  91. {
  92. u16 par;
  93. u8 v;
  94. /* Set multi-function pins to ethernet mode for fec0 */
  95. #if defined(CONFIG_M5271)
  96. v = readb(MCF_IPSBAR + 0x100047);
  97. writeb(v | 0xf0, MCF_IPSBAR + 0x100047);
  98. #else
  99. par = readw(MCF_IPSBAR + 0x100082);
  100. writew(par | 0xf00, MCF_IPSBAR + 0x100082);
  101. v = readb(MCF_IPSBAR + 0x100078);
  102. writeb(v | 0xc0, MCF_IPSBAR + 0x100078);
  103. /* Set multi-function pins to ethernet mode for fec1 */
  104. par = readw(MCF_IPSBAR + 0x100082);
  105. writew(par | 0xa0, MCF_IPSBAR + 0x100082);
  106. v = readb(MCF_IPSBAR + 0x100079);
  107. writeb(v | 0xc0, MCF_IPSBAR + 0x100079);
  108. #endif
  109. }
  110. /***************************************************************************/
  111. void __init config_BSP(char *commandp, int size)
  112. {
  113. mach_sched_init = hw_timer_init;
  114. m527x_uarts_init();
  115. m527x_fec_init();
  116. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  117. m527x_qspi_init();
  118. #endif
  119. }
  120. /***************************************************************************/