config.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/523x/config.c
  4. *
  5. * Sub-architcture dependant initialization code for the Freescale
  6. * 523x CPUs.
  7. *
  8. * Copyright (C) 1999-2005, 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/io.h>
  16. #include <asm/machdep.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfuart.h>
  20. /***************************************************************************/
  21. static struct mcf_platform_uart m523x_uart_platform[] = {
  22. {
  23. .mapbase = MCF_MBAR + MCFUART_BASE1,
  24. .irq = MCFINT_VECBASE + MCFINT_UART0,
  25. },
  26. {
  27. .mapbase = MCF_MBAR + MCFUART_BASE2,
  28. .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
  29. },
  30. {
  31. .mapbase = MCF_MBAR + MCFUART_BASE3,
  32. .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
  33. },
  34. { },
  35. };
  36. static struct platform_device m523x_uart = {
  37. .name = "mcfuart",
  38. .id = 0,
  39. .dev.platform_data = m523x_uart_platform,
  40. };
  41. static struct resource m523x_fec_resources[] = {
  42. {
  43. .start = MCF_MBAR + 0x1000,
  44. .end = MCF_MBAR + 0x1000 + 0x7ff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. {
  48. .start = 64 + 23,
  49. .end = 64 + 23,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. {
  53. .start = 64 + 27,
  54. .end = 64 + 27,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. {
  58. .start = 64 + 29,
  59. .end = 64 + 29,
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. };
  63. static struct platform_device m523x_fec = {
  64. .name = "fec",
  65. .id = 0,
  66. .num_resources = ARRAY_SIZE(m523x_fec_resources),
  67. .resource = m523x_fec_resources,
  68. };
  69. static struct platform_device *m523x_devices[] __initdata = {
  70. &m523x_uart,
  71. &m523x_fec,
  72. };
  73. /***************************************************************************/
  74. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  75. static void __init m523x_uart_init_line(int line, int irq)
  76. {
  77. u32 imr;
  78. if ((line < 0) || (line > 2))
  79. return;
  80. writeb(0x30+line, (INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line));
  81. imr = readl(INTC0 + MCFINTC_IMRL);
  82. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  83. writel(imr, INTC0 + MCFINTC_IMRL);
  84. }
  85. static void __init m523x_uarts_init(void)
  86. {
  87. const int nrlines = ARRAY_SIZE(m523x_uart_platform);
  88. int line;
  89. for (line = 0; (line < nrlines); line++)
  90. m523x_uart_init_line(line, m523x_uart_platform[line].irq);
  91. }
  92. /***************************************************************************/
  93. static void __init m523x_fec_init(void)
  94. {
  95. u32 imr;
  96. /* Unmask FEC interrupts at ColdFire interrupt controller */
  97. writeb(0x28, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 23);
  98. writeb(0x27, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 27);
  99. writeb(0x26, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 29);
  100. imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
  101. imr &= ~0xf;
  102. writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
  103. imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
  104. imr &= ~0xff800001;
  105. writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
  106. }
  107. /***************************************************************************/
  108. void mcf_disableall(void)
  109. {
  110. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
  111. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
  112. }
  113. /***************************************************************************/
  114. void mcf_autovector(unsigned int vec)
  115. {
  116. /* Everything is auto-vectored on the 523x */
  117. }
  118. /***************************************************************************/
  119. static void m523x_cpu_reset(void)
  120. {
  121. local_irq_disable();
  122. __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR);
  123. }
  124. /***************************************************************************/
  125. void __init config_BSP(char *commandp, int size)
  126. {
  127. mcf_disableall();
  128. mach_reset = m523x_cpu_reset;
  129. m523x_uarts_init();
  130. m523x_fec_init();
  131. }
  132. /***************************************************************************/
  133. static int __init init_BSP(void)
  134. {
  135. platform_add_devices(m523x_devices, ARRAY_SIZE(m523x_devices));
  136. return 0;
  137. }
  138. arch_initcall(init_BSP);
  139. /***************************************************************************/