config.c 4.1 KB

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