tqm8xx_setup.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Platform setup for the MPC8xx based boards from TQM.
  3. *
  4. * Heiko Schocher <hs@denx.de>
  5. * Copyright 2010 DENX Software Engineering GmbH
  6. *
  7. * based on:
  8. * Vitaly Bordug <vbordug@ru.mvista.com>
  9. *
  10. * Copyright 2005 MontaVista Software Inc.
  11. *
  12. * Heavily modified by Scott Wood <scottwood@freescale.com>
  13. * Copyright 2007 Freescale Semiconductor, Inc.
  14. *
  15. * This file is licensed under the terms of the GNU General Public License
  16. * version 2. This program is licensed "as is" without any warranty of any
  17. * kind, whether express or implied.
  18. */
  19. #include <linux/init.h>
  20. #include <linux/param.h>
  21. #include <linux/string.h>
  22. #include <linux/ioport.h>
  23. #include <linux/device.h>
  24. #include <linux/delay.h>
  25. #include <linux/fs_enet_pd.h>
  26. #include <linux/fs_uart_pd.h>
  27. #include <linux/fsl_devices.h>
  28. #include <linux/mii.h>
  29. #include <linux/of_fdt.h>
  30. #include <linux/of_platform.h>
  31. #include <asm/delay.h>
  32. #include <asm/io.h>
  33. #include <asm/machdep.h>
  34. #include <asm/page.h>
  35. #include <asm/processor.h>
  36. #include <asm/time.h>
  37. #include <asm/8xx_immap.h>
  38. #include <asm/cpm1.h>
  39. #include <asm/fs_pd.h>
  40. #include <asm/udbg.h>
  41. #include "mpc8xx.h"
  42. struct cpm_pin {
  43. int port, pin, flags;
  44. };
  45. static struct cpm_pin tqm8xx_pins[] __initdata = {
  46. /* SMC1 */
  47. {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
  48. {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  49. /* SCC1 */
  50. {CPM_PORTA, 5, CPM_PIN_INPUT}, /* CLK1 */
  51. {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
  52. {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
  53. {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
  54. {CPM_PORTC, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
  55. {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO},
  56. {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO},
  57. };
  58. static struct cpm_pin tqm8xx_fec_pins[] __initdata = {
  59. /* MII */
  60. {CPM_PORTD, 3, CPM_PIN_OUTPUT},
  61. {CPM_PORTD, 4, CPM_PIN_OUTPUT},
  62. {CPM_PORTD, 5, CPM_PIN_OUTPUT},
  63. {CPM_PORTD, 6, CPM_PIN_OUTPUT},
  64. {CPM_PORTD, 7, CPM_PIN_OUTPUT},
  65. {CPM_PORTD, 8, CPM_PIN_OUTPUT},
  66. {CPM_PORTD, 9, CPM_PIN_OUTPUT},
  67. {CPM_PORTD, 10, CPM_PIN_OUTPUT},
  68. {CPM_PORTD, 11, CPM_PIN_OUTPUT},
  69. {CPM_PORTD, 12, CPM_PIN_OUTPUT},
  70. {CPM_PORTD, 13, CPM_PIN_OUTPUT},
  71. {CPM_PORTD, 14, CPM_PIN_OUTPUT},
  72. {CPM_PORTD, 15, CPM_PIN_OUTPUT},
  73. };
  74. static void __init init_pins(int n, struct cpm_pin *pin)
  75. {
  76. int i;
  77. for (i = 0; i < n; i++) {
  78. cpm1_set_pin(pin->port, pin->pin, pin->flags);
  79. pin++;
  80. }
  81. }
  82. static void __init init_ioports(void)
  83. {
  84. struct device_node *dnode;
  85. struct property *prop;
  86. int len;
  87. init_pins(ARRAY_SIZE(tqm8xx_pins), &tqm8xx_pins[0]);
  88. cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
  89. dnode = of_find_node_by_name(NULL, "aliases");
  90. if (dnode == NULL)
  91. return;
  92. prop = of_find_property(dnode, "ethernet1", &len);
  93. if (prop == NULL)
  94. return;
  95. /* init FEC pins */
  96. init_pins(ARRAY_SIZE(tqm8xx_fec_pins), &tqm8xx_fec_pins[0]);
  97. }
  98. static void __init tqm8xx_setup_arch(void)
  99. {
  100. cpm_reset();
  101. init_ioports();
  102. }
  103. static int __init tqm8xx_probe(void)
  104. {
  105. unsigned long node = of_get_flat_dt_root();
  106. return of_flat_dt_is_compatible(node, "tqc,tqm8xx");
  107. }
  108. static const struct of_device_id of_bus_ids[] __initconst = {
  109. { .name = "soc", },
  110. { .name = "cpm", },
  111. { .name = "localbus", },
  112. { .compatible = "simple-bus" },
  113. {},
  114. };
  115. static int __init declare_of_platform_devices(void)
  116. {
  117. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  118. return 0;
  119. }
  120. machine_device_initcall(tqm8xx, declare_of_platform_devices);
  121. define_machine(tqm8xx) {
  122. .name = "TQM8xx",
  123. .probe = tqm8xx_probe,
  124. .setup_arch = tqm8xx_setup_arch,
  125. .init_IRQ = mpc8xx_pics_init,
  126. .get_irq = mpc8xx_get_irq,
  127. .restart = mpc8xx_restart,
  128. .calibrate_decr = mpc8xx_calibrate_decr,
  129. .set_rtc_time = mpc8xx_set_rtc_time,
  130. .get_rtc_time = mpc8xx_get_rtc_time,
  131. .progress = udbg_progress,
  132. };