config.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/54xx/config.c
  4. *
  5. * Copyright (C) 2010, Philippe De Muyter <phdm@macqel.be>
  6. */
  7. /***************************************************************************/
  8. #include <linux/kernel.h>
  9. #include <linux/param.h>
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/io.h>
  13. #include <asm/machdep.h>
  14. #include <asm/coldfire.h>
  15. #include <asm/m54xxsim.h>
  16. #include <asm/mcfuart.h>
  17. #include <asm/m54xxgpt.h>
  18. /***************************************************************************/
  19. static struct mcf_platform_uart m54xx_uart_platform[] = {
  20. {
  21. .mapbase = MCF_MBAR + MCFUART_BASE1,
  22. .irq = 64 + 35,
  23. },
  24. {
  25. .mapbase = MCF_MBAR + MCFUART_BASE2,
  26. .irq = 64 + 34,
  27. },
  28. {
  29. .mapbase = MCF_MBAR + MCFUART_BASE3,
  30. .irq = 64 + 33,
  31. },
  32. {
  33. .mapbase = MCF_MBAR + MCFUART_BASE4,
  34. .irq = 64 + 32,
  35. },
  36. };
  37. static struct platform_device m54xx_uart = {
  38. .name = "mcfuart",
  39. .id = 0,
  40. .dev.platform_data = m54xx_uart_platform,
  41. };
  42. static struct platform_device *m54xx_devices[] __initdata = {
  43. &m54xx_uart,
  44. };
  45. /***************************************************************************/
  46. static void __init m54xx_uart_init_line(int line, int irq)
  47. {
  48. int rts_cts;
  49. /* enable io pins */
  50. switch (line) {
  51. case 0:
  52. rts_cts = 0; break;
  53. case 1:
  54. rts_cts = MCF_PAR_PSC_RTS_RTS; break;
  55. case 2:
  56. rts_cts = MCF_PAR_PSC_RTS_RTS | MCF_PAR_PSC_CTS_CTS; break;
  57. case 3:
  58. rts_cts = 0; break;
  59. }
  60. __raw_writeb(MCF_PAR_PSC_TXD | rts_cts | MCF_PAR_PSC_RXD,
  61. MCF_MBAR + MCF_PAR_PSC(line));
  62. }
  63. static void __init m54xx_uarts_init(void)
  64. {
  65. const int nrlines = ARRAY_SIZE(m54xx_uart_platform);
  66. int line;
  67. for (line = 0; (line < nrlines); line++)
  68. m54xx_uart_init_line(line, m54xx_uart_platform[line].irq);
  69. }
  70. /***************************************************************************/
  71. static void mcf54xx_reset(void)
  72. {
  73. /* disable interrupts and enable the watchdog */
  74. asm("movew #0x2700, %sr\n");
  75. __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0);
  76. __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0);
  77. __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
  78. MCF_MBAR + MCF_GPT_GMS0);
  79. }
  80. /***************************************************************************/
  81. void __init config_BSP(char *commandp, int size)
  82. {
  83. mach_reset = mcf54xx_reset;
  84. m54xx_uarts_init();
  85. }
  86. /***************************************************************************/
  87. static int __init init_BSP(void)
  88. {
  89. platform_add_devices(m54xx_devices, ARRAY_SIZE(m54xx_devices));
  90. return 0;
  91. }
  92. arch_initcall(init_BSP);
  93. /***************************************************************************/