m528x.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/528x/config.c
  4. *
  5. * Sub-architcture dependent initialization code for the Freescale
  6. * 5280, 5281 and 5282 CPUs.
  7. *
  8. * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
  9. * Copyright (C) 2001-2003, 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/platform_device.h>
  16. #include <linux/io.h>
  17. #include <asm/machdep.h>
  18. #include <asm/coldfire.h>
  19. #include <asm/mcfsim.h>
  20. #include <asm/mcfuart.h>
  21. #include <asm/mcfgpio.h>
  22. /***************************************************************************/
  23. struct mcf_gpio_chip mcf_gpio_chips[] = {
  24. MCFGPS(NQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
  25. MCFGPS(TA, 8, 4, MCFGPTA_GPTDDR, MCFGPTA_GPTPORT, MCFGPTB_GPTPORT),
  26. MCFGPS(TB, 16, 4, MCFGPTB_GPTDDR, MCFGPTB_GPTPORT, MCFGPTB_GPTPORT),
  27. MCFGPS(QA, 24, 4, MCFQADC_DDRQA, MCFQADC_PORTQA, MCFQADC_PORTQA),
  28. MCFGPS(QB, 32, 4, MCFQADC_DDRQB, MCFQADC_PORTQB, MCFQADC_PORTQB),
  29. MCFGPF(A, 40, 8),
  30. MCFGPF(B, 48, 8),
  31. MCFGPF(C, 56, 8),
  32. MCFGPF(D, 64, 8),
  33. MCFGPF(E, 72, 8),
  34. MCFGPF(F, 80, 8),
  35. MCFGPF(G, 88, 8),
  36. MCFGPF(H, 96, 8),
  37. MCFGPF(J, 104, 8),
  38. MCFGPF(DD, 112, 8),
  39. MCFGPF(EH, 120, 8),
  40. MCFGPF(EL, 128, 8),
  41. MCFGPF(AS, 136, 6),
  42. MCFGPF(QS, 144, 7),
  43. MCFGPF(SD, 152, 6),
  44. MCFGPF(TC, 160, 4),
  45. MCFGPF(TD, 168, 4),
  46. MCFGPF(UA, 176, 4),
  47. };
  48. unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
  49. /***************************************************************************/
  50. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  51. static void __init m528x_qspi_init(void)
  52. {
  53. /* setup Port QS for QSPI with gpio CS control */
  54. __raw_writeb(0x07, MCFGPIO_PQSPAR);
  55. }
  56. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  57. /***************************************************************************/
  58. static void __init m528x_uarts_init(void)
  59. {
  60. u8 port;
  61. /* make sure PUAPAR is set for UART0 and UART1 */
  62. port = readb(MCF5282_GPIO_PUAPAR);
  63. port |= 0x03 | (0x03 << 2);
  64. writeb(port, MCF5282_GPIO_PUAPAR);
  65. }
  66. /***************************************************************************/
  67. static void __init m528x_fec_init(void)
  68. {
  69. u16 v16;
  70. /* Set multi-function pins to ethernet mode for fec0 */
  71. v16 = readw(MCF_IPSBAR + 0x100056);
  72. writew(v16 | 0xf00, MCF_IPSBAR + 0x100056);
  73. writeb(0xc0, MCF_IPSBAR + 0x100058);
  74. }
  75. /***************************************************************************/
  76. #ifdef CONFIG_WILDFIRE
  77. void wildfire_halt(void)
  78. {
  79. writeb(0, 0x30000007);
  80. writeb(0x2, 0x30000007);
  81. }
  82. #endif
  83. #ifdef CONFIG_WILDFIREMOD
  84. void wildfiremod_halt(void)
  85. {
  86. printk(KERN_INFO "WildFireMod hibernating...\n");
  87. /* Set portE.5 to Digital IO */
  88. MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
  89. /* Make portE.5 an output */
  90. MCF5282_GPIO_DDRE |= (1 << 5);
  91. /* Now toggle portE.5 from low to high */
  92. MCF5282_GPIO_PORTE &= ~(1 << 5);
  93. MCF5282_GPIO_PORTE |= (1 << 5);
  94. printk(KERN_EMERG "Failed to hibernate. Halting!\n");
  95. }
  96. #endif
  97. void __init config_BSP(char *commandp, int size)
  98. {
  99. #ifdef CONFIG_WILDFIRE
  100. mach_halt = wildfire_halt;
  101. #endif
  102. #ifdef CONFIG_WILDFIREMOD
  103. mach_halt = wildfiremod_halt;
  104. #endif
  105. mach_sched_init = hw_timer_init;
  106. m528x_uarts_init();
  107. m528x_fec_init();
  108. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  109. m528x_qspi_init();
  110. #endif
  111. }
  112. /***************************************************************************/