mpc86xads_setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*arch/powerpc/platforms/8xx/mpc86xads_setup.c
  2. *
  3. * Platform setup for the Freescale mpc86xads board
  4. *
  5. * Vitaly Bordug <vbordug@ru.mvista.com>
  6. *
  7. * Copyright 2005 MontaVista Software Inc.
  8. *
  9. * Heavily modified by Scott Wood <scottwood@freescale.com>
  10. * Copyright 2007 Freescale Semiconductor, Inc.
  11. *
  12. * This file is licensed under the terms of the GNU General Public License
  13. * version 2. This program is licensed "as is" without any warranty of any
  14. * kind, whether express or implied.
  15. */
  16. #include <linux/init.h>
  17. #include <linux/of_address.h>
  18. #include <linux/of_fdt.h>
  19. #include <linux/of_platform.h>
  20. #include <asm/io.h>
  21. #include <asm/machdep.h>
  22. #include <asm/time.h>
  23. #include <asm/8xx_immap.h>
  24. #include <asm/cpm1.h>
  25. #include <asm/fs_pd.h>
  26. #include <asm/udbg.h>
  27. #include "mpc86xads.h"
  28. #include "mpc8xx.h"
  29. struct cpm_pin {
  30. int port, pin, flags;
  31. };
  32. static struct cpm_pin mpc866ads_pins[] = {
  33. /* SMC1 */
  34. {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
  35. {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  36. /* SMC2 */
  37. {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */
  38. {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  39. /* SCC1 */
  40. {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */
  41. {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
  42. {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
  43. {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
  44. {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
  45. {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */
  46. {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */
  47. /* MII */
  48. {CPM_PORTD, 3, CPM_PIN_OUTPUT},
  49. {CPM_PORTD, 4, CPM_PIN_OUTPUT},
  50. {CPM_PORTD, 5, CPM_PIN_OUTPUT},
  51. {CPM_PORTD, 6, CPM_PIN_OUTPUT},
  52. {CPM_PORTD, 7, CPM_PIN_OUTPUT},
  53. {CPM_PORTD, 8, CPM_PIN_OUTPUT},
  54. {CPM_PORTD, 9, CPM_PIN_OUTPUT},
  55. {CPM_PORTD, 10, CPM_PIN_OUTPUT},
  56. {CPM_PORTD, 11, CPM_PIN_OUTPUT},
  57. {CPM_PORTD, 12, CPM_PIN_OUTPUT},
  58. {CPM_PORTD, 13, CPM_PIN_OUTPUT},
  59. {CPM_PORTD, 14, CPM_PIN_OUTPUT},
  60. {CPM_PORTD, 15, CPM_PIN_OUTPUT},
  61. /* I2C */
  62. {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  63. {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  64. };
  65. static void __init init_ioports(void)
  66. {
  67. int i;
  68. for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) {
  69. struct cpm_pin *pin = &mpc866ads_pins[i];
  70. cpm1_set_pin(pin->port, pin->pin, pin->flags);
  71. }
  72. cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
  73. cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
  74. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX);
  75. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX);
  76. /* Set FEC1 and FEC2 to MII mode */
  77. clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
  78. }
  79. static void __init mpc86xads_setup_arch(void)
  80. {
  81. struct device_node *np;
  82. u32 __iomem *bcsr_io;
  83. cpm_reset();
  84. init_ioports();
  85. np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr");
  86. if (!np) {
  87. printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n");
  88. return;
  89. }
  90. bcsr_io = of_iomap(np, 0);
  91. of_node_put(np);
  92. if (bcsr_io == NULL) {
  93. printk(KERN_CRIT "Could not remap BCSR\n");
  94. return;
  95. }
  96. clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN);
  97. iounmap(bcsr_io);
  98. }
  99. static int __init mpc86xads_probe(void)
  100. {
  101. unsigned long root = of_get_flat_dt_root();
  102. return of_flat_dt_is_compatible(root, "fsl,mpc866ads");
  103. }
  104. static const struct of_device_id of_bus_ids[] __initconst = {
  105. { .name = "soc", },
  106. { .name = "cpm", },
  107. { .name = "localbus", },
  108. {},
  109. };
  110. static int __init declare_of_platform_devices(void)
  111. {
  112. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  113. return 0;
  114. }
  115. machine_device_initcall(mpc86x_ads, declare_of_platform_devices);
  116. define_machine(mpc86x_ads) {
  117. .name = "MPC86x ADS",
  118. .probe = mpc86xads_probe,
  119. .setup_arch = mpc86xads_setup_arch,
  120. .init_IRQ = mpc8xx_pics_init,
  121. .get_irq = mpc8xx_get_irq,
  122. .restart = mpc8xx_restart,
  123. .calibrate_decr = mpc8xx_calibrate_decr,
  124. .set_rtc_time = mpc8xx_set_rtc_time,
  125. .get_rtc_time = mpc8xx_get_rtc_time,
  126. .progress = udbg_progress,
  127. };