mpc86xads_setup.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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_platform.h>
  18. #include <asm/io.h>
  19. #include <asm/machdep.h>
  20. #include <asm/time.h>
  21. #include <asm/8xx_immap.h>
  22. #include <asm/cpm1.h>
  23. #include <asm/fs_pd.h>
  24. #include <asm/udbg.h>
  25. #include "mpc86xads.h"
  26. #include "mpc8xx.h"
  27. struct cpm_pin {
  28. int port, pin, flags;
  29. };
  30. static struct cpm_pin mpc866ads_pins[] = {
  31. /* SMC1 */
  32. {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
  33. {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  34. /* SMC2 */
  35. {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */
  36. {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  37. /* SCC1 */
  38. {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */
  39. {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
  40. {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
  41. {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
  42. {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
  43. {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */
  44. {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */
  45. /* MII */
  46. {CPM_PORTD, 3, CPM_PIN_OUTPUT},
  47. {CPM_PORTD, 4, CPM_PIN_OUTPUT},
  48. {CPM_PORTD, 5, CPM_PIN_OUTPUT},
  49. {CPM_PORTD, 6, CPM_PIN_OUTPUT},
  50. {CPM_PORTD, 7, CPM_PIN_OUTPUT},
  51. {CPM_PORTD, 8, CPM_PIN_OUTPUT},
  52. {CPM_PORTD, 9, CPM_PIN_OUTPUT},
  53. {CPM_PORTD, 10, CPM_PIN_OUTPUT},
  54. {CPM_PORTD, 11, CPM_PIN_OUTPUT},
  55. {CPM_PORTD, 12, CPM_PIN_OUTPUT},
  56. {CPM_PORTD, 13, CPM_PIN_OUTPUT},
  57. {CPM_PORTD, 14, CPM_PIN_OUTPUT},
  58. {CPM_PORTD, 15, CPM_PIN_OUTPUT},
  59. /* I2C */
  60. {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  61. {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  62. };
  63. static void __init init_ioports(void)
  64. {
  65. int i;
  66. for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) {
  67. struct cpm_pin *pin = &mpc866ads_pins[i];
  68. cpm1_set_pin(pin->port, pin->pin, pin->flags);
  69. }
  70. cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
  71. cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
  72. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX);
  73. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX);
  74. /* Set FEC1 and FEC2 to MII mode */
  75. clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
  76. }
  77. static void __init mpc86xads_setup_arch(void)
  78. {
  79. struct device_node *np;
  80. u32 __iomem *bcsr_io;
  81. cpm_reset();
  82. init_ioports();
  83. np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr");
  84. if (!np) {
  85. printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n");
  86. return;
  87. }
  88. bcsr_io = of_iomap(np, 0);
  89. of_node_put(np);
  90. if (bcsr_io == NULL) {
  91. printk(KERN_CRIT "Could not remap BCSR\n");
  92. return;
  93. }
  94. clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN);
  95. iounmap(bcsr_io);
  96. }
  97. static int __init mpc86xads_probe(void)
  98. {
  99. unsigned long root = of_get_flat_dt_root();
  100. return of_flat_dt_is_compatible(root, "fsl,mpc866ads");
  101. }
  102. static struct of_device_id __initdata of_bus_ids[] = {
  103. { .name = "soc", },
  104. { .name = "cpm", },
  105. { .name = "localbus", },
  106. {},
  107. };
  108. static int __init declare_of_platform_devices(void)
  109. {
  110. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  111. return 0;
  112. }
  113. machine_device_initcall(mpc86x_ads, declare_of_platform_devices);
  114. define_machine(mpc86x_ads) {
  115. .name = "MPC86x ADS",
  116. .probe = mpc86xads_probe,
  117. .setup_arch = mpc86xads_setup_arch,
  118. .init_IRQ = mpc8xx_pics_init,
  119. .get_irq = mpc8xx_get_irq,
  120. .restart = mpc8xx_restart,
  121. .calibrate_decr = mpc8xx_calibrate_decr,
  122. .set_rtc_time = mpc8xx_set_rtc_time,
  123. .get_rtc_time = mpc8xx_get_rtc_time,
  124. .progress = udbg_progress,
  125. };