config.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/528x/config.c
  4. *
  5. * Sub-architcture dependant initialization code for the Motorola
  6. * 5280 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/interrupt.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/spi/spi.h>
  18. #include <linux/spi/flash.h>
  19. #include <linux/io.h>
  20. #include <asm/machdep.h>
  21. #include <asm/coldfire.h>
  22. #include <asm/mcfsim.h>
  23. #include <asm/mcfuart.h>
  24. #include <asm/mcfqspi.h>
  25. /***************************************************************************/
  26. void coldfire_reset(void);
  27. /***************************************************************************/
  28. static struct mcf_platform_uart m528x_uart_platform[] = {
  29. {
  30. .mapbase = MCF_MBAR + MCFUART_BASE1,
  31. .irq = MCFINT_VECBASE + MCFINT_UART0,
  32. },
  33. {
  34. .mapbase = MCF_MBAR + MCFUART_BASE2,
  35. .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
  36. },
  37. {
  38. .mapbase = MCF_MBAR + MCFUART_BASE3,
  39. .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
  40. },
  41. { },
  42. };
  43. static struct platform_device m528x_uart = {
  44. .name = "mcfuart",
  45. .id = 0,
  46. .dev.platform_data = m528x_uart_platform,
  47. };
  48. static struct platform_device *m528x_devices[] __initdata = {
  49. &m528x_uart,
  50. };
  51. /***************************************************************************/
  52. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  53. static void __init m528x_uart_init_line(int line, int irq)
  54. {
  55. u8 port;
  56. u32 imr;
  57. if ((line < 0) || (line > 2))
  58. return;
  59. /* level 6, line based priority */
  60. writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
  61. imr = readl(INTC0 + MCFINTC_IMRL);
  62. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  63. writel(imr, INTC0 + MCFINTC_IMRL);
  64. /* make sure PUAPAR is set for UART0 and UART1 */
  65. if (line < 2) {
  66. port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
  67. port |= (0x03 << (line * 2));
  68. writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
  69. }
  70. }
  71. static void __init m528x_uarts_init(void)
  72. {
  73. const int nrlines = ARRAY_SIZE(m528x_uart_platform);
  74. int line;
  75. for (line = 0; (line < nrlines); line++)
  76. m528x_uart_init_line(line, m528x_uart_platform[line].irq);
  77. }
  78. /***************************************************************************/
  79. void mcf_disableall(void)
  80. {
  81. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
  82. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
  83. }
  84. /***************************************************************************/
  85. void mcf_autovector(unsigned int vec)
  86. {
  87. /* Everything is auto-vectored on the 5272 */
  88. }
  89. /***************************************************************************/
  90. void __init config_BSP(char *commandp, int size)
  91. {
  92. mcf_disableall();
  93. mach_reset = coldfire_reset;
  94. }
  95. /***************************************************************************/
  96. static int __init init_BSP(void)
  97. {
  98. m528x_uarts_init();
  99. platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
  100. return 0;
  101. }
  102. arch_initcall(init_BSP);
  103. /***************************************************************************/